Compare commits

..

No commits in common. "fe93d9eff6d7a03c28a3d863defe79b92ca84e78" and "5f0f19c58d28c8828b0dfa70091f65c1be8a7eb9" have entirely different histories.

3 changed files with 14 additions and 80 deletions

View File

@ -113,12 +113,9 @@ void temperature_loop(unsigned long loopmillis) {
Serial.println("Warn: Request Temperatures Timeout!");
publishInfo("error/temperature","Warn: Request Temperatures Timeout!");
flag_requestTemperatures=false;
last_read_ds18b20=loopmillis;
}
if (!flag_requestTemperatures) {
sensors.setWaitForConversion(false); //make async
sensors.requestTemperatures(); //this takes ~600ms in non async mode. about 2ms in async mode
sensors.setWaitForConversion(true);
sensors.requestTemperatures(); //this takes ~600ms
flag_requestTemperatures=true;
}
if (sensors.isConversionComplete()) {

View File

@ -52,24 +52,24 @@ monitor_speed = 115200
build_flags=
'-D CLIENT_ID="hydroponic-Test"'
-D PIN_BUTTON=12
'-D CLIENT_ID="hydroponic-DB"'
-D PIN_BUTTON
-D EC_PIN_RELAY_PROBE=6
-D EC_PIN_FREQ=5
-D EC_PIN_RELAY_PROBE
-D EC_PIN_FREQ
-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_LINEAR_LOWADC=728
-D EC_CALIBRATION_LINEAR_LOWEC=0
-D FLOW_PIN=16
-D ONE_WIRE_BUS_PIN=18
-D FLOW_PIN
-D ONE_WIRE_BUS_PIN
-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_SCL=2
-D PIN_SDA
-D PIN_SCL
lib_deps =
https://github.com/milesburton/Arduino-Temperature-Control-Library/
@ -77,4 +77,3 @@ lib_deps =
robtillaart/ADS1X15@^0.3.9
256dpi/MQTT@^2.5.2
pololu/VL53L0X@^1.3.1
adafruit/Adafruit NeoPixel

View File

@ -48,36 +48,14 @@ ADS1115 ADS(0x48);
//#include "soilmoisture.h"
#ifdef PIN_NEOPIXEL
#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel pixels(1, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800);
#endif
void setup() {
pinMode(PIN_BUTTON,INPUT_PULLUP);
#ifdef PIN_LED
pinMode(PIN_LED,OUTPUT);
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);
if (mqtt) {
WiFi.begin(ssid, pass);
@ -88,7 +66,7 @@ void setup() {
Serial.println("Setup Waterlevel");
waterlevel_setup();
//waterlevel_setup(); //Temporarily disabled
//init ADS1115
@ -149,7 +127,7 @@ void loop() {
temperature_loop(loopmillis);
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);
@ -163,35 +141,17 @@ void loop() {
if (!digitalRead(PIN_BUTTON)) { //button pressed
valueError=false;
Serial.println("Reset ValueError flag by user");
#ifdef PIN_LED
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);
}
static bool last_valueError=true;
if (!valuesStabilized) { //if values are not okay since boot
#ifdef PIN_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
if (last_valueError!=valueError) { //update led if valueerror flag changed
last_valueError=valueError;
#ifdef PIN_LED
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 (!isValueArrayOK(ec_calib_array,EC_CALIB_ARRAY_SIZE,EC_ADC_UNAVAILABLE)) {
for (uint8_t blink=0;blink<5;blink++) {
#ifdef PIN_LED
digitalWrite(PIN_LED,HIGH);
delay(100);
digitalWrite(PIN_LED,LOW);
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{
getReading=true;
force_ec_measurement=true;
ec_flag_measurement_available=false;
#ifdef PIN_LED
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;
getReading=false;
#ifdef PIN_LED
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(tempCmean_reservoir); Serial.print(",");
Serial.print(ec_calib_adc); Serial.print(",");