olehs / PZEM004T

Arduino communication library for Peacefair PZEM-004T Energy monitor
MIT License
229 stars 114 forks source link

Help with software serial on Wroom-02 (oLED and battery board) #42

Closed ovisopa closed 6 years ago

ovisopa commented 6 years ago

Hello guys,

I have one sensor working with an Wemos D1 board, everything is fine with that, but today I struggled a few hours to start working with the WROOM-02 board, I first made the layout of the informations as I wanted on the OLED, but I can't get any data from the PZEM Is it possible to use ANY of those pins for software serial : D3, D4, D8, D9 ?

wroom-02-oled The numbers above are randomly generated.

`

include

include

include

include // https://github.com/olehs/PZEM004T

//SoftwareSerial swSer1(D3, D4, false, 256);

//PZEM004T pzem(4,5); // RX,TX (D2, D1) on NodeMCU //PZEM004T pzem(&Serial1); //PZEM004T pzem(&Serial); //PZEM004T pzem(D3,D4); //PZEM004T pzem(D4,D3);

PZEM004T pzem(D3,D4); IPAddress ip(192,168,1,1);

void setup() { // Serial.begin(115200); // Serial.println(); // Serial.println(); //swSer1.begin(9600); pzem.setAddress(ip); } `

If anyone can provide an sample code with software serial to see how exactly you define the pins the communication is initiated, maybe I could make it work

The board I use is this : https://www.banggood.com/Wemos-D1-Esp-Wroom-02-Motherboard-ESP8266-Mini-WiFi-NodeMCU-Module-p-1224577.html?cur_warehouse=CN

I connected it like this: PZEM RX -> D4, PZEM TX -> D3

The board doesn't have a detailed documentation, but the oLed is wired to D1 and D2, and the Joystick uses D5, D6 and D7. 220v was connected to the terminals, but no wire trough coil (once I see the voltage, I will mount it in place and see the CURENT also). TTL +5v and GND was also connected, and I have not used any level converter from 5v to 3.3v, as my other Wemos D1 works ok without any level converter.

img_1724

img_1723

ANY HELP IS APPRECIATED !!!

ovisopa commented 6 years ago

I fixed it, somehow the dupon cables ware not making contacts proper contacts, now after I removed and pluged them back in, I see a reading from the sensor .. everything is ok

`#include

include

include

include // https://github.com/olehs/PZEM004T

PZEM004T pzem(D3,D4); IPAddress ip(192,168,1,1);

const char ssid = "XWD office"; const char password = "Extr3m3WD"; // Static IP details... IPAddress wifiip(192, 168, 1, 50); IPAddress gateway(192, 168, 1, 1); IPAddress subnet(255, 255, 255, 0); IPAddress dns(192, 168, 1, 1);

String script_version = "v1.2-2018.05.21";

// END OVIS VARIABLES //////////////////////////////////////////////////

void setup() { // Serial.begin(115200); // Serial.println(); // Serial.println(); // swSer1.begin(9600); pzem.setAddress(ip);

// Initialising the UI will init the display too. display.init();

//display.flipScreenVertically(); display.setFont(ArialMT_Plain_10);

// Serial.println("Powering up ESP oLED ");

// Static IP Setup Info Here... WiFi.config(wifiip, dns, gateway, subnet); //If you need Internet Access You should Add DNS also... // Serial.printf("Connecting to %s ", ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); // Serial.print("."); } // Serial.println(" connected"); // Serial.println(WiFi.localIP());

String ipaddress = WiFi.localIP().toString();

} `