Hello
I have completed a projekt for my garten momentan with board Wemos D1 and i use Blynk App
I reads with my code momentan :
1 x Soil moisture
1 x Bme280 sensor pressure temperatur humidity
1 x relay 5v
1 x Watter pump
But now i want to connect another one soil sensor and one Uv sensor ml8511 …i have a wemos D1 r1 momentan and i want to connect all analog Pins from the sensor with board ADS1015 to read all analog pins… because my board wemos have only one A0 pins…It is possibile to do this one???
I started writing extra code to read the Uv sensor ML8511 with blynk togheter but i dint not succeed…
I dont understand how to include the board ADS1015 in my code the same?
This is my code and now how do i enter the other codes in my program ?
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <Wire.h>
#include <BlynkSimpleEsp8266.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
WidgetLED PUMP(V0);
#define SEALEVELPRESSURE_HPA (309.25)
#define SOIL_MOIST_1_PIN A0 // pin A0 with A0
#define PUMP_PIN D2 // PUMP RELAY
#define DRY_SOIL 68
#define WET_SOIL 90
#define TIME_PUMP_ON 15
#define READ_SOIL_HUM_TM 10L
#define READ_AIR_DATA_TM 2L
#define SEND_UP_DATA_TM 10L
#define AUTO_CTRL_TM 60L
char auth[] = "blynk";
char ssid[] = "wifi";
char pass[] = "password";
float pressure; //To store the barometric pressure (Pa)
float temperature; //To store the temperature (oC)
int altimeter; //To store the humidity (%) (you can also use it as a float variable)
int soilMoist = 0;
boolean pumpStatus = 0;
int timePumpOn = 1;
long sampleTimingSeconds = 20;
long startTiming = 0;
long elapsedTime = 0;
SimpleTimer timer;
Adafruit_BME280 bme;
void setup() {
pinMode(PUMP_PIN, OUTPUT);
bme.begin(0x76); //Begin the sensor
aplyCmd();
Serial.begin(9600);
Serial.println("Adafruit BME280 test:");
Blynk.begin( auth, ssid , pass );
PUMP.off();
startTimers();
timer.setInterval(2000L, ReadSensors); // read sensor every 5s
}
void loop() {
timer.run(); // Initiates SimpleTimer
Blynk.run();
}
BLYNK_WRITE(4)
{
int i = param.asInt();
if (i == 1)
{
pumpStatus = !pumpStatus;
aplyCmd();
}
}
void getSoilMoist(void)
{
int i = 0;
soilMoist = 0;
for (i = 0; i < 10; i++) //
{
soilMoist += analogRead(SOIL_MOIST_1_PIN);
delay(20);
}
soilMoist = soilMoist / (i);
soilMoist = map(soilMoist, 1023, 0, 0, 100);
}
void ReadSensors(void) {
//Read values from the sensor:
pressure = bme.readPressure();
temperature = bme.readTemperature();
altimeter = bme.readHumidity ();
//Print values to serial monitor:
Serial.print(F("Pressure: "));
Serial.print(pressure);
Serial.print(" hPa");
Serial.print("\t");
Serial.print(("Temp: "));
Serial.print(temperature);
Serial.print(" °C");
Serial.print("\t");
Serial.print(" Altimeter: ");
Serial.print( altimeter ); // this should be adjusted to your local forcase
Serial.println(" % ");
//delay(2000); //Update every 5 sec
}
void aplyCmd()
{
if (pumpStatus == 1)
{
Blynk.notify("pump ON");
digitalWrite(PUMP_PIN, LOW);
PUMP.on();
}
else {
digitalWrite(PUMP_PIN, HIGH);
PUMP.off();
}
}
void autoControlPlantation(void)
{
if (soilMoist < DRY_SOIL)
{
turnPumpOn();
}
}
void turnPumpOn()
{
pumpStatus = 1;
aplyCmd();
delay (TIME_PUMP_ON * 1000);
pumpStatus = 0;
aplyCmd();
}
void startTimers(void)
{
timer.setInterval(READ_SOIL_HUM_TM * 1000, getSoilMoist);
timer.setInterval(SEND_UP_DATA_TM * 1000, sendUptime);
timer.setInterval(AUTO_CTRL_TM * 1000, autoControlPlantation);
}
void sendUptime()
{
Blynk.virtualWrite(V1, pressure / 100); // write pressure to V1 value display widget
Blynk.virtualWrite(V2, temperature); // write temperature to V2 value display widget
Blynk.virtualWrite(V3, altimeter); // write altimeter to V3 value display widget
Blynk.virtualWrite(V4, soilMoist);
}```