- dmm-ble-mp730026
- About
- Installation
- Before first run
- Running
- Advanced Usage
- Accessing the Data
- Example URLs
- OBS
- Troubleshooting
- Supported Meters
Python code to access the a Multicomp Pro MP730026 (and others) DMM over BLE
This multimeter supports communication over Bluetooth, however, the official software is not very good. It only works with a specific dongle.
Using the bleak python module, virtually any operation system and Bluetooth controller works. So far I have successfully used this code with:
-
Linux: Raspberry Pi 3B, Raspberry Pi 4, Raspberry Pi0W *Recommended
-
macOS: Macbook Pro and MacPro (Trashcan)
-
Windows 10: Microsoft Surface Book Pro 2
The intent for the code is to provide an object representing the DMM.
bleak_scan.py can be used to find the MAC address of your meter.
The recommended method for installing is to use git on a Raspberry Pi
git clone https://github.com/baldengineer/dmm-ble-mp730026.git
setup on Raspberry Pi:
cd ~/dmm-ble-mp730026
./pi_setup.sh
A systemd service file is provided for your convience. It will need to be edited to point to your working directory and virtual enviroments python binary.
[Unit]
Description=Bluetooth DMM broker
After=network.target
[Service]
Type=simple
Restart=always
WorkingDirectory=/path/to/dmm-ble-mp730026/
ExecStart=/path/to/dmm-ble-mp730026/.venv/bin/python3 main.py
Restart=on-failure
[Install]
WantedBy=multi-user.target
setup on Windows:
WIP
This will install the appropriate programs needed and create a python virtual environment
Note about dmm.js
Building dmm.js
requires installing node and some node modules to build it from source. These will install locally inside the scripts folder. The installation script will then build dmm.js
.
Copy the settings.py.template
to settings.py
This file will not be over-written on updates.
The multi_meters
is a comma separated list for each meter you wish to connect to. The template currently has MP730026 as meter 0, and Demo as meter 1.
See Supported Meters for specific configurations to pass.
On Raspberry Pi, use:
cd ~/dmm-ble-mp730026
./run.sh
Will start up the webserver, websocket server and Bluetooth services for getting data from the meter.
If you get a permissions error on Raspberry Pi see Raspberry Pi Permissions
This library exposes a DMM object that exposes all the data for a mp730026 multimeter
self.address = address # Devices MAC address
self.mode = False # Current measurement Mode. EG AC voltage
self.hold = False # hold Flag
self.rel = False # rel Flag
self.value = False # String containing 4 digit and one decimal Value
self.suffix = False # String of data suffix. EG mV KΩ
self.decimal = False # Decimal Position
self.negative = False # If the number is a negative value
self.autorange = False # Auto-range flag
self.connected = False # Returns the status of the meter
self.digits = 4 # The number of digits the meter can display
self.model = "Mfg Model" # Manufacturer and Model numbers of meter
These values are updated by calling parse() with a raw byte array of the data from the DMM.
DMM.parse([0x23, 0xF0, 0x04, 0x00, 0xDE, 0x85])
# this fills the object variables as such
mode = "DC volts"
hold = False
rel = False
value = -1.502
suffix = "V"
decimal = 1
negative = False
autorange = False
You can access the web front end on port 18881, example: http://192.168.1.71:18881
Shortcut for meter 0 you can use http://192.168.1.71:18881/0 Shortcut for meter 1 you can use http://192.168.1.71:18881/1 etc...
These will redirect you to a longer URL that has settings for colors and label text that you can tweak with the information in Example URLs
Included is an example for connecting a meter to a web-socket for sending the data across the internet, In this case to a web page to show off the multimeter reading in real time.
Opening meter.html either locally or hosted with the following flags
*websocketserver required
IP Address or Host name of server, eg 127.0.0.1, 192,168.1.100, raspberrypi
websocketport
Web socket port, defaults to 18881
meter
Give an integer value that matches the index in your settings.py. For the first meter use 0, second, 1, etc...
Defaults to meter 0 if no value is passed, or is an invalid value.
background
RGB syntax or HTML color names,
rgb(250,128,114)
salmon
oncolor
Color of the darker background elements of the display
offcolor
Color of the brighter foreground elements
- http://127.0.0.1/index.html?websocketserver=127.0.0.1&websocketport=18881&background=grey&onColor=black&offColor=dimgrey
- http://localhost/?websocketserver=127.0.0.1&websocketport=18881&background=black&onColor=Lime&offColor=DarkGreen
- http://localhost/?websocketserver=127.0.0.1
- http://192.168.1.71/?websocketserver=192.168.1.71&websocketport=18881&meter=0
Open saved.html either locally or hosted with the same flags as Accessing Live Data.
- http://127.0.0.1/saved.html?websocketserver=127.0.0.1
- http://192.168.1.71/saved.html?websocketserver=192.168.1.71&websocketport=18881&meter=0
- http://localhost/saved.html?websocketserver=127.0.0.1&websocketport=18881&background=black&onColor=Lime&offColor=DarkGreen
This was actually designed to be used with OBS as a browser source. The URL you generated above goes in URL height and width are as follows
width = 250
height = 85
All other defaults are fine.
You can configure the meter to automatically turn on and off the OBS Source by passing obs_source=
and obs_scene=
when configuring your settings.py. See the settings.py example in Supported Meters
Recommendation for setup is to create a Scene called Multimeters
, with a Source called Meter0
as a Browser Source, setting the URL as specified in Accessing Live Data. Then adding the Multimeters
scene as a Source in your primary scene.
In your settings.py in the OBS_Settings
class, set enabled=True
, and the other values as necessary to connect to your OBS instance.
In OBS, you need to install OBS-Websocket from - https://github.com/Palakis/obs-websocket
Permissions for the Pi user to access Bluetooth are needed
sudo adduser pi bluetooth
Also you will need to modify a file according to this post
If you get a Failed Building Wheel error or txdbus ModuleNotFound error you need to install the Twisted wheel manually.
Download the appropriate version from https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted
If you are using python 3.8, windows 64 bit download Twisted-20.3.0-cp38-cp38-win_amd64.whl
Then install with
source .venv/Scripts/activate
pipenv install %userprofile%\Downloads\Twisted-20.3.0-cp38-cp38-win_amd64.whl
Then run pipenv install
again.
The html interface can be locally provided to a web browser or OBS source. However if one desires to host it remotely a nginx file has been provided.
Install Nginx and link file
sudo apt-get install nginx
sudo rm /etc/nginx/sites-available/default # Warning: This will remove the default nginx page
ln ~/dmm-ble-mp730026/nginx-site /etc/nginx/sites-available/default
Mfg | Model | Required Parameters | Optional Parameters | Settings.py Example |
---|---|---|---|---|
Multicomp | MP730026 | MAC_Address | obs_scene="", obs_source="" | MP730026("AA:AA:AA:AA:AA:AA",obs_scene="MultiMeters", obs_source="Meter0") |
Owon | OW18B | MAC_Address | obs_scene="", obs_source="" | OW18B("AA:AA:AA:AA:AA:AA") |
Demo | Name | Demo(), Demo("My Demo") |
Support for more meters is in progress. If you have a meter you would like to be supported, please check the Issues, and add a new Issue if no one else has requested it.