Author Topic: Monitoring the Tristar TS-xx with a PI.  (Read 25255 times)

0 Members and 1 Guest are viewing this topic.

DamonHD

  • Administrator
  • Super Hero Member Plus
  • *****
  • Posts: 4125
  • Country: gb
    • Earth Notes
Re: Monitoring the Tristar TS-xx with a PI.
« Reply #33 on: May 06, 2014, 01:39:57 AM »
Sorry about the CAPTCHA, I hate them too.  You'll stop being prompted for one soon, and they're less annoying than the deluge of SPAM that the mods had to manually clear up.  And a mod is still personally screening each new account.

Rgds

Damon
Podcast: https://www.earth.org.uk/SECTION_podcast.html

@DamonHD@mastodon.social

brocktice

  • Newbie
  • *
  • Posts: 5
  • Country: us
Re: Monitoring the Tristar TS-xx with a PI.
« Reply #34 on: July 25, 2014, 12:37:19 PM »
I just migrated my monitoring to a fresh server, and a new version (1.2) of pymodbus was involved. It required one change to the script, which has now been added and pushed to the git repo, if anyone needs it.

brocktice

  • Newbie
  • *
  • Posts: 5
  • Country: us
Re: Monitoring the Tristar TS-xx with a PI.
« Reply #35 on: June 13, 2015, 01:37:27 PM »
We just deployed my older TS-45 (non-MPPT version) in the field with a raspberry pi monitoring. I've added a munin module for the serial version since the TS-45 has only serial, no network monitoring.

I'm going to work on unifying the code so you just specify whether you're using serial or TCP, right now there's a lot of duplication, but the different models use different registers.

Thanks again to everyone for this forum and topic -- it's been hugely helpful to us.

Simen

  • Sr. Member
  • ****
  • Posts: 479
  • Country: no
  • Grimstad, Norway
Re: Monitoring the Tristar TS-xx with a PI.
« Reply #36 on: June 13, 2015, 02:55:13 PM »
I'm still using my original code - although, it stops without any explanation sometimes , but since it isn't 'mission critical', i haven't bothered to do something about it. :)

I also had to move my domain to another server without Python support on the web server, so the link in my first post in this thread doesn't work anymore... I still run it on a local server, since it's here at home it's interesting for me anyway... ;)
I will accept the rules that you feel necessary to your freedom. I am free, no matter what rules surround me. If I find them tolerable, I tolerate them; if I find them too obnoxious, I break them. I am free because I know that I alone am morally responsible for everything I do. - (R. A. Heinlein)

Sajor87

  • Newbie
  • *
  • Posts: 1
  • Country: mx
Re: Monitoring the Tristar TS-xx with a PI.
« Reply #37 on: February 20, 2018, 10:18:27 PM »
Hello!

This thread saved my life, so here's what I did. Morningstar Tristar MPPT 60 with a raspberry pi via LAN and twitter client to keep me updated.

from __future__ import division
from pymodbus.client.sync import ModbusTcpClient
import schedule
import time
import tweepy


CONSUMER_KEY = ""
CONSUMER_SECRET = ""
ACCESS_KEY = ""
ACCESS_SECRET = ""


def get_data():
    client = ModbusTcpClient("") #<--- local ip of tristar
    client.connect()
    rr = client.read_holding_registers(0, 60, unit=1)
    client.close()
    return rr.registers


def handle_data():
    data = get_data()
    charge_state = ["START", "NIGHT_CHECK", "DISCONNECT", "NIGHT",
                    "FAULT", "MPPT", "ABSORPTION", "FLOAT", "EQUALIZE", "SLAVE"]

    alarms = ["RTS open", "RTS shorted", "RTS disconnected", "Heatsink temp sensor open",
              "Heatsink temp sensor shorted", "High temperature current limit", "Current limit",
              "Current offset", "Battery sense out of range", "Battery sense disconnected",
              "Uncalibrated", "RTS miswire", "High voltage disconnect", "Undefined",
              "system miswire", "MOSFET open", "P12 voltage off", "High input voltage current limit",
              "ADC input max", "Controller was reset", "Alarm 21", "Alarm 22", "Alarm 23", "Alarm 24"]

    faults = ["overcurrent", "FETs shorted", "software bug", "battery HVD", "array HVD",
              "settings switch changed", "custom settings edit", "RTS shorted", "RTS disconnected",
              "EEPROM retry limit", "Reserved", " Slave Control Timeout",
              "Fault 13", "Fault 14", "Fault 15", "Fault 16"]
    if data:

        volt_scaling = data[0]
        current_scaling = data[2]
        battery_voltage = round(data[38] / volt_scaling, 2)
        charging_current = round(data[39] / current_scaling, 2)
        charging_state = data[50]
        target_voltage = data[51]
        output_power = data[58]
        battery_temp = data[36]
        total_kwh = data[56]
        alarm = data[46]
        fault = data[44]

        text = "Battery {} V, temp {} C, power {} W, state {}. Total kWh {}.".format(
            battery_voltage, battery_temp, output_power, charge_state[charging_state], total_kwh)

        return text


def publish():
    try:
        text = handle_data()
        if text:
            auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
            auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
            api = tweepy.API(auth)
            api.update_status(text)
    except:
        pass


schedule.every(10).minutes.do(publish)


while True:
    schedule.run_pending()
    time.sleep(1)

Twitter: HolboxCalamar10

Hope it is all self-explanatory.

Regards,
Oscar