Coding for FSR sensor with blynk

Hi everone I want to connect FSR sensor with Blynk uisng ESP32
Can anyone help to find the problem:

#include <BlynkSimpleEsp32.h>

#define BLYNK_DEVICE_NAME "first project"
#define BLYNK_AUTH_TOKEN "H46NFGb02mEV9YAz_ExbqBGvhf0rSVR3"
#define FORCE_SENSOR_PIN 36 // ESP32 pin GIOP36 (ADC0): the FSR and 10K pulldown are connected to A0

char auth[]= "H46NFGb02mEV9YAz_ExbqBGvhf0rSVR3";
char ssid[]= "Success";
char pass[]= "1A2B3C4D";

void setup() {
  Blynk.begin(auth, ssid, pass);

void loop() {
  // Read the FSR sensor's output
  int FORCE_SENSOR_PIN = analogRead(A0);

  // Send the FSR output to the Blynk app
  Blynk.virtualWrite(V1, FORCE_SENSOR_PIN);

  // Wait for a short time before reading the sensor again

It shows an Compilation error: “expected unqualified-id before numeric constant”

at which point in your code?

Post the compiler error message with triple backticks in the same way that you did with your sketch.

I’m guessing that it’s something to do with this…

There are a variety of other issue with your code, but we’ll talk about those when we’ve resolved your compiler issue.


Thanks for your reply

It shows the error in this line

#define FORCE_SENSOR_PIN 36 // ESP32 pin GIOP36 (ADC0): the FSR and 10K pulldown are connected to A0

Okay, well this:

tells the compiler to replace all occurrences of FORCE_SENSOR_PIN with 36

So, this line…

is actually being read as…

define an integer variable called 36 and make it equal to the value that is returned when you read the voltage on pin A0

The compiler doesn’t really like variables with names like 36 and there is no A0 pin on the ESP32.

and, when you do this…

You’re actually writing the value 36 to datasteram V1, not the reading that has come from an analog pin.

In addition, these thee lines of code…

need to be the very first lines of your sketch, you need these two lines of code in your sketch…

#include <WiFi.h>
#include <WiFiClient.h>

this line of code…

should read…

char auth[] = BLYNK_AUTH_TOKEN;

you shouldn’t have Blynk.virtualWrites in your void loop, and you shouldn’t use delay() commands with Blynk.Instead you should use a BlynkTimer to call a function which reads your analog pin and writes the result to Blynk.

you should read this for more info…

If you want to take a reading from GPIO36 and send it to Blynk, you could do this…

int analog_reading = analogRead(36);
Blynk.virtualWrite(V1, analog_reading);