Page 1 of 1

coding for solar system

Posted: Fri May 06, 2016 9:46 am
by Northland
I have a small project requiring a little help. I know nothing about pi coding but have done a little coding a long time ago so I will assign symbols and make arguments as I go.

I have a solar system including batteries. One of the things running off the inverter is a water heater.

1. The water heater current is regulated by an SCR (like a dimmer) and the SCR current is controlled by a variable resistor (r). 0 ohm = full power. 500k ohm = 10% power. So the pi needs to either provide the resistance (or current?) to the SCR.
The inverter has a comms port (I have the protocol) and can output battery current (bc) battery voltage (bv), load, input power etc.
The pi should decrease resistance until battery current is zero.

{
fetch bc
fetch bv
loop while bv > 51
r = 400
{
if bc > 1 then dec r 100
if r < 0 then r = 0
elseif bc < 0 then inc r 100
if r > 500 then r = 500
else r = 400
}
wait 1 sec
loop
}

2. I will put an electronic thermostat on the water heater. I would like the pi to fetch the weather report at 1pm for the following day and increase temperature (t) if tomorrow is rainy or decrease if today is rainy and tomorrow is sunny. No idea how to get the data

{
if time = 1300hrs then fetch weather report
goto next
}

{
if weather tomorrow = rain and
if weather today = sun
then t = 60
else t = 50
}

this will check if batteries full then increase thermostat:

{
loop while bc < 5 and bv > 56
count
wait 1 sec
}
{
if count > 60 sec then t = 60
else t = 50
}

3. Log bc, bv, load, input power, water temp every 1 sec for 30 days and show charts on a Web page. No idea how to do this

{
fetch load
fetch input power
fetch water temp
wait 1 sec
write data to Web page
loop
}

Thanks in advance

Re: coding for solar system

Posted: Mon May 16, 2016 10:33 pm
by Heater
Northland,

Right there, not understanding anything else, I see:

"write data to Web page"

That tells me you need to learn Javascript and how it runs under node.js so that you can use it to read all the sensors you need, server a web page and push the data to the browser.

Good starting point is here:

https://learn.adafruit.com/node-embedde ... ode-dot-js

Re: coding for solar system

Posted: Tue May 17, 2016 12:15 am
by stderr
Northland wrote:I know nothing about pi coding but have done a little coding a long time ago so I will assign symbols and make arguments as I go.
1. If you post code or anything that needs indentation, put it between the

Code: Select all

 this is what I'm talking about
blocks. This makes it a lot easier to read.

2. Use meaningful names for things, not just two letters or so.

3. If you want to control the burners or elements of your hot water heater, this is safety critical stuff if done directly. You should be able to safely control the heater without the pi being involved before you worry about hooking it up to the pi, I think. Of course you can do the soft pi stuff, get the web thing worked out, get the download the weather data worked out, all that without even going near the heater itself.