project:
it is a that in theory was supposed to be simple but i ran into many errors and as i never managed to use blynk 2.0 sucesfully so … here is my proyect is based on an esp 8266 with a dht 11 and a bmp 180 (I know I could have used a bmp 280 but in my country I can’t find them) everything is powered with a 18650 2200mah battery that is recharged using solar and a tp4056 and the voltage monitor with 2 resistors (100K) and the light with a ldr and a 3.3k resistor seen that the esp 8266 has are an analog input I used a multiplexer (cd4051be) of which I use only 2 inputs B, C are connected to ground p.s. the code is based on examples.
connections:
dht pin D4
bmp pin D1, D2
mux out pin A0
mux A pin D5
problem: my code does not seem to work I do not know if they are syntax errors or blynk adgent that is used wrongly I am totally open to suggestions I am infinitely thankful to anyone who can help me.
if you need any informaction ask.
#define BLYNK_TEMPLATE_ID ""
#define BLYNK_DEVICE_NAME ""
#define BLYNK_FIRMWARE_VERSION "0.1.0"
#define BLYNK_PRINT Serial
#define USE_NODE_MCU_BOARD
#include <Adafruit_BMP085.h>
#include "DHT.h"
int analogInPin = A0; // Analog input pin
int sensorValue;
#define DHTpin 2 // D4 on the nodemcu ESP8266
#define DHTTYPE DHT11
DHT dht(DHTpin,DHTTYPE);
#define MUX_A D5 //pin mux
float calibration = 0.33;
//#define APP_DEBUG
#include "BlynkEdgent.h"
Adafruit_BMP085 bmp;
void setup()
{ Serial.begin(115200);
pinMode(MUX_A, OUTPUT);
}
void changeMux(int a){
digitalWrite(MUX_A, a);
dht.begin();
bmp.begin();
Serial.println("Serial begin");
BlynkEdgent.begin();
delay(2000);
}
void loop() {
BlynkEdgent.run();
//luminosità
float voltage;
float light;
changeMux(LOW);
delay (1000);
sensorValue = analogRead(analogInPin);
voltage = (((sensorValue * 3.3) / 1024) * 2 + calibration); //multiply by two as voltage divider network is 100K & 100K Resistor
Serial.print("Analog Value = ");
Serial.print(sensorValue);
Serial.print("\t Output Voltage = ");
Serial.print(voltage);
delay(1000);
changeMux(HIGH);
delay (1000);
light = analogRead(analogInPin / 1023.0f);
Serial.print("ligt = ");
Serial.print(light);
delay (1000);
//altri sensori
float humidity = dht.readHumidity();
Serial.print("humidity ");
Serial.println(humidity);
float temperature = bmp.readTemperature();
Serial.print("temperature ");
Serial.println(temperature);
float pressure = bmp.readPressure();
Serial.print("Pressure ");
Serial.println(pressure);
Blynk.virtualWrite(V0, voltage); //luminosità
Blynk.virtualWrite(V1, temperature); //temperatura
Blynk.virtualWrite(V2, humidity); //humidità
Blynk.virtualWrite(V3, pressure); //pressione
Blynk.virtualWrite(V4, light); //luce
delay(2000);
ESP.deepSleep(60000000);
}