0% found this document useful (0 votes)
6 views2 pages

GSM

Uploaded by

Sana Emmanuel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

GSM

Uploaded by

Sana Emmanuel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <SPI.

h>
#include <max6675.h>
#include <SoftwareSerial.h>

const int redLED = 2;


const int greenLED = 3;
const int buzzer = 4;

int thermoDO = 10;


int thermoCS = 9;
int thermoSCK = 8;

MAX6675 thermocouple(thermoSCK, thermoCS, thermoDO);

// Configuration du module GSM SIM808


SoftwareSerial sim808(7, 6); // RX, TX
const char* phoneNumber = "+1234567890"; // Numéro de téléphone à appeler

void setup() {
Serial.begin(9600);
sim808.begin(9600);

pinMode(redLED, OUTPUT);
pinMode(greenLED, OUTPUT);
pinMode(buzzer, OUTPUT);

// Initialisation du module GSM


sim808.println("AT");
delay(1000);
sim808.println("AT+CMGF=1"); // Mode texte
delay(1000);
sim808.println("AT+CNMI=2,2,0,0,0"); // Configuration des notifications
delay(1000);
}

void loop() {
float temperature = thermocouple.readCelsius();
Serial.print("Temperature: ");
Serial.println(temperature);

if (temperature < 30) {


digitalWrite(greenLED, HIGH);
digitalWrite(redLED, LOW);
digitalWrite(buzzer, LOW); // Pas de sonnerie
} else {
digitalWrite(redLED, HIGH);
digitalWrite(greenLED, LOW);
digitalWrite(buzzer, HIGH); // Déclencher le buzzer

// Envoyer un message d'alerte


sendAlert();
}

delay(1000);
}

void sendAlert() {
sim808.println("AT+CMGS=\"" + String(phoneNumber) + "\"");
delay(1000);
sim808.println("Alerte ! La température est supérieure à 30°C.");
sim808.write(0x1A); // Envoi du message
delay(1000);
}

You might also like