Many users have requested a way to talk to their Mooshimeters programatically from their computer. This blog post introduces a library and a piece of hardware that will allow you to do that.
On the Mooshim Github page there is now Mooshimeter-PythonAPI, a set of Python classes that will allow you to connect to, configure and receive notifications from a Mooshimeter through a BLED112. The BLED112 is available from many suppliers for roughly $20USD.
Why do I need a BLED112? Why can’t I use a regular Bluetooth 4.0 dongle?
Windows 8 is the only version of Windows supporting Bluetooth Low Energy, and the majority of Mooshimeter users are running Windows 7 or earlier. This is a real shame, OSX and many flavors of Linux have BLE support built in by now. The BLED112 provides a BLE interface but looks like a USB serial port, which is almost universally supported. So with a BLED112 you can talk to your Mooshimeter programatically from Windows, OSX or Linux.
- Computer with USB port
- Python 2.X
- If you have pip installed you can install from the command line using “python -m pip install pyserial”
- You can install this in your Python Lib directory (usually C:/PythonXX/Lib) by copying bglib.py there, or just add bglib.py to your project
- Download the code from the Github page.
- Plug in the BLED112 to your computer and determine the path to the port.
- On Windows you can do this through the device manager:
- Run the Example.py script with the name of the port as the argument. The script will scan for Mooshimeters, connect to the one with strongest signal, configure it and start streaming voltage and current. A sample output is below.
python Example.py COM4
Initializing BLED112 on port COM4...
Found 3 Mooshimeters
CE:A6:A0:39:CD:20: -39 1BC5FFA0-0200-62AB-E411-F254E005DBD4
64:B8:A0:39:CD:20: -70 1BC5FFA0-0200-62AB-E411-F254E005DBD4
CC:A6:A0:39:CD:20: -55 1BC5FFA0-0200-62AB-E411-F254E005DBD4
Connected to 20:CD:39:A0:A6:CE
<... list of characteristics ...>
We hope this enables new applications for you and can’t wait to see what you come up with. Thanks for reading!