Read articles from the magazine right here on Make:. Don’t have a subscription yet? Get one today.

Morse code is a super simple communication protocol that can be used in all kinds of ways — from secret signals tapped out by hand, to lights, whistles, radio beacons, you name it. It was humanity’s first means of long-distance electronic communication, and appearances in fictional (and sometimes factual) tales of adventure and intrigue have been propping up its vintage mystique ever since.

Like many youngsters, we were intrigued by codes and ciphers, especially Morse. We sent Morse coded letters to our friends, and used flashlights to transmit Morse messages between the shore and our family’s sailboat. Our first Morse telegraph system was made of two hand-wound electromagnets connected by a salvaged telephone wire. An AC transformer powered the magnets, which rattled against strips of scrap metal with an ear-wrenching 60Hz buzz with each dot and dash.

Luckily, our technical skills have improved since then. What would happen, we wondered, if we took the bare-bones simplicity of a physical Morse key and connected it to the internet? When the Raspberry Pi Zero W came along, offering a web-connectable board that would fit in a project box for $10, we decided to find out.

Several prototypes and programming languages later, we had a tidy laser-cut 3″×5″ box with the Pi, buzzer, and one large button. Push the button, and a Golang client on the Pi sends a signal through a WebSocket server, turning on the buzzer in all the other connected telegraphs. The Pi’s configuration lets you set the channel to which your telegraph connects, allowing open channels that anyone can listen and talk on (like amateur radio Morse bands) and private ones for you and your cohorts. Both server and client code are open source, so you can hack and modify at will.

All Systems Golang: Sending Morse over the internet requires a real-time communication protocol — you wouldn’t want to wait for an HTTP request to complete every time you tried to send a dot or dash! Luckily, there is a protocol for that: WebSockets.

We went through several different technology stacks in the quest for a simple client-server WebSocket implementation for the telegraph. These included Node.js, which is equipped with a nice WebSocket library but is complex to implement on the Pi, and Python, which works nicely on the Pi but not so nicely, we found, on the server end.

We settled on Go. Go, or “Golang,” is a relatively new open source programming language originally developed by Google. It combines features of some high-level languages like Python or JavaScript (such as online package management and relatively compact syntax) with features of low-level languages like C++ (static types, compiles to machine code), and then adds some special sauce of its own, like the ability to add threads easily through “goroutines.”

What will the next generation of Make: look like? We’re inviting you to shape the future by investing in Make:. By becoming an investor, you help decide what’s next. The future of Make: is in your hands. Learn More.

Project Steps

1. Load the Pi

The simplest way to get the telegraph code set up on your Pi is to use the pre-packed disk image. Download and unzip the disk image. The disk image includes the Raspbian operating system, so it will take a few minutes to download. (For advanced options, or to install the telegraph client manually, check the instructions in the GitHub repo).

If you don’t already have a tool for burning disk images, Etcher is a good option. Insert a blank microSD card into your card reader. Launch Etcher, click “Select Image,” and select the Internet Telegraph disk image (internet-telegraph.img). Click “Select Drive” and select your microSD card (be careful with this one — you don’t want to write the image to your hard drive!). Click “Flash” and wait for Etcher to do its work. Eject the SD card and pull it out of your card reader, then put it back in. It should mount as a disk that’s accessible through your file manager.

2. Configure Your Telegraph

SET THE WIRELESS NETWORK INFO

The telegraph can be run over Ethernet (using a micro USB to Ethernet adapter such as Adafruit #2992), or connected to a wireless network. To connect it to a wireless network, open /etc/wpa_supplicant/wpa_supplicant.conf from the SD card, and update the network info at the bottom of the file with your network’s SSID and Wi-Fi password.

SET TELEGRAPH CHANNEL AND SERVER

Open config.json in the root directory of your SD card. There are two configuration options you can set: The “channel” determines who else you’ll be communicating with. To send private Morse messages with your friends or relations, set this to an obscure series of words or string of characters that only you and your buddies know. The default channel is the “lobby.” Anyone with a telegraph who doesn’t change their channel will be in the lobby.

By default, telegraph messages go through our server at morse.autodidacts.io. You can also grab the server code from GitHub and set up your own server either on the web or on your local network. If you’re running your own server, change the “server” value from morse.autodidacts.io to the URL or IP address of your server.

Once you’ve saved the updated config, eject your SD card and pop it into the Pi Zero.

3. Wire It Up!

The first step for connecting things to your Pi Zero is to solder on the GPIO pin header. Put the header in from the top, then flip the Pi over and solder a pin in at each end to hold the header in place. Solder the rest of the pins, taking care to avoid bridging the gaps between pins with any errant solder blobs (Figure A). Check out Adafruit for a more detailed tutorial.

Figure A

Slip a couple of sections of heat-shrink tubing over the leads of one of the JST connectors, and then solder the leads onto the terminals of the arcade button (Figure B). It doesn’t matter which wire goes to which terminal on the button. When you’re done, slide the heat-shrink tubing over the joint and shrink it on with your soldering iron (Figure C).

 

 

 

 

 

 

 

Solder the other JST lead onto the buzzer. This one is polarity-specific: Make sure you connect the black or dashed negative wire onto the longer pin (Figure D).

Figure D

6. Power Up

Plug in the USB power and wait about 30 seconds for the Pi to boot up. When the Pi is booted up and connected to the Morse server, it will beep out “ready” in Morse code ( .-.  .  .-  -..  -.–).

To test your connection, push the button on your telegraph. If you hear a beep, your telegraph is talking to the server. All systems go!

May the Morse be With You!

The standard Morse alphabet includes letters, numbers, and a variety of punctuation symbols. The numbers and letters are shown in the engraving on the top of the telegraph for easy reference. For a more complete set, as well as some tips on learning Morse, print out a copy of InternetTelegraph/Docs/translate-morse.pdf from the GitHub repo. You’ll want to have a notebook handy for transcribing incoming messages.

Morse is made up of dots, dashes, and spaces (gaps). Each of these has a specific length in relation to the other symbols. Keeping these lengths in mind will help you send well-formed messages that are easy to decode, at whatever speed you’re punching them out. A dash is 3 times as long as a dot. Gaps between symbols within a letter are as long as one dot. Gaps between letters are 3 dots long, and gaps between words are 7 times as long as a dot.

Once you (and any other telegraph operators on your channel) are ready to go, it’s time to send a message!

We suggest something short and sweet, like “hi.” In Morse, that’s 4 dots, a space, and then 2 dots: dit-dit-dit-dit  dit-dit. (As it happens, “hi” was also the output sample that came just before the first ever use of “hello world” in a 1972 programming tutorial by Brian Kernighan. We’re sticking with historical precedent here.)

Try going very slowly at first, and sending simple messages. You might want to jot down the Morse as it comes in, and then decode it after the transmission. The same works for sending: write out the Morse first, and then key it into the telegraph.

Less Is Morse: Morse code, and the telegraphs to send and receive it, were invented by painter and tinkerer Samuel Morse and machinist Alfred Vail around 1840. For a century, Morse code was the primary means of long-distance communication, both over wires and by radio.

The original Morse telegraph used a solenoid-actuated stylus to press dots and dashes into a moving sheet of paper. Eventually, telegraph operators discovered they could hear the code in the solenoid movements and do away with the stylus system altogether.

Morse code has also found some more arcane uses. Thomas Edison famously proposed to his wife in Morse code, and the two would send surreptitious messages to each other by tapping out the code silently with their fingers (a trick that we’ve tried on several occasions as well, though not with marriage proposals). U.S. Navy commander and POW Jeremiah Denton rose to celebrity status after using Morse-coded eyeblinks during a television interview to sneak a message out from under the nose of his North Vietnamese captors in 1966.

Because of its simplicity, Morse can be transmitted by sounds, light beams, radio, touch, telegraph wires, or just about any other medium that can be varied or turned on and off. Morse radio transmissions are less susceptible to weak signals and interference than voice communications, which makes it a popular mode for long-distance amateur radio operators.

Troubleshooting

If the telegraph runs into an error connecting to the Morse server, it will give out a string of 8 short beeps when the button is pressed. This means it’s time to check that the Pi’s internet connection is working and the telegraph client is configured correctly.

The easiest way of troubleshooting is to attach a monitor, mouse, and keyboard to your Pi. Once you’ve got these peripherals hooked up, first make sure that the Pi is connected to the internet. Second, try running the telegraph client from the command line by opening up a terminal and typing cd / && ./internet-telegraph. Then try pressing the telegraph button. Check to make sure the terminal is logging key presses, shows the client is connected to the server, and hasn’t thrown any errors.

If you’re feeling 1337, you can do all this through SSH rather than plugging in a monitor. Use nmap to obtain your Pi’s IP address (or try ssh pi@raspberrypi.local), SSH into your Pi, and start debugging.

If any problematic issues show up, we’re happy to help. Just open an issue on the GitHub repo, or shoot us an email at info@autodidacts.io.