Go Down

Topic: Help editing sketch. Will pay (Read 817 times) previous topic - next topic

Almurphy556

Hi all,

I'm using a ESP8266 connected via a RJ12 to my soladin 600 (grid tie inverter)

I'm using a sketch and library from: https://github.com/vChrisR/esp8266-pv-logger

It reads the data from the soladin inverter and posts it to thingspeak.

The library that is used for communicating with the soladin inverter is called soladin.h and is capable of reading many variables such as device temperature, grid voltage, total power, etc but the only value I'm interested in is 'gridpower' as this shows the output of the solar panels.

Rather than having the data sent to thingspeak I'd like it sent to my local MQTT broker (mosquitto) running on a Raspberry Pi so I can incorporate the data into my home assistant setup.

Gridpower is the only value I wish to publish to MQTT

I know the ESP8266 supports MQTT with the library: PubSubClient.h

If you're still reading I'm sure you've guessed I have no idea how to write a sketch beyond the basics. I've been trying to research how to do this myself but it's beyond my capabilities. I'm willing to pay someone for their time.

Summary:
Convert sketch that posts data to thingspeak so that it publishes to MQTT instead.

Regards,

Andrew

Almurphy556

Just a quick update if anyone is interested.

I've still not been able to compose a sketch with uses MQTT but I have been able a accomplish my end goal with the following:

Using the thingspeak last entry API:

http://api.thingspeak.com/channels/72872/feed/last.json

Which returns:

{"created_at":"2016-01-05T11:37:37Z","entry_id":4802,"field4":"26.00"}

Watts being produced is the end numerical value. 26w (It's a cloudy day)

Compose a python script (Soladin.py) to return the value and print only the required data:

Import urllib
htmlfile = urllib.urlopen("http://api.thingspeak.com/channels/72872/feed/last.json")
htmltext = htmlfile.read ()
print htmltext[63:-5]

Returns:

26

Compose a sh script to run at boot, publish to MQTT and repeat every 15 seconds (can't be less than 15 seconds due to thingspeak only updating every 15 seconds):

#!/bin/bash
while true
do
soladin="$(sudo python /home/pi/soladin.py
mosqitto_pub -t energy/soladin -m "$soladin"
sleep 15
done

It's a bit of a bodge job but gets the job done. If anyone can suggest a better way of doing this feel free to make a suggestion.

Regards,

Andrew

Go Up