1) Via I2C or SPI interface chips
One way of getting the Raspberry GPIO pins to read analog sensor inputs is via I2C or SPI interface chips such as the ones found on the RasPiO Analog Zero board, ADC Pi Plus board, DFRobot 18-Bit ADC board and JeeLabs Analog Plug board, which are Analog to Digital converter boards that use the MCP3008 and MCP3424 chips.
RasPiO Analog Zero board uses the MCP3008 chip and can connect to any 40-pin Raspberry Pi, as well as Raspberry Pi Zero and older 26-pin Raspberry Pi (with the aid of a Downgrade GPIO Ribbon Cable)
Hooking up an RC circuit to the Raspberry Pi is another way to get analog values from the Raspberry Pi by connecting analog sensors to one GPIO pin of the Raspberry Pi. Then, you place a resistor and capacitor in series on a breadboard and connect the breakout wires to PIN1 (3.3V) and PIN6 (Ground) of the Raspberry Pi to create an event where the GPIO pin goes from LOW to HIGH to register a reading. This is done by discharging the capacitor (by setting the GPIO pin LOW as an output) and then, setting the GPIO pin as in input to allow the capacitor to charge to at least 2 volts so the GPIO pin will register HIGH. Here is visually how the Resistor–Capacitor (RC) circuit method works:
3) Analog-to-Digital Converter Integrated Circuit
This third way is similar to the RC charging circuit method above, but it integrates an Analog to digital converter (ADC) chip in the circuit, allowing the Raspberry Pi to be able to read multiple analog signals. To create an ADC integrated circuit that can read multiple sensor inputs all you need is a breadboard, breadboard breakout wires, 10K ohm resistor and a 1uF capacitor, as well as an Analogue-to-digital converter (ADC) like the MCP3008 chip or similar chip that is pin compatible and uses the SPI protocol for successful data communication between the ADC and the Raspberry Pi.
4) Connecting Arduino to the Raspberry Pi
Another alternative to getting analog inputs from the Raspberry Pi would be to connect the Arduino to the Raspberry Pi as Arduino usually has a 10-bit ADC on board. With an Arduino, you would be able to trigger and control in real time potentiometers and many other analog sensors via USB connection without having to program in Arduino’s quasi-C++ language.
While it is great you can use the features and benefits of the Arduino microcontroller, the drawback of using Arduino with your Raspberry Pi to perform analog sampling is that Arduino's serial device name can change every time you connect Arduino to your Raspberry Pi. This means you will have to manually find Arduino's device name every-time and connect via USB which can get annoying.
Constructing a simple RC circuit and ADC circuit is definitely fun though it requires setting up the Raspberry GPIO pins, installing the necessary software and executing Python code which will become more complex the more sensors you add. Of course, you could easily add the sensors in Raspberry Pi Cayenne without having to do any coding.
Still, if you do not like tinkering much with breadboard wires; with a solution like the RasPiO Analog Zero board you can easily control GPIO pins and read analog sensors with very few lines of code because the board is easy to code with RPi.GPIO +Python and GPIO Zero +Raspberry Pi Python libraries so it requires minimal boilerplate code to get started.
2 comments
Can,We read 26 analog input with pi zero
ReplyDeleteCan,We read 26 analog input with pi zero
ReplyDelete