0% found this document useful (0 votes)
68 views

Module C - Test Paper

The document outlines tasks for a test project using a Raspberry Pi 4 with various sensors and displays. Competitors must: 1. Display their country's flag on an OLED display and print sensor data to segment displays and InfluxDB. 2. Create APIs to return local sensor and remote sensor data in JSON or XML formats. 3. Configure Grafana with dashboards and alerts to monitor the sensor data in InfluxDB.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views

Module C - Test Paper

The document outlines tasks for a test project using a Raspberry Pi 4 with various sensors and displays. Competitors must: 1. Display their country's flag on an OLED display and print sensor data to segment displays and InfluxDB. 2. Create APIs to return local sensor and remote sensor data in JSON or XML formats. 3. Configure Grafana with dashboards and alerts to monitor the sensor data in InfluxDB.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Module C - Test project

Hardware
● Raspberry Pi 4 Model B 8GB
● 1x BME280 Environmental Sensor (I2C Connectivity, Address 0x76 or 0x77)
● 2x MAX7219, 8 character, 7 segment displays (SPI Connectivity, Port 0, Device 0)
○ Note: These devices are chained together where the output of the first is the input
of the second
● 1x SSD1351 based 128x128 RGB OLED display (SPI Connectivity, Port 1, Device 0)

Hardware access
● Access is configured via the Management UI located at https://ws.netlabs.xyz/login
● Competitors will have received their login username & password by email
● Competitors must upload a valid OpenSSH format SSH Key, these can be obtained from
○ Linux/Mac/WSL ssh-keygen then copied from ~/.ssh/id_rsa.pub
○ Copied from PuttyGen on Windows (Must be in OpenSSH authorized_keys format)
● Once a valid key has been added to the account the competitors will be able to reserve a
node from the hardware cluster, this node will be picked at random by the management
system and a base image of “Raspberry Pi OS Lite” with some minor required changes
applied
○ Users SSH Keys added
○ Apt repository modified to local mirror
○ Hostname configured to be unique on network
○ Password authentication disabled on SSH (SSH Keys are required)
○ Boot config modified to enable SPI0, SPI1, I2C
● All access to the competitors node will be via SSH
○ For ports other than SSH(22), SSH tunneling is required, an example of this is
available on the ManagementUI
Tasks
1. Download and extract the folder of country flags located at
a. https://ws.netlabs.xyz/flags.zip => /opt/flags.zip
b. flags.zip should be extracted to /opt/flags/
c. Create a new service called “oled-flag” and configure to display your countries
flag on the attached OLED display after booting up
i. This should require no interaction to run/start at boot
d. Note: Red and Blue channels may be switched, this will not be penalised

2. Create a python script at /usr/local/bin/bme280


a. This script should have a valid shebang (#!) to the python interpreter
b. This script should print to stdout data from the attached BME280 sensor in the
following JSON format
i. {
“temp”: 21.45,
“pressure”: 1008.98,
“humidity”: 48.66
}
1. “temp” in degrees Celsius
2. “pressure” in millibar
3. “humidity” in %
4. These values should all have 2 significant figures

3. Create a startup service that displays the current time and cycles through the readings
from the bme280 script on the attached 7segment displays
a. An example video of this is available at
https://www.youtube.com/watch?v=T-EEsQTD8SU
b. This service should start at boot time with no interaction required by the user

4. Create a python script at /usr/local/bin/pi_status


a. This script should have a valid shebang (#!) to the python interpreter
b. This script should print to stdout some system stats in the following JSON format
i. {
“cpu”: {
“temp”: 56.33
},
“ram”: {
“used”: 88,
“free”: 7426
},
“uptime-hrs”: 1.3
}
1. “cpu:temp” in degrees Celsius
2. “ram:used” in MB (MB/MiB are both acceptable)
3. “ram:free” in MB (MB/MiB are both acceptable)
4. “uptime-hrs” in decimal hours (90mins = 1.5)
5. Install and configure Grafana & InfluxDB
a. The Grafana username/password is given on the ManagementUI
b. InfluxDB should be protected with basic authentication using the
username/password given on the ManagementUI
c. Unauthenticated access to InfluxDB should be prohibited

6. Create a new database on InfluxDB named readings

7. Create a SystemD timer to insert the data from the bme280 sensor into the new InfluxDB
measurement named bme280 every minute
a. The fields for this should also be
i. “temp” in degrees Celsius
ii. “pressure” in millibar
iii. “humidity” in %

8. Configure Grafana to show the data from the readings:bme280 measurement in a new
dashboard named “Local Sensor”
a. This dashboard should have 2 panels
i. Temperature & Pressure data
ii. Temperature & Humidity data
b. Configure an alert on the Temperature & Humidity panel to raise an alert when
iii. Temperature is > 20°c
iv. Temperature is < 10°c
v. Humidity is > 60%
vi. Humidity is < 40%
c. This should be a POST webhook alert with the URL of
○ https://ws.netlabs.xyz/alerts

9. Create a python script at /usr/local/bin/remote_sensor


a. This script should have a valid shebang (#!) to the python interpreter
b. This script should connect to the given API endpoint with credentials and return as
a valid JSON String
i. Endpoint: https://ws.netlabs.xyz/remote_sensor
ii. {
“temp”: 21.45,
“pressure”: 1008.98,
“humidity”: 48.66
}
1. “temp” in degrees Celsius
2. “pressure” in millibar
3. “humidity” in %
4. These values should all have 2 significant figures
10. Install Nginx and configure for the following use
a. Nginx should be available on port 80
b. Setup a simple GET API that returns the values of the scripts created above in
either JSON or XML format depending on the requested content-type
i. You can use any framework you like, some suggestions are
Flask/Falcon/Django
c. /usr/local/bin/bme280 http://<your_lan_ip>/bme280
d. /usr/local/bin/remote http://<your_lan_ip>/remote
e. /usr/local/bin/pi_status http://<your_lan_ip>/local_status

You might also like