This project is a simple kiosk/serial sample project which shows a value on a web page, taken from a json
file. This value is increased when we receive any value on the serial port.
We have a serial device which sends a line of data whenever it wants. We listen to this device and count every line of data we receive.
The counter is initialized by the script init.py
. To listen to the serial port, we use connect.py
.
For convenience, a service is created to run this script when the RPi is started (see notes.md to set up the service).
We use RPiOS desktop to have all required stuff for the kiosk mode built-in.
- Set up a RPi with the desktop image and do the basic configuration as advised by this guide https://www.raspberrypi.com/documentation/computers/getting-started.html
- Copy the Python file to the home directory (
service/init.py
andservice/connect.py
) - Create a directory which will contain the web page files and copy the files from
web
directory there. - Configure autostart to show localhost in Chromium web browser at login:
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
- Add the following line:
@chromium-browser localhost/path/to/index.html
- Create the service to automatically connect to the serial port
sudo systemctl --force --full edit <myscript>.service
- Copy the content of the code snippet in appendix a. into this file
- Enable the script:
sudo systemctl enable --now <myscript>.service
- Check service status:
systemctl status <myscript>.service
- (Optional) Check the script output (like print(), etc.):
journalctl -b -e
[Unit]
Description=My script to monitor the serial port
After=multi-user.target
[Service]
WorkingDirectory=/home/<user>/
User=<user>
ExecStart=/usr/bin/python3 /home/<user>/connect.py
[Install]
WantedBy=multi-user.target