logo elektroda
logo elektroda
X
logo elektroda

KWS-301L RS485 – Teardown and interface with Wemos D1 R32 (ESP32) and Openlog

Lusant 489 1
ADVERTISEMENT
  • Helpful post

    KWS-301L exposes TX, RX, GND and 5 V pins

    #1 21909836
    Lusant
    Level 5  
    Posts: 8
    Help: 1
    Rate: 3
    KWS-301L Teardown

    KWS-301L RS485 – Teardown and interface with Wemos D1 R32 (ESP32) and Openlog


    There are a lot of this kind of devices, this type appear in versions with external current transformer or with internal shunt measuring and also with/without RS485 interface.
    In this case it will be the model with 100 A external clamp current transfomer and also with R485.

    KWS-301L RS485 – Teardown and interface with Wemos D1 R32 (ESP32) and OpenlogKWS-301L RS485 – Teardown and interface with Wemos D1 R32 (ESP32) and OpenlogKWS-301L RS485 – Teardown and interface with Wemos D1 R32 (ESP32) and OpenlogKWS-301L RS485 – Teardown and interface with Wemos D1 R32 (ESP32) and Openlog

    Inside of it we find the HT5015, which do everything, measure, display interface and communication. We can find the datasheet in the web but only in Mandarin (at least I never found an English version).
    There is also a NON ISOLATED power supply (be aware with the place where you put your fingers), based in a BP2525 reference B, which give 500 mA (according the manufacturer).
    The model with RS485 interface has an extra board soldered to the main board (I've messed up the connections, but nothing that a little piece of wire didn't solve). This small board has their own isolated power supply with a B0505S-1WR3, a RS485 transceiver BL3085 and a digital isolated chip PI122u31. This little board makes the device safe from the communications point of view.

    When I start playing with this stuff, after some digging in the net, I was trying to glue an ESP8266 to the case of the device and have it running with a browser interface. But when I saw the power supply, I was affraid it can't handle enaugh power to everything and try another approach. Anyway, for those that want to test, even those that don't have the L version, the pins for TX, RX, GND and 5 V are available in the main board .. may be the HT5015 of both versions of the device have the same program and allowed communication to RS232 inside of the device ... AGAIN, BE AWARE OF YOUR FINGERS, THE INTERNAL POWER SUPPLY IS NOT ISOLATED.

    So, I was following another direction, using a little transceiver board RS485<->TTL and a Wemos D1 R32 (any ESP32 will do the work) and make some software in strict collaboration of Codex from OpenAI (he, or she, ... or it, ... make the text code under my requests).
    KWS-301L RS485 – Teardown and interface with Wemos D1 R32 (ESP32) and OpenlogKWS-301L RS485 – Teardown and interface with Wemos D1 R32 (ESP32) and Openlog

    As I was not satisfied, I make an improvement and join an Openlog datalogger from Sparkfun. This small piece of hardware can log whatever we send to it, the only thing that was missing was a parser to save the data more conveniently. So, I reuse an idea that I've done for log a GPS data, and, again with Codex, I changed the original code from Sparkfun to parse the data from KWS-301L.


    The final result is, I got a web interface that handle all the knowed stuff of the device and also with a page that give a JSON with that stuff, and a datalogger which record the data in a structure YYYY\MM\YYYYMMDD.CSV.
    The system can read from the sdcard and it is possible to download files to pc .. slowly, because this part run at 115200 bps.

    KWS-301L RS485 – Teardown and interface with Wemos D1 R32 (ESP32) and OpenlogKWS-301L RS485 – Teardown and interface with Wemos D1 R32 (ESP32) and Openlog


    In attach, you will find the project for Wemos in Platformio, the code for "upgrade" the datalogger and some definitions of the protocol.


    Post Scritp and joke ... I know this is not a teardown for BK chips .. but it will be a candidate to win at least a pen ...
    Attachments:
    • files.zip (55.87 KB) You must be logged in to download this attachment.
  • ADVERTISEMENT
  • Wiring and config for KWS-301L with ESP32

    #2 21910485
    Lusant
    Level 5  
    Posts: 8
    Help: 1
    Rate: 3
    In order to help those who didn't read the report inside files.zip, where you can find the major connections, there is a diagram that we can follow to wire this stuff.
    Wiring diagram of an ESP32 with an RS485 module and a UART TTL converter, showing pins and A+/B- lines


    Pay attention to the RS485 transceiver, because in the model I have, the TX and RX of the transceiver are directly connected to TX and RX of the Wemos board (no cross connections).
    The datalogger, by the way, is cross connected to Wemos, meaning the RX of the datalogger connects to TX of Wemos and TX of the datalogger connects to RX of Wemos.

    The power supply of the RS485 transceiver should be connected to 3.3 V, because the ESP32 is not 5 V tolerant. The datalogger has a 3.3 V regulator, so it can be connected to 5 V.


    To program the new code in the datalogger, one can use an FTDI converter and Arduino IDE, choose the board "Arduino Pro or Pro Mini" and connect it like the picture shows:

    Wiring diagram of two FTDI Basic boards with crossed TX/RX connections


    One thing I forgot to mention is that the SD card must have the config.txt file with the following content:
    
    115200,36,3,4,0,0,0,100,100
    baud,escape,esc#,mode,verb,echo,ignoreRX,maxFilesize,maxFilenum
    
    Attachments:
    • config.txt (92 Bytes) You must be logged in to download this attachment.
ADVERTISEMENT