Logged in users > User Diaries

Monitoring the Tristar TS-xx with a PI.

<< < (8/8)

brocktice:
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:
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... ;)

Sajor87:
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

Navigation

[0] Message Index

[*] Previous page

Go to full version