Reading meters using Bluetooth connection – Step by Step
If you want to read your meters using Bluetooth connection your meter must support Bluetooth. If the meter is not supporting Bluetooth then you can use optical Probe that supports Bluetooth or Bluetooth to serial port converter.
Bluetooth connection is shown as serial port and you can communicate with your Bluetooth meter using a normal serial port connection.
In this example, we are using Raspberry Pi and Gurux DLMS library for Python to read DLMS meter. If you want to read your meter using Windows you can access your meter in the same way. The only difference is how to pair your Bluetooth device with Windows.
First, you need to pair the Bluetooth device with the Raspberry Pi. You can do it as described here.
1. Get list of Bluetooth devices.
You get result like this, where XX:XX:XX:XX:XX:XX is BD address and HC-05 is device name.
Save DB address (XX:XX:XX:XX:XX:XX), you need it when you pair the device with Raspberry Pi.
2. Pair the meter with Raspberry Pi
Start pairing with bluetoothctl.
Then pair device:
agent on default-agent scan on
PIN code is requested when you run pair. Here we are using default pin code 1234.
Next trust the Bluetooth device.
Now you can close bluetoothctl application typing exit.
Next connect to the bluetooth device.
sudo rfcomm bind 0 XX:XX:XX:XX:XX:XX
Bluetooth device is now connected to /dev/rfcomm0
You need to run this command again if you restart the Raspberry Pi.
3. Getting Python source codes from GitHub
You can get client source code from GitHub typing
git clone https://github.com/Gurux/Gurux.DLMS.Python
Go to the Gurux.DLMS.Client.Example.Python folder get the required packages.
cd Gurux.DLMS.Python/Gurux.DLMS.Client.Example.Python pip install -r requirements.txt
4. Reading the meter.
You can finally read your meter using Gurux.DLMS.Client.Example.python. Go Gurux.DLMS.Client.Example.python folder and run:
python main.py -S /dev/rfcomm0 -t Verbose
Thats it. If you have any questions or ideas how to improve Gurux.DLMS component let us know or ask question in a Forum