Introduction: Off-the-grid Camera Beacon With Solar Panels

A beacon is such a radio transmitter that transmits signals in regular intervals to perform various radio measurements. The transmisison usually carries morse code, but as you'll see in this instructable, it can include a live image taken by a small camera. Since the device will transmit using a simple radio, no wired or cellular coverage is needed, thus it can be a real off-the-grid appliance. To make it even less reliant on centralized infrastructure, we'll use solar panels we got from Brown Dog Gadgets to power it with the sun -- taking photos wouldn't make sense in the dark anyway. Of course if you don't have such a panel, you can skip it and use a battery, but then you'll have to recharge it regularly.

We'll base our solution on a Raspberry Pi, any version and model will work, so if you don't have one already, it's OK to buy the cheapest one. If you prefer or already have other boards, you can adapt the steps, just make sure it has audio output and one GPIO port.

You'll also need a radio and a transparent box (more about them later) and the following electrical components:

  • electrical wires

  • 1k resistor

  • an NPN transistor (e.g. BC337 or 2N2222)

  • a small relay (5 volts)

  • pin header connectors for the Raspberry Pi (2.54 mm / 100 mil spacing,
    these can be salvaged from old PC IDE cables)

If you'd also like to build the (optional) USB Y cable, you'll need two USB to micro USB cables and optionally a big capacitor (at least 5 volts).

For assembling the parts, you'll need to do soldering, so make sure you have everything for that including a soldering iron and some skill.

In the following steps, we'll cover how transmitting images over radio can work, how you'll connect the Pi to the radio, setting up the software on the Pi and finally putting it in a neat weatherproof box along with the solar panels.

Step 1: Learn How SSTV Works

Slow-scan Television (SSTV) works the same way as television does; it transmits images by scanning the picture in so-called scanlines, and transforming information about the line (color, luminosity) into radio waves. Broadcast television does this by transmitting 25 to 30 images every second, which requires huge bandwidth; however if we lower the speed of scanning, transmitting small pictures in 30 to 120 seconds is possible within much smaller bandwidth.

This means that instead of transmitting several images per second, a single image is transmitted for a minute or two. Several methods are known for performing the actual transmission, the simplest is to use a small handheld off-the-self radio, also known as HT (handie-talkie) or walkie-talkie. Keep in mind that depending on the frequency and transmission power, you might need a license for this, so it's best to consult your local, state or federal laws.

Most SSTV transmissions are initiated by ham radio or amateur radio operators and such images can travel from within a city to around the globe, depending on the frequency, power and antenna used.

For translating images to sound, the cheapest solution is using a small computer like a smartphone or a Raspberry Pi that has a camera and audio output. Several translation methods (also known as modes) can be used, we're going to use Martin M2, which transmits 320x256 color pixels in 60 seconds.

Most radios designed for transmitting speech can carry audio between around 100 and 3000 Hz, distortion can occur outside this range. Thus, SSTV uses frequencies between 1100 and 2300 Hz; 1200 Hz is used to signal the end of a line and the beginning of the next, and within the line, the actual color information is mapped linearly from 1500 to 2300 Hz. In case of the Martin system, the three color components are sent separately for each line, so for each line, three lines are sent, first the green, then the blue, and finally the red component is sent.

There are many different modes that can be used, and since these are mostly incompatible, the receiver needs to know the format being used before decoding the transmission. Historically, people announced the mode being used using voice transmission, but there's a simple method of using FSK (frequency shift keying) to encode information about the mode used right before transmitting the image using the frequencies 1100 and 1300 to signal bits 1 and 0, respectively.

If you're interested in a more in-depth description of slow-scan television, you'll enjoy the free eBook Image Communication on Short Waves by Martin OK2MNM. (On ham radio, many people identify themselves with their callsign, a 5 to 6 character combination of letters and numbers.)

Step 2: Interfacing the Raspberry Pi With a Radio

Of course, to transmit radio waves, you'll need a radio. The simplest and cheapest option is getting a Baofeng handheld transceiver, we got the UV-5R model, sold by many vendors on various sites. Of course, any radio can be used as long as it has electronic PTT control and microphone input, but the connections below are described for this model.

Important: check regulations before transmitting. You can use a PMR radio in most jurisdictions without a license, but the best is to get a ham (amateur) radio license and/or get in touch with a local ham club. Radios are cheap, but fines may be high if you transmit with the wrong power and/or on the wrong band.

Two connections are required between the Raspberry Pi and the radio.

First, the audio must be routed from the output of the Pi (light blue 3.5mm TRS/Jack socket) to the microphone input of the radio (bigger 3.5mm TRS/Jack socket). This requires two wires and two Jack connectors.

Second, the PTT (Push To Talk) functionality must be controllable by the Pi to switch the radio between transitting and receiving. This can be toggled on the radio by shorting the grounds of the above mentioned 3.5mm and the other 2.5mm TRS sockets, thus requires an additional, smaller Jack connector.

In case of most radios, such a connection only requires a transistor and a resistor, but that wasn't stable in case of Baofeng ones. Using a little relay solved this problem, and it only involves one more element. The transistor is controlled via its base connected to one of the GPIO (General Purpose Input/Output) pins. Such pins are present on all versions of Raspberry Pi (and most embedded computers), and in our case, we'll set it as an output, which means that based on setting a value to 1 or 0 in software results in the pin being connected to the power supply (3.3 volts on the Pi) or ground, respectively.

With these connected, the following sequence should be performed to transmit an image:

  1. Capture image with camera
  2. Convert camera to sound waves using SSTV modulation
  3. Activate PTT with relay over GPIO
  4. Play the sound
  5. Deactivate PTT

We'll create the software setup for that in the next step.

Step 3: Setting Up the Software Stack

Install the OS of your choice on the Pi, we used Raspbian since people familiar with Debian/Ubuntu find it easy to use. This step will follow Raspbian conventions; you can use any distribution if you'd like but then you'll have to adjust these to the flavor it uses.

Taking images is going to happen using raspistill, this should already be installed on the device. Conversion to SSTV modulated sound file will happen using PySSTV and UNIXSSTV, so you'll need Python, Git, GCC and make for that. Latter dependencies are present by default on Raspbian, so you just need to install the two SSTV software by executing the following commands.

sudo pip install PySSTV

git clone <a href="https://github.com/dnet/unixsstv" rel="nofollow">https://github.com/dnet/unixsstv</a>

make -C unixsstv

The image will be taken and preprocessed in Python, an example script can be found below:

from PIL import Image

from pysstv.color import MartinM2

from subprocess import check_output

from cStringIO import StringIO

import RPi.GPIO as GPIO

import struct, sys



TX_PIN = 18

img = Image.open(StringIO(check_output(['raspistill', '--output', '-',

 '--width', '320', '--height', '256', '-e', 'bmp'])))

overlay = Image.open('overlay.png')

img.paste(overlay, (0, 0), overlay)

img = img.resize((MartinM2.WIDTH, MartinM2.HEIGHT))

sstv = MartinM2(img, 44100, 16)

for freq, msec in sstv.gen_freq_bits():

    sys.stdout.write(struct.pack('ff', freq, msec))

GPIO.setmode(GPIO.BCM)

GPIO.setup(TX_PIN, GPIO.OUT)

GPIO.output(TX_PIN, True)

The image in overlay.png will be put onto the photo, so you'll need to construct it in a way that most of it is transparent, since those pixels will be the only ones that can be seen from the photo. Feel free to experiment, just make sure that if you use ham (amateur) radio frequencies, transmit your callsign by putting it on the image. (Advanced users can try and use the FSK callsign encoder in PySSTV.)

Martin M2 was selected since it has a rather nice color output, while still taking only one minute to transmit an image. 44100 Hz and 16 bits are also good default parameters, but feel free to experiment with those as well, just make sure to match these parameters in other components.

Since this script ends its job by activating the PTT and writing preprocessed SSTV data on the standard output (stdout), another component is needed that finishes the processing, plays the sound on the audio output, and deactivates PTT at the end.

For this, a shell script needs to be created like the one below:

#!/bin/sh python

/home/pi/beacon.py | /home/pi/unixsstv/gen_values 44100 >/tmp/wav.bin

play -q -r 44100 -t f32 -c 1 --norm /tmp/wav.bin >/dev/null 2>&1

python -c 'import RPi.GPIO as G; G.setmode(G.BCM); G.setup(18, G.OUT); G.output(18, False); G.cleanup()' >/dev/null 2>&1

rm -f /tmp/wav.bin

The Python script above is named beacon.py and located in the home directory of the default pi user, if this differs on your device, you'll need to change this appropriately. The output is piped into gen_values of UNIXSSTV, and then saved to a file with no header, just binary contents, hence the .bin extension.

This is later played with the play command of sox, which can be installed on Raspbian from the package sox, but you might have to do that manually on other distros. Finally, the PTT is deactivated by calling Python code directly, in so-called inline style, and rm deletes the temporary preprocessed file.

Note: since GPIO can only be manipulated by root, you'll need to execute this shell script as root as well. Also, play will use the HDMI audio channel by default, so make sure to disconnect HDMI while trying this part. If no sound plays, also check the volume level (for example with alsamixer).

Having these, capturing the image and transmitting the photo can be tried by executing the above shell script from a console (serial, local, GUI) or over SSH. If it works well, just one thing is needed for regular transmission called cron. On Unix-like systems such as Linux, this program performs predefined tasks according to a schedule that can be set using crontab -e, where -e stands for edit. This will display the current schedule of the user (this should be root for this task) and allows editing it in the user's default editor. There's also some help in there regarding the syntax, and for example, sending an image every 15 minutes looks like this:

*/15 * * * * sh /home/pi/beacon.sh

This setup can be tested by connecting the Raspberry Pi to a USB charger, and if everything works, you can continue by replacing it with solar.

Step 4: Creating a Y Cable for Higher USB Power (optional)

If the solar panel doesn't produce enough power to cover peak consumption, the simplest solution is using two panels interconnected with a Y-shaped cable that has two USB A connector inputs and one micro USB outputs. It also helps if a capacitor is added, and all these inputs, output and capacitor should be wired parallel. This way, the voltage stays the same (5V for USB) and the power is the sum of all the inputs.

Step 5: Putting It Together in a Box With Solar Panels

Since the beacon should ideally be located outside, a weatherproof container is required. We prefer the Samla transparent plastic boxes from IKEA since they're quite cheap, come in various but compatible sizes and are available in most of the world.

The actual assembly can be done in two ways, either by placing the solar panels on the bottom of the box, or by putting the components into the box first, then placing the panels on the side and/or the top. In case of former, the box is deployed upside down to have the solar panels exposed to the sun.

The camera should be put on the side, and if you don't care about rain (or solved this problem in another way), feel free to cut a small window with an X-ACTO knife, otherwise the image will be a little bit faded by the plastic.

With the components in place, the beacon is ready and can be deployed to transmit images taken at regular intervals to anyone who listens on the right frequency.

Comments

author
MikB (author)2015-05-09

Please put a diode across the relay coil, if you want the transistor to survive :)

http://en.wikipedia.org/wiki/Flyback_diode

http://en.wikipedia.org/wiki/Snubber#Diode_snubbers

author
hackbp (author)MikB2015-05-11

You're right, the whole relay thing was added at the last moment since most radios work just fine with the transistor by itself.

author
BenT4 (author)2015-05-08

How far does this broadcast and what do you use to receive the picture?

author
hackbp (author)BenT42015-05-08

It depends on lots of things including both (transmitter and receiver) antennas, and output power -- the UHF band we used (70 cm / 433 MHz) works best if there's a direct way between the two antennas. If that's the case, since we were on a hill, the signal could've been received from many kilometers away.

For reception, we use either a Software Defined Radio or a regular/dedicated ham radio receiver that outputs audio, and then convert it with a suitable software. On Windows, most people use MMSSTV, on Linux, popular choices include QSSTV and slowrx. These receive audio on microphone input (or virtual cable in case of SDR on the same machine) and convert it into image files.

There are also similar software for smartphones (both for Android and iOS), which can be used in a portable setup with a handheld radio better -- just hold the microphone to the speaker of the radio or use a small cable. Essentially, you perform the reverse of what we've done in case of the transmitter.

author
blkhawk (author)2015-04-30

Your instructable reminded me of a previous project: https://www.instructables.com/id/Images-On-An-Audio-Cassette/

author
hackbp (author)blkhawk2015-05-03

Yes, it's the same technology -- although that one states that transmitters are expensive, while it costs roughly the same as a tape recorder (although most people have one of the latter somewhere in their home, but not former). For example, the Baofeng UV-5R we used costs 25 to 35 USD depending on the site you order it from.

author
blkhawk (author)hackbp2015-05-04

Thank you for the info!

author
florlayamp (author)2015-04-30

Good work! We need more sstv on the air.

author
sa_penguin (author)2015-05-09

Nice instructable, but... which solar panels do you use? The Brown Dog website has nine different versions, at assorted prices:

http://www.browndoggadgets.com/collections/solar-c...

author
hackbp (author)sa_penguin2015-05-12

We used the 5W folding USB solar cell.

author
SilasM (author)2015-05-10

author
praveen_joshi (author)2015-05-04

thanks for sharing

author
tomatoskins (author)2015-04-30

Such a cool idea! Thanks for sharing!

About This Instructable

17,838views

142favorites

License:

Bio: Hackerspace Budapest
More by hackbp:Simple solar-powered QRP transmitterOff-the-grid camera beacon with solar panelsSpark.io Alarm Clock with mood light
Add instructable to: