ESP32: measure ambient light with the BH1750 lux sensor
Wire a BH1750 to an ESP32 over I2C and get real lux readings instead of a raw ADC number. The light sensor that works out of the box.
Tag
117 tutorials
Wire a BH1750 to an ESP32 over I2C and get real lux readings instead of a raw ADC number. The light sensor that works out of the box.
The ESP32 ADC is noisy and 12-bit. The ADS1115 gives you 16-bit, 4-channel, differential readings over I2C for $4.
The BME680 reads temperature, humidity, pressure, AND volatile organic compounds (VOC) from air quality, over one I2C bus.
Turn a $8 load cell into a working digital scale with the HX711 amp and an ESP32. Calibration, tare, and the wiring that gets 1g resolution.
Send push notifications from an ESP32 to your phone with ntfy.sh. One HTTP POST, no cloud account, and the server can live on your own Raspberry Pi.
Send email straight from an ESP32 over SMTP with STARTTLS. Works with your own mail server or any provider, no third-party IoT API.
PIR sensor triggers the ESP32-CAM, which captures a JPEG and pushes it to your phone over ntfy. Self-hosted security camera, no cloud.
Wire a $3 INMP441 MEMS mic to the ESP32 and capture real audio over I2S. The hardware path to sound detection, voice notes, and wake words.
Stream live video from an ESP32-CAM to any browser on your Wi-Fi. MJPEG over HTTP, the pattern behind every DIY security camera.
Add two servos to the ESP32-CAM and aim the camera from a web page. The streaming camera that looks where you look, for $12 more.
Wire the $3 MFRC522 RFID reader to an ESP32 over SPI and build the tap-to-unlock pattern: card UID list, relay output, event logging.
Drive a 2.9-inch e-ink panel with an ESP32: crisp static text, months on a battery, and the refresh rules that keep the panel alive.
Turn the ESP32-CAM into a QR code scanner: on-board decode with the quirc library, valid-code list, relay output for the door strike.
Go past basic ADS1115 single-ended reads: differential inputs for bridge sensors, the PGA gain math, and a data-rate benchmark you can run yourself.
Wire an APDS9960 to an ESP32 and read swipes, hand distance, and ambient color over I2C. One $4 sensor, three sensors inside, plus the level-shifter trap.
Compare EMQX and HiveMQ free tiers against Mosquitto on a Raspberry Pi, wire an ESP32 to each, and pick the right broker for your home.
Clamp an SCT-013 current transformer around your main feed, read real AC current on the ESP32, and convert it to watts with the burden-resistor math.
Track BME680 gas resistance over days, survive the 48-hour burn-in, and publish air quality trends over MQTT so your room gets a real baseline, not a guess.
PIR motion triggers the ESP32-CAM to capture a JPEG and email it as an SMTP attachment with STARTTLS. The alert channel that works with any mail account, no app install.
Generate real analog tones, ramps, and waveforms on the ESP32's true 8-bit DAC pins (GPIO25/26), from a beep to a sine sweep.
Run the ESP32's built-in face detection model on the ESP32-CAM with ESP-WHO: detect faces in real time, no cloud, no external server, with human detection as a fallback.
Wire a NEO-M8N GPS module to an ESP32 over serial, parse NMEA for position and UTC time, and understand why your first fix takes minutes.
Wire an ESP32 sensor into a self-hosted Home Assistant: flash it with ESPHome from the HA UI, or run native firmware and publish MQTT discovery. Both paths, one tutorial.
Wire the MAX98357A I2S amplifier to an ESP32 and play WAV data from flash or an internet stream. The talking-device pattern that pairs with the INMP441 microphone tutorial.
Three ways to push an ESP32-CAM photo through ntfy: raw JPEG attachment, captioned image, and thumbnail with a link. With the header semantics that make each one work.
Write ESP32 sensor readings straight into a self-hosted InfluxDB over HTTP with line protocol. Time-series storage on your Pi, graphed by Grafana, no cloud in the middle.
Build an ESP32 IR blaster that replays remote codes to control a TV or AC unit over the network. Pairs with the IR receiver tutorial to capture the codes first.
Wire the RCWL-0516 microwave radar to an ESP32 and detect motion through walls and plastic. Doppler sensing with Wi-Fi reporting, deep sleep, and ntfy alerts.
Measure up to 600 C with a K-type thermocouple and MAX6675 amplifier on an ESP32. Wiring, the 220ms update gotcha, and when to upgrade to a MAX31855.
Build an ESP32 web-server IR blaster with a page of buttons for TV, soundbar, and AC. Capture codes with the IR receiver, replay them over Wi-Fi from any browser.
Write timestamped CSV data from ESP32 sensors to a microSD card. FAT file basics, real timestamps, daily file rotation, and the flush pattern that survives power cuts.
Drive a 320x240 ILI9341 touch display with LVGL 9 on an ESP32. Real widgets, buttons that work, and the two-task structure that keeps drawing and touch alive.
Read real state-of-charge from a LiPo with the MAX17048 fuel gauge over I2C. Percent, voltage, and charge rate instead of a voltage lookup table.
Wire an analog microphone module (MAX4466 or LM393 sound sensor) to the ESP32's ADC and build an RMS sound level meter for clap triggers and noise logging.
The ESP32 loses half its ADC pins the moment Wi-Fi turns on. Add 8 clean analog inputs with a $4 MCP3008 over SPI: wiring, real pins, and a full 8-channel sketch.
Turn a $1 NTC thermistor and a 10K resistor into an ESP32 temperature sensor: divider math, analogReadMilliVolts to dodge ADC nonlinearity, and the beta equation.
Get real wall-clock time on the ESP32 over NTP: settimeofday, the TZ string that handles DST for you, and a self-hosted angle pointing at your own router or a Pi.
Read your utility meter's blinking LED with an ESP32 photoresistor and count real kWh: interrupt pulse counting, kWh math, and MQTT for a live whole-house power figure.
Wire a GPS, GSM, or second microcontroller to the ESP32 over UART2, with working pins, the TX/RX cross, and non-blocking code that parses what comes back.
Add username and password login to an ESP32 web server with session cookies, random tokens, and logout. Self-hosted, no third-party identity provider, honest limits stated.
Wire an ST7735 or ST7789 color TFT to an ESP32, draw text and shapes, update a live readout without flicker, and fix the classic black-screen and wrong-color problems.
Give an ESP32 a fixed IP with WiFi.config(), reserve it in your router with a DHCP reservation, and stop hunting the network for a device that moved.
Use the ESP32's hardware timers for interrupt-driven timing, understand why millis() and delay() drift under load, and stop your blinking LED from wandering.
Wire the analog TDS sensor module to an ESP32, convert ADC counts to ppm with temperature compensation, and calibrate against a known solution instead of guessing.
Put HTML, CSS, and JavaScript files on the ESP32's flash with LittleFS and serve them with WebServer. No more escaping quotes inside C++ strings.
Build a real HTTP API on the ESP32. Route by path, handle GET vs POST, parse JSON bodies, serve JSON responses, and use async handlers when the request rate goes up.
Stop guessing why the firmware crashes. Set breakpoints, step through code, inspect registers, with JTAG + OpenOCD + GDB. The right tool when print debugging fails.
When the Serial.print tells you nothing, the I2C bus tells you everything. Pick a $10 clone or a $400 Saleae, install Sigrok and PulseView, decode I2C/SPI/UART.
Use the Preferences library to save and load settings that survive power cycles on the ESP32. Wi-Fi credentials, calibration values, and the blob storage pattern for larger data.
The MITM attack on unsigned OTA, why HTTPS alone does not save you, and the signed-update pattern that closes the loop. With anti-rollback and key rotation.
Read a scope like you read a multimeter. Volts per div, time per div, AC vs DC coupling, what bandwidth actually buys you, and how to measure PWM duty cycle.
Wire a WS2812B addressable RGB LED strip to an ESP32, drive it with the RMT peripheral and the FastLED library, and avoid the 800-LED limit and the always-on power math.
Use RTC_DATA_ATTR to keep state across deep sleep on the ESP32. Boot counters, last-known sensor values, and the gotcha that it does not survive a power cycle.
Burn efuses, sign firmware, and lock the flash so a stolen ESP32 cannot be cloned. The right way to ship an ESP32 product instead of a hobby board.
Move past setInsecure() and the WiFiClientSecure default that ships in every HTTPS example. Bundle root CAs, validate chains, and pin fingerprints on the ESP32.
Every packet your ESP32 sends over WiFi goes through a TCP socket. Three-way handshake, WiFiClient, WiFiServer, the stuck connection gotcha, TCP_NODELAY.
Build a WebSocket server on the ESP32 with ESPAsyncWebServer. Push sensor readings to a browser at 10 Hz without polling, with the ping/pong heartbeat that keeps the connection alive.
Build a single ESP32 + SX1278 LoRa gateway that bridges off-grid LoRa packets to your home Wi-Fi MQTT broker. Sender subscribes, receiver publishes, one channel only, and a real gateway disclosure.
Flash Meshtastic on an ESP32 + LoRa board and you have an off-grid text messaging device with mesh routing, encryption, and battery-friendly operation. No SIM card, no monthly bill, no account.
Wire two ESP32 boards to SX1278 LoRa modules and send packets between them with no Wi-Fi, no internet, no gateway. The wiring, the Sandeep Mistry library, sender code, receiver code, and the urban range truth.
Set up the Arduino IDE for ESP32 the way that does not break six months from now. Boards manager URLs, USB drivers, and the port detection traps.
The BOOT button on most ESP32 boards is not a reset button. It puts the chip in download mode. Here is what that means and why you keep needing it.
Use the ESP32's 12-bit ADC to read a potentiometer or analog sensor. Includes the ADC2 vs Wi-Fi trap and the input-only pin caveat.
Make the ESP32 show up as a Bluetooth device that a phone can see and connect to. The foundation for any BLE-based IoT project.
Use the ESP32's LEDC hardware to generate PWM on any GPIO. The right way to dim LEDs, drive servos, and control motor speed.
Wire a hobby servo to an ESP32 using the LEDC peripheral. The right way to control an SG90 or MG996R without the Servo.h library.
Wire a NEMA 17 stepper motor to an ESP32 using the A4988 stepper driver. The right call for real torque and precise positioning.
Make the ESP32 read data from BLE devices like heart rate straps, temperature sensors, and beacons. The reverse of the peripheral tutorial.
Make the ESP32 talk to real APIs over HTTPS, with proper TLS validation. The right way to send sensor data to a cloud service.
Wire a single 18650 cell to an ESP32 using the TP4056 charge controller. The minimum circuit for any battery-powered ESP32 project.
When to use a $5 dev board and when to drop down to the bare ESP32 module. The tradeoffs that matter for battery, size, and cost.
Wire an MQ-2 gas sensor to an ESP32 and read combustible gas concentrations. Important caveats about what MQ sensors can and cannot tell you.
Wire a 3-pin IR receiver module to an ESP32 and decode remote control signals. Use any TV remote, AC remote, or cheap IR remote as a wireless input.
Wire a PIR motion sensor (HC-SR501) to an ESP32 and detect people moving in a room. The foundation for security, automation, and wake-on-motion projects.
Wire a capacitive soil moisture sensor to an ESP32 and read soil moisture as a percentage. Skip the resistive sensor; it corrodes and lies.
Wire an ACS712 current sensor module to an ESP32 and measure DC current in amps. The right way to monitor power consumption of battery devices.
Wire a BH1750 light sensor to an ESP32 and measure ambient light in real lux units. The right sensor for daylight sensing, plant monitoring, and screen brightness.
Wire a BME280 to an ESP32 over I2C and stream temperature, humidity, and barometric pressure. Better than the DHT22 for anything weather-related.
Wire one or many DS18B20 temperature sensors to a single ESP32 GPIO pin. Multiple sensors, one wire, accurate to 0.5 C.
Wire an MPU6050 to an ESP32 and read acceleration and rotation rate in three axes. The sensor you need for robots, drones, and motion tracking.
How to read and write the ESP32's GPIO pins, when to use the internal pull-ups, and the input-only pins that catch everyone once.
Use a piezo buzzer with an ESP32 to play tones, melodies, and alarm sounds. The LEDC peripheral does this in hardware, with no CPU overhead.
Use a relay module with an ESP32 to switch mains-powered devices. The hardware safety boundaries and why opto-isolated modules matter.
Use a 2N2222 NPN transistor to switch a load that draws too much current for a GPIO pin. Pumps, fans, LED strips, solenoids.
Wire a 128x64 OLED display (SSD1306) to an ESP32 and draw text, graphics, and sensor graphs. Smaller and brighter than the 16x2 LCD.
Wire a 16x2 character LCD (HD44780 with the PCF8574 I2C backpack) to an ESP32 and show text. The right display for showing sensor readings and menus.
Build a multi-hop Wi-Fi network with multiple ESP32 boards. Self-healing, automatic routing, no central router needed.
Send messages between ESP32 boards directly, without Wi-Fi infrastructure. Up to 250 bytes per packet, up to 20 peers, range of 200m+ line of sight.
Replace IP addresses with friendly names like 'kitchen-sensor.local'. mDNS is built into the ESP32 and most operating systems.
Make the ESP32 broadcast its own Wi-Fi network and serve a configuration page. The right pattern for projects that need Wi-Fi credentials but have no keyboard.
Use the HLK-PM01 isolated mains-to-5V module to power an ESP32 from a wall outlet. The safer alternative to wiring a 5V phone charger inline.
Power an ESP32 from a USB battery bank. The hidden auto-shutoff feature that turns off most battery banks after 30 seconds with low-current loads.
Add a supercapacitor to your ESP32 project so it can detect a power loss and shut down gracefully. The minimum circuit for industrial-grade deployments.
Soil moisture sensor + 12V water pump + ESP32 = a plant monitor that waters your plant when the soil gets dry. Solar-powered for outdoor use.
Add a small solar panel to your 18650 battery setup for perpetual operation. The math for sizing the panel and the protection circuit you actually need.
A complete weather station: BME280 over I2C, ESP32 web server, deep sleep between readings. Battery-powered, weatherproof case, web dashboard.
The complete home sensor network: ESP32 publishes to MQTT, Raspberry Pi runs Node-RED and a dashboard. Multiple sensors in multiple rooms.
BME280 + MQ-2 + MQ-135 + ESP32 + OLED = a complete indoor air quality monitor. Temperature, humidity, CO2 equivalent, and combustible gas.
ESP32-CAM with PIR motion sensor, SD card storage, and solar power. Captures images when motion is detected and stores them on the SD card.
Two DC motors, an L298N motor driver, an ESP32, and ultrasonic distance sensors. The base you build a robot on top of.
Press a button, get a notification on your phone. The ESP32 + Pushover (or Telegram) + a simple button. Replaces a $50 smart doorbell.
Run out of GPIO on your ESP32? The MCP23017 adds 16 GPIO pins over I2C using only 2 wires. Multi-platform code for ESP32, Arduino, Pico, and Pi.
Wire a MAX7219 to an ESP32 to drive an 8-digit 7-segment display over SPI. The right pick for showing sensor numbers, counters, or clocks.
Add 8 output pins to your ESP32 using only 3 GPIO pins and a 74HC595 shift register. For LEDs, relay arrays, and 7-segment without a driver.
When the ESP32's LEDC peripheral is not enough, the TLC5940 adds 16 channels of 12-bit PWM over SPI. The right pick for big LED projects.
Get 5V, 9V, 12V, 15V, or 20V out of any USB-C charger with a FUSB302 or HW-715 trigger board. The right power source when you need 12V from a USB-C brick.
Wire a LiPo battery to an ESP32 with a TP4056 or MCP73831 charger. The safer alternative to 18650 for projects that get handled or carried.
Wire a button to an ESP32 and write the debounce code that keeps your state from flickering. Includes the pattern I use in every project.
Update ESP32 firmware over Wi-Fi without plugging in USB. The feature that turns a project from prototype into something you actually deploy.
The ESP32 has 10 capacitive touch pins that work without any extra hardware. Wire a piece of foil and you have a button.
Wire an HC-SR04 to an ESP32 and measure distance in centimeters. The sensor that goes into most of my robotics projects.
The minimum code to bring up Wi-Fi on an ESP32, with reconnect logic and the most common reasons it silently fails.
Send sensor data over MQTT from an ESP32 to a broker, and subscribe from another device. The pub/sub pattern that runs most home automation.
Put an ESP32 into deep sleep and measure the actual current draw with a multimeter. Includes what to expect on different boards and battery chemistries.
Wire a strip of WS2812B LEDs to an ESP32 and drive colors, brightness, and animations from Arduino code. The classic ESP32 eye-candy project.
Turn your ESP32 into a tiny web server that shows live sensor readings on any phone or laptop on the same Wi-Fi. No cloud, no app.
Wire a DHT22 to an ESP32, install the library, and stream readings over Serial every 2 seconds. The shortest useful ESP32 project.