Substitutes the RS485 modbus service of DTSU-H coil based 3 phase power meter for usage with a Deye hybrid inverter.
On phase L1 it reads every 4. current waves, on phase L2 and L3 it reads only every 8. half wave.
- Astonishing accuracy of 1% at my site.
- Every watt-hour, the build-in LED flashes for 30 ms. On negative energy it flashes twice.
- 2 buttons to set a correction percentage other than 100% - which was not required at my site :-).
- Display of Power, Energy, Time for energy and correction percentage on a locally attached 1602 LCD.
- Page button for switching 4 LCD display pages.
- Debug button/switch for realtime monitoring analog current and voltage of 4 different half waves with Arduino Plotter.
- Serial.print() is still available for monitoring and debugging.
- Watchdog reset after 8 seconds. It resets the CPU, e.g. if zero voltage crossing cannot be determined, or the program hangs at another location.
- Display of watchdog reset reason, which currently (3/2024) only works with optiboot 8.1 bootloader.
For all, which want to see the values sent by a real DTSU666 or see the vlues sent by this program e.g. at the other end of the RS485 line, this repository contains a simple Modbus sniffer program. It displays the power values on a 1602 serial LCD.
Modbus reply sending at 9600 baud is done by SoftwareSerialTX.
This enables the usage of the Arduino Serial for monitoring and debugging.
Modbus receiving at 9600 baud is done by standard Arduino Serial at 9600 baud.
Monitoring output is done by switching Arduino Serial baudrate to 115200 baud,
send data, flush it and reset Arduino Serial baudrate back to 9600 baud.
During monitoring output, receiving of modbus requests is therefore disturbed!
We assume, that voltage waveform of the 3 phases are equal and negative and positive values are symmetric, so we take only one half wave as voltage reference.
Phase A is reference (the one, which supplies the voltage and which can be negative), phase B has a delay of 6.6 ms / 120 ° and C a delay of 13.3 ms / 240 °.
- Read "positive" part voltage values of phase A for 10 ms and store 385 values in RAM to be used as reference for all 3 phases. This starts 16 Bit timer 1 to keep track of the phase for the next current measurements.
- Wait 3.3 ms.
- After 10 + 3.333 ms do 10 ms phase C current measurement. Multiply values with voltage.
- Wait 3.3 ms.
- After 20 + 6.666 ms do 10 ms phase B current measurement. Multiply values with voltage.
- Wait 3.3 ms
- After 40 ms do 20 ms phase A current measurement, which will also cover negative current. Multiply values with voltage.
- 20 ms for math and reply to RS485 or output to LCD until starting again at 80 ms - x ms.
The Deye inverter sends a 9600 baud modbus request 01 03 15 1E 00 06 A1 C2 every 100 ms to 120 ms.
We send the reply at pin 2 with software serial at a 80 ms raster.
This means, around every 400 ms we have one loop where we do not need to reply and can update the LCD instead.
Sometimes the Deye sends the request, while we do a reply.
My installation | Display and buttons |
---|---|
Breadboard detail | Automatic brightness |
Split-core current transformers used | Deye settings |
DTSU666ModbusSniffer | |
Also usable as connection schematic.
Power page | Energy page |
---|---|
Time for Energy page | Period page |
Reference phase - positive half wave | Reference phase - negative half wave |
---|---|
6.6 ms / 120 ° delayed phase | 13.2 ms / 240 ° delayed phase |
6.6 ms / 120 ° without low-pass | 13.2 ms / 240 ° without low-pass |
Implemented with 3 x 30A split-core current transformers.
2. order low pass 1600 Hz, to suppressthe high frequency modulation of current as seen above.
____ ____ _____
o---|____|---o---|____|---o---|_____|---o-----> A1 (A2, A3)
| 1k | 1k | 10k |
Split- > | | |
core < --- --- | Schottky diode
coil > --- 100 nF --- 100 nF o-|<|-o
< | | |
__|____________|____________|___________________|__ GND
Grid voltage divider for full range (1.1 V) at 400 V.
HIGH VOLTAGE - DANGER - use heat-shrink tubing
____ ____ ____ _____
230V~ L1 >--|____|---|____|---|____|---|_____|---o-----o-----> A0
1M 1M 1M 630 k | |
_ |
| | | Schottky diode
| | o-|<|-o
|_| |
| |
__|___________|__ N (GND)
# Automatic brightness control for 1602 LCD
5V O------o------o
| |
_ |
| | |
LDR | | |
|_| |
| |/
o----|
|>
|
O To anode of LCD backlight
Download and extract the repository. In the Arduino IDE open the sketch with File -> Open... and select the Arduino-DTSU666H_PowerMeter folder.
All libraries, especially the modified ones, are included in this project.
If you burn the Optiboot bootloader on the Nano, the reboot flags are available at startup and the (watchdog) reboot reason character can be displayed.
This program uses the following libraries, which are already included in this repository:
- SoftwareSerialTX for sending Serial to JK-BMS.
- Modified LiquidCrystal for 1602 LCD.
- EasyButtonAtInt01 for LCD page switching button.
- Breadboard.
- Jumper wire and cables.
- Pin header to connect cables to breadboard.
- Arduino Nano.
- TTL to RS485 converter module with 74HC04 and MAX485.
- 10 nF capacitor to increase the C2 capacitor on the module, preventing the module (using 74HC04 instead of 74HC06) from ringing.
- 4 Schottky diodes for the 4 analog pins used e.g. BAT 42, BAT 43, BAT 85.
- 6 x 100 nF capacitors and 6 x 1 kOhm resistors for the 3 low-passes.
- 3 x 1 MOhm + 630 (680) kOhm + 10 kOhm for the 230 V voltage divider.
- Power supply.
- 1602 LCD.
- LDR for automatic LCD brightness control.
- BC 549 or any NPN type for automatic LCD brightness control. The effect varies, depending on the LDR and the hFE of the transistor.
- SUN-5K-SG05LP1-EU
- Improved button handling.
- 2 flashes on negative energy.
- Added Optiboot 8.1 for improved watchdog handling.
- Added macro STANDALONE_TEST.
- DTSU666ModbusSniffer - added direct_pin input to show non lowpass filtered data.
- Fix LCD power-sum bug.
- Error handling and watchdog added to improve stability.
- Added reply to 0x2014 (Power in 0.1 W units) and 0x0006 (Current transformer rate IrAt).
- Initial version.
See also here.
START ../src/Arduino-DTSU666H_PowerMeter.cpp
Version 1.0 from Sep 19 2023_
If you connect periodically print pin A4 to ground, Serial plotter data is printed every 2000 ms
Power correction + pin is 5
Power correction - pin is 4
LCD data is printed every (8 * 80) ms
Reference line, which can be negative is 2
Line, with 6.6 ms delay is 1
Line, with 13.3 ms delay is 3
Waiting for requests to ID MODBUS_SLAVE_ADDR with _9600_ baud at pin RX. Reply / TX is on pin 2
First waiting for voltage at line2
Power correction is 100 %