-
Notifications
You must be signed in to change notification settings - Fork 97
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
Can you please explain unstable reading? #8
Comments
Can you try adding a delay between readings? |
Yes, 50ms delay fix this. Thank you! |
someone can test this example (without any delays between readings) and report whether problem with NaN readings still persists
|
Using latest version of this library, latest software serial and the code below (printf on the esp8266 doesn't understand floats), I get: Voltage: 228.20V Voltage: 228.40V Voltage: 228.40V Voltage: 228.10V #include <SDM.h> //import SDM template library
SDM<2400, 12, 13> sdm; //SDM120T baud, rx pin, tx pin
//SDM<4800, 12, 13> sdm; //SDM220T baud, rx pin, tx pin
//SDM<9600, 12, 13> sdm; //SDM630 baud, rx pin, tx pin
//or without parameters (default from SDM.h will be used):
//SDM<> sdm;
void setup() {
Serial.begin(115200); //initialize serial
sdm.begin(); //initalize SDM220 communication baudrate
}
void loop() {
float v = sdm.readVal(SDM120C_VOLTAGE); //read voltage
float c = sdm.readVal(SDM120C_CURRENT); //read current
float p = sdm.readVal(SDM120C_POWER); //read power
float f = sdm.readVal(SDM120C_FREQUENCY); //read frequency
Serial.printf("\nVoltage: %sV\nCurrent: %sA\nPower: %sW\nFrequency: %sHz\n", String(v, 2).c_str(), String(c, 2).c_str(), String(p, 2).c_str(), String(f, 2).c_str());
delay(1000); //wait a while before next loop
} If I modify the library with a delay(1), it works
Voltage: 231.40V Voltage: 230.90V Voltage: 231.10V Voltage: 231.00V |
fix for issue with nan reading by sjfaustino: #7 (comment) #8 (comment)
done btw, which version does not understand float?? |
I'm still getting
Gives me:
Adding a delay of 20ms between each
Maybe you have an idea how to optimize this. Or should I simply use the hardware serial? Thank you for the lib. Cheers, |
Please try to use hw serial, I don't have more than 1-2 errors per day for sdm220 with hw serial (without any delay between readings) |
I'm using a plain SN75176B - which is a drop-in replacement for the MAX485 - with no additional resistors. Maybe I should add some Pull-Up's like these chinese boards have? //edit: |
It's hard to say for me...it's just an idea. |
I've ordered the SP3485EN-L, which is a 3.3V version of the MAX485. The MAX485/SN75176B itself is specified for 5V. I will test when they arive to know if it's simply a problem with 3.3V logic. |
if You waiting for new converter, please try on "old" 5V how it works on ESP8266 HW serial lines.
|
Sorry for getting back late... I've switched to the SP3485EN-L (3.3V RS485 tranceiver) and have the same result, but slightly more stable. Only every 3rd/4th reading has a I will try the "hardware"-serial next and will get back to you. |
I have one more idea to check,
and
maybe something is wrong with enabling/disabling softwareserial RX interrupt |
I still get nan-readings... and a panic:
|
I have to make sure, that my esp is not faulty... I will get back to you as soon as I have time to test... especially with hardware serial. I only testet it with softserial, yet... Thanks for your time! |
I've used another ESP8266 - no How do you manage to flash while the RS485 tranceiver is also connected to the hardware serial? Should I enable it (VCC) from software to not feed the "programming data" to the tranceiver? |
Nice to hear. |
Ok, I've implemented that already... finishing up the code to push some vars to mqtt. Will post it in a minute. Currently I think the I've also tested with it the LDO and an added 330µF capacitor over the 3.3V line using softserial. This get's ma far less |
Here is what I came up with: https://github.com/codmpm/esp-sdm-mqtt And, I also get |
I'm using MeanWell din rail 5V power supply, connected directly to wemos d1 usb connector and converter powered from wemos 3.3V pin. |
Hm, I can't see anything faulty with the scope. Meanwhile I'm using hardware serial, which works like a charm. |
I'am using meanwell hdr-15-5 and connected 2 x Wemos D1 mini with https://www.aliexpress.com/item/TTL-turn-RS485-module-485-to-serial-UART-level-mutual-conversion-hardware-automatic-flow-control/32709226383.html converters. Both pairs shares same power supply. |
have you swapped pair? wemos1 to converter2 and wemos2 to converter1 to detect which element can cause errors. As I understand, you are using two sdm? If yes, you can use one pair for reading both sdm (with different ID) |
I have tried to swap, no luck. Even used different converter. When I conect seperate power supply seems no problems. Maybe some interference when 1 power supply is used. I plan to read more sdm, so need 2 wemos and 2 converters. At the moment 2 sdm working. |
you can read up to 247 (with id from 1 to 247) devices from one pair (wemos+converter). |
I pass all values via mqqt and need stability, will try to read several SDM from one pair. |
I also pass values (but from one sdm) to home mqtt server and to remote thingspeak, the same values are available via internal esp8266 http server for live page and json for remote php requests, everything is done by one wemos module |
I have SDM120, this converter and Wemos D1 mini.
And i got NaN in output always in different places.
What i should tune in fw?
at 2400b
The text was updated successfully, but these errors were encountered: