Web server for Raspberry Pi computers written in Rust serving JSON data from a Bosch BME280 sensor.
RPPAL compatible operating system and hardware
Configuration is loaded from a TOML file that contains parameters required for the operation. Sample of the configuration
Address of the sensor, path the server should respond to, port server should reserve and limit of measurement considered stale can be customized.
A sample of systemd service file is provided at sample.service That must be modified to match compiled programs location
ExecStartDefines the program that is to be run. Sample assumes that binary is located in/home/Pi/Programs/rpi-bme280-server/directory and namedrpi-bme280-serverand thatconfig.tomlfile is present in the working directory.WorkingDirectorySets the working directory for the program, ifExecStartline does not contain the configuration file locationconfig.tomlfile must exist in the working directory.
The service file can be copied to target systems /etc/systemd/system/ folder with
appropriate name. After file has been copied the server can be started by using $sudo systemctl start sample.service command.
When requested server tries to connect to the sensor over I²C, if the sensor is currently in use the most recent measurement that was completed will be returned.
Sample output:
{"unix_timestamp":1630406866,
"temperature_c":17.995813178854586,
"pressure_pa":99947.35153765255,
"humidity_relative":67.69223043636826}