Hey guys, can u all help me what's the problem here? esp8266 with Blynk

it shows this error message
'temperatures' was not declared in this scope

#define BLYNK_TEMPLATE_ID ""
#define BLYNK_DEVICE_NAME ""
#define BLYNK_AUTH_TOKEN "";

#include <Arduino.h>
#include <EEPROM.h>
#include "GravityTDS.h"
#include <OneWire.h>
#include <DallasTemperature.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth = "";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid = "";
char pass = "";
SimpleTimer timer;

#define ONE_WIRE_BUS 7 // Digitalpin where Temp sensor is connected
#define TdsSensorPin A0 // Where Analog pin of TDS sensor is connected to A0 of nodemcu

OneWire oneWire(ONE_WIRE_BUS);
GravityTDS gravityTds;

DallasTemperature sensors(&oneWire);

float tdsValue = 0;

void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
sensors.begin();
gravityTds.setPin(TdsSensorPin);
gravityTds.setAref(5.0); //reference voltage on ADC, default 5.0V from NodeMCU
gravityTds.setAdcRange(1024); //1024 for 10bit ADC;4096 for 12bit ADC
gravityTds.begin(); //initialization
timer.setInterval(1000L,MainFunction);
}

void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
}

void MainFunction()
{
sensors.requestTemperatures();
gravityTds.setTemperature(sensors.getTempCByIndex(0)); // grab the temperature from sensor and execute temperature compensation
gravityTds.update(); //calculation done here from gravity library
tdsValue = gravityTds.getTdsValue(); // then get the TDS value

Serial.print("TDS value is:");
Serial.print(tdsValue,0);
Serial.println("ppm");
Serial.print("Temperature is: ");
Serial.print(sensors.getTempCByIndex(0));

// Sensor Values to Blynk application
temperature = sensors.getTempCByIndex(0); //it show this line have error for temperature
Blynk.virtualWrite(V2, temperature);
Blynk.virtualWrite(V3, tdsValue);

}

Are you sure about that error message?

Please remember to use code tags when posting code

(I'm with the compiler on this one - I can't see where it is defined either)

hi, I don't understand what you mean for Im sure about the error message. But it show the line that temperature does not declare. this is the first time i use esp8266 connect with tds and temperature sensor and send data to Blynk.

The error message you quoted says "temperatures", but the undefined variable is "temperature", according to the code you posted.

That's why I asked.

It's possible you posted the wrong error message, or the wrong code.

float temperature = sensors.getTempCByIndex(0); 

i copy that code from another website and i dont know whats wrong with the code, Cuz this is the first time i try this type of code and i tried compile in the Arduino compiler, it show the error message and i dont know how to fix it.

image

I posted a possible fix in reply #4, but for future reference, the IDE has a "copy error messages" control for when things go tango uniform - please use it.

Yes, as I suspected, the code you posted originally doesn't match the error message you posted.

This is confusing. Please don't do that again - it wastes time.

Please don't post pictures, post code. In code tags.

This is the original code

#define BLYNK_TEMPLATE_ID ""
#define BLYNK_DEVICE_NAME ""
#define BLYNK_AUTH_TOKEN "";

#include <Arduino.h>
#include <EEPROM.h>
#include "GravityTDS.h"
#include <OneWire.h>
#include <DallasTemperature.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth = "";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid = "";
char pass = "";
SimpleTimer timer;

#define ONE_WIRE_BUS 7 // Digitalpin where Temp sensor is connected
#define TdsSensorPin A0 // Where Analog pin of TDS sensor is connected to A0 of nodemcu

OneWire oneWire(ONE_WIRE_BUS);
GravityTDS gravityTds;

DallasTemperature sensors(&oneWire);

float tdsValue = 0;

void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
sensors.begin();
gravityTds.setPin(TdsSensorPin);
gravityTds.setAref(5.0); //reference voltage on ADC, default 5.0V from NodeMCU
gravityTds.setAdcRange(1024); //1024 for 10bit ADC;4096 for 12bit ADC
gravityTds.begin(); //initialization
timer.setInterval(1000L,MainFunction);
}

void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
}

void MainFunction()
{
sensors.requestTemperatures();
gravityTds.setTemperature(sensors.getTempCByIndex(0)); // grab the temperature from sensor and execute temperature compensation
gravityTds.update(); //calculation done here from gravity library
tdsValue = gravityTds.getTdsValue(); // then get the TDS value

Serial.print("TDS value is:");
Serial.print(tdsValue,0);
Serial.println("ppm");
Serial.print("Temperature is: ");
Serial.print(sensors.getTempCByIndex(0));

// Sensor Values to Blynk application
temperature = sensors.getTempCByIndex(0); 
Blynk.virtualWrite(V2, temperature);
Blynk.virtualWrite(V3, tdsValue);

}

I've tried your solution, but still not fix it

Look again at reply #4

Doesn't look like it. Otherwise the line that gives the error would look like the one in post #4. Or you changed it back because you're convinced #4 was wrong. You never know these days.