i am in serious need of help as i cant understand whats wrong with this code, when im running the code without blynk its working but over blynk connection no output is showing on the widget nor the serial monitor
#define BLYNK_TEMPLATE_ID "TMPLc6UqRDpu"
#define BLYNK_TEMPLATE_NAME "FOOT PRESSURE"
#define BLYNK_AUTH_TOKEN "XXXX"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
char auth[] = "XXXX";
char ssid[] = "XXXX"; // type your wifi name
char pass[] = "XXXX"; // type your wifi password
BlynkTimer timer;
int FSRpin = 2;
int value;
int voltage;
int pressure;
unsigned long resistance ;
unsigned long conductance ;
int R;
void setup(void) {
Serial.begin(9600);
pinMode(FSRpin, INPUT);
Blynk.begin(auth, ssid, pass,"blynk.cloud", 80);
timer.setInterval(100L, sensorData);
}
void sensorData()
{
value = analogRead(FSRpin);
Serial.print("Analog reading from FSR = ");
Serial.println(value);
// Map analog value to obtain Vo in mV
voltage = map(value, 0, 4095, 0, 3300);
if (voltage == 0) {
Serial.println("No force applied");
delay(1000);
return;
}
Serial.print("Vo = ");
Serial.print(voltage);
Serial.println(" mV ");
//Calculate resistance using voltage divider equation
//R_fsr = [(Vin*R)/Vo] - R
resistance = 33e6/voltage;
resistance = resistance - 10000;
//Calculate conductance in micro mho(1/R)
conductance = 1000000/resistance; //Convert to micro mhos
//Use the FSR resistance vs. force graphs to estimate the force
if (conductance <= 1000) {
R = conductance/80;
}
else {
R = (conductance - 1000)/30;
}
Blynk.virtualWrite(V0, R); // sending sensor value to Blynk app
}
void loop() {
Blynk.run();
timer.run();
}
@Snehasis Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```
Copy and paste these if you can’t find the correct symbol on your keyboard.
The ESP32 has two analog to digital converters (ADCs) called ADC1 and ADC2.
Pins attached to ADC 2 cannot be used at the same time as WiFi.
GPIO2 is attached to ADC2, which is why it works fine without Blynk (when WiFi is not used) but stops working when WiFi is used.
Choose an ADC1 pin from the lost below and use that instead…
Analog to Digital Converter (ADC)
The ESP32 has 18 x 12 bits ADC input channels (while the ESP8266 only has 1x 10 bits ADC). These are the GPIOs that can be used as ADC and respective channels:
Posting screenshots of your serial output doesn’t help.
Copy/paste the text and use triple backticks, and post the exact code that produced the serial output.