Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example code using TTGO TCALL ESP32? #97

Open
mandulaj opened this issue Nov 15, 2022 · 1 comment
Open

Example code using TTGO TCALL ESP32? #97

mandulaj opened this issue Nov 15, 2022 · 1 comment

Comments

@mandulaj
Copy link
Owner

    Good day, do you have an example code for pzem004t using ttgo tcall esp32?

I have tried your code for hardserial but i think it is not for ttgo.thanks

On Tue, Nov 15, 2022 at 12:00 AM Jakub Mandula @.***>
wrote:

@123salee https://github.com/123salee could you please be a bit more
specific? Is this related to this issue? Do you want example code? Do you
have a problem?


Reply to this email directly, view it on GitHub
#47 (comment),
or unsubscribe
https://github.com/notifications/unsubscribe-auth/A4FXZDA3MT2TDYIVOK4S7K3WIJOYBANCNFSM4WXK54EA
.
You are receiving this because you were mentioned.Message ID:
@.***>

Originally posted by @margohaux in #47 (comment)

@margohaux
Copy link

### I had been connecting pzem to TTGO ESP32. but the issue was my serial monitor can't read the reading even though I successfully upload my file. They just display the unit but when I turn on main supply and load, they did not detect the value.. Hopefully someone can help me to figure out this issue.

#include <PZEM004Tv30.h>
#include <SoftwareSerial.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

#if defined(ESP32)
PZEM004Tv30 pzem(Serial1, TX, RX);
#else
PZEM004Tv30 pzem(Serial1);
#endif

void setup() {
/* Debugging serial */
Serial.begin(9600);
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.setCursor(0, 1);
lcd.print("ENERGY METER");
delay(500);
lcd.clear();

}

void loop() {

float voltage = pzem.voltage();
  if(voltage != NAN){
    Serial.print("Voltage: ");
    Serial.print(voltage);
    Serial.println("V");
    lcd.setCursor(0,0);
    lcd.print("V:");
    lcd.print("VOLTAGE");
  
  }else{
    Serial.println("Error reading voltage");
  }
            

  float current = pzem.current();
  if (current != NAN){
    Serial.print("Current: ");
    Serial.print(current);
    Serial.println("A");
    lcd.setCursor(0,1);
    lcd.print("I:");
    lcd.print("CURRENT");
    
  }else{
    Serial.println("Error reading current");
    }

    
  float power = pzem.power();
  if (power != NAN) {
    Serial.print("Power: ");
    Serial.print(power);
    Serial.println("W");
    lcd.setCursor(8,0);
    lcd.print("P:");
    lcd.print("POWER");
  
  }else{
    Serial.println("Error reading power");
  }
  
  
  float energy = pzem.energy();
  if (energy != NAN) {
    Serial.print("Energy: ");
    Serial.print(energy,3);
    Serial.println("kWh");
  }else{
    Serial.println("Error reading energy");
  }
  
  float frequency = pzem.frequency();
  if (frequency != NAN) {
    Serial.print("Frequency: ");
    Serial.print(frequency, 1);
    Serial.println("Hz");
    lcd.setCursor(8,1);
    lcd.print("F:");
    lcd.print("FREQUENCY");
         
  }else{
    Serial.println("Error reading frequency");
  }
  

  float pf = pzem.pf();
  if (pf != NAN) {
    Serial.print("PF: ");Serial.println(pf);
    lcd.setCursor(0,3);
    lcd.print("PF:");
    lcd.print("pf");
  }else{
    Serial.println("Error reading power factor");
  } 

Serial.println();
delay(2000);
}

SERIAL MONITOR: Energy:

Voltage: nanV
Current: nanA
Power: nanW
Energy: nankWh
Frequency: nanHz
PF: nan
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants