This project is part of the bigger project "Masterthesis: Learning Networks with new technologies like LoRa". With this server, it should be possible to establish a connection between a Raspberry Pi and Scratch.
Prepare Raspberry Pi:
- enable
Interface Options
/I2C
- enable
Interface Options
/SPI
$ sudo raspi-config
Install required packages:
$ sudo pip3 install -r requirements.txt
Create a .env
file and edit its content:
$ cp example.env .env
$ nano .env
Connect the raspberry pi with the LoRa Bonnet from adafruit:
$ wget https://github.com/adafruit/Adafruit_CircuitPython_framebuf/raw/main/examples/font5x8.bin
Test everything needed on the Raspberry Pi:
$ python3 test_server.py
$ python3 server.py
With postman: WebSocket Request. Connect to localhost:8820
You can communicate with the server by sending json:
{
"display": "a new message"
}
key | handling | example |
---|---|---|
display |
shows a message on the screen of the raspberry pi | {"display": "some output"} |
send |
sends a message via the LoRa-Node of the raspberry pi | {"send": "a message"} |
You can add used packages to the requirements.txt
in the root-folder. Use the following command to show all installed packages:
$ sudo pip freeze
You can update a specific package with the following command:
$ sudo pip install --upgrade adafruit-circuitpython-rfm9x
⚠️ NotImplementedError: font module not available (ImportError: libSDL2_ttf-2.0.so.0: cannot open shared object file: No such file or directory)
$ sudo apt install libsdl2-ttf-2.0-0
A second module in this project is the watcher. With the watcher, you can watch the sending streams from the different scratch-server-applications.
$ python3 Watcher.py
You cannot run the Watcher from an external console, because it needs a display to show the incoming messages.
$ sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
Now add the following line before the screensaver line:
@sudo sh /home/pi/raspberry-scratch-server/system/launcher.sh