RPi Projects/serialJpegCam

= Serial JPEG camera (TTL, µCAM) =

This project is about attaching the "Serial JPEG µCAM" (coolcomponents) to the GPIO pins and take pictures on command.

Requirements
You will need the following:


 * A Raspberry PI, any model
 * A µCAM (see above). Ideally one which comes with the connector and wires already pre-soldered. Most do.
 * A 26pin IDC (female) socket that fits onto the GPIO connector of your Pi. (RS or any electronics supplier).
 * Some flat pliers or, better a small vice.
 * A recent raspberry linux SD images.

About the camera
Consult the datasheet for full details - but the short of it is that the camera is connected to your Pi by a '3.3v TTL serial connection'. One talks to the camera using a simple serial command protocol. Such as 'get started', 'measure the light', 'take an image NOW' and ultimately 'give me the image'. The camera (mostly) expects a simple master/slave model. Where the Pi is the master and the camera the slave. The master then gives commands and the slave reacts with things such as 'Ok, done that', 'Error' or 'here is what you asked for'.

Serial Connections
Serial connections are relatively simple affairs. They consists of two wires; one which goes from the Pi to the camera. The Pi then 'transmits (Yx)' on this wire to the camera its receive wire 'Rx'. And a second wire going from the camera to the Pi where the Camera Transmits and the receiver listens. The only issue is the voltage.

There are various voltages in common use: from 15 volt (the old RS232) all the way down to the more modern 5 and 3.3 volt digital. Your Pi supports 3.3 volt digital TTL. As does above camera (it also supports 5 volt; but we won't be using that).

Wiring things up
We need to wire up 4 things:


 * The Tx pin of the GPIO to the RX wire of the camera.
 * The Rx wire of the GPIO to the TX wire of the camera.
 * The ground of the Pi to the ground of the camera (as otherwise above Tx and Rx signals would not have any common ground).
 * And, as the camera needs power, we need to wire the 3.3volt wire up to the 3.3volt of the PI.

We can find the various pins of the GPIO socket in the documentation of the PI. On the detailed documentation page you will find this image:

!http://elinux.org/images/2/2a/GPIOs.png!

and what we now need to find are the 4 pins:

Now we do the same for the camera. Page 5 and 6 of the datasheet tell you that on the camera the wiring is as follows:

So combing this we get the wiring diagram.

The next step is to wire this up on the IDC connector. There are some good video's on the web on how to do this or that.

The connector comes in 3 parts. We'll start with the connector itself and the bit which clicks straight on top of it - with the 26 grooves and the tiny slots for the metal knifes of the connector. Leave the smooth wire-tensioning loop for now.

The numbering is from the small triangle; the notch or groove at that side is number 1; the next one 2 until you hit 26.

In our case we'll be skipping a few of the holes as shown below in the photograph. So at the far end (where the notch is) we have the first wire (to pin 2 of the camera, the VCC wire). We then skip 4 notches until we are at position 6. There we insert the ground wire (to pin 3 of the camera). We then skip another notch and insert the serial transmit wire from Pi to Camera (pin 5 on the camera, notch 8 on the connector). And we then skip one more notch for the last cable, pin 5 on the camera to notch 10 on the GPI connector.

If you are doing this for the first time - it is a good idea to use a pencil or similar to make a small marking on the strip with the notches at position 1, 6, 8 and 10. And check and double check that you got those at the right place. Counting down from what you think is position 26 on the far end is a good way to do this.

You may want to make a small diagram on a piece of paper with the colours of the wire on it. That helps in the next step.

Once you've marked things - you gently click the small strip with the notches on top of the connector. But do *NOT* press them together. They should click once - but not more (if you press to hard - they'll click twice and you will have to use a small screwdriver or needed to dis-assemble them). You should now have a small grove between the connector and the top strip.

Gently insert the first wire (pin 2 on the camera, pin 1 on the GPIO connector) in the 1st slot of the GPIO connector; the one all the way to wards the triangle. It should come out on the other side; still in groove 1. If you cannot push it through - loosen the strip a bit. Once inserted you'll find it will stay in place thanks to the small metal knives. Check and double check it is exactly in the first grove (and not in the second one or diagonal).

Continue doing this for the other 3 wires. The end result should look like

Once done - check things a final time and squeeze the two halves together 'hand tight'. You will probably find that the thing does not properly snap together. This is good - as this gives you the all important chance to check it one final time. If things are wrong - gently pry the connector loose and try again. If the wire is damaged; cut the wire(s) and try again.

If things are right - then use a small vice or some pliers to really 'click' the connector together. Once that is done - loop the cable back and put the tension-relief bar over top. This will generally also lock the strips in place.

If you have a multi-meter - you can now check your wires; simply insert a thin wire or needed into pin 1, 6, 8 and 10 and check where they connect to. It is easy to get pin 1 and 2 confused; so keep checking where the triangle is. Consider putting a bit of red inkt on it.

The final assembly should look like

== Connecting it to the PI

Next up - ensure the pi is unplugged and insert the connector. Make sure your pin one (the triangle) is next to the P1 and notch marking near the edge of the board.

If you have a multi-meter you can check your wiring a final time.

== Software

Download the zip file from