Automatic dusk-to-dawn light
Lights switch on by themselves at dusk and off again in the morning.
Shop by category
Shop all componentsExtend the smoke alarm into a full safety loop: buzzer, warning lamp and a relay that can cut power or start an exhaust fan. Real safety systems latch: once triggered they stay triggered until a person resets them, because a fire that briefly dips below the threshold is still a fire. The alarmActive flag does exactly that. Note also that the relay stays energised for the whole alarm rather than pulsing, the buzzer flashes for attention, but the exhaust fan must run continuously.
Switch only low-voltage demo loads such as the LED here. Never wire mains to these relay modules in a classroom project.
Every part for this build comes in the Geekobot Explorer Kit box, a Geekobot exclusive, together with the parts for all 61 projects, from a first blinking LED to a smart fan and a reaction game. The wiring below is the kit's own wiring.
Tick anything you already have and the total updates.
The brain of every Explorer Kit project
Male-to-female and female-to-female leads for the modules
LEDs from the kit's red, green, yellow and blue packs (one is the lamp the relay switches)
220 ohm resistors: one in series with every LED segment
16x2 LCD with I2C backpack: four wires, two lines of text
MQ-2 smoke and gas sensor
Nano I/O shield from the kit: every pin has its own S, V, G header, so modules plug in with jumpers
Follow the colours: red is power, dark grey is ground, blue is a signal.
explorer_kit_31_fire_warning.inoVerify & upload in Electrolark#include <Wire.h>
#include <LiquidCrystal_I2C.h>
int gasPin = A0;
int relayPin = 9;
int buzzer = 8;
int redLed = 7;
int greenLed = 6;
int alarmLevel = 400;
bool alarmActive = false;
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
pinMode(relayPin, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
digitalWrite(relayPin, HIGH); // Active LOW relay - load OFF
Serial.begin(9600);
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Fire System");
lcd.setCursor(0, 1);
lcd.print("Warming up...");
delay(20000);
lcd.clear();
}
void loop()
{
int gasLevel = analogRead(gasPin);
Serial.println(gasLevel);
if (gasLevel > alarmLevel)
{
alarmActive = true;
}
lcd.setCursor(0, 0);
lcd.print("Gas: ");
lcd.print(gasLevel);
lcd.print(" ");
lcd.setCursor(0, 1);
if (alarmActive)
{
lcd.print("FIRE! EVACUATE ");
digitalWrite(relayPin, LOW); // Exhaust fan ON
digitalWrite(greenLed, LOW);
digitalWrite(buzzer, HIGH);
digitalWrite(redLed, HIGH);
delay(250);
digitalWrite(buzzer, LOW);
digitalWrite(redLed, LOW);
delay(250);
}
else
{
lcd.print("Status: SAFE ");
digitalWrite(relayPin, HIGH);
digitalWrite(greenLed, HIGH);
digitalWrite(redLed, LOW);
digitalWrite(buzzer, LOW);
delay(500);
}
}
Use the kit's mini-USB cable, install the CH340 driver on Windows if no port appears, pick Tools > Board > Arduino Nano and try Tools > Processor > ATmega328P (Old Bootloader) if the upload times out.
Turn it round: the long leg (anode) goes to the pin side through the 220 ohm resistor, the short leg to GND.
The active buzzer has a + leg: it goes to the pin, the other to GND. Peel off the sticker on top if it has one.
Turn the small contrast pot on the back of the I2C board. If still blank, change 0x27 in the sketch to 0x3F.
Real safety systems latch: once triggered they stay triggered until a person resets them, because a fire that briefly dips below the threshold is still a fire. The alarmActive flag does exactly that. Note also that the relay stays energised for the whole alarm rather than pulsing, the buzzer flashes for attention, but the exhaust fan must run continuously.
Gas: 190 / Status: SAFE with the green LED steady. Introduce smoke: FIRE! EVACUATE, the relay clicks in, the buzzer and red LED pulse. The alarm stays latched until you press the Arduino's reset button.
Yes. It is project 31 of 61 in the Geekobot Explorer Kit, in level 6 (Security and access). Every part on the list comes in the kit box, and you can also buy the parts one by one from the list above.
No. Every Explorer Kit project is wired on the Nano I/O shield and the breadboard with jumper wires.
11 parts: Generic Nano CH340 Development Board (Soldered), USB Cable, Solderless Breadboard, Dupont Jumper Wires (40 pcs), Through-Hole LED Pack (Pack of 10), Carbon Film Resistor 1/4W 5% (Pack of 10), PCB Mounted Active Buzzer Module, LCD1602 16x2 Character LCD Display, 5V Relay Module with Optocoupler, Generic MQ-2 Smoke LPG Butane Hydrogen Gas Sensor Module – 5V Analog/Digital Output, plus 1 more. On this page you can tick the parts you already have and add only the rest to your cart.
It is a intermediate project and takes about 1 hour. The build on this page has 8 steps.
No. This page has the complete, tested code (explorer_kit_31_fire_warning.ino).
About ₹767 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Multi-component safety loops; Latching an alarm so it cannot silently clear; Driving a relay alongside indicators; Separating continuous outputs from flashing ones.
Switch only low-voltage demo loads such as the LED here. Never wire mains to these relay modules in a classroom project.
Lights switch on by themselves at dusk and off again in the morning.
A precise thermostat that keeps tropical fish at a steady 25–26 °C.
Starts the pump when the tank runs low and stops it when it is full.
Tap a hidden pad to switch a lamp on or off, even through a wooden desk.
Learning project. Check every circuit and the datasheet of each part before you power it up.