Voltage Sensor =============== .. image:: Images/voltagesensor.jpg :align: center There are many applications for the voltage sensor, such as measuring battery levels (Voltage), estimating battery life, tracking solar power generation or even to measure how many power consumption is being used by the raspberry pi. This module allows you to measure voltages of 0-25V. .. warning:: Before proceeding with this sensor, you will need to learn about the :ref:`mcpadc`. Connecting the Sensor ---------------------- .. image:: Circuits/voltagesensor-nopi.jpg :align: center Inputs: - **GND**: Connected to the low side of the voltage you are measuring. - **VCC**: Connected to the high side of the voltage you are measuring Outputs - S: Connected to your MCP analog input. - '-' (or minus): Connected to the ground. - '+': not connected. Note that the voltage sensor is an analog sensor and cannot be connected directly to the Raspberry Pi pins. It needs an analog to digital converter, MCP3008 in this case, in order to collect proper data. Full circuit: .. image:: Circuits/voltagesensor.jpg :align: center Python Program to Read Voltage ------------------------------- .. literalinclude:: Code/voltagesensor.py :linenos: :language: python