TTGO T-eight problem using PZEM004T-v3.0

droid69
Posts: 1
Joined: Fri Jul 19, 2019 6:07 am

TTGO T-eight problem using PZEM004T-v3.0

Postby droid69 » Fri Jul 19, 2019 6:15 am

My name is Rakhmad, from Indonesia,, i have some problem to use PZEM004T v3.0 with TTGO T-eight sith SH1106 (product link https://id.aliexpress.com/i/32851861333.html) this TTGO using esp32-D0WDQ6 SoC,,
I succes use the PZEM to arduino nano and wemos mini D1, but cant use in TTGO. can you help me to solve the problem. when i compile to TTGO, always error... this is error message when i compile to TTGO

Code: Select all

Arduino: 1.8.9 (Windows 10), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"

C:\Users\user\sketchbook\libraries\PZEM-004T-v30-master\PZEM004Tv30.cpp: In constructor 'PZEM004Tv30::PZEM004Tv30(uint8_t, uint8_t, uint8_t)':

C:\Users\user\sketchbook\libraries\PZEM-004T-v30-master\PZEM004Tv30.cpp:62:5: error: 'SoftwareSerial' was not declared in this scope

     SoftwareSerial *port = new SoftwareSerial(receivePin, transmitPin);

     ^

C:\Users\user\sketchbook\libraries\PZEM-004T-v30-master\PZEM004Tv30.cpp:62:21: error: 'port' was not declared in this scope

     SoftwareSerial *port = new SoftwareSerial(receivePin, transmitPin);

                     ^

C:\Users\user\sketchbook\libraries\PZEM-004T-v30-master\PZEM004Tv30.cpp:62:32: error: expected type-specifier before 'SoftwareSerial'

     SoftwareSerial *port = new SoftwareSerial(receivePin, transmitPin);

                                ^

exit status 1
Error compiling for board ESP32 Dev Module.[/quote]

and this is my simple program

[code=simple program]#include <PZEM004Tv30.h>
#include <Wire.h>          
#include "SH1106Wire.h" 
#include "SH1106.h"
#include "images.h"
SH1106 display(0x3c, SDA, SCL); 

PZEM004Tv30 pzem(25,27);

void setup() {
  Serial.begin(115200);
  Serial.println();
  Serial.println();
  display.init();
  display.flipScreenVertically();
  display.setFont(ArialMT_Plain_10);
  pzem.resetEnergy();
  pzem.setAddress(0x42);
}

void drawTextFlowDemo() {
    display.setFont(ArialMT_Plain_10);
    display.setTextAlignment(TEXT_ALIGN_LEFT);
    display.drawStringMaxWidth(0, 0, 128, "TES 1 2 3 INDRA" );
}

void loop() {
 
  display.clear();
  // draw the current demo method
  display.setTextAlignment(TEXT_ALIGN_RIGHT);
  display.drawString(10, 128, String(millis()));
  drawTextFlowDemo();
  display.display();
  float volt = pzem.voltage();
  Serial.print("Voltage: ");
  Serial.print(volt);
  Serial.println("V");

  float cur = pzem.current();
  Serial.print("Current: ");
  Serial.print(cur);
  Serial.println("A");

  float powe = pzem.power();
  Serial.print("Power: ");
  Serial.print(powe);
  Serial.println("W");

  float ener = pzem.energy();
  Serial.print("Energy: ");
  Serial.print(ener,3);
  Serial.println("kWh");

  float freq = pzem.frequency();
  Serial.print("Frequency: ");
  Serial.print(freq);
  Serial.println("Hz");

  float pf = pzem.pf();
  Serial.print("PF: ");
  Serial.println(pf);

  delay(1000);
}
many thanks for any help...

carlus111
Posts: 1
Joined: Thu Aug 29, 2019 11:57 pm

Re: TTGO T-eight problem using PZEM004T-v3.0

Postby carlus111 » Fri Aug 30, 2019 12:03 am

Hi,

I have developed a library that allows us to connect our ESP32 board with the PZEM004T v3.0, thanks to the Modbus protocol. The connection is made through HardwareSerial.

I have tried it with my ESP32 board and it works perfectly.

I hope it helps you and solve your problem.

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: TTGO T-eight problem using PZEM004T-v3.0

Postby ESP_Sprite » Fri Aug 30, 2019 2:57 am

Moved to the Arduino subforum.

Who is online

Users browsing this forum: No registered users and 43 guests