Arduino UNO and Sim800l GSM-Based Temperature Monitoring System with DS18B20 Sensors
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to read temperature data from three DS18B20 temperature sensors and send the data via text message using the Sim800l GSM module. The circuit is controlled by an Arduino UNO microcontroller, which interfaces with the sensors and the GSM module. A rocker switch and a 12V battery are used to power the circuit.
Component List
Arduino UNO
- Description: Microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
Sim800l
- Description: GSM/GPRS module for sending and receiving SMS and data.
- Pins: NET, RST, VCC, RXD, TXD, GND
DS18B20
- Description: Digital temperature sensor.
- Pins: signal, GND, vcc
Rocker Switch
- Description: Switch to control the power supply.
- Pins: output, input
Battery 12V
- Description: 12V power supply.
- Pins: +, -
Wiring Details
Arduino UNO
- 5V: Connected to VCC of DS18B20 sensors and Sim800l.
- GND: Connected to GND of DS18B20 sensors, Sim800l, and the negative terminal of the 12V battery.
- Vin: Connected to the output of the rocker switch.
- A0: Connected to the signal pin of the first DS18B20 sensor.
- A1: Connected to the signal pin of the second DS18B20 sensor.
- A2: Connected to the signal pin of the third DS18B20 sensor.
- D10: Connected to TXD of the Sim800l.
- D11: Connected to RXD of the Sim800l.
Sim800l
- VCC: Connected to 5V of the Arduino UNO.
- GND: Connected to GND of the Arduino UNO.
- RXD: Connected to D11 of the Arduino UNO.
- TXD: Connected to D10 of the Arduino UNO.
DS18B20 (First Sensor)
- vcc: Connected to 5V of the Arduino UNO.
- GND: Connected to GND of the Arduino UNO.
- signal: Connected to A0 of the Arduino UNO.
DS18B20 (Second Sensor)
- vcc: Connected to 5V of the Arduino UNO.
- GND: Connected to GND of the Arduino UNO.
- signal: Connected to A1 of the Arduino UNO.
DS18B20 (Third Sensor)
- vcc: Connected to 5V of the Arduino UNO.
- GND: Connected to GND of the Arduino UNO.
- signal: Connected to A2 of the Arduino UNO.
Rocker Switch
- output: Connected to Vin of the Arduino UNO.
- input: Connected to the positive terminal of the 12V battery.
Battery 12V
- +: Connected to the input of the rocker switch.
- -: Connected to GND of the Arduino UNO.
Code Documentation
/*
* This Arduino Sketch reads data from three DS18B20 temperature sensors
* and sends the data via text message using the Sim800l GSM module.
*/
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SoftwareSerial.h>
// Pin configuration for DS18B20 sensors
#define ONE_WIRE_BUS_A0 A0
#define ONE_WIRE_BUS_A1 A1
#define ONE_WIRE_BUS_A2 A2
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWireA0(ONE_WIRE_BUS_A0);
OneWire oneWireA1(ONE_WIRE_BUS_A1);
OneWire oneWireA2(ONE_WIRE_BUS_A2);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensorsA0(&oneWireA0);
DallasTemperature sensorsA1(&oneWireA1);
DallasTemperature sensorsA2(&oneWireA2);
// Pin configuration for GSM module
SoftwareSerial gsmSerial(10, 11); // RX, TX for GSM module
void setup() {
// Start serial communication
Serial.begin(9600);
gsmSerial.begin(9600);
// Start up the library for sensors
sensorsA0.begin();
sensorsA1.begin();
sensorsA2.begin();
// Send SMS to confirm system startup
sendSMS("System started. Temperature monitoring enabled.");
}
void loop() {
// Request temperature readings from all sensors
sensorsA0.requestTemperatures();
sensorsA1.requestTemperatures();
sensorsA2.requestTemperatures();
// Fetch temperature readings
float tempA0 = sensorsA0.getTempCByIndex(0);
float tempA1 = sensorsA1.getTempCByIndex(0);
float tempA2 = sensorsA2.getTempCByIndex(0);
// Print temperature readings to serial monitor
Serial.print("Sensor A0: "); Serial.print(tempA0); Serial.println(" °C");
Serial.print("Sensor A1: "); Serial.print(tempA1); Serial.println(" °C");
Serial.print("Sensor A2: "); Serial.print(tempA2); Serial.println(" °C");
// Send temperature readings via SMS
String message = "Temp A0: " + String(tempA0) + " °C\n" +
"Temp A1: " + String(tempA1) + " °C\n" +
"Temp A2: " + String(tempA2) + " °C";
sendSMS(message);
// Wait for 10 minutes before next reading
delay(600000);
}
// Function to send SMS using GSM module
void sendSMS(String message) {
gsmSerial.println("AT+CMGF=1"); // Set SMS mode to text
delay(1000);
gsmSerial.println("AT+CMGS=\"+918454044438\""); // Replace with predefined contact
delay(1000);
gsmSerial.print(message);
delay(1000);
gsmSerial.write(26); // Send CTRL+Z to indicate the end of the message
delay(5000);
}
This code initializes the DS18B20 sensors and the Sim800l GSM module, reads temperature data from the sensors, and sends the data via SMS at regular intervals. The sendSMS function is used to send text messages using the GSM module.