New: the AI firewall watches the whole platform and explains each incident in plain words. See how it works

I opened a cheap Wi-Fi socket: what are the signals between the logic board and the power board?

I opened a cheap Wi-Fi socket: what are the signals between the logic board and the power board?

Solved 5 4

Translated from Türkçe by AI ·

I have 6 cheap Wi-Fi sockets. They work with their own cloud app, and I want to get rid of that app. Plan: remove the Wi-Fi module and replace it with an ESP32-C3, using my own firmware to both drive the relay and send consumption data to Hermetry.I opened the socket. There are two boards: on top, the small logic board with the Wi-Fi module; underneath, the power board with the relay and the measurement IC. There is a 7-pin header between them. With the plug unplugged, as far as I can measure with a multimeter:

1  3V3   (güç kartından geliyor)
2  GND
3  REL   lojik karttan çıkış, 3.3V = röle çekiyor
4  ?     sürekli kare dalga, yük yokken çok yavaş
5  ?     kare dalga, yükle birlikte hızlanıyor
6  ?     lojik karttan çıkış, sabit
7  LED

On pins 4 and 5 the frequency changes with load; I think these are the outputs of the measurement IC. The text on the IC seems to have been erased, it is an 8-leg SOIC. How should I read these signals, and can I connect an oscilloscope while it is plugged in?

Sahadan selamlar.
♥ 0

Translated from Türkçe by AI ·

Don’t connect an oscilloscope while it’s plugged in. Most of these boards have no isolation, the GND is directly tied to the mains. If you short the scope’s ground with it, you lose the probe and yourself.

Ağ geçidi yine bağlanıyor…
♥ 0

Translated from Türkçe by AI ·

Alright, I was a bit scared 🙂 So far I always measured with it unplugged, I powered the board with a separate 3.3V and checked, the frequency doesn’t change there of course since there’s no load.

Sahadan selamlar.
♥ 0

Translated from Türkçe by AI ·

We in the hospital gave up on this route and bought measuring plugs that come with a calibration certificate. If you are going to report the consumption data as measurements, keep that in mind. If it’s for a hobby, then of course carry on.

Modbus sadece register'dır, ta ki olmayana kadar.
♥ 2

Translated from Türkçe by AI ·

Most of these plugs have an HLW8012 or its clone BL0937, 8 legs, and the pins you described match exactly. I used the same chip modules in water pump panels at the municipality, and this is how it works:

  • CF (your pin 5): pulse output whose frequency is proportional to active power.
  • CF1 (pin 4): depending on the SEL pin, a pulse proportional to either current or voltage.
  • SEL (pin 6): selection pin going from the logic board to the chip. On HLW8012 SEL=1 is current, on BL0937 it’s the opposite, and if you mix these up the values come out nonsense.

It’s easy to read: connect the two pins to an interrupt, count pulses in a 1 second window. For power, roughly:

volatile uint32_t cfPulses = 0;
void IRAM_ATTR onCF() { cfPulses++; }

// setup:
attachInterrupt(digitalPinToInterrupt(PIN_CF), onCF, RISING);

// every second:
noInterrupts(); uint32_t n = cfPulses; cfPulses = 0; interrupts();
float power_w = n * powerFactor;     // kalibrasyonla bulunacak
energy_wh += power_w / 3600.0;

Find the powerFactor value with a known load: plug in a 100 W heater or an incandescent bulb, divide the counted pulses by the real power. For voltage, do the same by changing SEL and using CF1.
Safety: when uploading the code, unplug the socket from the mains, program the ESP32-C3 via USB, then disconnect and plug it back in. Connecting to the mains while USB is attached means connecting your computer to the mains. Do the calibration by watching the log over Wi-Fi.
Send a energy_wh counter that increases, together with power_w, to Hermetry; getting the daily consumption from the counter later is much cleaner.

Accepted solution♥ 6

Translated from Türkçe by AI ·

It was the BL0937, I was using SEL the wrong way round, I was reading current and voltage swapped, it thought 230 V was 0.8 A 🙂 I calibrated it with a 100 W heater, and it reads 59.2 W on the 60 W bulb plugged into the socket. I don’t plug it in at all while programming now, I set up OTA. Thanks Oğuz.

Sahadan selamlar.
♥ 1
Viewing 6 posts – 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Join the conversation

Sign in to ask and answer, like helpful posts and mark the reply that solved your problem. Every contribution earns points and levels.

Share