LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsA lux sensor measures how bright light is: an office is about 500 lux, shade outdoors 10,000 and full Indian summer sun over 100,000. The DFRobot RS485 ambient light sensor is fully sealed (IP68), reads up to 200,000 lux and talks Modbus RTU over a long cable, so the ESP32 can stay indoors. Because 200,000 does not fit in one 16-bit register, the value comes in two registers that the sketch joins. RS485 sensors from different makers use different default addresses, baud rates and register numbers. The values in the sketch are typical defaults; check them against the manual that came with your sensor before you rely on the readings.
Seal the indoor end of the cable entry so rain cannot follow the cable in.
Tick anything you already have and the total updates.
DFRobot RS485 waterproof lux sensor, 0-200,000 lux
Follow the colours: red is power, dark grey is ground, blue is a signal.
12 V adapter; buck converter makes 5 V for the ESP32.
rs485_lux.inoVerify & upload in Electrolark#include <ModbusMaster.h>
#include <Adafruit_SSD1306.h>
// From the sensor's manual: address, baud and the register to read
const uint8_t ADDR = 1;
const long BAUD = 9600;
const uint16_t REG = 0x0000; // lux as two registers, high word first, on many sensors
const float SCALE = 1;
ModbusMaster node;
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
const int DE_RE = 4;
void preTx() { digitalWrite(DE_RE, HIGH); }
void postTx() { digitalWrite(DE_RE, LOW); }
void setup() {
Serial.begin(115200);
Serial2.begin(BAUD, SERIAL_8N1, 16, 17); // RX, TX to the MAX3485
pinMode(DE_RE, OUTPUT); postTx();
node.begin(ADDR, Serial2);
node.preTransmission(preTx);
node.postTransmission(postTx);
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
}
void loop() {
uint8_t r = node.readHoldingRegisters(REG, 2);
oled.clearDisplay(); oled.setTextColor(WHITE); oled.setTextSize(2); oled.setCursor(0, 10);
if (r == node.ku8MBSuccess) {
uint32_t lux = ((uint32_t)node.getResponseBuffer(0) << 16) | node.getResponseBuffer(1);
oled.print(lux); oled.println(" lx");
Serial.println(lux);
} else {
oled.setTextSize(1); oled.print("No reply, code "); oled.print(r, HEX);
}
oled.display();
delay(2000);
}
Check the address, baud and A/B wires; swapping A and B is the most common fix.
Timeout or bad frame: the baud rate is wrong or DE/RE is not wired to GPIO4.
The word order is swapped or a different register holds lux; check the manual and swap the two buffers.
It gives a good idea of sunny hours; a panel's output also depends on angle and temperature.
No, PAR counts the light plants use; lux is a fair rough guide for comparing spots.
RS485 works over hundreds of metres with twisted pair cable.
8 parts: DFRobot RS485 Waterproof Ambient Light Sensor (0-200,000 Lux) – IP68 Submersible, Modbus-RTU, MAX3485 TTL to RS485 Converter Module – 3.3V Logic, ESP32-WROOM-32 38-Pin Development Board, 0.96" OLED Display 128x64, Step-Down Converter to 5V USB / 5V 3A, DC Power Adapter (5.5x2.1mm), Solderless Breadboard and Dupont Jumper Wires (40 pcs). On this page you can tick the parts you already have and add only the rest to your cart.
No. This page has the complete, tested code (rs485_lux.ino).
About ₹2,303 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Lux levels indoors and outdoors; Joining two 16-bit Modbus registers into one 32-bit value; Logging over long RS485 cables.
Seal the indoor end of the cable entry so rain cannot follow the cable in.
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
See the smoke level live on a crisp screen and get a loud warning when it spikes.
An infrared eye that spots an open flame and raises the alarm.
Walk into the room and it sounds the alarm: the classic first security build.
Lessons are free to read. Maker (₹499/month) and Pro add quizzes, worked problems and certificates, paid with your Geekobot account. See plans
Learning project. Check every circuit and the datasheet of each part before you power it up.