Skip to content
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

Stupid sdm120 from Aliexpress [solved] #16

Closed
da3020 opened this issue Apr 4, 2018 · 2 comments
Closed

Stupid sdm120 from Aliexpress [solved] #16

da3020 opened this issue Apr 4, 2018 · 2 comments

Comments

@da3020
Copy link

da3020 commented Apr 4, 2018

Hi guys. I've bought SDM120 power meter on Aliexpress. It has no any suffixes at label. Just SDM120. Looks exactly like this.
I have spend three days trying to connect it to Arduino Mega and parsed four different librarys before I've understood one really despicable thing. The item is that it has OWN undocumented protocol.
I vave found original protocol on the manufacturer's website. But meter from Aliexpress did not match this.

When i send for example, voltage request:
01 04 00 00 00 02 71 CB

the meter  response like:
00 01 04 04 43 66 E6 66 C4
00 01 04 04 43 66 B3 33 3B
00 01 04 04 43 66 CC CD 9A
and so on ...
00 01 04 04 43 xx xx xx xx

So, it seams like first byte is missing and response starts from second byte. And really - if I interpret b4-b7 bytes like the value then it works!
Code needs to be changed like:

((uint8_t*)&res)[3]= sdmarr[4];
((uint8_t*)&res)[2]= sdmarr[5];
((uint8_t*)&res)[1]= sdmarr[6];
((uint8_t*)&res)[0]= sdmarr[7];

and error checks need to be redused.
But I don't know what the last byte meens.


I have found interesting thing now.
If I cut first and last bytes from response and calculate CRC for remaining bytes on this website then last byte of CRC-16 (modbus) value is ALWAYS equal to cutted last byte from response. See screenshot

Is it any simplified CRC byte? Does anybody knows?


Hi again! I have serious reasons to believe that rs485-ttl convertor is the reason of my fault.
Yes!!! It need to remove R7 resistor from rs485 to TTL convertor!

@da3020 da3020 changed the title Stupid sdm120 from Aliexpress Stupid sdm120 from Aliexpress [partially resolved] Apr 4, 2018
@da3020 da3020 changed the title Stupid sdm120 from Aliexpress [partially resolved] Stupid sdm120 from Aliexpress [partially solved] Apr 4, 2018
@da3020 da3020 changed the title Stupid sdm120 from Aliexpress [partially solved] Stupid sdm120 from Aliexpress [solved] Apr 4, 2018
@reaper7 reaper7 closed this as completed Apr 15, 2018
@nicklasharaldsson
Copy link

I'm having similar problems.

I have this rs232 <-> rs485 converter:
https://www.sparkfun.com/products/10124

If i remove one byte in the beginning and end of response it works fine. But for some reason i get a trailing and leading zero on every response.

My fix is to just throw these away before we parse the response.

I have installed 120 ohm resistors, tried to change the 220 ohm smd resistor on the module with a 120 ohm resitor but still get the same results.

I am using softwareserial and ESP8266 on an nodemcu 0.9.

Don't know if this is a bug of this library, probably more lika a hardware issue. But it might help others coming here.

@MinionDiv
Copy link

RS485 RTU SDM120***
Connec modbus fail. REG >>> 0
Connec modbus fail. REG >>> 6
Connec modbus fail. REG >>> C
Connec modbus fail. REG >>> 1E
Connec modbus fail. REG >>> 46
Connec modbus fail. REG >>> 156

Voltage = 0.00 VAC
Current = 0.00 Amps
Active Power= 0.00 Watts
Power Factor = 0.00
Frequency = 0.00 Hz
Total Active Energy = 0.00 kWh
Connec modbus fail. REG >>> 0
Connec modbus fail. REG >>> 6
Connec modbus fail. REG >>> C
Connec modbus fail. REG >>> 1E
Connec modbus fail. REG >>> 46
Connec modbus fail. REG >>> 156

is it due to my convertor problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants