Measure voltage with an analogic pin

Hello, im trying to measure voltage with an analogic pin, I modificated the code and i have this:

CAYENNE_OUT(VIRTUAL_CHANNEL4)
{
analogRead(SENSOR_PIN);

if(SENSOR_PIN == 0){
	Cayenne.virtualWrite(VIRTUAL_CHANNEL4, "0");
	}
if(SENSOR_PIN > 0){
	Cayenne.virtualWrite(VIRTUAL_CHANNEL4, "1");
	}

}

Cuz I wanna see a light icon if i have voltage and it works! But unfortunately when my arduino get refresh i get “0” again even if i have voltage yet, so the light icon get off

Could somebody help me?

i am not sure what your code is doing but it is wrong.

I don’t know what this part of the code is doing.

for this, you can send the data in the void setup. so that when the Arduino restart, it reads the latest analog data and send it.