Wednesday, June 13, 2018

(#29) And now for something completely different


Tinkering on the Home Automation front has slowed. I've got a number of projects in various states of completion: IKEA Tradfri lighting, ODB2 and CANBUS monitoring, GPS work, etc.  And Solar.  



Since we bought the motorhome, my interest in solar charging of 12V systems has been growing.  A few months ago, I purchased a 100W solar panel, and a simple 10A solar charge controller to get started.

While this approach taught me a few things about solar charging systems at a low entry cost, the charge controller was dumb.  More sophisticated charge controllers, with communication capabilities are out there.

Given my interest in IoT, a smarter controller was a necessity!


The Solar Charge Controller

Beijing Epsolar Technology Co is a popular manufacturer of affordable solar charging products. Their LandStar series of PWM Charge Controllers met my needs of being affordable and having a communication interface. 



Twenty dollars and three weeks later, the LS1024B PWM Solar Charge Controller from EPSolar arrived.



Other models from this vendor used a serial interface. This one uses a protocol called "modbus".  I knew nothing of this protocol before the controller arrived and I still know precious little. And I have little desire to master an archaic protocol, so take this next section with a huge 'grain of salt'.

Apparently you can use the Modbus protocol over a variety of interface specifications, but the LandStar uses Modbus RTU over RS485.  While I have no idea what that really means, I was able to Google up a number of matches to get something cobbled up that works.

USB / RS485 Adapter

The first purchase was a USB/Modbus dongle.  There are dozens available on eBay, Aliexpress, etc. I spent $3.50 for one that looks like this and when plugged into Linux, it registers as "ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter":

Plug the adapter into your Linux machine, check 'dmesg' to ensure the device is recognized.  And you should have a "/dev/ttyUSBx" device appear.

[ ] usb 1-2: new full-speed USB device number 3 using ohci-pci
[ ] usb 1-2: New USB device found, idVendor=1a86, idProduct=7523
[ ] usb 1-2: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ ] usb 1-2: Product: USB2.0-Serial
[ ] usbcore: registered new interface driver usbserial
[ ] usbcore: registered new interface driver usbserial_generic
[ ] usbserial: USB Serial support registered for generic
[ ] usbcore: registered new interface driver ch341
[ ] usbserial: USB Serial support registered for ch341-uart
[ ] ch341 1-2:1.0: ch341-uart converter detected

[ ] usb 1-2: ch341-uart converter now attached to ttyUSB0


Wiring it all up

Wiring of the device is simple.  Grab any old Ethernet cable (the connection on the LandStar controller is RJ45.)  Cut one of the RJ45s from the cable, strip the wires.  Find the wires that connect to pins 3 and 5 - and trim the insulation.



Wire 5 goes the the connection marked "A" on the adapter. Wire 3 goes to the connection marked "B".  Use a multimeter to ensure continuity and a good connection.  Then plug the adapter back into the Linux machine.

Plug the other end of the Ethernet cable into the COM port on the controller.  Connect the 12V battery to the charge controller and the LandStart will power up.



[ Ignore the DC-DC buck converter in the photo as I use this setup to power a Raspberry Pi. ]


With the hardware wired and connected, we can move on to the software. Which is discussed in the next post!






No comments :

Post a Comment