New component: PZEM-004T Power Monitor

For general Flowcode discussion that does not belong in the other sections.
chipfryer27
Valued Contributor
Posts: 1687
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 374 times
Been thanked: 583 times

Re: New component: PZEM-004T Power Monitor

Post by chipfryer27 »

Hi

Following with interest.

Just wondering why you would want voltage in a red font?

I did build the FAD version last year with good results and I do like the idea of running one without a PC as mentioned in an earlier post. I'm unlikely to use the TTGO, although I do admire (drool over) it, but if I were to use it I'd probably add some code that would change the font from green to red if the voltage went above or below the permitted tolerances.

It's ESP32 based so you have the option to record externally, perhaps to ThingSpeak or the like. That's very easy to include, as is a notification via your phone via PushingBox or the like (kids have got ALL the lights on again :evil: ).

To me, having the component allows you to incorporate anything you think would be useful rather than a one size fits all approach.

If I revisited, I'd probably use either a cheapo microcontroller with an ESP8266 or just an ESP32 itself. These "sensors" would simply gather the info (possibly also sending to ThingSpeak / PushingBox) and communicate with a "display" module elsewhere in my cave/hovel. The display module would simply display what the sensor is recording, much like what the energy companies supply with the exception that it would probably last more than a month, and if it did go awry I could fix it :)

Regards

EDIT..
Seems as I was typing you intercepted my thoughts :lol:

jgu1
Posts: 813
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 696 times
Been thanked: 183 times

Re: New component: PZEM-004T Power Monitor

Post by jgu1 »

Hi Chipfryer!

Thank´s

I think Martin want the voltage in read if it´s over/under limit because in his area is some issue with the stability with the voltage. I want to get "Over power" in read when alarm occur. There are many possibilities, fortunately. The examble Martin have made, we can read the result in the display, and use these benefits and to show how it work, from this examble, I have again learn a lot ;)

Concerning the Thinkspeak, you are one step further, maybe possible to use FC App developer too it look very interesting too, I have no experience with Thinkspeak, I have this morning a short search on the net and can see many use it, and maybe even a dummy like me have a change :lol:
But is it possible to use it via Flowcode, I know of course I have to create an account and connect to my router ect..?

Br Jorgen

medelec35
Matrix Staff
Posts: 2086
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 644 times
Been thanked: 702 times

Re: New component: PZEM-004T Power Monitor

Post by medelec35 »

Hi Guys.
I have changed the wording of my post as I was only referring to the wiki stating supply voltage from the ESP32 must be 3V and not 5V.
However since the ESP32 TTGO is a colour gLCD then nothing wrong with how different colours for voltage, power, and the overpower warning.
For example 0 to 999W green, 1 to 1.99KW Amber and 2+KW red
Martin

medelec35
Matrix Staff
Posts: 2086
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 644 times
Been thanked: 702 times

Flowcode v10 Re: New component: PZEM-004T Power Monitor

Post by medelec35 »

I have just made some nice improvements to the Arduino version.
If the comms fail the display shows you.
Just simply check the connections etc then comms will automatically be established and the program will continue.
No need to press reset anymore.
The switch's status only when pressed with now is displayed on the LCD.
You will need to change the LCD address to the one you have got.
Attachments
Arduino_Uno_Mains_PM_LCDv1.1.fcfx
(46.19 KiB) Downloaded 435 times
Martin

jgu1
Posts: 813
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 696 times
Been thanked: 183 times

Re: New component: PZEM-004T Power Monitor

Post by jgu1 »

Hi Martin!

Very nice, thank´s. I also see that you have simplified the way to write to the display and more logig, easyer ;)

Br Jorgen

chipfryer27
Valued Contributor
Posts: 1687
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 374 times
Been thanked: 583 times

Re: New component: PZEM-004T Power Monitor

Post by chipfryer27 »

Hi Jorgen

Regarding connecting to ThingSpeak (and other services) it's really quite easy using any microcontroller that can connect to the internet, such as your ESP32.

Once you sign up for an account you get access to your dashboard and from there you will create your api keys which allow you to read/write data to the service. I posted about it here in the v8 forum.

https://www.matrixtsl.com/mmforums/view ... 83#p106883

Although I used a GSM module the principles are similar. A search should give you some examples using an ESP8266/ESP32 but I probably have an example kicking around somewhere if needed.

Regards

jgu1
Posts: 813
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 696 times
Been thanked: 183 times

Re: New component: PZEM-004T Power Monitor

Post by jgu1 »

Hi Martin and Chipfryer!

@Chipfryer, yes it seem to be easy to add the project in Thingspeak, but how I change Martins project to work together with Teamspeak I don´t know, How do I add in the program SSID and the Password so I can connect to my router, could be interested?

Martin in LCD ver. 1.1 Info, forget to add the init for the PZM004 in the Init macro. I see that you not have updatet in wiki yet

I have added init in ver 1.1 work nice too (with or with out init :lol: )I have chage the adress for the display to 32, is mine.

Br

Jorgen
Attachments
Arduino_Uno_Mains_PM_LCDv1.1.fcfx
(46.48 KiB) Downloaded 496 times

chipfryer27
Valued Contributor
Posts: 1687
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 374 times
Been thanked: 583 times

Re: New component: PZEM-004T Power Monitor

Post by chipfryer27 »

Hi

If I'm using an ESP32 then it's because I want it to connect to something. At the start of my programs I initialise the ESP32 and have it connect to my WiFi (using preassigned values). Depending on what I'm doing I may then connect to ThingSpeeak (or other service), or I may choose to connect / disconnect on demand. If I'm only sending data very infrequently then I will send on demand rather than try keeping a connection open.

When you read your monitor you obtain values such as Volts, Amps etc and you assign these to variables (for simplicity we will call the variables Volts and Amps etc too).

ThingSpeak allows you to have Channels and each channel has multiple Fields. So you could have your first Channel contain Fields such as Volts, Amps etc.

Now, when you read your monitor, either after or before you print them on your display, you would simply create a string containing your api key and append your fields (Volts, Amps etc), then send this to ThingSpeak. It sounds more complicated than it is.

Regards

medelec35
Matrix Staff
Posts: 2086
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 644 times
Been thanked: 702 times

Re: New component: PZEM-004T Power Monitor

Post by medelec35 »

Hi Jorgen.
I did not forget to add the PZEM-004T::initialise, as if you look at the decision branch PZEM004TInitRtrnValue within main.
That's why yours is working without adding PZEM-004T::initialise.
I just moved it to make it so it can re-establish comms if it was working and got broken, then fixed again without using Reset on the Uno

I have also made some more improvements so Arduino_Uno_Mains_PM_LCDv1.2.fcfx is now available on the Wiki.

That version now allows comms to be broken and will wait for it to be established after it has been working
Martin

jgu1
Posts: 813
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 696 times
Been thanked: 183 times

Re: New component: PZEM-004T Power Monitor

Post by jgu1 »

Hi Both!

Yes now I see, Aplogize Martin I have not seen that and I did not know this also is a way to init, I always use the "initmacro", sorry ;)
I´ll have a look at the improvement ;) Thank´s

Chipfryer, Thank you for the explanation, I will play with it, I understand almost how the Teeamspeak work, my problem is how I set up the FC to connect Wifi. I´ll investigate and I come back :)

Br Jorgen

Post Reply