Doing what you love doing…

Posted: October 18, 2019 in Hacking, Hardware, Linux, Raspberry PI, RPi, Software, Uncategorized
Tags: , ,

Funny, I tend not to blog much but every once in a while I get the urge.

Not too long ago someone asked me what I really love doing. As in what would I do for free every day if I could (assuming I did not have to worry about paying the bills and such). I thought about the question for a while and looked back over my years as a developer and manager of technical types and realized that I love creating new things that are needed by someone, I also love teaching folks about technology. That explains why some jobs in my past have resonated with me more then others.

I recently took a small contract that was really fun, I got an email from a gent that wanted to send Morse Code via light. He wanted to be able to type a paragraph of text and send it over and over again via a light and not just any light, a bright enough light to cover a mile or more of distance. He had a few more requirements:

  1. It had to be self-contained, and portable
  2. Water resistant to water mist and or light rain
  3. Easy to use, he did not want to learn Morse Code, just wanted to type text and have it sent as Morse Code
  4. Able to send the text as Morse Code somewhere between 5 words per minute (WPM) and 75 WPM

As it turns out I am an amateur radio operator (HAM) here in the US and I have my general license (still studying for my extra license), so I know about Morse Code but I can’t actually send or receive it. I tried back in the 70’s to learn it but never could wrap my brain around it. Seems to fit in the same general area as speaking and understanding other human languages besides English (I can’t do that either). I’ve tried to learn Spanish, Italian, Esperanto and Klingon. I’ve never had any success, the closest I’ve come is I can count to 39 in Spanish….. and that was with 6 years of training in elementary school.


Thinking over his requirements, I realized I needed some kind of a waterproof case about briefcase size, perhaps a bit deeper then a normal briefcase to allow for a large light to be stored in the case when not in use.

Clearly needed to be some kind of embedded computer to create the text and control the light. Cheap and small, how about a Raspberry Pi (Rpi) model 3B? It’s small, easy to program, has lots of general purpose input output pins (GPIO) and has an HDMI monitor output. Perfect. Of course if you are going to have a computer you need a keyboard/mouse and a display. MonitorInLidAll simple enough. Now what kind of light will be bright enough to be seen a mile away and yet be controllable to be able to send Morse Code. Needs to be bright, really bright. Can’t use Halogen, that gets too hot and will keep glowing even when the power is removed, incandescent same problem, florescent does not turn on fast enough and keeps glowing also. LED fit the requirement – it turns on and off fast and it’s very bright. When you replace a household 100 watt light with an LED you usually replace it with an 8 watt (W) LED, so what if I use a 100W LED? I hunted around and find a 100W spotlight that is normally used on trucks that go off-roading. Now that is BRIGHT, slight problem however it uses 12VDC – 30VDC for power and requires up to 8 amps of current.  Video of a super bright LED light flashing on a blue wall.

We have a computer and monitor that use 5VDC to run, the LED light that requires somewhere between 12V and 30VDC and is high amperage at least compared to the GPIO pins of the Rpi. For easy portability powering it from 12VDC makes sense, that is easily available from a vehicle or a wall power supply. Some bigger trucks use 24VDC so keep that in mind when designed the circuit….. OK I found a DC to DC step down power supply that can handle up to 35VDC input and can output 5VDC regulated for the Rpi and Monitor. Now all I had to handle was the current for the LED spotlight. First thought is use a cheap 5VDC mechanical relay, the Rpi can control a 5DCV relay easily, except one problem. Sending text at 75WPM means that the transition speed between on and off is fast, very fast, in fact much faster then a mechanical relay can handle. So back to the drawing board…… Wait one, how about a solid state DC relay? 3 – 32VDC input for control – 5VDC input from the Rpi check that works, can switch 5 – 200VDC output – the LED light works on 12 – 30VDC, check that works too. Alright a solid state relay it is. Solid state relays can generate heat so make sure I get a heat sink made for the relay. Some miscellaneous other parts, wires, mounts, case, etc and we are off to the races:

So far we have about a $800 parts list:

  1. VideoSecu LCD LED Monitor TV Wall Mount
  2. SAE Cable – iGreely Solar Weatherproof SAE Socket Sidewall Port
  3. MUYI 2 Set Inline Fuse Holder 10 Gauge Waterproof Pigtail Blade Fuse Holder
  4. Kenowa Portable Monitor 11.6 Inch 1920X1080 IPS with 2 Mini HDMI USB(5v)
  5. Logitech K400 Plus Wireless Touch TV Keyboard with Easy Media Control and Built-in Touchpad
  6. RS Components Raspberry Pi 3 B+ Motherboard
  7. Miuzei Raspberry Pi 3 B+ Case with Fan Cooling
  8. Seahorse SE-720 Waterproof Protective Hardcase Without Foam (Black)
  9. DROK Buck Converter Voltage Regulator DC 5V Power Supply
  10. Blue Sea Systems DualBus 100A BusBar – 5 Circuit
  11. Universal Compact Bench Power Supply – 30 Amp Regulated
  12. Universal 6″ LED Spot Lights For Cars – 100W Bright 8000LM LED Off-Road Spotlight
  13. TinaWood SSR-25DD Solid State Relay 25A 3-32V DC/5-200V DC
  14. 8’ Aluminum angle
  15. A 1/8” sheet of Aluminum to bolt the computer hardware too.
  16. Misc bolts, pop-rivets and connectors.

Time to build the system into a solid system. I took the Seahorse case and built an aluminum frame that had 3 compartments, 1 for the LED light, 1 for the computer, relay and DC-DC power supply, and one for the keyboard storage. The entire frame was pop-riveted together, painted black and then the frame was riveted to the 1/8” aluminum sheet. Then nuts and bolts were used to secure it inside the case.

The LED compartment had a slot to allow the LED to be bolted down so the LED could not bounce around in the case, if that happened it would be a disaster, the light was big enough and heavy enough to break everything else in the case if it broke loose. The Monitor mount was bolted to the inside of the lid of the case and the flat panel monitor mounted to it.Computer-Power-Relay

Now wire up the Rpi, monitor, solid state relay and step down power supply. Plug in the external power and it works, it powers up and I get the Rpi logo on the monitor. Fantastic. Now we need some software.PowerSupply


I had told the gent that I was going to use Open Source software on his project, fortunately he knew what Open Source software is so I did not have to explain that to him. I installed Raspbian on the Rpi and did a search for any Open Source application that sent Morse Code, I found only a few. I downloaded the source code to all of them and had a look. My original plan was to crib as much as possible from an application and only write the controlling aspects. No luck there. The few applications I found were not suitable for the project. Most were for learning Morse Code, the best was fldigi that is a radio control application but it was far too complex for the project.

So I had to design from scratch an application that could take a paragraph of text and send it via flashing the LED light. I called the command line application “morse”, I know really original. I used the “C” language as I wanted the application to be compiled and fast. Morse code is “interesting” it’s all about timing, more about that below.

Quick Primer on Morse Code

Morse Code is all about the dot. All the timing in Morse code is based off the time of the dot. So:

  • A dot is one time unit.
  • A dash is three dot time units.
  • A dot dot or dot dash or dash dash separation is one dot time unit.
  • A letter separation is three dot time units.
  • A word separation is seven dot time units.

How fast a dot is depends on how many words per minute you are sending, and from there cascades the rest of the timing. There are two type of timing: “Standard” and “Farnsworth”, the “morse” application can do both types. For more info lookup Morse Code on a search engine.

I designed the application in several sections.

  1. First I built a header file that was a lookup table of dot and dashes for each Morse Code letter and punctuation. I ended up building the lookup table for the most of the entire ASCII table with either dots and dashes or NULL’s for things not in Morse Code.
  2. The next thing I did was write the code to display a letter from the lookup table from that I added the ability to process and display an array of text. That all ended up being in a single C file called “display_morse.c”.
  3. Now that I could display text, I needed a way to load a text file into memory so it could be displayed, that ended up being in a file called “process_file.c”.
  4. Next I needed a way to tell the application the name of the file to load, speed to display it, how many times to loop displaying it, etc. all of that ended up going into a file called “process_command_line.c”.
  5. Of course if you are taking command line input it might be handy to also have config files that set the defaults so you don’t have to use the command line options, that ended up being in a file called “process_config_file.c”.
  6. Finally all “C” applications start with a main() function that is in the file called “morse.c” and the include file called “morse.h” which contains the master structure of variables needed to control the application.

The application is under the gpl v2 license and is available on github  It does use two library’s one of the library’s is specific to the Rpi to run the GPIO pin that controls the LED light and would need to be replaced if a different embedded hardware system is used, the other library is to parse command line options and can be used no matter what hardware platform is chosen.

It was truly a fun project and met his needs. It’s used on a really large field where they fly drones and don’t allow any radio communications except the drone controllers. Turns out there are apps that will read Morse code signals sent on light by cell phones! Who would have thunk??? So you can receive Morse code via your cell phone for short range communications but for truly long range well that is where a special project like this comes in. So if you need a special device and you can’t buy it on Amazon or at Target or some other store, and you really need it, get it touch with me and likely I can create it for you.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s