Replacing a tact switch with an transistor/optocoupler to remotely switch it on?

Hello everyone,

I have an PZEM 004t module that I will use to monitor the voltage and power usage, the main goal is to monitor all 3 phases, but for now I just purchased one module. I want to use it toghether with an ESP8266 (Wemos D1 mini) and now I had the first valid readings with the ESP module, so I'm on the right path, but I discovered the energy consumption can't be reset by sending an command to the PZEM module, the only way to do it is by long pressing and than quickly short press the tact button on the PCB.

I want to reset the acumulated energy each month, and I don't think a good solution is to go each month ad open the mains fuse panel and push the buttons to reset, it must be done remotely, a cron job running on my BananaPi home server, that will be set to run in the first day of the month, and send an command to the ESP, when ESP will receive that command it should power the transistor 5 seconds, than stop for half a second and than power again for half a second. I can easily do the coding for this, but I'm not experience enogh in electronics, I don;t know if it's possible, if yes, what kind of transistor is needed?

The PZEM004t module is powered by 5v, the ESP is 3.3v .. is this an issue ? Maybe I could use another 3,3v to 5v bidirectional logic converter like I use for the RX/TX pins going from the ESP to the PZEM.

As I already mention, I'm not good in electronics, please give me some advices to accomplish what I want.

Thank you

Hi,

I am not familiar with the PZEM 004t module. However it appears the module is directly connected to the mains and you are protected from dangerous potentials by the fact that it is wireless.

I would:

Look to be sure there is no other means to reset what you want.

if not, you will have to use an opto-isolator (a good one with a high isolation voltage).

  1. try to follow the traces to the PB. It would be good if one were ground and the other some pull up resistor. If so try to read the resistor value.

  2. It that all works, you can connect the output transistor of the opto-isolator across the switch.

I suspect you will have to find the results of 1 above and post them for further help.

Caution mains voltage can kill. Yes some folks survive, likely most but some don't. Would not like to see you in the first category.

Good luck

Hello John,

the PZEM004t module communicates with an ESP8266 module via serial interface, this is how this module is wireless, I setup the ESP to push the voltage, curent, power, totalenergy to a BananaPi server I have in my house, the only way to reset the total energy value, which is saved in PZEM eprom is by pressing the CLR button available on the board, others confirmed that there is no command available to reset using the serial interface.

I don’t know if it helps, but I measured the voltage across the tact switch pins, and it’s 2.1v. One of the pins goes to the SD3004 IC pin 20, but the other pin I can’t see exactly where it leads, as the trace is under 2 optocouplers . If the CLR button is pressed the voltage drops to 0.

I also searched for the schematic of the PZEM module but wasn’t so lucky, couldn’t find anything

In the last picture it seems the trace goes to the R12, but checking the trace continuity using my multimeter set on diode, it seems the trace doesn’t goes to that resistor.

Thanks for any more ideas

pzem004t close up.jpg

sd3004.jpg

IMG_0352.JPG

Anyone around to give me some advices ?

Can the thing I want be achieved with a transistor? or I should look over to other methods like micro relays like those : Electronics-Salon.com | eBay Stores

Thank you.

I would look at powering a small relay and use its contacts across the reset switch . That would do the job and isolate the two system from each other .
You might not be able to power the relay directly and might need a transistor to switch it

sibianul:
Anyone around to give me some advices ?

Can the thing I want be achieved with a transistor? or I should look over to other methods like micro relays like those : http://stores.ebay.com/Electronics-Salon/NEC-/_i.html?_fsub=643546419&_sid=804830199&_trksid=p4634.c0.m322

Thank you.

My advice would be to SAVE the energy used value once a month and then there would be no reason to reset it. If you want the energy value daily, then once a month save the monthly value separately in a “daily value” location. Then subtract the old daily value from the value just read, giving today’s energy, then save today’s value back in the “daily value” ready to tomorrow.

In all cases, watch for energy value roll over.

Paul

Your digging around for schematics and testing methods are commendable! You're in the right track. :slight_smile:

As you've said, pressing the microswitch does indeed pull (sink) the pin signal to ground (0V). So an NPN transistor will indeed work. (If I may suggest, try researching about sinking/sourcing and what are pull up and pull down resistors? A very important thing to learn when it comes to digital electronics.)

However, rather than just use a plain transistor, An optocoupler is a must. (4N25 / 4N33 / 4NXX works?)

This is very important because you'll need the isolation for these kinds of work. (Mains voltage can break your devices. Also, at worst, it can kill you.)

But warnings aside, as mentioned by JohnRob, you'd actually just need to parallel the Collector and Emitter output of the optocoupler to the microswitch. Then switch the LED input side with enough current. Then you're good. :slight_smile:

But for the sake of documentation, let me attempt to elaborate on how I got to the conclusion that the method works before I tested it out:

Using the microswitch in your picture as a basis, here is a rough layout:

(1) (2)

(3) (4)

**(3) is the pin of the microswitch what you've marked red.

Here are some details for you to verify:

(1) & (3) are shorted.

(2) & (4) are shorted.

Measuring the voltage across the switch (1&2 OR 3&4), it'll give a HIGH signal when not pressed. A LOW signal if pressed. (2.1V and 0V respectively, according to your measurement.)

Given the above, it is probably safe to assume that the signal for 'CLR' is pulled up, needing to be sinked to GND for a signal.

Since your sinking to GND, this then implies that you can probably use an NPN transistor as a substitute for the switch.

But again, ISOLATION. So use an optocoupler.

Then, looking at the underside of the board, (1) & (3) of the microswitch is connected to the huge copper fills/traces. Given that, a usual assumption is that the huge copper fills is the ground.

Given these things, I connected the Optocoupler's Emitter to (1). And by default, Collector at (2).

Supplied the input side of the optocoupler manually for testing.

It worked first time. Woo!

Tested with code. Also worked. :slight_smile:

But of course, this probably not advisable for everybody. One can never be too cautious when working with mains voltage. (Or any circuit actually.)

Well, unless... You don't mind setting up the necessary safety precautions, the occasional smoke+sparks, and/or breaking your devices. But you'll learn that with time and experience. :wink: