-
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
Odd numbers are read correctly, even numbers not #7
Comments
Please try a delay(50); between each sdm.readVal. |
A delay(1) between reading each value seems to be sufficient.
|
I can add this,
my config: SDM220 at 4800 baud maybe baudrate affected this? If I find some free time, then I insert some debug code with count wrong/nan reading |
Not sure it's Baud related. I have 120c and 630 with 2400 and 9600 baud rate. |
After 1 hour of tests with error counter, I don't have any wrong readings. this is my code (sorry but not usable as is because it uses my priv helper lib for wifi connection/ota/oled)
this is a prototype code but works ~129days without a problems |
one more thing... |
I'm using a Wemos D1 mini (esp8266) connected to this ttl2rs485: https://www.aliexpress.com/item/TTL-turn-RS485-module-485-to-serial-UART-level-mutual-conversion-hardware-automatic-flow-control/32709226383.html Wemos mini to TTL2RS485: TTL2RS485 to SDM120C So, 2 wire. Also, no 120 ohm resistor in use ( I believe it is only necessary on long cable runs). I sugest adding a ifdefine add_sdm_delay to the library and let the user do a #define add_sdm_delay if he wants. |
I can't reproduce this error. GND...maybe 8: |
after 14 hours still no errors |
@beireken - do You check if this problem also exists when converter is connected via hardware serial? I checked this problem whole weekend, code read all fourteen SDM220 registers at once in loop every 2sec and after 2 days I have only 37 errors I must check if problem is a timeout/bad checksum/not enough bytes read |
@reaper7 Do you mean changing the library to function with hardware serial and not softserial? |
no no, this lib is ready for use with hardware serial,
before:
If You not tested yet hardware serial functionality of this lib then no question :D Today I added a few fix, maybe some reading errors disappear... |
Hmm I did not know that. I will test this when I get the chance and report back. |
ok, tnx. |
fix for issue with nan reading by sjfaustino: #7 (comment) #8 (comment)
Im trying to use your code from above but im missing this library ESP8266r7Helper.h |
@mariusz84pl - this is my private lib, only for connect to wifi, configure ota and print lines on oled display.
with Your own solution. |
I'm trying to use hardwareserial cut can't get to work with it. TX working but no RX. in sketch added #define USE_HARDWARESERIAL on top.
|
added or removed? I don't know what is needed in Your application. What kind of converter you are using, with or without DE/RE pins ? |
Tryed every combination of connection TX/RX and can't get any values |
I use the same :) so, I just tested this simple sketch with hw serial (my sdm is set to 9600b!!!):
led blinks, it's mean reading ok this is my "hardware" ;) |
I have WEMOS d1 mini. wdt reset |
watchdog timer reset https://github.com/esp8266/Arduino/blob/4897e0006b5b0123a2fa31f67b14a3fff65ce561/doc/faq/a02-my-esp-crashes.md I have to guess for what reason? |
This happens to me when I want to test Sdm_live_page. |
at start or whether during operation? |
Error appears at the beginning. With programming i do not have problem. It is, when the program start on esp. |
example sdm_simple works for You? |
sorry, |
I removed some external libs(for display the time) from example, please download again and try. You are using hardware or software serial? If softwareserial, then on which pins? Try debuging code yourself by inserting Serial.print("something"); in different places, to detect the error location. |
reinstall arduino and libraries
|
sorry but I cant duplicate this issue,
web page works this is my code:
|
Hello. Thank you very much for all your help and informations. I did my web. Best Regards, M. Rotovnik |
all measurements in one loop run are NAN? what you changed?
|
Example :sdm_simple change serial PIN Change delay time: Change delay : Change SDM120 - SDM220 ............................ |
try to check which error causes a bad reading,
Have you tried other speeds? 4800? I still suggest switching to HardwareSerial which I personally use. |
Error 4. �[1;0HVoltage: 230.50V |
error 4 -> SDM_ERR_TIMEOUT Try to increase MAX_MILLIS_TO_WAIT |
Thank you for all informations. How can I change the speed from 2400 to 4800? I would not yous Tx in Rx pin, because I allready use them for Serial.print. |
I have the very same setup as descibed here. I also changed the MAX_MILLIS_TO_WAIT to 1500 to be on the safe side. But I continue to receive the error code 4 as well. If possible I would like to stay with 2400 baud. Simply because I don't have the software to change it. |
When using the code below with a SDM120C:
`#include <SDM.h> //import SDM template library
SDM<2400, D1, D2> sdm; //SDM120C baud, rx pin, tx pin
void setup() {
Serial.begin(115200); //initialize serial
sdm.begin(); //initalize SDM220 communication baudrate
}
void loop() {
Serial.print("Frequency: ");
Serial.print(sdm.readVal(SDM120C_FREQUENCY), 2); //display frequency
Serial.println("Hz");
Serial.print("Voltage: ");
Serial.print(sdm.readVal(SDM120C_VOLTAGE), 2); //display voltage
Serial.println("V");
delay(1000); //wait a while before next loop
}`
I get:
If I swap the read order as on the code below:
`#include <SDM.h> //import SDM template library
SDM<2400, D1, D2> sdm; //SDM120C baud, rx pin, tx pin
void setup() {
Serial.begin(115200); //initialize serial
sdm.begin(); //initalize SDM220 communication baudrate
}
void loop() {
Serial.print("Voltage: ");
Serial.print(sdm.readVal(SDM120C_VOLTAGE), 2); //display voltage
Serial.println("V");
Serial.print("Frequency: ");
Serial.print(sdm.readVal(SDM120C_FREQUENCY), 2); //display frequency
Serial.println("Hz");
delay(1000); //wait a while before next loop
}`
I get:
The text was updated successfully, but these errors were encountered: