added distance sensor and adjusted pcb for it
This commit is contained in:
parent
5fcf72602d
commit
a8403a7c98
File diff suppressed because it is too large
Load Diff
@ -297,8 +297,6 @@ F 4 "C205442" H 10650 14600 50 0001 C CNN "LCSC_PART_NUMBER"
|
|||||||
1 10650 14600
|
1 10650 14600
|
||||||
0 -1 -1 0
|
0 -1 -1 0
|
||||||
$EndComp
|
$EndComp
|
||||||
Wire Wire Line
|
|
||||||
10650 14800 10650 14750
|
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
10650 14400 10650 14450
|
10650 14400 10650 14450
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
@ -342,8 +340,6 @@ F 3 "~" H 9700 1750 50 0001 C CNN
|
|||||||
$EndComp
|
$EndComp
|
||||||
Text GLabel 9500 1650 1 50 Input ~ 0
|
Text GLabel 9500 1650 1 50 Input ~ 0
|
||||||
VCC
|
VCC
|
||||||
Wire Wire Line
|
|
||||||
10650 15100 10650 15150
|
|
||||||
$Comp
|
$Comp
|
||||||
L Device:LED Pumps1
|
L Device:LED Pumps1
|
||||||
U 1 1 5F834AFA
|
U 1 1 5F834AFA
|
||||||
@ -443,17 +439,6 @@ VCC_BATT
|
|||||||
Text GLabel 20050 6150 0 50 Input ~ 0
|
Text GLabel 20050 6150 0 50 Input ~ 0
|
||||||
VCC_BATT
|
VCC_BATT
|
||||||
$Comp
|
$Comp
|
||||||
L Jumper:SolderJumper_2_Bridged LED_SENS1
|
|
||||||
U 1 1 6017FFC5
|
|
||||||
P 10650 14950
|
|
||||||
F 0 "LED_SENS1" V 10604 15018 50 0000 L CNN
|
|
||||||
F 1 "NC" V 10695 15018 50 0000 L CNN
|
|
||||||
F 2 "Jumper:SolderJumper-2_P1.3mm_Bridged_Pad1.0x1.5mm" H 10650 14950 50 0001 C CNN
|
|
||||||
F 3 "~" H 10650 14950 50 0001 C CNN
|
|
||||||
1 10650 14950
|
|
||||||
0 1 1 0
|
|
||||||
$EndComp
|
|
||||||
$Comp
|
|
||||||
L Device:C_Small C13
|
L Device:C_Small C13
|
||||||
U 1 1 603684C2
|
U 1 1 603684C2
|
||||||
P 6400 2500
|
P 6400 2500
|
||||||
@ -2058,20 +2043,7 @@ F 4 "C45783" H 9800 5900 50 0001 C CNN "LCSC_PART_NUMBER"
|
|||||||
$EndComp
|
$EndComp
|
||||||
Text GLabel 9800 6050 3 50 Input ~ 0
|
Text GLabel 9800 6050 3 50 Input ~ 0
|
||||||
GND
|
GND
|
||||||
Text GLabel 3950 4050 0 50 Input ~ 0
|
Text GLabel 3950 3850 0 50 Input ~ 0
|
||||||
PWR_SENSORS
|
|
||||||
$Comp
|
|
||||||
L Connector_Generic:Conn_01x04 Hall1
|
|
||||||
U 1 1 5F9D6D22
|
|
||||||
P 4200 3850
|
|
||||||
F 0 "Hall1" H 4280 3842 50 0000 L CNN
|
|
||||||
F 1 "Conn_01x04" H 4000 3550 50 0000 L CNN
|
|
||||||
F 2 "ESP32:SR04M-2PinHeader_1x04_P2.54mm_Vertical" H 4200 3850 50 0001 C CNN
|
|
||||||
F 3 "~" H 4200 3850 50 0001 C CNN
|
|
||||||
1 4200 3850
|
|
||||||
1 0 0 -1
|
|
||||||
$EndComp
|
|
||||||
Text GLabel 3950 3750 0 50 Input ~ 0
|
|
||||||
GND
|
GND
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
3950 3850 4000 3850
|
3950 3850 4000 3850
|
||||||
@ -2441,10 +2413,10 @@ Wire Wire Line
|
|||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
11300 5750 11650 5750
|
11300 5750 11650 5750
|
||||||
$Comp
|
$Comp
|
||||||
L Connector:Conn_01x04_Female I2C1
|
L Connector:Conn_01x04_Female Custom1
|
||||||
U 1 1 607BAC29
|
U 1 1 607BAC29
|
||||||
P 12550 7950
|
P 12550 7950
|
||||||
F 0 "I2C1" H 12578 7926 50 0000 L CNN
|
F 0 "Custom1" H 12578 7926 50 0000 L CNN
|
||||||
F 1 "Conn_01x04_Female" H 12578 7835 50 0000 L CNN
|
F 1 "Conn_01x04_Female" H 12578 7835 50 0000 L CNN
|
||||||
F 2 "Connector_JST:JST_EH_B4B-EH-A_1x04_P2.50mm_Vertical" H 12550 7950 50 0001 C CNN
|
F 2 "Connector_JST:JST_EH_B4B-EH-A_1x04_P2.50mm_Vertical" H 12550 7950 50 0001 C CNN
|
||||||
F 3 "~" H 12550 7950 50 0001 C CNN
|
F 3 "~" H 12550 7950 50 0001 C CNN
|
||||||
@ -2601,9 +2573,9 @@ F 4 "C503217" H 17000 6300 50 0001 C CNN "LCSC_PART_NUMBER"
|
|||||||
1 0 0 -1
|
1 0 0 -1
|
||||||
$EndComp
|
$EndComp
|
||||||
Text GLabel 11400 6750 2 50 Input ~ 0
|
Text GLabel 11400 6750 2 50 Input ~ 0
|
||||||
HALL_TX
|
SCL
|
||||||
Text GLabel 3950 3850 0 50 Input ~ 0
|
Text GLabel 3500 4250 0 50 Input ~ 0
|
||||||
HALL_TX
|
SDA
|
||||||
Text GLabel 11400 5850 2 50 Input ~ 0
|
Text GLabel 11400 5850 2 50 Input ~ 0
|
||||||
ESP_TX
|
ESP_TX
|
||||||
Text GLabel 11400 6050 2 50 Input ~ 0
|
Text GLabel 11400 6050 2 50 Input ~ 0
|
||||||
@ -2612,8 +2584,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 Notes 2950 3300 0 105 ~ 0
|
Text Notes 3650 3500 0 105 ~ 0
|
||||||
Hall Sensor Serial2|Trigger/Echo
|
I2C
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
10550 4850 10650 4850
|
10550 4850 10650 4850
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
@ -2658,22 +2630,16 @@ Wire Wire Line
|
|||||||
21850 7500 21850 7250
|
21850 7500 21850 7250
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
8850 5750 8850 5450
|
8850 5750 8850 5450
|
||||||
Text Notes 3800 3650 0 39 ~ 8
|
|
||||||
JSN-SR04T-2.0\nIO16 RX\nIO17 TX
|
|
||||||
Text GLabel 11400 6850 2 50 Input ~ 0
|
Text GLabel 11400 6850 2 50 Input ~ 0
|
||||||
HALL_RX
|
SDA
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
11300 6750 11400 6750
|
11300 6750 11400 6750
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
11300 6550 11400 6550
|
11300 6550 11400 6550
|
||||||
Text GLabel 3950 3950 0 50 Input ~ 0
|
Text GLabel 3300 4100 0 50 Input ~ 0
|
||||||
HALL_RX
|
SCL
|
||||||
Wire Wire Line
|
Wire Wire Line
|
||||||
3950 3950 4000 3950
|
3950 3950 4000 3950
|
||||||
Wire Wire Line
|
|
||||||
3950 3750 4000 3750
|
|
||||||
Wire Wire Line
|
|
||||||
4000 4050 3950 4050
|
|
||||||
Text GLabel 9050 1550 1 50 Input ~ 0
|
Text GLabel 9050 1550 1 50 Input ~ 0
|
||||||
3_3V
|
3_3V
|
||||||
Text GLabel 8200 1550 0 50 Input ~ 0
|
Text GLabel 8200 1550 0 50 Input ~ 0
|
||||||
@ -3404,4 +3370,200 @@ F 4 "C212284" H 12200 5450 50 0001 C CNN "LCSC_PART_NUMBER"
|
|||||||
1 12200 5450
|
1 12200 5450
|
||||||
0 -1 -1 0
|
0 -1 -1 0
|
||||||
$EndComp
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L Connector_Generic:Conn_01x04 I2C1
|
||||||
|
U 1 1 60C08BAC
|
||||||
|
P 4200 3850
|
||||||
|
F 0 "I2C1" H 4280 3842 50 0000 L CNN
|
||||||
|
F 1 "Conn_01x04" H 4280 3751 50 0000 L CNN
|
||||||
|
F 2 "Connector_JST:JST_EH_B4B-EH-A_1x04_P2.50mm_Vertical" H 4200 3850 50 0001 C CNN
|
||||||
|
F 3 "~" H 4200 3850 50 0001 C CNN
|
||||||
|
1 4200 3850
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L Device:R R67
|
||||||
|
U 1 1 60C19E10
|
||||||
|
P 3400 3900
|
||||||
|
F 0 "R67" H 3470 3946 50 0000 L CNN
|
||||||
|
F 1 "R" H 3470 3855 50 0000 L CNN
|
||||||
|
F 2 "Resistor_SMD:R_0805_2012Metric" V 3330 3900 50 0001 C CNN
|
||||||
|
F 3 "~" H 3400 3900 50 0001 C CNN
|
||||||
|
1 3400 3900
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L Device:R R68
|
||||||
|
U 1 1 60C1A741
|
||||||
|
P 3550 3900
|
||||||
|
F 0 "R68" H 3620 3946 50 0000 L CNN
|
||||||
|
F 1 "R" H 3620 3855 50 0000 L CNN
|
||||||
|
F 2 "Resistor_SMD:R_0805_2012Metric" V 3480 3900 50 0001 C CNN
|
||||||
|
F 3 "~" H 3550 3900 50 0001 C CNN
|
||||||
|
1 3550 3900
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
3500 4250 3550 4250
|
||||||
|
Wire Wire Line
|
||||||
|
3550 4250 3550 4050
|
||||||
|
Wire Wire Line
|
||||||
|
3550 4050 4000 4050
|
||||||
|
Connection ~ 3550 4050
|
||||||
|
Wire Wire Line
|
||||||
|
3300 4100 3400 4100
|
||||||
|
Wire Wire Line
|
||||||
|
3400 4100 3400 4050
|
||||||
|
Wire Wire Line
|
||||||
|
3400 4100 3950 4100
|
||||||
|
Wire Wire Line
|
||||||
|
3950 4100 3950 3950
|
||||||
|
Connection ~ 3400 4100
|
||||||
|
Wire Wire Line
|
||||||
|
3400 3750 3550 3750
|
||||||
|
Connection ~ 3550 3750
|
||||||
|
Wire Wire Line
|
||||||
|
3550 3750 4000 3750
|
||||||
|
Text GLabel 14450 13950 3 50 Input ~ 0
|
||||||
|
3_3V
|
||||||
|
Wire Wire Line
|
||||||
|
13500 14300 13500 14600
|
||||||
|
Connection ~ 13500 14300
|
||||||
|
Wire Wire Line
|
||||||
|
13850 14300 13500 14300
|
||||||
|
Wire Wire Line
|
||||||
|
13850 14150 13850 14300
|
||||||
|
Wire Wire Line
|
||||||
|
14150 14150 13850 14150
|
||||||
|
Wire Wire Line
|
||||||
|
13500 14200 13500 14300
|
||||||
|
Text GLabel 13800 13950 0 50 Input ~ 0
|
||||||
|
GND
|
||||||
|
$Comp
|
||||||
|
L Diode:BAS40-04 D29
|
||||||
|
U 1 1 60CF85CE
|
||||||
|
P 14150 14050
|
||||||
|
F 0 "D29" H 14150 14375 50 0000 C CNN
|
||||||
|
F 1 "BAS40-04" H 14150 14284 50 0000 C CNN
|
||||||
|
F 2 "Package_TO_SOT_SMD:SOT-23" H 13900 14350 50 0001 L CNN
|
||||||
|
F 3 "http://www.vishay.com/docs/85701/bas40v.pdf" H 14030 14150 50 0001 C CNN
|
||||||
|
F 4 "C397601" H 14150 14050 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
|
1 14150 14050
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
13800 13950 13850 13950
|
||||||
|
Connection ~ 13500 15000
|
||||||
|
Wire Wire Line
|
||||||
|
13350 15000 13350 15100
|
||||||
|
Wire Wire Line
|
||||||
|
13350 15000 13500 15000
|
||||||
|
Wire Wire Line
|
||||||
|
13350 15100 13200 15100
|
||||||
|
Wire Wire Line
|
||||||
|
13500 15050 13500 15000
|
||||||
|
Text GLabel 13500 15050 3 50 Input ~ 0
|
||||||
|
3_3V
|
||||||
|
Connection ~ 13200 14800
|
||||||
|
$Comp
|
||||||
|
L Device:R R72
|
||||||
|
U 1 1 60CF85A1
|
||||||
|
P 13200 14950
|
||||||
|
F 0 "R72" H 13270 14996 50 0000 L CNN
|
||||||
|
F 1 "10k" H 13270 14905 50 0000 L CNN
|
||||||
|
F 2 "Resistor_SMD:R_0805_2012Metric" V 13130 14950 50 0001 C CNN
|
||||||
|
F 3 "~" H 13200 14950 50 0001 C CNN
|
||||||
|
F 4 "C212284" H 13200 14950 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
|
1 13200 14950
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Text GLabel 13500 14200 1 50 Input ~ 0
|
||||||
|
PWR_I2C
|
||||||
|
Wire Wire Line
|
||||||
|
13150 14800 13200 14800
|
||||||
|
$Comp
|
||||||
|
L Transistor_FET:BSS84 Q_PWR4
|
||||||
|
U 1 1 60CF8589
|
||||||
|
P 13400 14800
|
||||||
|
F 0 "Q_PWR4" H 13604 14846 50 0000 L CNN
|
||||||
|
F 1 "P-channel 50v 4A" H 13604 14755 50 0000 L CNN
|
||||||
|
F 2 "Package_TO_SOT_SMD:SOT-23" H 13600 14725 50 0001 L CIN
|
||||||
|
F 3 "" H 13400 14800 50 0001 L CNN
|
||||||
|
F 4 "" H 13400 14800 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
|
1 13400 14800
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
$Comp
|
||||||
|
L Device:R R71
|
||||||
|
U 1 1 60CF85E1
|
||||||
|
P 13000 14800
|
||||||
|
F 0 "R71" H 13070 14846 50 0000 L CNN
|
||||||
|
F 1 "1k" H 13070 14755 50 0000 L CNN
|
||||||
|
F 2 "Resistor_SMD:R_0805_2012Metric" V 12930 14800 50 0001 C CNN
|
||||||
|
F 3 "~" H 13000 14800 50 0001 C CNN
|
||||||
|
F 4 "C95781" H 13000 14800 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
|
1 13000 14800
|
||||||
|
0 1 1 0
|
||||||
|
$EndComp
|
||||||
|
Text GLabel 12800 15350 3 50 Input ~ 0
|
||||||
|
GND
|
||||||
|
Wire Wire Line
|
||||||
|
12800 15300 12800 15350
|
||||||
|
Wire Wire Line
|
||||||
|
12800 15300 12800 15200
|
||||||
|
Connection ~ 12800 15300
|
||||||
|
Wire Wire Line
|
||||||
|
12500 15300 12800 15300
|
||||||
|
Wire Wire Line
|
||||||
|
12050 15000 12100 15000
|
||||||
|
$Comp
|
||||||
|
L Device:R R69
|
||||||
|
U 1 1 60CF85BD
|
||||||
|
P 12250 15000
|
||||||
|
F 0 "R69" H 12320 15046 50 0000 L CNN
|
||||||
|
F 1 "1k" H 12320 14955 50 0000 L CNN
|
||||||
|
F 2 "Resistor_SMD:R_0805_2012Metric" V 12180 15000 50 0001 C CNN
|
||||||
|
F 3 "~" H 12250 15000 50 0001 C CNN
|
||||||
|
F 4 "C95781" H 12250 15000 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
|
1 12250 15000
|
||||||
|
0 1 1 0
|
||||||
|
$EndComp
|
||||||
|
Wire Wire Line
|
||||||
|
12400 15000 12500 15000
|
||||||
|
Text GLabel 12050 15000 0 50 Input ~ 0
|
||||||
|
SENSORS_ENABLE
|
||||||
|
Wire Wire Line
|
||||||
|
12850 14800 12800 14800
|
||||||
|
$Comp
|
||||||
|
L Device:R R70
|
||||||
|
U 1 1 60CF8597
|
||||||
|
P 12500 15150
|
||||||
|
F 0 "R70" H 12570 15196 50 0000 L CNN
|
||||||
|
F 1 "10k" H 12570 15105 50 0000 L CNN
|
||||||
|
F 2 "Resistor_SMD:R_0805_2012Metric" V 12430 15150 50 0001 C CNN
|
||||||
|
F 3 "~" H 12500 15150 50 0001 C CNN
|
||||||
|
F 4 "C212284" H 12500 15150 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
|
1 12500 15150
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Connection ~ 12500 15000
|
||||||
|
$Comp
|
||||||
|
L ESP32-DEVKITC-32D:SL2300 Q12
|
||||||
|
U 1 1 60CF8590
|
||||||
|
P 12750 15000
|
||||||
|
F 0 "Q12" H 12905 15046 50 0000 L CNN
|
||||||
|
F 1 "N-channel 30V 5A" H 12905 14955 50 0000 L CNN
|
||||||
|
F 2 "Package_TO_SOT_SMD:SOT-23" H 12750 15000 50 0001 C CNN
|
||||||
|
F 3 "" H 12750 15000 50 0001 C CNN
|
||||||
|
F 4 "C350314" H 12750 15000 50 0001 C CNN "LCSC_PART_NUMBER"
|
||||||
|
1 12750 15000
|
||||||
|
1 0 0 -1
|
||||||
|
$EndComp
|
||||||
|
Text GLabel 3350 3750 0 50 Input ~ 0
|
||||||
|
PWR_I2C
|
||||||
|
Wire Wire Line
|
||||||
|
3350 3750 3400 3750
|
||||||
|
Connection ~ 3400 3750
|
||||||
|
Wire Wire Line
|
||||||
|
10650 14750 10650 15150
|
||||||
$EndSCHEMATC
|
$EndSCHEMATC
|
||||||
|
@ -71,8 +71,8 @@
|
|||||||
#define BUTTON GPIO_NUM_0 /**< GPIO 0 - Fix button of NodeMCU */
|
#define BUTTON GPIO_NUM_0 /**< GPIO 0 - Fix button of NodeMCU */
|
||||||
#define CUSTOM1_PIN3 GPIO_NUM_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 GPIO_NUM_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 GPIO_NUM_34 /**< GPIO 34 - I2C */
|
#define I2C1_SDA GPIO_NUM_34 /**< GPIO 34 - I2C */
|
||||||
#define I2C1_PIN3 GPIO_NUM_35 /**< GPIO 35 - I2C */
|
#define I2C1_SCL GPIO_NUM_35 /**< GPIO 35 - I2C */
|
||||||
/* @} */
|
/* @} */
|
||||||
|
|
||||||
/** \addtogroup Configuration
|
/** \addtogroup Configuration
|
||||||
|
@ -19,6 +19,7 @@ board_build.partitions = defaultWithSmallerSpiffs.csv
|
|||||||
lib_deps = ArduinoJson@6.16.1
|
lib_deps = ArduinoJson@6.16.1
|
||||||
OneWire
|
OneWire
|
||||||
DallasTemperature
|
DallasTemperature
|
||||||
|
pololu/VL53L0X
|
||||||
https://github.com/homieiot/homie-esp8266.git#develop
|
https://github.com/homieiot/homie-esp8266.git#develop
|
||||||
|
|
||||||
[platformio]
|
[platformio]
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#include "DS2438.h"
|
#include "DS2438.h"
|
||||||
#include "soc/soc.h"
|
#include "soc/soc.h"
|
||||||
#include "soc/rtc_cntl_reg.h"
|
#include "soc/rtc_cntl_reg.h"
|
||||||
|
#include <Wire.h>
|
||||||
|
#include <VL53L0X.h>
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
@ -82,6 +84,7 @@ unsigned long setupFinishedTimestamp;
|
|||||||
OneWire oneWire(SENSOR_ONEWIRE);
|
OneWire oneWire(SENSOR_ONEWIRE);
|
||||||
DallasTemperature sensors(&oneWire);
|
DallasTemperature sensors(&oneWire);
|
||||||
DS2438 battery(&oneWire, 0.0333333f, AMOUNT_SENOR_QUERYS);
|
DS2438 battery(&oneWire, 0.0333333f, AMOUNT_SENOR_QUERYS);
|
||||||
|
VL53L0X tankSensor;
|
||||||
|
|
||||||
Plant mPlants[MAX_PLANTS] = {
|
Plant mPlants[MAX_PLANTS] = {
|
||||||
Plant(SENSOR_PLANT0, OUTPUT_PUMP0, 0, &plant0, &mSetting0),
|
Plant(SENSOR_PLANT0, OUTPUT_PUMP0, 0, &plant0, &mSetting0),
|
||||||
@ -211,7 +214,8 @@ void readOneWireSensors(bool withMQTT)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!valid){
|
if (!valid)
|
||||||
|
{
|
||||||
//wrong family or crc errors on each retry
|
//wrong family or crc errors on each retry
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -230,7 +234,7 @@ void readOneWireSensors(bool withMQTT)
|
|||||||
if (valid)
|
if (valid)
|
||||||
{
|
{
|
||||||
Serial << "DS18S20 Temperatur " << String(buf) << " : " << temp << " °C " << endl;
|
Serial << "DS18S20 Temperatur " << String(buf) << " : " << temp << " °C " << endl;
|
||||||
if (strcmp(lipoSensorAddr.get(),buf) == 0)
|
if (strcmp(lipoSensorAddr.get(), buf) == 0)
|
||||||
{
|
{
|
||||||
if (withMQTT)
|
if (withMQTT)
|
||||||
{
|
{
|
||||||
@ -238,7 +242,7 @@ void readOneWireSensors(bool withMQTT)
|
|||||||
}
|
}
|
||||||
Serial << "Lipo Temperatur " << temp << " °C " << endl;
|
Serial << "Lipo Temperatur " << temp << " °C " << endl;
|
||||||
}
|
}
|
||||||
if (strcmp(waterSensorAddr.get(),buf) == 0)
|
if (strcmp(waterSensorAddr.get(), buf) == 0)
|
||||||
{
|
{
|
||||||
if (withMQTT)
|
if (withMQTT)
|
||||||
{
|
{
|
||||||
@ -281,33 +285,44 @@ void readPowerSwitchedSensors()
|
|||||||
delay(2);
|
delay(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the distance and give the temperature sensors some time */
|
Wire.setPins(SENSOR_TANK_TRG, SENSOR_TANK_ECHO);
|
||||||
|
Wire.begin();
|
||||||
|
tankSensor.setTimeout(500);
|
||||||
|
long start = millis();
|
||||||
|
bool distanceReady = false;
|
||||||
|
while (start + 500 > millis())
|
||||||
{
|
{
|
||||||
for (int i = 0; i < AMOUNT_SENOR_QUERYS; i++)
|
if (tankSensor.init())
|
||||||
{
|
{
|
||||||
unsigned long duration = 0;
|
distanceReady = true;
|
||||||
|
break;
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
waterRawSensor.add(mmDis);
|
delay(20);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (distanceReady)
|
||||||
|
{
|
||||||
|
tankSensor.setSignalRateLimit(0.1);
|
||||||
|
// increase laser pulse periods (defaults are 14 and 10 PCLKs)
|
||||||
|
tankSensor.setVcselPulsePeriod(VL53L0X::VcselPeriodPreRange, 18);
|
||||||
|
tankSensor.setVcselPulsePeriod(VL53L0X::VcselPeriodFinalRange, 14);
|
||||||
|
tankSensor.setMeasurementTimingBudget(200000);
|
||||||
|
|
||||||
Serial << "Distance sensor " << waterRawSensor.getAverage() << " cm" << endl;
|
for (int readCnt = 0; readCnt < 5; readCnt++)
|
||||||
|
{
|
||||||
|
if(!tankSensor.timeoutOccurred()){
|
||||||
|
waterRawSensor.add(tankSensor.readRangeSingleMillimeters());
|
||||||
|
}
|
||||||
|
delay(10);
|
||||||
|
}
|
||||||
|
Serial << "Distance sensor " << waterRawSensor.getMedian() << " mm" << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.println("Failed to detect and initialize distance sensor!");
|
||||||
|
}
|
||||||
|
|
||||||
/* deactivate the sensors */
|
/* deactivate the sensors */
|
||||||
digitalWrite(OUTPUT_ENABLE_SENSOR, LOW);
|
digitalWrite(OUTPUT_ENABLE_SENSOR, LOW);
|
||||||
@ -612,8 +627,7 @@ void setup()
|
|||||||
// 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");
|
||||||
@ -633,8 +647,6 @@ void 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++)
|
||||||
{
|
{
|
||||||
@ -675,10 +687,11 @@ void setup()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
readOneWireSensors(false);
|
readOneWireSensors(false);
|
||||||
|
//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);
|
delay(100);
|
||||||
Serial << "Wifi mode set to " << WIFI_AP_STA << endl;
|
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 1);
|
||||||
WiFi.mode(WIFI_AP_STA);
|
|
||||||
Serial.println("Initial Setup. Start Accesspoint...");
|
Serial.println("Initial Setup. Start Accesspoint...");
|
||||||
mDownloadMode = true;
|
mDownloadMode = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user