Off-grid Solar / Battery monitoring and control freeware

upnorthandpersonal

Administrator
Joined
Dec 25, 2019
Messages
2,251
Location
63 degrees North, Finland
It's the same register, just the lower bits are for external sensor and the higher ones are for controller temperature. Making the if() statement True and adding the following below the print() statement in the if() statement should give you the value (as batTemp):

valName = "mode=\"batTemp\""
valName = "{" + valName + "}"
dataStr = f"Renogy{valName} {float(battery_temp)}"
print(dataStr, file=fileObj)
 

BarkingSpider

Carbon Lifeform
Joined
Apr 14, 2020
Messages
373
Location
Silicon Valley, CA
Hi Mike, I don't have an SCC with 2 temp sensors to test, i would suggest just googling for the right address and keep trying your code until you find it.

Also be aware, some codes have 2 values in one reading, you need to bit shift 8 or 16 bits to get the next value.

Please post your results if you do get it working.
 

mike_d_

New Member
Joined
Mar 8, 2021
Messages
5
Thanks Joe, but @upnorthandpersonal got me set up with the code. Here is the final code block:


Python:
                if (True):     # for chargers with remote temp sensors
                        register = renogy.read_register(0x103)
                        battery_temp_bits = register & 0x00ff
                        temp_value = battery_temp_bits & 0x0ff
                        sign = battery_temp_bits >> 7
                        battery_temp = -(temp_value - 128) if sign == 1 else temp_value
                        #print("battery temp:", float(battery_temp), "C")
                        valName = "mode=\"batTemp\""
                        valName = "{" + valName + "}"
                        dataStr = f"Renogy{valName}{float(battery_temp)}"
                        print(dataStr,file=fileObj)

And here is what the data comes out as: (my temp sensor is currently taped to the battery but still in the same box for now)

Screenshot from 2021-04-09 07-20-26.png
 

upnorthandpersonal

Administrator
Joined
Dec 25, 2019
Messages
2,251
Location
63 degrees North, Finland

BarkingSpider

Carbon Lifeform
Joined
Apr 14, 2020
Messages
373
Location
Silicon Valley, CA

upnorthandpersonal

Administrator
Joined
Dec 25, 2019
Messages
2,251
Location
63 degrees North, Finland

TGPB

Solar Enthusiast
Joined
Aug 16, 2020
Messages
125
This project is right in line with what I want for my off-grid location.
I honestly have little experience with the raspberry pi but can figure out just about anything with a bit of detailed instruction.
my system has the following.

1- Morningstart 45A Tristar MPPT SCC
1- Morningstar Relay Driver 4 Channel (1 used for Auto-Start of Diesel Gen)
1- Epever 40A BN Series SCC w/ USB Adapt.
4- LLT Power (overkill) 4S 12V 120A BMS with Bluetooth + 2-wire RS485

I have a
Raspberry Pi 3+ 32GB
2- Peacefair PZEM-017
1- Tripp Lite USB to Serial Adapter Cable (USB-A to DB9 U209-000-R)

What other devices or equipment do I need to acquire before I pester anyone about setting this up for system monitoring?

Thanks
Clay
 

BarkingSpider

Carbon Lifeform
Joined
Apr 14, 2020
Messages
373
Location
Silicon Valley, CA
Hi Clay, looks like your off to a good start.

The Epever is the low hanging fruit. You should be able to get that up and running very quickly. Just refer to my github link below.

Your BMS should be workable also, I haven't tested that device yet, but it's on my todo list. Keep us posted on any progress you make.

Code at https://github.com/BarkinSpider/SolarShed/
 
Last edited:

Sanwizard

Photon Sorcerer
Joined
Feb 2, 2021
Messages
1,298

Shotgun

Solar Enthusiast
Joined
Apr 28, 2021
Messages
26
It seems that there are multiple projects in Github named SolarShed. I'm working to monitor my PowMr unit and followed used this project as a template:


I put my project at:


I see a significant difference in how the code written by @BarkingSpider and I what I've done. You're sending commands and parsing responses. I'm just reading registers. I think getting the formatted responses would be more robust, but how do you figure out the commands and how to parse the responses. The people at PowMr seem to be completely incompetent and refused to share any technical data, so I'm fishing here.

BTW, I have a Pi Zero W on the way. The controller I have doesn't have a USB supply port, so I'll have to pull 5V off of the RS-485 connector. They did tell me that it can supply 2W of power, nearly double what the Pi Zero will pull.

I'd like to tag onto this project, instead of rolling my own. The only difference is that I don't want to push data to the cloud. Just want to be able to query it locally. I'm just not sure how to get this controller on board.
 

upnorthandpersonal

Administrator
Joined
Dec 25, 2019
Messages
2,251
Location
63 degrees North, Finland
You're sending commands and parsing responses. I'm just reading registers.
It's all reading registers, its just that with devices that support modbus you use minimalmodbus in Python which abstracts stuff. The JK/Heltec BMS is also RS485, but not modbus, so one has to do some extra work and needs some trial and error with perhaps the help of a badly translated datasheet.
 

shadowsteve

Solar Enthusiast
Joined
Feb 11, 2021
Messages
193
I run software I based on EPSolarServer and it reads modbus registers from my Rover 40. I log the data to a SQL db and also capture other info and log it (5th wheel trailer)
 

tschuh

New Member
Joined
Feb 25, 2021
Messages
4
Really appreciate you doing the heavy lifting!

I built mine yesterday afternoon. The Renogy doesn't give me nearly the level of detail as a more expensive unit but my use case is very tiny. My next solar powered project is bigger than powering a RPi and a webcam so I'll likely spend quite a lot more than $20 on a charge controller. This will absolutely be part of the solution!
 

Shotgun

Solar Enthusiast
Joined
Apr 28, 2021
Messages
26
It's been a long day, but I finally got my script running on a Pi Zero. The problem is that minimalmodbus is coming back with "No communication with the instrument (no answer)". I plug the same cable into the Linux box that I've been monitoring with, and it works just fine. /dev/ttyUSB0 doesn't show up until I plug the jack into the controller, just as one would suspect, so I know that there is some data communication going on.

What could I be looking at to determine why the Zero isn't getting an answer from the controller?
 

Sanwizard

Photon Sorcerer
Joined
Feb 2, 2021
Messages
1,298
It's been a long day, but I finally got my script running on a Pi Zero. The problem is that minimalmodbus is coming back with "No communication with the instrument (no answer)". I plug the same cable into the Linux box that I've been monitoring with, and it works just fine. /dev/ttyUSB0 doesn't show up until I plug the jack into the controller, just as one would suspect, so I know that there is some data communication going on.

What could I be looking at to determine why the Zero isn't getting an answer from the controller?
I heard the zero had issues with USB. Why not just go for a Pi4?
 

Shotgun

Solar Enthusiast
Joined
Apr 28, 2021
Messages
26
I heard the zero had issues with USB. Why not just go for a Pi4?
I had not heard that. I went with the Zero for smaller weight and reduced power draw. I was going to let it hang from its connector and be powered by the RS-485 power.
 

Shotgun

Solar Enthusiast
Joined
Apr 28, 2021
Messages
26
I found some troubleshooting advice on the RaspberryPi pages. Using dmesg, I see that the USB is connecting to the device:


pi@raspberrypi:~ $ sudo dmesg -C
pi@raspberrypi:~ $ <went over, disconnected, and then reconnected the controller.
pi@raspberrypi:~ $ dmesg
[51165.301178] usb 1-1: USB disconnect, device number 3
[51165.307890] ch341-uart ttyUSB1: ch341-uart converter now disconnected from ttyUSB1
[51165.308223] ch341 1-1:1.0: device disconnected
[51169.001067] Indeed it is in host mode hprt0 = 00021501
[51169.210924] usb 1-1: new full-speed USB device number 4 using dwc_otg
[51169.211290] Indeed it is in host mode hprt0 = 00021501
[51169.452376] usb 1-1: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.64
[51169.452419] usb 1-1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[51169.452470] usb 1-1: Product: USB Serial
[51169.471962] ch341 1-1:1.0: ch341-uart converter detected
[51169.474422] usb 1-1: ch341-uart converter now attached to ttyUSB0
pi@raspberrypi:~ $
pi@raspberrypi
:~ $ lsusb
Bus 001 Device 004: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pi@raspberrypi:~ $
pi@raspberrypi:~ $ python3 -m powmr
No communication with the instrument (no answer)
 
Top