The RasPiO Analog Zero is an add on ‘hat’ that can be used with any 40 pin Raspberry Pi. This board adds analog input capability to your Raspberry Pi.
About the hat
The main part of the RasPiO Analog Zero is an MCP3008 8 analog to digital converter. This board allows you add various sensors and devices that you could not normally use such as LDRs, potentiometers, voltages and many sensors that output their value as an analog value
Here is a picture of the board after it has been assembled.
Code
Save this with a python .py extension
[codesyntax lang=”python”]
from gpiozero import MCP3008 from time import sleep while True: for x in range(0, 8): with MCP3008(channel=x) as reading: print(x,": ", reading.value) sleep(0.1)
[/codesyntax]
If you want to display a voltage of a channel you would do something like this, again save this example with a .py extension
[codesyntax lang=”python”]
from gpiozero import MCP3008 adc = MCP3008(channel=0) voltage = 3.3 * adc.value print("channel 0 voltage is: ", voltage)
[/codesyntax]
Links
RASPIO ANALOG ZERO (Pack of 3)