ArminJo / Arduino-DTSU666H_PowerMeter

Arduino Nano substitute for a RS485 3 Phase DTSU666-H coil based power meter. Less resolution, but better display
GNU General Public License v3.0
7 stars 0 forks source link
arduino current-transformer dtsu666 modbus modbus-sniffer optiboot power-meter rs485 split-core-coils
# [Arduino Nano substitute for a DTSU666-H power meter](https://github.com/ArminJo/Arduino-DTSU666H_PowerMeter) 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.
[![Badge License: GPLv3](https://img.shields.io/badge/License-GPLv3-brightgreen.svg)](https://www.gnu.org/licenses/gpl-3.0)     [![Badge Version](https://img.shields.io/github/v/release/ArminJo/Arduino-DTSU666H_PowerMeter?include_prereleases&color=yellow&logo=DocuSign&logoColor=white)](https://github.com/ArminJo/Arduino-DTSU666H_PowerMeter/releases/latest)     [![Badge Commits since latest](https://img.shields.io/github/commits-since/ArminJo/Arduino-DTSU666H_PowerMeter/latest?color=yellow)](https://github.com/ArminJo/Arduino-DTSU666H_PowerMeter/commits/main)     [![Badge Build Status](https://github.com/ArminJo/Arduino-DTSU666H_PowerMeter/workflows/TestCompile/badge.svg)](https://github.com/ArminJo/Arduino-DTSU666H_PowerMeter/actions)     ![Badge Hit Counter](https://visitor-badge.laobi.icu/badge?page_id=ArminJo_Arduino-DTSU666H_PowerMeter)

If you find this program useful, please give it a star.

🌎 Google Translate


Features


Modbus sniffer

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 sending and receiving

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!


Principle of operation

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 °.

  1. 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.
  2. Wait 3.3 ms.
  3. After 10 + 3.333 ms do 10 ms phase C current measurement. Multiply values with voltage.
  4. Wait 3.3 ms.
  5. After 20 + 6.666 ms do 10 ms phase B current measurement. Multiply values with voltage.
  6. Wait 3.3 ms
  7. After 40 ms do 20 ms phase A current measurement, which will also cover negative current. Multiply values with voltage.
  8. 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.


Pictures

My installation Display and buttons
My installation Display and buttons
Breadboard detail Automatic brightness
Breadboard detail Automatic brightness
Split-core current transformers used Deye settings
Split-coil Deye settings
DTSU666ModbusSniffer
DTSU666ModbusSniffer


Example on Wokwi

Also usable as connection schematic.

Screenshots

LCD pages

Power page Energy page
Power page Energy page
Time for Energy page Period page
Time for Energy page Period page

Arduino plotter output of measured currents

Reference phase - positive half wave Reference phase - negative half wave
Reference positive Reference negative
6.6 ms / 120 ° delayed phase 13.2 ms / 240 ° delayed phase
7 ms 13 ms
6.6 ms / 120 ° without low-pass 13.2 ms / 240 ° without low-pass
7 ms without low-pass 13 ms 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


Compile with the Arduino IDE

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.


Libraries used

This program uses the following libraries, which are already included in this repository:

BOM


Tested Inverter

Useful Links

Revision History

Version 1.1

Version 1.0

Sample Serial output

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 %