# Simple First Analog Read

**URL:** <https://community.particle.io/t/simple-first-analog-read/40021>\
**Category:** Getting Started\
**Created:** [March 4, 2018, 4:13pm UTC](https://community.particle.io/t/simple-first-analog-read/40021 "2018-03-04T16:13:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![teppich](https://avatars.discourse-cdn.com/v4/letter/t/7c8e57/32.png) [@teppich](https://community.particle.io/u/teppich)\
**Post date:** [March 4, 2018, 4:13pm UTC](https://community.particle.io/t/simple-first-analog-read/40021/1 "2018-03-04T16:13:38Z")

</div>

Hi, I have a reed switch connected to a Photon. I want to read and publish the voltage of the circuit with the reed switch. here is a small extract of the code:

```
switchValue = analogRead(A7);
    Serial.println(switchValue);
Particle.publish("Value", String(switchValue));

```

This works, but when i goto the Particle Console to see the output I get:  
Event name “Value”. Which is correct  
Data as “Null” instead of the voltage readout between 0 and 4095

Any idea how i can actually see the output instead of Null?  
Thanks  
MGM

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [March 4, 2018, 4:39pm UTC](https://community.particle.io/t/simple-first-analog-read/40021/2 "2018-03-04T16:39:22Z")

</div>

> [@teppich](#):
>
> This works

So you do get sensible data over serial?  
Any chance we could see your entire code? Preferably shared with the share link from the web IDE.

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [March 4, 2018, 7:47pm UTC](https://community.particle.io/t/simple-first-analog-read/40021/3 "2018-03-04T19:47:22Z")

</div>

@teppich, how is your read switch connected (power, pin)?

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [March 4, 2018, 8:15pm UTC](https://community.particle.io/t/simple-first-analog-read/40021/4 "2018-03-04T20:15:09Z")

</div>

Why use `analogRead()` and not `digitalRead()` for a reed switch?  
You may also want to publish the event as `PRIVATE`
