Read analog pin on Graph bar via push

Hello,

Im trying to analogRead (A0) - for instance-, but graph refreshing time is 1 sec for analog pins. There is any way to make it realtime (live) or to use push option (converting analog pin to a virtual pin). If so, what would be the code?

Thank you so much.

We don’t teach programming here… but we can direct you to the Documents, Help Center and Sketch Builder (Links all at the top right of this page… scroll up if you don’t see them.

for example…

Meanwhile, here is some of the relevant commands needed, with your widget set to PUSH

http://docs.blynk.cc/#blynk-firmware-virtual-pins-control-blynkvirtualwritevpin-value

Blynk.virtualWrite(vPin, analogRead(pin));

Don’t put that command in the void loop(), use a timer…

http://docs.blynk.cc/#blynk-firmware-blynktimer

1 Like

thanks

Shows up an error, i have downloaded all the drivers.

prueba_emg_plot_ios:10: error: 'BlynkTimer' does not name a type
 BlynkTimer timer;
 ^
/Users/yow/Documents/Arduino/prueba_emg_plot_ios/prueba_emg_plot_ios.ino: In function 'void myTimerEvent()':
prueba_emg_plot_ios:17: error: 'sensorData' was not declared in this scope
   sensorData = analogRead(A0);
   ^
/Users/yow/Documents/Arduino/prueba_emg_plot_ios/prueba_emg_plot_ios.ino: In function 'void setup()':
prueba_emg_plot_ios:32: error: 'timer' was not declared in this scope
   timer.setInterval(1000L, myTimerEvent);
   ^
/Users/yow/Documents/Arduino/prueba_emg_plot_ios/prueba_emg_plot_ios.ino: In function 'void loop()':
prueba_emg_plot_ios:38: error: 'timer' was not declared in this scope
   timer.run(); // Initiates BlynkTimer
   ^
exit status 1
'BlynkTimer' does not name a type

here is my code.

#define BLYNK_PRINT Serial1

#include <BlynkSimpleStream.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = “YourAuthToken”;

BlynkTimer timer;

// This function sends Arduino’s up time every second to Virtual Pin (5).
// In the app, Widget’s reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
sensorData = analogRead(A0);
Blynk.virtualWrite(V5, sensorData);
}

void setup()
{
// Debug console
Serial1.begin(9600);

// Blynk will work through Serial
// Do not read or write this serial manually in your sketch
Serial.begin(9600);
Blynk.begin(Serial, auth);

// Setup a function to be called every second
timer.setInterval(1000L, myTimerEvent);
}

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

The error suggests different. Make sure you have latest version of Blynk Library v0.5.0.

Yes, updated Blank Library, but a new error comes up: (same code as before)

sketch_jan04b:7: error: stray ‘\342’ in program
char auth[] = “c27f5f4c412643fc9e4XXXXXX”;
^
sketch_jan04b:7: error: stray ‘\200’ in program
sketch_jan04b:7: error: stray ‘\234’ in program
sketch_jan04b:7: error: stray ‘\342’ in program
sketch_jan04b:7: error: stray ‘\200’ in program
sketch_jan04b:7: error: stray ‘\235’ in program
sketch_jan04b:7: error: ‘c27f5f4c412643fc9e4XXXXXX’ was not declared in this scope
char auth[] = “c27f5f4c412643fc9e4XXXXXX”;
^
/Users/yow/Documents/Arduino/sketch_jan04b/sketch_jan04b.ino: In function ‘void myTimerEvent()’:
sketch_jan04b:16: error: ‘sensorData’ was not declared in this scope
sensorData = analogRead(A0);
^
exit status 1
stray ‘\342’ in program

thank you for your time

Google these errors to see if you can determine their relevance in the syntax of your skript

Also Google this part of the error… it basically means you haven’t “declared” this “variable” or whatever the js equivalent of those terms are :wink:

This is all “how to program 101”, and not really Blynk specific, and you will keep running into similar issues/solutions as get more familiar with the whole syntax of the programming language.

Find a good online course or “How To” for NodeJS.