Wiring an analog input pin with a voltage source

The easiest way to understand how to read the values from analog pins and map these values back to voltage values is to work with a very simple example. We will connect a power source to one of the analog input pins, specifically a pack with two AA or AAA 1.25 V rechargeable batteries in series. It is also possible to use AA or AAA 1.5 V standard batteries in series. Note that the maximum voltage with the two rechargeable batteries in series will be 2.5 V (1.25 V * 2), while the maximum voltage with the two standard batteries in series will be 3 V (1.5 V * 2).

We will use the analog pin labeled A0 to connect to the positive side (+) of the battery pack. Don't forget that the positive side (+) of ...

Get Internet of Things with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.