Merge branch 'master' of github.com:0110/PlantCtrl
This commit is contained in:
commit
8cbd96adda
File diff suppressed because it is too large
Load Diff
@ -32,15 +32,15 @@ Lipo
|
|||||||
$Comp
|
$Comp
|
||||||
L Connector_Generic:Conn_01x03 1WIRE1
|
L Connector_Generic:Conn_01x03 1WIRE1
|
||||||
U 1 1 5F109CD6
|
U 1 1 5F109CD6
|
||||||
P 4800 1150
|
P 5200 1100
|
||||||
F 0 "1WIRE1" H 4718 825 50 0000 C CNN
|
F 0 "1WIRE1" H 5118 775 50 0000 C CNN
|
||||||
F 1 "Conn_01x03" H 4718 916 50 0000 C CNN
|
F 1 "Conn_01x03" H 5118 866 50 0000 C CNN
|
||||||
F 2 "Connector_JST:JST_EH_B3B-EH-A_1x03_P2.50mm_Vertical" H 4800 1150 50 0001 C CNN
|
F 2 "Connector_JST:JST_EH_B3B-EH-A_1x03_P2.50mm_Vertical" H 5200 1100 50 0001 C CNN
|
||||||
F 3 "~" H 4800 1150 50 0001 C CNN
|
F 3 "~" H 5200 1100 50 0001 C CNN
|
||||||
1 4800 1150
|
1 5200 1100
|
||||||
-1 0 0 1
|
-1 0 0 1
|
||||||
$EndComp
|
$EndComp
|
||||||
Text GLabel 5000 1150 2 50 Input ~ 0
|
Text GLabel 5400 1100 2 50 Input ~ 0
|
||||||
Temp
|
Temp
|
||||||
$Comp
|
$Comp
|
||||||
L Transistor_FET:BSS84 Q_PWR1
|
L Transistor_FET:BSS84 Q_PWR1
|
||||||
@ -442,9 +442,7 @@ F 3 "~" H 18100 2250 50 0001 C CNN
|
|||||||
$EndComp
|
$EndComp
|
||||||
Text GLabel 18550 2600 2 50 Input ~ 0
|
Text GLabel 18550 2600 2 50 Input ~ 0
|
||||||
VCC
|
VCC
|
||||||
Wire Wire Line
|
Text GLabel 16400 9600 3 50 Input ~ 0
|
||||||
16400 9350 16400 9300
|
|
||||||
Text GLabel 16400 9350 3 50 Input ~ 0
|
|
||||||
VCC
|
VCC
|
||||||
Text GLabel 18300 2150 2 50 Input ~ 0
|
Text GLabel 18300 2150 2 50 Input ~ 0
|
||||||
PUMP_PWR
|
PUMP_PWR
|
||||||
@ -488,13 +486,13 @@ Wire Wire Line
|
|||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
6350 2600 6400 2600
|
6350 2600 6400 2600
|
||||||
Connection ~ 6400 2600
|
Connection ~ 6400 2600
|
||||||
Text GLabel 5050 1250 2 50 Input ~ 0
|
Text GLabel 5450 1200 2 50 Input ~ 0
|
||||||
GND
|
GND
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
5050 1250 5000 1250
|
5450 1200 5400 1200
|
||||||
Text GLabel 9350 2000 3 50 Input ~ 0
|
Text GLabel 9350 2000 3 50 Input ~ 0
|
||||||
GND
|
GND
|
||||||
Text GLabel 16750 9500 3 50 Input ~ 0
|
Text GLabel 16750 9550 2 50 Input ~ 0
|
||||||
GND
|
GND
|
||||||
Text GLabel 10650 15150 3 50 Input ~ 0
|
Text GLabel 10650 15150 3 50 Input ~ 0
|
||||||
GND
|
GND
|
||||||
@ -607,8 +605,6 @@ Wire Wire Line
|
|||||||
16150 5750 16150 6100
|
16150 5750 16150 6100
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
15500 5750 16150 5750
|
15500 5750 16150 5750
|
||||||
Wire Wire Line
|
|
||||||
15050 5750 15050 6100
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
15200 5750 15050 5750
|
15200 5750 15050 5750
|
||||||
$Comp
|
$Comp
|
||||||
@ -628,9 +624,6 @@ Wire Wire Line
|
|||||||
Connection ~ 14750 6800
|
Connection ~ 14750 6800
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
14750 6600 14750 6800
|
14750 6600 14750 6800
|
||||||
Wire Wire Line
|
|
||||||
14750 6100 15050 6100
|
|
||||||
Connection ~ 14750 6100
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
14750 6300 14750 6100
|
14750 6300 14750 6100
|
||||||
$Comp
|
$Comp
|
||||||
@ -652,8 +645,6 @@ Wire Wire Line
|
|||||||
14700 6100 14750 6100
|
14700 6100 14750 6100
|
||||||
Text GLabel 14700 6800 0 50 Input ~ 0
|
Text GLabel 14700 6800 0 50 Input ~ 0
|
||||||
GND
|
GND
|
||||||
Text GLabel 14700 6100 0 50 Input ~ 0
|
|
||||||
PWR_PUMP_CONVERTER
|
|
||||||
$Comp
|
$Comp
|
||||||
L Connector_Generic:Conn_01x04 DCDC1
|
L Connector_Generic:Conn_01x04 DCDC1
|
||||||
U 1 1 5F837F50
|
U 1 1 5F837F50
|
||||||
@ -704,7 +695,7 @@ L Device:R R26
|
|||||||
U 1 1 5EE03137
|
U 1 1 5EE03137
|
||||||
P 4150 1200
|
P 4150 1200
|
||||||
F 0 "R26" H 4220 1246 50 0000 L CNN
|
F 0 "R26" H 4220 1246 50 0000 L CNN
|
||||||
F 1 "4k7" H 4220 1155 50 0000 L CNN
|
F 1 "2.2k" H 4220 1155 50 0000 L CNN
|
||||||
F 2 "Resistor_SMD:R_0805_2012Metric" V 4080 1200 50 0001 C CNN
|
F 2 "Resistor_SMD:R_0805_2012Metric" V 4080 1200 50 0001 C CNN
|
||||||
F 3 "~" H 4150 1200 50 0001 C CNN
|
F 3 "~" H 4150 1200 50 0001 C CNN
|
||||||
F 4 "C17673" H 4150 1200 50 0001 C CNN "LCSC_PART_NUMBER"
|
F 4 "C17673" H 4150 1200 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
@ -741,25 +732,18 @@ F 4 "C17590" H 7900 11100 50 0001 C CNN "LCSC_PART_NUMBER"
|
|||||||
$EndComp
|
$EndComp
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
2150 14500 2150 14850
|
2150 14500 2150 14850
|
||||||
Connection ~ 2150 14500
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
2900 14500 2900 14850
|
2900 14500 2900 14850
|
||||||
Connection ~ 2900 14500
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
5250 14500 5250 14850
|
5250 14500 5250 14850
|
||||||
Connection ~ 5250 14500
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
3700 14500 3700 14850
|
3700 14500 3700 14850
|
||||||
Connection ~ 3700 14500
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
4500 14500 4500 14850
|
4500 14500 4500 14850
|
||||||
Connection ~ 4500 14500
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
6050 14500 6050 14850
|
6050 14500 6050 14850
|
||||||
Connection ~ 6050 14500
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
6850 14500 6850 14850
|
6850 14500 6850 14850
|
||||||
Connection ~ 6850 14500
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
7050 14150 7050 14200
|
7050 14150 7050 14200
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
@ -858,16 +842,6 @@ Text GLabel 3900 14150 2 50 Input ~ 0
|
|||||||
GND
|
GND
|
||||||
Text GLabel 3900 14850 2 50 Input ~ 0
|
Text GLabel 3900 14850 2 50 Input ~ 0
|
||||||
3_3V
|
3_3V
|
||||||
Wire Wire Line
|
|
||||||
6850 14100 6850 14500
|
|
||||||
Wire Wire Line
|
|
||||||
6050 14100 6050 14500
|
|
||||||
Wire Wire Line
|
|
||||||
5250 14100 5250 14500
|
|
||||||
Wire Wire Line
|
|
||||||
4500 14100 4500 14500
|
|
||||||
Wire Wire Line
|
|
||||||
3700 14100 3700 14500
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
3100 14150 3100 14200
|
3100 14150 3100 14200
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
@ -908,10 +882,6 @@ Text GLabel 2350 14150 2 50 Input ~ 0
|
|||||||
GND
|
GND
|
||||||
Text GLabel 2350 14850 2 50 Input ~ 0
|
Text GLabel 2350 14850 2 50 Input ~ 0
|
||||||
3_3V
|
3_3V
|
||||||
Wire Wire Line
|
|
||||||
2900 14100 2900 14500
|
|
||||||
Wire Wire Line
|
|
||||||
2150 14100 2150 14500
|
|
||||||
Text GLabel 6950 15150 3 50 Input ~ 0
|
Text GLabel 6950 15150 3 50 Input ~ 0
|
||||||
GND
|
GND
|
||||||
Text GLabel 6150 15150 3 50 Input ~ 0
|
Text GLabel 6150 15150 3 50 Input ~ 0
|
||||||
@ -938,7 +908,7 @@ Text GLabel 3800 13800 3 50 Input ~ 0
|
|||||||
GND
|
GND
|
||||||
Text GLabel 3000 13800 3 50 Input ~ 0
|
Text GLabel 3000 13800 3 50 Input ~ 0
|
||||||
GND
|
GND
|
||||||
Text GLabel 2250 13800 3 50 Input ~ 0
|
Text GLabel 2300 13750 3 50 Input ~ 0
|
||||||
GND
|
GND
|
||||||
Text GLabel 9250 12100 3 50 Input ~ 0
|
Text GLabel 9250 12100 3 50 Input ~ 0
|
||||||
GND
|
GND
|
||||||
@ -958,7 +928,7 @@ Text Notes 5100 13050 2 207 ~ 0
|
|||||||
Sensors
|
Sensors
|
||||||
Text GLabel 2900 15000 3 50 Input ~ 0
|
Text GLabel 2900 15000 3 50 Input ~ 0
|
||||||
PLANT1_MOIST
|
PLANT1_MOIST
|
||||||
Text GLabel 2050 15000 3 50 Input ~ 0
|
Text GLabel 2200 13750 3 50 Input ~ 0
|
||||||
PWR_SENSORS
|
PWR_SENSORS
|
||||||
Text GLabel 3700 15000 3 50 Input ~ 0
|
Text GLabel 3700 15000 3 50 Input ~ 0
|
||||||
PLANT2_MOIST
|
PLANT2_MOIST
|
||||||
@ -972,25 +942,25 @@ Text GLabel 6850 15000 3 50 Input ~ 0
|
|||||||
PLANT6_MOIST
|
PLANT6_MOIST
|
||||||
Text GLabel 2150 15000 3 50 Input ~ 0
|
Text GLabel 2150 15000 3 50 Input ~ 0
|
||||||
PLANT0_MOIST
|
PLANT0_MOIST
|
||||||
Text GLabel 2800 15000 3 50 Input ~ 0
|
Text GLabel 2900 13800 3 50 Input ~ 0
|
||||||
PWR_SENSORS
|
PWR_SENSORS
|
||||||
Text GLabel 3600 15000 3 50 Input ~ 0
|
Text GLabel 3700 13800 3 50 Input ~ 0
|
||||||
PWR_SENSORS
|
PWR_SENSORS
|
||||||
Text GLabel 4400 15000 3 50 Input ~ 0
|
Text GLabel 4500 13800 3 50 Input ~ 0
|
||||||
PWR_SENSORS
|
PWR_SENSORS
|
||||||
Text GLabel 5150 15000 3 50 Input ~ 0
|
Text GLabel 5250 13800 3 50 Input ~ 0
|
||||||
PWR_SENSORS
|
PWR_SENSORS
|
||||||
Text GLabel 5950 15000 3 50 Input ~ 0
|
Text GLabel 6050 13800 3 50 Input ~ 0
|
||||||
PWR_SENSORS
|
PWR_SENSORS
|
||||||
$Comp
|
$Comp
|
||||||
L Connector:Conn_01x03_Male S0
|
L Connector:Conn_01x03_Male S0
|
||||||
U 1 1 5F6785CE
|
U 1 1 5F6785CE
|
||||||
P 2150 13550
|
P 2200 13550
|
||||||
F 0 "S0" H 2122 13482 50 0000 R CNN
|
F 0 "S0" H 2172 13482 50 0000 R CNN
|
||||||
F 1 "Conn_01x03_Male" H 2750 13350 50 0000 R CNN
|
F 1 "Conn_01x03_Male" H 2800 13350 50 0000 R CNN
|
||||||
F 2 "Connector_JST:JST_EH_B3B-EH-A_1x03_P2.50mm_Vertical" H 2150 13550 50 0001 C CNN
|
F 2 "Connector_JST:JST_EH_B3B-EH-A_1x03_P2.50mm_Vertical" H 2200 13550 50 0001 C CNN
|
||||||
F 3 "~" H 2150 13550 50 0001 C CNN
|
F 3 "~" H 2200 13550 50 0001 C CNN
|
||||||
1 2150 13550
|
1 2200 13550
|
||||||
0 1 1 0
|
0 1 1 0
|
||||||
$EndComp
|
$EndComp
|
||||||
$Comp
|
$Comp
|
||||||
@ -1048,7 +1018,7 @@ F 3 "~" H 6050 13550 50 0001 C CNN
|
|||||||
1 6050 13550
|
1 6050 13550
|
||||||
0 1 1 0
|
0 1 1 0
|
||||||
$EndComp
|
$EndComp
|
||||||
Text GLabel 6750 15000 3 50 Input ~ 0
|
Text GLabel 6850 13800 3 50 Input ~ 0
|
||||||
PWR_SENSORS
|
PWR_SENSORS
|
||||||
$Comp
|
$Comp
|
||||||
L Connector:Conn_01x03_Male S6
|
L Connector:Conn_01x03_Male S6
|
||||||
@ -1061,64 +1031,52 @@ F 3 "~" H 6850 13550 50 0001 C CNN
|
|||||||
1 6850 13550
|
1 6850 13550
|
||||||
0 1 1 0
|
0 1 1 0
|
||||||
$EndComp
|
$EndComp
|
||||||
Wire Wire Line
|
|
||||||
2800 13750 2800 15000
|
|
||||||
Wire Wire Line
|
|
||||||
3600 13750 3600 15000
|
|
||||||
Wire Wire Line
|
|
||||||
4400 13750 4400 15000
|
|
||||||
Wire Wire Line
|
|
||||||
5150 13750 5150 15000
|
|
||||||
Wire Wire Line
|
|
||||||
5950 13750 5950 15000
|
|
||||||
Wire Wire Line
|
|
||||||
6750 13750 6750 15000
|
|
||||||
$Comp
|
$Comp
|
||||||
L Device:R R41
|
L Device:R R41
|
||||||
U 1 1 5F99C5A6
|
U 1 1 5F99C5A6
|
||||||
P 4500 13950
|
P 4400 13900
|
||||||
F 0 "R41" H 4570 13996 50 0000 L CNN
|
F 0 "R41" H 4470 13946 50 0000 L CNN
|
||||||
F 1 "1k" H 4570 13905 50 0000 L CNN
|
F 1 "1k" H 4470 13855 50 0000 L CNN
|
||||||
F 2 "Resistor_SMD:R_0805_2012Metric" V 4430 13950 50 0001 C CNN
|
F 2 "Resistor_SMD:R_0805_2012Metric" V 4330 13900 50 0001 C CNN
|
||||||
F 3 "~" H 4500 13950 50 0001 C CNN
|
F 3 "~" H 4400 13900 50 0001 C CNN
|
||||||
F 4 "C95781" H 4500 13950 50 0001 C CNN "LCSC_PART_NUMBER"
|
F 4 "C95781" H 4400 13900 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
1 4500 13950
|
1 4400 13900
|
||||||
1 0 0 -1
|
1 0 0 -1
|
||||||
$EndComp
|
$EndComp
|
||||||
$Comp
|
$Comp
|
||||||
L Device:R R43
|
L Device:R R43
|
||||||
U 1 1 5F99C828
|
U 1 1 5F99C828
|
||||||
P 5250 13950
|
P 5150 13900
|
||||||
F 0 "R43" H 5320 13996 50 0000 L CNN
|
F 0 "R43" H 5220 13946 50 0000 L CNN
|
||||||
F 1 "1k" H 5320 13905 50 0000 L CNN
|
F 1 "1k" H 5220 13855 50 0000 L CNN
|
||||||
F 2 "Resistor_SMD:R_0805_2012Metric" V 5180 13950 50 0001 C CNN
|
F 2 "Resistor_SMD:R_0805_2012Metric" V 5080 13900 50 0001 C CNN
|
||||||
F 3 "~" H 5250 13950 50 0001 C CNN
|
F 3 "~" H 5150 13900 50 0001 C CNN
|
||||||
F 4 "C95781" H 5250 13950 50 0001 C CNN "LCSC_PART_NUMBER"
|
F 4 "C95781" H 5150 13900 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
1 5250 13950
|
1 5150 13900
|
||||||
1 0 0 -1
|
1 0 0 -1
|
||||||
$EndComp
|
$EndComp
|
||||||
$Comp
|
$Comp
|
||||||
L Device:R R45
|
L Device:R R45
|
||||||
U 1 1 5F99CBD3
|
U 1 1 5F99CBD3
|
||||||
P 6050 13950
|
P 5950 13900
|
||||||
F 0 "R45" H 6120 13996 50 0000 L CNN
|
F 0 "R45" H 6020 13946 50 0000 L CNN
|
||||||
F 1 "1k" H 6120 13905 50 0000 L CNN
|
F 1 "1k" H 6020 13855 50 0000 L CNN
|
||||||
F 2 "Resistor_SMD:R_0805_2012Metric" V 5980 13950 50 0001 C CNN
|
F 2 "Resistor_SMD:R_0805_2012Metric" V 5880 13900 50 0001 C CNN
|
||||||
F 3 "~" H 6050 13950 50 0001 C CNN
|
F 3 "~" H 5950 13900 50 0001 C CNN
|
||||||
F 4 "C95781" H 6050 13950 50 0001 C CNN "LCSC_PART_NUMBER"
|
F 4 "C95781" H 5950 13900 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
1 6050 13950
|
1 5950 13900
|
||||||
1 0 0 -1
|
1 0 0 -1
|
||||||
$EndComp
|
$EndComp
|
||||||
$Comp
|
$Comp
|
||||||
L Device:R R49
|
L Device:R R49
|
||||||
U 1 1 5F99CEF5
|
U 1 1 5F99CEF5
|
||||||
P 6850 13950
|
P 6750 13900
|
||||||
F 0 "R49" H 6920 13996 50 0000 L CNN
|
F 0 "R49" H 6820 13946 50 0000 L CNN
|
||||||
F 1 "1k" H 6920 13905 50 0000 L CNN
|
F 1 "1k" H 6820 13855 50 0000 L CNN
|
||||||
F 2 "Resistor_SMD:R_0805_2012Metric" V 6780 13950 50 0001 C CNN
|
F 2 "Resistor_SMD:R_0805_2012Metric" V 6680 13900 50 0001 C CNN
|
||||||
F 3 "~" H 6850 13950 50 0001 C CNN
|
F 3 "~" H 6750 13900 50 0001 C CNN
|
||||||
F 4 "C95781" H 6850 13950 50 0001 C CNN "LCSC_PART_NUMBER"
|
F 4 "C95781" H 6750 13900 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
1 6850 13950
|
1 6750 13900
|
||||||
1 0 0 -1
|
1 0 0 -1
|
||||||
$EndComp
|
$EndComp
|
||||||
$Comp
|
$Comp
|
||||||
@ -1138,12 +1096,6 @@ Wire Wire Line
|
|||||||
2150 14850 2150 15000
|
2150 14850 2150 15000
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
2150 14850 2250 14850
|
2150 14850 2250 14850
|
||||||
Wire Wire Line
|
|
||||||
2150 13750 2150 13800
|
|
||||||
Wire Wire Line
|
|
||||||
2250 13750 2250 13800
|
|
||||||
Wire Wire Line
|
|
||||||
2050 13750 2050 15000
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
2900 13750 2900 13800
|
2900 13750 2900 13800
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
@ -1273,37 +1225,37 @@ Wire Wire Line
|
|||||||
$Comp
|
$Comp
|
||||||
L Device:R R39
|
L Device:R R39
|
||||||
U 1 1 5F99C2BC
|
U 1 1 5F99C2BC
|
||||||
P 3700 13950
|
P 3600 13900
|
||||||
F 0 "R39" H 3770 13996 50 0000 L CNN
|
F 0 "R39" H 3670 13946 50 0000 L CNN
|
||||||
F 1 "1k" H 3770 13905 50 0000 L CNN
|
F 1 "1k" H 3670 13855 50 0000 L CNN
|
||||||
F 2 "Resistor_SMD:R_0805_2012Metric" V 3630 13950 50 0001 C CNN
|
F 2 "Resistor_SMD:R_0805_2012Metric" V 3530 13900 50 0001 C CNN
|
||||||
F 3 "~" H 3700 13950 50 0001 C CNN
|
F 3 "~" H 3600 13900 50 0001 C CNN
|
||||||
F 4 "C95781" H 3700 13950 50 0001 C CNN "LCSC_PART_NUMBER"
|
F 4 "C95781" H 3600 13900 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
1 3700 13950
|
1 3600 13900
|
||||||
1 0 0 -1
|
1 0 0 -1
|
||||||
$EndComp
|
$EndComp
|
||||||
$Comp
|
$Comp
|
||||||
L Device:R R37
|
L Device:R R37
|
||||||
U 1 1 5F99BE26
|
U 1 1 5F99BE26
|
||||||
P 2900 13950
|
P 2800 13900
|
||||||
F 0 "R37" H 2970 13996 50 0000 L CNN
|
F 0 "R37" H 2870 13946 50 0000 L CNN
|
||||||
F 1 "1k" H 2970 13905 50 0000 L CNN
|
F 1 "1k" H 2870 13855 50 0000 L CNN
|
||||||
F 2 "Resistor_SMD:R_0805_2012Metric" V 2830 13950 50 0001 C CNN
|
F 2 "Resistor_SMD:R_0805_2012Metric" V 2730 13900 50 0001 C CNN
|
||||||
F 3 "~" H 2900 13950 50 0001 C CNN
|
F 3 "~" H 2800 13900 50 0001 C CNN
|
||||||
F 4 "C95781" H 2900 13950 50 0001 C CNN "LCSC_PART_NUMBER"
|
F 4 "C95781" H 2800 13900 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
1 2900 13950
|
1 2800 13900
|
||||||
1 0 0 -1
|
1 0 0 -1
|
||||||
$EndComp
|
$EndComp
|
||||||
$Comp
|
$Comp
|
||||||
L Device:R R35
|
L Device:R R35
|
||||||
U 1 1 5F993C00
|
U 1 1 5F993C00
|
||||||
P 2150 13950
|
P 2100 13900
|
||||||
F 0 "R35" H 2220 13996 50 0000 L CNN
|
F 0 "R35" H 2170 13946 50 0000 L CNN
|
||||||
F 1 "1k" H 2220 13905 50 0000 L CNN
|
F 1 "1k" H 2170 13855 50 0000 L CNN
|
||||||
F 2 "Resistor_SMD:R_0805_2012Metric" V 2080 13950 50 0001 C CNN
|
F 2 "Resistor_SMD:R_0805_2012Metric" V 2030 13900 50 0001 C CNN
|
||||||
F 3 "~" H 2150 13950 50 0001 C CNN
|
F 3 "~" H 2100 13900 50 0001 C CNN
|
||||||
F 4 "C95781" H 2150 13950 50 0001 C CNN "LCSC_PART_NUMBER"
|
F 4 "C95781" H 2100 13900 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
1 2150 13950
|
1 2100 13900
|
||||||
1 0 0 -1
|
1 0 0 -1
|
||||||
$EndComp
|
$EndComp
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
@ -2105,7 +2057,7 @@ U 1 1 603DF238
|
|||||||
P 8550 5750
|
P 8550 5750
|
||||||
F 0 "Reset1" H 8550 6035 50 0000 C CNN
|
F 0 "Reset1" H 8550 6035 50 0000 C CNN
|
||||||
F 1 "SW_Push" H 8550 5944 50 0000 C CNN
|
F 1 "SW_Push" H 8550 5944 50 0000 C CNN
|
||||||
F 2 "Button_Switch_SMD:SW_Push_1P1T_NO_CK_KMR2" H 8550 5950 50 0001 C CNN
|
F 2 "Button_Switch_SMD:SW_SPST_CK_RS282G05A3" H 8550 5950 50 0001 C CNN
|
||||||
F 3 "~" H 8550 5950 50 0001 C CNN
|
F 3 "~" H 8550 5950 50 0001 C CNN
|
||||||
F 4 "C72443" H 8550 5750 50 0001 C CNN "LCSC_PART_NUMBER"
|
F 4 "C72443" H 8550 5750 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
1 8550 5750
|
1 8550 5750
|
||||||
@ -2253,7 +2205,7 @@ U 1 1 60983DAC
|
|||||||
P 11650 4150
|
P 11650 4150
|
||||||
F 0 "Boot1" H 11650 4435 50 0000 C CNN
|
F 0 "Boot1" H 11650 4435 50 0000 C CNN
|
||||||
F 1 "Boot" H 11650 4344 50 0000 C CNN
|
F 1 "Boot" H 11650 4344 50 0000 C CNN
|
||||||
F 2 "Button_Switch_SMD:SW_Push_1P1T_NO_CK_KMR2" H 11650 4350 50 0001 C CNN
|
F 2 "Button_Switch_SMD:SW_SPST_CK_RS282G05A3" H 11650 4350 50 0001 C CNN
|
||||||
F 3 "~" H 11650 4350 50 0001 C CNN
|
F 3 "~" H 11650 4350 50 0001 C CNN
|
||||||
F 4 "C72443" H 11650 4150 50 0001 C CNN "LCSC_PART_NUMBER"
|
F 4 "C72443" H 11650 4150 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
1 11650 4150
|
1 11650 4150
|
||||||
@ -2322,7 +2274,7 @@ L Device:R R2
|
|||||||
U 1 1 60983DD4
|
U 1 1 60983DD4
|
||||||
P 11800 5450
|
P 11800 5450
|
||||||
F 0 "R2" V 11593 5450 50 0000 C CNN
|
F 0 "R2" V 11593 5450 50 0000 C CNN
|
||||||
F 1 "10k" V 11684 5450 50 0000 C CNN
|
F 1 "1k" V 11684 5450 50 0000 C CNN
|
||||||
F 2 "Resistor_SMD:R_0805_2012Metric" V 11730 5450 50 0001 C CNN
|
F 2 "Resistor_SMD:R_0805_2012Metric" V 11730 5450 50 0001 C CNN
|
||||||
F 3 "~" H 11800 5450 50 0001 C CNN
|
F 3 "~" H 11800 5450 50 0001 C CNN
|
||||||
F 4 "C212284" H 11800 5450 50 0001 C CNN "LCSC_PART_NUMBER"
|
F 4 "C212284" H 11800 5450 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
@ -2517,7 +2469,7 @@ Wire Wire Line
|
|||||||
19350 10500 19400 10500
|
19350 10500 19400 10500
|
||||||
Text GLabel 3650 900 0 50 Input ~ 0
|
Text GLabel 3650 900 0 50 Input ~ 0
|
||||||
3_3V
|
3_3V
|
||||||
Text GLabel 5000 1050 2 50 Input ~ 0
|
Text GLabel 5400 1000 2 50 Input ~ 0
|
||||||
3_3V
|
3_3V
|
||||||
$Comp
|
$Comp
|
||||||
L Device:R R4
|
L Device:R R4
|
||||||
@ -2536,7 +2488,7 @@ L Device:R R48
|
|||||||
U 1 1 60592B8B
|
U 1 1 60592B8B
|
||||||
P 19000 11550
|
P 19000 11550
|
||||||
F 0 "R48" V 18793 11550 50 0000 C CNN
|
F 0 "R48" V 18793 11550 50 0000 C CNN
|
||||||
F 1 "10k" V 18884 11550 50 0000 C CNN
|
F 1 "1k" V 18884 11550 50 0000 C CNN
|
||||||
F 2 "Resistor_SMD:R_0805_2012Metric" V 18930 11550 50 0001 C CNN
|
F 2 "Resistor_SMD:R_0805_2012Metric" V 18930 11550 50 0001 C CNN
|
||||||
F 3 "~" H 19000 11550 50 0001 C CNN
|
F 3 "~" H 19000 11550 50 0001 C CNN
|
||||||
F 4 "C212284" H 19000 11550 50 0001 C CNN "LCSC_PART_NUMBER"
|
F 4 "C212284" H 19000 11550 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
@ -2609,18 +2561,6 @@ Wire Wire Line
|
|||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
19500 10300 19450 10300
|
19500 10300 19450 10300
|
||||||
$Comp
|
$Comp
|
||||||
L Device:R R54
|
|
||||||
U 1 1 60B3E4F0
|
|
||||||
P 19300 11400
|
|
||||||
F 0 "R54" H 19230 11354 50 0000 R CNN
|
|
||||||
F 1 "100k" H 19230 11445 50 0000 R CNN
|
|
||||||
F 2 "Resistor_SMD:R_0805_2012Metric" V 19230 11400 50 0001 C CNN
|
|
||||||
F 3 "~" H 19300 11400 50 0001 C CNN
|
|
||||||
F 4 "C702859" H 19300 11400 50 0001 C CNN "LCSC_PART_NUMBER"
|
|
||||||
1 19300 11400
|
|
||||||
0 -1 -1 0
|
|
||||||
$EndComp
|
|
||||||
$Comp
|
|
||||||
L Device:C C21
|
L Device:C C21
|
||||||
U 1 1 60B3E4F7
|
U 1 1 60B3E4F7
|
||||||
P 19750 11150
|
P 19750 11150
|
||||||
@ -2632,11 +2572,7 @@ F 4 "C49678" H 19750 11150 50 0001 C CNN "LCSC_PART_NUMBER"
|
|||||||
1 19750 11150
|
1 19750 11150
|
||||||
0 -1 -1 0
|
0 -1 -1 0
|
||||||
$EndComp
|
$EndComp
|
||||||
Wire Wire Line
|
|
||||||
19000 11400 19150 11400
|
|
||||||
Connection ~ 19000 11400
|
Connection ~ 19000 11400
|
||||||
Wire Wire Line
|
|
||||||
19450 11400 19600 11400
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
19600 11400 19600 11150
|
19600 11400 19600 11150
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
@ -2677,8 +2613,6 @@ Wire Wire Line
|
|||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
21900 7700 21850 7700
|
21900 7700 21850 7700
|
||||||
Connection ~ 21850 7700
|
Connection ~ 21850 7700
|
||||||
Text Notes 4900 1400 0 50 ~ 0
|
|
||||||
todo: Add DIODEs for onewire
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
11300 6350 11400 6350
|
11300 6350 11400 6350
|
||||||
Connection ~ 3700 900
|
Connection ~ 3700 900
|
||||||
@ -2750,164 +2684,8 @@ Wire Wire Line
|
|||||||
11300 5850 11400 5850
|
11300 5850 11400 5850
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
11300 6050 11400 6050
|
11300 6050 11400 6050
|
||||||
Text GLabel 1500 3600 0 50 Input ~ 0
|
|
||||||
ESP_TX
|
|
||||||
Text GLabel 1500 3700 0 50 Input ~ 0
|
|
||||||
ESP_RX
|
|
||||||
$Comp
|
|
||||||
L Transistor_BJT:BC337 Q13
|
|
||||||
U 1 1 602B8D19
|
|
||||||
P 1200 4800
|
|
||||||
F 0 "Q13" H 1391 4846 50 0000 L CNN
|
|
||||||
F 1 "BC817" H 1391 4755 50 0000 L CNN
|
|
||||||
F 2 "Package_TO_SOT_SMD:SOT-23" H 1400 4725 50 0001 L CIN
|
|
||||||
F 3 "" H 1200 4800 50 0001 L CNN
|
|
||||||
F 4 "C908259" H 1200 4800 50 0001 C CNN "LCSC_PART_NUMBER"
|
|
||||||
1 1200 4800
|
|
||||||
-1 0 0 -1
|
|
||||||
$EndComp
|
|
||||||
$Comp
|
|
||||||
L Transistor_BJT:BC337 Q14
|
|
||||||
U 1 1 6031A86F
|
|
||||||
P 1200 5600
|
|
||||||
F 0 "Q14" H 1391 5554 50 0000 L CNN
|
|
||||||
F 1 "BC817" H 1391 5645 50 0000 L CNN
|
|
||||||
F 2 "Package_TO_SOT_SMD:SOT-23" H 1400 5525 50 0001 L CIN
|
|
||||||
F 3 "" H 1200 5600 50 0001 L CNN
|
|
||||||
F 4 "C908259" H 1200 5600 50 0001 C CNN "LCSC_PART_NUMBER"
|
|
||||||
1 1200 5600
|
|
||||||
-1 0 0 1
|
|
||||||
$EndComp
|
|
||||||
$Comp
|
|
||||||
L Device:R R20
|
|
||||||
U 1 1 6031B230
|
|
||||||
P 1650 4800
|
|
||||||
F 0 "R20" V 1443 4800 50 0000 C CNN
|
|
||||||
F 1 "10k" V 1534 4800 50 0000 C CNN
|
|
||||||
F 2 "Resistor_SMD:R_0805_2012Metric" V 1580 4800 50 0001 C CNN
|
|
||||||
F 3 "~" H 1650 4800 50 0001 C CNN
|
|
||||||
F 4 "C212284" H 1650 4800 50 0001 C CNN "LCSC_PART_NUMBER"
|
|
||||||
1 1650 4800
|
|
||||||
0 -1 -1 0
|
|
||||||
$EndComp
|
|
||||||
$Comp
|
|
||||||
L Device:R R56
|
|
||||||
U 1 1 6031B7FB
|
|
||||||
P 1650 5600
|
|
||||||
F 0 "R56" V 1443 5600 50 0000 C CNN
|
|
||||||
F 1 "10k" V 1534 5600 50 0000 C CNN
|
|
||||||
F 2 "Resistor_SMD:R_0805_2012Metric" V 1580 5600 50 0001 C CNN
|
|
||||||
F 3 "~" H 1650 5600 50 0001 C CNN
|
|
||||||
F 4 "C212284" H 1650 5600 50 0001 C CNN "LCSC_PART_NUMBER"
|
|
||||||
1 1650 5600
|
|
||||||
0 -1 -1 0
|
|
||||||
$EndComp
|
|
||||||
Text GLabel 2000 4800 2 50 Input ~ 0
|
|
||||||
DTR
|
|
||||||
Text GLabel 1950 5600 2 50 Input ~ 0
|
|
||||||
RTS
|
|
||||||
Wire Wire Line
|
|
||||||
1400 4800 1500 4800
|
|
||||||
Wire Wire Line
|
|
||||||
1800 4800 1900 4800
|
|
||||||
Wire Wire Line
|
|
||||||
1800 5600 1850 5600
|
|
||||||
Wire Wire Line
|
|
||||||
1100 5000 1100 5200
|
|
||||||
Wire Wire Line
|
|
||||||
1100 5200 1850 5200
|
|
||||||
Wire Wire Line
|
|
||||||
1850 5200 1850 5600
|
|
||||||
Connection ~ 1850 5600
|
|
||||||
Wire Wire Line
|
|
||||||
1850 5600 1950 5600
|
|
||||||
Wire Wire Line
|
|
||||||
1400 5600 1500 5600
|
|
||||||
Wire Wire Line
|
|
||||||
1100 5400 1100 5300
|
|
||||||
Wire Wire Line
|
|
||||||
1900 5300 1900 4800
|
|
||||||
Wire Wire Line
|
|
||||||
1100 5300 1900 5300
|
|
||||||
Connection ~ 1900 4800
|
|
||||||
Wire Wire Line
|
|
||||||
1900 4800 2000 4800
|
|
||||||
Wire Wire Line
|
|
||||||
1100 4600 1100 4450
|
|
||||||
Wire Wire Line
|
|
||||||
1100 4450 950 4450
|
|
||||||
Wire Wire Line
|
|
||||||
1100 5800 1100 5900
|
|
||||||
Wire Wire Line
|
|
||||||
1100 5900 1000 5900
|
|
||||||
Text GLabel 1000 5900 0 50 Input ~ 0
|
|
||||||
IO0
|
|
||||||
Text GLabel 950 4450 0 50 Input ~ 0
|
|
||||||
EN
|
|
||||||
Text GLabel 12100 5150 2 50 Input ~ 0
|
|
||||||
IO0
|
|
||||||
Wire Wire Line
|
|
||||||
11650 4950 11650 5150
|
|
||||||
Wire Wire Line
|
|
||||||
11800 5150 11650 5150
|
|
||||||
Connection ~ 11650 5150
|
|
||||||
Wire Wire Line
|
|
||||||
11650 5150 11650 5450
|
|
||||||
Wire Wire Line
|
|
||||||
9350 5750 9500 5750
|
|
||||||
Text GLabel 9500 5450 1 50 Input ~ 0
|
|
||||||
EN
|
|
||||||
$Comp
|
|
||||||
L Jumper:SolderJumper_2_Bridged EN1
|
|
||||||
U 1 1 605896D0
|
|
||||||
P 9500 5600
|
|
||||||
F 0 "EN1" V 9454 5668 50 0000 L CNN
|
|
||||||
F 1 "NC" V 9545 5668 50 0000 L CNN
|
|
||||||
F 2 "Jumper:SolderJumper-2_P1.3mm_Bridged_Pad1.0x1.5mm" H 9500 5600 50 0001 C CNN
|
|
||||||
F 3 "~" H 9500 5600 50 0001 C CNN
|
|
||||||
1 9500 5600
|
|
||||||
0 -1 -1 0
|
|
||||||
$EndComp
|
|
||||||
$Comp
|
|
||||||
L Jumper:SolderJumper_2_Bridged IO0_1
|
|
||||||
U 1 1 60596D62
|
|
||||||
P 11950 5150
|
|
||||||
F 0 "IO0_1" V 11904 5218 50 0000 L CNN
|
|
||||||
F 1 "NC" V 11995 5218 50 0000 L CNN
|
|
||||||
F 2 "Jumper:SolderJumper-2_P1.3mm_Bridged_Pad1.0x1.5mm" H 11950 5150 50 0001 C CNN
|
|
||||||
F 3 "~" H 11950 5150 50 0001 C CNN
|
|
||||||
1 11950 5150
|
|
||||||
1 0 0 -1
|
|
||||||
$EndComp
|
|
||||||
Connection ~ 9500 5750
|
|
||||||
Wire Wire Line
|
|
||||||
9500 5750 9800 5750
|
|
||||||
Text GLabel 1500 3500 0 50 Input ~ 0
|
|
||||||
DTR
|
|
||||||
Text GLabel 1500 3900 0 50 Input ~ 0
|
|
||||||
RTS
|
|
||||||
$Comp
|
|
||||||
L Connector:Conn_01x06_Female J1
|
|
||||||
U 1 1 6068F329
|
|
||||||
P 1700 3700
|
|
||||||
F 0 "J1" H 1728 3676 50 0000 L CNN
|
|
||||||
F 1 "Conn_01x06_Female" H 1728 3585 50 0000 L CNN
|
|
||||||
F 2 "Connector_PinHeader_2.54mm:PinHeader_1x06_P2.54mm_Vertical" H 1700 3700 50 0001 C CNN
|
|
||||||
F 3 "~" H 1700 3700 50 0001 C CNN
|
|
||||||
1 1700 3700
|
|
||||||
1 0 0 -1
|
|
||||||
$EndComp
|
|
||||||
Text GLabel 1500 4000 0 50 Input ~ 0
|
|
||||||
GND
|
|
||||||
NoConn ~ 1500 3800
|
|
||||||
Text Notes 1150 3300 0 105 ~ 0
|
|
||||||
ESP32 UART
|
|
||||||
Text Notes 800 4350 0 105 ~ 0
|
|
||||||
UART Automatic Download
|
|
||||||
Text Notes 2950 3300 0 105 ~ 0
|
Text Notes 2950 3300 0 105 ~ 0
|
||||||
Hall Sensor Serial2|Trigger/Echo
|
Hall Sensor Serial2|Trigger/Echo
|
||||||
Text Notes 1050 6750 0 50 ~ 0
|
|
||||||
Enable = 0 -> ESP32 is off\nEnable = 1 -> ESP32 is running\nGPIO0 = 0 -> Download mode\nGPIO0 = 1 -> "normal" boot\n\nDTR RTS | EN IO0\n1 1 | 1 1\n1 0 | 0 1\n0 1 | 1 0\n0 0 | 1 1
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
10550 4850 10650 4850
|
10550 4850 10650 4850
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
@ -2968,11 +2746,9 @@ Wire Wire Line
|
|||||||
3950 3750 4000 3750
|
3950 3750 4000 3750
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
4000 4050 3950 4050
|
4000 4050 3950 4050
|
||||||
Wire Wire Line
|
|
||||||
8400 1550 8350 1550
|
|
||||||
Text GLabel 9050 1550 1 50 Input ~ 0
|
Text GLabel 9050 1550 1 50 Input ~ 0
|
||||||
3_3V
|
3_3V
|
||||||
Text GLabel 8350 1550 0 50 Input ~ 0
|
Text GLabel 8200 1550 0 50 Input ~ 0
|
||||||
GND
|
GND
|
||||||
$Comp
|
$Comp
|
||||||
L Diode:BAS40-04 D16
|
L Diode:BAS40-04 D16
|
||||||
@ -3020,10 +2796,8 @@ Wire Wire Line
|
|||||||
11300 5950 11400 5950
|
11300 5950 11400 5950
|
||||||
Text GLabel 8900 2900 3 50 Input ~ 0
|
Text GLabel 8900 2900 3 50 Input ~ 0
|
||||||
GPIO2
|
GPIO2
|
||||||
Text GLabel 8650 1750 0 50 Input ~ 0
|
Text GLabel 8350 1750 0 50 Input ~ 0
|
||||||
CUSTOM_GPIO1
|
CUSTOM_GPIO1
|
||||||
Wire Wire Line
|
|
||||||
8650 1750 8700 1750
|
|
||||||
Connection ~ 8700 1750
|
Connection ~ 8700 1750
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
8700 1750 9500 1750
|
8700 1750 9500 1750
|
||||||
@ -3321,8 +3095,138 @@ Wire Wire Line
|
|||||||
11950 8050 12350 8050
|
11950 8050 12350 8050
|
||||||
Text Notes 16600 7300 0 207 ~ 0
|
Text Notes 16600 7300 0 207 ~ 0
|
||||||
TODO: Richtige Shot-Diode bestellen
|
TODO: Richtige Shot-Diode bestellen
|
||||||
Text Notes 7800 4150 0 129 ~ 0
|
Wire Wire Line
|
||||||
TODO: Button mit nur zwei Pins nutzen, statt den 4pin-varianten
|
15050 5750 15050 6100
|
||||||
Text Notes 3100 5200 0 129 ~ 0
|
Connection ~ 14750 6100
|
||||||
TODO: Stiftleisten bestellen!!!!!!!!!!!!!!\n\nPumpe LED einen Mililmeter nach links aufm PCB schieben\n\nHW- An&Ausschalter
|
Wire Wire Line
|
||||||
|
14750 6100 15050 6100
|
||||||
|
Text GLabel 14700 6100 0 50 Input ~ 0
|
||||||
|
PWR_PUMP_CONVERTER
|
||||||
|
Wire Wire Line
|
||||||
|
5250 1700 5300 1700
|
||||||
|
Text GLabel 5300 1700 2 50 Input ~ 0
|
||||||
|
GND
|
||||||
|
$Comp
|
||||||
|
L Diode:BAS40-04 D28
|
||||||
|
U 1 1 60B6BC6E
|
||||||
|
P 4950 1600
|
||||||
|
F 0 "D28" H 4950 1925 50 0000 C CNN
|
||||||
|
F 1 "BAS40-04" H 4950 1834 50 0000 C CNN
|
||||||
|
F 2 "Package_TO_SOT_SMD:SOT-23" H 4700 1900 50 0001 L CNN
|
||||||
|
F 3 "http://www.vishay.com/docs/85701/bas40v.pdf" H 4830 1700 50 0001 C CNN
|
||||||
|
F 4 "C397601" H 4950 1600 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
|
1 4950 1600
|
||||||
|
-1 0 0 1
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
4650 1700 4600 1700
|
||||||
|
Text GLabel 4950 1500 1 50 Input ~ 0
|
||||||
|
Temp
|
||||||
|
Text GLabel 4600 1700 3 50 Input ~ 0
|
||||||
|
3_3V
|
||||||
|
$Comp
|
||||||
|
L Device:CP C26
|
||||||
|
U 1 1 60BF7877
|
||||||
|
P 16600 9500
|
||||||
|
F 0 "C26" H 16715 9546 50 0000 L CNN
|
||||||
|
F 1 "1000uF" H 16715 9455 50 0000 L CNN
|
||||||
|
F 2 "Capacitor_THT:CP_Radial_D10.0mm_P5.00mm" H 16638 9350 50 0001 C CNN
|
||||||
|
F 3 "~" H 16600 9500 50 0001 C CNN
|
||||||
|
F 4 "C503217" H 16600 9500 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
|
1 16600 9500
|
||||||
|
0 -1 -1 0
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
16450 9500 16400 9500
|
||||||
|
Connection ~ 16400 9500
|
||||||
|
Wire Wire Line
|
||||||
|
16400 9500 16400 9600
|
||||||
|
Wire Wire Line
|
||||||
|
16750 9500 16750 9550
|
||||||
|
Wire Wire Line
|
||||||
|
16400 9300 16400 9500
|
||||||
|
Connection ~ 16750 9500
|
||||||
|
Wire Wire Line
|
||||||
|
19000 11400 19600 11400
|
||||||
|
$Comp
|
||||||
|
L Device:R R54
|
||||||
|
U 1 1 60C0C50E
|
||||||
|
P 8350 1650
|
||||||
|
F 0 "R54" V 8550 1600 50 0000 L CNN
|
||||||
|
F 1 "10k" V 8450 1550 50 0000 L CNN
|
||||||
|
F 2 "Resistor_SMD:R_0805_2012Metric" V 8280 1650 50 0001 C CNN
|
||||||
|
F 3 "~" H 8350 1650 50 0001 C CNN
|
||||||
|
F 4 "C212284" H 8350 1650 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
|
1 8350 1650
|
||||||
|
0 1 1 0
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
8200 1550 8200 1650
|
||||||
|
Wire Wire Line
|
||||||
|
8200 1550 8400 1550
|
||||||
|
Wire Wire Line
|
||||||
|
8350 1750 8500 1750
|
||||||
|
Wire Wire Line
|
||||||
|
8500 1650 8500 1750
|
||||||
|
Connection ~ 8500 1750
|
||||||
|
Wire Wire Line
|
||||||
|
8500 1750 8700 1750
|
||||||
|
Wire Wire Line
|
||||||
|
9350 5750 9800 5750
|
||||||
|
Wire Wire Line
|
||||||
|
11650 4950 11650 5450
|
||||||
|
Text Notes 1150 3300 0 105 ~ 0
|
||||||
|
ESP32 UART
|
||||||
|
Text GLabel 1550 3550 2 50 Input ~ 0
|
||||||
|
GND
|
||||||
|
$Comp
|
||||||
|
L Connector:Conn_01x03_Male J1
|
||||||
|
U 1 1 6068F329
|
||||||
|
P 1350 3650
|
||||||
|
F 0 "J1" H 1378 3626 50 0000 L CNN
|
||||||
|
F 1 "Conn_01x03_Female" H 950 3450 50 0000 L CNN
|
||||||
|
F 2 "Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical" H 1350 3650 50 0001 C CNN
|
||||||
|
F 3 "~" H 1350 3650 50 0001 C CNN
|
||||||
|
1 1350 3650
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Text GLabel 1550 3750 2 50 Input ~ 0
|
||||||
|
ESP_RX
|
||||||
|
Text GLabel 1550 3650 2 50 Input ~ 0
|
||||||
|
ESP_TX
|
||||||
|
Wire Wire Line
|
||||||
|
2100 14050 2100 14500
|
||||||
|
Wire Wire Line
|
||||||
|
2100 14500 2150 14500
|
||||||
|
Connection ~ 2150 14500
|
||||||
|
Wire Wire Line
|
||||||
|
2800 14050 2800 14500
|
||||||
|
Wire Wire Line
|
||||||
|
2800 14500 2900 14500
|
||||||
|
Connection ~ 2900 14500
|
||||||
|
Wire Wire Line
|
||||||
|
3600 14050 3600 14500
|
||||||
|
Wire Wire Line
|
||||||
|
3600 14500 3700 14500
|
||||||
|
Connection ~ 3700 14500
|
||||||
|
Wire Wire Line
|
||||||
|
4500 14500 4400 14500
|
||||||
|
Wire Wire Line
|
||||||
|
4400 14500 4400 14050
|
||||||
|
Connection ~ 4500 14500
|
||||||
|
Wire Wire Line
|
||||||
|
5950 14050 5950 14500
|
||||||
|
Wire Wire Line
|
||||||
|
5950 14500 6050 14500
|
||||||
|
Connection ~ 6050 14500
|
||||||
|
Wire Wire Line
|
||||||
|
6850 14500 6750 14500
|
||||||
|
Wire Wire Line
|
||||||
|
6750 14500 6750 14050
|
||||||
|
Connection ~ 6850 14500
|
||||||
|
Wire Wire Line
|
||||||
|
5150 14050 5150 14500
|
||||||
|
Wire Wire Line
|
||||||
|
5150 14500 5250 14500
|
||||||
|
Connection ~ 5250 14500
|
||||||
$EndSCHEMATC
|
$EndSCHEMATC
|
||||||
|
@ -18,7 +18,10 @@
|
|||||||
"string": "cpp",
|
"string": "cpp",
|
||||||
"typeinfo": "cpp",
|
"typeinfo": "cpp",
|
||||||
"cmath": "cpp",
|
"cmath": "cpp",
|
||||||
"iterator": "cpp"
|
"iterator": "cpp",
|
||||||
|
"array": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"utility": "cpp"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,39 +46,39 @@
|
|||||||
/** \addtogroup GPIO Settings
|
/** \addtogroup GPIO Settings
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define SENSOR_PLANT0 32 /**< GPIO 32 (ADC1) */
|
#define SENSOR_PLANT0 GPIO_NUM_32 /**< GPIO 32 (ADC1) */
|
||||||
#define SENSOR_PLANT1 33 /**< GPIO 33 (ADC1) */
|
#define SENSOR_PLANT1 GPIO_NUM_33 /**< GPIO 33 (ADC1) */
|
||||||
#define SENSOR_PLANT2 25 /**< GPIO 25 (ADC2) */
|
#define SENSOR_PLANT2 GPIO_NUM_25 /**< GPIO 25 (ADC2) */
|
||||||
#define SENSOR_PLANT3 26 /**< GPIO 26 (ADC2) */
|
#define SENSOR_PLANT3 GPIO_NUM_26 /**< GPIO 26 (ADC2) */
|
||||||
#define SENSOR_PLANT4 27 /**< GPIO 27 (ADC2) */
|
#define SENSOR_PLANT4 GPIO_NUM_27 /**< GPIO 27 (ADC2) */
|
||||||
#define SENSOR_PLANT5 39 /**< SENSOR_VIN */
|
#define SENSOR_PLANT5 GPIO_NUM_39 /**< SENSOR_VIN */
|
||||||
#define SENSOR_PLANT6 36 /**< SENSOR_VP */
|
#define SENSOR_PLANT6 GPIO_NUM_36 /**< SENSOR_VP */
|
||||||
|
|
||||||
#define OUTPUT_PUMP0 15 /**< GPIO 15 */
|
#define OUTPUT_PUMP0 GPIO_NUM_15 /**< GPIO 15 */
|
||||||
#define OUTPUT_PUMP1 5 /**< GPIO 5 */
|
#define OUTPUT_PUMP1 GPIO_NUM_5 /**< GPIO 5 */
|
||||||
#define OUTPUT_PUMP2 18 /**< GPIO 18 */
|
#define OUTPUT_PUMP2 GPIO_NUM_18 /**< GPIO 18 */
|
||||||
#define OUTPUT_PUMP3 19 /**< GPIO 19 */
|
#define OUTPUT_PUMP3 GPIO_NUM_19 /**< GPIO 19 */
|
||||||
#define OUTPUT_PUMP4 21 /**< GPIO 21 */
|
#define OUTPUT_PUMP4 GPIO_NUM_21 /**< GPIO 21 */
|
||||||
#define OUTPUT_PUMP5 22 /**< GPIO 22 */
|
#define OUTPUT_PUMP5 GPIO_NUM_22 /**< GPIO 22 */
|
||||||
#define OUTPUT_PUMP6 23 /**< GPIO 23 */
|
#define OUTPUT_PUMP6 GPIO_NUM_23 /**< GPIO 23 */
|
||||||
|
|
||||||
#define OUTPUT_ENABLE_SENSOR 14 /**< GPIO 14 - Enable Sensors */
|
#define OUTPUT_ENABLE_SENSOR GPIO_NUM_14 /**< GPIO 14 - Enable Sensors */
|
||||||
#define OUTPUT_ENABLE_PUMP 13 /**< GPIO 13 - Enable Pumps */
|
#define OUTPUT_ENABLE_PUMP GPIO_NUM_13 /**< GPIO 13 - Enable Pumps */
|
||||||
|
|
||||||
#define SENSOR_ONEWIRE 4 /**< GPIO 12 - Temperatur sensor, Battery and other cool onewire stuff */
|
#define SENSOR_ONEWIRE GPIO_NUM_4 /**< GPIO 12 - Temperatur sensor, Battery and other cool onewire stuff */
|
||||||
#define SENSOR_TANK_ECHO 16 /**< GPIO 16 - echo feedback of water sensor */
|
#define SENSOR_TANK_ECHO GPIO_NUM_16 /**< GPIO 16 - echo feedback of water sensor */
|
||||||
#define SENSOR_TANK_TRG 17 /**< GPIO 17 - trigger for water sensor */
|
#define SENSOR_TANK_TRG GPIO_NUM_17 /**< GPIO 17 - trigger for water sensor */
|
||||||
#define BUTTON 0 /**< GPIO 0 - Fix button of NodeMCU */
|
#define BUTTON GPIO_NUM_0 /**< GPIO 0 - Fix button of NodeMCU */
|
||||||
#define CUSTOM1_PIN3 2 /**< GPIO 2 - Custom GPIO controlling a MOSFET, connected to GND */
|
#define CUSTOM1_PIN3 GPIO_NUM_2 /**< GPIO 2 - Custom GPIO controlling a MOSFET, connected to GND */
|
||||||
#define CUSTOM1_PIN2 12 /**< GPIO 4 - custom GPIO directly connected to GPIO header */
|
#define CUSTOM1_PIN2 GPIO_NUM_12 /**< GPIO 4 - custom GPIO directly connected to GPIO header */
|
||||||
#define I2C1_PIN2 34 /**< GPIO 34 - I2C */
|
#define I2C1_PIN2 GPIO_NUM_34 /**< GPIO 34 - I2C */
|
||||||
#define I2C1_PIN3 35 /**< GPIO 35 - I2C */
|
#define I2C1_PIN3 GPIO_NUM_35 /**< GPIO 35 - I2C */
|
||||||
/* @} */
|
/* @} */
|
||||||
|
|
||||||
/** \addtogroup Configuration
|
/** \addtogroup Configuration
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define FIRMWARE_VERSION "1.1.0"
|
#define FIRMWARE_VERSION "sw 1.2 hw 0.9"
|
||||||
|
|
||||||
#define MOIST_SENSOR_MAX_ADC (85 * 4095 / 100)
|
#define MOIST_SENSOR_MAX_ADC (85 * 4095 / 100)
|
||||||
#define MOIST_SENSOR_MIN_ADC (25 * 4095 / 100)
|
#define MOIST_SENSOR_MIN_ADC (25 * 4095 / 100)
|
||||||
|
@ -67,9 +67,8 @@ typedef uint8_t DeviceAddress[8];
|
|||||||
|
|
||||||
class DS2438 {
|
class DS2438 {
|
||||||
public:
|
public:
|
||||||
DS2438(OneWire *ow, float currentShunt);
|
DS2438(OneWire *ow, float currentShunt, int retryOnCRCError);
|
||||||
DS2438(OneWire *ow, uint8_t *address);
|
|
||||||
|
|
||||||
void begin();
|
void begin();
|
||||||
void update();
|
void update();
|
||||||
double getTemperature();
|
double getTemperature();
|
||||||
@ -94,6 +93,7 @@ class DS2438 {
|
|||||||
float _voltageB;
|
float _voltageB;
|
||||||
float _current;
|
float _current;
|
||||||
float _currentShunt;
|
float _currentShunt;
|
||||||
|
int _retryOnCRCError;
|
||||||
long _CCA;
|
long _CCA;
|
||||||
long _DCA;
|
long _DCA;
|
||||||
long _ICA;
|
long _ICA;
|
||||||
|
@ -17,9 +17,9 @@ board_build.partitions = defaultWithSmallerSpiffs.csv
|
|||||||
|
|
||||||
; the latest development brankitchen-lightch (convention V3.0.x)
|
; the latest development brankitchen-lightch (convention V3.0.x)
|
||||||
lib_deps = ArduinoJson@6.16.1
|
lib_deps = ArduinoJson@6.16.1
|
||||||
https://github.com/homieiot/homie-esp8266.git#v3.0
|
|
||||||
OneWire
|
OneWire
|
||||||
DallasTemperature
|
DallasTemperature
|
||||||
|
https://github.com/homieiot/homie-esp8266.git#develop
|
||||||
|
|
||||||
[platformio]
|
[platformio]
|
||||||
|
|
||||||
|
@ -24,9 +24,10 @@
|
|||||||
|
|
||||||
#define DS2438MODEL 0x26
|
#define DS2438MODEL 0x26
|
||||||
|
|
||||||
DS2438::DS2438(OneWire *ow, float currentShunt = 1.0f) {
|
DS2438::DS2438(OneWire *ow, float currentShunt, int retryOnCRCError) {
|
||||||
_ow = ow;
|
_ow = ow;
|
||||||
_currentShunt = currentShunt;
|
_currentShunt = currentShunt;
|
||||||
|
_retryOnCRCError = retryOnCRCError;
|
||||||
};
|
};
|
||||||
|
|
||||||
void DS2438::begin(){
|
void DS2438::begin(){
|
||||||
@ -234,22 +235,26 @@ void DS2438::writePage(int page, uint8_t *data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean DS2438::readPage(int page, uint8_t *data) {
|
boolean DS2438::readPage(int page, uint8_t *data) {
|
||||||
//TODO if all data is 0 0 is a valid crc, but most likly not as intended
|
bool valid = false;
|
||||||
_ow->reset();
|
for(int retry = 0;retry < this->_retryOnCRCError && !valid; retry ++){
|
||||||
_ow->select(_address);
|
//TODO if all data is 0 0 is a valid crc, but most likly not as intended
|
||||||
_ow->write(DS2438_RECALL_MEMORY_COMMAND, 0);
|
_ow->reset();
|
||||||
if ((page >= PAGE_MIN) && (page <= PAGE_MAX)) {
|
_ow->select(_address);
|
||||||
|
_ow->write(DS2438_RECALL_MEMORY_COMMAND, 0);
|
||||||
|
if ((page >= PAGE_MIN) && (page <= PAGE_MAX)) {
|
||||||
|
_ow->write(page, 0);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_ow->reset();
|
||||||
|
_ow->select(_address);
|
||||||
|
_ow->write(DS2438_READ_SCRATCHPAD_COMMAND, 0);
|
||||||
_ow->write(page, 0);
|
_ow->write(page, 0);
|
||||||
} else {
|
for (int i = 0; i < 9; i++){
|
||||||
return false;
|
data[i] = _ow->read();
|
||||||
|
}
|
||||||
|
valid = _ow->crc8(data, 8) == data[8];
|
||||||
}
|
}
|
||||||
_ow->reset();
|
return valid;
|
||||||
_ow->select(_address);
|
|
||||||
_ow->write(DS2438_READ_SCRATCHPAD_COMMAND, 0);
|
|
||||||
_ow->write(page, 0);
|
|
||||||
for (int i = 0; i < 9; i++){
|
|
||||||
data[i] = _ow->read();
|
|
||||||
}
|
|
||||||
return _ow->crc8(data, 8) == data[8];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,8 +44,14 @@ void Plant::init(void)
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* Initialize Hardware */
|
/* Initialize Hardware */
|
||||||
|
Serial.println("Set GPIO mode " + String(mPinPump) + "=" + String(OUTPUT));
|
||||||
|
Serial.flush();
|
||||||
pinMode(this->mPinPump, OUTPUT);
|
pinMode(this->mPinPump, OUTPUT);
|
||||||
|
Serial.println("Set GPIO mode " + String(mPinSensor) + "=" + String(ANALOG));
|
||||||
|
Serial.flush();
|
||||||
pinMode(this->mPinSensor, ANALOG);
|
pinMode(this->mPinSensor, ANALOG);
|
||||||
|
Serial.println("Set GPIO " + String(mPinPump) + "=" + String(LOW));
|
||||||
|
Serial.flush();
|
||||||
digitalWrite(this->mPinPump, LOW);
|
digitalWrite(this->mPinPump, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,6 +75,8 @@ void Plant::postMQTTconnection(void)
|
|||||||
|
|
||||||
void Plant::deactivatePump(void)
|
void Plant::deactivatePump(void)
|
||||||
{
|
{
|
||||||
|
int plantId = this->mPlantId;
|
||||||
|
Serial << "deactivating pump " << plantId << endl;
|
||||||
digitalWrite(this->mPinPump, LOW);
|
digitalWrite(this->mPinPump, LOW);
|
||||||
if (this->mConnected)
|
if (this->mConnected)
|
||||||
{
|
{
|
||||||
@ -79,6 +87,8 @@ void Plant::deactivatePump(void)
|
|||||||
|
|
||||||
void Plant::activatePump(void)
|
void Plant::activatePump(void)
|
||||||
{
|
{
|
||||||
|
int plantId = this->mPlantId;
|
||||||
|
Serial << "activating pump " << plantId << endl;
|
||||||
digitalWrite(this->mPinPump, HIGH);
|
digitalWrite(this->mPinPump, HIGH);
|
||||||
if (this->mConnected)
|
if (this->mConnected)
|
||||||
{
|
{
|
||||||
|
@ -26,48 +26,62 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <OneWire.h>
|
#include <OneWire.h>
|
||||||
#include "DS2438.h"
|
#include "DS2438.h"
|
||||||
|
#include "soc/soc.h"
|
||||||
|
#include "soc/rtc_cntl_reg.h"
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
#define AMOUNT_SENOR_QUERYS 8
|
#define AMOUNT_SENOR_QUERYS 8
|
||||||
#define MAX_TANK_DEPTH 1000
|
#define MAX_TANK_DEPTH 1000
|
||||||
|
#define TEST_TOPIC "roundtrip\0"
|
||||||
|
#define BACKUP_TOPIC "$implementation/config/backup/set\0"
|
||||||
|
#define BACKUP_STATUS_TOPIC "$implementation/config/backup\0"
|
||||||
|
|
||||||
|
#define getTopic(test, topic) \
|
||||||
|
char *topic = new char[strlen(Homie.getConfiguration().mqtt.baseTopic) + strlen(Homie.getConfiguration().deviceId) + 1 + strlen(test) + 1]; \
|
||||||
|
strcpy(topic, Homie.getConfiguration().mqtt.baseTopic); \
|
||||||
|
strcat(topic, Homie.getConfiguration().deviceId); \
|
||||||
|
strcat(topic, "/"); \
|
||||||
|
strcat(topic, test);
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* FUNCTION PROTOTYPES
|
* FUNCTION PROTOTYPES
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
int determineNextPump();
|
int determineNextPump();
|
||||||
int readTemp();
|
void plantcontrol(boolean withHomie);
|
||||||
void plantcontrol();
|
void readPowerSwitchedSensors();
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* NON VOLATILE VARIABLES in DEEP SLEEP
|
* NON VOLATILE VARIABLES in DEEP SLEEP
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
RTC_DATA_ATTR int lastPumpRunning = 0; /**< store last successfully waterd plant */
|
RTC_SLOW_ATTR int lastPumpRunning = -1; /**< store last successfully waterd plant */
|
||||||
RTC_DATA_ATTR long lastWaterValue = 0; /**< to calculate the used water per plant */
|
RTC_SLOW_ATTR long lastWaterValue = 0; /**< to calculate the used water per plant */
|
||||||
|
|
||||||
RTC_DATA_ATTR long rtcLastWateringPlant[MAX_PLANTS] = { 0 };
|
RTC_SLOW_ATTR long rtcLastWateringPlant[MAX_PLANTS] = {0};
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* LOCAL VARIABLES
|
* LOCAL VARIABLES
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
bool volatile mDownloadMode = false; /**< Controller must not sleep */
|
bool volatile mDownloadMode = false; /**< Controller must not sleep */
|
||||||
bool volatile mDeepsleep = false; /**< about to sleep, clearing the todolist of the controller */
|
bool volatile mSensorsRead = false; /**< Sensors are read without Wifi or MQTT */
|
||||||
bool volatile mSensorsRead = false; /**< Sensors are read without Wifi or MQTT */
|
bool volatile mAliveWasRead = false;
|
||||||
|
bool volatile mMQTTReady = false;
|
||||||
|
|
||||||
bool mConfigured = false;
|
bool mConfigured = false;
|
||||||
long nextBlink = 0; /**< Time needed in main loop to support expected blink code */
|
long nextBlink = 0; /**< Time needed in main loop to support expected blink code */
|
||||||
|
|
||||||
RunningMedian waterRawSensor = RunningMedian(5);
|
RunningMedian waterRawSensor = RunningMedian(5);
|
||||||
float mSolarVoltage = 0.0f; /**< Voltage from solar panels */
|
float mSolarVoltage = 0.0f; /**< Voltage from solar panels */
|
||||||
|
unsigned long setupFinishedTimestamp;
|
||||||
|
|
||||||
/*************************** Hardware abstraction *****************************/
|
/*************************** Hardware abstraction *****************************/
|
||||||
|
|
||||||
OneWire oneWire(SENSOR_ONEWIRE);
|
OneWire oneWire(SENSOR_ONEWIRE);
|
||||||
DallasTemperature sensors(&oneWire);
|
DallasTemperature sensors(&oneWire);
|
||||||
DS2438 battery(&oneWire, 0.1f);
|
DS2438 battery(&oneWire, 0.0333333f, AMOUNT_SENOR_QUERYS);
|
||||||
|
|
||||||
Plant mPlants[MAX_PLANTS] = {
|
Plant mPlants[MAX_PLANTS] = {
|
||||||
Plant(SENSOR_PLANT0, OUTPUT_PUMP0, 0, &plant0, &mSetting0),
|
Plant(SENSOR_PLANT0, OUTPUT_PUMP0, 0, &plant0, &mSetting0),
|
||||||
@ -97,40 +111,42 @@ int getCurrentHour()
|
|||||||
return info.tm_hour;
|
return info.tm_hour;
|
||||||
}
|
}
|
||||||
|
|
||||||
void espDeepSleepFor(long seconds, bool activatePump = false)
|
void espDeepSleepFor(long seconds, bool activatePump, bool withHomieShutdown)
|
||||||
{
|
{
|
||||||
if (mDownloadMode)
|
if (mDownloadMode)
|
||||||
{
|
{
|
||||||
Serial << "abort deepsleep, DownloadMode active" << endl;
|
Serial << "abort deepsleep, DownloadMode active" << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 10; i++)
|
if (withHomieShutdown)
|
||||||
{
|
{
|
||||||
long cTime = getCurrentTime();
|
for (int i = 0; i < 10; i++)
|
||||||
if (cTime < 100000)
|
|
||||||
{
|
{
|
||||||
Serial << "Wait for ntp" << endl;
|
long cTime = getCurrentTime();
|
||||||
delay(100);
|
if (cTime < 100000)
|
||||||
}
|
{
|
||||||
else
|
Serial << "Wait for ntp" << endl;
|
||||||
{
|
delay(100);
|
||||||
break;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);
|
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_ON);
|
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_ON);
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_ON);
|
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
|
||||||
if (activatePump)
|
if (activatePump)
|
||||||
{
|
{
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_ON);
|
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_ON);
|
||||||
gpio_deep_sleep_hold_en();
|
gpio_deep_sleep_hold_en();
|
||||||
gpio_hold_en(GPIO_NUM_13); //pump pwr
|
gpio_hold_en(OUTPUT_ENABLE_PUMP); //pump pwr
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
|
gpio_hold_dis(OUTPUT_ENABLE_PUMP); //pump pwr
|
||||||
gpio_hold_dis(GPIO_NUM_13); //pump pwr
|
|
||||||
gpio_deep_sleep_hold_dis();
|
gpio_deep_sleep_hold_dis();
|
||||||
digitalWrite(OUTPUT_ENABLE_PUMP, LOW);
|
digitalWrite(OUTPUT_ENABLE_PUMP, LOW);
|
||||||
digitalWrite(OUTPUT_ENABLE_SENSOR, LOW);
|
digitalWrite(OUTPUT_ENABLE_SENSOR, LOW);
|
||||||
@ -139,64 +155,68 @@ void espDeepSleepFor(long seconds, bool activatePump = false)
|
|||||||
mPlants[i].deactivatePump();
|
mPlants[i].deactivatePump();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//gpio_hold_en(GPIO_NUM_23); //p0
|
gpio_hold_en(OUTPUT_PUMP0);
|
||||||
|
gpio_hold_en(OUTPUT_PUMP1);
|
||||||
|
gpio_hold_en(OUTPUT_PUMP2);
|
||||||
|
gpio_hold_en(OUTPUT_PUMP3);
|
||||||
|
gpio_hold_en(OUTPUT_PUMP4);
|
||||||
|
gpio_hold_en(OUTPUT_PUMP5);
|
||||||
|
gpio_hold_en(OUTPUT_PUMP6);
|
||||||
//FIXME fix for outher outputs
|
//FIXME fix for outher outputs
|
||||||
|
|
||||||
Serial.print("Trying to sleep for ");
|
Serial.print("Trying to sleep for ");
|
||||||
Serial.print(seconds);
|
Serial.print(seconds);
|
||||||
Serial.println(" seconds");
|
Serial.println(" seconds");
|
||||||
esp_sleep_enable_timer_wakeup((seconds * 1000U * 1000U));
|
esp_sleep_enable_timer_wakeup((seconds * 1000U * 1000U));
|
||||||
|
Serial.flush();
|
||||||
mDeepsleep = true;
|
if (withHomieShutdown)
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Read ultra sensor JSN-SR04T-2.0
|
|
||||||
* Read the distance of the water level.
|
|
||||||
*/
|
|
||||||
void readDistance()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < AMOUNT_SENOR_QUERYS; i++)
|
|
||||||
{
|
{
|
||||||
unsigned long duration = 0;
|
Homie.prepareToSleep();
|
||||||
|
}
|
||||||
digitalWrite(SENSOR_TANK_TRG, HIGH);
|
else
|
||||||
delayMicroseconds(20);
|
{
|
||||||
cli();
|
Serial << "Bye offline mode" << endl;
|
||||||
digitalWrite(SENSOR_TANK_TRG, LOW);
|
Serial.flush();
|
||||||
duration = pulseIn(SENSOR_TANK_ECHO, HIGH);
|
esp_deep_sleep_start();
|
||||||
sei();
|
|
||||||
|
|
||||||
int mmDis = duration * 0.3432 / 2;
|
|
||||||
if (mmDis > MAX_TANK_DEPTH)
|
|
||||||
{
|
|
||||||
waterRawSensor.add(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
waterRawSensor.add(mmDis);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
//requires homie being started
|
||||||
* @brief Sensors, that are connected to GPIOs, mandatory for WIFI.
|
void readOneWireSensors(bool withMQTT)
|
||||||
* These sensors (ADC2) can only be read when no Wifi is used.
|
|
||||||
*/
|
|
||||||
void readSensors()
|
|
||||||
{
|
{
|
||||||
int sensorCount = sensors.getDS18Count();
|
|
||||||
Serial << "Read Sensors" << endl;
|
|
||||||
/* activate all sensors */
|
|
||||||
digitalWrite(OUTPUT_ENABLE_SENSOR, HIGH);
|
|
||||||
|
|
||||||
for (uint8_t i = 0; i < sensorCount; i++)
|
Serial << "Read OneWire" << endl;
|
||||||
|
Serial.flush();
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < sensors.getDeviceCount(); i++)
|
||||||
{
|
{
|
||||||
DeviceAddress ds18b20Address;
|
uint8_t ds18b20Address[8];
|
||||||
sensors.getAddress(ds18b20Address, i);
|
|
||||||
float temp = sensors.getTempC(ds18b20Address);
|
bool valid = false;
|
||||||
Serial << "OneWire sensor " << i << " has value " << temp << endl;
|
float temp = -127;
|
||||||
char buf[sizeof(DeviceAddress) * 2];
|
for (int retry = 0; retry < AMOUNT_SENOR_QUERYS && !valid; retry++)
|
||||||
|
{
|
||||||
|
bool validAddress = sensors.getAddress(ds18b20Address, i);
|
||||||
|
if (validAddress && sensors.validFamily(ds18b20Address))
|
||||||
|
{
|
||||||
|
temp = sensors.getTempC(ds18b20Address);
|
||||||
|
if (temp != -127)
|
||||||
|
{
|
||||||
|
valid = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delay(10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!valid){
|
||||||
|
//wrong family or crc errors on each retry
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
char buf[sizeof(ds18b20Address) * 2];
|
||||||
snprintf(buf, sizeof(buf), "%.2X%.2X%.2X%.2X%.2X%.2X%.2X%.2X",
|
snprintf(buf, sizeof(buf), "%.2X%.2X%.2X%.2X%.2X%.2X%.2X%.2X",
|
||||||
ds18b20Address[0],
|
ds18b20Address[0],
|
||||||
ds18b20Address[1],
|
ds18b20Address[1],
|
||||||
@ -207,22 +227,51 @@ void readSensors()
|
|||||||
ds18b20Address[6],
|
ds18b20Address[6],
|
||||||
ds18b20Address[7]);
|
ds18b20Address[7]);
|
||||||
|
|
||||||
if (String(lipoSensorAddr.get()).compareTo(String(buf))) {
|
if (valid)
|
||||||
sensorTemp.setProperty(TEMPERATUR_SENSOR_LIPO).send(String(temp));
|
{
|
||||||
|
Serial << "DS18S20 Temperatur " << String(buf) << " : " << temp << " °C " << endl;
|
||||||
|
if (strcmp(lipoSensorAddr.get(),buf) == 0)
|
||||||
|
{
|
||||||
|
if (withMQTT)
|
||||||
|
{
|
||||||
|
sensorTemp.setProperty(TEMPERATUR_SENSOR_LIPO).send(String(temp));
|
||||||
|
}
|
||||||
Serial << "Lipo Temperatur " << temp << " °C " << endl;
|
Serial << "Lipo Temperatur " << temp << " °C " << endl;
|
||||||
} else if (String(waterSensorAddr.get()).compareTo(String(buf))) {
|
}
|
||||||
sensorTemp.setProperty(TEMPERATUR_SENSOR_WATER).send(String(temp));
|
if (strcmp(waterSensorAddr.get(),buf) == 0)
|
||||||
Serial << "Water Temperatur " << temp << " °C " << endl;
|
{
|
||||||
|
if (withMQTT)
|
||||||
|
{
|
||||||
|
sensorTemp.setProperty(TEMPERATUR_SENSOR_WATER).send(String(temp));
|
||||||
|
}
|
||||||
|
Serial << "Water Temperatur " << temp << " °C " << endl;
|
||||||
}
|
}
|
||||||
/* Always send the sensor address with the temperatur value */
|
/* Always send the sensor address with the temperatur value */
|
||||||
sensorTemp.setProperty(String(buf)).send(String(temp));
|
if (withMQTT)
|
||||||
Serial << "Temperatur " << String(buf) << " : " << temp << " °C " << endl;
|
{
|
||||||
|
sensorTemp.setProperty(String(buf)).send(String(temp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial << "DS18S20 sensor " << String(buf) << " could not be read " << temp << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update battery chip data
|
|
||||||
battery.update();
|
battery.update();
|
||||||
mSolarVoltage = battery.getVoltage(BATTSENSOR_INDEX_SOLAR) * SOLAR_VOLT_FACTOR;
|
mSolarVoltage = battery.getVoltage(BATTSENSOR_INDEX_SOLAR) * SOLAR_VOLT_FACTOR;
|
||||||
|
|
||||||
|
Serial.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sensors, that are connected to GPIOs, mandatory for WIFI.
|
||||||
|
* These sensors (ADC2) can only be read when no Wifi is used.
|
||||||
|
*/
|
||||||
|
void readPowerSwitchedSensors()
|
||||||
|
{
|
||||||
|
digitalWrite(OUTPUT_ENABLE_SENSOR, HIGH);
|
||||||
|
delay(10);
|
||||||
for (int readCnt = 0; readCnt < AMOUNT_SENOR_QUERYS; readCnt++)
|
for (int readCnt = 0; readCnt < AMOUNT_SENOR_QUERYS; readCnt++)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_PLANTS; i++)
|
for (int i = 0; i < MAX_PLANTS; i++)
|
||||||
@ -233,21 +282,119 @@ void readSensors()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Read the distance and give the temperature sensors some time */
|
/* Read the distance and give the temperature sensors some time */
|
||||||
readDistance();
|
{
|
||||||
|
for (int i = 0; i < AMOUNT_SENOR_QUERYS; i++)
|
||||||
|
{
|
||||||
|
unsigned long duration = 0;
|
||||||
|
|
||||||
|
digitalWrite(SENSOR_TANK_TRG, HIGH);
|
||||||
|
delayMicroseconds(20);
|
||||||
|
cli();
|
||||||
|
digitalWrite(SENSOR_TANK_TRG, LOW);
|
||||||
|
//10ms is > 2m tank depth
|
||||||
|
duration = pulseIn(SENSOR_TANK_ECHO, HIGH, 10);
|
||||||
|
sei();
|
||||||
|
|
||||||
|
int mmDis = duration * 0.3432 / 2;
|
||||||
|
if (mmDis > MAX_TANK_DEPTH)
|
||||||
|
{
|
||||||
|
waterRawSensor.add(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
waterRawSensor.add(mmDis);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Serial << "Distance sensor " << waterRawSensor.getAverage() << " cm" << endl;
|
Serial << "Distance sensor " << waterRawSensor.getAverage() << " cm" << endl;
|
||||||
|
|
||||||
/* deactivate the sensors */
|
/* deactivate the sensors */
|
||||||
digitalWrite(OUTPUT_ENABLE_SENSOR, LOW);
|
digitalWrite(OUTPUT_ENABLE_SENSOR, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool copyFile(const char *source, const char *target)
|
||||||
|
{
|
||||||
|
Serial << "copy started " << source << " -> " << target << endl;
|
||||||
|
byte buffer[512];
|
||||||
|
if (!SPIFFS.begin())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
File file = SPIFFS.open(source, FILE_READ);
|
||||||
|
File file2 = SPIFFS.open(target, FILE_WRITE);
|
||||||
|
Serial.flush();
|
||||||
|
if (!file)
|
||||||
|
{
|
||||||
|
Serial << "There was an error opening " << source << " for reading" << endl;
|
||||||
|
SPIFFS.end();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!file2)
|
||||||
|
{
|
||||||
|
Serial << "There was an error opening " << target << " for reading" << endl;
|
||||||
|
file.close();
|
||||||
|
SPIFFS.end();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
while (file.available())
|
||||||
|
{
|
||||||
|
int read = file.read(buffer, 512);
|
||||||
|
if (read < 0)
|
||||||
|
{
|
||||||
|
Serial << "copy file is fucked" << endl;
|
||||||
|
file.close();
|
||||||
|
file2.close();
|
||||||
|
SPIFFS.end();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
file.write(buffer, read);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file2.flush();
|
||||||
|
Serial << "copy finished " << source << " -> " << target << endl;
|
||||||
|
file.close();
|
||||||
|
file2.close();
|
||||||
|
SPIFFS.end();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void onMessage(char *incoming, char *payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total)
|
||||||
|
{
|
||||||
|
getTopic(TEST_TOPIC, testTopic);
|
||||||
|
if (strcmp(incoming, testTopic) == 0)
|
||||||
|
{
|
||||||
|
mAliveWasRead = true;
|
||||||
|
}
|
||||||
|
delete testTopic;
|
||||||
|
getTopic(BACKUP_TOPIC, backupTopic);
|
||||||
|
if (strcmp(incoming, backupTopic) == 0)
|
||||||
|
{
|
||||||
|
bool backupSucessful = copyFile("/homie/config.json", "/homie/config.old");
|
||||||
|
getTopic(BACKUP_STATUS_TOPIC, backupStatusTopic);
|
||||||
|
Homie.getMqttClient().publish(backupStatusTopic, 2, true, backupSucessful ? "true" : "false");
|
||||||
|
delete backupStatusTopic;
|
||||||
|
}
|
||||||
|
delete backupTopic;
|
||||||
|
}
|
||||||
|
|
||||||
void onHomieEvent(const HomieEvent &event)
|
void onHomieEvent(const HomieEvent &event)
|
||||||
{
|
{
|
||||||
switch (event.type)
|
switch (event.type)
|
||||||
{
|
{
|
||||||
|
case HomieEventType::READY_TO_SLEEP:
|
||||||
|
Serial << "Bye homie mode" << endl;
|
||||||
|
Serial.flush();
|
||||||
|
esp_deep_sleep_start();
|
||||||
|
break;
|
||||||
case HomieEventType::SENDING_STATISTICS:
|
case HomieEventType::SENDING_STATISTICS:
|
||||||
break;
|
break;
|
||||||
case HomieEventType::MQTT_READY:
|
case HomieEventType::MQTT_READY:
|
||||||
if (mSensorsRead) {
|
if (mSensorsRead)
|
||||||
|
{
|
||||||
Serial.printf("Timeout occured... too late!\r\n");
|
Serial.printf("Timeout occured... too late!\r\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -256,28 +403,39 @@ void onHomieEvent(const HomieEvent &event)
|
|||||||
Serial.printf("NTP Setup with server %s\r\n", ntpServer.get());
|
Serial.printf("NTP Setup with server %s\r\n", ntpServer.get());
|
||||||
configTime(0, 0, ntpServer.get());
|
configTime(0, 0, ntpServer.get());
|
||||||
|
|
||||||
Serial << "Setup plants" << endl;
|
Serial << "publish plants mqtt" << endl;
|
||||||
for (int i = 0; i < MAX_PLANTS; i++)
|
for (int i = 0; i < MAX_PLANTS; i++)
|
||||||
{
|
{
|
||||||
mPlants[i].postMQTTconnection();
|
mPlants[i].postMQTTconnection();
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
getTopic(TEST_TOPIC, testopic)
|
||||||
|
Homie.getMqttClient()
|
||||||
|
.subscribe(testopic, 2);
|
||||||
|
Homie.getMqttClient().publish(testopic, 2, false, "ping");
|
||||||
|
Homie.getMqttClient().onMessage(onMessage);
|
||||||
|
|
||||||
|
getTopic(BACKUP_TOPIC, backupTopic)
|
||||||
|
Homie.getMqttClient()
|
||||||
|
.subscribe(backupTopic, 2);
|
||||||
|
}
|
||||||
|
mMQTTReady = true;
|
||||||
|
|
||||||
plantcontrol();
|
|
||||||
break;
|
break;
|
||||||
case HomieEventType::OTA_STARTED:
|
case HomieEventType::OTA_STARTED:
|
||||||
Homie.getLogger() << "OTA started" << endl;
|
Homie.getLogger() << "OTA started" << endl;
|
||||||
digitalWrite(OUTPUT_ENABLE_SENSOR, HIGH);
|
|
||||||
digitalWrite(OUTPUT_ENABLE_PUMP, HIGH);
|
|
||||||
gpio_hold_dis(GPIO_NUM_13); //pump pwr
|
|
||||||
gpio_deep_sleep_hold_dis();
|
|
||||||
for (int i = 0; i < MAX_PLANTS; i++)
|
for (int i = 0; i < MAX_PLANTS; i++)
|
||||||
{
|
{
|
||||||
mPlants[i].deactivatePump();
|
mPlants[i].deactivatePump();
|
||||||
}
|
}
|
||||||
|
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
|
||||||
|
digitalWrite(OUTPUT_ENABLE_PUMP, HIGH);
|
||||||
|
delay(100);
|
||||||
|
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 1);
|
||||||
mDownloadMode = true;
|
mDownloadMode = true;
|
||||||
break;
|
break;
|
||||||
case HomieEventType::OTA_SUCCESSFUL:
|
case HomieEventType::OTA_SUCCESSFUL:
|
||||||
Homie.getLogger() << "OTA successfull" << endl;
|
Homie.getLogger() << "OTA successful" << endl;
|
||||||
digitalWrite(OUTPUT_ENABLE_SENSOR, LOW);
|
digitalWrite(OUTPUT_ENABLE_SENSOR, LOW);
|
||||||
digitalWrite(OUTPUT_ENABLE_PUMP, LOW);
|
digitalWrite(OUTPUT_ENABLE_PUMP, LOW);
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
@ -299,8 +457,8 @@ int determineNextPump()
|
|||||||
Serial.printf("%d Skip deactivated pump\r\n", i);
|
Serial.printf("%d Skip deactivated pump\r\n", i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((rtcLastWateringPlant[i] > 0)
|
if ((rtcLastWateringPlant[i] > 0) && ((rtcLastWateringPlant[i] + plant.getCooldownInSeconds()) < getCurrentTime()))
|
||||||
&& ((rtcLastWateringPlant[i] + plant.getCooldownInSeconds()) < getCurrentTime())) {
|
{
|
||||||
Serial.printf("%d Skipping due to cooldown %ld / %ld \r\n", i, rtcLastWateringPlant[i], plant.getCooldownInSeconds());
|
Serial.printf("%d Skipping due to cooldown %ld / %ld \r\n", i, rtcLastWateringPlant[i], plant.getCooldownInSeconds());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -316,12 +474,20 @@ int determineNextPump()
|
|||||||
}
|
}
|
||||||
if (plant.isPumpRequired())
|
if (plant.isPumpRequired())
|
||||||
{
|
{
|
||||||
if ((plant.getHoursStart() > getCurrentHour() && plant.getHoursEnd() < getCurrentHour()) ||
|
/* Handle e.g. start = 21, end = 8 */
|
||||||
(getCurrentTime() < 10000) /* no time from NTP received */)
|
if (((plant.getHoursStart() > plant.getHoursEnd()) &&
|
||||||
|
(getCurrentHour() >= plant.getHoursStart() || getCurrentHour() <= plant.getHoursEnd())) ||
|
||||||
|
/* Handle e.g. start = 8, end = 21 */
|
||||||
|
((plant.getHoursStart() < plant.getHoursEnd()) &&
|
||||||
|
(getCurrentHour() >= plant.getHoursStart() && getCurrentHour() <= plant.getHoursEnd())) ||
|
||||||
|
/* no time from NTP received */
|
||||||
|
(getCurrentTime() < 10000))
|
||||||
{
|
{
|
||||||
Serial.printf("%d Requested pumping\r\n", i);
|
Serial.printf("%d Requested pumping\r\n", i);
|
||||||
pumpToUse = i;
|
pumpToUse = i;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Serial.printf("%d ignored due to time boundary: %d to %d (current %d)\r\n", i, plant.getHoursStart(), plant.getHoursEnd(), getCurrentHour());
|
Serial.printf("%d ignored due to time boundary: %d to %d (current %d)\r\n", i, plant.getHoursStart(), plant.getHoursEnd(), getCurrentHour());
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@ -346,21 +512,33 @@ bool aliveHandler(const HomieRange &range, const String &value)
|
|||||||
{
|
{
|
||||||
if (range.isRange)
|
if (range.isRange)
|
||||||
return false; // only one controller is present
|
return false; // only one controller is present
|
||||||
|
Serial.println("aliuve handler");
|
||||||
|
Serial.flush();
|
||||||
if (value.equals("ON") || value.equals("On") || value.equals("1"))
|
if (value.equals("ON") || value.equals("On") || value.equals("1"))
|
||||||
{
|
{
|
||||||
mDownloadMode = true;
|
mDownloadMode = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (mDownloadMode)
|
||||||
|
{
|
||||||
|
esp_restart();
|
||||||
|
}
|
||||||
mDownloadMode = false;
|
mDownloadMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool notStarted = true;
|
||||||
void homieLoop()
|
void homieLoop()
|
||||||
{
|
{
|
||||||
|
if (mMQTTReady && mAliveWasRead && notStarted)
|
||||||
|
{
|
||||||
|
Serial.println("received alive & mqtt is ready");
|
||||||
|
notStarted = false;
|
||||||
|
plantcontrol(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -373,33 +551,41 @@ void setup()
|
|||||||
setCpuFrequencyMhz(80);
|
setCpuFrequencyMhz(80);
|
||||||
|
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial << endl
|
|
||||||
<< endl;
|
Serial << "Wifi mode set to " << WIFI_OFF << " to allow analog2 useage " << endl;
|
||||||
|
WiFi.mode(WIFI_OFF);
|
||||||
|
Serial.flush();
|
||||||
|
|
||||||
/* Intialize Plant */
|
/* Intialize Plant */
|
||||||
for (int i = 0; i < MAX_PLANTS; i++)
|
for (int i = 0; i < MAX_PLANTS; i++)
|
||||||
{
|
{
|
||||||
mPlants[i].init();
|
mPlants[i].init();
|
||||||
}
|
}
|
||||||
|
Serial.println("plants init");
|
||||||
|
Serial.flush();
|
||||||
// read button
|
// read button
|
||||||
pinMode(BUTTON, INPUT);
|
pinMode(BUTTON, INPUT);
|
||||||
|
|
||||||
// Power pins
|
// Power pins
|
||||||
pinMode(OUTPUT_ENABLE_PUMP, OUTPUT);
|
pinMode(OUTPUT_ENABLE_PUMP, OUTPUT);
|
||||||
|
|
||||||
|
digitalWrite(OUTPUT_ENABLE_PUMP, LOW);
|
||||||
|
|
||||||
pinMode(OUTPUT_ENABLE_SENSOR, OUTPUT);
|
pinMode(OUTPUT_ENABLE_SENSOR, OUTPUT);
|
||||||
|
|
||||||
if (HomieInternals::MAX_CONFIG_SETTING_SIZE < MAX_CONFIG_SETTING_ITEMS)
|
if (HomieInternals::MAX_CONFIG_SETTING_SIZE < MAX_CONFIG_SETTING_ITEMS)
|
||||||
{
|
{
|
||||||
//increase the config settings to 50 and the json to 3000
|
//increase the config settings to 50 and the json to 3000
|
||||||
Serial << "Limits.hpp" << endl;
|
Serial << "Limits.hpp is not adjusted, please search for this string and increase" << endl;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************* Start One-Wire bus ***************/
|
/************************* Start One-Wire bus ***************/
|
||||||
int timeoutTemp = millis() + TEMPERATUR_TIMEOUT;
|
int tempInitStartTime = millis();
|
||||||
uint8_t sensorCount = 0U;
|
uint8_t sensorCount = 0U;
|
||||||
|
|
||||||
/* Required to read the temperature at least once */
|
/* Required to read the temperature at least once */
|
||||||
while ((sensorCount == 0 || !battery.isFound()) && millis() < timeoutTemp)
|
while ((sensorCount == 0 || !battery.isFound()) && millis() < tempInitStartTime + TEMPERATUR_TIMEOUT)
|
||||||
{
|
{
|
||||||
sensors.begin();
|
sensors.begin();
|
||||||
battery.begin();
|
battery.begin();
|
||||||
@ -407,25 +593,27 @@ void setup()
|
|||||||
delay(50);
|
delay(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial << "One wire count: " << sensorCount << " found in " << (millis() - timeoutTemp) << "ms" << endl;
|
Serial << "DS18S20 count: " << sensorCount << " found in " << (millis() - tempInitStartTime) << " ms" << endl;
|
||||||
|
Serial.flush();
|
||||||
/* Measure temperature TODO idea: move this into setup */
|
/* Measure temperature TODO idea: move this into setup */
|
||||||
if (sensorCount > 0)
|
if (sensorCount > 0)
|
||||||
{
|
{
|
||||||
sensors.setResolution(DS18B20_RESOLUTION);
|
//sensors.setResolution(DS18B20_RESOLUTION);
|
||||||
sensors.requestTemperatures();
|
sensors.requestTemperatures();
|
||||||
}
|
}
|
||||||
|
Serial << "Reading sensors start" << endl;
|
||||||
|
Serial.flush();
|
||||||
|
readPowerSwitchedSensors();
|
||||||
|
Serial << "Reading sensors end" << endl;
|
||||||
|
Serial.flush();
|
||||||
/************************* Start Homie Framework ***************/
|
/************************* Start Homie Framework ***************/
|
||||||
WiFi.mode(WIFI_STA);
|
|
||||||
|
|
||||||
Homie_setFirmware("PlantControl", FIRMWARE_VERSION);
|
Homie_setFirmware("PlantControl", FIRMWARE_VERSION);
|
||||||
|
|
||||||
// Set default values
|
// Set default values
|
||||||
|
|
||||||
//in seconds
|
//in seconds
|
||||||
deepSleepTime.setDefaultValue(600).setValidator([](long candidate) {
|
deepSleepTime.setDefaultValue(600).setValidator([](long candidate)
|
||||||
return (candidate > 0) && (candidate < (60 * 60 * 2) /** 2h max sleep */);
|
{ return (candidate > 0) && (candidate < (60 * 60 * 2) /** 2h max sleep */); });
|
||||||
});
|
|
||||||
deepSleepNightTime.setDefaultValue(600);
|
deepSleepNightTime.setDefaultValue(600);
|
||||||
wateringDeepSleep.setDefaultValue(5);
|
wateringDeepSleep.setDefaultValue(5);
|
||||||
ntpServer.setDefaultValue("pool.ntp.org");
|
ntpServer.setDefaultValue("pool.ntp.org");
|
||||||
@ -439,11 +627,15 @@ void setup()
|
|||||||
Homie.setLoopFunction(homieLoop);
|
Homie.setLoopFunction(homieLoop);
|
||||||
Homie.onEvent(onHomieEvent);
|
Homie.onEvent(onHomieEvent);
|
||||||
//Homie.disableLogging();
|
//Homie.disableLogging();
|
||||||
|
|
||||||
Homie.setup();
|
Homie.setup();
|
||||||
|
|
||||||
mConfigured = Homie.isConfigured();
|
mConfigured = Homie.isConfigured();
|
||||||
if (mConfigured)
|
if (mConfigured)
|
||||||
{
|
{
|
||||||
|
Serial << "Wifi mode set to " << WIFI_STA << endl;
|
||||||
|
WiFi.mode(WIFI_STA);
|
||||||
|
|
||||||
for (int i = 0; i < MAX_PLANTS; i++)
|
for (int i = 0; i < MAX_PLANTS; i++)
|
||||||
{
|
{
|
||||||
mPlants[i].advertise();
|
mPlants[i].advertise();
|
||||||
@ -479,11 +671,19 @@ void setup()
|
|||||||
.setDatatype(NUMBER_TYPE)
|
.setDatatype(NUMBER_TYPE)
|
||||||
.setUnit("V");
|
.setUnit("V");
|
||||||
sensorWater.advertise("remaining").setDatatype(NUMBER_TYPE).setUnit("%");
|
sensorWater.advertise("remaining").setDatatype(NUMBER_TYPE).setUnit("%");
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
readOneWireSensors(false);
|
||||||
|
digitalWrite(OUTPUT_ENABLE_PUMP, HIGH);
|
||||||
|
delay(100);
|
||||||
|
Serial << "Wifi mode set to " << WIFI_AP_STA << endl;
|
||||||
|
WiFi.mode(WIFI_AP_STA);
|
||||||
Serial.println("Initial Setup. Start Accesspoint...");
|
Serial.println("Initial Setup. Start Accesspoint...");
|
||||||
mDownloadMode = true;
|
mDownloadMode = true;
|
||||||
}
|
}
|
||||||
stayAlive.advertise("alive").setName("Alive").setDatatype(NUMBER_TYPE).settable(aliveHandler);
|
stayAlive.advertise("alive").setName("Alive").setDatatype(NUMBER_TYPE).settable(aliveHandler);
|
||||||
|
setupFinishedTimestamp = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -492,35 +692,56 @@ void setup()
|
|||||||
*/
|
*/
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
|
Homie.loop();
|
||||||
/* Toggel Senor LED to visualize mode 3 */
|
/* Toggel Senor LED to visualize mode 3 */
|
||||||
if (mDownloadMode)
|
if (mDownloadMode)
|
||||||
{
|
{
|
||||||
if (nextBlink < millis())
|
if (nextBlink < millis())
|
||||||
{
|
{
|
||||||
nextBlink = millis() + 500;
|
|
||||||
digitalWrite(OUTPUT_ENABLE_SENSOR, !digitalRead(OUTPUT_ENABLE_SENSOR));
|
digitalWrite(OUTPUT_ENABLE_SENSOR, !digitalRead(OUTPUT_ENABLE_SENSOR));
|
||||||
}
|
if (mConfigured)
|
||||||
}
|
{
|
||||||
else if (!mDeepsleep)
|
nextBlink = millis() + 500;
|
||||||
{
|
}
|
||||||
Homie.loop();
|
else
|
||||||
if ((millis() > MQTT_TIMEOUT) && (!mSensorsRead)) {
|
{
|
||||||
mSensorsRead = true;
|
if (lastPumpRunning >= 0 && lastPumpRunning < MAX_PLANTS)
|
||||||
/* Disable Wifi and put modem into sleep mode */
|
{
|
||||||
WiFi.mode(WIFI_OFF);
|
mPlants[lastPumpRunning].deactivatePump();
|
||||||
Serial << (millis() / 1000) << "s passed, read sensors manually" << endl;
|
}
|
||||||
plantcontrol();
|
if (lastPumpRunning >= MAX_PLANTS)
|
||||||
|
{
|
||||||
|
digitalWrite(OUTPUT_ENABLE_PUMP, LOW);
|
||||||
|
nextBlink = millis() + 500;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lastPumpRunning++;
|
||||||
|
nextBlink = millis() + 5000;
|
||||||
|
}
|
||||||
|
if (lastPumpRunning < MAX_PLANTS)
|
||||||
|
{
|
||||||
|
mPlants[lastPumpRunning].activatePump();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial << "Bye" << endl;
|
unsigned long timeSinceSetup = millis() - setupFinishedTimestamp;
|
||||||
Serial.flush();
|
if ((timeSinceSetup > MQTT_TIMEOUT) && (!mSensorsRead))
|
||||||
esp_deep_sleep_start();
|
{
|
||||||
|
mSensorsRead = true;
|
||||||
|
/* Disable Wifi and put modem into sleep mode */
|
||||||
|
WiFi.mode(WIFI_OFF);
|
||||||
|
Serial << "Wifi mode set to " << WIFI_OFF << " mqqt was no reached within " << timeSinceSetup << "ms , fallback to offline mode " << endl;
|
||||||
|
Serial.flush();
|
||||||
|
plantcontrol(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Timeout always stopping the ESP -> no endless power consumption */
|
/** Timeout always stopping the ESP -> no endless power consumption */
|
||||||
if (millis() > 30000 && !mDownloadMode)
|
if (millis() > 60000 && !mDownloadMode)
|
||||||
{
|
{
|
||||||
Serial << (millis() / 1000) << "not terminated watchdog reset" << endl;
|
Serial << (millis() / 1000) << "not terminated watchdog reset" << endl;
|
||||||
Serial.flush();
|
Serial.flush();
|
||||||
@ -528,21 +749,12 @@ void loop()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* @fn plantcontrol
|
* @fn plantcontrol
|
||||||
* Main function, doing the logic
|
* Main function, doing the logic
|
||||||
*/
|
*/
|
||||||
void plantcontrol()
|
void plantcontrol(bool withHomie)
|
||||||
{
|
{
|
||||||
digitalWrite(OUTPUT_ENABLE_PUMP, LOW);
|
|
||||||
for (int i = 0; i < MAX_PLANTS; i++)
|
|
||||||
{
|
|
||||||
mPlants[i].deactivatePump();
|
|
||||||
}
|
|
||||||
|
|
||||||
readSensors();
|
|
||||||
|
|
||||||
if (lastPumpRunning != -1)
|
if (lastPumpRunning != -1)
|
||||||
{
|
{
|
||||||
long waterDiff = waterRawSensor.getAverage() - lastWaterValue;
|
long waterDiff = waterRawSensor.getAverage() - lastWaterValue;
|
||||||
@ -551,6 +763,8 @@ void plantcontrol()
|
|||||||
Serial << "Plant" << lastPumpRunning << ": Water diff " << waterDiff << " mm" << endl;
|
Serial << "Plant" << lastPumpRunning << ": Water diff " << waterDiff << " mm" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readOneWireSensors(true);
|
||||||
|
|
||||||
for (int i = 0; i < MAX_PLANTS; i++)
|
for (int i = 0; i < MAX_PLANTS; i++)
|
||||||
{
|
{
|
||||||
long raw = mPlants[i].getCurrentMoisture();
|
long raw = mPlants[i].getCurrentMoisture();
|
||||||
@ -571,33 +785,40 @@ void plantcontrol()
|
|||||||
mPlants[i].setProperty("moist").send(String(pct));
|
mPlants[i].setProperty("moist").send(String(pct));
|
||||||
mPlants[i].setProperty("moistraw").send(String(raw));
|
mPlants[i].setProperty("moistraw").send(String(raw));
|
||||||
}
|
}
|
||||||
sensorWater.setProperty("remaining").send(String(waterLevelMax.get() - waterRawSensor.getAverage()));
|
|
||||||
Serial << "W : " << waterRawSensor.getAverage() << " cm (" << String(waterLevelMax.get() - waterRawSensor.getAverage()) << "%)" << endl;
|
Serial << "W : " << waterRawSensor.getAverage() << " cm (" << String(waterLevelMax.get() - waterRawSensor.getAverage()) << "%)" << endl;
|
||||||
lastWaterValue = waterRawSensor.getAverage();
|
lastWaterValue = waterRawSensor.getAverage();
|
||||||
|
|
||||||
float batteryVoltage = battery.getVoltage(BATTSENSOR_INDEX_BATTERY);
|
float batteryVoltage = battery.getVoltage(BATTSENSOR_INDEX_BATTERY);
|
||||||
float chipTemp = battery.getTemperature();
|
float chipTemp = battery.getTemperature();
|
||||||
|
|
||||||
|
|
||||||
sensorLipo.setProperty("percent").send(String(100 * batteryVoltage / VOLT_MAX_BATT));
|
|
||||||
sensorLipo.setProperty("volt").send(String(batteryVoltage));
|
|
||||||
sensorLipo.setProperty("current").send(String(battery.getCurrent()));
|
|
||||||
sensorLipo.setProperty("Ah").send(String(battery.getAh()));
|
|
||||||
sensorLipo.setProperty("ICA").send(String(battery.getICA()));
|
|
||||||
sensorLipo.setProperty("DCA").send(String(battery.getDCA()));
|
|
||||||
sensorLipo.setProperty("CCA").send(String(battery.getCCA()));
|
|
||||||
sensorSolar.setProperty("volt").send(String(mSolarVoltage));
|
|
||||||
|
|
||||||
sensorTemp.setProperty(TEMPERATUR_SENSOR_CHIP).send(String(chipTemp));
|
|
||||||
Serial << "Chip Temperatur " << chipTemp << " °C " << endl;
|
Serial << "Chip Temperatur " << chipTemp << " °C " << endl;
|
||||||
|
|
||||||
|
if (withHomie)
|
||||||
|
{
|
||||||
|
sensorWater.setProperty("remaining").send(String(waterLevelMax.get() - waterRawSensor.getAverage()));
|
||||||
|
sensorLipo.setProperty("percent").send(String(100 * batteryVoltage / VOLT_MAX_BATT));
|
||||||
|
sensorLipo.setProperty("volt").send(String(batteryVoltage));
|
||||||
|
sensorLipo.setProperty("current").send(String(battery.getCurrent()));
|
||||||
|
sensorLipo.setProperty("Ah").send(String(battery.getAh()));
|
||||||
|
sensorLipo.setProperty("ICA").send(String(battery.getICA()));
|
||||||
|
sensorLipo.setProperty("DCA").send(String(battery.getDCA()));
|
||||||
|
sensorLipo.setProperty("CCA").send(String(battery.getCCA()));
|
||||||
|
sensorSolar.setProperty("volt").send(String(mSolarVoltage));
|
||||||
|
sensorTemp.setProperty(TEMPERATUR_SENSOR_CHIP).send(String(chipTemp));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.println("Skipping MQTT, offline mode");
|
||||||
|
Serial.flush();
|
||||||
|
}
|
||||||
|
|
||||||
bool hasWater = true; //FIXMEmWaterGone > waterLevelMin.get();
|
bool hasWater = true; //FIXMEmWaterGone > waterLevelMin.get();
|
||||||
//FIXME no water warning message
|
//FIXME no water warning message
|
||||||
lastPumpRunning = determineNextPump();
|
lastPumpRunning = determineNextPump();
|
||||||
if (lastPumpRunning != -1 && !hasWater)
|
if (lastPumpRunning != -1 && !hasWater)
|
||||||
{
|
{
|
||||||
Serial.println("Want to pump but no water");
|
Serial.println("Want to pump but no water");
|
||||||
}
|
}
|
||||||
else if (lastPumpRunning != -1 && hasWater)
|
else if (lastPumpRunning != -1 && hasWater)
|
||||||
{
|
{
|
||||||
if (mDownloadMode)
|
if (mDownloadMode)
|
||||||
@ -606,7 +827,12 @@ void plantcontrol()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//prevent BOD to be paranoid
|
||||||
|
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
|
||||||
digitalWrite(OUTPUT_ENABLE_PUMP, HIGH);
|
digitalWrite(OUTPUT_ENABLE_PUMP, HIGH);
|
||||||
|
delay(100);
|
||||||
|
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 1);
|
||||||
|
|
||||||
rtcLastWateringPlant[lastPumpRunning] = getCurrentTime();
|
rtcLastWateringPlant[lastPumpRunning] = getCurrentTime();
|
||||||
mPlants[lastPumpRunning].activatePump();
|
mPlants[lastPumpRunning].activatePump();
|
||||||
}
|
}
|
||||||
@ -619,18 +845,18 @@ void plantcontrol()
|
|||||||
{
|
{
|
||||||
Serial.print(mSolarVoltage);
|
Serial.print(mSolarVoltage);
|
||||||
Serial.println("V! No pumps to activate and low light, deepSleepNight");
|
Serial.println("V! No pumps to activate and low light, deepSleepNight");
|
||||||
espDeepSleepFor(deepSleepNightTime.get());
|
espDeepSleepFor(deepSleepNightTime.get(), false, withHomie);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial.println("No pumps to activate, deepSleep");
|
Serial.println("No pumps to activate, deepSleep");
|
||||||
espDeepSleepFor(deepSleepTime.get());
|
espDeepSleepFor(deepSleepTime.get(), false, withHomie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial.println("Running pump, watering deepsleep");
|
Serial.println("Running pump, watering deepsleep");
|
||||||
espDeepSleepFor(wateringDeepSleep.get(), true);
|
espDeepSleepFor(wateringDeepSleep.get(), true, withHomie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,4 @@ board = esp32doit-devkit-v1
|
|||||||
framework = arduino
|
framework = arduino
|
||||||
build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
|
build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
|
||||||
lib_deps = OneWire
|
lib_deps = OneWire
|
||||||
DallasTemperature
|
DallasTemperature
|
||||||
|
|
||||||
upload_port = /dev/ttyUSB1
|
|
Loading…
Reference in New Issue
Block a user