Mottramlabs / MQTT-Power-Sensor

45 stars 20 forks source link

Incorrect values being reported #11

Open CplSyx opened 1 year ago

CplSyx commented 1 year ago

Using the clamp SCT-013-000 and v2 of the firmware, I connect the clamp to my mains supply and obtain values of 38~40 being reported by the software output.

If the comment to Issue 3 holds true for firmware v2, I believe that indicates 0.38-0.4 A - which is incorrect as I have other devices drawing more than that at present. Additionally when turning on a known load of 8.3A (a heater), that reading jumps to ~178, which would be 1.78A. That's also incorrect. Even assuming that the values are raw within the 0-1024 range of the ADC, then 38 => 3.7A and 178 => 17.3A which is also incorrect as I'd expect a value change of around 85 and not 140.

I have tested the D1 board I am using and it correctly reads from the ADC A0 pin within the 0-1024 range at 0-3.3V, and the clamp is definitely picking up a change in current draw so I assume this is an issue within the firmware but I cannot determine where.

Looking for some advice as to where I could be going wrong please @Mottramlabs

Scoff123 commented 1 year ago

@CplSyx Did you manage to resolve this? I'm looking at buying the kit to put this together with one of my spare D1 mini boards, and just trying to work out if it's generally accurate or if there are still issues like you have raised here?

CplSyx commented 1 year ago

@Scoff123 I didn't get a response from the creator so I started pulling apart the code myself. I've reworked the entire thing in a forked repo (starting from the base Emonlib).

I had some issues with home assistant (unrelated to this) which means I've not been able to actually hook it in yet as I'm sorting out zigbee sensor issues, hence that part of the documentation being missing. However the test data using a reference load is now correct.

Scoff123 commented 1 year ago

@CplSyx Thanks for taking the time to respond. That's good to hear - would you be happy for me to use your reworked code in my setup? I'm just figuring out how I can use the clamp to monitor just the phase line in my 2 core + earth, but once I've got that sorted I can put this all together.

CplSyx commented 1 year ago

@Scoff123 Yes of course, feel free to use / alter as you wish.

If you can strip the outer sheath from a section of your twin + earth, you can put the clamp over the live wire.

Scoff123 commented 1 year ago

@CplSyx Hi thanks very much. I'm having a couple of compile issues using the firmware.ino that you have on your repo. I wasn't sure how to contact you? I've downloaded the necessary libraries but the .ino won't compile due to not finding some header files relating to ESPAsyncWebServer...

CplSyx commented 1 year ago

@Scoff123 In the Readme.md I've referenced the libraries you need - copied here for simplicity:

Assuming you're using the Arduino IDE you can download the latest releases of those libraries and then install them by going to Sketch > Include Library > Add .zip Library

Hope that helps!

Scoff123 commented 1 year ago

@CplSyx Thanks - I did read through the readme file and followed the required libraries and installed them with library manager within the Arduino IDE. I'm getting the following error during compile:

c:/users/thinkpadx260/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\ThinkPadX260\AppData\Local\Temp\arduino\sketches\CED1DDF4214782B6EE214442A04C06BF\libraries\EmonLib\EmonLib_CurrentOnly.cpp.o: in function _ZN13EnergyMonitor7currentEjd': C:\Users\ThinkPadX260\Documents\Arduino\libraries\EmonLib/EmonLib_CurrentOnly.cpp:31: multiple definition of_ZN13EnergyMonitor7currentEjd'; C:\Users\ThinkPadX260\AppData\Local\Temp\arduino\sketches\CED1DDF4214782B6EE214442A04C06BF\libraries\EmonLib\EmonLib.cpp.o:C:\Users\ThinkPadX260\Documents\Arduino\libraries\EmonLib/EmonLib.cpp:36: first defined here c:/users/thinkpadx260/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\ThinkPadX260\AppData\Local\Temp\arduino\sketches\CED1DDF4214782B6EE214442A04C06BF\libraries\EmonLib\EmonLib_CurrentOnly.cpp.o: in function _ZN13EnergyMonitor8calcIrmsEj': C:\Users\ThinkPadX260\Documents\Arduino\libraries\EmonLib/EmonLib_CurrentOnly.cpp:52: multiple definition of_ZN13EnergyMonitor8calcIrmsEj'; C:\Users\ThinkPadX260\AppData\Local\Temp\arduino\sketches\CED1DDF4214782B6EE214442A04C06BF\libraries\EmonLib\EmonLib.cpp.o:C:\Users\ThinkPadX260\Documents\Arduino\libraries\EmonLib/EmonLib.cpp:178: first defined here c:/users/thinkpadx260/appdata/local/arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.1.0-gcc10.3-e5f9fec/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\ThinkPadX260\AppData\Local\Temp\arduino\sketches\CED1DDF4214782B6EE214442A04C06BF\libraries\EmonLib\EmonLib_CurrentOnly.cpp.o: in function _ZN13EnergyMonitor11serialprintEv': C:\Users\ThinkPadX260\Documents\Arduino\libraries\EmonLib/EmonLib_CurrentOnly.cpp:81: multiple definition of_ZN13EnergyMonitor11serialprintEv'; C:\Users\ThinkPadX260\AppData\Local\Temp\arduino\sketches\CED1DDF4214782B6EE214442A04C06BF\libraries\EmonLib\EmonLib.cpp.o:C:\Users\ThinkPadX260\Documents\Arduino\libraries\EmonLib/EmonLib.cpp:214: first defined here collect2.exe: error: ld returned 1 exit status

exit status 1

Any ideas what might be going on?

Scoff123 commented 1 year ago

Ignore me, it was the original EmonLib files that I thought I had moved out of the libraries folder, but they were actually in another sub folder still within the libraries folder. Problem solved :)