using an arduino as an ADC for a raspberry pi

reading a battery discharge with an arduino
discharging a 6V lead acid cell with two 50 ohm 10 watt resistors in parallel, reading the voltage with an arduino nano clone, and logging the data with a pi zero

Most everyone knows that unlike an arduino, the pi lacks an analog to digital converter. I normally use an MCP3004. These work ok for me most of the time, but I get a lot of readings that are outliers, and obviously not correct. I haven’t noticed this as much on the analog inputs on an arduino.

In this experiment (for an upcoming project) I essentially let an arduino nano clone read the voltage of a 6V lead acid battery that I was discharging with some low-value, high wattage resistors. The arduino read the voltage and printed it on it’s serial line at 9600 baud. The serial lines on the arduino were connected to the pi’s serial lines, and the pi recorded the readings by logging a screen session. First, you have to disable getty on the serial line, and then set up screen to log the session.
sudo systemctl stop serial-getty@ttyAMA0.service
sudo screen -L /dev/ttyAMA0 9600

I forgot to mention, that I used a 10K potentiometer as a voltage divider to step down the 6V so the arduino could read it.

6V battery discharging over 9 hour period under moderate load

I got a pretty good dataset with very little jitter and hardly any outliers. I think a pi and an ardino make a powerful combination. You can effectively extend all the arduino’s gpio’s, i2c, spi, etc. to the pi. You also have all the muscle and storage of the pi at your disposal for your projects.

Leave a Reply

Your email address will not be published. Required fields are marked *