components/libscpi | ||
main | ||
pictures | ||
.gitignore | ||
CMakeLists.txt | ||
DMM_158D.md | ||
DMM_623.md | ||
LICENSE | ||
README.md |
This project adds a computer interface to some Digital Multi-Meters (DMM). It allows remotely reading the measurements and, depending on the model, changing modes. It currently supports the Richmeters 158D and Aneng 623.
This firmware is for ESP32-* and uses the esp-idf development environment. I used ESP32-C3 Super Mini and WeMos S2 Mini development board. It will decode the I2C communication with the device's LCD to get the measurements. It can also simulate button presses to change modes.
installation
Follow the installation instruction for the corresponding DMM:
- Richmeters 158D (doesn't support mode setting)
- Aneng 623 (supports mode setting)
compilation
Compile the firmware using ESP-IDF (v5.3.1):
idf.py set-target esp32s2
# config project under ESP-DMM interface menu
idf.py menuconfig
idf.py build
idf.py -p /dev/ttyACM0 flash
The ESP-DMM configuration entry menu provides a lot of options:
- the GPIOs used
- the interfaces provided (UART, USB, network)
- the protocol used (ASYC-II, VC870, SCPI)
interfaces
USB
The USB interface is the most practical and stable. It also allows to power the ESP, but connects the grounds (see installation)
UART
The UART interface is mostly intended to be connected to an infra-red and used with an opto-coupler so to provide galvanic isolation But you could simply also use it to interface with any other MCU.
network
The network interface is the primary goal of this project. It allows getting the measurement remotely over WiFi, also providing galvanic isolation. Provide the WiFi credentials using the configuration menu so it can connect to your access point. While on UART and USB only one protocol can be used, over network both can be provided by using multiple TCP ports.
Bluetooth
No Bluetooth interface option is provided. I just find Bluetooth a pain to use on computers, and there is no phone app for this project. While Bluetooth Low Energy has the advantage to draw less energy from the battery, the ESP BLE is actually not that efficient. But the source code is open, so feel free to add it yourself.
protocols
ASYC-II
The data can transmitted using the ASYC-II 16 bytes ASCII protocol also used by Metrix MX56C. It it simple, but also human readable. To view the measurements, use any serial terminal (for UART set the configured baud rate; also enable new line on carriage return):
picocom --imap crcrlf /dev/ttyACM0
Using this protocol also allows to interface it with sigrok:
sigrok-cli --driver=metrix-mx56c:conn=/dev/ttyACM0 --continuous
It also allows to get the battery level and second measurement, the one on the top right of the LCD. Just enable these options in the configuration menu. It does not show min./max./hold status.
You can also connect over the network (adjust the IP and port to your setup):
nc 192.168.42.168 623
Because the output does not use line feed but only carriage return, the single line with always be updated. If you still want scrolling measurements, create a serial to TCP bridge using socat, and just use the serial terminal in another tab:
socat -d pty,raw,echo=0,link=/tmp/ttyV0 tcp:192.168.42.168:623
picocom --imap crcrlf /tmp/ttyV0
Sadly the sigrok metrix-mx56c driver only allows serial connections, and cannot use the tcp-raw conn option. Also this serial interface cannot be used by sigrok, as it does not allow virtual interfaces.
But we can use tty0tty to circumvent this restriction:
# create serial interfaces (tnt0 is connectect to tnt1, and so on)
sudo modprobe tty0tty
# connect serial interface to network (in separate terminal)
socat -d /dev/tnt1 tcp:192.168.42.168:623
# use sigrok
sigrok-cli --driver=metrix-mx56c:conn=/dev/tnt0
Advantages:
- human readable
- can display the non-standard measurements (NCV/live, dwell angle, pulse duration, RPM)
- can display auxiliary measurements (often the temperature)
- can display the battery level
- supported by sigrok (only the standard measurements)
Drawbacks:
- no mode setting
- no native sigrok network support
VC870
The data can transmitted using the VC870 23 bytes ASCII protocol (contains errors) also used by Voltcraft VC-870.
This protocol is also supported by sigrok.
sigrok-cli --driver=voltcraft-vc870-ser:conn=/dev/ttyACM0 --samples 1
While it is also an ASCII-based protocol, it is not really human readable. As for ASYC-II you can use a serial terminal or netcat on port 870 to see the traffic.
This protocol is also supported by QtDMM. This allows having a simple GUI for the DMM. And using tty0tty and socat (as described above), you can also connect it over the network.
Advantages:
- supported by sigrok
- supported by QtDMM
Drawbacks:
- not human readable
- no mode setting
- no native sigrok network support
SCPI
The second protocol supported is SCPI. While this protocol is kind of standardised, each instrument has its own flavor of it. This project use the scpi-parser library to support this protocol. This project's implementation pretends to be an Agilent 34401A since this is already supported in the latest sigrok release 0.5.2 (from 2018-12-23). If you use the git version of libsigrok, set in the source SCPI_IDN1 to GWInstek and SCPI_IDN2 to GDM9060, as this supports more commands.
Over USB:
sigrok-cli --driver scpi-dmm:conn=/dev/ttyACM0 --get measured_quantity
sigrok-cli --driver scpi-dmm:conn=/dev/ttyACM0 --samples 1 --output-format analog
And it has the advantage over ASYC-II and VC870 to also be directly usable over the network:
sigrok-cli --driver scpi-dmm:conn=tcp-raw/192.168.42.168/5555 --samples 2
To manually do it over the network:
echo "READ?" | netcat -v -w 1 192.168.42.168 555
The other advantage of SCPI is that it's bidirectional, meaning you can send commands, like setting the measurement mode (e.g. CONF: command). Because the DMM uses button instead of a dial, it registers button presses. When enabled in the configuration (by default) and connected to the right points (see installation), the ESP can simulate these presses, thus set modes.
echo "CONF:VOLT" | netcat -v -w 1 192.168.42.168 5555
sigrok-cli --driver scpi-dmm:conn=tcp-raw/192.168.42.168/5555 -c measured_quantity=voltage/dc --set
To get all supported commands, use the SYSTem:Help? command:
echo "SYST:H?" | netcat -v -w 1 192.168.42.168 5555
You can also use SmuView to have a GUI for remote DMM operation. It shows measurements in real time, and even allows easily setting modes.
smuview --driver scpi-dmm:conn=tcp-raw/192.168.42.168/5555
Advantages:
- mode setting
- supported by sigrok
- supported by SmuView
- mostly likely supported by other SCPI-based software
- native network access
Drawbacks:
- requires querying instead of continuous stream