Python script to read power meter data from sdm630 meters and publish them via mqtt and/or into a sqlite database.
I'm using this script on a Raspberry Pi 4 with rasbian buster with an RS485 usb adapter.
- You need an RS485 usb adapter
- Python3 is required (developed with 3.10.12)
- If you want to use the sqlite export, it is a little bit more complex, because the compiled python3 packages from apt-get have no sqlite support and you have to compile python on our own (see below)
With sqlite support
- run
compile_python_sqlite.sh
to compile python with sqlite support (takes long time!)
Without sqlite support
sudo apt-get install python3
Setup a virtual environment
- I recommend to create and use a virtual python environment for this script
- Open the sdm630-py path
python3.10.12 -m venv py-env
to create a virtual envsource py-env/bin/activate
to use virtual envpip3 install -r requirements.txt
to install python modules
Setup without virtual environment
pip3 install -r requirements.txt
to install python modules
- Edit
config.py
, set your device path ("dev"), mqtt settings, sqlite path... - Possible loglevels are: ERROR, DEBUG (others are currently not in use). Set loglevel to "DEBUG" for testing
- Set the loglevel in config.py to "DEBUG" and run
./sdm630-py.sh
- You should see a lot debug informations, but no Exceptions
- Check if the sqlite database has been created in the specified path (config.py)
- Check if the mqtt messages will be published correctly
- Exit with CTRL+C
- Remind to set loglevel back to "ERROR" (in config.py) to avoid huge log files
- Set the correct path for sdm630-py.sh in
sdm630-py.service
sudo cp sdm630-py.service /etc/systemd/system
to copy the service to your systemd pathsudo systemctl enable sdm630-py
to start sdm630-py automaticallysudo systemctl start sdm630-py
to start sdm630-py nowsudo systemctl status sdm630-py
to check if there are erorrs (1 error "reading failed" at the begining is ok)
For bugs or feature requests, please create an issue on github. "Star" or "Watch" the github repo if you like my work.
Regards, Arne Drees