Skip to the content.

Sensor Hardware V1

All of the code used to program the ESP32 boards is in the project esp32_sunlight_sensor.

This was my first embedded software project, so this document is as much as a description of the learning process as a reference for the actual hardware.

Components

I started putting together the first version of the sensor hardware with the cheapest ESP32 board that I thought would meet my needs. I bought the ESP32 DEVKIT V1.1 - DOIT from DIYMALL via Amazon.

Top view of the ESP32 DEVKIT V1.1 - DOIT development board.  Roughly an inch by 2 inches.
ESP32 DEVKIT V1.1 - DOIT
Back of ESP32 DEVKIT V1.1 - DOIT development board.
Back of ESP32 DEVKIT V1.1 - DOIT

For the light sensor, I used a BH1750FVI type with a light diffusion dome. [Amazon]

Back of the BH1750FVI light sensor, showing the silk-screened labels.  About 1 inch in diameter.
BH1750FVI light sensor
Light sensor module view showing the board under the diffusion dome.
BH1750FVI light sensor with diffusion dome removed

For light readout, I used a small LED screen. [Amazon]

Image of the LED screen, not yet hooked up to anything.  Approximately an inch by an inch and a half.
LED screen for light readout

Flashing LED Test

The first thing I did was test that the ESP32 board was functional with a flashing LED test.

Video of the Flashing LED Test

Here it is sketched up in Fritzing, a great tool for drawing electronic diagrams if you are just learning about electronics, since it lets you switch between semi-realistic and schematic views.

A diagram of the connections between the ESP32 board and the LED on a half-breadboard for the flashing LED test.
Fritzing diagram for flashing LED test

Light Sensor and LED Screen

The second step was to introduce the light sensor and the LED screen. in that order. I made sure that the light sensor was working by watching the device monitor output on my computer. With the LED screen, you can see the output displayed continuously without hooking it up to your computer. One thing that was great about this combination of hardware is that I could wire them all in parallel to the I2C ports and I didn’t have to do much research into how to hook them up beyond that.

Fritzing Sketch

A diagram showing the connections between the ESP32 board, the light sensor, and the LED screen on a mini-breadboard.
Fritzing diagram for light sensor and LED screen

Light Sensor and LED Screen Test

I used my bike headlight and its various illumination levels to test that the LED screen reflected the sensor output. In the video clips my phone camera is trying to compensate for the rapidly changing light levels, so it looks a little weird, but the screen display did not blink as it does in the video, and the output on the LED reflected the sensor input.

Video of LED screen and light sensor test

WiFi

The next step was to send sensor output to the cloud via WiFi. This is where I ran into a problem. Even though this ESP32 development board clearly has a connector which will accept an external antenna, it is disabled. There is a small resistor on the board which forces the board to use its PCB antenna. I wasn’t able to connect to anything except when I put my phone hotspot within a couple of feet of the board. I was afraid that in removing the resistor I might destroy the board, so I decided to do some more research on the ESP32 board types and get one compatible with an external antenna.

Continue with Sensor Hardware V2