Work by 31416kungfu, age 10-11
Last night I assembled the Quick2Wire analogue board. The software setup took a little bit of fiddling, after which I was able to make the simple tests described at Quick2Wire and a measurement with a potentiometer. The source I found most useful was the post at www.miraculum.ch.
1. Set up ictools as described at adafruit.
2. Install the quick2wire-python-api in a directory /home/git as Miraculum recommends. (Make this directory if need be).
$ cd git $ git clone https://github.com/quick2wire/quick2wire-python-api.git
3. Find the file pcf8591read:
$ find /home /usr -name pcf8591read
Make a copy of this file in ~/git and rename it as pcf8591read.py. Then add the line indicated below to the code so that the head of the file looks like this:
#! /usr/bin/env python3 import sys sys.path.append(r'/home/pi/git/quick2wire-python-api/') # add this from quick2wire.i2c import I2CMaster from quick2wire.parts.pcf8591 import *
As noted in Miraculum’s post, the added line ensures that the program finds the needed parts of the quick2wire-python-api.
4. On the Quick2Wire Analogue board, run a jumper from AIN0 to GND. Then say
sudo python3 pcf8591read.py. You should see this:
pi@raspberrypi ~/git $ sudo python3 pcf8591read.py read: 1 : 0.0 read: 2 : 0.0 read: 3 : 0.0
5. Now run the jumper from AIN0 to VREF. You should see this:
pi@raspberrypi ~/git $ sudo python3 pcf8591read.py read: 1 : 1.0 read: 2 : 1.0 read: 3 : 1.0
6. Attach a potentiometer as follows: one outside lead to GND, the other to VREF, the middle lead to AIN0. Then test. You will get something like this as you rotate the potentiometer:
pi@raspberrypi ~/git $ sudo python3 pcf8591read.py read: 1 : 0.0 read: 2 : 0.0 read: 3 : 0.0 read: 4 : 0.06274509803921569 read: 5 : 0.14901960784313725 read: 6 : 0.20392156862745098 read: 7 : 0.2627450980392157 read: 8 : 0.3254901960784314 read: 9 : 0.39215686274509803 read: 10 : 0.47058823529411764 read: 11 : 0.5686274509803921 read: 12 : 0.6705882352941176 read: 13 : 0.796078431372549 read: 14 : 0.9686274509803922 read: 15 : 1.0 read: 16 : 1.0