I ended up adding a second resistor after R1 and measuring the voltage between R1 and the new resistor. Turns out it’s either 0 or 3.33 V which is perfect for my application. I don’t think it screws up the alarm system (which I’m not using anyhow).
But now to figure out how to use this programmatically(!). The value for the voltage seems to be jumping all over the place, and I can’t make out why.
I have the wire connected to A0 and nothing else is connected except the mini-USB powering the device.
My code:
int analogPin = A0;
int val = 0;
void setup() {}
void loop()
{
val = analogRead(analogPin); // read the analogPin
Spark.publish("Voltage", String(val));
delay(2000);
}
And some example output from the terminal. (TL;DR: the “voltage” variable is jumping all over the place.)
event: Voltage
data: {"data":"110","ttl":60,"published_at":"2017-07-24T02:45:20.487Z","coreid":"54ff72066672524841241267"}
event: Voltage
data: {"data":"3831","ttl":60,"published_at":"2017-07-24T02:45:22.493Z","coreid":"54ff72066672524841241267"}
event: Voltage
data: {"data":"2125","ttl":60,"published_at":"2017-07-24T02:45:24.499Z","coreid":"54ff72066672524841241267"}
event: Voltage
data: {"data":"140","ttl":60,"published_at":"2017-07-24T02:45:26.503Z","coreid":"54ff72066672524841241267"}
event: Voltage
data: {"data":"3882","ttl":60,"published_at":"2017-07-24T02:45:28.512Z","coreid":"54ff72066672524841241267"}
event: Voltage
data: {"data":"2042","ttl":60,"published_at":"2017-07-24T02:45:30.514Z","coreid":"54ff72066672524841241267"}
event: Voltage
data: {"data":"91","ttl":60,"published_at":"2017-07-24T02:45:32.518Z","coreid":"54ff72066672524841241267"}
Now I verified that the voltage isn’t infact jumping all over the place with my multimeter. I physically touched A0 and GND and it is only changing between something like 1.67 and 1.68 (or something similar) with my multimeter set to VDC.
What have I done wrong? Many thanks!