Hi i have a project.i use sparkfun blynk board esp 8266. This project shows how many buttons are pressed!. i have a issue with stability.One day. It says right number about how many buttons are pressed.One day it says wrong number about how many buttons are pressed.Is soldering the solution to the problem? what are other solutions? Reducing the number of cables is also a solution?
what i use
SparkFun Blynk Board - ESP8266
Resistor 10k ohm
Li-Ion Battery 3.7 volt 1050mAh
connection
!code
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#include "SparkFunHTU21D.h"
#include <SparkFunTSL2561.h>
HTU21D thSense;
#define TEMPERATURE_F_VIRTUAL V5
#define TEMPERATURE_C_VIRTUAL V6
#define HUMIDITY_VIRTUAL V7
#define switch V8
////////////////////
// Blynk Settings //
////////////////////
char BlynkAuth[] = "0Pegr97uh45ı7674goıh3"; //replace
char WiFiNetwork[] = "pier2";
char WiFiPassword[] = "44h535h6";
///////////////////////
// Hardware Settings //
///////////////////////
#define SENSOR_PIN A0
float tempCOffset = 0; //-8.33;
BLYNK_READ(TEMPERATURE_F_VIRTUAL)
{
float tempC = thSense.readTemperature(); // Read from the temperature sensor
tempC += tempCOffset; // Add any offset
float tempF = tempC * 9.0 / 5.0 + 32.0; // Convert to farenheit
// Create a formatted string with 1 decimal point:
Blynk.virtualWrite(TEMPERATURE_F_VIRTUAL, tempF); // Update Blynk virtual value
//BB_DEBUG("Blynk Read TempF: " + String(tempF));
}
BLYNK_READ(TEMPERATURE_C_VIRTUAL)
{
float tempC = thSense.readTemperature(); // Read from the temperature sensor
tempC += tempCOffset; // Add any offset
Blynk.virtualWrite(TEMPERATURE_C_VIRTUAL, tempC); // Update Blynk virtual value
//BB_DEBUG("Blynk Read TempC: " + String(tempC));
}
BLYNK_READ(HUMIDITY_VIRTUAL)
{
float humidity = thSense.readHumidity(); // Read from humidity sensor
Blynk.virtualWrite(HUMIDITY_VIRTUAL, humidity); // Update Blynk virtual value
//BB_DEBUG("Blynk Read Humidity: " + String(humidity));
}
BLYNK_READ(switch)
{
uint8_t Count = analogRead(SENSOR_PIN);
Serial.println(Count);
//Blynk.virtualWrite(switch, "You have 2 ");
if(Count>200){
Blynk.virtualWrite(switch, "YOU HAVE 4 ");
}
else if(Count<120 && Count>100){
Blynk.virtualWrite(switch, "You have 2 ");
}
else if(Count<100 && Count>30){
Blynk.virtualWrite(switch, "You have 1 ");
//Blynk.notify("You have no ");
}
else if(Count<200 && Count>120){
Blynk.virtualWrite(switch, "You have 0 ");
Blynk.notify("You have no ");
}
else if(Count>0 && Count<30){
Blynk.virtualWrite(switch, "You have 3 ");
}
}
void setup()
{
// Initialize hardware
Serial.begin(9600); // Serial
thSense.begin();
delay(500);
// Initialize Blynk
Blynk.begin(BlynkAuth, WiFiNetwork, WiFiPassword);
}
void loop()
{
// Execute Blynk.run() as often as possible during the loop
Blynk.run();
}