Arduino as ADC for Raspberry Pi

Hey Guys. I'm trying to hook up an analog sensor to the raspberry and since that won't work I was thinking about using the Arduino to do it for the raspberry. I know you can get an MCP3008 or something like that but I don't have it here, and it costs like 6 euro here, in the NL, 7 euro's more to ship it...

Would it be possible to use the Arduino like an MCP3008 and let it send the analog signals to the Raspberry?

You can use the Arduino,s ADC to digitize your sensor signal and transfer said digital data to the pi via a serial protocol (TTL RS232 for instance).

I was thinking about that too, only doubting about how to do this. Letting the raspberry ask for a certain pin or simply returning a bunch of values in, for example, CSV format.

You can set it up so that when the Arduino has data it can signal the Pi and then send the data in delimited packets when the Pi is ready. Or the Pi can request a sample and wait and receive the answer from Arduino. It is pretty easy to format the outgoing data in CSV and actually makes it easier to parse on the receiving end.

Hi, I do it like this:

I connect the Arduino (Uno in my case) via USB to Raspberry Pi. I check dmesg to see which /dev/tty it was assigned in Raspbian (/dev/ttyUSB0 in my case).

Arduino is now drawing power from Raspberry Pi, running its measurement code and writes output via Serial.println(myAnalogReadValue)

Raspberry Pi is running this ruby code:

require 'rubygems'
require 'serialport'

sp = "/dev/ttyUSB0", 9600
while message_from_arduino = sp.gets
    puts message_from_arduino