I am new to the Raspberry Pi and i would appreciate it if you could help me to get started. I need to build a serial communication system, and the first stage is to be able to take a file (lets say a jpg pic) convert it into a stream of bits and write it to a gpio pin. since speed is a crucial requirement, I will probably use C language.

any idea on how to start?

  • 1
    What an odd requirement. Why do you want to do this? Is this a homework exercise?
    – joan
    Dec 29 '15 at 14:57
  • 1
    Welcome to the Raspberry Pi Stack Stack Exchange community - and the requirement is not so odd as it seems - the OP is talking about a Slow-Scan TV application. NASA does something like this to get pictures back from Far-Earth satellites and Inter-Planetary probes I believe.
    – SlySven
    Dec 30 '15 at 3:01

Where to start? I would start by opening the file, reading it, and then blink out the individual bits of the bytes read to a pin. You might want to add timing, checking bits and other kinds of protocol details later, but start by blinking it.

Also, if speed is a crucial requirement, you don't want to do this over one pin only. If you do, it won't matter if you use C, java or python - the limits won't be in the language. Get it working before you optimize. Python is probably your best choice and on the net there is a ton of tutorials on how to do it.

Have a look at https://www.raspberrypi.org/documentation/usage/gpio/


I tried something similar a while back, where I had to get more parrallel data to a 320x240 LCD display to make it work, than the RPI had available. So I used some GPIO bits to sync and reset and a single GPIO bit to populate a number of enjoined shift registers, then some more GPIO bits to send the data to the LCD.

The ability to serialise something is the easy bit. The hard bit is decide on and implement a protocol that'll support the clocking of your data (and when you're starting/ending the transmission).
You probably need to decide from the outset what the data is going to be received by, to decide what a generic data transmission looks like. Is it a fixed size, so you can infer the end when you know the beginning, or is it variable (like a jpg).
There are protocols like RS232 that endeavour to manage the data reset/start/clocking/end signals within a simple twisted pair of cables (although you can have extra handshaking connections), but to do that you need to consider the kit for sending on both sides of the communication line.

So to answer your question, I'd start by deciding what you're trying to achieve, and how much complication you need to add to the Pi, in order for the data to be received at the other end. A parallel bus is easier to implement than a serial one (in terms of hardware), but normally you start from the bit of the problem you can't control, which is normally what you're connecting to the Pi, rather than the other way around.

Once you've got your hardware sorted, I suggest investigating the wiredpi application, and libraries, to write C code that talks GPIO, but as discussed you'll probably find it easier prototyping Python.


If I were you I wouldn't try to reinvent the wheel, and used dedicated UART pins for the communication. From hardware point of view, you'll have to use particular pins (GPIO 14 & 15) as transmit/receive lines. Software-wise, sending data will be as simple as opening a device file /dev/ttyAMA0, configuring it to a particular transfer rate and writing data to that file. Reading is similar (open file, configure, read from it).

This way you can connect two RPis (don't forget you have to cross TX and RX lines, i.e. pin 14 from board 1 goes to pin 15 on board 2 and vice versa). You can also send/receive data from RPi to PC using a USB UART cable.

Tutorial: http://elinux.org/RPi_Serial_Connection

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.