Introduction of IOT Smoke Detector Project
Introduction of IOT Smoke Detector Project
Sofware specifications:
Arduino IDE software is used to develop the
embedded C language code for IOT based Smoke
detector using Arduino.
EAGLE PCB Layout software is used to design the
PCB layout of the IOT based Smoke detector
project.
Any IOT platform or IOT website that can display
the values of the smoke sensor in Graphical
format.
CODE:
#include <Wire.h>
#define SMOKE_SENSOR_PIN A0
#define GAS_SENSOR_PIN A1
WiFiClient espClient;
PubSubClient client(espClient);
void setup_wifi() {
delay(10);
Serial.println();
Serial.print("Connecting to ");
Serial.println(WIFI_SSID);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
delay(500);
Serial.print(".");
Serial.println("");
void reconnect() {
while (!client.connected()) {
Serial.println("connected");
client.subscribe("smoke_gas_detector");
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
delay(5000);
}
void setup() {
Serial.begin(9600);
setup_wifi();
client.setServer(MQTT_SERVER, MQTT_PORT);
client.setCallback(callback);
void loop() {
if (!client.connected()) {
reconnect();
client.loop();
Serial.println(smokeValue);
Serial.println(gasValue);
char gasMsg[20];
client.publish("smoke_gas_detector/smoke", smokeMsg);
client.publish("smoke_gas_detector/gas", gasMsg);