HTTP read GPIO input?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
GMaster1
New user
Posts: 2
Joined: 11 Jan 2016, 06:01

HTTP read GPIO input?

#1 Post by GMaster1 » 11 Jan 2016, 06:08

Heya,

I've spent quite a bit of time browsing this forum and everything online -- trying to solve the opposite of:

http://<ESP IP address>/control?cmd=GPIO,<pin>,0

It is pretty easy to SET via simple HTTP, but is there anything in place to GET/Read data from a pin?

My end goal (as one other person on this site posted back in November) is to read data from a ds18b20 or see the status of a GPIO (1/0)

This is all for an ESP 201 currently running the EasyESP firmware.

Thanks!

Martinus

Re: HTTP read GPIO input?

#2 Post by Martinus » 11 Jan 2016, 19:20

I'm experimenting with a simple json interface to retrieve data from the ESP sensors (actually from tasks).

Could become available with the next build and may look like this:

Code: Select all

{"Sensors":[
{
"TaskName": "PME",
"test": 3.30
},
{
"TaskName": "BMP Demo",
"Temperature": 20.06,
"Pressure": 981.87
},
{
"TaskName": "Lux sensor demo",
"Lux": 2.50
}
]}

GMaster1
New user
Posts: 2
Joined: 11 Jan 2016, 06:01

Re: HTTP read GPIO input?

#3 Post by GMaster1 » 11 Jan 2016, 20:21

That would be amazing and thanks for the reply! Most little IoT things I've been working with thus far offers me at least some type of 'curl' simple output ability so I was absolutely in love with these 201 chips when I saw the HTTP commands but yeah the last piece to the puzzle is data the other direction via some JSON type utility.

I showed up late to the party regarding these chips but assume the EasyESP firmware is the best way to go as far as the most functionality without use of arduino/pi/etc?

DA-Makes
Normal user
Posts: 12
Joined: 01 Jun 2016, 12:32

Re: HTTP read GPIO input?

#4 Post by DA-Makes » 01 Jun 2016, 12:37

I know I am late to the party, but I'm about to convert some sonoff's to run ESP Easy and this feature would be excellent to use. Did it ever get added and if so which version do I need?

Tjeerd
Normal user
Posts: 16
Joined: 06 Jun 2016, 11:54

Re: HTTP read GPIO input?

#5 Post by Tjeerd » 06 Jun 2016, 12:02

Hello DA_Makers,

I have a sonoff and i have connected it trough the wifi whit domoticz
I can send form domoticz a "http://<ESP IP address>/control?cmd=GPIO,12,1" to switch the light on and a "http://<ESP IP address>/control?cmd=GPIO,12,0" to switch it off again.

so i think the function works.

I use version R78 on my sonoff's

DA-Makes
Normal user
Posts: 12
Joined: 01 Jun 2016, 12:32

Re: HTTP read GPIO input?

#6 Post by DA-Makes » 06 Jun 2016, 12:10

Tjeerd wrote:Hello DA_Makers,

I have a sonoff and i have connected it trough the wifi whit domoticz
I can send form domoticz a "http://<ESP IP address>/control?cmd=GPIO,12,1" to switch the light on and a "http://<ESP IP address>/control?cmd=GPIO,12,0" to switch it off again.

so i think the function works.

I use version R78 on my sonoff's
Thanks - but are you able to read the status like the other post was suggesting with a GET request?

Tjeerd
Normal user
Posts: 16
Joined: 06 Jun 2016, 11:54

Re: HTTP read GPIO input?

#7 Post by Tjeerd » 06 Jun 2016, 12:30

Well,

I see that in domoticz the lightbulb changes when im sending an on or off message (when sending the command not using domoticz).
So i think the sonoff is sending his state to Domoticz.

Futher i have attached a DHT22 tem/hum sensor to GPIO14 of the sonof and domoticz reads (get the data puched) the tempeture.

I dont know if this answers your question?

DA-Makes
Normal user
Posts: 12
Joined: 01 Jun 2016, 12:32

Re: HTTP read GPIO input?

#8 Post by DA-Makes » 06 Jun 2016, 12:54

Tjeerd wrote:Well,

I see that in domoticz the lightbulb changes when im sending an on or off message (when sending the command not using domoticz).
So i think the sonoff is sending his state to Domoticz.

Futher i have attached a DHT22 tem/hum sensor to GPIO14 of the sonof and domoticz reads (get the data puched) the tempeture.

I dont know if this answers your question?

Hi. The question was around having a json interface to retrieve state so I don't think this interface is related.

User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Re: HTTP read GPIO input?

#9 Post by costo » 07 Jun 2016, 14:00

DA-Makes wrote:I know I am late to the party, but I'm about to convert some sonoff's to run ESP Easy and this feature would be excellent to use. Did it ever get added and if so which version do I need?
I don't think there is a GET_command to read the state of an output but you can use events and rules (only available on R86 and higher) to synchronize the relais_state and the LED_state on the Sonoff with Domoticz.
Search the forum for [rules + relais] and you will find the way how to synchronize the sonoff with Domoticz.

It will be something like this:

Code: Select all

on switchon do
  gpio 12,1
  gpio 13,0
  inputswitchstate 0,1
endon

on switchoff do
  gpio 12,0
  gpio 13,1
  inputswitchstate 0,0
endon

on Switch1#Switch do
  if [Switch1#Switch]=1
    event switchon
  else
    event switchoff
  endif
endon
In ESPEasy the relais is called Switch1 on GPIO-0
In Domoticz the commands to control the sonoff relais are :
http://192.168.178.104/control?cmd=event,switchon
http://192.168.178.104/control?cmd=event,switchoff

DA-Makes
Normal user
Posts: 12
Joined: 01 Jun 2016, 12:32

Re: HTTP read GPIO input?

#10 Post by DA-Makes » 07 Jun 2016, 15:15

costo wrote:
DA-Makes wrote:I know I am late to the party, but I'm about to convert some sonoff's to run ESP Easy and this feature would be excellent to use. Did it ever get added and if so which version do I need?
I don't think there is a GET_command to read the state of an output but you can use events and rules (only available on R86 and higher) to synchronize the relais_state and the LED_state on the Sonoff with Domoticz.
Search the forum for [rules + relais] and you will find the way how to synchronize the sonoff with Domoticz.

It will be something like this:

Code: Select all

on switchon do
  gpio 12,1
  gpio 13,0
  inputswitchstate 0,1
endon

on switchoff do
  gpio 12,0
  gpio 13,1
  inputswitchstate 0,0
endon

on Switch1#Switch do
  if [Switch1#Switch]=1
    event switchon
  else
    event switchoff
  endif
endon
In ESPEasy the relais is called Switch1 on GPIO-0
In Domoticz the commands to control the sonoff relais are :
http://192.168.178.104/control?cmd=event,switchon
http://192.168.178.104/control?cmd=event,switchoff

I don't have Domoticz (or want it) and was hoping that the suggestion from GMaster1 above had been added as direct JSON get requests would have been very useful.

User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Re: HTTP read GPIO input?

#11 Post by costo » 07 Jun 2016, 15:29

It does not need to be Domoticz to control your sonoff relais.
As long as your controlling server can fire the command: "IPofYourESPEasy/control?cmd=event,switchon" or switchoff it will work

DA-Makes
Normal user
Posts: 12
Joined: 01 Jun 2016, 12:32

Re: HTTP read GPIO input?

#12 Post by DA-Makes » 07 Jun 2016, 15:34

costo wrote:It does not need to be Domoticz to control your sonoff relais.
As long as your controlling server can fire the command: "IPofYourESPEasy/control?cmd=event,switchon" or switchoff it will work

I was looking for a way to query the sonoff for its current state as per the post from GMaster1 asking if he can make a JSON get request against the sonoff.

User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Re: HTTP read GPIO input?

#13 Post by costo » 07 Jun 2016, 17:07

DA-Makes wrote: I was looking for a way to query the sonoff for its current state as per the post from GMaster1 asking if he can make a JSON get request against the sonoff.
To my knowledge, there is no command to read the state of an output in ESPEasy.

dduley
Normal user
Posts: 93
Joined: 06 Feb 2016, 17:56

Re: HTTP read GPIO input?

#14 Post by dduley » 07 Jun 2016, 18:56

costo wrote:
DA-Makes wrote: I was looking for a way to query the sonoff for its current state as per the post from GMaster1 asking if he can make a JSON get request against the sonoff.
To my knowledge, there is no command to read the state of an output in ESPEasy.
Sure there is!!

See: http://www.esp8266.nu/forum/viewtopic.php?f=4&t=1431


Regards

Dave

DA-Makes
Normal user
Posts: 12
Joined: 01 Jun 2016, 12:32

Re: HTTP read GPIO input?

#15 Post by DA-Makes » 08 Jun 2016, 08:29

dduley wrote:
costo wrote:
DA-Makes wrote: I was looking for a way to query the sonoff for its current state as per the post from GMaster1 asking if he can make a JSON get request against the sonoff.
To my knowledge, there is no command to read the state of an output in ESPEasy.
Sure there is!!

See: http://www.esp8266.nu/forum/viewtopic.php?f=4&t=1431


Regards

Dave
Thanks but this isn't quite the same thing, I wanted to be able to check state from non ESP devices. The JSON get that was discussed at the beginning of this thread would have been perfect.

Post Reply

Who is online

Users browsing this forum: No registered users and 46 guests