Well, your code is a mess!
Your void setup only has one line in it…
void setup()
{
timer.setInterval(1000L, sensorDataSend); //timer will run every sec
}
These two lines of code, which aren’t in any function (void) should be in your void setup…
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
You then have these tw0 lines of code, one at the top and one near the bottom…
int sensorValue = analogRead(A0);
int sensorValue = analogRead(A0);
These in initialise the sensorValue
variable as an read the A0 pin and store the result in sensorValue
.
However, you want to be initialising the sensorValue
variable once, near the top of your code so that sensorValue
is a global variable, then taking a reading of A0 within a function which is called using a timer. The other lines of code that go with this process are…
int percentageHumididy = map(sensorVal, wet, dry, 100, 0);
Serial.print(percentageHumididy);
Serial.println("%");
delay(100);
and these need to be inside the same timed function, BUT, the delay is not required and should be removed.
Having variable definitions in the middle of your code can be confusing. Put them near the top so that they are easy to find…
I think it would be helpful if you spent some time learning the basics of C++ coding, so that you understand the structure of an Arduino sketch.
Pete.