RaspberryPi/IoT Morse Code Keyer
From charlesreid1
This page will show you how to turn your Raspberry Pi into an Internet of Things-enabled morse code keyer that can be remotely controlled with a RESTful web API.
The first part is the hello world LED circuit. This circuit connects to the Raspberry Pi (see RaspberryPi/Blink) via the GPIO pins. These are pins that enable you to turn voltages on and off from the Raspberry Pi, and therefore control circuits. The GPIO pins, in turn, can be controlled from a Python script on the Raspberry Pi.
The second part is the Flask API, which turns URL requests like http://myraspberrypi/hello into instructions to send morse code for "hello" via the LED circuit.
Part 1: Hello World LED Circuit
We've already covered how to get a basic Hello World circuit, independent of any code on the Raspberry Pi, on the RaspberryPi/Hello World page.
We then covered how to use the GPIO cable and a Python script to control voltage to certain pins, enabling us to control circuits with the Raspberry Pi, over on the RaspberryPi/Blink page.
These pieces cover part 1 of building your IoT Morse Code Keyer with the Raspberry Pi.
Part 2: RESTful API on the Raspberry Pi
The second step is getting a RESTful API up and running on the Raspberry Pi. We can do this by using Flask to define URL endpoints (like /hello or /on), and then define the "verbs" associated with those URLs.
Basic information on running a web server on the Pi here: RaspberryPi/Web_Server
However, this page doesn't go into much detail, so we'll go into greater detail here.
Setting Up Flask
We'll pick four URLs and four associated verbs for our remote control morse code keyer, and create four different urls for each of these actions:
| Action | Endpoint URL |
|---|---|
| Turn the LED on | /on
|
| Turn the LED off | /off
|
| Send message "SOS" with the LED | /sos
|
| Send message "Hello world" with the LED | /hello
|