67 Commits
v0.3.1 ... drv

Author SHA1 Message Date
lejubila
2ea6588c32 Implementato controllo meteo su servizio online tramite driver, implementato driver per interfacciarsi con le api di openweathermap e wunderground 2018-07-15 23:18:59 +02:00
lejubila
419695b420 Implementato driver subsistem per il controllo delle condizioni meteo tramite servizio online. Implementato driver 'wunderground' per il controllo meteo tramite il servizio wunderground 2018-06-05 16:31:45 +02:00
lejubila
3239006922 Modificato file README dei driver, variato numero di versione di piGarden 2018-06-01 22:16:26 +02:00
lejubila
24baa97dad Corretto nome di funzione nel driver sonoff_tasmota_http 2018-05-24 22:06:12 +02:00
lejubila
c354f72c0c Eseguito correzioni su driver sonoff_tasmota_http 2018-05-23 17:57:24 +02:00
lejubila
6f80b8ea21 Corretto problema parsing json su driver sonoff_tasmota_http 2018-05-22 12:53:57 +02:00
lejubila
87edbbbe7a Eseguito correzioni su driver sonoff_tasmota_http 2018-05-21 22:21:27 +02:00
lejubila
3eb45fd1e9 Aggiunto prima implementazione del driver sonoff_tesmota_http, aggiunto implementazione parametro EVx_MONOSTABLE per potere definire singolarmente le elettrovamvole monostabili, corretto alcuni commenti 2018-05-20 17:14:58 +02:00
lejubila
7c96a6afd1 Modificato output di notifiche eventi dello script rpinotify.sh, aggiornato CHANGELOG per nuova versione 2018-05-04 21:17:32 +02:00
lejubila
c664bea16a corretto timestamp su eventi ev_not_open_for_rain, ev_not_open_for_rain_online, ev_not_open_for_rain_sensor 2018-05-03 12:02:48 +02:00
lejubila
78fa176848 Implementato eventi events/ev_not_open_for_rain, events/ev_not_open_for_rain_sensor, events/ev_not_open_for_rain_online. Aggiornato script di invio mail notifiche 2018-05-03 11:45:47 +02:00
lejubila
5c00853e39 Aggiunto driver 'remote' per gestire da un'installazione master di piGarden più installazioni remote 2018-03-25 12:32:39 +02:00
lejubila
dd3cab12c2 Aggiornaeto numero di release 2017-12-13 15:47:06 +01:00
lejubila
38ecd92d7a Corretto problema di inizializzazione variabile LOG_OUTPUT_DRV_FILE 2017-12-13 15:43:06 +01:00
lejubila
22ec16cc9d Aggunto eventi cron_add_before, cron_add_after, cron_del_before, cron_del_after, ev_open_in_before, ev_open_in_after, exec_poweroff_before, exec_poweroff_after, exec_reboot_before, exec_reboot_after ed eseguito bugfix vari 2017-11-19 23:24:48 +01:00
lejubila
8d4849db75 Merge branch 'master' into develop 2017-11-01 18:10:41 +01:00
lejubila
35665c74a7 Corretto lettura parametri su script sendmail.sh 2017-11-01 18:09:26 +01:00
lejubila
80bcbbc92a corretto parametri in sendmail.sh 2017-11-01 18:03:52 +01:00
David Bigagli
67f2d6fe7f Merge pull request #9 from polcape/patch-1
Corretto errore variabile in drv_rain_sensor_get
2017-11-01 18:01:37 +01:00
Paolo
83e23d6bad Corretto errore variabile
Non veniva riconosciuto il valore del sensore pioggia in quanto veniva utilizzata una variabile in scrittura (val) che non veniva poi letta.
2017-11-01 17:48:56 +01:00
lejubila
daf8a7baa6 Implementato supporto a zone non soggette a pioggia (con il parametro EVx_NORAIN) 2017-10-28 00:12:06 +02:00
lejubila
4a0d6178d3 Teriminato debug gestione eventi, creato script sendmail.sh per l'invio di una mail allo scatenarsi du un evento 2017-10-27 23:26:12 +02:00
lejubila
3761c6cb94 terminata implementazione gestione eventi 2017-10-26 23:56:06 +02:00
lejubila
e29dc9dfd4 aggiunto directory relative ad identificare gli eventi 2017-10-26 23:10:34 +02:00
lejubila
6ccb8d3c19 aggiunto file contenente le funzioni per la gestioni degli eventi 2017-10-26 22:46:55 +02:00
lejubila
b3dae26372 iniziato implementazione gestione eventi 2017-10-25 23:44:06 +02:00
lejubila
c048337056 Eseguito merge del brench drv nel brench develop 2017-10-12 23:54:18 +02:00
lejubila
ecbef2c94c Variato changelog, corretto commenti in alcuni file, variato nome della directory di lock 2017-10-12 23:46:07 +02:00
lejubila
10aed48887 driver spb16ch: corretto sistema di attivazione schede 2017-09-19 22:24:38 +02:00
lejubila
4b690b4b7f variato gestione funzioni di lock/unlock per incrementare le prestazioni 2017-09-18 18:55:52 +02:00
lejubila
6afdb24d82 driver spb16ch: corretto inizializzazione e pilotaggio schede, aumentato prestazioni di esecuzione script staticizzando in fase di init gli identificativi delle board utilizzate in modo che che non vengano ricalcolati ad ogni esecuzione successiva dello script 2017-09-16 17:48:19 +02:00
lejubila
2f2cfdc720 eseguito ottimizzazione su chiamate json_status da socket server per migliorare tempi di risposta 2017-09-16 02:34:24 +02:00
lejubila
2b5b3e9687 corretto numero totale zone nel file di configurazione 2017-09-14 12:20:37 +02:00
lejubila
ba128967bd implementato spengimento di tutte le board spb16ch e riattivazione della sola scheda su cui è collegato il rele al quale si sta impartendo l'ordine di apertura/chiusura 2017-09-13 23:59:02 +02:00
lejubila
e64f651cab implementato comandi e socket server api per lo spengimento e riavvio del sistema. Corretto problema che lasciava sul sistema file di appoggio per i messaggi da inviare tramite socket server 2017-09-10 12:44:35 +02:00
lejubila
59b27365ed aggiunto api per eseguire la chiusura di tutte le zone e per la disabilitare tutte le schdulazioni 2017-09-10 02:16:01 +02:00
lejubila
fcbfa3cd32 eseguito merge su CHANGELOG.md 2017-09-09 23:26:02 +02:00
lejubila
3e34f05b4e corretto bug che non faceva aggirnare i dati meteo in caso di pioggia 2017-09-09 23:22:00 +02:00
lejubila
75dd4f5c48 ottimizzato loop di inizializzazione sul driver spb16ch 2017-09-09 00:37:11 +02:00
lejubila
4e15c37fe2 driver spb16ch: eseguito mappatura dei 128 relè distribuito sulle 8 possibili schede installabili 2017-09-05 00:24:33 +02:00
lejubila
9fc7c971f1 Corretto problema su gestione cron con cron type simili. Per esempio se veniva inserita una schedulazione per la zona Zona_10 questa veniva riconosciuta anche per la zona con nome Zona_1 2017-09-01 01:06:53 +02:00
lejubila
c370890f0b variato commento con specifiche mappatura rele 2017-08-31 09:54:13 +02:00
lejubila
efbd3c687d driver spb16ch: modificato mappatura rele e script python da lanciare per l'apertura/chiusura dei rele 2017-08-30 23:13:34 +02:00
lejubila
2f7b286424 separato codice di gestione pioggia da script principale, variato numero di versione, rimosso commenti non necessari in testa ai file di inclusione 2017-08-21 08:47:11 +02:00
lejubila
7f6a593833 modificato istruzioni di installazione 2017-08-21 08:34:47 +02:00
lejubila
4322a83977 Terminato gertione driver e implementato prima versione beta del driver spb16ch 2017-08-20 12:21:30 +02:00
lejubila
2056b30be0 Variato emissione log chiamate alle callback dei driver 2017-08-16 16:37:35 +02:00
lejubila
317781e217 Spostato diverse parti dello script in file di inclusione, completato driver di esempio 2017-08-15 12:35:28 +02:00
lejubila
426ccab0d2 continua modifiche per gestione driver 2017-08-03 23:43:06 +02:00
lejubila
867b4e4374 iniziato gestione driver 2017-08-03 00:18:35 +02:00
lejubila
2cdea46a11 Aggiunto schemi elettrici in formato kicad per l'impianto nella versione con elettrovalvole bistabili e monostabili 2017-07-13 22:43:17 +02:00
lejubila
9cb7d6ce9d Variato numero di versione 2017-06-17 15:31:11 +02:00
lejubila
ce062f30ca Rimosso lock/unlock nella funzione init per risolvere problema di inizializzazione 2017-06-17 15:23:09 +02:00
lejubila
164169e375 corretto path di sed nella funzione lock 2017-06-17 12:40:40 +02:00
lejubila
37a6c58b5a Corretto path dei comandi usati per genereare l'id di installazione, venvia generato un identificativo errato 2017-06-16 23:06:07 +02:00
lejubila
a34c1cd856 Modificato changelog per versione 0.4.1 2017-06-14 17:40:31 +02:00
lejubila
02cde84392 Corretto problema sull'invio identificativo installazione per uso statistico 2017-06-14 17:38:47 +02:00
lejubila
f58b2ba7fb Variato changelog per la versione 0.4.0 2017-06-14 01:19:43 +02:00
lejubila
2b13ba0cf0 aggiunto redirect standard error della chiamata per collezionare le statistiche di utilizzo 2017-06-13 01:00:06 +02:00
lejubila
e288244803 aggiunto unlock in caso timeout della funzione lock 2017-06-10 23:51:28 +02:00
lejubila
5a28d129f5 aggiunto sistema di invio identificativo installazione per uso statistico 2017-06-09 01:59:04 +02:00
lejubila
ced5ba83e8 aggiunto tempo di attesa random su funzione lock per impedire sovrapposizioni concorrenti 2017-05-30 23:51:39 +02:00
lejubila
44529c661f aggiunto supporto per l'inserimento di un cron disabiltato di schedulazione apertura/chiusura zona via api socket server 2017-05-28 16:42:13 +02:00
lejubila
357b976765 Aggiunto possibiltà di inserire una schedulazione di apertura/chiusura in modalità disabilitata 2017-05-23 23:34:43 +02:00
lejubila
3aad235dda aggiunto supporto per autenticazione su socket server 2017-05-21 12:42:26 +02:00
lejubila
6447ec5326 Aggiunto gestione lock/unnlock per prevenire chiamate concorrenti su apertura/chiusura delle elettrovalvole 2017-05-19 23:52:36 +02:00
lejubila
e5bfe3e8ca Corretto numero di versione 2017-05-14 10:51:00 +02:00
108 changed files with 7890 additions and 816 deletions

View File

@@ -1,30 +1,92 @@
# 0.5.8 - xx/07/2018
- Added "openweathermap" driver for impement check weather condition from openweatermap api
# 0.5.7 - 01/06/2018
- Added "sonoff_tasmota_http" driver for interfacin with Sonoff module with Tasmota firmware over http protocol
# 0.5.6 - 04/05/2018
- Added events ev_not_open_for_rain, ev_not_open_for_rain_sensor, ev_not_open_for_rain_online
- Added script rpinotify.sh for notificate events to telegram
# 0.5.5 - 25/03/2018
- Added "remote" driver to control remote pigarden
# 0.5.4 - 13/11/2017
- Fix bad initialization LOG_OUTPUT_DRV_FILE variable if not defined in config file
# 0.5.3 - 19/11/2017
- Fix send parameter on event init_before and init_after
- Added WEATHER argument in check_rain_sensor_after and check_rain_sensor_change event
- Added events cron_add_before, cron_add_after, cron_del_before, cron_del_after, ev_open_in_before, ev_open_in_after, exec_poweroff_before, exec_poweroff_after, exec_reboot_before, exec_reboot_after
- Added to sendmail.sh argument passed form check_rain_sensor_after and check_rain_sensor_change event
- Added to sendmail.sh new events
- Fix wrong state on event script sendmail.sh
# 0.5.2 - 01/11/2017
- Fix problem inconsistent return value in drv_rain_sensor_get
- Fix get parameter in event script sendmail.sh
# 0.5.1 - 28/10/2017
- Added events managemets
- Added support for zones not subject to rainfall (with parameter EVx_NORAIN)
# 0.5.0 - 12/10/2017
- Implemented driver subsystem for interfacing with other board
- Added driver spb16ch for interfacing with "Smart Power Board 16 channel with RTC"
- Added socket server api for close all zones and disable all scheduling
- Implement command and socket server api to perform system shutdown and reboot
- Fix problem with cron management on similar type cron
- Fix bug: in case of rain the weather data were not updated
- Fix bug: delete the temporary files for managing the socket server messages that were kept on the system
- Change manage of the lock/unlock function for encrase performance (do you need manualy remove the file /var/shm/piGarden.lock or /tmp/piGarden.lock)
- Add kicad electric schemas
## 0.4.4 - 17/06/2017
- Remove lock/unlock from init function for resove bug
## 0.4.3 - 17/06/2017
- Fix path of sed in lock function
## 0.4.2 - 16/06/2017
- Fix another problem on generate installation identifier to sendo for statistic
## 0.4.1 - 14/06/2017
- Fix problem on send identifier installation for statistic
## 0.4.0 - 14/06/2017
- Add credentials support to socket server (define TCPSERVER_USER and TCPSERVER_PWD in your config file)
- Add management lock/unlock for prevent concurrente call to open/close solenoid
- Added the ability to enter an open / close schedule in disabled mode
- Add send statistic information to remote server
- During the initialization function, information on the last rain is no longer removed
## 0.3.1 - 13/05/2017
Add experimental support for monostable solenoid valve:
- define in your config file the variable EV_MONOSTABLE and assign value 1
- if the solenoid valves close instead of opening and vice versa, reverse the values of the RELE_GPIO_CLOSE and RELE_GPIO_OPEN variables in your configuration file
## 0.3.0 - 07/05/2017
Add command "open_in" for scheduling on the fly the opens/close a solenoid
Add command "del_cron_open_in" for delete scheduling the fly the opens/close a solenoid
Add api in socket server for command open_in and delete_cron_open_in
Fix minor bug on command "open"
Changed the path of some temporary files to prevent sd card faults
- Add command "open_in" for scheduling on the fly the opens/close a solenoid
- Add command "del_cron_open_in" for delete scheduling the fly the opens/close a solenoid
- Add api in socket server for command open_in and delete_cron_open_in
- Fix minor bug on command "open"
- Changed the path of some temporary files to prevent sd card faults
## 0.2.2 - 25/04/2017
Fix bug: if it's reining, the solenoid valves were also closed even if they were pushed open in "force" mode
- Fix bug: if it's reining, the solenoid valves were also closed even if they were pushed open in "force" mode
## 0.2.1 - 22/04/2017
Add installation instructions in README.md file
- Add installation instructions in README.md file
## 0.2 (Easter egg) - 17/04/2017
Implementation of socket server for communicate with piGardenWeb
Implementation of messages (error, warning, success) passed to piGardenWeb
Added many information in json status to be passed to piGardenWeb
Added management cron for scheduling open and closed solenoid, for initialize control unit, for rain control
- Implementation of socket server for communicate with piGardenWeb
- Implementation of messages (error, warning, success) passed to piGardenWeb
- Added many information in json status to be passed to piGardenWeb
- Added management cron for scheduling open and closed solenoid, for initialize control unit, for rain control
## 0.1.1 - 24/12/2015 - BugFix
Fix the problem for 'av_status' parameter
- Fix the problem for 'av_status' parameter
## 0.1 - 18/12/2015 - First release
First release to piGarden
- First release to piGarden

View File

@@ -4,13 +4,13 @@ Bash script to manage an irrigation system built with a Raspberry Pi
## Official documentation
Documentation of piGarden and build system irrigation with Raspberry Pi can be found on the [www.lejubila.net/tag/pigarden/](http://www.lejubila.net/tag/pigarden/)
Documentation of piGarden and build system irrigation with Raspberry Pi can be found on the [www.lejubila.net/pigarden/](http://www.lejubila.net/pigarden/)
## License
This script is open-sourced software under GNU GENERAL PUBLIC LICENSE Version 2
## Installation
## Installation to Raspbian Jessie
1) Installs the necessary packages on your terminal:
@@ -26,7 +26,7 @@ sudo apt-get install flex -y
sudo apt-get install bison -y
sudo apt-get install gcc -y
sudo apt-get install make -y
sudo apt-get install autotools -y
sudo apt-get install libtool autoconf automake gettext autotools-dev -y
sudo apt-get install dh-autoreconf -y
wget https://github.com/stedolan/jq/releases/download/jq-1.5/jq-1.5.tar.gz
tar xfvz jq-1.5.tar.gz
@@ -66,5 +66,3 @@ sudo cp piGarden/conf/piGarden.conf.example /etc/piGarden.conf
Customize the configuration file.
For more information see
[www.lejubila.net/2015/12/impianto-di-irrigazione-con-raspberry-pi-pigarden-lo-script-di-gestione-quinta-parte/](https://www.lejubila.net/2015/12/impianto-di-irrigazione-con-raspberry-pi-pigarden-lo-script-di-gestione-quinta-parte/)
and
[www.lejubila.net/2017/04/pigarden-0-2-easter-egg/](https://www.lejubila.net/2017/04/pigarden-0-2-easter-egg/)

View File

@@ -2,9 +2,15 @@
LOG_FILE="/home/pi/piGarden/log/piGarden.log"
LOG_FILE_MAX_SIZE=1048576 # 1MB
# Log file for driver output
LOG_OUTPUT_DRV_FILE="/tmp/piGarden.drv.log"
# Status directory
STATUS_DIR="/home/pi/piGarden/state"
# Event directory
EVENT_DIR="/home/pi/piGarden/events"
# Posizione gpio
GPIO="/usr/local/bin/gpio"
@@ -44,13 +50,16 @@ SED="/bin/sed"
# Percorso readlink
READLINK="/bin/readlink"
# Percorso stat
STAT="/usr/bin/stat"
# Se impostato con il valore 1, indica che il sistema gestisce elettrovalvole monostabili,
# se impostato a 0 il sistema gestirà elettrovalvole bisstabili
EV_MONOSTABLE=0
# Id gpio usati per simulare il doppio deviatore con cui eseguire l'alimentazione alle elettrovalvole
SUPPLY_GPIO_1=2
SUPPLY_GPIO_2=3
SUPPLY_GPIO_1=2 # Physical 3 - wPi 8
SUPPLY_GPIO_2=3 # Physical 5 - wPi 9
# Stato dei due gpio per impartire l'alimentazione positiva alle elettrovalvole (aperta)
SUPPLY_GPIO_POS=0
@@ -65,7 +74,7 @@ RELE_GPIO_CLOSE=0
RELE_GPIO_OPEN=1
# Id del gpio usato per collegare il sensore di rilevamento pioggia
RAIN_GPIO=25
RAIN_GPIO=25 # Physical 22 - wPi 6
# Valore in ingresso sul gpio definito in RAIN_GPIO che indica lo stato di pioggia
RAIN_GPIO_STATE=0
@@ -79,26 +88,38 @@ EV_TOTAL=6
# Definizione delle elettrovalvole
EV1_ALIAS="1" #
EV1_GPIO=17
EV1_GPIO=17 # Physical 11 - wPi 0
#EV1_NORAIN=1 # Non interrompe l'irrigazione di questa zona in caso di pioggia
#EV1_MONOSTAVLE=1 # L'elettrovalvola è monostabile
EV2_ALIAS="2" #
EV2_GPIO=27
EV2_GPIO=27 # Physical 13 - wPi 2
EV3_ALIAS="3" #
EV3_GPIO=22
EV3_GPIO=22 # Physical 15 - wPi 3
EV4_ALIAS="4" #
EV4_GPIO=18
EV4_GPIO=18 # Physical 12 - wPi 1
EV5_ALIAS="5" #
EV5_GPIO=23
EV5_GPIO=23 # Physical 16 - wPi 4
EV6_ALIAS="6" #
EV6_GPIO=24
EV6_GPIO=24 # Physical 18 - wPi 5
# Definisce l'api key e il luogo per recuperare lo stato meteo online
# Definisci il servizio online da utilizzare per il controllo delle condizioni meteo, puoi scegliere openweathermap oppure wunderground
WEATHER_SERVICE="openweathermap"
# Parametri di openweathermap, definisce l'api key e il luogo per recuperare lo stato meteo online
OPENWEATHERMAP_KEY=""
OPENWEATHERMAP_LOCATION="q=Pieve%20a%20Nievole,it" # https://openweathermap.org/current
OPENWEATHERMAP_TZ="Europe/Rome" # Time zone
# Parametri di wunderground, definisce l'api key e il luogo per recuperare lo stato meteo online
WUNDERGROUND_KEY=""
WUNDERGROUND_LOCATION="IY/Monsummano" # http://www.wunderground.com/weather/api/d/docs?d=resources/country-to-iso-matching&MR=1
WUNDERGROUND_LOCATION="IT/Pieve%20a%20Nievole" # http://www.wunderground.com/weather/api/d/docs?d=resources/country-to-iso-matching&MR=1
# Blocca l'irrigazione se l'ultima pioggia rilevata online è avvenuta nell'ultima quantità di tempo inserita.
# Il tempo è espresso in secondi. Quindi inserendo 86400, se nelle ultime 24 ore ha piovuto viene bloccata l'irrigazione. Inserendo il valore zero non viene eseguito nessun controllo.
@@ -111,3 +132,10 @@ NOT_IRRIGATE_IF_RAIN_SENSOR=86400
TCPSERVER_IP="127.0.0.1"
TCPSERVER_PORT="8084"
# Utente e password che i clients devono utilizzare per stabilire una connessione tramite socket server
TCPSERVER_USER=""
TCPSERVER_PWD=""
# Con impostato il valore 1 non invia l'identificativi per statistiche di utilizzo
NO_SEND_IDENTIFIER=0

View File

@@ -0,0 +1,150 @@
# Log file
LOG_FILE="/home/pi/piGarden/log/piGarden.log"
LOG_FILE_MAX_SIZE=1048576 # 1MB
# Log file for driver output
#LOG_OUTPUT_DRV_FILE="/tmp/piGarden.drv.log"
# Status directory
STATUS_DIR="/home/pi/piGarden/state"
# Event directory
EVENT_DIR="/home/pi/piGarden/events"
# Posizione gpio
GPIO="/usr/local/bin/gpio"
# Posizione js
JQ="/usr/local/bin/jq"
# Percorso curl
CURL="/usr/bin/curl"
# Percorso wc
WC="/usr/bin/wc"
# Percorso gzip
GZIP="/bin/gzip"
# Percorso mv
MV="/bin/mv"
# Percorso di tr
TR="/usr/bin/tr"
# Percorso di cut
CUT="/usr/bin/cut"
# Percorso tcpserver
TCPSERVER="/usr/bin/tcpserver"
# Percorso cron
CRONTAB="/usr/bin/crontab"
# Percorso grep
GREP="/bin/grep"
# Percorsp sed
SED="/bin/sed"
# Percorso readlink
READLINK="/bin/readlink"
# Percorso stat
STAT="/usr/bin/stat"
# Se impostato con il valore 1, indica che il sistema gestisce elettrovalvole monostabili,
# se impostato a 0 il sistema gestirà elettrovalvole bisstabili
EV_MONOSTABLE=0
# Id gpio usati per simulare il doppio deviatore con cui eseguire l'alimentazione alle elettrovalvole
SUPPLY_GPIO_1=2
SUPPLY_GPIO_2=3
# Stato dei due gpio per impartire l'alimentazione positiva alle elettrovalvole (aperta)
SUPPLY_GPIO_POS=0
# Stato dei due gpio per impartire l'alimentazione negativa alle elettrovalvole (chiusa)
SUPPLY_GPIO_NEG=1
# Stato di ingresso da assegnare al gpio per chiudere il rele
RELE_GPIO_CLOSE=0
# Stato di ingresso da assegnare al gpio per aprire il rele
RELE_GPIO_OPEN=1
# Id del gpio usato per collegare il sensore di rilevamento pioggia
RAIN_GPIO=25 # Physical 22 - wPi 6
# Valore in ingresso sul gpio definito in RAIN_GPIO che indica lo stato di pioggia
RAIN_GPIO_STATE=0
# Numero totale di elettrovalvole
EV_TOTAL=4
# Definizione delle elettrovalvole
EV1_ALIAS="Giardino_Posteriore_DX" #
EV1_GPIO="drv:remote:PIREMOTE1:Giardino_Posteriore_DX"
#EV1_NORAIN=1 # Non interrompe l'irrigazione di questa zona in caso di pioggia
EV2_ALIAS="Giardino_Posteriore_CN" #
EV2_GPIO="drv:remote:PIREMOTE2:Giardino_Posteriore_CN"
EV3_ALIAS="Giardino_Posteriore_SX" #
EV3_GPIO="drv:remote:PIREMOTE2:Giardino_Posteriore_SX"
EV4_ALIAS="Giardino_Posteriore_GPIO" #
EV4_GPIO="18"
# Definisci il servizio online da utilizzare per il controllo delle condizioni meteo, puoi scegliere openweathermap oppure wunderground
WEATHER_SERVICE="openweathermap"
# Parametri di openweathermap, definisce l'api key e il luogo per recuperare lo stato meteo online
OPENWEATHERMAP_KEY=""
OPENWEATHERMAP_LOCATION="q=Pieve%20a%20Nievole,it" # https://openweathermap.org/current
OPENWEATHERMAP_TZ="Europe/Rome" # Time zone
# Parametri di wunderground, definisce l'api key e il luogo per recuperare lo stato meteo online
WUNDERGROUND_KEY=""
WUNDERGROUND_LOCATION="IT/Pieve%20a%20Nievole" # http://www.wunderground.com/weather/api/d/docs?d=resources/country-to-iso-matching&MR=1
# Blocca l'irrigazione se l'ultima pioggia rilevata online è avvenuta nell'ultima quantità di tempo inserita.
# Il tempo è espresso in secondi. Quindi inserendo 86400, se nelle ultime 24 ore ha piovuto viene bloccata l'irrigazione. Inserendo il valore zero non viene eseguito nessun controllo.
NOT_IRRIGATE_IF_RAIN_ONLINE=86400
# Il parametro è simile a quello precedente, il controllo però anziché essere fatto attingendo a wunderground, viene eseguito direttamente sul sensore se installato. Inserendo il valore zero non viene eseguito nessun controllo.
NOT_IRRIGATE_IF_RAIN_SENSOR=86400
# Indirizzo ip e porta di ascolto del socket server
TCPSERVER_IP="127.0.0.1"
TCPSERVER_PORT="8084"
# Utente e password che i clients devono utilizzare per stabilire una connessione tramite socket server
TCPSERVER_USER=""
TCPSERVER_PWD=""
# Con impostato il valore 1 non invia l'identificativi per statistiche di utilizzo
NO_SEND_IDENTIFIER=0
#
# Configurazione piGarden remoti
#
PIREMOTE1_IP="192.168.1.51"
PIREMOTE1_PORT="8084"
PIREMOTE1_USER=""
PIREMOTE1_PWD=""
PIREMOTE2_IP="192.168.1.52"
PIREMOTE2_PORT="8084"
PIREMOTE2_USER=""
PIREMOTE2_PWD=""

View File

@@ -0,0 +1,150 @@
# Log file
LOG_FILE="/home/pi/piGarden/log/piGarden.log"
LOG_FILE_MAX_SIZE=1048576 # 1MB
# Log file for driver output
#LOG_OUTPUT_DRV_FILE="/tmp/piGarden.drv.log"
# Status directory
STATUS_DIR="/home/pi/piGarden/state"
# Event directory
EVENT_DIR="/home/pi/piGarden/events"
# Posizione gpio
GPIO="/usr/local/bin/gpio"
# Posizione js
JQ="/usr/local/bin/jq"
# Percorso curl
CURL="/usr/bin/curl"
# Percorso wc
WC="/usr/bin/wc"
# Percorso gzip
GZIP="/bin/gzip"
# Percorso mv
MV="/bin/mv"
# Percorso di tr
TR="/usr/bin/tr"
# Percorso di cut
CUT="/usr/bin/cut"
# Percorso tcpserver
TCPSERVER="/usr/bin/tcpserver"
# Percorso cron
CRONTAB="/usr/bin/crontab"
# Percorso grep
GREP="/bin/grep"
# Percorsp sed
SED="/bin/sed"
# Percorso readlink
READLINK="/bin/readlink"
# Percorso stat
STAT="/usr/bin/stat"
# Se impostato con il valore 1, indica che il sistema gestisce elettrovalvole monostabili,
# se impostato a 0 il sistema gestirà elettrovalvole bisstabili
EV_MONOSTABLE=0
# Id gpio usati per simulare il doppio deviatore con cui eseguire l'alimentazione alle elettrovalvole
SUPPLY_GPIO_1=2
SUPPLY_GPIO_2=3
# Stato dei due gpio per impartire l'alimentazione positiva alle elettrovalvole (aperta)
SUPPLY_GPIO_POS=0
# Stato dei due gpio per impartire l'alimentazione negativa alle elettrovalvole (chiusa)
SUPPLY_GPIO_NEG=1
# Stato di ingresso da assegnare al gpio per chiudere il rele
RELE_GPIO_CLOSE=0
# Stato di ingresso da assegnare al gpio per aprire il rele
RELE_GPIO_OPEN=1
# Id del gpio usato per collegare il sensore di rilevamento pioggia
RAIN_GPIO=25 # Physical 22 - wPi 6
# Valore in ingresso sul gpio definito in RAIN_GPIO che indica lo stato di pioggia
RAIN_GPIO_STATE=0
# Numero totale di elettrovalvole
EV_TOTAL=4
# Definizione delle elettrovalvole
EV1_ALIAS="Giardino_Posteriore_DX"
EV1_GPIO="drv:sonoff_tasmota_http:SONOFF1:Power1"
EV1_MONOSTABLE=1
EV2_ALIAS="Giardino_Posteriore_CN"
EV2_GPIO="drv:sonoff_tasmota_http:SONOFF1:Power2"
EV2_MONOSTABLE=1
EV3_ALIAS="Giardino_Posteriore_SX"
EV3_GPIO="drv:sonoff_tasmota_http:SONOFF1:Power3"
EV3_MONOSTABLE=1
EV4_ALIAS="Giardino_Anteriore"
EV4_GPIO="drv:sonoff_tasmota_http:SONOFF2:Power1"
# Definisci il servizio online da utilizzare per il controllo delle condizioni meteo, puoi scegliere openweathermap oppure wunderground
WEATHER_SERVICE="openweathermap"
# Parametri di openweathermap, definisce l'api key e il luogo per recuperare lo stato meteo online
OPENWEATHERMAP_KEY=""
OPENWEATHERMAP_LOCATION="q=Pieve%20a%20Nievole,it" # https://openweathermap.org/current
OPENWEATHERMAP_TZ="Europe/Rome" # Time zone
# Parametri di wunderground, definisce l'api key e il luogo per recuperare lo stato meteo online
WUNDERGROUND_KEY=""
WUNDERGROUND_LOCATION="IT/Pieve%20a%20Nievole" # http://www.wunderground.com/weather/api/d/docs?d=resources/country-to-iso-matching&MR=1
# Blocca l'irrigazione se l'ultima pioggia rilevata online è avvenuta nell'ultima quantità di tempo inserita.
# Il tempo è espresso in secondi. Quindi inserendo 86400, se nelle ultime 24 ore ha piovuto viene bloccata l'irrigazione. Inserendo il valore zero non viene eseguito nessun controllo.
NOT_IRRIGATE_IF_RAIN_ONLINE=86400
# Il parametro è simile a quello precedente, il controllo però anziché essere fatto attingendo a wunderground, viene eseguito direttamente sul sensore se installato. Inserendo il valore zero non viene eseguito nessun controllo.
NOT_IRRIGATE_IF_RAIN_SENSOR=86400
# Indirizzo ip e porta di ascolto del socket server
TCPSERVER_IP="127.0.0.1"
TCPSERVER_PORT="8084"
# Utente e password che i clients devono utilizzare per stabilire una connessione tramite socket server
TCPSERVER_USER=""
TCPSERVER_PWD=""
# Con impostato il valore 1 non invia l'identificativi per statistiche di utilizzo
NO_SEND_IDENTIFIER=0
#
# Configurazione moduli sonoff
#
SONOFF1_IP="192.168.1.1"
SONOFF1_USER="user"
SONOFF1_PWD="pwd"
SONOFF2_IP="192.168.1.21"
SONOFF2_USER=""
SONOFF2_PWD=""

View File

@@ -0,0 +1,523 @@
# Log file
LOG_FILE="/home/pi/piGarden/log/piGarden.log"
LOG_FILE_MAX_SIZE=1048576 # 1MB
# Log file for driver output
#LOG_OUTPUT_DRV_FILE="/tmp/piGarden.drv.log"
# Status directory
STATUS_DIR="/home/pi/piGarden/state"
# Event directory
EVENT_DIR="/home/pi/piGarden/events"
# Posizione gpio
GPIO="/usr/local/bin/gpio"
# Posizione js
JQ="/usr/local/bin/jq"
# Percorso curl
CURL="/usr/bin/curl"
# Percorso wc
WC="/usr/bin/wc"
# Percorso gzip
GZIP="/bin/gzip"
# Percorso mv
MV="/bin/mv"
# Percorso di tr
TR="/usr/bin/tr"
# Percorso di cut
CUT="/usr/bin/cut"
# Percorso tcpserver
TCPSERVER="/usr/bin/tcpserver"
# Percorso cron
CRONTAB="/usr/bin/crontab"
# Percorso grep
GREP="/bin/grep"
# Percorsp sed
SED="/bin/sed"
# Percorso readlink
READLINK="/bin/readlink"
# Percorso stat
STAT="/usr/bin/stat"
# Se impostato con il valore 1, indica che il sistema gestisce elettrovalvole monostabili,
# se impostato a 0 il sistema gestirà elettrovalvole bisstabili
EV_MONOSTABLE=1
# Id gpio usati per simulare il doppio deviatore con cui eseguire l'alimentazione alle elettrovalvole
SUPPLY_GPIO_1="drv:spb16ch:15"
SUPPLY_GPIO_2="drv:spb16ch:16"
# Stato dei due gpio per impartire l'alimentazione positiva alle elettrovalvole (aperta)
SUPPLY_GPIO_POS=0
# Stato dei due gpio per impartire l'alimentazione negativa alle elettrovalvole (chiusa)
SUPPLY_GPIO_NEG=1
# Stato di ingresso da assegnare al gpio per chiudere il rele
RELE_GPIO_CLOSE=0
# Stato di ingresso da assegnare al gpio per aprire il rele
RELE_GPIO_OPEN=1
# Id del gpio usato per collegare il sensore di rilevamento pioggia
RAIN_GPIO=
# Valore in ingresso sul gpio definito in RAIN_GPIO che indica lo stato di pioggia
RAIN_GPIO_STATE=0
# Numero totale di elettrovalvole
EV_TOTAL=128
# Definizione delle elettrovalvole
EV1_ALIAS="Zona_1" #
EV1_GPIO="drv:spb16ch:1"
#EV1_NORAIN=1 # Non interrompe l'irrigazione di questa zona in caso di pioggia
EV2_ALIAS="Zona_2" #
EV2_GPIO="drv:spb16ch:2"
EV3_ALIAS="Zona_3" #
EV3_GPIO="drv:spb16ch:3"
EV4_ALIAS="Zona_4" #
EV4_GPIO="drv:spb16ch:4"
EV5_ALIAS="Zona_5" #
EV5_GPIO="drv:spb16ch:5"
EV6_ALIAS="Zona_6" #
EV6_GPIO="drv:spb16ch:6"
EV7_ALIAS="Zona_7" #
EV7_GPIO="drv:spb16ch:7"
EV8_ALIAS="Zona_8" #
EV8_GPIO="drv:spb16ch:8"
EV9_ALIAS="Zona_9" #
EV9_GPIO="drv:spb16ch:9"
EV10_ALIAS="Zona_10" #
EV10_GPIO="drv:spb16ch:10"
EV11_ALIAS="Zona_11" #
EV11_GPIO="drv:spb16ch:11"
EV12_ALIAS="Zona_12" #
EV12_GPIO="drv:spb16ch:12"
EV13_ALIAS="Zona_13" #
EV13_GPIO="drv:spb16ch:13"
EV14_ALIAS="Zona_14" #
EV14_GPIO="drv:spb16ch:14"
EV15_ALIAS="Zona_15" #
EV15_GPIO="drv:spb16ch:15"
EV16_ALIAS="Zona_16" #
EV16_GPIO="drv:spb16ch:16"
EV17_ALIAS="Zona_17" #
EV17_GPIO="drv:spb16ch:17"
EV18_ALIAS="Zona_18" #
EV18_GPIO="drv:spb16ch:18"
EV19_ALIAS="Zona_19" #
EV19_GPIO="drv:spb16ch:19"
EV20_ALIAS="Zona_20" #
EV20_GPIO="drv:spb16ch:20"
EV21_ALIAS="Zona_21" #
EV21_GPIO="drv:spb16ch:21"
EV22_ALIAS="Zona_22" #
EV22_GPIO="drv:spb16ch:22"
EV23_ALIAS="Zona_23" #
EV23_GPIO="drv:spb16ch:23"
EV24_ALIAS="Zona_24" #
EV24_GPIO="drv:spb16ch:24"
EV25_ALIAS="Zona_25" #
EV25_GPIO="drv:spb16ch:25"
EV26_ALIAS="Zona_26" #
EV26_GPIO="drv:spb16ch:26"
EV27_ALIAS="Zona_27" #
EV27_GPIO="drv:spb16ch:27"
EV28_ALIAS="Zona_28" #
EV28_GPIO="drv:spb16ch:28"
EV29_ALIAS="Zona_29" #
EV29_GPIO="drv:spb16ch:29"
EV30_ALIAS="Zona_30" #
EV30_GPIO="drv:spb16ch:30"
EV31_ALIAS="Zona_31" #
EV31_GPIO="drv:spb16ch:31"
EV32_ALIAS="Zona_32" #
EV32_GPIO="drv:spb16ch:32"
EV33_ALIAS="Zona_33" #
EV33_GPIO="drv:spb16ch:33"
EV34_ALIAS="Zona_34" #
EV34_GPIO="drv:spb16ch:34"
EV35_ALIAS="Zona_35" #
EV35_GPIO="drv:spb16ch:35"
EV36_ALIAS="Zona_36" #
EV36_GPIO="drv:spb16ch:36"
EV37_ALIAS="Zona_37" #
EV37_GPIO="drv:spb16ch:37"
EV38_ALIAS="Zona_38" #
EV38_GPIO="drv:spb16ch:38"
EV39_ALIAS="Zona_39" #
EV39_GPIO="drv:spb16ch:39"
EV40_ALIAS="Zona_40" #
EV40_GPIO="drv:spb16ch:40"
EV41_ALIAS="Zona_41" #
EV41_GPIO="drv:spb16ch:41"
EV42_ALIAS="Zona_42" #
EV42_GPIO="drv:spb16ch:42"
EV43_ALIAS="Zona_43" #
EV43_GPIO="drv:spb16ch:43"
EV44_ALIAS="Zona_44" #
EV44_GPIO="drv:spb16ch:44"
EV45_ALIAS="Zona_45" #
EV45_GPIO="drv:spb16ch:45"
EV46_ALIAS="Zona_46" #
EV46_GPIO="drv:spb16ch:46"
EV47_ALIAS="Zona_47" #
EV47_GPIO="drv:spb16ch:47"
EV48_ALIAS="Zona_48" #
EV48_GPIO="drv:spb16ch:48"
EV49_ALIAS="Zona_49" #
EV49_GPIO="drv:spb16ch:49"
EV50_ALIAS="Zona_50" #
EV50_GPIO="drv:spb16ch:50"
EV51_ALIAS="Zona_51" #
EV51_GPIO="drv:spb16ch:51"
EV52_ALIAS="Zona_52" #
EV52_GPIO="drv:spb16ch:52"
EV53_ALIAS="Zona_53" #
EV53_GPIO="drv:spb16ch:53"
EV54_ALIAS="Zona_54" #
EV54_GPIO="drv:spb16ch:54"
EV55_ALIAS="Zona_55" #
EV55_GPIO="drv:spb16ch:55"
EV56_ALIAS="Zona_56" #
EV56_GPIO="drv:spb16ch:56"
EV57_ALIAS="Zona_57" #
EV57_GPIO="drv:spb16ch:57"
EV58_ALIAS="Zona_58" #
EV58_GPIO="drv:spb16ch:58"
EV59_ALIAS="Zona_59" #
EV59_GPIO="drv:spb16ch:59"
EV60_ALIAS="Zona_60" #
EV60_GPIO="drv:spb16ch:60"
EV61_ALIAS="Zona_61" #
EV61_GPIO="drv:spb16ch:61"
EV62_ALIAS="Zona_62" #
EV62_GPIO="drv:spb16ch:62"
EV63_ALIAS="Zona_63" #
EV63_GPIO="drv:spb16ch:63"
EV64_ALIAS="Zona_64" #
EV64_GPIO="drv:spb16ch:64"
EV65_ALIAS="Zona_65" #
EV65_GPIO="drv:spb16ch:65"
EV66_ALIAS="Zona_66" #
EV66_GPIO="drv:spb16ch:66"
EV67_ALIAS="Zona_67" #
EV67_GPIO="drv:spb16ch:67"
EV68_ALIAS="Zona_68" #
EV68_GPIO="drv:spb16ch:68"
EV69_ALIAS="Zona_69" #
EV69_GPIO="drv:spb16ch:69"
EV70_ALIAS="Zona_70" #
EV70_GPIO="drv:spb16ch:70"
EV71_ALIAS="Zona_71" #
EV71_GPIO="drv:spb16ch:71"
EV72_ALIAS="Zona_72" #
EV72_GPIO="drv:spb16ch:72"
EV73_ALIAS="Zona_73" #
EV73_GPIO="drv:spb16ch:73"
EV74_ALIAS="Zona_74" #
EV74_GPIO="drv:spb16ch:74"
EV75_ALIAS="Zona_75" #
EV75_GPIO="drv:spb16ch:75"
EV76_ALIAS="Zona_76" #
EV76_GPIO="drv:spb16ch:76"
EV77_ALIAS="Zona_77" #
EV77_GPIO="drv:spb16ch:77"
EV78_ALIAS="Zona_78" #
EV78_GPIO="drv:spb16ch:78"
EV79_ALIAS="Zona_79" #
EV79_GPIO="drv:spb16ch:79"
EV80_ALIAS="Zona_80" #
EV80_GPIO="drv:spb16ch:80"
EV81_ALIAS="Zona_81" #
EV81_GPIO="drv:spb16ch:81"
EV82_ALIAS="Zona_82" #
EV82_GPIO="drv:spb16ch:82"
EV83_ALIAS="Zona_83" #
EV83_GPIO="drv:spb16ch:83"
EV84_ALIAS="Zona_84" #
EV84_GPIO="drv:spb16ch:84"
EV85_ALIAS="Zona_85" #
EV85_GPIO="drv:spb16ch:85"
EV86_ALIAS="Zona_86" #
EV86_GPIO="drv:spb16ch:86"
EV87_ALIAS="Zona_87" #
EV87_GPIO="drv:spb16ch:87"
EV88_ALIAS="Zona_88" #
EV88_GPIO="drv:spb16ch:88"
EV89_ALIAS="Zona_89" #
EV89_GPIO="drv:spb16ch:89"
EV90_ALIAS="Zona_90" #
EV90_GPIO="drv:spb16ch:90"
EV91_ALIAS="Zona_91" #
EV91_GPIO="drv:spb16ch:91"
EV92_ALIAS="Zona_92" #
EV92_GPIO="drv:spb16ch:92"
EV93_ALIAS="Zona_93" #
EV93_GPIO="drv:spb16ch:93"
EV94_ALIAS="Zona_94" #
EV94_GPIO="drv:spb16ch:94"
EV95_ALIAS="Zona_95" #
EV95_GPIO="drv:spb16ch:95"
EV96_ALIAS="Zona_96" #
EV96_GPIO="drv:spb16ch:96"
EV97_ALIAS="Zona_97" #
EV97_GPIO="drv:spb16ch:97"
EV98_ALIAS="Zona_98" #
EV98_GPIO="drv:spb16ch:98"
EV99_ALIAS="Zona_99" #
EV99_GPIO="drv:spb16ch:99"
EV100_ALIAS="Zona_100" #
EV100_GPIO="drv:spb16ch:100"
EV101_ALIAS="Zona_101" #
EV101_GPIO="drv:spb16ch:101"
EV102_ALIAS="Zona_102" #
EV102_GPIO="drv:spb16ch:102"
EV103_ALIAS="Zona_103" #
EV103_GPIO="drv:spb16ch:103"
EV104_ALIAS="Zona_104" #
EV104_GPIO="drv:spb16ch:104"
EV105_ALIAS="Zona_105" #
EV105_GPIO="drv:spb16ch:105"
EV106_ALIAS="Zona_106" #
EV106_GPIO="drv:spb16ch:106"
EV107_ALIAS="Zona_107" #
EV107_GPIO="drv:spb16ch:107"
EV108_ALIAS="Zona_108" #
EV108_GPIO="drv:spb16ch:108"
EV109_ALIAS="Zona_109" #
EV109_GPIO="drv:spb16ch:109"
EV110_ALIAS="Zona_110" #
EV110_GPIO="drv:spb16ch:110"
EV111_ALIAS="Zona_111" #
EV111_GPIO="drv:spb16ch:111"
EV112_ALIAS="Zona_112" #
EV112_GPIO="drv:spb16ch:112"
EV113_ALIAS="Zona_113" #
EV113_GPIO="drv:spb16ch:113"
EV114_ALIAS="Zona_114" #
EV114_GPIO="drv:spb16ch:114"
EV115_ALIAS="Zona_115" #
EV115_GPIO="drv:spb16ch:115"
EV116_ALIAS="Zona_116" #
EV116_GPIO="drv:spb16ch:116"
EV117_ALIAS="Zona_117" #
EV117_GPIO="drv:spb16ch:117"
EV118_ALIAS="Zona_118" #
EV118_GPIO="drv:spb16ch:118"
EV119_ALIAS="Zona_119" #
EV119_GPIO="drv:spb16ch:119"
EV120_ALIAS="Zona_120" #
EV120_GPIO="drv:spb16ch:120"
EV121_ALIAS="Zona_121" #
EV121_GPIO="drv:spb16ch:121"
EV122_ALIAS="Zona_122" #
EV122_GPIO="drv:spb16ch:122"
EV123_ALIAS="Zona_123" #
EV123_GPIO="drv:spb16ch:123"
EV124_ALIAS="Zona_124" #
EV124_GPIO="drv:spb16ch:124"
EV125_ALIAS="Zona_125" #
EV125_GPIO="drv:spb16ch:125"
EV126_ALIAS="Zona_126" #
EV126_GPIO="drv:spb16ch:126"
EV127_ALIAS="Zona_127" #
EV127_GPIO="drv:spb16ch:127"
EV128_ALIAS="Zona_128" #
EV128_GPIO="drv:spb16ch:128"
# Definisci il servizio online da utilizzare per il controllo delle condizioni meteo, puoi scegliere openweathermap oppure wunderground
WEATHER_SERVICE="openweathermap"
# Parametri di openweathermap, definisce l'api key e il luogo per recuperare lo stato meteo online
OPENWEATHERMAP_KEY=""
OPENWEATHERMAP_LOCATION="q=Pieve%20a%20Nievole,it" # https://openweathermap.org/current
OPENWEATHERMAP_TZ="Europe/Rome" # Time zone
# Parametri di wunderground, definisce l'api key e il luogo per recuperare lo stato meteo online
WUNDERGROUND_KEY=""
WUNDERGROUND_LOCATION="IT/Pieve%20a%20Nievole" # http://www.wunderground.com/weather/api/d/docs?d=resources/country-to-iso-matching&MR=1
# Blocca l'irrigazione se l'ultima pioggia rilevata online è avvenuta nell'ultima quantità di tempo inserita.
# Il tempo è espresso in secondi. Quindi inserendo 86400, se nelle ultime 24 ore ha piovuto viene bloccata l'irrigazione. Inserendo il valore zero non viene eseguito nessun controllo.
NOT_IRRIGATE_IF_RAIN_ONLINE=86400
# Il parametro è simile a quello precedente, il controllo però anziché essere fatto attingendo a wunderground, viene eseguito direttamente sul sensore se installato. Inserendo il valore zero non viene eseguito nessun controllo.
NOT_IRRIGATE_IF_RAIN_SENSOR=86400
# Indirizzo ip e porta di ascolto del socket server
TCPSERVER_IP="127.0.0.1"
TCPSERVER_PORT="8084"
# Utente e password che i clients devono utilizzare per stabilire una connessione tramite socket server
TCPSERVER_USER=""
TCPSERVER_PWD=""
# Con impostato il valore 1 non invia l'identificativi per statistiche di utilizzo
NO_SEND_IDENTIFIER=0
#
# Configurazione schede spb16ch
#
# Stato da assegnare ai gpio per abilitare/disabilitare le schede spb16ch
SPB16CH_GPIO_ON=1
SPB16CH_GPIO_OFF=0
# Gpio di per gestire l'abilitazione/disabilitazione delle chede spb16ch
SPB16CH1_GPIO=17 # Physical 11 - wPi 0
SPB16CH2_GPIO=27 # Physical 13 - wPi 2
SPB16CH3_GPIO=22 # Physical 15 - wPi 3
SPB16CH4_GPIO=18 # Physical 12 - wPi 1
SPB16CH5_GPIO=23 # Physical 16 - wPi 4
SPB16CH6_GPIO=24 # Physical 18 - wPi 5
SPB16CH7_GPIO=4 # Physical 7 - wPi 7
SPB16CH8_GPIO=14 # Physical 8 - wPi 15

View File

@@ -0,0 +1,13 @@
# Driver for check wather condition with openweathermap online service
# Example of configuration in piGarden.conf
```bash
WEATHER_SERVICE="openweathermap"
OPENWEATHERMAP_KEY="d4d22ea805788420267971135563b4cc" # Set with your api key of openweathermap
OPENWEATHERMAP_LOCATION="q=Pieve%20a%20Nievole,it" # Set with location identify, see https://openweathermap.org/current
OPENWEATHERMAP_TZ="Europe/Rome" # Set with your time zone
```

View File

@@ -0,0 +1,123 @@
#
# Funzioni comuni utilizzate dal driver
#
#
# Recupera la descrizione della condizione meteo
#
# $1 condizione meteo recuperata dalle api
#
function drv_openweathermap_get_wather {
declare -A w
w["thunderstorm with light rain"]="Thunderstorms and Rain"
w["thunderstorm with rain"]="Thunderstorms and Rain"
w["thunderstorm with heavy rain"]="Thunderstorms and Rain"
w["light thunderstorm"]="Thunderstorm"
w["thunderstorm"]="Thunderstorm"
w["heavy thunderstorm"]="Thunderstorm"
w["ragged thunderstorm"]="Thunderstorm"
w["thunderstorm with light drizzle"]="Thunderstorms and Rain"
w["thunderstorm with drizzle"]="Thunderstorms and Rain"
w["thunderstorm with heavy drizzle"]="Thunderstorms and Rain"
w["light intensity drizzle"]="Drizzle"
w["drizzle"]="Drizzle"
w["heavy intensity drizzle"]="Drizzle"
w["light intensity drizzle rain"]="Drizzle"
w["drizzle rain"]="Drizzle"
w["heavy intensity drizzle rain"]="Drizzle"
w["shower rain and drizzle"]="Drizzle"
w["heavy shower rain and drizzle"]="Drizzle"
w["shower drizzle"]="Drizzle"
w["light rain"]="Rain Mist"
w["moderate rain"]="Rain"
w["heavy intensity rain"]="Rain"
w["very heavy rain"]="Rain"
w["extreme rain"]="Rain"
w["freezing rain"]="Freezing Rain"
w["light intensity shower rain"]="Rain"
w["shower rain"]="Rain"
w["heavy intensity shower rain"]="Rain"
w["ragged shower rain"]="Rain"
w["light snow"]="Snow"
w["snow"]="Snow"
w["heavy snow"]=""
w["sleet"]="Snow Grains"
w["shower sleet"]="Snow Grains"
w["light rain and snow"]="Snow"
w["rain and snow"]="Snow"
w["light shower snow"]="Snow"
w["shower snow"]="Snow"
w["heavy shower snow"]="Snow"
w["mist"]="Mist"
w["smoke"]="Smoke"
w["haze"]="Haze"
w["sand, dust whirls"]="Dust Whirls"
w["fog"]="Fog"
w["sand"]="Sand"
w["dust"]="Widespread Dust"
w["volcanic ash"]="Volcanic Ash"
w["squalls"]="Squalls"
w["tornado"]="Tornado"
w["clear sky"]="Clear"
w["few clouds"]="Partly Cloudy"
w["scattered clouds"]="Scattered Clouds"
w["broken clouds"]="Partly Cloudy"
w["overcast clouds"]="Mostly Cloudy"
local weather=${w[$1]}
if [ -z "$weather" ]; then
weather="$1"
fi
echo $weather
}
#
# Recupera la l'icona rappresentativa delle condizione meteo
#
# $1 nome dell'icona recuperato delle api weather.icon
#
function drv_openweathermap_get_ico {
declare -A w
w["01d"]="http://icons.wxug.com/i/c/k/clear.gif"
w["01n"]="http://icons.wxug.com/i/c/k/nt_clear.gif"
w["02d"]="http://icons.wxug.com/i/c/k/partlycloudy.gif"
w["02n"]="http://icons.wxug.com/i/c/k/nt_partlycloudy.gif"
w["03d"]="http://icons.wxug.com/i/c/k/cloudy.gif"
w["03n"]="http://icons.wxug.com/i/c/k/nt_cloudy.gif"
w["04d"]="http://icons.wxug.com/i/c/k/cloudy.gif"
w["04n"]="http://icons.wxug.com/i/c/k/nt_cloudy.gif"
w["09d"]="http://icons.wxug.com/i/c/k/sleet.gif"
w["09n"]="http://icons.wxug.com/i/c/k/nt_sleet.gif"
w["10d"]="http://icons.wxug.com/i/c/k/rain.gif"
w["10n"]="http://icons.wxug.com/i/c/k/nt_rain.gif"
w["11d"]="http://icons.wxug.com/i/c/k/tstorms.gif"
w["11n"]="http://icons.wxug.com/i/c/k/nt_tstorms.gif"
w["13d"]="http://icons.wxug.com/i/c/k/snow.gif"
w["13n"]="http://icons.wxug.com/i/c/k/nt_snow.gif"
w["50d"]="http://icons.wxug.com/i/c/k/fog.gif"
w["50n"]="http://icons.wxug.com/i/c/k/nt_fog.gif"
local ico=${w[$1]}
if [ -z "$ico" ]; then
ico="$1"
fi
echo $ico
}

View File

@@ -0,0 +1,74 @@
#
# Ritorna lo stato delle condizioni meteo interrogando il servizio online
#
# $i identificativo gpio del sensore di pioggia
#
# return output: 0 - errore durante il recupero delle condizioni meteo
# >0 - rilevato pioggia, timestamp del rilevamento
# <0 - rilevato nessuna pioggia, timestamp del rilevamento
function drv_openweathermap_rain_online_get {
# http://www.wunderground.com/weather/api/d/docs?d=resources/phrase-glossary&MR=1
$CURL "http://api.openweathermap.org/data/2.5/weather?$OPENWEATHERMAP_LOCATION&units=metric&appid=$OPENWEATHERMAP_KEY" > $TMP_PATH/check_rain_online.openweathermap.json
local weather=`cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -M ".weather[0].main"`
local wind_deg=$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".wind.deg")
local wind_speed=$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".wind.speed")
if [ "$wind_speed" == "null" ]; then
#wind_speed=$($JQ -n $wind_speed*3600/1000)
wind_speed=0
fi
local weather="$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".weather[0].description")"
local ico=$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".weather[0].icon")
weather=$(drv_openweathermap_get_wather "$weather")
ico=$(drv_openweathermap_get_ico "$ico")
local current_observation=$(cat <<EOF
{
"display_location": {
"city": "$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".name")"
},
"observation_epoch": "$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".dt")",
"local_epoch": "$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".dt")",
"local_tz_long": "$OPENWEATHERMAP_TZ",
"weather": "$weather",
"temp_c": $(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".main.temp"),
"relative_humidity": "$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".main.humidity")%",
"wind_dir": "$(deg2dir $wind_deg)",
"wind_degrees": $wind_deg,
"wind_kph": $wind_speed,
"wind_gust_kph": "--",
"pressure_mb": "$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".main.pressure")",
"dewpoint_c": "--",
"feelslike_c": "--",
"icon_url": "$ico"
}
EOF
)
# "icon_url": "http://openweathermap.org/img/w/$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".weather[0].icon").png"
#local current_observation=`cat $TMP_PATH/check_rain_online.json | $JQ -M ".current_observation"`
if [ "$weather" = "null" ]; then
echo "0"
else
echo "$current_observation" > "$STATUS_DIR/last_weather_online"
local local_epoch=`cat $STATUS_DIR/last_weather_online | $JQ -M -r ".local_epoch"`
if [[ "$weather" == *"Rain"* ]] ||
[[ "$weather" == *"Snow"* ]] ||
[[ "$weather" == *"Hail"* ]] ||
[[ "$weather" == *"Ice"* ]] ||
[[ "$weather" == *"Thunderstorm"* ]] ||
[[ "$weather" == *"Drizzle"* ]];
then
echo $local_epoch
else
echo "-$local_epoch"
fi
fi
}

13
drv/remote/README.md Normal file
View File

@@ -0,0 +1,13 @@
# Driver for controlling remote pigarden on the network from a pigarden master installation
For more information see https://www.lejubila.net/2018/03/pigardent-0-5-5-driver-master-per-implementare-un-architettura-master-slave/
# Example of zone configuration in piGarden.conf
EV1_ALIAS="Giarino_Posteriore_DX" #
EV1_GPIO="drv:remote:PIREMOTE1:Giardino_Posteriore_DX"
PIREMOTE1_IP="192.168.1.51"
PIREMOTE1_PORT="8084"
PIREMOTE1_USER=""
PIREMOTE1_PWD=""

View File

@@ -0,0 +1,38 @@
#
# Funzioni comuni utilizzate dal driver
#
#
# Esegue un comando su un pigarden remoto tramite socket
#
# $1 identificativo pigarden remoto
# $2 comando da eseguire
#
function drv_remote_command {
local remote="$1"
local command="$2"
local remote_ip_var=$remote"_IP"
local remote_port_var=$remote"_PORT"
local remote_user_var=$remote"_USER"
local remote_pwd_var=$remote"_PWD"
local remote_ip="${!remote_ip_var}"
local remote_port="${!remote_port_var}"
local remote_user="${!remote_user_var}"
local remote_pwd="${!remote_pwd_var}"
exec 5<>/dev/tcp/$remote_ip/$remote_port
if [[ ! -z $remote_user ]] && [[ ! -z $remote_pwd ]]; then
command="$remote_user\n$remote_pwd\n$command"
fi
echo -e "$command" >&5
cat <&5
}

View File

@@ -0,0 +1,7 @@
#
# File di configurazione del driver
#
# Dichiarazione variabile di esempio
#declare -g SAMPLE_FOO
#SAMPLE_FOO="bar"

View File

@@ -0,0 +1,9 @@
#
# Questa funzione viene inviocata dalla funzione "init" di piGarden se sono presenti elettrovalvole o sensori che utilizzano questo driver
#
function drv_remote_init {
local FOO=bar
}

View File

@@ -0,0 +1,23 @@
#
# Inizializza il sensore di rilevamento pioggia
#
# $i identificativo gpio del sensore di pioggia
#
function drv_remote_rain_sensor_init {
local FOO="bar"
}
#
# Ritorna lo stato del sensore di rilevamento pioggia
#
# $i identificativo gpio del sensore di pioggia
#
function drv_remote_rain_sensor_get {
local FOO="bar"
}

View File

@@ -0,0 +1,76 @@
#
# Inizializzazione rele
#
# $1 identificativo relè da inizializzare
#
function drv_remote_rele_init {
drv_remote_rele_open "$1"
}
#
# Apertura rele
#
# $1 identificativo relè da aprire (chiude l'elettrovalvola)
#
function drv_remote_rele_open {
local remote=`echo $1 | $CUT -d':' -f3,3`
local remote_alias=`echo $1 | $CUT -d':' -f4,4`
local command="close $remote_alias"
echo "remote=$remote"
echo "remote_alias=$remote_alias"
echo "command=$command"
local response=$(drv_remote_command "$remote" "$command")
echo "response=$response"
local result=$(echo $response|$JQ -M ".error.description")
echo "result=$result"
if [[ "$result" != "\"\"" ]]; then
local error=$result
error="${error%\"}"
error="${error#\"}"
echo "error=$error"
log_write "Remote rele open error: $error"
message_write "warning" "Remote rele open error: $error"
return 1
fi
}
#
# Chiusura rele
#
# $1 identificativo relè da chiudere (apre l'elettrovalvola)
#
function drv_remote_rele_close {
local remote=`echo $1 | $CUT -d':' -f3,3`
local remote_alias=`echo $1 | $CUT -d':' -f4,4`
local command="open $remote_alias force"
echo "remote=$remote"
echo "remote_alias=$remote_alias"
echo "command=$command"
local response=$(drv_remote_command "$remote" "$command")
echo "response=$response"
local result=`echo $response|$JQ -M ".error.description"`
echo "result=$result"
if [[ "$result" != "\"\"" ]]; then
local error=$result
error="${error%\"}"
error="${error#\"}"
echo "error=$error"
log_write "Remote rele close error: $error"
message_write "warning" "Remote rele close error: $error"
return 1
fi
}

View File

@@ -0,0 +1,27 @@
#
# Questa funzione viene invocata dalla funzione "setup_drv" di piGarden ad ogni avvio dello script
# e serve per eseguire l'eventuale setup del driver se necessario
#
function drv_remote_setup {
local all_remote=0
# Imposta le zone come remote
for i in $(seq $EV_TOTAL)
do
local a=EV"$i"_GPIO
local gpio="${!a}"
if [[ "$gpio" == drv:remote:* ]]; then
local varname=EV"$i"_REMOTE
declare -g $varname=1
all_remote=$((all_remote+1))
fi
done
# Se tutte le zone sono remote disabilita la gestione dell'alimentazione bistabile
if [ $all_remote -eq $EV_TOTAL ]; then
EV_MONOSTABLE=1
fi
}

View File

@@ -0,0 +1,34 @@
#
# Inizializza i rele che gestiscono l'alimentazione per le valvole bistabili
#
# $1 identificativo relè
#
function drv_remote_supply_bistable_init {
local FOO="bar"
}
#
# Imposta l'alimentazione delle elettrovalvole con voltaggio positivo
#
# $1 identificativo relè
#
function drv_remote_supply_positive {
local FOO="bar"
}
#
# Imposta l'alimentazione delle elettrovalvole con voltaggio negativo
#
# $1 identificativo relè
#
function drv_remote_supply_negative {
local FOO="bar"
}

2
drv/sample/README.md Normal file
View File

@@ -0,0 +1,2 @@
# Fake driver for sample and testing

View File

@@ -0,0 +1,12 @@
#
# Funzioni comuni utilizzate dal driver
#
#
# Funzione di esempio
#
function sample_foo {
echo "bar"
}

View File

@@ -0,0 +1,7 @@
#
# File di configurazione del driver
#
# Dichiarazione variabile di esempio
declare -g SAMPLE_FOO
SAMPLE_FOO="bar"

View File

@@ -0,0 +1,9 @@
#
# Questa funzione viene invocata dalla funzione "init" di piGarden se sono presenti elettrovalvole o sensori che utilizzano questo driver
#
function drv_sample_init {
local FOO="bar"
}

View File

@@ -0,0 +1,13 @@
#
# Ritorna lo stato delle condizioni meteo interrogando il servizio online
#
# return output: 0 - errore durante il recupero delle condizioni meteo
# >0 - rilevato pioggia, timestamp del rilevamento
# <0 - rilevato nessuna pioggia, timestamp del rilevamento
function drv_sample_rain_online_get {
local FOO="bar"
}

View File

@@ -0,0 +1,23 @@
#
# Inizializza il sensore di rilevamento pioggia
#
# $i identificativo gpio del sensore di pioggia
#
function drv_sample_rain_sensor_init {
local FOO="bar"
}
#
# Ritorna lo stato del sensore di rilevamento pioggia
#
# $i identificativo gpio del sensore di pioggia
#
function drv_sample_rain_sensor_get {
local FOO="bar"
}

View File

@@ -0,0 +1,33 @@
#
# Inizializzazione rele
#
# $1 identificativo relè da inizializzare
#
function drv_sample_rele_init {
local FOO="bar"
}
#
# Apertura rele
#
# $1 identificativo relè da aprire
#
function drv_sample_rele_open {
local FOO="bar"
}
#
# Chiusura rele
#
# $1 identificativo relè da chiudere
#
function drv_sample_rele_close {
local FOO="bar"
}

View File

@@ -0,0 +1,10 @@
#
# Questa funzione viene invocata dalla funzione "setup_drv" di piGarden ad ogni avvio dello script
# e serve per eseguire l'eventuale setup del driver se necessario
#
function drv_sample_setup {
local FOO="bar"
}

View File

@@ -0,0 +1,34 @@
#
# Inizializza i rele che gestiscono l'alimentazione per le valvole bistabili
#
# $1 identificativo relè
#
function drv_sample_supply_bistable_init {
local FOO="bar"
}
#
# Imposta l'alimentazione delle elettrovalvole con voltaggio positivo
#
# $1 identificativo relè
#
function drv_sample_supply_positive {
local FOO="bar"
}
#
# Imposta l'alimentazione delle elettrovalvole con voltaggio negativo
#
# $1 identificativo relè
#
function drv_sample_supply_negative {
local FOO="bar"
}

View File

@@ -0,0 +1,21 @@
# Driver for controlling Sonoff remote relays with Tasmota firmware via http protocol
More information on Sonoff Tasmota firmware: https://github.com/arendst/Sonoff-Tasmota
# Example of zone configuration in piGarden.conf
EV1_ALIAS="Giardino_Posteriore_DX"
EV1_GPIO="drv:sonoff_tasmota_http:SONOFF1:Power1"
EV1_MONOSTABLE=1
EV2_ALIAS="Giardino_Posteriore_CN"
EV2_GPIO="drv:sonoff_tasmota_http:SONOFF1:Power2"
EV2_MONOSTABLE=1
SONOFF1_IP="192.168.1.1"
SONOFF1_USER="user"
SONOFF1_PWD="pwd"
More information for configuration: https://www.lejubila.net/2018/06/pigarden-0-5-7-gestisci-le-tue-elettrovalvole-con-i-moduli-sonoff-grazie-al-nuovo-driver-sonoff_tasmota_http

View File

@@ -0,0 +1,50 @@
#
# Funzioni comuni utilizzate dal driver
#
#
# Invia un comando al modulo sonoff tramite http
#
# $1 identificativo modulo sonoff
# $2 comando da eseguire
#
function drv_sonoff_tasmota_http_command {
local remote="$1"
local command="$2"
local remote_ip_var=$remote"_IP"
local remote_user_var=$remote"_USER"
local remote_pwd_var=$remote"_PWD"
local remote_ip="${!remote_ip_var}"
local remote_user="${!remote_user_var}"
local remote_pwd="${!remote_pwd_var}"
local url="http://$remote_ip/cm"
local credentials=""
local response=""
if [[ ! -z $remote_user ]] && [[ ! -z $remote_pwd ]]; then
credentials="user=$remote_user&password=$remote_pwd&"
fi
url="$url?$credentials$command"
echo "url api sonoff: $url" >> "$LOG_OUTPUT_DRV_FILE"
$CURL --connect-timeout 5 -sb -H "$url"
local res=$?
echo "curl code response: $res" >> "$LOG_OUTPUT_DRV_FILE"
if [ "$res" != "0" ]; then
echo "The curl command failed with: $res - url: $url"
fi
#echo "{\"POWER1\":\"ON\"}"
}

View File

@@ -0,0 +1,7 @@
#
# File di configurazione del driver
#
# Dichiarazione variabile di esempio
#declare -g SAMPLE_FOO
#SAMPLE_FOO="bar"

View File

@@ -0,0 +1,9 @@
#
# Questa funzione viene inviocata dalla funzione "init" di piGarden se sono presenti elettrovalvole o sensori che utilizzano questo driver
#
function drv_sonoff_tasmota_http_init {
local FOO=bar
}

View File

@@ -0,0 +1,23 @@
#
# Inizializza il sensore di rilevamento pioggia
#
# $i identificativo gpio del sensore di pioggia
#
function drv_sonoff_tasmota_http_rain_sensor_init {
local FOO="bar"
}
#
# Ritorna lo stato del sensore di rilevamento pioggia
#
# $i identificativo gpio del sensore di pioggia
#
function drv_sonoff_tasmota_http_rain_sensor_get {
local FOO="bar"
}

View File

@@ -0,0 +1,78 @@
#
# Inizializzazione rele
#
# $1 identificativo relè da inizializzare
#
function drv_sonoff_tasmota_http_rele_init {
drv_sonoff_tasmota_http_rele_open "$1"
}
#
# Apertura rele
#
# $1 identificativo relè da aprire (chiude l'elettrovalvola)
#
function drv_sonoff_tasmota_http_rele_open {
local remote=`echo $1 | $CUT -d':' -f3,3`
local remote_alias=`echo $1 | $CUT -d':' -f4,4`
local command="cmnd=$remote_alias%20Off"
echo "remote=$remote"
echo "remote_alias=$remote_alias"
echo "command=$command"
local response=$(drv_sonoff_tasmota_http_command "$remote" "$command")
echo "response=$response"
local jskey=${remote_alias^^}
local result=$(echo $response|$JQ -M ".$jskey")
echo "result=$result"
if [[ "$result" != "\"OFF\"" ]]; then
local error="Command error: $response"
error="${error%\"}"
error="${error#\"}"
echo "error=$error"
log_write "Remote rele open error: $error"
message_write "warning" "Remote rele open error: $error"
return 1
fi
}
#
# Chiusura rele
#
# $1 identificativo relè da chiudere (apre l'elettrovalvola)
#
function drv_sonoff_tasmota_http_rele_close {
local remote=`echo $1 | $CUT -d':' -f3,3`
local remote_alias=`echo $1 | $CUT -d':' -f4,4`
local command="cmnd=$remote_alias%20On"
echo "remote=$remote"
echo "remote_alias=$remote_alias"
echo "command=$command"
local response=$(drv_sonoff_tasmota_http_command "$remote" "$command")
echo "response=$response"
local jskey=${remote_alias^^}
local result=$(echo $response|$JQ -M ".$jskey")
echo "result=$result"
if [[ "$result" != "\"ON\"" ]]; then
local error="Command error: $response"
error="${error%\"}"
error="${error#\"}"
echo "error=$error"
log_write "Remote rele close error: $error"
message_write "warning" "Remote rele close error: $error"
return 1
fi
}

View File

@@ -0,0 +1,10 @@
#
# Questa funzione viene invocata dalla funzione "setup_drv" di piGarden ad ogni avvio dello script
# e serve per eseguire l'eventuale setup del driver se necessario
#
function drv_sonoff_tasmota_http_setup {
local FOO="bar"
}

View File

@@ -0,0 +1,34 @@
#
# Inizializza i rele che gestiscono l'alimentazione per le valvole bistabili
#
# $1 identificativo relè
#
function drv_sonoff_tasmota_http_supply_bistable_init {
drv_sonoff_tasmota_http_supply_negative "$1"
}
#
# Imposta l'alimentazione delle elettrovalvole con voltaggio positivo
#
# $1 identificativo relè
#
function drv_sonoff_tasmota_http_supply_positive {
drv_sonoff_tasmota_http_rele_open "$1"
}
#
# Imposta l'alimentazione delle elettrovalvole con voltaggio negativo
#
# $1 identificativo relè
#
function drv_sonoff_tasmota_http_supply_negative {
drv_sonoff_tasmota_http_rele_close "$1"
}

12
drv/spb16ch/README.md Normal file
View File

@@ -0,0 +1,12 @@
# Driver per controllare la scheda "Smart Power Board 16 channel with RTC" (spb16ch)
Questo driver richiede l'interprete python e la libreria python-smbus. Inoltre l'utente pi deve fare parte del gruppo i2c
sudo apt-get install python python-smbus
sudo usermod -a -G i2c pi
Oltre a quanto sopra indicato, il raspberry deve avere caricato i moduli di gestione del bus i2c:
sudo raspi-config
Interfacing Options / I2C / Yes
Per maggiori informazioni consulta https://www.lejubila.net/2017/10/pigarden-spb16ch-gestiamo-fino-a-128-zone-nel-nostro-impianto-di-irrigazione/

View File

@@ -0,0 +1,80 @@
#
# Funzioni comuni per il driver spb16ch
#
#
# Abilita una scheda spb16ch in modo che possa esseregli impartito un comando successivamente
# $1 identificativo scheda da abilitare
#
function drv_spb16ch_board_enable {
local board_id=$1
local a=SPB16CH"$board_id"_GPIO
local gpio_n=${!a}
echo "** drv_spb16ch_board_enable() - Enable board: $board_id - gpio $gpio_n"
$GPIO -g write $gpio_n $SPB16CH_GPIO_ON
}
#
# Disabilita una scheda spb16ch
# $1 identificativo scheda da disabilitare
#
function drv_spb16ch_board_disable {
local board_id=$1
local a=SPB16CH"$board_id"_GPIO
local gpio_n=${!a}
echo "** drv_spb16ch_board_disable() - Disable board: $board_id - gpio $gpio_n"
$GPIO -g write $gpio_n $SPB16CH_GPIO_OFF
}
#
# Disabilita tutte le schede
#
function drv_spb16ch_board_disable_all {
echo "** drv_spb16ch_board_disable_all() - Boads id: ${SPB16CH_USED_ID[@]}"
local board_id
for board_id in ${SPB16CH_USED_ID[@]}
do
local a=SPB16CH"$board_id"_GPIO
local gpio_n=${!a}
echo "** drv_spb16ch_board_disable_all() - Disable board: $board_id - gpio $gpio_n"
$GPIO -g write $gpio_n $SPB16CH_GPIO_OFF
done
}
#
# Memorizza in un file di appoggio gli id delle schede spb16ch utilizzate
#
function drv_spb16ch_boards_id_store {
echo "${SPB16CH_USED_ID[@]}" > "$SPB16CH_BOARD_ID_STORE_FILE"
}
#
# Recupera gli di delle schede spb16ch utilizzate leggendoli dal file di appoggio
# $1 identificativi schede da salvare
#
function drv_spb16ch_boards_id_load {
if [ -f "$SPB16CH_BOARD_ID_STORE_FILE" ]; then
for board_id in $(cat "$SPB16CH_BOARD_ID_STORE_FILE")
do
SPB16CH_USED_ID+=("$board_id")
done
else
log_write "spb16ch: file $SPB16CH_BOARD_ID_STORE_FILE not found: remember to run 'piGarden init' to generate the file"
fi
}

View File

@@ -0,0 +1,160 @@
#
# Mapping rele spb16ch: l'indice indica il relè, ogni elemento deve essere lungo 8 caratteri,
# 1-2: i primi due indicano l'indirizzo della scheda
# 3-3: separatore
# 4-4: il quarto carattere indica il mux channel
# 5-5: separatore
# 6-8: dal 6 all'ottavo carattere indicano il numero del rele sul canale
# 10-10: l'ultimo carattere indica il numero identificativo della scheda spb16ch
# Scheda 1 - address 70h - GS1:chiuso, GS2:chiuso, GS3:chiuso
SPB16CH_RELE_MAP[1]="70|0| 1|1"
SPB16CH_RELE_MAP[2]="70|0| 2|1"
SPB16CH_RELE_MAP[3]="70|0| 4|1"
SPB16CH_RELE_MAP[4]="70|0| 8|1"
SPB16CH_RELE_MAP[5]="70|0| 16|1"
SPB16CH_RELE_MAP[6]="70|0| 32|1"
SPB16CH_RELE_MAP[7]="70|0| 64|1"
SPB16CH_RELE_MAP[8]="70|0|128|1"
SPB16CH_RELE_MAP[9]="70|1| 1|1"
SPB16CH_RELE_MAP[10]="70|1| 2|1"
SPB16CH_RELE_MAP[11]="70|1| 4|1"
SPB16CH_RELE_MAP[12]="70|1| 8|1"
SPB16CH_RELE_MAP[13]="70|1| 16|1"
SPB16CH_RELE_MAP[14]="70|1| 32|1"
SPB16CH_RELE_MAP[15]="70|1| 64|1"
SPB16CH_RELE_MAP[16]="70|1|128|1"
# Scheda 2 - address 71h - GS1:aperto, GS2:chiuso, GS3:chiuso
SPB16CH_RELE_MAP[17]="71|0| 1|2"
SPB16CH_RELE_MAP[18]="71|0| 2|2"
SPB16CH_RELE_MAP[19]="71|0| 4|2"
SPB16CH_RELE_MAP[20]="71|0| 8|2"
SPB16CH_RELE_MAP[21]="71|0| 16|2"
SPB16CH_RELE_MAP[22]="71|0| 32|2"
SPB16CH_RELE_MAP[23]="71|0| 64|2"
SPB16CH_RELE_MAP[24]="71|0|128|2"
SPB16CH_RELE_MAP[25]="71|1| 1|2"
SPB16CH_RELE_MAP[26]="71|1| 2|2"
SPB16CH_RELE_MAP[27]="71|1| 4|2"
SPB16CH_RELE_MAP[28]="71|1| 8|2"
SPB16CH_RELE_MAP[29]="71|1| 16|2"
SPB16CH_RELE_MAP[30]="71|1| 32|2"
SPB16CH_RELE_MAP[31]="71|1| 64|2"
SPB16CH_RELE_MAP[32]="71|1|128|2"
# Scheda 3 - address 72h - GS1:chiuso, GS2:aperto, GS3:chiuso
SPB16CH_RELE_MAP[33]="72|0| 1|3"
SPB16CH_RELE_MAP[34]="72|0| 2|3"
SPB16CH_RELE_MAP[35]="72|0| 4|3"
SPB16CH_RELE_MAP[36]="72|0| 8|3"
SPB16CH_RELE_MAP[37]="72|0| 16|3"
SPB16CH_RELE_MAP[38]="72|0| 32|3"
SPB16CH_RELE_MAP[39]="72|0| 64|3"
SPB16CH_RELE_MAP[40]="72|0|128|3"
SPB16CH_RELE_MAP[41]="72|1| 1|3"
SPB16CH_RELE_MAP[42]="72|1| 2|3"
SPB16CH_RELE_MAP[43]="72|1| 4|3"
SPB16CH_RELE_MAP[44]="72|1| 8|3"
SPB16CH_RELE_MAP[45]="72|1| 16|3"
SPB16CH_RELE_MAP[46]="72|1| 32|3"
SPB16CH_RELE_MAP[47]="72|1| 64|3"
SPB16CH_RELE_MAP[48]="72|1|128|3"
# Scheda 4 - address 73h - GS1:aperto, GS2:aperto, GS3:chiuso
SPB16CH_RELE_MAP[49]="73|0| 1|4"
SPB16CH_RELE_MAP[50]="73|0| 2|4"
SPB16CH_RELE_MAP[51]="73|0| 4|4"
SPB16CH_RELE_MAP[52]="73|0| 8|4"
SPB16CH_RELE_MAP[53]="73|0| 16|4"
SPB16CH_RELE_MAP[54]="73|0| 32|4"
SPB16CH_RELE_MAP[55]="73|0| 64|4"
SPB16CH_RELE_MAP[56]="73|0|128|4"
SPB16CH_RELE_MAP[57]="73|1| 1|4"
SPB16CH_RELE_MAP[58]="73|1| 2|4"
SPB16CH_RELE_MAP[59]="73|1| 4|4"
SPB16CH_RELE_MAP[60]="73|1| 8|4"
SPB16CH_RELE_MAP[61]="73|1| 16|4"
SPB16CH_RELE_MAP[62]="73|1| 32|4"
SPB16CH_RELE_MAP[63]="73|1| 64|4"
SPB16CH_RELE_MAP[64]="73|1|128|4"
# Scheda 5 - address 74h - GS1:chiuso, GS2:chiuso, GS3:aperto
SPB16CH_RELE_MAP[65]="74|0| 1|5"
SPB16CH_RELE_MAP[66]="74|0| 2|5"
SPB16CH_RELE_MAP[67]="74|0| 4|5"
SPB16CH_RELE_MAP[68]="74|0| 8|5"
SPB16CH_RELE_MAP[69]="74|0| 16|5"
SPB16CH_RELE_MAP[70]="74|0| 32|5"
SPB16CH_RELE_MAP[71]="74|0| 64|5"
SPB16CH_RELE_MAP[72]="74|0|128|5"
SPB16CH_RELE_MAP[73]="74|1| 1|5"
SPB16CH_RELE_MAP[74]="74|1| 2|5"
SPB16CH_RELE_MAP[75]="74|1| 4|5"
SPB16CH_RELE_MAP[76]="74|1| 8|5"
SPB16CH_RELE_MAP[77]="74|1| 16|5"
SPB16CH_RELE_MAP[78]="74|1| 32|5"
SPB16CH_RELE_MAP[79]="74|1| 64|5"
SPB16CH_RELE_MAP[80]="74|1|128|5"
# Scheda 6 - address 75h - GS1:aperto, GS2:chiuso, GS3:aperto
SPB16CH_RELE_MAP[81]="75|0| 1|6"
SPB16CH_RELE_MAP[82]="75|0| 2|6"
SPB16CH_RELE_MAP[83]="75|0| 4|6"
SPB16CH_RELE_MAP[84]="75|0| 8|6"
SPB16CH_RELE_MAP[85]="75|0| 16|6"
SPB16CH_RELE_MAP[86]="75|0| 32|6"
SPB16CH_RELE_MAP[87]="75|0| 64|6"
SPB16CH_RELE_MAP[88]="75|0|128|6"
SPB16CH_RELE_MAP[89]="75|1| 1|6"
SPB16CH_RELE_MAP[90]="75|1| 2|6"
SPB16CH_RELE_MAP[91]="75|1| 4|6"
SPB16CH_RELE_MAP[92]="75|1| 8|6"
SPB16CH_RELE_MAP[93]="75|1| 16|6"
SPB16CH_RELE_MAP[94]="75|1| 32|6"
SPB16CH_RELE_MAP[95]="75|1| 64|6"
SPB16CH_RELE_MAP[96]="75|1|128|6"
# Scheda 7 - address 76h - GS1:chiuso, GS2:aperto, GS3:aperto
SPB16CH_RELE_MAP[97]="76|0| 1|7"
SPB16CH_RELE_MAP[98]="76|0| 2|7"
SPB16CH_RELE_MAP[99]="76|0| 4|7"
SPB16CH_RELE_MAP[100]="76|0| 8|7"
SPB16CH_RELE_MAP[101]="76|0| 16|7"
SPB16CH_RELE_MAP[102]="76|0| 32|7"
SPB16CH_RELE_MAP[103]="76|0| 64|7"
SPB16CH_RELE_MAP[104]="76|0|128|7"
SPB16CH_RELE_MAP[105]="76|1| 1|7"
SPB16CH_RELE_MAP[106]="76|1| 2|7"
SPB16CH_RELE_MAP[107]="76|1| 4|7"
SPB16CH_RELE_MAP[108]="76|1| 8|7"
SPB16CH_RELE_MAP[109]="76|1| 16|7"
SPB16CH_RELE_MAP[110]="76|1| 32|7"
SPB16CH_RELE_MAP[111]="76|1| 64|7"
SPB16CH_RELE_MAP[112]="76|1|128|7"
# Scheda 8 - address 77h - GS1:aperto, GS2:aperto, GS3:aperto
SPB16CH_RELE_MAP[113]="77|0| 1|8"
SPB16CH_RELE_MAP[114]="77|0| 2|8"
SPB16CH_RELE_MAP[115]="77|0| 4|8"
SPB16CH_RELE_MAP[116]="77|0| 8|8"
SPB16CH_RELE_MAP[117]="77|0| 16|8"
SPB16CH_RELE_MAP[118]="77|0| 32|8"
SPB16CH_RELE_MAP[119]="77|0| 64|8"
SPB16CH_RELE_MAP[120]="77|0|128|8"
SPB16CH_RELE_MAP[121]="77|1| 1|8"
SPB16CH_RELE_MAP[122]="77|1| 2|8"
SPB16CH_RELE_MAP[123]="77|1| 4|8"
SPB16CH_RELE_MAP[124]="77|1| 8|8"
SPB16CH_RELE_MAP[125]="77|1| 16|8"
SPB16CH_RELE_MAP[126]="77|1| 32|8"
SPB16CH_RELE_MAP[127]="77|1| 64|8"
SPB16CH_RELE_MAP[128]="77|1|128|8"
# Array contenente i gli identificativi delle schede usate
declare -g -a SPB16CH_USED_ID
SPB16CH_USED_ID=()
# Nome del file dove memorizzare gli id delle schede utilizzate
declare -g SPB16CH_BOARD_ID_STORE_FILE
SPB16CH_BOARD_ID_STORE_FILE="$STATUS_DIR/spb16ch_board_id_store"

View File

@@ -0,0 +1,84 @@
#
# Questa funzione viene inviocata dalla funzione "init" di piGarden se sono presenti elettrovalvole o sensori che utilizzano questo driver
#
function drv_spb16ch_init {
declare -a address_used
address_used=()
SPB16CH_USED_ID=()
local address=""
local board_id=""
# Cerca gli indirizzi delle schede spb16ch utilizzate per i rele utilizzati per le zone
for i in $(seq $EV_TOTAL)
do
local a=EV"$i"_GPIO
local gpio="${!a}"
if [[ "$gpio" == drv:spb16ch:* ]]; then
local rele_id=`echo $gpio | $CUT -d':' -f3,3`
local rele_data=${SPB16CH_RELE_MAP[$rele_id]}
if [[ ! -z $rele_data ]]; then
local address_num=${rele_data:0:2}
local board_id=${rele_data:9:1}
if [[ ! " ${address_used[@]} " =~ " ${address_num} " ]]; then
address_used+=("$address_num")
SPB16CH_USED_ID+=("$board_id")
fi
fi
fi
done
# Cerca gli indirizzi delle schede spb16ch utilizzate per i rele che gestiscono l'alimentazione delle elettrovalvole bistabili
for gpio in "$SUPPLY_GPIO_1" "$SUPPLY_GPIO_2"
do
if [[ "$gpio" == drv:spb16ch:* ]]; then
local rele_id=`echo $gpio | $CUT -d':' -f3,3`
local rele_data=${SPB16CH_RELE_MAP[$rele_id]}
if [[ ! -z $rele_data ]]; then
local address_num=${rele_data:0:2}
local board_id=${rele_data:9:1}
if [[ ! " ${address_used[@]} " =~ " ${address_num} " ]]; then
address_used+=("$address_num")
SPB16CH_USED_ID+=("$board_id")
fi
fi
fi
done
# Memorizza gli id delle schede usate
drv_spb16ch_boards_id_store
# Esegue l'inizializzazione dei gpio che gestiscono l'abilitazine/disabilitazione delle schede
local board_id
for board_id in ${SPB16CH_USED_ID[@]}
do
local a=SPB16CH"$board_id"_GPIO
local gpio_n=${!a}
echo "******** Number used board: $board_id - inizializzazione gpio $gpio_n"
$GPIO -g mode $gpio_n out
done
#drv_spb16ch_board_disable_all
# Esegue l'inizializzazione delle schede spb16ch trovate
local address_num=""
local board_num=""
for i in ${!address_used[@]}
do
address_num=${address_used[$i]}
board_num=${SPB16CH_USED_ID[$i]}
drv_spb16ch_board_enable $board_num # Porto alto il reset della scheda e lo mantengo sempre alto
echo "****** Inizializzazione address_num = $address_num - board_num = $board_num *******"
$DIR_SCRIPT/drv/spb16ch/scripts/mux_channel.py $address_num 0
$DIR_SCRIPT/drv/spb16ch/scripts/gpo_init.py 25 255 0
$DIR_SCRIPT/drv/spb16ch/scripts/mux_channel.py $address_num 1
$DIR_SCRIPT/drv/spb16ch/scripts/gpo_init.py 25 255 0
$DIR_SCRIPT/drv/spb16ch/scripts/mux_channel.py $address_num 0
# Disabilito il mux
$DIR_SCRIPT/drv/spb16ch/scripts/mux_disable.py $address_num
#drv_spb16ch_board_disable $board_id
done
}

View File

@@ -0,0 +1,23 @@
#
# Inizializza il sensore di rilevamento pioggia
#
# $i identificativo gpio del sensore di pioggia
#
function drv_spb16ch_rain_sensor_init {
local FOO="bar"
}
#
# Ritorna lo stato del sensore di rilevamento pioggia
#
# $i identificativo gpio del sensore di pioggia
#
function drv_spb16ch_rain_sensor_get {
local FOO="bar"
}

View File

@@ -0,0 +1,76 @@
#
# Inizializzazione rele
#
# $1 identificativo relè da inizializzare
#
function drv_spb16ch_rele_init {
drv_spb16ch_rele_open "$1"
}
#
# Apertura rele
#
# $1 identificativo relè da aprire
#
function drv_spb16ch_rele_open {
local rele_id=`echo $1 | $CUT -d':' -f3,3`
local rele_data=${SPB16CH_RELE_MAP[$rele_id]}
if [[ -z $rele_data ]]; then
local message="Error - Rele map not defined - rele_id=$rele_id - ($1)"
log_write "$message"
message_write "warning" "$message"
fi
local address_num=${rele_data:0:2}
local channel_num=${rele_data:3:1}
local rele_num=${rele_data:5:3}
local board_id=${rele_data:9:1}
#drv_spb16ch_board_enable $board_id
echo address_num=$address_num
echo channel_num=$channel_num
echo rele_num=$rele_num
$DIR_SCRIPT/drv/spb16ch/scripts/mux_channel.py $address_num $channel_num
$DIR_SCRIPT/drv/spb16ch/scripts/gpo_init.py $address_num $rele_num 0
# Disabilito il mux
$DIR_SCRIPT/drv/spb16ch/scripts/mux_disable.py $address_num
#drv_spb16ch_board_disable $board_id
}
#
# Chiusura rele
#
# $1 identificativo relè da chiudere
#
function drv_spb16ch_rele_close {
local rele_id=`echo $1 | $CUT -d':' -f3,3`
local rele_data=${SPB16CH_RELE_MAP[$rele_id]}
if [[ -z $rele_data ]]; then
local message="Error - Rele map not defined - rele_id=$rele_id - ($1)"
log_write "$message"
message_write "warning" "$message"
fi
local address_num=${rele_data:0:2}
local channel_num=${rele_data:3:1}
local rele_num=${rele_data:5:3}
local board_id=${rele_data:9:1}
#drv_spb16ch_board_enable $board_id
echo address_num=$address_num
echo channel_num=$channel_num
echo rele_num=$rele_num
$DIR_SCRIPT/drv/spb16ch/scripts/mux_channel.py $address_num $channel_num
$DIR_SCRIPT/drv/spb16ch/scripts/gpo_init.py $address_num $rele_num 1
# Disabilito il mux
$DIR_SCRIPT/drv/spb16ch/scripts/mux_disable.py $address_num
#drv_spb16ch_board_disable $board_id
}

37
drv/spb16ch/scripts/ee_read.py Executable file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/python
# coding=utf-8
# Read the eeprom 24C16
# I2C Address: 0x50 (24C16)
# sudo ./ee_read.py 0x50 address
# Example: sudo ./ee_read.py 50 0
import time
import argparse
import RPi.GPIO as GPIO
import smbus
def I2C_setup(i2c_address, eeprom_address):
I2C_address = 0x50
if GPIO.RPI_REVISION in [2, 3]:
I2C_bus_number = 1
else:
I2C_bus_number = 0
bus = smbus.SMBus(I2C_bus_number)
#bus.read_byte_data(I2C_address, eeprom_address)
print("24C16 ADDRESS: {}".format(bin(eeprom_address)))
print("24C16 DATA: {}".format(bin(bus.read_byte_data(I2C_address, eeprom_address))))
print("24C16 DATA: {}".format(hex(bus.read_byte_data(I2C_address, eeprom_address))))
def menu():
parser = argparse.ArgumentParser(description='Select address to read data on eeprom 24C16 ')
parser.add_argument('i2c_address', type=int)
parser.add_argument('eeprom_address', type=int)
args = parser.parse_args()
I2C_setup(args.i2c_address, args.eeprom_address)
if __name__ == "__main__":
menu()

35
drv/spb16ch/scripts/ee_write.py Executable file
View File

@@ -0,0 +1,35 @@
#!/usr/bin/python
# coding=utf-8
# Write the eeprom 24C16
# I2C Address: 0x50 (24C16)
# sudo ./ee_write.py 0x50 address data
# Example: sudo ./ee_write.py 50 0 1
import time
import argparse
import RPi.GPIO as GPIO
import smbus
def I2C_setup(i2c_address, eeprom_address, eeprom_data):
I2C_address = 0x50
if GPIO.RPI_REVISION in [2, 3]:
I2C_bus_number = 1
else:
I2C_bus_number = 0
bus = smbus.SMBus(I2C_bus_number)
bus.write_byte_data(I2C_address, eeprom_address, eeprom_data)
def menu():
parser = argparse.ArgumentParser(description='Select address and data to write on eeprom 24C16 ')
parser.add_argument('i2c_address', type=int)
parser.add_argument('eeprom_address', type=int)
parser.add_argument('eeprom_data', type=int)
args = parser.parse_args()
I2C_setup(args.i2c_address, args.eeprom_address, args.eeprom_data)
if __name__ == "__main__":
menu()

View File

@@ -0,0 +1,44 @@
#!/usr/bin/python
# coding=utf-8
# Select address and channel of PCA9571 I2C general purpose outputs
# I2C Address: 0x25 Fixed
# sudo ./gpo_active.py CHANNEL
# Example: sudo ./gpo_active.py 25 255 1 #all relays activates
import time
import argparse
import RPi.GPIO as GPIO
import smbus
def I2C_setup(multiplexer_i2c_address, i2c_channel_setup, state):
I2C_address = 0x25
if GPIO.RPI_REVISION in [2, 3]:
I2C_bus_number = 1
else:
I2C_bus_number = 0
bus = smbus.SMBus(I2C_bus_number)
status_outputs=bus.read_byte(I2C_address)
if state == 1:
i2c_channel_setup=status_outputs|i2c_channel_setup
elif state == 0:
i2c_channel_setup=(-i2c_channel_setup-1)&status_outputs
elif state == -1:
i2c_channel_setup=0
bus.write_byte(I2C_address, i2c_channel_setup)
#time.sleep(0)
file = open("rl1", "r")
address=int(file.readline())
channel_outputs=int(file.readline())
state=int(file.readline())
def menu():
I2C_setup(address, channel_outputs, state)
if __name__ == "__main__":
menu()

44
drv/spb16ch/scripts/gpo_init.py Executable file
View File

@@ -0,0 +1,44 @@
#!/usr/bin/python
# coding=utf-8
# Select address and channel of PCA9571 I2C general purpose outputs
# I2C Address: 0x25 Fixed
# sudo ./gpo_active.py CHANNEL
# Example: sudo ./gpo_active.py 25 255 1 #all relays activates
import time
import argparse
import RPi.GPIO as GPIO
import smbus
def I2C_setup(multiplexer_i2c_address, i2c_channel_setup, state):
I2C_address = 0x25
if GPIO.RPI_REVISION in [2, 3]:
I2C_bus_number = 1
else:
I2C_bus_number = 0
bus = smbus.SMBus(I2C_bus_number)
status_outputs=bus.read_byte(I2C_address)
if state == 1:
i2c_channel_setup=status_outputs|i2c_channel_setup
elif state == 0:
i2c_channel_setup=(-i2c_channel_setup-1)&status_outputs
elif state == -1:
i2c_channel_setup=0
bus.write_byte(I2C_address, i2c_channel_setup)
#time.sleep(0)
def menu():
parser = argparse.ArgumentParser(description='Select channel outputs of PCA9571')
parser.add_argument('address', type=int)
parser.add_argument('channel_outputs', type=int)
parser.add_argument('state', type=int)
args = parser.parse_args()
I2C_setup(args.address, args.channel_outputs, args.state)
if __name__ == "__main__":
menu()

33
drv/spb16ch/scripts/gpo_read.py Executable file
View File

@@ -0,0 +1,33 @@
#!/usr/bin/python
# coding=utf-8
# Select address and channel of PCA9571 I2C general purpose outputs
# I2C Address: 0x25 Fixed
# sudo ./gpo_read.py CHANNEL
# Example: sudo ./gpo_read.py 25
import time
import argparse
import RPi.GPIO as GPIO
import smbus
def I2C_read(multiplexer_i2c_address):
I2C_address = 0x25
if GPIO.RPI_REVISION in [2, 3]:
I2C_bus_number = 1
else:
I2C_bus_number = 0
bus = smbus.SMBus(I2C_bus_number)
status_outputs=bus.read_byte(I2C_address)
time.sleep(0)
# print("PCA9571 sts:{}".format(bin(bus.read_byte(I2C_address))))
print("PCA9571 GPO sts:{}".format(hex(bus.read_byte(I2C_address))))
def menu():
I2C_read(0x25)
if __name__ == "__main__":
menu()

3
drv/spb16ch/scripts/gpo_send Executable file
View File

@@ -0,0 +1,3 @@
25
100
1

1
drv/spb16ch/scripts/gpo_states Executable file
View File

@@ -0,0 +1 @@
PCA9571 GPO sts:0x64

5
drv/spb16ch/scripts/init.sh Executable file
View File

@@ -0,0 +1,5 @@
./mux_channel.py 72 0
./gpo_init.py 25 255 0
./mux_channel.py 72 1
./gpo_init.py 25 255 0
./mux_channel.py 72 0

View File

@@ -0,0 +1,38 @@
#!/usr/bin/python
# coding=utf-8
# Select address and channel of PCA9547 I2C multiplexer
# I2C Address: 0xYY, where YY can be 70 through 77
# Multiplexer Channel: 1 - 8
# sudo ./mux_channel.py ADDRESS CHANNEL
# Example: sudo ./mux_channel.py 70 1
import time
import argparse
import RPi.GPIO as GPIO
import smbus
def I2C_setup(multiplexer_i2c_address, i2c_channel_setup):
I2C_address = 0x70 + multiplexer_i2c_address % 10
if GPIO.RPI_REVISION in [2, 3]:
I2C_bus_number = 1
else:
I2C_bus_number = 0
bus = smbus.SMBus(I2C_bus_number)
i2c_channel_setup=i2c_channel_setup + 0x08
bus.write_byte(I2C_address, i2c_channel_setup)
#time.sleep(0.1)
def menu():
parser = argparse.ArgumentParser(description='Select channel of PCA9547 I2C multiplexer')
parser.add_argument('address', type=int)
parser.add_argument('channel', type=int)
args = parser.parse_args()
I2C_setup(args.address, args.channel)
if __name__ == "__main__":
menu()

View File

@@ -0,0 +1,37 @@
#!/usr/bin/python
# coding=utf-8
# Disable PCA9547 I2C multiplexer
# I2C Address: 0xYY, where YY can be 70 through 77
# sudo ./mux_channel.py ADDRESS CHANNEL
# Example: sudo ./mux_disable.py 70
import time
import argparse
import RPi.GPIO as GPIO
import smbus
def I2C_setup(multiplexer_i2c_address):
I2C_address = 0x70 + multiplexer_i2c_address % 10
if GPIO.RPI_REVISION in [2, 3]:
I2C_bus_number = 1
else:
I2C_bus_number = 0
bus = smbus.SMBus(I2C_bus_number)
i2c_channel_setup=0x00
#i2c_channel_setup=i2c_channel_setup + 0x08
bus.write_byte(I2C_address, i2c_channel_setup)
#time.sleep(0.1)
def menu():
parser = argparse.ArgumentParser(description='Select Address of Disable PCA9547 Multiplexer')
parser.add_argument('address', type=int)
args = parser.parse_args()
I2C_setup(args.address)
if __name__ == "__main__":
menu()

37
drv/spb16ch/scripts/mux_read.py Executable file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/python
# coding=utf-8
# Select address and channel of PCA9547 I2C multiplexer
# I2C Address: 0xYY, where YY can be 70 through 77
# Multiplexer Channel: 1 - 8
# sudo ./mux_read.py ADDRESS
# Example: sudo ./mux_read.py 70
import time
import argparse
import RPi.GPIO as GPIO
import smbus
def I2C_setup(multiplexer_i2c_address):
I2C_address = 0x70 + multiplexer_i2c_address % 10
if GPIO.RPI_REVISION in [2, 3]:
I2C_bus_number = 1
else:
I2C_bus_number = 0
bus = smbus.SMBus(I2C_bus_number)
time.sleep(0.1)
# print("PCA9547 MUX sts:{}".format(bin(bus.read_byte(I2C_address))))
print("PCA9547 MUX sts:{}".format(hex(bus.read_byte(I2C_address))))
def menu():
parser = argparse.ArgumentParser(description='Select channel of PCA9547 I2C multiplexer')
parser.add_argument('address', type=int)
args = parser.parse_args()
I2C_setup(args.address)
if __name__ == "__main__":
menu()

1
drv/spb16ch/scripts/mux_states Executable file
View File

@@ -0,0 +1 @@
PCA9547 MUX sts:0x8

View File

@@ -0,0 +1,6 @@
#!/usr/bin/python
# coding=utf-8
file = open("mux", "r")
line1=file.readline()
print line1

33
drv/spb16ch/scripts/rele1_16 Executable file
View File

@@ -0,0 +1,33 @@
25
1
0
2
0
4
0
8
0
16
1
32
1
64
1
128
1
1
0
2
0
4
0
8
0
16
1
32
1
64
1
128
1

View File

@@ -0,0 +1,95 @@
#!/usr/bin/python
# coding=utf-8
# Select address and channel of PCA9571 I2C general purpose outputs
# I2C Address: 0x25 Fixed
# sudo ./gpo_active.py CHANNEL
# Example: sudo ./gpo_active.py 25 255 1 #all relays activates
import time
import argparse
import subprocess
import RPi.GPIO as GPIO
import smbus
def I2C_setup(multiplexer_i2c_address, i2c_channel_setup, state):
I2C_address = 0x25
if GPIO.RPI_REVISION in [2, 3]:
I2C_bus_number = 1
else:
I2C_bus_number = 0
bus = smbus.SMBus(I2C_bus_number)
status_outputs=bus.read_byte(I2C_address)
if state == 1:
i2c_channel_setup=status_outputs|i2c_channel_setup
elif state == 0:
i2c_channel_setup=(-i2c_channel_setup-1)&status_outputs
elif state == -1:
i2c_channel_setup=0
bus.write_byte(I2C_address, i2c_channel_setup)
#time.sleep(0)
def menu():
while 1==1:
subprocess.call('./mux_channel.py 72 0', shell=True)
#time.sleep(0.1)
file = open("rele1_16", "r")
address=int(file.readline())
channel_outputs1=int(file.readline())
state1=int(file.readline())
channel_outputs2=int(file.readline())
state2=int(file.readline())
channel_outputs3=int(file.readline())
state3=int(file.readline())
channel_outputs4=int(file.readline())
state4=int(file.readline())
channel_outputs5=int(file.readline())
state5=int(file.readline())
channel_outputs6=int(file.readline())
state6=int(file.readline())
channel_outputs7=int(file.readline())
state7=int(file.readline())
channel_outputs8=int(file.readline())
state8=int(file.readline())
channel_outputs9=int(file.readline())
state9=int(file.readline())
channel_outputs10=int(file.readline())
state10=int(file.readline())
channel_outputs11=int(file.readline())
state11=int(file.readline())
channel_outputs12=int(file.readline())
state12=int(file.readline())
channel_outputs13=int(file.readline())
state13=int(file.readline())
channel_outputs14=int(file.readline())
state14=int(file.readline())
channel_outputs15=int(file.readline())
state15=int(file.readline())
channel_outputs16=int(file.readline())
state16=int(file.readline())
I2C_setup(address, channel_outputs1, state1)
I2C_setup(address, channel_outputs2, state2)
I2C_setup(address, channel_outputs3, state3)
I2C_setup(address, channel_outputs4, state4)
I2C_setup(address, channel_outputs5, state5)
I2C_setup(address, channel_outputs6, state6)
I2C_setup(address, channel_outputs7, state7)
I2C_setup(address, channel_outputs8, state8)
subprocess.call('./mux_channel.py 72 1', shell=True)
#time.sleep(0.1)
I2C_setup(address, channel_outputs9, state9)
I2C_setup(address, channel_outputs10, state10)
I2C_setup(address, channel_outputs11, state11)
I2C_setup(address, channel_outputs12, state12)
I2C_setup(address, channel_outputs13, state13)
I2C_setup(address, channel_outputs14, state14)
I2C_setup(address, channel_outputs15, state15)
I2C_setup(address, channel_outputs16, state16)
subprocess.call('./mux_channel.py 72 0', shell=True)
if __name__ == "__main__":
menu()

View File

@@ -0,0 +1,12 @@
#
# Questa funzione viene inviocata dalla funzione "setup_drv" ad ogni avvio di piGarden
# esegue il setup del driver recuperando gli identificativi delle schede sbp16ch usati
#
function drv_spb16ch_setup {
drv_spb16ch_boards_id_load
echo "*********** drv_spb16ch_setup: identificativi schede caricati: ${SPB16CH_USED_ID[@]}"
}

View File

@@ -0,0 +1,34 @@
#
# Inizializza i rele che gestiscono l'alimentazione per le valvole bistabili
#
# $1 identificativo relè
#
function drv_spb16ch_supply_bistable_init {
drv_spb16ch_supply_negative "$1"
}
#
# Imposta l'alimentazione delle elettrovalvole con voltaggio positivo
#
# $1 identificativo relè
#
function drv_spb16ch_supply_positive {
drv_spb16ch_rele_open "$1"
}
#
# Imposta l'alimentazione delle elettrovalvole con voltaggio negativo
#
# $1 identificativo relè
#
function drv_spb16ch_supply_negative {
drv_spb16ch_rele_close "$1"
}

View File

@@ -0,0 +1,12 @@
# Driver for check wather condition with wunderground online service
# Example of configuration in piGarden.conf
```bash
WEATHER_SERVICE="wunderground"
WUNDERGROUND_KEY="" # Set with your api key of wunderground
WUNDERGROUND_LOCATION="IY/Monsummano" # Set with your location indentify, see http://www.wunderground.com/weather/api/d/docs?d=resources/country-to-iso-matching&MR=1
```

View File

@@ -0,0 +1,12 @@
#
# Funzioni comuni utilizzate dal driver
#
#
# Funzione di esempio
#
function sample_foo {
echo "bar"
}

View File

@@ -0,0 +1,36 @@
#
# Ritorna lo stato delle condizioni meteo interrogando il servizio online
#
# $i identificativo gpio del sensore di pioggia
#
# return output: 0 - errore durante il recupero delle condizioni meteo
# >0 - rilevato pioggia, timestamp del rilevamento
# <0 - rilevato nessuna pioggia, timestamp del rilevamento
function drv_wunderground_rain_online_get {
# http://www.wunderground.com/weather/api/d/docs?d=resources/phrase-glossary&MR=1
$CURL http://api.wunderground.com/api/$WUNDERGROUND_KEY/conditions/q/$WUNDERGROUND_LOCATION.json > $TMP_PATH/check_rain_online.json
local weather=`cat $TMP_PATH/check_rain_online.json | $JQ -M ".current_observation.weather"`
local current_observation=`cat $TMP_PATH/check_rain_online.json | $JQ -M ".current_observation"`
local local_epoch=`cat $TMP_PATH/check_rain_online.json | $JQ -M -r ".current_observation.local_epoch"`
if [ "$weather" = "null" ]; then
echo "0"
else
if [[ "$weather" == *"Rain"* ]] ||
[[ "$weather" == *"Snow"* ]] ||
[[ "$weather" == *"Hail"* ]] ||
[[ "$weather" == *"Ice"* ]] ||
[[ "$weather" == *"Thunderstorm"* ]] ||
[[ "$weather" == *"Drizzle"* ]];
then
echo $local_epoch
else
echo "-$local_epoch"
fi
echo "$current_observation" > "$STATUS_DIR/last_weather_online"
fi
}

View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/cron_add_after/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/cron_add_before/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/cron_del_after/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/cron_del_before/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/ev_close_after/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/ev_close_before/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/ev_open_after/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/ev_open_before/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/ev_open_in_after/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/ev_open_in_before/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/exec_poweroff_after/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/exec_reboot_after/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/exec_reboot_before/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/init_after/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/init_before/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/scripts/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*custom*
# Except this file
!.gitignore

111
events/scripts/rpinotify.sh Executable file
View File

@@ -0,0 +1,111 @@
#!/bin/bash
#
# Send telegram notificacion on triggered event
#
# $1 = event
# $2 = cause
# $3 = time
#
# To use this script, you must get your hash. Register for the rpinotify service. Get the hash and enter it below
#
# rpinotify token
TOKEN=""
EVENT="$1"
TO="mail@destination.com"
FROM="piGarden@your_domain.com"
SUBJECT="[piGarden notification mail] event $EVENT"
BODY=""
case "$EVENT" in
"init_before" | "init_after")
TIME=$2
BODY="PiGarden triggered new event --- EVENT: $EVENT --- TIME: $(/bin/date -d@$TIME)"
;;
"ev_open_before" | "ev_open_after")
ALIAS="$2"
FORCE="$3"
TIME=$4
BODY="PiGarden triggered new event --- EVENT: $EVENT --- ZONE: $ALIAS --- FORCED IRRIGATION: $FORCE --- TIME: $(/bin/date -d@$TIME)"
;;
"ev_open_in_before")
ALIAS="$2"
FORCE="$3"
MINUTE_START="$4"
MINUTE_STOP="$5"
TIME=$6
BODY="PiGarden triggered new event --- EVENT: $EVENT --- ZONE: $ALIAS --- FORCED IRRIGATION: $FORCE --- MINUTE START: $MINUTE_START --- MINUTE STOP: $MINUTE_STOP --- TIME: $(/bin/date -d@$TIME)"
;;
"ev_open_in_after")
ALIAS="$2"
FORCE="$3"
CRON_START="$4"
CRON_STOP="$5"
TIME=$6
BODY="PiGarden triggered new event --- EVENT: $EVENT --- ZONE: $ALIAS --- FORCED IRRIGATION: $FORCE --- CRON START: $CRON_START --- CRON STOP: $CRON_STOP --- TIME: $(/bin/date -d@$TIME)"
;;
"ev_close_before" | "ev_close_after")
ALIAS="$2"
TIME=$3
BODY="PiGarden triggered new event --- EVENT: $EVENT --- ZONE: $ALIAS --- TIME: $(/bin/date -d@$TIME);"
;;
"ev_not_open_for_rain" | "ev_not_open_for_rain_online" | "ev_not_open_for_rain_sensor")
ALIAS="$2"
TIME=$3
BODY="PiGarden triggered new event --- EVENT: $EVENT --- ZONE: $ALIAS --- TIME: $(/bin/date -d@$TIME)"
;;
"check_rain_sensor_before" | "check_rain_sensor_after" | "check_rain_sensor_change")
STATE="$2"
TIME=$3
BODY="PiGarden triggered new event --- EVENT: $EVENT --- STATE: $STATE --- TIME: $(/bin/date -d@$TIME)"
;;
"check_rain_online_before")
STATE="$2"
TIME=$3
BODY="PiGarden triggered new event --- EVENT: $EVENT --- STATE: $STATE --- TIME: $(/bin/date -d@$TIME)"
;;
"check_rain_online_after" | "check_rain_online_change")
STATE="$2"
WEATHER="$3"
TIME=$4
BODY="PiGarden triggered new event --- EVENT: $EVENT --- STATE: $STATE --- WEATHER: $WEARTHER --- TIME: $(/bin/date -d@$TIME)"
;;
"cron_add_before" | "cron_add_after")
CRON_TYPE="$2"
CRON_ARG="$3"
CRON_ELEMENT="$4"
TIME=$5
BODY="PiGarden triggered new event --- EVENT: $EVENT --- CRON TYPE: $CRON_TYPE --- CRON ARG: $CRON_ARG --- CRON ELEMENT: $CRON_ELEMENT\nTIME: $(/bin/date -d@$TIME)"
;;
"cron_del_before" | "cron_del_after")
CRON_TYPE="$2"
CRON_ARG="$3"
TIME=$4
BODY="PiGarden triggered new event --- EVENT: $EVENT --- CRON TYPE: $CRON_TYPE --- CRON ARG: $CRON_ARG --- TIME: $(/bin/date -d@$TIME)"
;;
"exec_poweroff_before" | "exec_poweroff_after" | "exec_reboot_before" | "exec_reboot_after")
TIME=$2
BODY="PiGarden triggered new event --- EVENT: $EVENT --- TIME: $(/bin/date -d@$TIME)"
;;
*)
exit
;;
esac
curl -X POST -F "text=$BODY" https://api.rpinotify.it/message/$TOKEN/

120
events/scripts/sendmail.sh Executable file
View File

@@ -0,0 +1,120 @@
#!/bin/bash
#
# Send mail on triggered event
#
# $1 = event
# $2 = cause
# $3 = time
#
# To send an email with this script you must install and configure ssmtp and mailutils:
# sudo apt-get install ssmtp mailutils
#
# edit the configuration file /etc/ssmtp/ssmtp.conf and insert the below lines:
#
# root=postmaster
# mailhub=smtp.gmail.com:587
# hostname=guard
# FromLineOverride=YES
# AuthUser=your_mail@gmail.com
# AuthPass=your_password
# UseSTARTTLS=YES
#
EVENT="$1"
TO="mail@destination.com"
FROM="piGarden@your_domain.com"
SUBJECT="[piGarden notification mail] event $EVENT"
BODY=""
case "$EVENT" in
"init_before" | "init_after")
TIME=$2
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nTIME: $(/bin/date -d@$TIME)"
;;
"ev_open_before" | "ev_open_after")
ALIAS="$2"
FORCE="$3"
TIME=$4
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nZONE: $ALIAS\nFORCED IRRIGATION: $FORCE\nTIME: $(/bin/date -d@$TIME)"
;;
"ev_open_in_before")
ALIAS="$2"
FORCE="$3"
MINUTE_START="$4"
MINUTE_STOP="$5"
TIME=$6
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nZONE: $ALIAS\nFORCED IRRIGATION: $FORCE\nMINUTE START: $MINUTE_START\nMINUTE STOP: $MINUTE_STOP\nTIME: $(/bin/date -d@$TIME)"
;;
"ev_open_in_after")
ALIAS="$2"
FORCE="$3"
CRON_START="$4"
CRON_STOP="$5"
TIME=$6
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nZONE: $ALIAS\nFORCED IRRIGATION: $FORCE\nCRON START: $CRON_START\nCRON STOP: $CRON_STOP\nTIME: $(/bin/date -d@$TIME)"
;;
"ev_close_before" | "ev_close_after")
ALIAS="$2"
TIME=$3
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nZONE: $ALIAS\nTIME: $(/bin/date -d@$TIME)"
;;
"ev_not_open_for_rain" | "ev_not_open_for_rain_online" | "ev_not_open_for_rain_sensor")
ALIAS="$2"
TIME=$3
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nZONE: $ALIAS\nTIME: $(/bin/date -d@$TIME)"
;;
"check_rain_sensor_before" | "check_rain_sensor_after" | "check_rain_sensor_change")
STATE="$2"
TIME=$3
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nSTATE: $STATE\nTIME: $(/bin/date -d@$TIME)"
;;
"check_rain_online_before")
STATE="$2"
TIME=$3
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nSTATE: $STATE\nTIME: $(/bin/date -d@$TIME)"
;;
"check_rain_online_after" | "check_rain_online_change")
STATE="$2"
WEATHER="$3"
TIME=$4
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nSTATE: $STATE\nWEATHER: $WEARTHER\nTIME: $(/bin/date -d@$TIME)"
;;
"cron_add_before" | "cron_add_after")
CRON_TYPE="$2"
CRON_ARG="$3"
CRON_ELEMENT="$4"
TIME=$5
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nCRON TYPE: $CRON_TYPE\nCRON ARG: $CRON_ARG\nCRON ELEMENT: $CRON_ELEMENT\nTIME: $(/bin/date -d@$TIME)"
;;
"cron_del_before" | "cron_del_after")
CRON_TYPE="$2"
CRON_ARG="$3"
TIME=$4
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nCRON TYPE: $CRON_TYPE\nCRON ARG: $CRON_ARG\nTIME: $(/bin/date -d@$TIME)"
;;
"exec_poweroff_before" | "exec_poweroff_after" | "exec_reboot_before" | "exec_reboot_after")
TIME=$2
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nTIME: $(/bin/date -d@$TIME)"
;;
*)
exit
;;
esac
echo -e "$BODY" | /usr/bin/mail -s "$SUBJECT" $TO -r $FROM &

14
events/scripts/testevent.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
#
# Send mail on triggered event
#
# $1 = event
EVENT="$1"
P2="$2"
P3="$3"
P4="$4"
P5="$5"
echo "$(date) $EVENT $P2 $P3 $P4 $P5" >> /tmp/piGarden.testevent

View File

@@ -0,0 +1,14 @@
#!/bin/bash
#
# Send mail on triggered event
#
# $1 = event
EVENT="$1"
P2="$2"
P3="$3"
P4="$4"
P5="$5"
echo "testevent break $(date) $EVENT $P2 $P3 $P4 $P5" >> /tmp/piGarden.testevent
exit 1

565
include/cron.include.sh Normal file
View File

@@ -0,0 +1,565 @@
#
# Elimina una tipoliga di schedulazione dal crontab dell'utente
# $1 tipologia del crontab
# $2 argomento della tipologia
#
function cron_del {
local CRON_TYPE=$1
local CRON_ARG=$2
if [ -z "$CRON_TYPE" ]; then
echo "Cron type is empty" >&2
log_write "Cron type is empty"
return 1
fi
$CRONTAB -l > "$TMP_CRON_FILE"
local START=`$GREP -n "^# START cron $CRON_TYPE $CRON_ARG$" "$TMP_CRON_FILE"| $CUT -d : -f 1`
local END=`$GREP -n "^# END cron $CRON_TYPE $CRON_ARG$" "$TMP_CRON_FILE"| $CUT -d : -f 1`
local re='^[0-9]+$'
if ! [[ "$START" =~ $re ]] && ! [[ "$END" =~ $re ]] ; then
echo "$1 $2 cron is not present" >&2
return
fi
if ! [[ $START =~ $re ]] ; then
echo "Cron start don't find" >&2
log_write "Cron start don't find"
return 1
fi
if ! [[ $END =~ $re ]] ; then
echo "Cron end cron don't find" >&2
log_write "Cron end cron don't find"
return 1
fi
if [ "$START" -gt "$END" ]; then
echo "Wrong position for start and end in cron" >&2
log_write "Wrong position for start and end in cron"
return 1
fi
trigger_event "cron_del_before" "$1" "$2"
$SED "$START,${END}d" "$TMP_CRON_FILE" | $SED '$!N; /^\(.*\)\n\1$/!P; D' | $CRONTAB -
rm "$TMP_CRON_FILE"
trigger_event "cron_del_after" "$1" "$2"
}
#
# Aggiunge una schedulazione nel crontab dell'utente
# $1 tipologia del crontab
# $2 minuto
# $3 ora
# $4 giorno del mese
# $5 mese
# $6 giorno della settimana
# $7 argomento della tipologia
# $8 secondo argomento della tipologia
#
function cron_add {
local CRON_TYPE=$1
local CRON_M=$2
local CRON_H=$3
local CRON_DOM=$4
local CRON_MON=$5
local CRON_DOW=$6
local CRON_ARG=$7
local CRON_ARG2=$8
local CRON_COMMAND=""
local CRON_DISABLED=""
local PATH_SCRIPT=`$READLINK -f "$DIR_SCRIPT/$NAME_SCRIPT"`
local TMP_CRON_FILE2="$TMP_CRON_FILE-2"
if [ -z "$CRON_TYPE" ]; then
echo "Cron type is empty" >&2
log_write "Cron type is empty"
return 1
fi
$CRONTAB -l > "$TMP_CRON_FILE"
local START=`$GREP -n "^# START cron $CRON_TYPE $CRON_ARG$" "$TMP_CRON_FILE"| $CUT -d : -f 1`
local END=`$GREP -n "^# END cron $CRON_TYPE $CRON_ARG$" "$TMP_CRON_FILE"| $CUT -d : -f 1`
local re='^[0-9]+$'
local NEW_CRON=0
local PREVIUS_CONTENT=""
if ! [[ $START =~ $re ]] && ! [[ $END =~ $re ]] ; then
NEW_CRON=1
else
if ! [[ $START =~ $re ]] ; then
echo "Cron start don't find" >&2
log_write "Cron start don't find"
return 1
fi
if ! [[ $END =~ $re ]] ; then
echo "Cron end cron don't find" >&2
log_write "Cron end cron don't find"
return 1
fi
START=$(($START + 1))
END=$(($END - 1))
if [ "$START" -gt "$END" ]; then
echo "Wrong position for start and end in cron" >&2
log_write "Wrong position for start and end in cron"
return 1
fi
PREVIOUS_CONTENT=`$SED -n "$START,${END}p" "$TMP_CRON_FILE"`
fi
case "$CRON_TYPE" in
init)
CRON_M="@reboot"
CRON_H=""
CRON_DOM=""
CRON_MON=""
CRON_DOW=""
CRON_COMMAND="$PATH_SCRIPT init"
;;
start_socket_server)
CRON_M="@reboot"
CRON_H=""
CRON_DOM=""
CRON_MON=""
CRON_DOW=""
CRON_COMMAND="$PATH_SCRIPT start_socket_server force"
;;
check_rain_online)
CRON_M="*/3"
CRON_H="*"
CRON_DOM="*"
CRON_MON="*"
CRON_DOW="*"
CRON_COMMAND="$PATH_SCRIPT check_rain_online 2> /tmp/check_rain_online.err"
;;
check_rain_sensor)
CRON_M="*"
CRON_H="*"
CRON_DOM="*"
CRON_MON="*"
CRON_DOW="*"
CRON_COMMAND="$PATH_SCRIPT check_rain_sensor 2> /tmp/check_rain_sensor.err"
;;
close_all_for_rain)
CRON_M="*/5"
CRON_H="*"
CRON_DOM="*"
CRON_MON="*"
CRON_DOW="*"
CRON_COMMAND="$PATH_SCRIPT close_all_for_rain 2> /tmp/close_all_for_rain.err 1> /dev/null"
;;
open)
CRON_COMMAND="$PATH_SCRIPT open $CRON_ARG"
if [ "$CRON_ARG2" == "disabled" ]; then
CRON_DISABLED="#"
fi
;;
open_in)
CRON_COMMAND="$PATH_SCRIPT open $CRON_ARG $CRON_ARG2"
;;
open_in_stop)
CRON_COMMAND="$PATH_SCRIPT close $CRON_ARG"
;;
close)
CRON_COMMAND="$PATH_SCRIPT close $CRON_ARG"
if [ "$CRON_ARG2" == "disabled" ]; then
CRON_DISABLED="#"
fi
;;
*)
echo "Wrong cron type: $CRON_TYPE"
log_write "Wrong cron type: $CRON_TYPE"
;;
esac
if [ "$NEW_CRON" -eq "0" ]; then
START=$(($START - 1))
END=$(($END + 1))
$SED "$START,${END}d" "$TMP_CRON_FILE" > "$TMP_CRON_FILE2"
else
cat "$TMP_CRON_FILE" > "$TMP_CRON_FILE2"
fi
if [ "$NEW_CRON" -eq "1" ]; then
echo "" >> "$TMP_CRON_FILE2"
fi
echo "# START cron $CRON_TYPE $CRON_ARG" >> "$TMP_CRON_FILE2"
if [ "$NEW_CRON" -eq "0" ]; then
echo "$PREVIOUS_CONTENT" >> "$TMP_CRON_FILE2"
fi
echo "$CRON_DISABLED$CRON_M $CRON_H $CRON_DOM $CRON_MON $CRON_DOW $CRON_COMMAND" >> "$TMP_CRON_FILE2"
echo "# END cron $CRON_TYPE $CRON_ARG" >> "$TMP_CRON_FILE2"
trigger_event "cron_add_before" "$CRON_TYPE" "$CRON_ARG" "$CRON_DISABLED$CRON_M $CRON_H $CRON_DOM $CRON_MON $CRON_DOW $CRON_COMMAND"
$CRONTAB "$TMP_CRON_FILE2"
rm "$TMP_CRON_FILE" "$TMP_CRON_FILE2"
trigger_event "cron_add_after" "$CRON_TYPE" "$CRON_ARG" "$CRON_DISABLED$CRON_M $CRON_H $CRON_DOM $CRON_MON $CRON_DOW $CRON_COMMAND"
}
#
# Legge una tipoliga di schedulazione dal crontab dell'utente
# $1 tipologia del crontab
# $2 argomento della tipologia
#
function cron_get {
local CRON_TYPE=$1
local CRON_ARG=$2
if [ -z "$CRON_TYPE" ]; then
echo "Cron type is empty" >&2
log_write "Cron type is empty"
return 1
fi
$CRONTAB -l > "$TMP_CRON_FILE"
local START=`$GREP -n "^# START cron $CRON_TYPE $CRON_ARG$" "$TMP_CRON_FILE"| $CUT -d : -f 1`
local END=`$GREP -n "^# END cron $CRON_TYPE $CRON_ARG$" "$TMP_CRON_FILE"| $CUT -d : -f 1`
local re='^[0-9]+$'
local PREVIUS_CONTENT=""
if ! [[ $START =~ $re ]] && ! [[ $END =~ $re ]] ; then
PREVIUS_CONTENT=""
else
if ! [[ $START =~ $re ]] ; then
echo "Cron start don't find" >&2
log_write "Cron start don't find"
return 1
fi
if ! [[ $END =~ $re ]] ; then
echo "Cron end cron don't find" >&2
log_write "Cron end cron don't find"
return 1
fi
START=$(($START + 1))
END=$(($END - 1))
if [ "$START" -gt "$END" ]; then
echo "Wrong position for start and end in cron" >&2
log_write "Wrong position for start and end in cron"
return 1
fi
PREVIOUS_CONTENT=`$SED -n "$START,${END}p" "$TMP_CRON_FILE"`
fi
echo "$PREVIOUS_CONTENT"
}
#
# Imposta il cron di inizializzazione della centralina
#
function set_cron_init {
cron_del "init" 2> /dev/null
cron_add "init"
}
#
# Elimina il cron di inizializzazione della centralina
#
function del_cron_init {
cron_del "init"
}
#
# Imposta il cron per l'avvio del socket server
#
function set_cron_start_socket_server {
cron_del "start_socket_server" 2> /dev/null
cron_add "start_socket_server"
}
#
# Elimina il cron per l'avvio del socket server
#
function del_cron_start_socket_server {
cron_del "start_socket_server"
}
#
# Imposta il cron che esegue il controllo di presenza pioggia tramite sensore
#
function set_cron_check_rain_sensor {
cron_del "check_rain_sensor" 2> /dev/null
cron_add "check_rain_sensor"
}
#
# Elimina il cron che esegue il controllo di presenza pioggia tramite sensore
#
function del_cron_check_rain_sensor {
cron_del "check_rain_sensor"
}
#
# Imposta il cron che esegue il controllo di presenza pioggia tramite servizio online
#
function set_cron_check_rain_online {
cron_del "check_rain_online" 2> /dev/null
cron_add "check_rain_online"
}
#
# Elimina il cron che esegue il controllo di presenza pioggia tramite servizio online
#
function del_cron_check_rain_online {
cron_del "check_rain_online"
}
#
# Imposta il cron che gestisce la chiusura delle elettrovalvole in caso di pioggia
#
function set_cron_close_all_for_rain {
cron_del "close_all_for_rain" 2> /dev/null
cron_add "close_all_for_rain"
}
#
# Elimina il cron che gestisce la chiusura delle elettrovalvole in caso di pioggia
#
function del_cron_close_all_for_rain {
cron_del "close_all_for_rain"
}
#
# Aggiunge una schedulazione cron per aprire una elettrovalvola
# $1 alias elettrovalvola
# $2 minuto cron
# $3 ora cron
# $4 giorno del mese cron
# $5 mese cron
# $6 giorno della settimana cron
# $7 disabled
#
function add_cron_open {
local exists=`alias_exists $1`
if [ "check $exists" = "check FALSE" ]; then
log_write "Alias $1 not found"
echo "Alias $1 not found"
return 1
fi
cron_add "open" "$2" "$3" "$4" "$5" "$6" "$1" "$7"
}
#
# Cancella tutte le schedulazioni cron per aprire una elettrovalvola
# $1 alias elettrovalvola
#
function del_cron_open {
local exists=`alias_exists $1`
if [ "check $exists" = "check FALSE" ]; then
log_write "Alias $1 not found"
echo "Alias $1 not found"
return 1
fi
cron_del "open" $1
}
#
# Legge tutte le schedulazioni cron per aprire una elettrovalvola
# $1 alias elettrovalvola
#
function get_cron_open {
local exists=`alias_exists $1`
if [ "check $exists" = "check FALSE" ]; then
log_write "Alias $1 not found"
echo "Alias $1 not found"
return 1
fi
cron_get "open" $1
}
#
# Cancella tutte le schedulazioni cron per aprire/chiudere una elettrovalvola in modo ritardato
# $1 alias elettrovalvola
#
function del_cron_open_in {
local exists=`alias_exists $1`
if [ "check $exists" = "check FALSE" ]; then
log_write "Alias $1 not found"
echo "Alias $1 not found"
return 1
fi
cron_del "open_in" $1
cron_del "open_in_stop" $1
}
#
# Legge tutte le schedulazioni cron per chiudere una elettrovalvola
# $1 alias elettrovalvola
#
function get_cron_close {
local exists=`alias_exists $1`
if [ "check $exists" = "check FALSE" ]; then
log_write "Alias $1 not found"
echo "Alias $1 not found"
return 1
fi
cron_get "close" $1
}
#
# Aggiunge una schedulazione cron per chiudere una elettrovalvola
# $1 alias elettrovalvola
# $2 minuto cron
# $3 ora cron
# $4 giorno del mese cron
# $5 mese cron
# $6 giorno della settimana cron
# $7 disabled
#
function add_cron_close {
local exists=`alias_exists $1`
if [ "check $exists" = "check FALSE" ]; then
log_write "Alias $1 not found"
echo "Alias $1 not found"
return 1
fi
cron_add "close" "$2" "$3" "$4" "$5" "$6" "$1" "$7"
}
#
# Cancella tutte le schedulazioni cron per chiudere una elettrovalvola
# $1 alias elettrovalvola
#
function del_cron_close {
local exists=`alias_exists $1`
if [ "check $exists" = "check FALSE" ]; then
log_write "Alias $1 not found"
echo "Alias $1 not found"
return 1
fi
cron_del "close" $1
}
#
# Disabilita tutte le schedulazioni di apertura e chiusura elettrovalvole
#
function cron_disable_all_open_close {
local a=""
local al=""
local cron=""
#
# Disabilita tutte le schedulazioni di apertura
#
for i in $(seq $EV_TOTAL)
do
a=EV"$i"_ALIAS
al=${!a}
local crons=`get_cron_open $al`
if [[ ! -z "$crons" ]]; then
del_cron_open $al
IFS=$'\n' # make newlines the only separator
for cron in $crons
do
#echo "-- $cron --"
CRON_M=`echo $cron | $CUT -d' ' -f1,1`
CRON_H=`echo $cron | $CUT -d' ' -f2,2`
CRON_DOM=`echo $cron | $CUT -d' ' -f3,3`
CRON_MON=`echo $cron | $CUT -d' ' -f4,4`
CRON_DOW=`echo $cron | $CUT -d' ' -f5,5`
if [[ ${CRON_M:0:1} == "#" ]]; then
CRON_M=${CRON_M:1:${#CRON_M}}
fi
#echo "++ $CRON_M $CRON_H $CRON_DOM $CRON_MON $CRON_DOW ++"
add_cron_open $al "$CRON_M" "$CRON_H" "$CRON_DOM" "$CRON_MON" "$CRON_DOW" "disabled"
done
fi
done
#
# Disabilita tutte le schedulazioni di chiusura
#
for i in $(seq $EV_TOTAL)
do
a=EV"$i"_ALIAS
al=${!a}
local crons=`get_cron_close $al`
if [[ ! -z "$crons" ]]; then
del_cron_close $al
IFS=$'\n' # make newlines the only separator
for cron in $crons
do
#echo "-- $cron --"
CRON_M=`echo $cron | $CUT -d' ' -f1,1`
CRON_H=`echo $cron | $CUT -d' ' -f2,2`
CRON_DOM=`echo $cron | $CUT -d' ' -f3,3`
CRON_MON=`echo $cron | $CUT -d' ' -f4,4`
CRON_DOW=`echo $cron | $CUT -d' ' -f5,5`
if [[ ${CRON_M:0:1} == "#" ]]; then
CRON_M=${CRON_M:1:${#CRON_M}}
fi
#echo "++ $CRON_M $CRON_H $CRON_DOM $CRON_MON $CRON_DOW ++"
add_cron_close $al "$CRON_M" "$CRON_H" "$CRON_DOM" "$CRON_MON" "$CRON_DOW" "disabled"
done
fi
done
}

344
include/drv.include.sh Normal file
View File

@@ -0,0 +1,344 @@
declare -a list_drv
function setup_drv {
#declare -a list_drv
list_drv=()
# Inizializza i driver per le elettrovalvole
for i in $(seq $EV_TOTAL)
do
local a=EV"$i"_GPIO
local gpio="${!a}"
if [[ "$gpio" == drv:* ]]; then
local drv=`echo $gpio | $CUT -d':' -f2,2`
if [[ ! " ${list_drv[@]} " =~ " ${drv} " ]]; then
list_drv+=("$drv")
fi
fi
done
# Inizializza i driver per gli altri gpio
for gpio in "$SUPPLY_GPIO_1" "$SUPPLY_GPIO_2" "$RAIN_GPIO" "$WEATHER_SERVICE"
do
if [[ "$gpio" == drv:* ]]; then
local drv=`echo $gpio | $CUT -d':' -f2,2`
if [[ ! " ${list_drv[@]} " =~ " ${drv} " ]]; then
list_drv+=("$drv")
fi
fi
done
local file_drv
for drv in "${list_drv[@]}"
do
for callback in config common init rele supply rainsensor rainonline setup
do
file_drv="$DIR_SCRIPT/drv/$drv/$callback.include.sh"
if [ -f "$file_drv" ]; then
#drv_avalible[$drv]="${drv_avalible[$drv]}#$callback#"
#echo ${drv_avalible[$drv]}
. "$file_drv"
if [ $callback == "setup" ]; then
local fnc="drv_${drv}_setup"
echo "$(date) $fnc" >> "$LOG_OUTPUT_DRV_FILE"
$fnc >> "$LOG_OUTPUT_DRV_FILE" 2>&1
fi
fi
done
done
}
#
# Restituisce in output il nome del driver callback function da richiamare per una specifica funzione
#
# $1 nome della funzione per il quale si vuore recuperare la callback
# $2 idetificativo del driver
function get_driver_callback {
local fnc="$1"
local idx="$2"
local ret=""
if [[ "$idx" == drv:* ]]; then
local drv=`echo $idx | $CUT -d':' -f2,2`
if [[ ! " ${list_drv[@]} " =~ " ${drv} " ]]; then
ret="drvnotfound"
else
ret="drv_${drv}_${fnc}"
fi
fi
echo "$ret"
}
#
# Inizializza un relè e lo porta nello stato aperto
#
# $1 identificativo relè da inizializzare
#
function drv_rele_init {
local idx="$1"
local fnc=`get_driver_callback "rele_init" "$idx"`
# Nessun driver definito, esegue la chiusura del relè tramite gpio del raspberry
if [ -z "$fnc" ]; then
$GPIO -g write $idx $RELE_GPIO_OPEN # chiude l'alimentazione all'elettrovalvole
$GPIO -g mode $idx out # setta il gpio nella modalita di scrittura
# Il driver definito non è stato trovato
elif [ "$fnc" == "drvnotfound" ]; then
log_write "Driver not found: $idx"
message_write "warning" "Driver not found: $idx"
else
echo "$(date) $fnc arg:$idx" >> "$LOG_OUTPUT_DRV_FILE"
$fnc "$idx" >> "$LOG_OUTPUT_DRV_FILE" 2>&1
fi
}
#
# Chiude un relè
#
# $1 identificativo relè da chiudere
#
function drv_rele_close {
local idx="$1"
local fnc=`get_driver_callback "rele_close" "$idx"`
# Nessun driver definito, esegue la chiusura del relè tramite gpio del raspberry
if [ -z "$fnc" ]; then
$GPIO -g write $idx $RELE_GPIO_CLOSE
# Il driver definito non è stato trovato
elif [ "$fnc" == "drvnotfound" ]; then
log_write "Driver not found: $idx"
message_write "warning" "Driver not found: $idx"
return 1
else
echo "$(date) $fnc arg:$idx" >> "$LOG_OUTPUT_DRV_FILE"
$fnc "$idx" >> "$LOG_OUTPUT_DRV_FILE" 2>&1
if [ $? -eq 1 ]; then
return 1
fi
fi
}
#
# Apre un relè
#
# $1 identificativo relè da aprire
#
function drv_rele_open {
local idx="$1"
local fnc=`get_driver_callback "rele_open" "$idx"`
# Nessun driver definito, esegue la chiusura del relè tramite gpio del raspberry
if [ -z "$fnc" ]; then
$GPIO -g write $idx $RELE_GPIO_OPEN
# Il driver definito non è stato trovato
elif [ "$fnc" == "drvnotfound" ]; then
log_write "Driver not found: $idx"
message_write "warning" "Driver not found: $idx"
return 1
else
echo "$(date) $fnc arg:$idx" >> "$LOG_OUTPUT_DRV_FILE"
$fnc "$idx" >> "$LOG_OUTPUT_DRV_FILE" 2>&1
if [ $? -eq 1 ]; then
return 1
fi
fi
}
#
# Inizializza i rele che gestiscono l'alimentazione per le valvole bistabili
#
# $1 identificativo relè 1
# $2 identificativo relè 2
#
function drv_supply_bistable_init {
local idx1=$1
local idx2=$2
local fnc1=`get_driver_callback "supply_bistable_init" "$idx1"`
local fnc2=`get_driver_callback "supply_bistable_init" "$idx2"`
# Nessun driver definito, esegue l'operazione tramite gpio del raspberry
if [ -z "$fnc1" ]; then
$GPIO -g write $idx1 0
$GPIO -g mode $idx1 out
# Il driver definito non è stato trovato
elif [ "$fnc1" == "drvnotfound" ]; then
log_write "Driver not found: $idx1"
message_write "warning" "Driver not found: $idx1"
return
else
echo "$(date) $fnc1 arg:$idx1" >> "$LOG_OUTPUT_DRV_FILE"
$fnc1 "$idx1" >> "$LOG_OUTPUT_DRV_FILE" 2>&1
fi
# Nessun driver definito, esegue l'operazione tramite gpio del raspberry
if [ -z "$fnc2" ]; then
$GPIO -g write $idx2 0
$GPIO -g mode $idx2 out
# Il driver definito non è stato trovato
elif [ "$fnc2" == "drvnotfound" ]; then
log_write "Driver not found: $idx2"
message_write "warning" "Driver not found: $idx2"
else
echo "$(date) $fnc2 arg:$idx2" >> "$LOG_OUTPUT_DRV_FILE"
$fnc2 "$idx2" >> "$LOG_OUTPUT_DRV_FILE" 2>&1
fi
}
#
# Imposta la tensine positiva per le elettrovalvole bistabili
#
# $1 identificativo rele 1
# $2 identificativo rele 2
#
function drv_supply_positive {
local idx1=$1
local idx2=$2
local fnc1=`get_driver_callback "supply_positive" "$idx1"`
local fnc2=`get_driver_callback "supply_positive" "$idx2"`
# Nessun driver definito, esegue l'operazione tramite gpio del raspberry
if [ -z "$fnc1" ]; then
$GPIO -g write $idx1 $SUPPLY_GPIO_POS
# Il driver definito non è stato trovato
elif [ "$fnc1" == "drvnotfound" ]; then
log_write "Driver not found: $idx1"
message_write "warning" "Driver not found: $idx1"
return
else
echo "$(date) $fnc1 arg:$idx1" >> "$LOG_OUTPUT_DRV_FILE"
$fnc1 "$idx1" >> "$LOG_OUTPUT_DRV_FILE" 2>&1
fi
# Nessun driver definito, esegue l'operazione tramite gpio del raspberry
if [ -z "$fnc2" ]; then
$GPIO -g write $idx2 $SUPPLY_GPIO_POS
# Il driver definito non è stato trovato
elif [ "$fnc2" == "drvnotfound" ]; then
log_write "Driver not found: $idx2"
message_write "warning" "Driver not found: $idx2"
else
echo "$(date) $fnc2 arg:$idx2" >> "$LOG_OUTPUT_DRV_FILE"
$fnc2 "$idx2" >> "$LOG_OUTPUT_DRV_FILE" 2>&1
fi
}
#
# Imposta la tensine neagativa per le elettrovalvole bistabili
#
# $1 identificativo rele 1
# $2 identificativo rele 2
#
function drv_supply_negative {
local idx1=$1
local idx2=$2
local fnc1=`get_driver_callback "supply_negative" "$idx1"`
local fnc2=`get_driver_callback "supply_negative" "$idx2"`
# Nessun driver definito, esegue l'operazione tramite gpio del raspberry
if [ -z "$fnc1" ]; then
$GPIO -g write $idx1 $SUPPLY_GPIO_NEG
# Il driver definito non è stato trovato
elif [ "$fnc1" == "drvnotfound" ]; then
log_write "Driver not found: $idx1"
message_write "warning" "Driver not found: $idx1"
return
else
echo "$(date) $fnc1 arg:$idx1" >> "$LOG_OUTPUT_DRV_FILE"
$fnc1 "$idx1" >> "$LOG_OUTPUT_DRV_FILE" 2>&1
fi
# Nessun driver definito, esegue l'operazione tramite gpio del raspberry
if [ -z "$fnc2" ]; then
$GPIO -g write $idx2 $SUPPLY_GPIO_NEG
# Il driver definito non è stato trovato
elif [ "$fnc2" == "drvnotfound" ]; then
log_write "Driver not found: $idx2"
message_write "warning" "Driver not found: $idx2"
else
echo "$(date) $fnc2 arg:$idx2" >> "$LOG_OUTPUT_DRV_FILE"
$fnc2 "$idx2" >> "$LOG_OUTPUT_DRV_FILE" 2>&1
fi
}
#
# Inizializza il sensore della pioggia
#
# $1 identificativo gpio sensore pioggia
#
function drv_rain_sensor_init {
local idx="$1"
local fnc=`get_driver_callback "rain_sensor_init" "$idx"`
local vret=""
# Nessun driver definito, esegue la lettura del sensore tramite gpio del raspberry
if [ -z "$fnc" ]; then
$GPIO -g mode $idx in
# Il driver definito non è stato trovato
elif [ "$fnc" == "drvnotfound" ]; then
log_write "Driver not found: $idx"
message_write "warning" "Driver not found: $idx"
else
echo "$(date) $fnc arg:$idx" >> "$LOG_OUTPUT_DRV_FILE"
$fnc "$idx" >> "$LOG_OUTPUT_DRV_FILE" 2>&1
fi
}
#
# Legge lo stato del sensore della pioggia
#
# $1 identificativo gpio sensore pioggia
#
function drv_rain_sensor_get {
local idx="$1"
local fnc=`get_driver_callback "rain_sensor_get" "$idx"`
local vret=""
# Nessun driver definito, esegue la lettura del sensore tramite gpio del raspberry
if [ -z "$fnc" ]; then
vret=`$GPIO -g read $idx`
# Il driver definito non è stato trovato
elif [ "$fnc" == "drvnotfound" ]; then
log_write "Driver not found: $idx"
message_write "warning" "Driver not found: $idx"
else
echo "$(date) $fnc arg:$idx" >> "$LOG_OUTPUT_DRV_FILE"
vret=`$fnc "$idx"`
fi
echo "$vret"
}
#
# Legge lo stato le condizioni meteo dal servizio online
#
# $1 identificativo gpio sensore pioggia
#
function drv_rain_online_get {
local idx="$1"
local fnc=`get_driver_callback "rain_online_get" "$idx"`
local vret=""
# Nessun driver definito, esegue la lettura del sensore tramite gpio del raspberry
if [ -z "$fnc" ]; then
log_write "Driver not found: $idx"
message_write "warning" "Driver not found: $idx"
# Il driver definito non è stato trovato
elif [ "$fnc" == "drvnotfound" ]; then
log_write "Driver not found: $idx"
message_write "warning" "Driver not found: $idx"
else
echo "$(date) $fnc arg:$idx" >> "$LOG_OUTPUT_DRV_FILE"
vret=`$fnc "$idx"`
fi
echo "$vret"
}

103
include/events.include.sh Normal file
View File

@@ -0,0 +1,103 @@
#
# Triggered an event and executge associated scripts
# $1 event
#
function trigger_event {
local EVENT="$1"
local CAUSE="$2"
local current_event_dir="$EVENT_DIR/$EVENT"
if [ -d "$current_event_dir" ]; then
local FILES="$current_event_dir/*"
for f in $FILES
do
if [ -x "$f" ]; then
case "$EVENT" in
"ev_open_before" | "ev_open_after")
ALIAS="$2"
FORCE="$3"
$f "$EVENT" "$ALIAS" "$FORCE" `date +%s` &> /dev/null
;;
"ev_open_in_before")
ALIAS="$2"
FORCE="$3"
local MINUTE_START="$4"
local MINUTE_STOP="$5"
$f "$EVENT" "$ALIAS" "$FORCE" "$MINUTE_START" "$MINUTE_STOP" `date +%s` &> /dev/null
;;
"ev_open_in_after")
ALIAS="$2"
FORCE="$3"
local CRON_START="$4"
local CRON_STOP="$5"
$f "$EVENT" "$ALIAS" "$FORCE" "$CRON_START" "$CRON_STOP" `date +%s` &> /dev/null
;;
"ev_close_before" | "ev_close_after")
ALIAS="$2"
$f "$EVENT" "$ALIAS" `date +%s` &> /dev/null
;;
"check_rain_sensor_before" | "check_rain_sensor_after" | "check_rain_sensor_change")
STATE="$2"
$f "$EVENT" "$STATE" `date +%s` &> /dev/null
;;
"check_rain_online_before")
STATE="$2"
$f "$EVENT" "$STATE" `date +%s` &> /dev/null
;;
"check_rain_online_after" | "check_rain_online_change")
STATE="$2"
WEATHER="$3"
$f "$EVENT" "$STATE" "$WEATHER" `date +%s` &> /dev/null
;;
"init_before" | "init_after")
STATE="$2"
$f "$EVENT" `date +%s` &> /dev/null
;;
"cron_add_before" | "cron_add_after")
local CRON_TYPE="$2"
local CRON_ARG="$3"
local CRON_ELEMENT="$4"
$f "$EVENT" "$CRON_TYPE" "$CRON_ARG" "$CRON_ELEMENT" `date +%s` &> /dev/null
;;
"cron_del_before" | "cron_del_after")
local CRON_TYPE="$2"
local CRON_ARG="$3"
$f "$EVENT" "$CRON_TYPE" "$CRON_ARG" `date +%s` &> /dev/null
;;
"exec_poweroff_before" | "exec_poweroff_after" | "exec_reboot_before" | "exec_reboot_after" )
$f "$EVENT" `date +%s` &> /dev/null
;;
*)
$f "$EVENT" "$CAUSE" `date +%s` &> /dev/null
;;
esac
local ec=$?
#echo "$EVENT ec=$ec" >> /tmp/piGarden.testevent
if [ $ec -ne 0 ]; then
log_write "Stop events chain for exit code $ec in $current_event_dir/$f"
return $ec
fi
fi
done
fi
}

171
include/rain.include.sh Normal file
View File

@@ -0,0 +1,171 @@
#
# Controlla se se piove tramite http://api.wunderground.com/
#
function check_rain_online_old {
trigger_event "check_rain_online_before" ""
# http://www.wunderground.com/weather/api/d/docs?d=resources/phrase-glossary&MR=1
$CURL http://api.wunderground.com/api/$WUNDERGROUND_KEY/conditions/q/$WUNDERGROUND_LOCATION.json > $TMP_PATH/check_rain_online.json
local weather=`cat $TMP_PATH/check_rain_online.json | $JQ -M ".current_observation.weather"`
local current_observation=`cat $TMP_PATH/check_rain_online.json | $JQ -M ".current_observation"`
local local_epoch=`cat $TMP_PATH/check_rain_online.json | $JQ -M -r ".current_observation.local_epoch"`
local current_state_rain_online=""
local last_state_rain_online=`cat "$STATUS_DIR/last_state_rain_online" 2> /dev/null`
#echo $weather
#weather="[Light/Heavy] Drizzle"
if [ "$weather" = "null" ]; then
log_write "check_rain_online - failed read online data"
else
log_write "check_rain_online - weather=$weather, local_epoch=$local_epoch"
#if [[ "$weather" == *"Clear"* ]]; then
#if [[ "$weather" == *"Rain"* ]]; then
if [[ "$weather" == *"Rain"* ]] ||
[[ "$weather" == *"Snow"* ]] ||
[[ "$weather" == *"Hail"* ]] ||
[[ "$weather" == *"Ice"* ]] ||
[[ "$weather" == *"Thunderstorm"* ]] ||
[[ "$weather" == *"Drizzle"* ]];
then
current_state_rain_online='rain'
echo $local_epoch > "$STATUS_DIR/last_rain_online"
else
current_state_rain_online='norain'
fi
echo "$current_observation" > "$STATUS_DIR/last_weather_online"
if [ "$current_state_rain_online" != "$last_state_rain_online" ]; then
echo "$current_state_rain_online" > "$STATUS_DIR/last_state_rain_online"
trigger_event "check_rain_online_change" "$current_state_rain_online" "$weather"
fi
fi
trigger_event "check_rain_online_after" "$current_state_rain_online" "$weather"
}
#
# Controlla se se piove tramite http://api.wunderground.com/
#
function check_rain_online {
trigger_event "check_rain_online_before" ""
local local_epoch=`drv_rain_online_get $WEATHER_SERVICE`
local current_state_rain_online=""
local last_state_rain_online=`cat "$STATUS_DIR/last_state_rain_online" 2> /dev/null`
local weather="null"
if [[ $local_epoch =~ ^-?[0-9]+$ ]]; then
if [ $local_epoch -eq 0 ]; then
log_write "check_rain_online - failed read online data"
else
if [ $local_epoch -gt 0 ]; then
current_state_rain_online='rain'
echo $local_epoch > "$STATUS_DIR/last_rain_online"
else
current_state_rain_online='norain'
fi
weather=$(cat "$STATUS_DIR/last_weather_online" | $JQ -M ".weather")
log_write "check_rain_online - weather=$weather, local_epoch=$local_epoch"
if [ "$current_state_rain_online" != "$last_state_rain_online" ]; then
echo "$current_state_rain_online" > "$STATUS_DIR/last_state_rain_online"
trigger_event "check_rain_online_change" "$current_state_rain_online" "$weather"
fi
fi
else
log_write "check_rain_online - failed read online data"
fi
trigger_event "check_rain_online_after" "$current_state_rain_online" "$weather"
}
#
# Controlla se se piove tramite sensore
#
function check_rain_sensor {
if [ -n "$RAIN_GPIO" ]; then
trigger_event "check_rain_sensor_before" ""
local current_state_rain_sensor=""
local last_state_rain_sensor=`cat "$STATUS_DIR/last_state_rain_sensor" 2> /dev/null`
local s=`drv_rain_sensor_get $RAIN_GPIO`
if [ "$s" = "$RAIN_GPIO_STATE" ]; then
current_state_rain_sensor='rain'
local local_epoch=`date +%s`
echo $local_epoch > "$STATUS_DIR/last_rain_sensor"
log_write "check_rain_sensor - now it's raining ($local_epoch)"
#return $local_epoch
else
current_state_rain_sensor='norain'
log_write "check_rain_sensor - now is not raining"
fi
if [ "$current_state_rain_sensor" != "$last_state_rain_sensor" ]; then
echo "$current_state_rain_sensor" > "$STATUS_DIR/last_state_rain_sensor"
trigger_event "check_rain_sensor_change" "$current_state_rain_sensor"
fi
trigger_event "check_rain_sensor_after" "$current_state_rain_sensor"
else
log_write "Rain sensor not present"
fi
}
#
# Chiude tutte le elettrovalvole se sta piovendo
# Eseguie il controllo in tempo reale sul sensore hardware e sui dati dell'ultima chiamata eseguita online
#
function close_all_for_rain {
local close_all=0
local now=`date +%s`
if [[ "$NOT_IRRIGATE_IF_RAIN_ONLINE" -gt 0 && -f $STATUS_DIR/last_rain_online ]]; then
local last_rain=`cat $STATUS_DIR/last_rain_online`
local dif=0
let "dif = now - last_rain"
if [ $dif -lt $NOT_IRRIGATE_IF_RAIN_ONLINE ]; then
close_all=1
fi
fi
if [[ "$NOT_IRRIGATE_IF_RAIN_SENSOR" -gt 0 && -f $STATUS_DIR/last_rain_sensor ]]; then
local last_rain=`cat $STATUS_DIR/last_rain_sensor`
local dif=0
let "dif = now - last_rain"
if [ $dif -lt $NOT_IRRIGATE_IF_RAIN_SENSOR ]; then
close_all=1
fi
fi
if [ "$close_all" = "1" ]; then
for i in $(seq $EV_TOTAL)
do
local a=EV"$i"_ALIAS
local al=${!a}
local a=EV"$i"_NORAIN
local evnorain=${!a}
ev_status $al
local state=$?
#echo "$al = $state"
if [ "$state" = "1" ] && [ "$evnorain" != "1" ]; then
ev_close $al
log_write "close_all_for_rain - Close solenoid '$al' for rain"
fi
done
fi
}

232
include/socket.include.sh Normal file
View File

@@ -0,0 +1,232 @@
#
# Avvia il socket server
#
function start_socket_server {
rm -f "$TCPSERVER_PID_FILE"
echo $TCPSERVER_PID_SCRIPT > "$TCPSERVER_PID_FILE"
$TCPSERVER -v -RHl0 $TCPSERVER_IP $TCPSERVER_PORT $0 socket_server_command
}
#
# Ferma il socket server
#
function stop_socket_server {
if [ ! -f "$TCPSERVER_PID_FILE" ]; then
echo "Daemon is not running"
exit 1
fi
log_write "stop socket server"
kill -9 $(list_descendants `cat "$TCPSERVER_PID_FILE"`) 2> /dev/null
kill -9 `cat "$TCPSERVER_PID_FILE"` 2> /dev/null
rm -f "$TCPSERVER_PID_FILE"
}
#
# Esegue un comando ricevuto dal socket server
#
function socket_server_command {
RUN_FROM_TCPSERVER=1
local line=""
if [ ! -z "$TCPSERVER_USER" ] && [ ! -z "$TCPSERVER_PWD" ]; then
local user=""
local password=""
read -t 3 user
read -t 3 password
user=$(echo "$user" | $TR -d '[\r\n]')
password=$(echo "$password" | $TR -d '[\r\n]')
if [ "$user" != "$TCPSERVER_USER" ] || [ "$password" != "$TCPSERVER_PWD" ]; then
log_write "socket connection from: $TCPREMOTEIP - Bad socket server credentials - user:$user"
json_error 0 "Bad socket server credentials"
return
fi
fi
read line
line=$(echo "$line " | $TR -d '[\r\n]')
arg1=$(echo "$line " | $CUT -d ' ' -f1)
arg2=$(echo "$line " | $CUT -d ' ' -f2)
arg3=$(echo "$line " | $CUT -d ' ' -f3)
arg4=$(echo "$line " | $CUT -d ' ' -f4)
arg5=$(echo "$line " | $CUT -d ' ' -f5)
arg6=$(echo "$line " | $CUT -d ' ' -f6)
arg7=$(echo "$line " | $CUT -d ' ' -f7)
arg8=$(echo "$line " | $CUT -d ' ' -f8)
log_write "socket connection from: $TCPREMOTEIP - command: $arg1 $arg2 $arg3 $arg4 $arg5 $arg6 $arg7 $arg8"
reset_messages &> /dev/null
case "$arg1" in
status)
json_status $arg2 $arg3 $arg4 $arg5 $arg6 $arg7
;;
open)
if [ "empty$arg2" == "empty" ]; then
json_error 0 "Alias solenoid not specified"
else
ev_open $arg2 $arg3 &> /dev/null
json_status "get_cron_open_in:$arg2"
fi
;;
open_in)
ev_open_in $arg2 $arg3 $arg4 $arg5 &> /dev/null
json_status "get_cron_open_in:$arg4"
;;
close)
if [ "empty$arg2" == "empty" ]; then
json_error 0 "Alias solenoid not specified"
else
ev_close $arg2 &> /dev/null
json_status "get_cron_open_in:$arg2"
fi
;;
close_all)
if [ "$arg2" == "disable_scheduling" ]; then
cron_disable_all_open_close &> /dev/null
fi
close_all &> /dev/null
message_write "success" "All solenoid closed"
json_status
;;
set_general_cron)
local vret=""
for i in $arg2 $arg3 $arg4 $arg5 $arg6 $arg7
do
if [ $i = "set_cron_init" ]; then
vret="$(vret)`set_cron_init`"
elif [ $i = "set_cron_start_socket_server" ]; then
vret="$(vret)`set_cron_start_socket_server`"
elif [ $i = "set_cron_check_rain_sensor" ]; then
vret="$(vret)`set_cron_check_rain_sensor`"
elif [ $i = "set_cron_check_rain_online" ]; then
vret="$(vret)`set_cron_check_rain_online`"
elif [ $i = "set_cron_close_all_for_rain" ]; then
vret="$(vret)`set_cron_close_all_for_rain`"
fi
done
if [[ ! -z $vret ]]; then
json_error 0 "Cron set failed"
log_write "Cron set failed: $vret"
else
message_write "success" "Cron set successfull"
json_status
fi
;;
del_cron_open)
local vret=""
vret=`del_cron_open $arg2`
if [[ ! -z $vret ]]; then
json_error 0 "Cron set failed"
log_write "Cron del failed: $vret"
else
message_write "success" "Cron set successfull"
json_status
fi
;;
del_cron_open_in)
local vret=""
vret=`del_cron_open_in $arg2`
if [[ ! -z $vret ]]; then
json_error 0 "Cron del failed"
log_write "Cron del failed: $vret"
else
message_write "success" "Scheduled start successfully deleted"
json_status "get_cron_open_in:$arg2"
fi
;;
del_cron_close)
local vret=""
vret=`del_cron_close $arg2`
if [[ ! -z $vret ]]; then
json_error 0 "Cron set failed"
log_write "Cron set failed: $vret"
else
message_write "success" "Cron set successfull"
json_status
fi
;;
add_cron_open)
local vret=""
vret=`add_cron_open "$arg2" "$arg3" "$arg4" "$arg5" "$arg6" "$arg7" $arg8`
if [[ ! -z $vret ]]; then
json_error 0 "Cron set failed"
log_write "Cron set failed: $vret"
else
message_write "success" "Cron set successfull"
json_status
fi
;;
add_cron_close)
local vret=""
vret=`add_cron_close "$arg2" "$arg3" "$arg4" "$arg5" "$arg6" "$arg7" $arg8`
if [[ ! -z $vret ]]; then
json_error 0 "Cron set failed"
log_write "Cron set failed: $vret"
else
message_write "success" "Cron set successfull"
json_status
fi
;;
reboot)
message_write "warning" "System reboot is started"
json_status
local PATH_SCRIPT=`$READLINK -f "$DIR_SCRIPT/$NAME_SCRIPT"`
nohup $PATH_SCRIPT reboot > /dev/null 2>&1 &
;;
poweroff)
message_write "warning" "System shutdown is started"
json_status
local PATH_SCRIPT=`$READLINK -f "$DIR_SCRIPT/$NAME_SCRIPT"`
nohup $PATH_SCRIPT poweroff > /dev/null 2>&1 &
;;
*)
json_error 0 "invalid command"
;;
esac
reset_messages &> /dev/null
}

View File

@@ -0,0 +1,96 @@
EESchema-LIBRARY Version 2.3
#encoding utf-8
#
# +9V
#
DEF +9V #PWR 0 0 Y Y 1 F P
F0 "#PWR" 0 -150 50 H I C CNN
F1 "+9V" 0 140 50 H V C CNN
F2 "" 0 0 60 H V C CNN
F3 "" 0 0 60 H V C CNN
DRAW
P 2 0 1 0 -30 50 0 100 N
P 2 0 1 0 0 0 0 100 N
P 2 0 1 0 0 100 30 50 N
X +9V 1 0 0 0 U 50 50 1 1 W N
ENDDRAW
ENDDEF
#
# GPIO-Rev.2.0
#
DEF GPIO-Rev.2.0 P 0 40 Y Y 1 F N
F0 "P" 500 -800 60 H V C CNN
F1 "GPIO-Rev.2.0" 200 600 60 H V C CNN
F2 "" 0 0 79 H V C CNN
F3 "" 0 0 79 H V C CNN
DRAW
S -600 550 550 -750 0 1 0 N
X 3V3 1 -900 500 300 R 50 50 1 1 w
X 5V 2 850 500 300 L 50 50 1 1 w
X GPIO2/SDA 3 -900 400 300 R 50 50 1 1 B
X 5V 4 850 400 300 L 50 50 1 1 w
X GPIO3/SCL 5 -900 300 300 R 50 50 1 1 B
X GND 6 850 300 300 L 50 50 1 1 w
X GPIO4/1-WIRE 7 -900 200 300 R 50 50 1 1 B
X TXD/GPIO14 8 850 200 300 L 50 50 1 1 B
X GND 9 -900 100 300 R 50 50 1 1 w
X RXD/GPIO15 10 850 100 300 L 50 50 1 1 B
X GND 20 850 -400 300 L 50 50 1 1 B
X GPIO17 11 -900 0 300 R 50 50 1 1 B
X GPIO9/MISO 21 -900 -500 300 R 50 50 1 1 B
X GPIO18 12 850 0 300 L 50 50 1 1 B
X GPIO25 22 850 -500 300 L 50 50 1 1 B
X GPIO27 13 -900 -100 300 R 50 50 1 1 B
X GPIO11/SCLK 23 -900 -600 300 R 50 50 1 1 B
X GND 14 850 -100 300 L 50 50 1 1 w
X GPIO8/CE0 24 850 -600 300 L 50 50 1 1 B
X GPIO22 15 -900 -200 300 R 50 50 1 1 B
X GND 25 -900 -700 300 R 50 50 1 1 w
X GPIO23 16 850 -200 300 L 50 50 1 1 B
X GPIO7/CE1 26 850 -700 300 L 50 50 1 1 B
X 3V3 17 -900 -300 300 R 50 50 1 1 w
X GPIO24 18 850 -300 300 L 50 50 1 1 B
X GPIO10/MOSI 19 -900 -400 300 R 50 50 1 1 B
ENDDRAW
ENDDEF
#
# STABI
#
DEF STABI U 0 0 Y Y 1 F N
F0 "U" 200 225 50 H V C CNN
F1 "STABI" 225 -225 50 H V C CNN
F2 "VALVE-MINI_P" 0 150 50 H I C CNN
F3 "" 0 0 79 H V C CNN
DRAW
P 2 1 0 0 0 -100 0 -200 N
P 2 1 0 0 0 200 0 100 N
C 0 0 200 1 1 6 N
C 131 -24 20 1 1 0 F
P 2 1 1 6 0 -100 0 -200 N
P 2 1 1 6 0 200 0 100 N
P 3 1 1 10 -100 -100 100 -100 100 -100 N
P 4 1 1 10 -100 100 100 100 100 100 100 100 N
X A 3 0 -300 100 U 40 40 1 1 P
X K 7 0 300 100 D 40 40 1 1 P
ENDDRAW
ENDDEF
#
# SWITCH_INV
#
DEF SWITCH_INV SW 0 0 N Y 1 F N
F0 "SW" -200 150 50 H V C CNN
F1 "SWITCH_INV" -150 -150 50 H V C CNN
F2 "" 0 0 60 H V C CNN
F3 "" 0 0 60 H V C CNN
DRAW
C -150 0 50 0 0 0 N
C 150 -100 50 0 0 0 N
C 150 100 50 0 1 0 N
P 2 0 1 0 -100 0 150 50 N
X 1 1 500 100 300 L 60 60 1 1 P
X 2 2 -500 0 300 R 60 60 1 1 P
X 3 3 500 -100 300 L 60 60 1 1 P
ENDDRAW
ENDDEF
#
#End Library

View File

@@ -0,0 +1,685 @@
EESchema Schematic File Version 2
LIBS:power
LIBS:device
LIBS:transistors
LIBS:conn
LIBS:linear
LIBS:regul
LIBS:74xx
LIBS:cmos4000
LIBS:adc-dac
LIBS:memory
LIBS:xilinx
LIBS:microcontrollers
LIBS:dsp
LIBS:microchip
LIBS:analog_switches
LIBS:motorola
LIBS:texas
LIBS:intel
LIBS:audio
LIBS:interface
LIBS:digital-audio
LIBS:philips
LIBS:display
LIBS:cypress
LIBS:siliconi
LIBS:opto
LIBS:atmel
LIBS:contrib
LIBS:valves
LIBS:Raspberry
LIBS:garden-cache
EELAYER 25 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 1 1
Title "Centralina impianto di irrigazione comandata da Raspeberry PI"
Date ""
Rev ""
Comp ""
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
$EndDescr
$Comp
L GPIO-Rev.2.0 P?
U 1 1 55DE3A84
P 1900 2250
F 0 "P?" H 2400 1450 60 0000 C CNN
F 1 "GPIO-Rev.2.0" H 2100 2850 60 0000 C CNN
F 2 "" H 1900 2250 60 0000 C CNN
F 3 "" H 1900 2250 60 0000 C CNN
1 1900 2250
1 0 0 -1
$EndComp
Entry Wire Line
3800 1750 3900 1850
Entry Wire Line
3800 1950 3900 2050
Entry Wire Line
3800 2150 3900 2250
Entry Wire Line
3800 2350 3900 2450
Entry Wire Line
3800 2550 3900 2650
Entry Wire Line
3800 2750 3900 2850
Text Label 3950 2850 0 60 ~ 0
1-GND
Text Label 3950 2650 0 60 ~ 0
2-IN4
Text Label 3950 2450 0 60 ~ 0
3-IN3
Text Label 3950 2250 0 60 ~ 0
4-IN2
Text Label 3950 2050 0 60 ~ 0
5-IN1
Text Label 3950 1850 0 60 ~ 0
5-VCC
Text Label 3550 1750 0 60 ~ 0
+5v
Text Label 3550 2750 0 60 ~ 0
GND
Text Label 3500 1950 0 60 ~ 0
DEV+
Text Label 3500 2150 0 60 ~ 0
DEV-
Text Label 3500 2350 0 60 ~ 0
EV-1
Text Label 3500 2550 0 60 ~ 0
EV-2
$Comp
L SWITCH_INV SW2
U 1 1 55DE49C3
P 5600 2200
F 0 "SW2" H 5400 2350 50 0000 C CNN
F 1 "K2" H 5450 2050 50 0000 C CNN
F 2 "" H 5600 2200 60 0000 C CNN
F 3 "" H 5600 2200 60 0000 C CNN
1 5600 2200
1 0 0 -1
$EndComp
$Comp
L SWITCH_INV SW3
U 1 1 55DE4A0D
P 5600 2950
F 0 "SW3" H 5400 3100 50 0000 C CNN
F 1 "K3" H 5450 2800 50 0000 C CNN
F 2 "" H 5600 2950 60 0000 C CNN
F 3 "" H 5600 2950 60 0000 C CNN
1 5600 2950
1 0 0 -1
$EndComp
$Comp
L SWITCH_INV SW4
U 1 1 55DE4A5B
P 5600 3450
F 0 "SW4" H 5400 3600 50 0000 C CNN
F 1 "K4" H 5450 3300 50 0000 C CNN
F 2 "" H 5600 3450 60 0000 C CNN
F 3 "" H 5600 3450 60 0000 C CNN
1 5600 3450
1 0 0 -1
$EndComp
$Comp
L +9V #PWR?
U 1 1 55DE4EB1
P 10050 1150
F 0 "#PWR?" H 10050 1000 50 0001 C CNN
F 1 "+9V" H 10050 1290 50 0000 C CNN
F 2 "" H 10050 1150 60 0000 C CNN
F 3 "" H 10050 1150 60 0000 C CNN
1 10050 1150
1 0 0 -1
$EndComp
Text Label 7000 850 0 60 ~ 0
ALIMENTAZIONE-ELETTROVALVOLA+
Text Label 7000 1300 0 60 ~ 0
ALIMENTAZIONE-ELETTROVALVOLA-
Text Label 4950 1700 0 60 ~ 0
9V+
Text Label 4950 2200 0 60 ~ 0
9V-
$Comp
L STABI EV1
U 1 1 55DE54D9
P 9500 2450
F 0 "EV1" H 9700 2675 50 0000 C CNN
F 1 "STABI" H 9725 2225 50 0000 C CNN
F 2 "VALVE-MINI_P" H 9500 2600 50 0001 C CNN
F 3 "" H 9500 2450 60 0000 C CNN
1 9500 2450
1 0 0 -1
$EndComp
$Comp
L STABI EV2
U 1 1 55DE58C1
P 9500 3500
F 0 "EV2" H 9700 3725 50 0000 C CNN
F 1 "STABI" H 9725 3275 50 0000 C CNN
F 2 "VALVE-MINI_P" H 9500 3650 50 0001 C CNN
F 3 "" H 9500 3500 60 0000 C CNN
1 9500 3500
1 0 0 -1
$EndComp
Text Notes 10250 1200 0 60 ~ 0
Batteria 9V\nper alimentazione\nelettrovalvole
Entry Wire Line
3800 4400 3900 4500
Entry Wire Line
3800 4600 3900 4700
Entry Wire Line
3800 4800 3900 4900
Entry Wire Line
3800 5000 3900 5100
Entry Wire Line
3800 5200 3900 5300
Entry Wire Line
3800 5400 3900 5500
Text Label 3950 5500 0 60 ~ 0
1-GND
Text Label 3950 5300 0 60 ~ 0
2-IN4
Text Label 3950 5100 0 60 ~ 0
3-IN3
Text Label 3950 4900 0 60 ~ 0
4-IN2
Text Label 3950 4700 0 60 ~ 0
5-IN1
Text Label 3950 4500 0 60 ~ 0
5-VCC
$Comp
L SWITCH_INV SW7
U 1 1 55DF289D
P 5600 5600
F 0 "SW7" H 5400 5750 50 0000 C CNN
F 1 "K3" H 5450 5450 50 0000 C CNN
F 2 "" H 5600 5600 60 0000 C CNN
F 3 "" H 5600 5600 60 0000 C CNN
1 5600 5600
1 0 0 -1
$EndComp
$Comp
L SWITCH_INV SW8
U 1 1 55DF28A3
P 5600 6100
F 0 "SW8" H 5400 6250 50 0000 C CNN
F 1 "K4" H 5450 5950 50 0000 C CNN
F 2 "" H 5600 6100 60 0000 C CNN
F 3 "" H 5600 6100 60 0000 C CNN
1 5600 6100
1 0 0 -1
$EndComp
$Comp
L STABI EV5
U 1 1 55DF28B3
P 9500 5250
F 0 "EV5" H 9700 5475 50 0000 C CNN
F 1 "STABI" H 9725 5025 50 0000 C CNN
F 2 "VALVE-MINI_P" H 9500 5400 50 0001 C CNN
F 3 "" H 9500 5250 60 0000 C CNN
1 9500 5250
1 0 0 -1
$EndComp
$Comp
L STABI EV6
U 1 1 55DF28B9
P 9500 6150
F 0 "EV6" H 9700 6375 50 0000 C CNN
F 1 "STABI" H 9725 5925 50 0000 C CNN
F 2 "VALVE-MINI_P" H 9500 6300 50 0001 C CNN
F 3 "" H 9500 6150 60 0000 C CNN
1 9500 6150
1 0 0 -1
$EndComp
$Comp
L SWITCH_INV SW6
U 1 1 55DF2897
P 5600 4850
F 0 "SW6" H 5400 5000 50 0000 C CNN
F 1 "K2" H 5450 4700 50 0000 C CNN
F 2 "" H 5600 4850 60 0000 C CNN
F 3 "" H 5600 4850 60 0000 C CNN
1 5600 4850
1 0 0 -1
$EndComp
$Comp
L SWITCH_INV SW5
U 1 1 55DF2891
P 5600 4350
F 0 "SW5" H 5400 4500 50 0000 C CNN
F 1 "K1" H 5450 4200 50 0000 C CNN
F 2 "" H 5600 4350 60 0000 C CNN
F 3 "" H 5600 4350 60 0000 C CNN
1 5600 4350
1 0 0 -1
$EndComp
$Comp
L STABI EV3
U 1 1 55DF5576
P 7850 4200
F 0 "EV3" H 8050 4425 50 0000 C CNN
F 1 "STABI" H 8075 3975 50 0000 C CNN
F 2 "VALVE-MINI_P" H 7850 4350 50 0001 C CNN
F 3 "" H 7850 4200 60 0000 C CNN
1 7850 4200
1 0 0 -1
$EndComp
$Comp
L STABI EV4
U 1 1 55DF5990
P 7850 5050
F 0 "EV4" H 8050 5275 50 0000 C CNN
F 1 "STABI" H 8075 4825 50 0000 C CNN
F 2 "VALVE-MINI_P" H 7850 5200 50 0001 C CNN
F 3 "" H 7850 5050 60 0000 C CNN
1 7850 5050
1 0 0 -1
$EndComp
Text Label 2850 1750 0 60 ~ 0
ROSSO
Text Label 2850 1500 0 60 ~ 0
BIANCO
Text Label 2850 1300 0 60 ~ 0
GRIGIO
Text Label 2850 1950 0 60 ~ 0
NERO
Text Label 1700 3550 0 60 ~ 0
VIOLA
Text Label 1700 3350 0 60 ~ 0
VERDE
Text Label 4950 850 0 60 ~ 0
ROSSO
Text Label 4950 1300 0 60 ~ 0
NERO
Text Label 3200 4600 0 60 ~ 0
GRIGIO
Text Label 3200 5400 0 60 ~ 0
NERO
Text Label 3600 4400 0 60 ~ 0
+5v
Text Label 3550 4600 0 60 ~ 0
EV-3
Text Label 3550 4800 0 60 ~ 0
EV-4
Text Label 3550 5000 0 60 ~ 0
EV-5
Text Label 3550 5200 0 60 ~ 0
EV-6
Text Label 3600 5400 0 60 ~ 0
GND
Text Label 3200 4400 0 60 ~ 0
ROSSO
Text Label 3300 4800 0 60 ~ 0
BLU
Text Label 3050 5000 0 60 ~ 0
MARRONE
Text Label 3200 5200 0 60 ~ 0
VIOLA
Text Label 6500 1600 0 60 ~ 0
NERO
Text Label 6500 2300 0 60 ~ 0
NERO
Text Label 6500 1800 0 60 ~ 0
ARANCIONE
Text Label 6500 2100 0 60 ~ 0
ARANCIONE
Text Label 5600 2600 0 60 ~ 0
ARANCIONE
Text Label 8050 1600 0 60 ~ 0
NERO
Text Label 4800 5000 1 60 ~ 0
ARANCIONE
Text Label 7400 3050 0 60 ~ 0
GIALLO
Text Label 7400 3550 0 60 ~ 0
GIALLO
Text Label 6750 4450 0 60 ~ 0
GIALLO
Text Label 6750 4950 0 60 ~ 0
GIALLO
Text Label 6750 5700 0 60 ~ 0
GIALLO
Text Label 6750 6200 0 60 ~ 0
GIALLO
$Comp
L SWITCH_INV SW1
U 1 1 55DE4874
P 5600 1700
F 0 "SW1" H 5400 1850 50 0000 C CNN
F 1 "K1" H 5450 1550 50 0000 C CNN
F 2 "" H 5600 1700 60 0000 C CNN
F 3 "" H 5600 1700 60 0000 C CNN
1 5600 1700
1 0 0 -1
$EndComp
Text Notes 9450 2100 0 79 ~ 0
+
Text Notes 9450 3200 0 79 ~ 0
+
Text Notes 7800 3750 0 79 ~ 0
+
Text Notes 7800 4750 0 79 ~ 0
+
Text Notes 9450 4950 0 79 ~ 0
+
Text Notes 9450 5850 0 79 ~ 0
+
Text Notes 9450 2950 0 79 ~ 0
-
Text Notes 9450 3900 0 79 ~ 0
-
Text Notes 7800 4600 0 79 ~ 0
-
Text Notes 7800 5450 0 79 ~ 0
-
Text Notes 9450 5750 0 79 ~ 0
-
Text Notes 9450 6550 0 79 ~ 0
-
Text Label 4550 2500 1 79 ~ 0
MSW1
Text Label 4550 5150 1 79 ~ 0
MSW2
Text Label 1850 6400 0 60 ~ 0
GND
Text Label 1850 6550 0 60 ~ 0
DO
Text Label 1850 6700 0 60 ~ 0
AO
Text Label 1850 6850 0 60 ~ 0
VCC
Entry Wire Line
1650 6300 1750 6400
Entry Wire Line
1650 6450 1750 6550
Entry Wire Line
1650 6600 1750 6700
Entry Wire Line
1650 6750 1750 6850
Wire Bus Line
3900 1650 3900 2950
Wire Bus Line
3900 2950 4350 2950
Wire Bus Line
4350 1650 3900 1650
Wire Wire Line
2750 1750 3800 1750
Wire Wire Line
2750 1950 3250 1950
Wire Wire Line
3250 1950 3250 2750
Wire Wire Line
3250 2750 3800 2750
Wire Wire Line
1000 1850 800 1850
Wire Wire Line
800 1850 800 1500
Wire Wire Line
800 1500 3450 1500
Wire Wire Line
3450 1500 3450 1950
Wire Wire Line
3450 1950 3800 1950
Wire Wire Line
1000 1950 700 1950
Wire Wire Line
700 1950 700 1300
Wire Wire Line
700 1300 3350 1300
Wire Wire Line
3350 1300 3350 2150
Wire Wire Line
3350 2150 3800 2150
Wire Wire Line
1000 2250 700 2250
Wire Wire Line
700 2250 700 3550
Wire Wire Line
700 3550 3350 3550
Wire Wire Line
3350 3550 3350 2350
Wire Wire Line
3350 2350 3800 2350
Wire Wire Line
1000 2350 800 2350
Wire Wire Line
800 2350 800 3350
Wire Wire Line
800 3350 3450 3350
Wire Wire Line
3450 3350 3450 2550
Wire Wire Line
3450 2550 3800 2550
Wire Bus Line
4350 1650 4350 1400
Wire Bus Line
4350 1400 6400 1400
Wire Bus Line
6400 1400 6400 3800
Wire Bus Line
6400 3800 4350 3800
Wire Bus Line
4350 3800 4350 2950
Wire Wire Line
10050 1300 10050 850
Wire Wire Line
10050 850 4650 850
Wire Wire Line
4650 850 4650 1700
Wire Wire Line
4650 1700 5100 1700
Wire Wire Line
4800 1300 10050 1300
Wire Wire Line
4800 1300 4800 2200
Wire Wire Line
4800 2200 5100 2200
Wire Wire Line
9050 2100 9050 3050
Wire Wire Line
7650 1800 7650 2600
Wire Wire Line
7650 2600 4800 2600
Wire Wire Line
4800 2600 4800 6100
Wire Wire Line
4800 2950 5100 2950
Wire Wire Line
4800 3450 5100 3450
Connection ~ 4800 2950
Wire Wire Line
9050 2100 9500 2100
Wire Wire Line
9500 2100 9500 2150
Wire Wire Line
6100 1600 10100 1600
Wire Wire Line
10100 1600 10100 6450
Wire Wire Line
9500 3800 10100 3800
Wire Wire Line
7150 2300 7150 1600
Connection ~ 7150 1600
Wire Wire Line
10100 2850 9500 2850
Wire Wire Line
9500 2850 9500 2750
Connection ~ 10100 2850
Wire Notes Line
9900 900 9900 1200
Wire Notes Line
9900 1200 10200 1200
Wire Notes Line
10200 1200 10200 900
Wire Notes Line
10200 900 9900 900
Wire Bus Line
3900 4300 3900 5600
Wire Bus Line
3900 5600 4350 5600
Wire Bus Line
4350 4300 3900 4300
Wire Bus Line
4350 4300 4350 4050
Wire Bus Line
4350 4050 6400 4050
Wire Bus Line
6400 4050 6400 6450
Wire Bus Line
6400 6450 4350 6450
Wire Bus Line
4350 6450 4350 5600
Wire Wire Line
9050 4950 9050 5700
Wire Wire Line
9500 5850 9500 6100
Wire Wire Line
4800 5600 5100 5600
Wire Wire Line
4800 6100 5100 6100
Connection ~ 4800 5600
Wire Wire Line
9050 4950 9500 4950
Wire Wire Line
10100 6450 9500 6450
Wire Wire Line
10100 5650 9500 5650
Wire Wire Line
9500 5650 9500 5550
Connection ~ 10100 5650
Connection ~ 4800 3450
Wire Wire Line
5100 4350 4800 4350
Connection ~ 4800 4350
Wire Wire Line
5100 4850 4800 4850
Connection ~ 4800 4850
Wire Wire Line
7500 3750 7500 4450
Wire Wire Line
7500 3750 7850 3750
Wire Wire Line
7850 3750 7850 3900
Connection ~ 10100 3800
Wire Wire Line
7850 4500 10100 4500
Connection ~ 10100 4500
Wire Wire Line
7850 5350 8700 5350
Wire Wire Line
8700 5350 8700 4750
Wire Wire Line
8700 4750 10100 4750
Connection ~ 10100 4750
Wire Wire Line
9050 5850 9500 5850
Wire Wire Line
2750 1850 3150 1850
Wire Wire Line
3150 1850 3150 4400
Wire Wire Line
3150 4400 3800 4400
Wire Wire Line
1000 2950 1000 5400
Wire Wire Line
1000 5400 3800 5400
Wire Wire Line
1000 2450 900 2450
Wire Wire Line
900 2450 900 4600
Wire Wire Line
900 4600 3800 4600
Wire Wire Line
2750 2250 3050 2250
Wire Wire Line
3050 2250 3050 4800
Wire Wire Line
3050 4800 3800 4800
Wire Wire Line
2750 2450 2950 2450
Wire Wire Line
2950 2450 2950 5000
Wire Wire Line
2950 5000 3800 5000
Wire Wire Line
2750 2550 2850 2550
Wire Wire Line
2850 2550 2850 5200
Wire Wire Line
2850 5200 3800 5200
Wire Wire Line
9050 3200 9500 3200
Wire Wire Line
9050 3550 9050 3200
Wire Wire Line
9050 3550 6100 3550
Wire Wire Line
9050 3050 6100 3050
Wire Wire Line
7500 4450 6100 4450
Wire Wire Line
7850 4750 7500 4750
Wire Wire Line
7500 4750 7500 4950
Wire Wire Line
7500 4950 6100 4950
Wire Wire Line
9050 5700 6100 5700
Wire Wire Line
9050 6200 9050 5850
Wire Wire Line
7150 2300 6100 2300
Wire Wire Line
6100 1800 7650 1800
Wire Wire Line
7650 2100 6100 2100
Connection ~ 7650 2100
Wire Wire Line
9050 6200 6100 6200
Wire Bus Line
1750 6250 1750 6950
Wire Bus Line
1750 6950 2300 6950
Wire Bus Line
2300 6950 2300 6250
Wire Bus Line
2300 6250 1750 6250
Wire Wire Line
1000 2150 600 2150
Wire Wire Line
600 2150 600 6300
Wire Wire Line
600 6300 1650 6300
Wire Wire Line
1000 1750 550 1750
Wire Wire Line
550 1750 550 6750
Wire Wire Line
550 6750 1650 6750
Wire Wire Line
2750 2750 2800 2750
Wire Wire Line
2800 2750 2800 6000
Wire Wire Line
2800 6000 700 6000
Wire Wire Line
700 6000 700 6450
Wire Wire Line
700 6450 1650 6450
Text Label 800 6750 0 60 ~ 0
MARRONE
Text Label 800 6300 0 60 ~ 0
VERDE
Text Label 800 6450 0 60 ~ 0
BIANCO
Text Label 1600 6000 0 60 ~ 0
BIANCO
Text Label 2850 6550 2 79 ~ 0
SENSORE
Text Label 2800 6700 2 79 ~ 0
PIOGGIA
$EndSCHEMATC

View File

@@ -0,0 +1 @@
(kicad_pcb (version 4) (host kicad "dummy file") )

View File

@@ -0,0 +1,71 @@
update=dom 25 ott 2015 08:12:34 CET
version=1
last_client=kicad
[pcbnew]
version=1
LastNetListRead=
UseCmpFile=1
PadDrill=0.600000000000
PadDrillOvalY=0.600000000000
PadSizeH=1.500000000000
PadSizeV=1.500000000000
PcbTextSizeV=1.500000000000
PcbTextSizeH=1.500000000000
PcbTextThickness=0.300000000000
ModuleTextSizeV=1.000000000000
ModuleTextSizeH=1.000000000000
ModuleTextSizeThickness=0.150000000000
SolderMaskClearance=0.000000000000
SolderMaskMinWidth=0.000000000000
DrawSegmentWidth=0.200000000000
BoardOutlineThickness=0.100000000000
ModuleOutlineThickness=0.150000000000
[cvpcb]
version=1
NetIExt=net
[general]
version=1
[eeschema]
version=1
LibDir=
[eeschema/libraries]
LibName1=power
LibName2=device
LibName3=transistors
LibName4=conn
LibName5=linear
LibName6=regul
LibName7=74xx
LibName8=cmos4000
LibName9=adc-dac
LibName10=memory
LibName11=xilinx
LibName12=microcontrollers
LibName13=dsp
LibName14=microchip
LibName15=analog_switches
LibName16=motorola
LibName17=texas
LibName18=intel
LibName19=audio
LibName20=interface
LibName21=digital-audio
LibName22=philips
LibName23=display
LibName24=cypress
LibName25=siliconi
LibName26=opto
LibName27=atmel
LibName28=contrib
LibName29=valves
LibName30=Raspberry
[schematic_editor]
version=1
PageLayoutDescrFile=
PlotDirectoryName=
SubpartIdSeparator=0
SubpartFirstId=65
NetFmtName=
SpiceForceRefPrefix=0
SpiceUseNetNumbers=0
LabSize=79

View File

@@ -0,0 +1,685 @@
EESchema Schematic File Version 2
LIBS:power
LIBS:device
LIBS:transistors
LIBS:conn
LIBS:linear
LIBS:regul
LIBS:74xx
LIBS:cmos4000
LIBS:adc-dac
LIBS:memory
LIBS:xilinx
LIBS:microcontrollers
LIBS:dsp
LIBS:microchip
LIBS:analog_switches
LIBS:motorola
LIBS:texas
LIBS:intel
LIBS:audio
LIBS:interface
LIBS:digital-audio
LIBS:philips
LIBS:display
LIBS:cypress
LIBS:siliconi
LIBS:opto
LIBS:atmel
LIBS:contrib
LIBS:valves
LIBS:Raspberry
LIBS:garden-cache
EELAYER 25 0
EELAYER END
$Descr A4 11693 8268
encoding utf-8
Sheet 1 1
Title "Centralina impianto di irrigazione comandata da Raspeberry PI"
Date ""
Rev ""
Comp ""
Comment1 ""
Comment2 ""
Comment3 ""
Comment4 ""
$EndDescr
$Comp
L GPIO-Rev.2.0 P?
U 1 1 55DE3A84
P 1900 2250
F 0 "P?" H 2400 1450 60 0000 C CNN
F 1 "GPIO-Rev.2.0" H 2100 2850 60 0000 C CNN
F 2 "" H 1900 2250 60 0000 C CNN
F 3 "" H 1900 2250 60 0000 C CNN
1 1900 2250
1 0 0 -1
$EndComp
Entry Wire Line
3800 1750 3900 1850
Entry Wire Line
3800 1950 3900 2050
Entry Wire Line
3800 2150 3900 2250
Entry Wire Line
3800 2350 3900 2450
Entry Wire Line
3800 2550 3900 2650
Entry Wire Line
3800 2750 3900 2850
Text Label 3950 2850 0 60 ~ 0
1-GND
Text Label 3950 2650 0 60 ~ 0
2-IN4
Text Label 3950 2450 0 60 ~ 0
3-IN3
Text Label 3950 2250 0 60 ~ 0
4-IN2
Text Label 3950 2050 0 60 ~ 0
5-IN1
Text Label 3950 1850 0 60 ~ 0
5-VCC
Text Label 3550 1750 0 60 ~ 0
+5v
Text Label 3550 2750 0 60 ~ 0
GND
Text Label 3500 1950 0 60 ~ 0
DEV+
Text Label 3500 2150 0 60 ~ 0
DEV-
Text Label 3500 2350 0 60 ~ 0
EV-1
Text Label 3500 2550 0 60 ~ 0
EV-2
$Comp
L SWITCH_INV SW2
U 1 1 55DE49C3
P 5600 2200
F 0 "SW2" H 5400 2350 50 0000 C CNN
F 1 "K2" H 5450 2050 50 0000 C CNN
F 2 "" H 5600 2200 60 0000 C CNN
F 3 "" H 5600 2200 60 0000 C CNN
1 5600 2200
1 0 0 -1
$EndComp
$Comp
L SWITCH_INV SW3
U 1 1 55DE4A0D
P 5600 2950
F 0 "SW3" H 5400 3100 50 0000 C CNN
F 1 "K3" H 5450 2800 50 0000 C CNN
F 2 "" H 5600 2950 60 0000 C CNN
F 3 "" H 5600 2950 60 0000 C CNN
1 5600 2950
1 0 0 -1
$EndComp
$Comp
L SWITCH_INV SW4
U 1 1 55DE4A5B
P 5600 3450
F 0 "SW4" H 5400 3600 50 0000 C CNN
F 1 "K4" H 5450 3300 50 0000 C CNN
F 2 "" H 5600 3450 60 0000 C CNN
F 3 "" H 5600 3450 60 0000 C CNN
1 5600 3450
1 0 0 -1
$EndComp
$Comp
L +9V #PWR?
U 1 1 55DE4EB1
P 10050 1150
F 0 "#PWR?" H 10050 1000 50 0001 C CNN
F 1 "+9V" H 10050 1290 50 0000 C CNN
F 2 "" H 10050 1150 60 0000 C CNN
F 3 "" H 10050 1150 60 0000 C CNN
1 10050 1150
1 0 0 -1
$EndComp
Text Label 7000 850 0 60 ~ 0
ALIMENTAZIONE-ELETTROVALVOLA+
Text Label 7000 1300 0 60 ~ 0
ALIMENTAZIONE-ELETTROVALVOLA-
Text Label 4950 1700 0 60 ~ 0
9V+
Text Label 4950 2200 0 60 ~ 0
9V-
$Comp
L STABI EV1
U 1 1 55DE54D9
P 9500 2450
F 0 "EV1" H 9700 2675 50 0000 C CNN
F 1 "STABI" H 9725 2225 50 0000 C CNN
F 2 "VALVE-MINI_P" H 9500 2600 50 0001 C CNN
F 3 "" H 9500 2450 60 0000 C CNN
1 9500 2450
1 0 0 -1
$EndComp
$Comp
L STABI EV2
U 1 1 55DE58C1
P 9500 3500
F 0 "EV2" H 9700 3725 50 0000 C CNN
F 1 "STABI" H 9725 3275 50 0000 C CNN
F 2 "VALVE-MINI_P" H 9500 3650 50 0001 C CNN
F 3 "" H 9500 3500 60 0000 C CNN
1 9500 3500
1 0 0 -1
$EndComp
Text Notes 10250 1200 0 60 ~ 0
Batteria 9V\nper alimentazione\nelettrovalvole
Entry Wire Line
3800 4400 3900 4500
Entry Wire Line
3800 4600 3900 4700
Entry Wire Line
3800 4800 3900 4900
Entry Wire Line
3800 5000 3900 5100
Entry Wire Line
3800 5200 3900 5300
Entry Wire Line
3800 5400 3900 5500
Text Label 3950 5500 0 60 ~ 0
1-GND
Text Label 3950 5300 0 60 ~ 0
2-IN4
Text Label 3950 5100 0 60 ~ 0
3-IN3
Text Label 3950 4900 0 60 ~ 0
4-IN2
Text Label 3950 4700 0 60 ~ 0
5-IN1
Text Label 3950 4500 0 60 ~ 0
5-VCC
$Comp
L SWITCH_INV SW7
U 1 1 55DF289D
P 5600 5600
F 0 "SW7" H 5400 5750 50 0000 C CNN
F 1 "K3" H 5450 5450 50 0000 C CNN
F 2 "" H 5600 5600 60 0000 C CNN
F 3 "" H 5600 5600 60 0000 C CNN
1 5600 5600
1 0 0 -1
$EndComp
$Comp
L SWITCH_INV SW8
U 1 1 55DF28A3
P 5600 6100
F 0 "SW8" H 5400 6250 50 0000 C CNN
F 1 "K4" H 5450 5950 50 0000 C CNN
F 2 "" H 5600 6100 60 0000 C CNN
F 3 "" H 5600 6100 60 0000 C CNN
1 5600 6100
1 0 0 -1
$EndComp
$Comp
L STABI EV5
U 1 1 55DF28B3
P 9500 5250
F 0 "EV5" H 9700 5475 50 0000 C CNN
F 1 "STABI" H 9725 5025 50 0000 C CNN
F 2 "VALVE-MINI_P" H 9500 5400 50 0001 C CNN
F 3 "" H 9500 5250 60 0000 C CNN
1 9500 5250
1 0 0 -1
$EndComp
$Comp
L STABI EV6
U 1 1 55DF28B9
P 9500 6150
F 0 "EV6" H 9700 6375 50 0000 C CNN
F 1 "STABI" H 9725 5925 50 0000 C CNN
F 2 "VALVE-MINI_P" H 9500 6300 50 0001 C CNN
F 3 "" H 9500 6150 60 0000 C CNN
1 9500 6150
1 0 0 -1
$EndComp
$Comp
L SWITCH_INV SW6
U 1 1 55DF2897
P 5600 4850
F 0 "SW6" H 5400 5000 50 0000 C CNN
F 1 "K2" H 5450 4700 50 0000 C CNN
F 2 "" H 5600 4850 60 0000 C CNN
F 3 "" H 5600 4850 60 0000 C CNN
1 5600 4850
1 0 0 -1
$EndComp
$Comp
L SWITCH_INV SW5
U 1 1 55DF2891
P 5600 4350
F 0 "SW5" H 5400 4500 50 0000 C CNN
F 1 "K1" H 5450 4200 50 0000 C CNN
F 2 "" H 5600 4350 60 0000 C CNN
F 3 "" H 5600 4350 60 0000 C CNN
1 5600 4350
1 0 0 -1
$EndComp
$Comp
L STABI EV3
U 1 1 55DF5576
P 7850 4200
F 0 "EV3" H 8050 4425 50 0000 C CNN
F 1 "STABI" H 8075 3975 50 0000 C CNN
F 2 "VALVE-MINI_P" H 7850 4350 50 0001 C CNN
F 3 "" H 7850 4200 60 0000 C CNN
1 7850 4200
1 0 0 -1
$EndComp
$Comp
L STABI EV4
U 1 1 55DF5990
P 7850 5050
F 0 "EV4" H 8050 5275 50 0000 C CNN
F 1 "STABI" H 8075 4825 50 0000 C CNN
F 2 "VALVE-MINI_P" H 7850 5200 50 0001 C CNN
F 3 "" H 7850 5050 60 0000 C CNN
1 7850 5050
1 0 0 -1
$EndComp
Text Label 2850 1750 0 60 ~ 0
ROSSO
Text Label 2850 1500 0 60 ~ 0
BIANCO
Text Label 2850 1300 0 60 ~ 0
GRIGIO
Text Label 2850 1950 0 60 ~ 0
NERO
Text Label 1700 3550 0 60 ~ 0
VIOLA
Text Label 1700 3350 0 60 ~ 0
VERDE
Text Label 4950 850 0 60 ~ 0
ROSSO
Text Label 4950 1300 0 60 ~ 0
NERO
Text Label 3200 4600 0 60 ~ 0
GRIGIO
Text Label 3200 5400 0 60 ~ 0
NERO
Text Label 3600 4400 0 60 ~ 0
+5v
Text Label 3550 4600 0 60 ~ 0
EV-3
Text Label 3550 4800 0 60 ~ 0
EV-4
Text Label 3550 5000 0 60 ~ 0
EV-5
Text Label 3550 5200 0 60 ~ 0
EV-6
Text Label 3600 5400 0 60 ~ 0
GND
Text Label 3200 4400 0 60 ~ 0
ROSSO
Text Label 3300 4800 0 60 ~ 0
BLU
Text Label 3050 5000 0 60 ~ 0
MARRONE
Text Label 3200 5200 0 60 ~ 0
VIOLA
Text Label 6500 1600 0 60 ~ 0
NERO
Text Label 6500 2300 0 60 ~ 0
NERO
Text Label 6500 1800 0 60 ~ 0
ARANCIONE
Text Label 6500 2100 0 60 ~ 0
ARANCIONE
Text Label 5600 2600 0 60 ~ 0
ARANCIONE
Text Label 8050 1600 0 60 ~ 0
NERO
Text Label 4800 5000 1 60 ~ 0
ARANCIONE
Text Label 7400 3050 0 60 ~ 0
GIALLO
Text Label 7400 3550 0 60 ~ 0
GIALLO
Text Label 6750 4450 0 60 ~ 0
GIALLO
Text Label 6750 4950 0 60 ~ 0
GIALLO
Text Label 6750 5700 0 60 ~ 0
GIALLO
Text Label 6750 6200 0 60 ~ 0
GIALLO
$Comp
L SWITCH_INV SW1
U 1 1 55DE4874
P 5600 1700
F 0 "SW1" H 5400 1850 50 0000 C CNN
F 1 "K1" H 5450 1550 50 0000 C CNN
F 2 "" H 5600 1700 60 0000 C CNN
F 3 "" H 5600 1700 60 0000 C CNN
1 5600 1700
1 0 0 -1
$EndComp
Text Notes 9450 2100 0 79 ~ 0
+
Text Notes 9450 3200 0 79 ~ 0
+
Text Notes 7800 3750 0 79 ~ 0
+
Text Notes 7800 4750 0 79 ~ 0
+
Text Notes 9450 4950 0 79 ~ 0
+
Text Notes 9450 5850 0 79 ~ 0
+
Text Notes 9450 2950 0 79 ~ 0
-
Text Notes 9450 3900 0 79 ~ 0
-
Text Notes 7800 4600 0 79 ~ 0
-
Text Notes 7800 5450 0 79 ~ 0
-
Text Notes 9450 5750 0 79 ~ 0
-
Text Notes 9450 6550 0 79 ~ 0
-
Text Label 4550 2500 1 79 ~ 0
MSW1
Text Label 4550 5150 1 79 ~ 0
MSW2
Text Label 1850 6400 0 60 ~ 0
GND
Text Label 1850 6550 0 60 ~ 0
DO
Text Label 1850 6700 0 60 ~ 0
AO
Text Label 1850 6850 0 60 ~ 0
VCC
Entry Wire Line
1650 6300 1750 6400
Entry Wire Line
1650 6450 1750 6550
Entry Wire Line
1650 6600 1750 6700
Entry Wire Line
1650 6750 1750 6850
Wire Bus Line
3900 1650 3900 2950
Wire Bus Line
3900 2950 4350 2950
Wire Bus Line
4350 1650 3900 1650
Wire Wire Line
2750 1750 3800 1750
Wire Wire Line
2750 1950 3250 1950
Wire Wire Line
3250 1950 3250 2750
Wire Wire Line
3250 2750 3800 2750
Wire Wire Line
1000 1850 800 1850
Wire Wire Line
800 1850 800 1500
Wire Wire Line
800 1500 3450 1500
Wire Wire Line
3450 1500 3450 1950
Wire Wire Line
3450 1950 3800 1950
Wire Wire Line
1000 1950 700 1950
Wire Wire Line
700 1950 700 1300
Wire Wire Line
700 1300 3350 1300
Wire Wire Line
3350 1300 3350 2150
Wire Wire Line
3350 2150 3800 2150
Wire Wire Line
1000 2250 700 2250
Wire Wire Line
700 2250 700 3550
Wire Wire Line
700 3550 3350 3550
Wire Wire Line
3350 3550 3350 2350
Wire Wire Line
3350 2350 3800 2350
Wire Wire Line
1000 2350 800 2350
Wire Wire Line
800 2350 800 3350
Wire Wire Line
800 3350 3450 3350
Wire Wire Line
3450 3350 3450 2550
Wire Wire Line
3450 2550 3800 2550
Wire Bus Line
4350 1650 4350 1400
Wire Bus Line
4350 1400 6400 1400
Wire Bus Line
6400 1400 6400 3800
Wire Bus Line
6400 3800 4350 3800
Wire Bus Line
4350 3800 4350 2950
Wire Wire Line
10050 1300 10050 850
Wire Wire Line
10050 850 4650 850
Wire Wire Line
4650 850 4650 1700
Wire Wire Line
4650 1700 5100 1700
Wire Wire Line
4800 1300 10050 1300
Wire Wire Line
4800 1300 4800 2200
Wire Wire Line
4800 2200 5100 2200
Wire Wire Line
9050 2100 9050 3050
Wire Wire Line
7650 1800 7650 2600
Wire Wire Line
7650 2600 4800 2600
Wire Wire Line
4800 2600 4800 6100
Wire Wire Line
4800 2950 5100 2950
Wire Wire Line
4800 3450 5100 3450
Connection ~ 4800 2950
Wire Wire Line
9050 2100 9500 2100
Wire Wire Line
9500 2100 9500 2150
Wire Wire Line
6100 1600 10100 1600
Wire Wire Line
10100 1600 10100 6450
Wire Wire Line
9500 3800 10100 3800
Wire Wire Line
7150 2300 7150 1600
Connection ~ 7150 1600
Wire Wire Line
10100 2850 9500 2850
Wire Wire Line
9500 2850 9500 2750
Connection ~ 10100 2850
Wire Notes Line
9900 900 9900 1200
Wire Notes Line
9900 1200 10200 1200
Wire Notes Line
10200 1200 10200 900
Wire Notes Line
10200 900 9900 900
Wire Bus Line
3900 4300 3900 5600
Wire Bus Line
3900 5600 4350 5600
Wire Bus Line
4350 4300 3900 4300
Wire Bus Line
4350 4300 4350 4050
Wire Bus Line
4350 4050 6400 4050
Wire Bus Line
6400 4050 6400 6450
Wire Bus Line
6400 6450 4350 6450
Wire Bus Line
4350 6450 4350 5600
Wire Wire Line
9050 4950 9050 5700
Wire Wire Line
9500 5850 9500 6100
Wire Wire Line
4800 5600 5100 5600
Wire Wire Line
4800 6100 5100 6100
Connection ~ 4800 5600
Wire Wire Line
9050 4950 9500 4950
Wire Wire Line
10100 6450 9500 6450
Wire Wire Line
10100 5650 9500 5650
Wire Wire Line
9500 5650 9500 5550
Connection ~ 10100 5650
Connection ~ 4800 3450
Wire Wire Line
5100 4350 4800 4350
Connection ~ 4800 4350
Wire Wire Line
5100 4850 4800 4850
Connection ~ 4800 4850
Wire Wire Line
7500 3750 7500 4450
Wire Wire Line
7500 3750 7850 3750
Wire Wire Line
7850 3750 7850 3900
Connection ~ 10100 3800
Wire Wire Line
7850 4500 10100 4500
Connection ~ 10100 4500
Wire Wire Line
7850 5350 8700 5350
Wire Wire Line
8700 5350 8700 4750
Wire Wire Line
8700 4750 10100 4750
Connection ~ 10100 4750
Wire Wire Line
9050 5850 9500 5850
Wire Wire Line
2750 1850 3150 1850
Wire Wire Line
3150 1850 3150 4400
Wire Wire Line
3150 4400 3800 4400
Wire Wire Line
1000 2950 1000 5400
Wire Wire Line
1000 5400 3800 5400
Wire Wire Line
1000 2450 900 2450
Wire Wire Line
900 2450 900 4600
Wire Wire Line
900 4600 3800 4600
Wire Wire Line
2750 2250 3050 2250
Wire Wire Line
3050 2250 3050 4800
Wire Wire Line
3050 4800 3800 4800
Wire Wire Line
2750 2450 2950 2450
Wire Wire Line
2950 2450 2950 5000
Wire Wire Line
2950 5000 3800 5000
Wire Wire Line
2750 2550 2850 2550
Wire Wire Line
2850 2550 2850 5200
Wire Wire Line
2850 5200 3800 5200
Wire Wire Line
9050 3200 9500 3200
Wire Wire Line
9050 3550 9050 3200
Wire Wire Line
9050 3550 6100 3550
Wire Wire Line
9050 3050 6100 3050
Wire Wire Line
7500 4450 6100 4450
Wire Wire Line
7850 4750 7500 4750
Wire Wire Line
7500 4750 7500 4950
Wire Wire Line
7500 4950 6100 4950
Wire Wire Line
9050 5700 6100 5700
Wire Wire Line
9050 6200 9050 5850
Wire Wire Line
7150 2300 6100 2300
Wire Wire Line
6100 1800 7650 1800
Wire Wire Line
7650 2100 6100 2100
Connection ~ 7650 2100
Wire Wire Line
9050 6200 6100 6200
Wire Bus Line
1750 6250 1750 6950
Wire Bus Line
1750 6950 2300 6950
Wire Bus Line
2300 6950 2300 6250
Wire Bus Line
2300 6250 1750 6250
Wire Wire Line
1000 2150 600 2150
Wire Wire Line
600 2150 600 6300
Wire Wire Line
600 6300 1650 6300
Wire Wire Line
1000 1750 550 1750
Wire Wire Line
550 1750 550 6750
Wire Wire Line
550 6750 1650 6750
Wire Wire Line
2750 2750 2800 2750
Wire Wire Line
2800 2750 2800 6000
Wire Wire Line
2800 6000 700 6000
Wire Wire Line
700 6000 700 6450
Wire Wire Line
700 6450 1650 6450
Text Label 800 6750 0 60 ~ 0
MARRONE
Text Label 800 6300 0 60 ~ 0
VERDE
Text Label 800 6450 0 60 ~ 0
BIANCO
Text Label 1600 6000 0 60 ~ 0
BIANCO
Text Label 2850 6550 2 79 ~ 0
SENSORE
Text Label 2800 6700 2 79 ~ 0
PIOGGIA
$EndSCHEMATC

Some files were not shown because too many files have changed in this diff Show More