Arduino uno analog A0 voltage measurement error with virtual pins


I am using an Arduino Uno to measure analog voltage using this arduino widget code copied from the widget posting

#define VIRTUAL_PIN =.000488759(V1)*
// Virtual Pin of the widget2
#define VIRTUAL_PIN =.00488759(V2)*
void loop()

I am using only an arduino uno and raspberry pi3

The multiplier (.0048875 = 5 /1024) is for arduino analog measurements is to convert the input value to volts for a 5 V system.
As well note that value reads the same for V1 and V2 on the widget dashboard despite the number of zeroes in the multiplier.
FYI my arduino is connected with a USB cable to my laptop. and compiles code just fine.

Please advise how to fix this…


Hello, can you try with this approach:

#define VIRTUAL_PIN V1
#define VIRTUAL_PIN V2

setup; loops and etc.
  Cayenne.virtualWrite(V1, YOUR_DATA*000488759); //virtual pin
  Cayenne.virtualWrite(V2, YOUR_DATA*00488759); //virtual pin


LIsted below is what I tried, and the output result is exactly the same
despite the different multiplier variables for V1 and V2.
If you hook both inputs to the the 5V pin the widget output reads 1023.
There is something else wrong with the widget code.
I am using a dial indicator for the display.

#include <CayenneSerial.h>

// Cayenne authentication token. This should be obtained from the Cayenne
char token[] = “qjtdwnqpsq”;

void setup()
//Baud rate can be specified by calling Cayenne.begin(token, 9600);

#define CAYENNE_PRINT Serial // Comment this out to disable prints and
save space

float input0 = analogRead(A0);
float input1 = analogRead(A1);

Cayenne.virtualWrite(V1, input0*(.00049)); //virtual pin1

Cayenne.virtualWrite(V2, input1*(.0049)); //virtual pin2

void loop()


Okey. Can you try just with one Analog Input measurement and can you use this approach:
void loop {
int input0 = analogRead(A0);
float voltage = input0 * (5.0 / 1023.0);

and then send the value to the widget ?


I tried this but it will not compile.


I’m doing the same thing with analog reads. @tad.dvor wrote this for me. Just remove what you don’t need.


I am not having any luck with your code, sorry Wmontg5988

I do not understand the syntax and variable declarations, so I will have to
read up on that.

For example why semicolon? Why pound sign?

I understand the idea of constantly calling variables in a loop to obtain
updated readings, but I do not understand when to call the Cayenne
functions as I have not found any explanation of what they are…Should
they always be called inside the loop to update?

Is there any explanation of the Cayenne functions and how variables are
passed? By value or address or pointer?
I did find the conversion code for a 5 V system analog voltage measurement
in the standard arduino tutorial libraries so that helped.
Thanks for your patience.


Send me the error that you have compiling your code.


Semicolon just ends a line of code, and pound comments a line of code (it is not executed)

Cayenne functions only need to be called to send data to the server or receive data from the server.; should be called as often as possible.

Right now Cayenne will only accept numerical values. It uses customized Blynk libraries to send and receive the data.

Hopefully that answers everything for you, let me know if that doesn’t make sense.