[SOLVED] Eventor nodemcu with analog pin

Hi friends.
is anyway to use eventor with analog pin on Nodemcu ? in eventor there is no analog pin selector.

You need to use virtual pins and coding with analogRead()

1 Like

I’m adding below code to my project but it’s wrong on compilig

BLYNK_READ(V5) //Blynk app has something on V5
{
  sensorData = analogRead(A0); //reading the sensor on A0
  Blynk.virtualWrite(V5, sensorData); //sending to Blynk
}

the full sketch

#include <SimpleTimer.h>           // Allows us to call functions without putting them in loop()

#define BLYNK_PRINT Serial         // Comment this out to disable prints and save space
#include <BlynkSimpleEsp8266.h> 

#include <OneWire.h>
#include <DallasTemperature.h> 
#define ONE_WIRE_BUS 2          // Your ESP8266 pin (ESP9266 GPIO 2 = WeMos D1 Mini pin D4)
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

char auth[] = "e926e5e00df34563a62ab2377f640732";
char ssid[] = "";
char pass[] = "10242048";
char server[] = "";

BLYNK_READ(V5) //Blynk app has something on V5
{
  sensorData = analogRead(A0); //reading the sensor on A0
  Blynk.virtualWrite(V5, sensorData); //sending to Blynk
}

SimpleTimer timer;

int roomTemperature;            // Room temperature in C

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

  while (Blynk.connect() == false) {
    // Wait until connected
  }

  sensors.begin();                        // Starts the DS18B20 sensor(s).
  sensors.setResolution(10);              // More on resolution: http://www.homautomation.org/2015/11/17/ds18b20-how-to-change-resolution-9101112-bits/

  timer.setInterval(2000L, sendTemps);    // Temperature sensor read interval. 2000 (ms) = 2 seconds.
}

// Notice how there is very little in the loop()? Blynk works best that way.
void loop()
{
  Blynk.run();
  timer.run();
}

// Notice how there are no delays in the function below? Blynk works best that way.
void sendTemps()
{
  sensors.requestTemperatures();                  // Polls the sensors.
  roomTemperature = sensors.getTempCByIndex(0);   // Stores temperature. Change to getTempCByIndex(0) for celcius.
  Blynk.virtualWrite(1, roomTemperature);         // Send temperature to Blynk app virtual pin 1.
}

You didn’t show the compile error, but you do need to assign this variable as an integer or something… standard “Arduino” Programming 101. https://www.arduino.cc/en/Reference/VariableDeclaration

int sensorData = analogRead(A0); //reading the sensor on A0
1 Like

Ok. I changed it to :slight_smile:

  inputVariable2 = analogRead(A0); //reading the sensor on A0
  Blynk.virtualWrite(V5, inputVariable2); //sending to Blynk 

the compiling error:

sketch_jul14a:19: error: 'inputVariable2' was not declared in this scope

   inputVariable2 = analogRead(A0); //reading the sensor on A0

You only changed the variable name and ignored the need to declare it (and I even gave you the correct answer in my previous post) :confounded:… Please read up on the Arduino site (link above) for programming tips and references… Teaching you how to program is NOT the scope of this forum!

Your OP question has been answered, so I am marking this topic as solved.

1 Like

Ok. I reading your link fully and adding the codes:

error is:

sketch_jul14a:54: error: ‘void A0()’ redeclared as different kind of symbol

void A0()

#include <SimpleTimer.h>           // Allows us to call functions without putting them in loop()

#define BLYNK_PRINT Serial         // Comment this out to disable prints and save space
#define analogPin A0
#include <BlynkSimpleEsp8266.h> 

#include <OneWire.h>
#include <DallasTemperature.h> 
#define ONE_WIRE_BUS 2          // Your ESP8266 pin (ESP9266 GPIO 2 = WeMos D1 Mini pin D4)
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

char auth[] = "e926e5e00df34563a62ab2377f640732";
char ssid[] = "";
char pass[] = "";
char server[] = "t";

SimpleTimer timer;

int roomTemperature;            // Room temperature in C
int analog = 0;

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

  while (Blynk.connect() == false) {
    // Wait until connected
  }

  sensors.begin();                        // Starts the DS18B20 sensor(s).
  sensors.setResolution(10);              // More on resolution: http://www.homautomation.org/2015/11/17/ds18b20-how-to-change-resolution-9101112-bits/

  timer.setInterval(2000L, sendTemps);    // Temperature sensor read interval. 2000 (ms) = 2 seconds.
  timer.setInterval(2000L, analog);    // Temperature sensor read interval. 2000 (ms) = 2 seconds.
}

// Notice how there is very little in the loop()? Blynk works best that way.
void loop()
{
  Blynk.run();
  timer.run();
}

// Notice how there are no delays in the function below? Blynk works best that way.
void sendTemps()
{
  sensors.requestTemperatures();                  // Polls the sensors.
  roomTemperature = sensors.getTempCByIndex(0);   // Stores temperature. Change to getTempCByIndex(0) for celcius.
  Blynk.virtualWrite(1, roomTemperature);         // Send temperature to Blynk app virtual pin 1.
}

void A0()
{
  analog= analogRead(analogPin);  // analog read on A0
  Blynk.virtualWrite(12, analog);  //displays analog data on V12
}

You can NOT use a pin designation as a void name… Please start reading the error messages and making some intelligent guesses as to their meaning. Even Googling the error message will often help.

Pleas refer any further NON Blynk, Arduino programming type, questions over on the Arduino Forum. Thank you. https://forum.arduino.cc/