SpringBoot REST Service to provide gas meter reading via i2c QMC5883L 3-Axis Magnetic Sensor on Raspberry Pi. Depends on Python driver for the QMC5883L 3-Axis Magnetic Sensor project
e.g. http://localhost:8081/energy
*{
- "timestamp": "2020-10-03T15:19:17Z",
- "consumption": 2352.0,
- "serverID": "09 01 49 ... 4F 3E 5D", *}
Rest Service can run on other server (Server B / Raspberry Pi) than OpenHAB server
openhab config files to visualize electricity meter included in project
- Install OpenHab on Linux Server A e.g. via docker-compose.yml -> https://github.com/openhab/openhab-docker
- Install HTTP Binding (http://ServerA:8080/paperui/index.html#/extensions?tab=binding)
- Install RRD4j Persistence (http://ServerA:8080/paperui/index.html#/extensions?tab=persistence)
- Config files will be placed below /var/lib/docker/volumes/openhab_openhab_conf
- Summery page will be availible on http://ServerA:8080/basicui/app
- Pepare Linux Server B to serve the REST Service
- Connect cable from 3-axis compass to raspberry pi
- TODO: some more details.... (see below part)
- Build REST Service (tested with java11)
- maven based SpringBoot Service (mvn clean package)
- Transfer build jar file to Server B and start REST Service
- Start REST Service via "java -jar gas_meter_rest_service-1.0-SNAPSHOT.jar"
- Crontab restart scenario:
- @reboot /home/pi/git/gas_meter_rest_service/scripts/test_raw.sh > /dev/null 2>&1
- @reboot /usr/bin/java -jar /home/pi/git/gas_meter_rest_service/target/gas_meter_rest_service-1.0-SNAPSHOT.jar > /dev/null 2>&1
Following parameters are relevant
- value of current gas meter in "currentGasValue.txt" file
- id of gas meter in "gasMeterId.txt" file
gas meter
sudo apt-get update ls /dev/i2c -> ls: cannot access '/dev/i2c': No such file or directory sudo apt-get install -y i2c-tools sudo raspi-config -> Enable "ARM I2C interface" sudo i2cdetect -y 1 -> shows some table information now ls /dev/i2c -> shows "/dev/i2c-1" sudo i2cget 1 0x0d 0x01 -> 0x00 sudo apt-get install python sudo apt-get install python-smbus sudo apt-get install python-pip git clone https://github.com/abhiTronix/py-qmc5883l.git vim py-qmc5883l/py_qmc5883l/init.py -> change from smbus2 to smbus cd py-qmc5883l sudo pip install . -> Successfully installed py-qmc5883l-0.1.1
cd ../gasmeter/ ./test_raw.sh
java -jar qmc5883l-0.0.1-SNAPSHOT.jar cd git/gasmeter/input/