It would be great because up until now I have failed miserably when trying to read the firmware. I've found the way to power up the board but I'm having problems with TX and RX due to lack of experience.
I was trying to connect directly to CSE but without any luck.
[Edit] And where should I cut if that is a solution for backup fw? I can remove CSE for the time being but I'm not so sure that I will be able to place it back due to my soldering skill.
CSE7759B may interfere with the flashing of WiFi module. Once the connection to CSE7759B is temporarily removed, you can first make a 2MB backup of the flash, maybe extract Tuya Config from that, if possible, and later try to flash the OBK
So, where do you connect them currently? Which two of four pins on the white ribbon are VDD and GND? The RX/TX port of CB2S is at the PCB side, so it may be hard to follow it.
Are you sure that CSE7759B and CSE7766 are using the same protocol? I don't remember checking my driver on CSE7759B, you may be the first one with it.
I may need to adjust the driver if there is a difference
Is only current read broken, voltage and power are correct?
Make sure the serial link is set to 4800bps. Each meter reading (from the CSE chip) is 24 bytes. The code below assumes you have read the 24 bytes from the CSE chip into inData[] (byte array) (starting with 55 5A) .
Extract the volts from the inData byte array like this:
Extracting the watts & amps is the same except use a different position in the inData array (as the instructables link above shows).
Hope this helps. I find these CSE chips are sensitive and very accurate but they don't tell you the direction of the current.
BTY, a NAN float value is probably caused by a division by zero. The most common mistake is shifting the data left in a byte and making it zero. The ULONG (unsigned long) data conversion in the GetData() function prevents this.
Looking at the photos of the Tuya WiFi Energy Meter in taktlos's original post, the circuit does not appear to have the live AC side isolated from the DC side. If you try to flash that with it connected to the power it could destroy your computer. This also makes it hard to debug and the circuit could be dangerous to touch. So, maybe it is better to use a power meter that is properly built?
Most cheap power meters from China have the CSE7759 chip in them which we know is easy to read with an arduino. The meter shown below came with an inverter I bought from AliExpress. I expect most cheap meters with an LED display from AliExpress are similar.
The bottom photo shows the meter main PCB with the display PCB removed. I have connected the CSE7759 chip and 5V power to the Arduino pro-mini and been able to read the power meter with the code I described in my posts above. The meter still works and displays the watts and volts on the display board if you fit it to the main board.
Looking at the main PCB (bottom photo), positioned at the bottom left is the 5V power supply module. Position at the mid-right on the main PCB is the ZMPT107 transformer which acts as an isolation transformer for reading the voltage. The CT current sensor is plugged into the top right connector. This totally isolates the DC side from the AC side and makes the DC side safe to work on and debug with the meter functioning.
The bottom connector is for power. Above the ZMPT107 is the CSE7759 chip which is easy to connect to the arduino with just 2 wires.
Another reason why this solution may be better is because many places (like Australia) have the home power meter in a metal meter box on the side of the house. So the WiFi won't work if it is in a grounded metal box. So, this way we can have the arduino+wifi+antenna mounted in a separate case on top of the meter box and connected to the power meter with a 3 or 4 wires. A proper antenna would also provide more wifi range. You might need to check that the arduino and wifi module does not overload the 5V power supply module on the main meter PCB.
Will this read negative power? It seems most Tuya devices are configured from the factory not to, even when having a supported power meter IC such as the BL0942
No, that's a big deficiency with the CSE7759 chip. Apparently, China hasn't learned how to read the direction of AC power yet. The only power meters I can find from China that read import/export power do it with two current sensors. Here is one from Tuya, but it is one of those non-isolated meters, so be careful. If you clip one CT sensor onto the AC output from the solar inverter and the other one onto the home mains, the difference should be the import/export power.
Alternatively, one way to read AC power and direction with an Arduino and one CT sensor is to use the Emon lib. See here: Link
To do this you will have to construct the CT sensor and Voltage sensor circuits given in the schematic. Link
That's not too hard. The website explains the calibration procedure. Link
I am considering building a phase detector circuit for the CSE7759 chip which will indicate the direction of the current. I will post it here if I make progress on that.
BTY, this is the meter in my post above. Apparently, it is the only one I can find with an isolated DC circuit. Just search AliExpress for: "Current Limiter Sensor for Soyosource GTN" Link
If you want to read this meter directly from its RS485 port, there is code for that available. This code simulates the meter's RS485 serial output and explains the protocol. Link
Thanks for sharing. I wasn't aware of that sensor, using the two halls. That explains right the home assistant configuration with the strange two sensor input and 'calculations'.
Meters based on the BL0942 can measure bi-directional. The problem is that the Chinese don't implement this feature on their firmware (it needs flashing with open Becken) and it's not always easy to know which ones have this chip. While they are not isolated, it is easy to isolate the BL0942 chip using a Silicon labs SI8621 or other equivalent, right at the serial interface, if the MQQT readings method is not suitable.
PS: Calibration (and drift) from a hall sensor are a nonsense. With a standard shunt resistor, calibration is done once and fairly accurate throughout the load range. Super easy to do on OpenBecken too. Just connect a resistive load of known consumption and set the values on the web interface.
I started a thread about it here: Link, so as not to hijack this one
Hi p.kaczmarek2, your help is more than welcome. Same with anyone else.
A safe bidirectional power meter module for arduino is desperately needed. The wifi in those cheap non-isolated wifi meters from China won't work inside a metal meter-box because it is inside a Faraday cage. If someone tries fit an external antenna to the wifi module it could cause a big problem. This is because the ground (0V) in those non-isolated meters is connected directly to the AC neutral (N) wire. So if you use a coax cable to put an external antenna on top of your meter-box and use the meter-box as the ground plane, this will trip the earth leakage detector in the AC power circuit breaker. This is because some of the AC power going into the meter will return via the meter box earth (E) and not the neutral wire (N). The other problem is with trying to code, debug and calibrate a live circuit.
The circuit below is based on the isolated CSE7759 power meter in my posts above. Both the CSE7759 and BL0942 chips use a 0.001 ohm shunt resistor for the amps and a 1000:1 divider circuit to measure the volts, so this should work. We could make the burden resistors variable for calibration?
I have ordered all the components and will try to get a prototype working. Any suggestions are welcome. If, you want to start a new thread for this project that's ok with me.
If you want to use the BL0942 as above, then my suggestion is to keep the mains referenced stuff and isolate at the RS232 level. I attach one such reference design for you to have a look - But in practice you can use any design and just add the opto-isolators to the serial line. You'll probably want to keep the WiFi chip on reset and instead use one externally, if WiFi range is a problem.
I had a look at the CSE7759, but it doesn't appear to have a feature to measure the direction of the power flow. So you can't use that for a bidirectional power meter. It will give you the absolute value, but not the direction. It seems similar to the BL0937.
The discussion revolves around the challenges faced while programming the EARU EAWEM-T-CT power meter, which utilizes the CSE7759B chip. Users share experiences regarding firmware reading, UART communication issues, and the need for proper connections to successfully flash the device with OpenBeken firmware. Several users suggest methods for connecting the CSE7759B and CB2S chips, including desoldering components and using specific programming adapters. The conversation also touches on the differences between the CSE7759B and CSE7766 chips, calibration issues, and the importance of isolating the device during programming to prevent damage. Additionally, there are discussions about the limitations of the CSE7759B in measuring bidirectional power and the potential need for a new driver to support it. Summary generated by the language model.