Closed shgubar closed 8 months ago
You are defined Serial1 as i/o for sdm library but your connection pins are Serial0
Thanks for your quick answer.
I tried, as you suggested, the piece of code below (did I understand correctly?):
#if defined ( ESP8266 ) //for ESP8266
SDM sdm(Serial0, SDM_UART_BAUD, NOT_A_PIN, SERIAL_8N1); //config SDM
#elif defined ( ESP32 ) //for ESP32
SDM sdm(Serial0, SDM_UART_BAUD, NOT_A_PIN, SERIAL_8N1, SDM_RX_PIN, SDM_TX_PIN); //config SDM
#else //for AVR
SDM sdm(Serial0, SDM_UART_BAUD, NOT_A_PIN); //config SDM on Serial1 (if available!)
#endif
But I immediately got an error:
Arduino: 1.8.13 (Mac OS X), Board: "LOLIN(WEMOS) D1 R2 & mini, 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), v2 Lower Memory, Disabled, OTA, Only Sketch, 921600"
sdm_simple:25:9: error: 'Serial0' was not declared in this scope
SDM sdm(Serial0, SDM_UART_BAUD, NOT_A_PIN, SERIAL_8N1); //config SDM
^
Using library SDM_Energy_Meter-2.2.0 at version 2.2.0 in folder: /Users/sh/Documents/Arduino/libraries/SDM_Energy_Meter-2.2.0
exit status 1
'Serial0' was not declared in this scope
Even if I use:
#if defined ( ESP8266 ) //for ESP8266
SDM sdm(Serial, SDM_UART_BAUD, NOT_A_PIN, SERIAL_8N1); //config SDM
#elif defined ( ESP32 ) //for ESP32
SDM sdm(Serial, SDM_UART_BAUD, NOT_A_PIN, SERIAL_8N1, SDM_RX_PIN, SDM_TX_PIN); //config SDM
#else //for AVR
SDM sdm(Serial, SDM_UART_BAUD, NOT_A_PIN); //config SDM on Serial1 (if available!)
#endif
The code compiles, but the response is:
13:06:40.044 -> Voltage: nanV
13:06:40.760 -> Current: nanA
13:06:41.510 -> Power: nanW
13:06:42.211 -> Frequency: nanHz
Serial not Serial0
You cannot use the serial port at the same time for debugging and for communication with sdm.
TX LED diode on the converter blinking? if so then what happens with RX LED
You cannot use the serial port at the same time for debugging and for communication with sdm.
I already tried to connect through the power supply, after downloading the sketch from the computer. But doesn't work.
TX LED diode on the converter blinking?
Yes, blinking
what happens with RX LED
Nothing, not blinking
Now I tried another sketch - sdm_live_page_esp8266_hwserial - from last release (SDM_Energy_Meter-2.2.0). And connect through the power supply.
That is, the behavior of LEDs is correct.
On web page zeroes:
try to modify the sketch, add the function getErrCode and display the error code on the website.
4 mean timeout https://github.com/reaper7/SDM_Energy_Meter/blob/master/SDM.cpp#L112
maybe you have set different baudrate or stopbits parameters ??
In sketch I use:
SDM sdm(Serial, 9600, NOT_A_PIN, SERIAL_8N1);
If I use SoftwareSerial:
SDM sdm(swSerSDM, 9600, NOT_A_PIN, SWSERIAL_8N1, 13, 15);
All working fine
have you tried an older version of the library ?? 2.1.1 in this new one, timeouts were modified, but unfortunately without verification (I don't have these devices anymore)
if swserial works and hw doesn't, maybe you swapped TX / RX pins ?? wemos often had swapped overprints... or something is plugged into wemos usb port and is interfering with transmission
if swserial works and hw doesn't, maybe you swapped TX / RX pins ?? wemos often had swapped overprints... or something is plugged into wemos usb port and is interfering with transmission
I have already tried to change it, but it does not help
have you tried an older version of the library ?? 2.1.1 in this new one, timeouts were modified, but unfortunately without verification (I don't have these devices anymore)
It's all the same
Unfortunately I have no more ideas :(
What was done: 1) Used external power supply 2) Changed RX/TX
Without success !!!
I think I found the answer to my question, @reaper7.
Wemos D1 Mini has a UART chip that is in constant contact with RX/TX. It is enough to either solder out the resistors going to the UART chip or remove this chip altogether, then everything works as it should. Yes, in this way we will get rid of serial reprogramming, but that's another story. By the way: Serial.Print was not activated anywhere in the code. From my experience, it is generally better to use the ESP8266 chip itself, but it needs a 3.3V power supply and a harness for correct operation.
Very grateful for this library.
Hello Please help with the connection, because I already spent a lot of time on this but nothing happened to me. The current connection looks like the picture below (everything seems to be correct):
Here is the configuration file:
Here is the code I am trying to use to output the data:
My output in Serial Monitor:
Thanks in advance.
FYI: Same converter I use with Raspberry Pi 4 and connect to RX_UART & TX_UART, read with phyton code - everithing work fine.