Skip to content

Part of my Masterthesis: Establish a connection between Raspberry Pi, Python and Scratch.

License

Notifications You must be signed in to change notification settings

btemperli/raspberry-scratch-server

Repository files navigation

Scratch Server

About

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.

Setup

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

Server

Start

$ python3 server.py

Connection

With postman: WebSocket Request. Connect to localhost:8820

Requests

You can communicate with the server by sending json:

{
    "display": "a new message"
}

Keys

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"}

Updates

Requirements

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

Bugs

Font Module

⚠️ NotImplementedError: font module not available (ImportError: libSDL2_ttf-2.0.so.0: cannot open shared object file: No such file or directory)

Solution

$ sudo apt install libsdl2-ttf-2.0-0

Watcher

A second module in this project is the watcher. With the watcher, you can watch the sending streams from the different scratch-server-applications.

Run watcher

$ python3 Watcher.py

You cannot run the Watcher from an external console, because it needs a display to show the incoming messages.

Add the watcher to autostart

$ 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

About

Part of my Masterthesis: Establish a connection between Raspberry Pi, Python and Scratch.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published