This is a demo project that shows how to read a light dependent resistor (LDR) on ESP32 with MicroPython.
- ESP32 development board
- A light dependent resistor (LDR)
- 10 KOhm resistor
- Breadboard
- Wires
esptool
for flashing ESP32mpfshell
for uploading files to ESP32minicom
for connecting to ESP32 for debugging purposes
The steps below were tested only on Linux (Ubuntu 18 and 20). This may or may not work in other environments.
The directory scripts
contains scripts that do the job.
Note that some ESP32 development boards require
pressing the EN
button while holding the Boot
button for switching the board to the mode
for erasing or uploading firmware.
First, erase the old firmware on the ESP32:
$ sh scripts/erase.sh
Next, upload MicroPython v1.13:
$ sh scripts/flash.sh
$ sh scripts/verify.sh
Then, upload the code to the board:
$ sh scripts/upload.sh
Finally, you can connect to the board with minicom
and see the measured values of the LDR:
$ sh scripts/minicon.sh
value = 18.92552
value = 18.87668
value = 5.006105
value = 18.63248
...
Try covering the LDR with a hand or putting more light on it. See how the values change.