Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Working installation of the RPI example module on hardware #20

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 0 additions & 79 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,87 +30,8 @@ A device contains a protocol, and can utilise modules
### Wish list:

- Poetry (Not started)
- ASGI backend server (Daphne)
- Native webcomponent FE with Bootstrap
- pip install raspberry pi
- modular components that are easy to install from a software and hardware perspective
- Provide systemd script to 3rd parties
- venv is crucial before installing any third party packages!
- Pre commit config with ci integration

## Installation

### Enable interfaces

For any temperature sensors the 1 wire interface is required

```shell
sudo raspi-config
```

1. Select the option: "Interface Options"

2. Select the Option I7: "1-Wire"

3. Agree to installing the 1-Wire script

4. Reboot

```shell
sudo reboot
```

Sanity check that the 1 Wire data is available:

```shell
ls /sys/bus/w1/devices/
```

Check the value read, be sure to change "28-000003ebbf13" to the values listed above:

```shell
cat /sys/bus/w1/devices/28-000003ebbf13/w1_slave
```

### Script auto start with systemd

Create a file in systemd

```shell
nano /lib/systemd/system/shed-pi.service
````

With the contents

```ini
[Unit]
Description = Shed-Pi
After = multi-user.target
StartLimitIntervalSec = 0

[Service]
Type = simple
ExecStart = /usr/bin/python3 /home/shed-pi/temp_logger.py
StandardInput = tty-force

[Install]
WantedBy = multi-user.target
```

Enable the service, (CAVEAT: didn't work when manually starting, works on reboot)

```shell
sudo systemctl daemon-reload
sudo systemctl enable shed-pi.service
sudo systemctl start shed-pi.service
sudo systemctl status shed-pi.service
```

Read the logs

```shell
tail -f /var/log/shed-pi.log
```

## Development

Expand Down
81 changes: 81 additions & 0 deletions standalone_modules/rpi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Raspberry Pi device

TODO:

- Use a venv for the module
- Add the shed-pi module imports to the Python PATH
- Better placement of logs

## Installation

### Enable interfaces

For any temperature sensors the 1 wire interface is required

```shell
sudo raspi-config
```

1. Select the option: "Interface Options"

2. Select the Option I7: "1-Wire"

3. Agree to installing the 1-Wire script

4. Reboot

```shell
sudo reboot
```

Sanity check that the 1 Wire data is available:

```shell
ls /sys/bus/w1/devices/
```

Check the value read, be sure to change "28-000003ebbf13" to the values listed above:

```shell
cat /sys/bus/w1/devices/28-000003ebbf13/w1_slave
```

### Script auto start with systemd

Create a file in systemd

```shell
nano /lib/systemd/system/shed-pi-rpi-device-modules.service
````

With the contents

```ini
[Unit]
Description = Shed-Pi Device Modules
After = multi-user.target
StartLimitIntervalSec = 0

[Service]
Type = simple
ExecStart = /usr/bin/python3 /home/shed-pi/standalone_modules/rpi/device_protocol.py
StandardInput = tty-force

[Install]
WantedBy = multi-user.target
```

Enable the service, (CAVEAT: didn't work when manually starting, works on reboot)

```shell
sudo systemctl daemon-reload
sudo systemctl enable shed-pi-rpi-device-modules.service
sudo systemctl start shed-pi-rpi-device-modules.service
sudo systemctl status shed-pi-rpi-device-modules.service
```

Read the logs

```shell
tail -f /var/log/shed-pi.log
```
1 change: 1 addition & 0 deletions standalone_modules/rpi/device_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def __init__(self, submission_service: ReadingSubmissionService):
# Installed modules
self.rpi_device = RPIDevice(
submission_service=submission_service,
# TODO: Add these values as configuration!!
device_module_id=None,
cpu_module_id=None,
)
Expand Down
Loading