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.

Required Material

  • 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.

Assembling

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

Programming

Once you have installed Zerynth Studio and created a Zerynth user, you have to register and virtualize the board.

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!

Code

Take a look at the code.

Analog Read To Voltage

Copy to Clipboard

Oscilloscope

Copy to Clipboard

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.

Share This Story, Choose Your Platform!

About the Author: Luigi F. Cerfeda

Luigi is a biomedical engineer, and is currently Sales Director at Zerynth. Being one of the first members on the team, he has held various roles in the company as he has a deep knowledge of the IoT market and Industry 4.0.

Follow Zerynth on

Latest Posts