# How to read the previous state of the pins after restart or deploy on raspberry

**URL:** <https://discourse.nodered.org/t/how-to-read-the-previous-state-of-the-pins-after-restart-or-deploy-on-raspberry/21196>\
**Category:** General\
**Created:** [3 February 2020 12:45 UTC](https://discourse.nodered.org/t/how-to-read-the-previous-state-of-the-pins-after-restart-or-deploy-on-raspberry/21196 "2020-02-03T12:45:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![devifast](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@devifast](https://discourse.nodered.org/u/devifast)\
**Post date:** [3 February 2020 12:45 UTC](https://discourse.nodered.org/t/how-to-read-the-previous-state-of-the-pins-after-restart-or-deploy-on-raspberry/21196/1 "2020-02-03T12:45:45Z")

</div>

After deploy output pin change state. Why?  
How to make sure this doesn't happen

 ![Untitled1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/1/a10ed95dc9c945f5559aad6c3a53b1cc88c4e243.png)  
After deploy. ![Untitled2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/a/5aa94beb12b96ddd70fe158b981d57c13b90a2ea.png)

```auto
[{"id":"7bbf6c01.b26624","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"407a809e.71686","type":"rpi-gpio in","z":"7bbf6c01.b26624","name":"","pin":"37","intype":"up","debounce":"25","read":false,"x":140,"y":140,"wires":[["384d8adf.464636"]]},{"id":"5efa9c17.e96944","type":"rpi-gpio in","z":"7bbf6c01.b26624","name":"","pin":"35","intype":"up","debounce":"25","read":false,"x":140,"y":200,"wires":[["384d8adf.464636"]]},{"id":"db5c91e3.4380c","type":"function","z":"7bbf6c01.b26624","name":"","func":"if (msg.payload[\"pi/35\"] == 1 && msg.payload[\"pi/37\"] == 1){\nmsg.payload = 1;\nreturn msg;\n}\nelse{\n msg.payload = 0;\nreturn msg;\n}\n\n ","outputs":1,"noerr":0,"x":490,"y":140,"wires":[["8c2e7942.8a9ef8","943f9a00.b4e478"]]},{"id":"8c2e7942.8a9ef8","type":"debug","z":"7bbf6c01.b26624","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":650,"y":140,"wires":[]},{"id":"384d8adf.464636","type":"join","z":"7bbf6c01.b26624","name":"test","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"1","reduceInitType":"num","reduceFixup":"","x":330,"y":140,"wires":[["11365f4b.9ab771","db5c91e3.4380c"]]},{"id":"11365f4b.9ab771","type":"debug","z":"7bbf6c01.b26624","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":410,"y":220,"wires":[]},{"id":"943f9a00.b4e478","type":"rpi-gpio out","z":"7bbf6c01.b26624","name":"","pin":"33","set":true,"level":"0","freq":"","out":"out","x":640,"y":180,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 February 2020 12:54 UTC](https://discourse.nodered.org/t/how-to-read-the-previous-state-of-the-pins-after-restart-or-deploy-on-raspberry/21196/2 "2020-02-03T12:54:46Z")

</div>

you have set the out pin to set itself to 0 - so it has done as you asked...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/8/588afe0cd2ce633419a5d944f8a0dcf70e07f549.png)

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 February 2020 12:57 UTC](https://discourse.nodered.org/t/how-to-read-the-previous-state-of-the-pins-after-restart-or-deploy-on-raspberry/21196/3 "2020-02-03T12:57:50Z")

</div>

And on the input side you haven't told the pins to do an initial read... so they haven't...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/8/083aa7ca2713360ee4c98d4bfdafc84ce83f0027.png)

---

<div class="post-metadata">

**Author:** ![devifast](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@devifast](https://discourse.nodered.org/u/devifast)\
**Post date:** [3 February 2020 13:41 UTC](https://discourse.nodered.org/t/how-to-read-the-previous-state-of-the-pins-after-restart-or-deploy-on-raspberry/21196/4 "2020-02-03T13:41:43Z")

</div>

After deploy, condition in a function is not true  
input pins is 1 but output pin is 0.  
diference between pics.  
differentiation between pics.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [3 February 2020 13:49 UTC](https://discourse.nodered.org/t/how-to-read-the-previous-state-of-the-pins-after-restart-or-deploy-on-raspberry/21196/5 "2020-02-03T13:49:34Z")

</div>

In the `GPIO-out` node, you initialize the pin to '0'.

![Screen Shot 2020-02-03 at 8.48.59 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/8/18a94268e8963a17ee7afa7290a725a4bff7f700.png)  
Untill you pass some msg's thru the flow, that is what it till be.

---

<div class="post-metadata">

**Author:** ![devifast](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@devifast](https://discourse.nodered.org/u/devifast)\
**Post date:** [4 February 2020 04:43 UTC](https://discourse.nodered.org/t/how-to-read-the-previous-state-of-the-pins-after-restart-or-deploy-on-raspberry/21196/6 "2020-02-04T04:43:59Z")

</div>

Read initial state of pin on deploy/restart?  
No one to read this !!! Thanks.  
I fill checkbox before Read initial state of pin on deploy/restart? and everything is ok.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [18 February 2020 04:44 UTC](https://discourse.nodered.org/t/how-to-read-the-previous-state-of-the-pins-after-restart-or-deploy-on-raspberry/21196/7 "2020-02-18T04:44:02Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
