NodeMcu with blynk Compiling error

This is an nodemcu program to display multiple sensor values in blynk app.It worked smooth on arduino ide 1.6.5.My current version is 1.6.7.In here while compiling IDE shows error that sensorvalue1 not found in scope.sensorvalue1 is a user defined function.Whats wrong with my code.How to correct it.Program and error image is attached.Help is much appreciated.

blynk.ino (1.8 KB)

char rdata;sensorvalue1

-->did you paste by mistake [color=red]sensorvalue1[/color] there ??

you can't have a variable that has the same name as the function... so you need to correct that. I don't believe this was working smoothly before;..

sry where??i couldnt see the mistake u said

J-M-L:

char rdata;sensorvalue1

-->did you paste by mistake [color=red]sensorvalue1[/color] there ??

you can't have a variable that has the same name as the function... so you need to correct that. I don't believe this was working smoothly before;..

pls i couldnt find the mistake u specified

This is the 3rd time i am posting this .Nobody tried to give me an answer.This was a program that ran smooth in arduino 1.6.5 ide.But now its shows error.

#define BlYNK_Print Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SoftwareSerial.h>
#include <SimpleTimer.h>

char auth[] = "bea7af839b1e421c995e09125e886bd5";

char ssid[] = "EnergyMonitor";
char pass[] = "Current";

SimpleTimer timer;

String myString;
char rdata;

int firstVal, secondVal, thirdVal, fourthVal;

void myTimerEvent()
{
  Blynk.virtualWrite(V1, millis() / 1000);
}

void setup()
{
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L,sensorvalue1);
  timer.setInterval(1000L,sensorvalue2);
  timer.setInterval(1000L,sensorvalue3);
}
void loop()
{
  if (Serial.available() == 0)
  {
    Blynk.run();
    timer.run();
  }
  if (Serial.available() > 0)
  {
    rdata = Serial.read();
    myString = myString + rdata;
    if (rdata == '\n')
    {
      String 1 = getValue(myString, ',', 0);
      String 2 = getValue(myString, ',', 1);
      String 3 = getValue(myString, ',', 2);
      String 4 = getValue(myString, ',', 3);

      firstVal = l.toInt();
      secondVal = m.toInt();
      thirdVal = n.toInt();
      fourthVal = o.toInt();

      myString = "";
    }
  }

}
void sensorvalue1()
{
  int sdata = secondVal;
  Blynk.virtualWrite(V2, sdata);
}
void sensorvalue2()
{
  int sdata = thirdVal;
  Blynk.virtualWrite(V3, sdata);
}
void sensorvalue3()
{
  int sdata = fourthVal;
  Blynk.virtualWrite(V4, sdata);
}

 String getValue(String data, char seperator, int index)
{
  int found = 0;
  int strIndex[] = {0, -1};
  int maxIndex = data.length() - 1;
  for (int i = 0; i <= maxIndex && found <= index; i++)
  {
    if (data.charAt(i) == seperator || i == maxIndex)
    {
      found++;
      strIndex[0] = strIndex[1] + 1;
      strIndex[1] = (i == maxIndex) ? i + 1 : i;
    }
  }
  return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
}

Shows error sensorvalue1 not declared in the scope.(sensorvalue1 is the user defined function)
.Help me guys pls

blynk.ino (1.8 KB)

Try moving the definitions of the functions sensorvalue1() etc. above the definition of setup().

If the file is a .ino file, the Arduino preprocessor normally creates the necessary prototypes so the order of declaration is irrelevant. Sometimes it doesn't.

6v6gt:
Try moving the definitions of the functions sensorvalue1() etc. above the definition of setup().

If the file is a .ino file, the Arduino preprocessor normally creates the necessary prototypes so the order of declaration is irrelevant. Sometimes it doesn't.

i did that,then they will say some other value is not in scope,no idea how to clear that.someone pls download attached code and find whats the problem,its a nodemcu a file oke.

This is a program for node mcu ,which fails to compile due to scope error.I am 99% sure program is correct,but not knowing how to adjust scope of functions and variable ,i am suffocating. Someone pls correct my program.I am wrking to correct itr for nearly 5 hour.just failed miserably.

blynk.ino (1.8 KB)

How is this different than your other post?

I am wrking to correct itr for nearly 5 hour

But you couldn't be bothered to post your code, or the error message?

ThottiKuttapan:
i did that,then they will say some other value is not in scope,no idea how to clear that.someone pls download attached code and find whats the problem,its a nodemcu a file oke.

Show your latest code which gave rise to this remarkably vague error message.

Which part is the one u dont understand??i have already attached my code and error image.there are several user defined functions which are interrelated in the program.So one of the remedies for out of scope error is defining functions over the setup() .But even after i did that they show secondVal is out of scope

Which part of "Don't post pictures of error messages, post error messages" don't you understand?

Sry my mistake,i just wanted to see if same error occurs in others ide while compiling my program,never mind,here is the error message

C:\Users\user\Desktop\blynk\blynk.ino: In function 'void setup()':

blynk:26: error: 'sensorvalue1' was not declared in this scope

timer.setInterval(1000L,sensorvalue1 );

^

blynk:27: error: 'sensorvalue2' was not declared in this scope

timer.setInterval(1000L,sensorvalue2 );

^

blynk:28: error: 'sensorvalue3' was not declared in this scope

timer.setInterval(1000L,sensorvalue3 );

^

C:\Users\user\Desktop\blynk\blynk.ino: In function 'void loop()':

blynk:43: error: expected unqualified-id before numeric constant

String 1 = getValue(myString, ',', 0);

^

blynk:44: error: expected unqualified-id before numeric constant

String 2 = getValue(myString, ',', 1);

^

blynk:45: error: expected unqualified-id before numeric constant

String 3 = getValue(myString, ',', 2);

^

blynk:46: error: expected unqualified-id before numeric constant

String 4 = getValue(myString, ',', 3);

^

blynk:48: error: 'l' was not declared in this scope

firstVal = l.toInt();

^

blynk:49: error: 'm' was not declared in this scope

secondVal = m.toInt();

^

blynk:50: error: 'n' was not declared in this scope

thirdVal = n.toInt();

^

blynk:51: error: 'o' was not declared in this scope

fourthVal = o.toInt();

^

Using library ESP8266WiFi at version 1.0 in folder: C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.2\libraries\ESP8266WiFi
Using library blynk-library-master at version 0.6.1 in folder: C:\Users\user\Documents\Arduino\libraries\blynk-library-master
Using library SoftwareSerial at version 1.0 in folder: C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.2\libraries\SoftwareSerial
Using library SimpleTimer-master in folder: C:\Users\user\Documents\Arduino\libraries\SimpleTimer-master (legacy)
exit status 1
'sensorvalue1' was not declared in this scope

      String 3 = getValue(myString, ',', 2);

etc.

Name me one language that allows variable names starting with of decimal digits.

That 99% estimate doesn't look good.

Actualy i am new at working with nodeMCU,And this code has been done and ran smoothly by a guy in a different version of arduino ide from me.So the code doesnt has errors i believe.

Hey changing variable names and other few tweaks worked.The program doesnt show errors now.Let me check the output

ThottiKuttapan:
.So the code doesnt has errors i believe.

The compiler disagrees, or you wouldn't be here

6v6gt:
Show your latest code which gave rise to this remarkably vague error message.

ThottiKuttapan:
Which part is the one u dont understand??i have already attached my code and error image.there are several user defined functions which are interrelated in the program.So one of the remedies for out of scope error is defining functions over the setup() .But even after i did that they show secondVal is out of scope

If you show the code with the changes, then it may be clear where the new error is. By the sound of it, you placed the definitions of those sensorvalueX functions above this statement:

int firstVal, secondVal, thirdVal, fourthVal;

If so, that was not a good idea. Directly above setup() may have been a better choice.

Okke thanks guys.It worked