Weewx and Tristar MPPT Controller Integration

clifwlkr
clifwlkr Registered Users Posts: 6 ✭✭
Hey everyone,

Developed a solution that I think really ends up being very powerful for my off grid cabin at 10k feet in Colorado.  It runs truly off grid utilizing solar and satellite internet.  I spend chunks of time up there, but am often away, so I wanted to keep track of things in the most energy efficient manner I can and check in on the place, as well as just virtually visit when stuck at work :-)....

So I centralized on a Raspberry Pi to act as a server there that uses very little power (about 6w most of the time max).  I started running a program called weewx on there to provide a view and logging of the weather for me.  This program logs the data, generates web pages, and provides graphs, gauges, and skins to create customized views.  This all runs on the pi.

I was using the internal tristar web page to check on the charge status, but it is very limited, doesn't allow me to customize the view, and doesn't provide me any kind of ability to query the log in interesting ways.  So last time I was up there, I had the great idea of combining the two.  So I ended up writing a data service for weewx that queries the tristar modbus interface and gathers the data at the same time it grabs the weather data.  This all gets stored in the sql database on the  pi, so I have a record every five minutes.  Then I can use the built in skinning capabilities of the weewx program to create any web page I want.  Here is my current example:



There is lots of documentation out there on configuring, installing, customizing, and using weewx, but here is a link to my github repo with the code and instructions on how to add in the tristar support.

Thought I would share my efforts as so far it has been way more reliable than the tristar internal web server (which crashed all the time) and a lot cleaner to view/access.  Kind of nice to get the whole picture of what is going on at the cabin in one screen.

Jim Olsen

Comments

  • clifwlkr
    clifwlkr Registered Users Posts: 6 ✭✭
    Would help if I provided the link to the source code....

    https://github.com/jim-olsen/weewx_tristar

    Jim Olsen
  • KMac
    KMac Registered Users Posts: 9 ✭✭
    edited September 2018 #3
    Very cool creative solution! I've got cellular at my cabin and a peplink router that is running great. I can acces and view the Morningstar webpage data and run MSView to adjust configurations, look at graphs, and set to equalize if I want. But, I would like to add a weather station and some security cameras. I know your app serves the weather data. Do you think your solution might be able to publish the locally stored video and show live stream? Would be cool to see it all in one place!
  • clifwlkr
    clifwlkr Registered Users Posts: 6 ✭✭
    My main goal was to get something that also logs all of the data and can graph it, etc, as well as providing a low power solution to it, so the raspberry pi based solution fits that well.  Also runs a vpn server and such so I can log in and fix things at the cabin if needed.  

    There is a package for the raspberry pi for security camera software, although I found its motion detection to be less than adequate for my needs.  So I also run a small fanless windows machine running blue iris software that only draws 0.25 amps.  So I have my full server needs up and running for weather, cameras, and vpn / remoting access all for about 0.5amps at 12v…..

    I used to use the internal web page in the Morningstar, but it crashed all of the time and wouldn't come back up without a full reset, and it was pretty limited.  The weewx interface stores all of the data in a local sql database, so I will have data for every five minutes, along with the weather, for as long as I want....

    Jim
  • KMac
    KMac Registered Users Posts: 9 ✭✭
    Very cool.
  • KMac
    KMac Registered Users Posts: 9 ✭✭
    I wonder whether you could read that SQL database and create some ifttt applet to turn on and off some smart devices and use excess power (like a small heat pump)?
  • AGB
    AGB Registered Users Posts: 40 ✭✭
    clifwlkr said:
    Hey everyone,

    Developed a solution that I think really ends up being very powerful for my off grid cabin at 10k feet in Colorado.  It runs truly off grid utilizing solar and satellite internet.  I spend chunks of time up there, but am often away, so I wanted to keep track of things in the most energy efficient manner I can and check in on the place, as well as just virtually visit when stuck at work :-)....

    So I centralized on a Raspberry Pi to act as a server there that uses very little power (about 6w most of the time max).  I started running a program called weewx on there to provide a view and logging of the weather for me.  This program logs the data, generates web pages, and provides graphs, gauges, and skins to create customized views.  This all runs on the pi.

    I was using the internal tristar web page to check on the charge status, but it is very limited, doesn't allow me to customize the view, and doesn't provide me any kind of ability to query the log in interesting ways.  So last time I was up there, I had the great idea of combining the two.  So I ended up writing a data service for weewx that queries the tristar modbus interface and gathers the data at the same time it grabs the weather data.  This all gets stored in the sql database on the  pi, so I have a record every five minutes.  Then I can use the built in skinning capabilities of the weewx program to create any web page I want.  Here is my current example:



    There is lots of documentation out there on configuring, installing, customizing, and using weewx, but here is a link to my github repo with the code and instructions on how to add in the tristar support.

    Thought I would share my efforts as so far it has been way more reliable than the tristar internal web server (which crashed all the time) and a lot cleaner to view/access.  Kind of nice to get the whole picture of what is going on at the cabin in one screen.

    Jim Olsen
    This is so cool. I have been trying to do this for some time. What interface did you use to connect from the Pi to the RS485?
  • clifwlkr
    clifwlkr Registered Users Posts: 6 ✭✭
    Actually I use the built in tcp/ip interface that is available in the MPPT controller that is Modbus based.  I just implemented the reading of the Modbus protocol in python, and is available in the code.  That said, I see no reason why you should not be able to modify the code to use a serial port for reading the packets instead.  The TCP/IP option was a better one for my wiring arrangement.

    Jim
  • clifwlkr
    clifwlkr Registered Users Posts: 6 ✭✭
    You absolutely should be able to read the data right out of SQL if you wanted to go that route.  I would also imagine you could add a little python code to the existing reader that sent updated to IFTT directly if you wanted to as well.

    Jim
  • KMac
    KMac Registered Users Posts: 9 ✭✭
    edited January 2019 #10
    So your code polling the Morningstar charge controller is over the Ethernet connection, and the response from the controller has the Modbus data embedded in the IP?  If so, that's what I need to do, and then save the data perhaps to a JSON database not a SQL database (according to my son). 

    I can imagine lots of fun can be had once that data is available like that. I could use the data with ifttt to control loads when I am gone from the cabin.  For example, I could turn on the power to my window air conditioner when in absorb or float, and when my input panel wattage is greater than output wattage to the batteries, by an amount greater than the air conditioner uses.  I could use averages of the readings and/or time delays too so it is not kicking on and off to much.  That would keep the cabin temp (and humidity) right by using excess solar power, and not affect the battery charging. A mini-split with a heat pump sounds better and better too.  

    Pretty inspiring stuff, Jim.  

  • clifwlkr
    clifwlkr Registered Users Posts: 6 ✭✭
    The code I have up at the provided link will decode the packet for you into real values, as it is not that straightforward to do, but it is all written in python.  Weewx, by default, stores the records in an sql database.  You could also have weewx post those values to a large number of different sources and let the overall program manage that process.  I am familiar with IFTT and would suggest that you just post those values to their system through an url, much like weewx would post data to weather underground, or other situations.  That way you can also use the weather data to determine if you should turn on the airconditioner, or the heater, to use up that extra free energy.

    There is definitely a lot of automation you can do with this information.

    Jim
  • KMac
    KMac Registered Users Posts: 9 ✭✭
    This just really opens a lot of doors.  Thanks so much for doing it!