Reading GPIO value

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
craicfinder
New user
Posts: 6
Joined: 04 Oct 2019, 23:49

Reading GPIO value

#1 Post by craicfinder » 04 Oct 2019, 23:56

Hi there,

I am setting the behaviour for a magnetic sensor to check if a door is closed. GPIO04 is set as input.

This is my code:

Code: Select all

on System#Boot do
 Monitor GPIO,4
endon

on GPIO#4 do
 Publish,home/garage/maindoor,%eventvalue%
endon

on MQTT#Connected do
  Publish,home/garage/maindoor,[GPIO#4]
endon
MQTT#Connected event is very important as it sets the first value, but [GPIO#4] returns blank... I googled everywhere and seems like that is the right syntax... I'm really confused, could you please guys give me a hand? why it doesn't work?

Regards,

craicfinder
New user
Posts: 6
Joined: 04 Oct 2019, 23:49

Re: Reading GPIO value

#2 Post by craicfinder » 05 Oct 2019, 00:28

Just found the way, the right code is:

Code: Select all

on System#Boot do
 Monitor GPIO,4
endon

on GPIO#4 do
 Publish,home/garage/maindoor,%eventvalue%
endon

on MQTT#Connected do
  Publish,home/garage/maindoor,[Plugin#GPIO#Pinstate#4]
endon

Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests