2026-05-0600
This commit is contained in:
+7
-5
@@ -24,6 +24,8 @@
|
||||
#define MQTT_SERVER "192.168.127.251"
|
||||
|
||||
PZEM004Tv30 pzem(Serial2, 16, 17); // Serial2 uses pins 16 (RX) & 17 (TX)
|
||||
// 16 = SCHWARZ
|
||||
// 17 = GELB
|
||||
|
||||
WiFiClient espClient;
|
||||
PubSubClient client(espClient);
|
||||
@@ -75,7 +77,7 @@ void loop() {
|
||||
json += "\"pf\":" + String(pf);
|
||||
json += "}";
|
||||
|
||||
client.publish("hjk/energy/pzem", json.c_str());
|
||||
client.publish("hjk/pzem", json.c_str());
|
||||
|
||||
Serial.print("Voltage: "); Serial.print(voltage); Serial.println(" V");
|
||||
Serial.print("Current: "); Serial.print(current); Serial.println(" A");
|
||||
@@ -85,13 +87,13 @@ void loop() {
|
||||
Serial.print("PF: "); Serial.println(pf);
|
||||
Serial.println("----------------------");
|
||||
|
||||
power = 10;
|
||||
energy = 134;
|
||||
/* power = 10;
|
||||
energy = 134; */
|
||||
oled.setCursor(0,2);
|
||||
oled.set2X();
|
||||
oled.print(energy, 1); oled.println(" kWh");
|
||||
oled.print(energy, 2); oled.println(" kWh");
|
||||
oled.set1X();
|
||||
oled.print(power, 0); oled.println(" W");
|
||||
oled.print(power, 2); oled.println(" W");
|
||||
|
||||
client.loop();
|
||||
delay(5000);
|
||||
|
||||
Reference in New Issue
Block a user