Raspberry pi & Morse code

Sailboat โ€œNaNโ€ beeps SOS (See Our Success) Raspberry Pi, Morse code and MQTT: more fun together



My name is Vova Balakin, I am from the Moscow school in the South-East named after Marshal VI Chuikov (classes "Silahedr": vk.com/silaedr ), I finished 5th grade, I am interested in programming and technology. I want to tell you what I did this spring. I had a sailboat called โ€œNot a Numberโ€ (โ€œNaNโ€). It is dangerous to go out to sea without signaling, so I thought that it lacked signal lights on the mast. Better yet, signal lights that can be controlled remotely. Better yet, remotely from anywhere in the world! I had a Raspberry Pi - and then I came up with ...







What I wanted (Problem statement)



... that you can attach an LED to the mast, connect it to the Raspberry Pi and program it so that any message from the Internet can be sent to the sailboat - and it is translated into Morse code - and the diode on the mast blinks according to this code. And on the same mast fix a photoresistor - Morse code decoder so that another computer on the Internet can receive the transmitted code.



What happened to me (Result)



After two months of trial and error, I managed to write a program that, through an MQTT broker (http://www.hivemq.com/demos/websocket-client/), allows anyone on the Internet who knows Topic - the secret key to transmit a message to the client , - send absolutely any message written in Latin - and the LED on my mast flashes it in Morse code!





In general, this is how it works: we write a message and send it to the MQTT server, and it, in turn, sends it to the Raspberry pi, which translates it into Morse code and winks with an LED in accordance with the code.



Here is the Node.js code on github .



How I Had to Suffer (Tools and Techniques)



I first wrote in Python3. But I couldn't connect python to MQTT - I didn't find the necessary documentation - and I switched to the Node.js platform.



In addition, throughout the day I tried to make a Morse code light signal decoder (using a photoresistor) and install it on the same mast of the same sailing ship, but it did not work, because the photoresistor (at least the one that I had) not able to distinguish light even from 5 LEDs (the voltage difference when the LEDs were on and off was too small).



Helpful advice for those who will do something like this (Discussion).



Write directly to Node.js if you want to link the code with MQTT later. Getting Python to connect with MQTT is not an easy task.



What has been done by humanity (Litobzor)



Before starting, I googled how to do this. All parts of this project are described separately on the Internet, but I did not find everything together.





Thank you for your valuable comments and cool advice from my robotics and computer science teachers and high school students!



All Articles