Raspberry Pi - single board Linux computer
revised 10-20-13 d. bodnar
Serial From Pi to PIC or PICAXE
NOTE: Serial from PIC to Pi Problem Resolved
|I have been working with the
Raspberry Pi for a few months and have had a great time
I plan on documenting some of the things that I have been able to do and observations that I have made.
My latest project is to use the Pi to read temperature from multiple DS18B20 sensors and graph the results - my notes are here
I have also been working on a Temperature / Humidity grapher - notes re here:
I made a protective Plexiglas case using materials that I found at my local (well stocked) hardware store.
Two pieces of 1/4" Plexiglas are held apart by 3/4" spacers (stand offs). The Plexiglas is 4.5" x 3".
There are three nylon screws that go through tapped holes in the top piece of Plexiglas to put gentle pressure on three points on the board, holding it firmly in place. The screws are 6 x 32 and 1" long. The screws that goes onto the yellow video out connector is way too long and will be cut down in length.
If you can't find nylon screws locally I purchased 8-32 x 1" screws from MicroFasteners.com
A small piece of 1/8" thick gasket material (2" x 1.75") goes under the side of the board away from the SD car socket. This padding helps to level out the bottom and it keeps the board from moving. The gasket material was found in the plumbing department. Make sure you test it to make sure that it DOES NOT conduct electricity before using it! The material I found is rubber and works well. It is similar to this item from Sears.
A slot can be cut into the top piece of Plexiglas it access to the
I/O pins is needed.
the Pi to Communicate with a Pic (or PICAXE) Microcontroller
Testing the Serial
echo "hello" > /dev/ttyAMA0 and press ENTER - note that the last character is a zero not an "O"
To send with a carriage return and line feed:
echo -e "hello \r\n" > /dev/ttyAMA0 and press ENTER
Modification to Shell file to Send Serial
The modified GPIOServer.sh file is here: RaspberryPi/GPIOServer-EchoWorking.sh.txt
Here are the changes I made:
PICAXE 14M2 Program
PICAXE 14M2 Program for Camera Controller
Using the Pi to Control a Web Cam System
The objective of this project is to use the Raspberry Pi, and its web interface, to select cameras and time delay. The project uses a number of routines and programs that have been written about using the Pi. My hat is off to all of those contributors who made this work possible!
Connecting to the built-in RS-232 Port with
The Raspberry Pi has a built in RS-232 port that is available at pins 8 and 10 on the 26 pin expansion header. In order to connect this port to a standard serial port on a PC or other device the 3.3 volt pulses that the Pi generates must be changed to normal RS-232 levels.
There are a number of articles on the Internet that show how to use the
MAX3232 to make this change. This is not a difficult device to use
but requires five capacitors to be fully functional. I found a
complete MAX3232 board that includes a surface mount chip and the five
capacitors on a board that is only 15mm long and 9mm wide.
The board is not well documented. Hopefully the notes below will get it working for you.
Here the top of the board and the MAX3232 chip can be seen. Even though there are solder pads on this side of the board no connections are made here.
The back of the board is shown here. The five small devices are surface mount capacitors. I used the four solder pads on the left to connect to the Raspberry Pi's expansion header. Three of the four pads (the one marked "+" is not used) go to the DB-9 that plugs into a PC's serial port. The silk screen labeling on these pads is not very good. The pads are labeled, from top to bottom, -, +, R, T.
Here is a photo of the completed unit. The DB-9 on the right goes to the PC's serial port. Only 3 wires connect from it to the MAX3232 board, pin 5 (ground), pin 3 (transmit) and pin 2 (receive). The four wires on the left of the board go to the pins on the Pi's expansion header.
The cable coming out from the left side goes to the Pi - these wires came from Deal Extreme and can be found with this link: http://dx.com/p/30cm-breadboard-wires-for-electronic-diy-40-cable-pack-80207 . I cut the 30cm wires in half and soldered the cut ends to the circuit board while the end with the female connectors go to the header on the Pi. The colors used are black, red, brown and orange.
It is important to note that all wiring is done on the back of the board, that is the side of the board that has the 5 capacitors, not the side with the MAX3232 chip.
Once the wires and connected plug the four wires on the left of the board to the following pins on the Pi's expansion header:
The other three connections go to the DB-9 serial plug.
To test the unit connect the DB-9 to a PC's serial port. Connect the four connectors to the pins listed above on the Pi
Fire up the Pi and, once it boots, start a terminal program on the PC - set the terminal program to 115200 baud, no parity, 8 data bits and no flow control. Press ENTER a few times and you should be rewarded by a login prompt.
I spent a few days getting errors on the PI (error
number 11 mostly - time out or resource not ready) until I stumbled on
that tells you to disable the serial login function - that appears to have been what was killing the serial input from the weather station that I am working to interface with the Pi. The serial would work for a dozen or so inputs from the PIC then would give an error.
Simply edit this file:
and put a remark symbol (#) before the line that includes "ttyAMA0" as below
#Spawn a getty on Raspberry Pi
thanks to Hobby Electronics!
Python Code (name on my system
PIC 12F683 Code:
'WX Date to Pi test d. bodnar