TLC2543 ADC with Dropbox Uploads

This code runs on a Raspberry Pi and talks with a TLC2543 ADC via the SPI ports. It will read the voltages on all of the inputs, write them to a file, then upload that file to Dropbox. The idea behind this project was instead of having to keep a computer near the ADC (as described in my Arduino TLC2543 project) you just needed a Raspberry Pi next to the ADC. This freed up computers to do other things and you could SSH into the Rasp Pi when you needed to change things or run a new test.

Below are the instructions I wrote for the other students on how to setup the system. The python code doesn’t convert the voltages to actual pressures or apply calibration data; I planned on letting them figure out how to do that on their own.

First download Wheezy from the Raspberry Pi website: http://www.raspberrypi.org/downloads
Put the image on the sd card: http://elinux.org/RPi_Easy_SD_Card_Setup (Follow steps under ‘Copying the image to an SD Card on Windows’)
Once you put the SD card in the Pi and power it up it will take a while to boot for the first time
(You can hook up a monitor and watch it boot up)

Once it has fully booted up, issue the following commands (I just SSH into it):
sudo raspi-config (expand the partition to fill the entire card)
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git
sudo wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update (downloads the rpi-update you need to update to the newest image)
sudo chmod +x /usr/bin/rpi-update
sudo rpi-update
sudo shutdown -r now

sudo wget http://apt.bootc.net/debian/pool/main/l/linux-source-3.2.23-rpi1+/linux-image-3.2.23-rpi1+_1_armel.deb (update to the kernel)
sudo dpkg -–force-architecture –i linux-image-3.2.23-rpi1+_1_armel.deb
sudo nano /etc/modprobe.d/raspi-blacklist.conf
(modify the following) #blacklist spi-bcm2708 (make sure to save it)
sudo shutdown -r now
ls -al /dev/spi* (should return the 2 spi ports)
wget http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git\;a=blob_plain\;f=Documentation/spi/spidev_test.c -O spidev_test.c
nano spidev_test.c
(modify the following) static const char *device = “/dev/spidev0.0”; (make sure to save)
gcc spidev_test.c
(now short the MISO pin to the MOSI pin)
sudo ./a.out
(make sure it returns the folowing:)
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)

FF FF FF FF FF FF
40 00 00 00 00 95
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF FF FF FF FF
DE AD BE EF BA AD
F0 0D

sudo apt-get install python-dev
sudo apt-get install python-pip
sudo easy_install -U distribute
sudo pip install RPi.GPIO
sudo pip install feedparser

(Download the files from my GitHub Repository)
wget https://github.com/Echoskope/RaspPi/blob/master/TLC2543_with_Dropbox_integration/datalogger2.py
wget https://github.com/Echoskope/RaspPi/blob/master/TLC2543_with_Dropbox_integration/initalize_dropbox.py
wget https://github.com/Echoskope/RaspPi/blob/master/TLC2543_with_Dropbox_integration/setup_loop.py
wget https://github.com/Echoskope/RaspPi/blob/master/TLC2543_with_Dropbox_integration/spimodule_loop.c
sudo python setup_loop.py build
cd build/lib.linux-armv6l-2.7/
ls
(make sure the spi.so is there)
sudo mv spi.so ../..
cd ~

wget https://www.dropbox.com/static/developers/dropbox-python-sdk-1.5.1.zip
sudo unzip dropbox-python-sdk-1.5.1.zip -d /home/pi/Dropbox_API
sudo rm dropbox-python-sdk-1.5.1.zip
cd Dropbox_API/dropbox-python-sdk-1.5.1/

sudo python setup.py install

(Now go get the APP_KEY and APP_SECRET from https://www.dropbox.com/developers/start/setup#python and you want an app folder when it asks)
cd ~
sudo nano initalize_dropbox.py (copy your key and secret into the script)
sudo nano datalogger2.py (same thing as above)
sudo python initalize_dropbox.py
(go to the website and allow the app, then go back to terminal and press ‘enter’)
(now hook up the TLC2543)

sudo python datalogger2.py

 

 

 

Leave a Reply

© 2014 - Brain Overload. All Rights Reserved. Powered by Wordpress and Design by We Create Web Designs