letscontrolit / ESPEasy

Easy MultiSensor device based on ESP8266/ESP32
http://www.espeasy.com
Other
3.3k stars 2.22k forks source link

Feature request - Energy meter SDM120, 220, 630 #205

Closed agsochi closed 5 years ago

agsochi commented 7 years ago

Cheap Eastron SDM120, but good quality. Can control 13 parameters. Template library for reading SDM120 / SDM220 / SDM630 Modbus Energy meters. 1$ rs232<->rs485 is needed.

beicnet commented 7 years ago

@agsochi that is good one, but this is cheaper with Pulse Counter: https://www.aliexpress.com/item/5-32-230V-50HZ-Single-phase-Din-rail-Watt-hour-energy-meter-with-LCD-digital-disply/695870527.html

agsochi commented 7 years ago

This is completely different products like computer and calculator, SDM120 can measure:

Voltage -Volts
Current -Amps
Active power -Watts
Apparent power -VA
Reactive power -VAr
Power factor
Frequency -Hz
Import active energy -kWh
Export active energy kWh
Import reactive energy -kvarh
Export reactive energy -kvarh
Total active energy -kWh
Total reactive energy -Kvarh

And it stores Total values in memory.

beicnet commented 7 years ago

@agsochi Oh, that is nice then! ;) Thumbs for that!

krikk commented 7 years ago

i prefer the non-invasive measurement like done with https://guide.openenergymonitor.org/setup/emontx/ more, it is more secure for non electricians like me :)

...so if you want this in espeasy, gear up you coding skills, and submit a pull request...

see here for a start: https://www.letscontrolit.com/wiki/index.php/ESPEasy#Source_code_development

agsochi commented 7 years ago

Working sketch is here.

sjfaustino commented 7 years ago

I'm hoping to do a ModBus controller later on so that any device that uses ModBus can more easily be developed.

I'm a newbie with ESPEasy so it's slow going but I currently have a plugin that I'm developing to communicate with ModBus for the Eastron SDM series of Energy meters and despite being in development, it works fine. Is there still an interest? http://imgur.com/a/AObtV

krikk, Eastron have Energy meters that can use slipt core current transformers.

beicnet commented 7 years ago

@sjfaustino Great, can you push into the Playground with other plugins?

krikk commented 7 years ago

@sjfaustino like @beicnet said, please do a pull request if it works and is tested...

beicnet commented 7 years ago

@krikk I can't do it, because it's not my work! @sjfaustino need to do that!

sjfaustino commented 7 years ago

There's a pull request on the playground right now. The plugin works as-is with no issues but it must be developed much further.

My thought is to work with the entire series of SDM with sanity checks (only allow baud rates and query values supported by each meter, do autodetect to check on which pins it's connected (a type of ModBus scan), etc...

Still a newbie to Arduino C and ESPEasy so if anyone wants to contribute, please do.

Also, I believe it's more useful to keep it returning a single value since you can either do a dummy device to compile several values or just add the same device several times with the same name.

This allows us to for example only check the total power every hour but check the current every minute.

yuret commented 6 years ago

Thank you to all who made this possible:)

sdm sdm2
psy0rz commented 6 years ago

if more people need it and the plugin is clean enough, we might add it to ESPEasy by default.

Please add a thumbs up to this comment if you want that.

For now use the plugin from the playground and compile ESPEasy manually.

TD-er commented 6 years ago

Hmm, I have a Eastron sensor to monitor my PV, so this is a good one to have. I was also working on support for other Senseair sensors, which also need Modbus, so I'm all in for separate Modbus support to use with several plugins.

psy0rz commented 6 years ago

sounds good :) we should move this plugin from playground to core if its possible.

Arek84 commented 6 years ago

Very good and useful plug. Does it work with SDM630?

sjfaustino commented 6 years ago

Yes, ALL the SDM630 values are available. Bit of work since I had to consult 3 datasheets to get them all. Still plan to improve it a lot but RL got in the way. It's open to anyone who want to have a go at it :)

LeeNX commented 6 years ago

A little more the $1, but I like the 3.3V support and re-setting fuses - https://www.ebay.com/itm/Stable-RS485-to-TTL-Module-UART-Serial-Port-to-RS485-Converter-Function-Module/361375498598

Ordered and waiting to play, thanks!!

mstjerna commented 6 years ago

What about this one ? :-) Schneider iEM3150 https://www.schneider-electric.com/en/product/A9MEM3150/iem3150-energy-meter---63-a---modbus/

sjfaustino commented 6 years ago

Schneider is a good brand but we are talking about 60€ for a Eastron 630C (been working on a 60KW machine hooked up to a 150KVA diesel generator with all the issues that generators cause for over 3 years with no issues so far) versus over 200€ for the Schneider one.

If you are going to use it on a production environment where your job is on the line if it fails, a good rule of thumb is DO NOT use Chinese stuff, if that's not the case however... :)

mstjerna commented 6 years ago

How hard would it be to implement with the work already done? I got a couple of these from a friend, would be nice to fit and use them.

TD-er commented 6 years ago

I guess we have to compare (programmer) datasheets then to get an idea of the diffs between them. But I guess it is basically the same. Address the Modbus device, request a register read and interpret the data. If they list the same output parameters, the plugin could even be shared.

LeeNX commented 6 years ago

There are some GitHub projects that have the data sheets for the Eastron ModBus meter readings - https://github.com/peninquen/Modbus-Energy-Monitor-Arduino/tree/master/Collection_of_manuals

Was looking at building an ESP/485 Device just for my meters - https://github.com/reaper7/SDM_Energy_Meter

But I would prefer all my ESP device to be running ESPEasy ... I'm just too lazy that way! ;-)

beicnet commented 6 years ago

DO NOT use Chinese stuff

Everything is made in China, and no matter what Brand we are talking about... :wink:

Egyras commented 6 years ago

@yuret How you managed to include this plugin ? please share .bin file to upload to NodeMCU 1.0 I have tried to compile with Ardruino IDE.... with no luck Changed in sdm.h SoftwareSerial to ESPeasySoftwareSerial because of errors.... error: 'class ESPeasySoftwareSerial' has no member named 'listen'

rvmil commented 6 years ago

I am also trying to get the playground working but with no luck.... Just need the easy esp with this nice plugin. does someone have a compiled version? Or does someone now where to get a instruction manual to get the playground working. Maybe some one already seen the error: Command:42: error: 'Command' does not name a type Command commandStringToEnum(const char * cmd) {

Thanks in advance!

erikzw7 commented 6 years ago

For a couple of days now I've been trying to compile this espeasy version for a nodemcu V3 board with the SDM150 plugin but without luck. I have taken the following steps:

  1. Installed platformio and atom
  2. Downloaded the ESPEasy zip ( ESPEasy_mega-20180818)
  3. Extracted it all to a directory and compiled it with Platformio. This worked
  4. Downloaded ESPEasyPluginPlayground-master.zip and extracted the _P150_SDM120C.ino and copied it to the directory
  5. Downloaded SDM_Energy_Meter-master.zip from reaper and extracted the files into the directory
  6. When building the file I get the following error: _P150_SDM120C.ino:86:101: error: no matching function for call to 'addFormSelector(String&, const FlashStringHelper*, const FlashStringH elper*, int, String [10], NULL, byte&)'

Anybody an idea on how to fix this?

LeeNX commented 6 years ago

Ran into similar issues and gave up after a day. If anybody has working instructions, I am interested too.

TD-er commented 6 years ago

In the line of that ino file, with addFormSelector, remove the first argument (the string)

Please let me know if it is working.

erikzw7 commented 6 years ago

Removed the string and that seemed to help on that particular problem. However, compiling is still failing, see results below

Compiling .pioenvs\dev_ESP8266_4096\FrameworkArduino\IPAddress.cpp.o C:/Users/Downloads/ESPEasy_mega-20180818/Source/src/_P150_SDM120C.ino:21:1: error: 'SDM' is not a template SDM<2400, D6, D7> Plugin_150_SDM; ^ C:/Users/Downloads/ESPEasy_mega-20180818/Source/src/_P150_SDM120C.ino:21:19: error: no matching function for call to 'SDM::SDM()' SDM<2400, D6, D7> Plugin_150_SDM; ^ C:/Users/Downloads/ESPEasy_mega-20180818/Source/src/_P150_SDM120C.ino:21:19: note: candidates are: In file included from C:/Users/Downloads/ESPEasy_mega-20180818/Source/src/_P150_SDM120C.ino:20:0: src/SDM.h:153:5: note: SDM::SDM(SoftwareSerial&, long int, int) SDM(SoftwareSerial& serial, long baud = SDM_UART_BAUD, int dere_pin = DERE_PIN); ^ src/SDM.h:153:5: note: candidate expects 3 arguments, 0 provided src/SDM.h:148:7: note: constexpr SDM::SDM(const SDM&) class SDM { ^ src/SDM.h:148:7: note: candidate expects 1 argument, 0 provided Compiling .pioenvs\dev_ESP8266_4096\FrameworkArduino\MD5Builder.cpp.o Compiling .pioenvs\dev_ESP8266_4096\FrameworkArduino\Print.cpp.o *** [.pioenvs\dev_ESP8266_4096\src\ESPEasy.ino.cpp.o] Error 1

LeeNX commented 6 years ago

I had the above problem, fix that by moving reaper's lib SDM_Energy_Meter into my lib folder and rename to SDM, if I remember correctly.

erikzw7 commented 6 years ago

Tried this, but still without luck:

Compiling .pioenvs\dev_ESP8266_4096\FrameworkArduino\Print.cpp.o C:/Users/Annemarie/Downloads/ESPEasy_mega-20180818/Source/src/_P150_SDM120C.ino:21:1: error: 'SDM' is not a template SDM<2400, D6, D7> Plugin_150_SDM; ^ C:/Users/Annemarie/Downloads/ESPEasy_mega-20180818/Source/src/_P150_SDM120C.ino:21:19: error: no matching function for call to 'SDM::SDM()' SDM<2400, D6, D7> Plugin_150_SDM; ^ C:/Users/Annemarie/Downloads/ESPEasy_mega-20180818/Source/src/_P150_SDM120C.ino:21:19: note: candidates are: In file included from C:/Users/Annemarie/Downloads/ESPEasy_mega-20180818/Source/src/_P150_SDM120C.ino:20:0: lib\SDM/SDM.h:153:5: note: SDM::SDM(SoftwareSerial&, long int, int) SDM(SoftwareSerial& serial, long baud = SDM_UART_BAUD, int dere_pin = DERE_PIN); ^ lib\SDM/SDM.h:153:5: note: candidate expects 3 arguments, 0 provided lib\SDM/SDM.h:148:7: note: constexpr SDM::SDM(const SDM&) class SDM { ^ lib\SDM/SDM.h:148:7: note: candidate expects 1 argument, 0 provided Compiling .pioenvs\dev_ESP8266_4096\FrameworkArduino\Schedule.cpp.o Compiling .pioenvs\dev_ESP8266_4096\FrameworkArduino\ScheduledFunctions.cpp.o Compiling .pioenvs\dev_ESP8266_4096\FrameworkArduino\Stream.cpp.o Compiling .pioenvs\dev_ESP8266_4096\FrameworkArduino\StreamString.cpp.o *** [.pioenvs\dev_ESP8266_4096\src\ESPEasy.ino.cpp.o] Error 1


C.Lee Taylor schreef op 23-08-2018 13:56:

I had the above problem, fix that by moving reaper's lib SDM_Energy_Meter into my lib folder and rename to SDM, if I remember correctly.

-- You are receiving this because you commented. Reply to this email directly, view it on GitHub [1], or mute the thread [2].

Links:

[1] https://github.com/letscontrolit/ESPEasy/issues/205#issuecomment-415388632 [2] https://github.com/notifications/unsubscribe-auth/AjGpropX3XCYFzufV_b639G7TyMWyPkvks5uTphZgaJpZM4M3WNC

erikzw7 commented 6 years ago

moved the SDM.h file to the lib directory in a separate SDM directory, but this had no effect.

TD-er commented 6 years ago

I discussed with @Grovkillen and I will move it from the playground to here with "[TESTING]" status.

LeeNX commented 6 years ago

If there more eyes on this, I will have another bash at this and see how I fair, thou I am no developer, so I don't expect much more, other than alot more learning ... :-)

LeeNX commented 6 years ago

@erikzw7 - Try moving the SDM lib into the Arduino lib folder, thou I am not sure how platform.io deals with external libs?

erikzw7 commented 6 years ago

Made a new directory SDM under libs and the error about not finding the SDM.h is gone, however the following error persists:

============

C:/Users/Annemarie/Downloads/ESPEasy_mega-20180818/Source/src/_P150_SDM120C.ino:21:1: error: 'SDM' is not a template SDM<2400, D6, D7> Plugin_150_SDM; ^ C:/Users/Annemarie/Downloads/ESPEasy_mega-20180818/Source/src/_P150_SDM120C.ino:21:19: error: no matching function for call to 'SDM::SDM()' SDM<2400, D6, D7> Plugin_150_SDM;

erikzw7 commented 6 years ago

apparently I'm not the only one with this issue: http://www.letscontrolit.com/forum/viewtopic.php?f=4&t=5665&start=10

TD-er commented 6 years ago

I was yesterday already working on it. The old version of that library used serial port definition as a template. The new one needs a SoftwareSerial object to interact with. This conflicts with the ESPEasySoftwareSerial object.

So I will try to solve this issue.

TD-er commented 6 years ago

Could you please test this pull request: https://github.com/letscontrolit/ESPEasy/pull/1679 ?

erikzw7 commented 6 years ago

Compiling works out nicely without error. However when I upload the new firmware on the device the wifi does not come on, so not much I can test further.


Gijs Noorlander schreef op 24-08-2018 23:20:

Could you please test this pull request: #1679 [1] ?

-- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [2], or mute the thread [3].

Links:

[1] https://github.com/letscontrolit/ESPEasy/pull/1679 [2] https://github.com/letscontrolit/ESPEasy/issues/205#issuecomment-415885470 [3] https://github.com/notifications/unsubscribe-auth/AjGpru2t-n-xUCjnXNVjjSvsMnN_v_Xhks5uUG4JgaJpZM4M3WNC

TD-er commented 6 years ago

Have you tried the nightly build? (Test build)

erikzw7 commented 6 years ago

Silly me, it worked nicely but it connected immediately to my accespoint. I thought that after every flash you had to input all the settings and hence the wifi code would be lost. That is not the case. Anyway, the 26-08 nightly build compiled and loaded correctly into the device.

Next step is to get the hardware connections working.


Gijs Noorlander schreef op 26-08-2018 19:53:

Have you tried the nightly build? (Test build)

-- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [1], or mute the thread [2].

Links:

[1] https://github.com/letscontrolit/ESPEasy/issues/205#issuecomment-416056551 [2] https://github.com/notifications/unsubscribe-auth/AjGprlqpl2HcFvVpAuFE4UEY21b9_U0Eks5uUuCqgaJpZM4M3WNC

erikzw7 commented 6 years ago

Managed to upload the firmware. Now connected the Nodemcu to the 485 via D3 and D4 and used this in the ESPEASY webinterface. However I only get NaN for the values of the device.

Findus76 commented 6 years ago

Hello Has an SDM630. An RS-232 <-> RS-485 is home. Hope it's just getting download the test version and try it :) What pin is it for communication and bus turnaround?

Findus76 commented 6 years ago

Looking at the code (P078_Eastron.ino, ESPEasy_mega-20180924) that the Rx is mapped to pin6 and Tx to pin7. But I find no info about bus turnaround. An RS-485 bus is half duplex. Therefore, a signal from the controller to RS-232 <-> RS-485 is required when switching from transmission to reciving.

seamoor commented 5 years ago

Hi, I'm sorry but from what i see this plugin supports only 1 phase power meters like SDM120, 220 etc I personally have SDM630, this is 3 phase power meter. Connected up and running. On ESP view:

image

We can choose only generic options like Voltage, Current etc but according to SDM.h by Reaper7 this power meter has 3 Voltage registers, 3 Current registers etc: image

How can i select Phase nr 1 Voltage or Phase nr 2 Voltage? And now when i select Voltage, output is divided by 3:

image

This is wrong result.

TD-er commented 5 years ago

I guess that's an easy addition to the plugin, just reading another register. I will look into a way to only list the registers available to the connected node. It will be not this week though.

seamoor commented 5 years ago

Thanks, If you need to test this on real hardware just tell me when, i can flash it and check :)

pite81 commented 5 years ago

Thank you to all who made this possible:)

sdm sdm2

I see that you have several devices in your device list, but what are those? am I right to assume that, you use a plugin? If so, how do I install it on an esp easy firmware? Thanks.

seamoor commented 5 years ago

Hi,

I see that this ticket is now closed.

Has reading from another registers been added?

I guess that's an easy addition to the plugin, just reading another register. I will look into a way to only list the registers available to the connected node. It will be not this week though.

Thanks for your time :)