I have issue about stability

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

OpenBuilds Micro Limit Switch

Resistor 10k ohm

Li-Ion Battery 3.7 volt 1050mAh

connectionScreenshot 2021-05-17 234108



#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 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;
  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));

  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));

  float humidity = thSense.readHumidity(); // Read from humidity sensor
  Blynk.virtualWrite(HUMIDITY_VIRTUAL, humidity); // Update Blynk virtual value
  //BB_DEBUG("Blynk Read Humidity: " + String(humidity));

  uint8_t Count = analogRead(SENSOR_PIN);
  //Blynk.virtualWrite(switch, "You have 2 ");
    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
  // Initialize Blynk
  Blynk.begin(BlynkAuth, WiFiNetwork, WiFiPassword);

void loop()
  // Execute Blynk.run() as often as possible during the loop

Looking at your photo then I’d say yes, almost certainly!


1 Like

Reducing the number of cables is also a solution? for example: Does using 4 wires instead of 8 wires increase the stability?

I haven’t bothered analyzing your code or process, but I would recommend BLYNK_WRITE() and BlynkTimer as needed. BLYNK_READ() requires the App Project to be active for the hardware code to fully work and then the App handles the widgets timing needs, but may not be as precise as the MCU.

I’m not familiar with the SparkFun board as such, but your schematic raises some questions… And they might be stupid! :grin:

Your VCC (3.7 V) is connected to the 3.3V pin, not VIN as it should. It’s interesting that it actually works, but I wouldn’t recommend it. If the whole board is running on 3.7V you might damage the components.

If I understand your sketch correct, you’re trying to calculate the number of buttons pressed down based by the voltage they collectively feed to the ADC, where each combination is (in theory) unique?

Well… that won’t work! :stuck_out_tongue_winking_eye: What you have is a current divider, not voltage!

Regardless of how many of the S6-S10 buttons you press down simultaneously, the voltage drops down to 1.85V (VCC == 3.7V) and that’s the only number the ADC will get!

Why uint8_t? uint8_t can only represent a value between 0 and 255. The ADC has a 10-bit resolution and returns a value between 0 and 1023. If the returned number is above 255, it (should) cause(s) an integer overflow. But it’s beyond my knowledge how it will affect your program!

You might want to check your alligator clips if they are dirty or corroded, loose cables and general connectivity. It’s easily done with a multimeter (and visually). The resistance in those short cables are negligeable. Again, use your multimeter! :slight_smile:

I would consider soldering some (female) pins to the PCB and only use those “breadboard jumper cables” you already have. They are easy to work with and makes the alligator clips pretty much redundant.