Compare commits
No commits in common. "fe93d9eff6d7a03c28a3d863defe79b92ca84e78" and "5f0f19c58d28c8828b0dfa70091f65c1be8a7eb9" have entirely different histories.
fe93d9eff6
...
5f0f19c58d
|
@ -113,12 +113,9 @@ void temperature_loop(unsigned long loopmillis) {
|
||||||
Serial.println("Warn: Request Temperatures Timeout!");
|
Serial.println("Warn: Request Temperatures Timeout!");
|
||||||
publishInfo("error/temperature","Warn: Request Temperatures Timeout!");
|
publishInfo("error/temperature","Warn: Request Temperatures Timeout!");
|
||||||
flag_requestTemperatures=false;
|
flag_requestTemperatures=false;
|
||||||
last_read_ds18b20=loopmillis;
|
|
||||||
}
|
}
|
||||||
if (!flag_requestTemperatures) {
|
if (!flag_requestTemperatures) {
|
||||||
sensors.setWaitForConversion(false); //make async
|
sensors.requestTemperatures(); //this takes ~600ms
|
||||||
sensors.requestTemperatures(); //this takes ~600ms in non async mode. about 2ms in async mode
|
|
||||||
sensors.setWaitForConversion(true);
|
|
||||||
flag_requestTemperatures=true;
|
flag_requestTemperatures=true;
|
||||||
}
|
}
|
||||||
if (sensors.isConversionComplete()) {
|
if (sensors.isConversionComplete()) {
|
||||||
|
|
|
@ -52,24 +52,24 @@ monitor_speed = 115200
|
||||||
|
|
||||||
|
|
||||||
build_flags=
|
build_flags=
|
||||||
'-D CLIENT_ID="hydroponic-Test"'
|
'-D CLIENT_ID="hydroponic-DB"'
|
||||||
-D PIN_BUTTON=12
|
-D PIN_BUTTON
|
||||||
|
|
||||||
-D EC_PIN_RELAY_PROBE=6
|
-D EC_PIN_RELAY_PROBE
|
||||||
-D EC_PIN_FREQ=5
|
-D EC_PIN_FREQ
|
||||||
|
|
||||||
-D EC_CALIBRATION_POLYNOM={8.718380956513695,-0.026463423062356713,3.425216464107108e-05,-4.069826379094172e-09,2.478900495960682e-13}
|
-D EC_CALIBRATION_POLYNOM={8.718380956513695,-0.026463423062356713,3.425216464107108e-05,-4.069826379094172e-09,2.478900495960682e-13}
|
||||||
-D EC_CALIBRATION_LINEARIZE_BELOW_ADC=2000
|
-D EC_CALIBRATION_LINEARIZE_BELOW_ADC=2000
|
||||||
-D EC_CALIBRATION_LINEAR_LOWADC=728
|
-D EC_CALIBRATION_LINEAR_LOWADC=728
|
||||||
-D EC_CALIBRATION_LINEAR_LOWEC=0
|
-D EC_CALIBRATION_LINEAR_LOWEC=0
|
||||||
|
|
||||||
-D FLOW_PIN=16
|
-D FLOW_PIN
|
||||||
-D ONE_WIRE_BUS_PIN=18
|
-D ONE_WIRE_BUS_PIN
|
||||||
-D THERMOMETER_ADDR_RESERVOIR={0x28,0xFF,0x30,0xBA,0x85,0x16,0x03,0xB5}
|
-D THERMOMETER_ADDR_RESERVOIR={0x28,0xFF,0x30,0xBA,0x85,0x16,0x03,0xB5}
|
||||||
-D THERMOMETER_ADDR_CASE={0x28,0xFF,0x30,0xBA,0x85,0x16,0x03,0xB6}
|
-D THERMOMETER_ADDR_CASE
|
||||||
|
|
||||||
-D PIN_SDA=1
|
-D PIN_SDA
|
||||||
-D PIN_SCL=2
|
-D PIN_SCL
|
||||||
|
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/milesburton/Arduino-Temperature-Control-Library/
|
https://github.com/milesburton/Arduino-Temperature-Control-Library/
|
||||||
|
@ -77,4 +77,3 @@ lib_deps =
|
||||||
robtillaart/ADS1X15@^0.3.9
|
robtillaart/ADS1X15@^0.3.9
|
||||||
256dpi/MQTT@^2.5.2
|
256dpi/MQTT@^2.5.2
|
||||||
pololu/VL53L0X@^1.3.1
|
pololu/VL53L0X@^1.3.1
|
||||||
adafruit/Adafruit NeoPixel
|
|
68
src/main.cpp
68
src/main.cpp
|
@ -48,36 +48,14 @@ ADS1115 ADS(0x48);
|
||||||
//#include "soilmoisture.h"
|
//#include "soilmoisture.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef PIN_NEOPIXEL
|
|
||||||
#include <Adafruit_NeoPixel.h>
|
|
||||||
Adafruit_NeoPixel pixels(1, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
pinMode(PIN_BUTTON,INPUT_PULLUP);
|
pinMode(PIN_BUTTON,INPUT_PULLUP);
|
||||||
#ifdef PIN_LED
|
|
||||||
pinMode(PIN_LED,OUTPUT);
|
pinMode(PIN_LED,OUTPUT);
|
||||||
digitalWrite(PIN_LED,LOW);
|
digitalWrite(PIN_LED,LOW);
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(NEOPIXEL_POWER)
|
|
||||||
// If this board has a power control pin, we must set it to output and high
|
|
||||||
// in order to enable the NeoPixels. We put this in an #if defined so it can
|
|
||||||
// be reused for other boards without compilation errors
|
|
||||||
pinMode(NEOPIXEL_POWER, OUTPUT);
|
|
||||||
digitalWrite(NEOPIXEL_POWER, HIGH);
|
|
||||||
#endif
|
|
||||||
#ifdef PIN_NEOPIXEL
|
|
||||||
pixels.begin();
|
|
||||||
pixels.setBrightness(100); // not so bright
|
|
||||||
pixels.clear();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
if (mqtt) {
|
if (mqtt) {
|
||||||
WiFi.begin(ssid, pass);
|
WiFi.begin(ssid, pass);
|
||||||
|
@ -88,7 +66,7 @@ void setup() {
|
||||||
|
|
||||||
|
|
||||||
Serial.println("Setup Waterlevel");
|
Serial.println("Setup Waterlevel");
|
||||||
waterlevel_setup();
|
//waterlevel_setup(); //Temporarily disabled
|
||||||
|
|
||||||
|
|
||||||
//init ADS1115
|
//init ADS1115
|
||||||
|
@ -149,7 +127,7 @@ void loop() {
|
||||||
temperature_loop(loopmillis);
|
temperature_loop(loopmillis);
|
||||||
|
|
||||||
if (!ec_measurementRunning()){ //skip tof read when ec measurement running, because vlxx sensor reading takes quite long per cycle
|
if (!ec_measurementRunning()){ //skip tof read when ec measurement running, because vlxx sensor reading takes quite long per cycle
|
||||||
waterlevel_loop(loopmillis);
|
//Temporarily disabled waterlevel_loop(loopmillis);
|
||||||
}
|
}
|
||||||
|
|
||||||
flow_loop(loopmillis);
|
flow_loop(loopmillis);
|
||||||
|
@ -163,35 +141,17 @@ void loop() {
|
||||||
if (!digitalRead(PIN_BUTTON)) { //button pressed
|
if (!digitalRead(PIN_BUTTON)) { //button pressed
|
||||||
valueError=false;
|
valueError=false;
|
||||||
Serial.println("Reset ValueError flag by user");
|
Serial.println("Reset ValueError flag by user");
|
||||||
#ifdef PIN_LED
|
|
||||||
digitalWrite(PIN_LED,valueError); //set led before delay to blink if error persists
|
digitalWrite(PIN_LED,valueError); //set led before delay to blink if error persists
|
||||||
#endif
|
|
||||||
#ifdef PIN_NEOPIXEL
|
|
||||||
pixels.setPixelColor(0, pixels.Color(255*valueError, 0,0));
|
|
||||||
pixels.show();
|
|
||||||
#endif
|
|
||||||
delay(100);
|
delay(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool last_valueError=true;
|
static bool last_valueError=true;
|
||||||
if (!valuesStabilized) { //if values are not okay since boot
|
if (!valuesStabilized) { //if values are not okay since boot
|
||||||
#ifdef PIN_LED
|
|
||||||
digitalWrite(PIN_LED,(loopmillis/250)%2==0); //blink led
|
digitalWrite(PIN_LED,(loopmillis/250)%2==0); //blink led
|
||||||
#endif
|
|
||||||
#ifdef PIN_NEOPIXEL
|
|
||||||
pixels.setPixelColor(0, pixels.Color((loopmillis/250)%2==0,(loopmillis/250)%2==0,0));
|
|
||||||
pixels.show();
|
|
||||||
#endif
|
|
||||||
}else{ //LED shows valueError flag status when values were okay once
|
}else{ //LED shows valueError flag status when values were okay once
|
||||||
if (last_valueError!=valueError) { //update led if valueerror flag changed
|
if (last_valueError!=valueError) { //update led if valueerror flag changed
|
||||||
last_valueError=valueError;
|
last_valueError=valueError;
|
||||||
#ifdef PIN_LED
|
|
||||||
digitalWrite(PIN_LED,valueError);
|
digitalWrite(PIN_LED,valueError);
|
||||||
#endif
|
|
||||||
#ifdef PIN_NEOPIXEL
|
|
||||||
pixels.setPixelColor(0, pixels.Color((loopmillis/250)%2==0,(loopmillis/250)%2==0,0));
|
|
||||||
pixels.show();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,32 +162,16 @@ void loop() {
|
||||||
if (eccalibrationoutput && !digitalRead(PIN_BUTTON) && !getReading) { //Calibration UI
|
if (eccalibrationoutput && !digitalRead(PIN_BUTTON) && !getReading) { //Calibration UI
|
||||||
if (!isValueArrayOK(ec_calib_array,EC_CALIB_ARRAY_SIZE,EC_ADC_UNAVAILABLE)) {
|
if (!isValueArrayOK(ec_calib_array,EC_CALIB_ARRAY_SIZE,EC_ADC_UNAVAILABLE)) {
|
||||||
for (uint8_t blink=0;blink<5;blink++) {
|
for (uint8_t blink=0;blink<5;blink++) {
|
||||||
#ifdef PIN_LED
|
|
||||||
digitalWrite(PIN_LED,HIGH);
|
digitalWrite(PIN_LED,HIGH);
|
||||||
delay(100);
|
delay(100);
|
||||||
digitalWrite(PIN_LED,LOW);
|
digitalWrite(PIN_LED,LOW);
|
||||||
delay(100);
|
delay(100);
|
||||||
#endif
|
|
||||||
#ifdef PIN_NEOPIXEL
|
|
||||||
pixels.setPixelColor(0, pixels.Color(0,0,255));
|
|
||||||
pixels.show();
|
|
||||||
delay(100);
|
|
||||||
pixels.setPixelColor(0, pixels.Color(0,0,0));
|
|
||||||
pixels.show();
|
|
||||||
delay(100);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
getReading=true;
|
getReading=true;
|
||||||
force_ec_measurement=true;
|
force_ec_measurement=true;
|
||||||
ec_flag_measurement_available=false;
|
ec_flag_measurement_available=false;
|
||||||
#ifdef PIN_LED
|
|
||||||
digitalWrite(PIN_LED,HIGH);
|
digitalWrite(PIN_LED,HIGH);
|
||||||
#endif
|
|
||||||
#ifdef PIN_NEOPIXEL
|
|
||||||
pixels.setPixelColor(0, pixels.Color(0,255,0));
|
|
||||||
pixels.show();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,13 +180,7 @@ void loop() {
|
||||||
|
|
||||||
ec_flag_measurement_available=false;
|
ec_flag_measurement_available=false;
|
||||||
getReading=false;
|
getReading=false;
|
||||||
#ifdef PIN_LED
|
|
||||||
digitalWrite(PIN_LED,LOW);
|
digitalWrite(PIN_LED,LOW);
|
||||||
#endif
|
|
||||||
#ifdef PIN_NEOPIXEL
|
|
||||||
pixels.setPixelColor(0, pixels.Color(0,0,0));
|
|
||||||
pixels.show();
|
|
||||||
#endif
|
|
||||||
Serial.print(loopmillis); Serial.print(",");
|
Serial.print(loopmillis); Serial.print(",");
|
||||||
Serial.print(tempCmean_reservoir); Serial.print(",");
|
Serial.print(tempCmean_reservoir); Serial.print(",");
|
||||||
Serial.print(ec_calib_adc); Serial.print(",");
|
Serial.print(ec_calib_adc); Serial.print(",");
|
||||||
|
|
Loading…
Reference in New Issue