Hi,
I’m building a weather station for my plants and trees.
I’ve started from this Blynk example for bringing in analog sensors. (My case Rain sensor and soil sensor.)
Then I switched to (bare with me) putting in the DHT11 sensor to send temp & humidity to my blynk app. I did this from Blynk example.
And the DHT example worked of course, I throwed some stuff out (Relay & LED) and started to join the Analog in example in the sketch.
The first problem then was that I lost my humidity in the app, better it became a 1 or a 0. Though Temp remained correct and the first analog in (moist sensor) gave me a analog voltage. (How to convert this to a correct mapping I still need to figure out!)
Being me, I headed on thru with adding sensors instead off fixing the problems first. Thus second analog sensor attached (Soil sensor, again don’t know how to correctly convert that data on the gauge)
Then I though I have I2C working (analogs) why not add a lux sensors, which I did and like all all the sensors separately throughout the build they worked in the serial monitor (BLYNK Lesson 1 ) as did the lux sensor. Strange quick data with lot’s of overloads. ( third time need to figure out how to convert the data in to something in the app to be more understandable)
But when adding the lux sensor the data gets weird on the app. The temp drops to 0 when the lux sensor gets lots of light. Humidity keeps being 1 and jumps very fast to 0 and back.
The lux sensor gives me correct data being mostly 26.00 too 4000.00
Without the drops (which I do want to get fixed), only the humidity doesn’t come back correctly.
And I need to map the value for the soil and lux and rain.
So the main question would be, how to fix the humidity and the mapping for the app.
code:
#include <Adafruit_TSL2561_U.h>
#include <pgmspace.h>
#include "ESP8266WiFi.h"
#include "BlynkSimpleEsp8266.h"
#include "DHT.h"
#include "SimpleTimer.h" //Good timer library
#include <Adafruit_ADS1015.h>
Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345);
#define BLYNK_PRINT Serial
#define DHTPIN D4 // what pin we're connected to
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
int temp;
int humidity;
int moisture_val; // SoilMoisture Value
char auth[] = ""; //Auth Token for project
char ssid[] = ""; //Wifi
char pass[] = "";//Pass
SimpleTimer timer;
Adafruit_ADS1115 ads;
float Voltage0 = 0.0;
float Voltage1 = 0.0;
float Voltage2 = 0.0;
float Voltage3 = 0.0;
void setup()
{
Serial.begin(115200);
dht.begin();
Blynk.begin(auth, ssid, pass);
int mytimeout = millis() /1000;
while (Blynk.connect() == false) {
if((millis() / 1000) > mytimeout + 8){
if(!tsl.begin())
{
Serial.print("No TSL2561 detected");
while(1);
}
tsl.enableAutoRange(true);
tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS);
Serial.println("");
break;
}
}
// Setup function to be called every 2 seconds
timer.setInterval(200L, sendData);
timer.setInterval(350L, ReadANALOGS);
timer.setInterval(350L, Lux);
ads.setGain(GAIN_TWO); //https://community.blynk.cc/t/ads1115-with-wemos-mini-d1/12215
ads.begin();
}
//--(end setup )---
void ReadANALOGS()
{
int16_t adc0, adc1, adc2, adc3;
adc0 = ads.readADC_SingleEnded(0);
adc1 = ads.readADC_SingleEnded(1);
adc2 = ads.readADC_SingleEnded(2);
adc3 = ads.readADC_SingleEnded(3);
Voltage0 = (adc0 * 0.125)/1000;
Voltage1 = (adc1 * 0.125)/1000;
Voltage2 = (adc2 * 0.125)/1000;
Voltage3 = (adc3 * 0.125)/1000;
//Serial.print("AIN0: "); Serial.println(Voltage0);
// Serial.print("AIN1: "); Serial.println(Voltage1);
// Serial.print("AIN2: "); Serial.println(Voltage2);
// Serial.print("AIN3: "); Serial.println(Voltage3);
// Serial.println(" ");
Blynk.virtualWrite(V0, Voltage0); **//Conversion or mapping here? SOIL**
Blynk.virtualWrite(V1, Voltage1); **//Conversion or mapping here? MOIST**
Blynk.virtualWrite(V4, Voltage2);
Blynk.virtualWrite(V5, Voltage3);
}
void sendData()
{
float t = dht.readTemperature();
float h = dht.readHumidity();
moisture_val = digitalRead(D4); // read the value from the moisture sensor
Blynk.virtualWrite(V2, t);
Blynk.virtualWrite(V3, moisture_val); **//This does not work**
}
void Lux()
{
/* Get a new sensor event */
sensors_event_t event;
tsl.getEvent(&event);
Blynk.virtualWrite(V6, event.light); **//Conversion or mapping here?**
}
void loop()
{
Blynk.run();
timer.run(); // Initiates SimpleTimer
}
If needed I’m making a fritzing for the wiring and can post that too and screenshots of the app if needed!!
Thanks! And big up to the ones I got the examples from!