pihome-shc / pihome

PiHome - Smart Heating, Ventilation and Air Conditioning (HVAC)
http://www.pihome.eu
Other
55 stars 25 forks source link

Customisation for different setup #1

Closed harvybob closed 6 years ago

harvybob commented 6 years ago

Hi,

I'm very intrested in setting up a similar controller to what you have, but php coding is non existent for me, the work i have done is by learning python.

Can you assist/guide me a little on how to make this work for me? The setup i have at the moment is 1)multiple DS18B20's around the house connected to multiple pi's. Each pi sends back readings to a central mysql database. 2) use bv4627 relay board to switch on and off various zones - i have an ufh manifold of 8 zones, plus first floor and DHW - so at present 10 zones (This will be come 15 in the future)

Everything is wired at present so no need to the wireless side, but want some pointers on where to make adjustments for the different relay controller, and also the data being held on a central mysql (not running on a pi!) I cant see any contact points via the website so forgive me for raising as an issue - feel free to close without comment if you are unable to help me!

pihome-shc commented 6 years ago

Hi, first question, what is the heat sources? is it gas boiler, solid fuel or solar? you are using pi with DS18B20 around the house to report back only temperature? does each pi with DS18B20 have relay connected or your relay module is connected to another pi who control zone?

harvybob commented 6 years ago

Hi, the heat source is gas boiler, I have two pi's and lots of network cables with sensors on the end. Pi 1 has approx 8 sensors, and also runs my current code + interface Pi 2 has approx 3 sensors and runs the control of the relay board over i2c The relay pi has code which invokes a pulse of a relay (short on and off) based on the zone that is needed ( the relay board handles 12v, to then activate as 230v latching relay - The pi only needs to pulse to turn on, and pulse again to turn off of the 12v system, and is isolated from interference from the pi, as it is controlled using i2c rather then directly over gpio.

pihome-shc commented 6 years ago

Hi, main brain in pihome heating is boiler.php i have added support for GPIO Pin connected zone relay and boiler relay. line important to you are 205, 206 for Zone Relay 247, 248 for Boiler Relay ON status 285, 286 for Boiler Relay Off status you can execute any command you like in these lines to control your zone or boiler relay, tried to google how to send on/off command to bv4627 relay but i didn't find any simple answer.

harvybob commented 6 years ago

the bv4627 is a bit special in that way - the commands i have are in python - for on is: bv4627.write(bytearray([relay_no,1,0,1])) for off is: bv4627.write(bytearray([relay_no,0,0,1]))

but you need the i2c library for it to work. Ill have a look at boiler.php and see what i can do,

Any tips on the sensors? do you base boiler.php on the values as they are in a database table?

pihome-shc commented 6 years ago

Then you can place these commands in boiler.php after you install required library. and best to do test run. on temperature sensors side: Each temperature sensors is represented with node_id in nodes table, when you create zone you just select correct node_id (temperature sensor), this way you have zone and temperature sensors for each zone. i hope this make some sense. best to have look at table structure and table view structure. Thank you

pihome-shc commented 6 years ago

@harvybob did you manage to test the code? need any further help? W

harvybob commented 6 years ago

I'm having issues installing and setting up, i've put a question on the LAMP setup page http://www.pihome.eu/2017/10/11/apache-php-mysql-raspberry-pi-lamp/#comment-238

seems setup.php is throwing back an error on the mysql_connect() . error is: `PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /var/www/setup.php:38 Stack trace:

0 {main}

thrown in /var/www/setup.php on line 38 `

Full detail son the post above

pihome-shc commented 6 years ago

@harvybob php7 isnt supported for PiHome, you need to follow Install Apache, PHP and MySQL on a Raspberry Pi (LAMP) let me know if you need more help Admin

pihome-shc commented 6 years ago

@harvybob i have added lines lines in setup.php to check php version before running it. Admin

harvybob commented 6 years ago

Thanks, my version of mysql doesn't do utf16 so need to set up a new dB next!

pihome-shc commented 6 years ago

you can change that to anything as system isnt depended on utf16. let me know if you need more help otherwise i m closing this ticket. pihome - admin

harvybob commented 6 years ago

Is there a specific place that it needs to be changed or is it throughout the installation script?

pihome-shc commented 6 years ago

can you share your python script you are using to control your relay?

harvybob commented 6 years ago

If your able to see my repo's there's home heating. I2c_raw.py does the actual switching, and the switch_relay.py does it from application - so figures out which relay needs to change etc. Line 111 does the actual switch. I'll try an link it when I get to a computer, octodroid doesn't let me copy/paste a link

harvybob commented 6 years ago

https://github.com/harvybob/home_heating/blob/master/i2c_raw.py is the class which activates the relays- there are 8 per board.

to invoke the above, i use:

def switch_relay(sensor): """Will look up relay number for a sensor and switch it""" relay_results=select_sql("SELECT relay,board FROM sensor_master WHERE sensors = '{0}'".format(sensor)) for relay in relay_results: relay_no=int(relay[0]) relay_board=int(relay[1]) bv4627 = i2c_raw.i2c(relay_board, 1) logging.info("switching on relay "+str(relay_no)+" on board "+str(relay_board)) bv4627.write(bytearray([relay_no,1,0,1])) time.sleep(.4) logging.info("switching off relay "+str(relay_no)+" on board "+str(relay_board)) bv4627.write(bytearray([relay_no,0,0,1]))

pihome-shc commented 6 years ago

Closing this issue, no further comments required,