In this tutorial, we’ll see how to read data from a light analog sensor and print them to the serial monitor in a visual way.
Of course, we’ll use Zerynth Studio to program the microcontroller-based board in Python.
Zerynth simplifies and speeds up IoT development allowing programming in Python or hybrid C/Python the most popular 32-bit microcontrollers and connecting them to the leading Cloud Infrastructures like AWS, Google Cloud, Microsoft Azure, IBM Watson, Ubidots, and many more.
- First of all, you need a board. You can select one of the 32-bit microcontroller devices supported by Zerynth. We’ve chosen the ESP32-DevkitC by Espressif (read Zerynth documentation here).
- You also need an Analog LightSensor: we’ve chosen the ALS-PT19 by Adafruit.
Last but not least, you need:
- Zerynth Studio, a powerful IDE for embedded programming in Python that enables the IoT. You can download it here.
Connect the analog light sensor to the ESP32-DevkitC as follows:
- Sensor ‘-‘ pin to board GND
- Sensor ‘+’ pin to board 3V3
- Sensor ‘out’ pin to board A4
Then, clone and uplink the Zerynth example “Analog to Digital Voltage Conversion” as shown in the video. If you want to view the data in a visual way, you can clone and uplink the Zerynth example “Oscilloscope”. For both the examples, you need to define the actual analog pin attached to the sensor. In this case, you need to set:
inputAnalog = A4
Place your hand on the analog sensor to see the brightness data changing and enjoy!
Take a look at the code.
Analog Read To Voltage
Download Zerynth Studio
Now that you have seen that this is quite a simple process, you can download Zerynth Studio and try it out for yourself.