Unlike the Beaglebone Black, which has endless analog inputs/outputs, all 17 GPIO pins on the Raspberry Pi are digital pins. The practiced tidings is that at that topographic point are a few ways to convert analog betoken to digital hence the Raspberry Pi tin forcefulness out read multiple analog input sensors:
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 equally the ones industrial plant life 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 role the MCP3008 and MCP3424 chips.
The ADC Pi Plus, DFRobot in addition to JeeLabs ADC boards role the MCP3424 chip, which provides 4 differential analog inputs for Raspberry Pi via I2C motorcoach interface also equally configurable sampling rates in addition to resolutions. All the way from 240 samples per instant (12-bits resolution) to threescore samples per instant (14-bits resolution), fifteen samples per instant (16-bits resolution) in addition to 3.75 samples per instant (18-bits resolution).
RasPiO Analog Zero board uses the MCP3008 chip in addition to tin forcefulness out connect to whatsoever 40-pin Raspberry Pi, also equally Raspberry Pi Zero in addition to older 26-pin Raspberry Pi (with the help of a Downgrade GPIO Ribbon Cable)
Using a cook made ADC board such equally the ones mentioned inwards a higher house would definitely hold upwards the easiest way out to perform analog sampling amongst your Raspberry Pi. The meliorate pick for Raspberry Pi analog signalling would belike hold upwards the RasPiO Analog Zero board because it does non require whatsoever software installation to larn the board reading 8 Sensors similar a shot on the Raspberry Pi, plus the Analog Zero board features a 54-pin prototyping expanse in addition to GPIO breakouts amongst enough of ability in addition to solid set down connections where you lot tin forcefulness out set additional components.
2) Resistor–Capacitor (RC) Charging Circuit
Hooking upwards an RC circuit to the Raspberry Pi is about other way to larn analog values from the Raspberry Pi yesteryear connecting analog sensors to 1 GPIO pivot of the Raspberry Pi. Then, you lot house a resistor in addition to capacitor inwards series on a breadboard in addition to connect the breakout wires to PIN1 (3.3V) in addition to PIN6 (Ground) of the Raspberry Pi to do an outcome where the GPIO pivot goes from LOW to HIGH to register a reading. This is done yesteryear discharging the capacitor (by setting the GPIO pivot LOW equally an output) in addition to then, setting the GPIO pivot equally inwards input to permit the capacitor to accuse to at to the lowest degree ii volts hence the GPIO pivot volition register HIGH. Here is visually how the Resistor–Capacitor (RC) circuit method works:
3) Analog-to-Digital Converter Integrated Circuit
This 3rd way is similar to the RC charging circuit method above, only it integrates an Analog to digital converter (ADC) chip inwards the circuit, allowing the Raspberry Pi to hold upwards able to read multiple analog signals. To do an ADC integrated circuit that tin forcefulness out read multiple sensor inputs all you lot need is a breadboard, breadboard breakout wires, 10K ohm resistor in addition to a 1uF capacitor, also equally an Analogue-to-digital converter (ADC) similar the MCP3008 chip or similar chip that is pivot compatible in addition to uses the SPI protocol for successful information communication betwixt the ADC in addition to the Raspberry Pi.
The MCP3008 chip is dandy to role because it alone requires 4 GPIO pins on the Raspberry Pi P1 Header in addition to volition hand you lot 8 channels to sample analog inputs simultaneously. The 4 GPIO pins of the Raspberry Pi that you lot volition need for communicating amongst the MCP3008 are the cobbler pins labeled equally MISO, MOSI, SCLK in addition to CE0 (or CE1).
4) Connecting Arduino to the Raspberry Pi
Another choice to getting analog inputs from the Raspberry Pi would hold upwards to connect the Arduino to the Raspberry Pi equally Arduino ordinarily has a 10-bit ADC on board. With an Arduino, you lot would hold upwards able to trigger in addition to command inwards existent fourth dimension potentiometers in addition to many other analog sensors via USB connectedness without having to programme inwards Arduino’s quasi-C++ language.
While it is dandy you lot tin forcefulness out role the features in addition to benefits of the Arduino microcontroller, the drawback of using Arduino amongst your Raspberry Pi to perform analog sampling is that Arduino’s series device shout out tin forcefulness out alter every fourth dimension you lot connect Arduino to your Raspberry Pi. This agency you lot volition convey to manually detect Arduino’s device shout out every-time in addition to connect via USB which tin forcefulness out larn annoying.
Constructing a uncomplicated RC circuit in addition to ADC circuit is definitely fun though it requires setting upwards the Raspberry GPIO pins, installing the necessary software in addition to executing Python code which volition snuff it to a greater extent than complex the to a greater extent than sensors you lot add. Of course, you lot could easily add together the sensors inwards Raspberry Pi Cayenne without having to do whatsoever coding.
Still, if you lot do non similar tinkering much amongst breadboard wires; amongst a solution similar the RasPiO Analog Zero board you lot tin forcefulness out easily command GPIO pins in addition to read analog sensors amongst real few lines of code because the board is tardily to code amongst RPi.GPIO +Python and GPIO Zero +Raspberry Pi Python libraries so it requires minimal boilerplate code to larn started.