Page 4 of 5
Re: New component: PZEM-004T Power Monitor
Posted: Thu Jul 27, 2023 9:17 pm
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

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

Re: New component: PZEM-004T Power Monitor
Posted: Fri Jul 28, 2023 6:15 am
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
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
Re: New component: PZEM-004T Power Monitor
Posted: Fri Jul 28, 2023 7:44 am
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
Re: New component: PZEM-004T Power Monitor
Posted: Fri Jul 28, 2023 9:59 am
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.
Re: New component: PZEM-004T Power Monitor
Posted: Fri Jul 28, 2023 7:49 pm
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
Re: New component: PZEM-004T Power Monitor
Posted: Sat Jul 29, 2023 3:15 am
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
Re: New component: PZEM-004T Power Monitor
Posted: Sat Jul 29, 2023 9:36 am
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

)I have chage the adress for the display to 32, is mine.
Br
Jorgen
Re: New component: PZEM-004T Power Monitor
Posted: Sat Jul 29, 2023 10:26 am
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
Re: New component: PZEM-004T Power Monitor
Posted: Sat Jul 29, 2023 12:44 pm
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
Re: New component: PZEM-004T Power Monitor
Posted: Sat Jul 29, 2023 5:56 pm
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