so here is my letest code; unfortunatly i can’t put a wiring diagram but i can explain it and put some photos
if you take a look the cd4051 datasheet or search for pin out … i got INH, Vee, Vss, C to ground of the board; A to pin D5 on the mcu and B to D6; Vdd is coneccted to vin on the mcu which is at 4.2 volt of the battery
the inputs i am using are the 0,1,2: 0 is for the ldr which i am not very interested in accuracy, 1 is used for the battery voltage is a voltage divider 100k and 100k so i get half the voltage, 2 is the same thing except that I use it to monitor the voltage of the solar panel which keeps the battery charged. it’s nothing special but when I see the values in the serial monitor they keep changing and fluctuating quite a bit sometimes they have the right value,
i put the: for (int x = 0; x <10; x ++)
{
function to get better accuracy but it doesn’t seem to work I don’t know if the problem is the same ground
#define BLYNK_TEMPLATE_ID ""
#define BLYNK_DEVICE_NAME ""
#define BLYNK_AUTH_TOKEN ""
// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
#include <Adafruit_BMP085.h>
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
#define MUX_A D5
#define MUX_B D6
#define MUX_C D7
int analogInPin = A0; // Analog input pin
int sensorValue;
int sensor;
float calibration1 = 0.43;
float calibration2 = 0.28 ;
float light;
float voltage;
float solar;
Adafruit_BMP085 bmp;
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "";
char pass[] = "";
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
dht.begin();
bmp.begin();
pinMode(MUX_A, OUTPUT);
pinMode(MUX_B, OUTPUT);
pinMode(MUX_C, OUTPUT);
}
void changeMux(int c, int b, int a){
digitalWrite(MUX_A, a);
digitalWrite(MUX_B, b);
digitalWrite(MUX_C, c);
}
void loop(){
Blynk.run();
send();
}
void send(){
delay(1000);
changeMux(LOW, LOW, LOW);
delay(2000);
light = analogRead(analogInPin / 1023.0f);
Serial.print("ligt = ");
Serial.print(light);
delay (1000);
for (int x = 0; x < 10; x++)
{
changeMux(LOW, LOW, HIGH);
delay(3000);
sensorValue = analogRead(analogInPin);
voltage = (((sensorValue * 3.3) / 1024) * 2 + calibration1);//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(2000);
changeMux(LOW, HIGH, LOW);
delay(3000);
sensor = analogRead(analogInPin);
solar = (((sensor * 3.3) / 1024) * 2 + calibration2);//multiply by two as voltage divider network is 100K & 100K Resistor
Serial.print("Analog Value = ");
Serial.print(sensor);
Serial.print("\t Output Voltage = ");
Serial.print(solar);
delay(2000);
}
float h = dht.readHumidity();
float t = bmp.readTemperature();
float p = bmp.readPressure();
Blynk.virtualWrite(V1, t);
Blynk.virtualWrite(V2, h);
Blynk.virtualWrite(V3, p);
Blynk.virtualWrite(V4, voltage);
Blynk.virtualWrite(V5, light);
Blynk.virtualWrite(V6, solar);
delay(3000);
ESP.deepSleep(9e+8);
}
P.S. the code works really well besides the accuracy error