In this instructable I will show you how to use a cheap PICAXE micro-controller as a multiple channel analogue to digital converter. We will be using I2C to access the PICAXE, which will be writing the adc values into the memory registers. 

The Raspberry Pi does not have a built in ADC, which is unhelpful if you need to read any kind of analogue value, such as a variable resistor position or a light level etc. PICAXE is a line of cheap microcontrollers, designed to be easy to use for school children. This means they are easy to use, and you may have one lying in a draw. This instructable will show you how to use one as an ADC, but by writing values to it, you could conceivably use one as a port expander at the same time. 

Step 1: Set Up Pi

You will need to set up the pi for i2c for this instructable, which is explained in another of my instructables, here: Set up i2c . You need to get up to the point of running i2cdetect. 
<p>how is the name of the electronic simulator shown?</p>
Thanks for that, saved me a LOT of time and googling, only place to document all the steps. Worked perfectly. Couple of points:<br> <br> - I like to &quot;go by the book&quot;, so I powered a 40X2 from the 3.3 on the rPI header (as mentioned by another poster). Spec rPI and PIC spec sheets says you can draw 40 MA from this, and a 40X2 (with no loads on pins) draws less than that.<br> <br> - I don't see you show the 4.7K pullup resistors on SDA and SCL. According to all the docs I read they are needed, see <a href="http://www.picaxe.com/docs/axe110_i2c.pdf" rel="nofollow">http://www.picaxe.com/docs/axe110_i2c.pdf </a><br> <br> Thanks again!<br> <a href="http://www.va3ep.net" rel="nofollow">www.va3ep.net</a>
<br> I was wrong on the pull ups, according to<br> <br> &nbsp; &nbsp; &nbsp;<a href="http://elinux.org/RPi_Low-level_peripherals#General_Purpose_Input.2FOutput_.28GPIO.29" rel="nofollow">http://elinux.org/RPi_Low-level_peripherals#General_Purpose_Input.2FOutput_.28GPIO.29</a><br> <br> P1-03 and P1-05 (SDA and SCL) have hardwired 1K8 pull up resistors<br> <br> So apparently external ones are not required.<br> <br> <br> www.va3ep.net<br> <br>
regarding ... WARNING: I will be connecting 5V logic to the Pi 3.3V pins. This has caused no damage, but I am not responsible if it breaks yours. <br> <br>I think newer PICAXE chips, the M2 series, can run at 3.3 volts, so would that solve this potential concern? <br> <br>I'm very interested in simplest way to get Pi and PICAXE talking, here's some discussion regarding serial comm ... <br> <br>http://www.picaxeforum.co.uk/showthread.php?21686-Raspberry-Pi-Picaxe-Serial-Interfacing&amp;highlight=raspberry+pi <br> <br>Do you have any opinions on this? <br> <br>Thanks
this is a great work around, I was bummed about the lack of adc on the pi as well

About This Instructable


48 favorites


More by AntMan232: PICAXE Raspberry Pi ADC Raspberry Pi I2C (Python) Arduino stepper motor and servos shield - AW GCSE Board
Add instructable to: