I opened a cheap Wi-Fi socket: what are the signals between the logic board and the power board?
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?
Elimde 6 tane ucuz Wi-Fi priz var, kendi bulut uygulamalarıyla çalışıyor ve o uygulamadan kurtulmak istiyorum. Plan: Wi-Fi modülünü söküp yerine ESP32-C3 koymak, kendi firmware’imle hem röleyi sürmek hem de tüketimi Hermetry’ye göndermek.
Prizi açtım, iki kart var: üstte Wi-Fi modülünün olduğu küçük lojik kart, altta röle ve ölçüm entegresinin olduğu güç kartı. Aralarında 7 pinli bir header var. Fişten çekili halde, multimetre ile ölçebildiğim kadarıyla:
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
4 ve 5 numaralı pinlerde frekans yükle değişiyor, sanırım ölçüm entegresinin çıkışları. Entegrenin üstündeki yazı silinmiş gibi, 8 bacaklı SOIC. Bu sinyalleri nasıl okumam lazım, ve fişe takılıyken osiloskop bağlayabilir miyim?
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.
Fişe takılıyken osiloskop bağlama. Bu kartların çoğunda izolasyon yok, GND doğrudan şebekeye bağlı oluyor. Osiloskobun toprağı ile kısa devre yaparsın, hem prob gider hem sen.
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.
Tamam, korktum biraz 🙂 Şimdiye kadar hep fişten çekili ölçtüm, kartı ayrı bir 3.3V ile besleyip baktım, frekans orada değişmiyor tabii yük olmadığı için.
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.
Biz hastanede bu yoldan vazgeçtik, kalibrasyon sertifikası olan ölçüm prizleri aldık. Tüketim verisini ölçüm olarak raporlayacaksan bunu düşün. Hobi içinse tabii devam.
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.
Bu prizlerin çoğunda HLW8012 ya da onun kopyası BL0937 var, 8 bacak ve tarif ettiğin pinler tam uyuyor. Ben belediyede su pompası panolarında aynı entegreli modüller kullandım, şöyle çalışıyor:
- CF (senin 5. pin): frekansı aktif güçle orantılı darbe çıkışı.
- CF1 (4. pin): SEL pinine göre ya akım ya gerilimle orantılı darbe.
- SEL (6. pin): lojik karttan entegreye giden seçim pini. HLW8012’de SEL=1 akım, BL0937’de tersi, bunu karıştırınca değerler saçma çıkıyor.
Okuması kolay: iki pini kesmeye bağla, 1 saniyelik pencerede darbe say. Güç için kabaca:
volatile uint32_t cfPulses = 0;
void IRAM_ATTR onCF() { cfPulses++; }
// setup:
attachInterrupt(digitalPinToInterrupt(PIN_CF), onCF, RISING);
// her saniye:
noInterrupts(); uint32_t n = cfPulses; cfPulses = 0; interrupts();
float power_w = n * powerFactor; // kalibrasyonla bulunacak
energy_wh += power_w / 3600.0;
powerFactor değerini bilinen bir yükle bul: 100 W’lık bir ısıtıcı ya da akkor ampul tak, sayılan darbeyi gerçek güce böl. Gerilim için de aynısını SEL’i değiştirip CF1’den yap.
Güvenlik: kodu yüklerken prizi şebekeden çek, ESP32-C3’ü USB ile programla, sonra kapat ve tak. USB bağlıyken şebekeye takmak, bilgisayarını şebekeye bağlamak demek. Kalibrasyonu da Wi-Fi üzerinden log izleyerek yap.
Hermetry’ye power_w ile birlikte artan bir energy_wh sayacı gönder, sonradan günlük tüketimi sayaçtan almak çok daha temiz oluyor.
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.
BL0937 çıktı, SEL’i ters kullanıyormuşum, akım ile gerilimi yer değiştirmiş okuyordum, 230 V’u 0.8 A sanıyordu 🙂 100 W ısıtıcıyla kalibre ettim, prizin üstündeki 60 W ampulde 59.2 W okuyor. Programlarken artık prizi hiç takmıyorum, OTA ayarladım. Teşekkürler Oğuz.
- 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.

