-
-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GPIO output feature #355
Comments
Actually there is a pin command to set a output pin remotely. If you are using relais, there are some modules available that have much too less insulation distance for 230V, double check before using. |
I have some more information in my wiki: I still strongly recommend NOT using the Gateway GPIO but just get another ESP board with Tasmota etc for relay functions. For instance this Wemos relay shield is the most dangerous thing you can use: The GPIO line is about 1mm away from main voltage. If it makes contact, you WILL blow up the Gateway and the EMS bus. |
@MichaelDvP I was able to build an automation in HA that lights the LED on GPIO12 of my raspberry if (btw: your idea in #324:
sounds very interesting - but I think, this would requires some major changes to ems-esp so that I suppose thats not very likely to see that getting implemented) Meanwhile I tried to experiment with the pin command, but unluckily I failed with that. so I tried different variations like: but still after several hours I didn't succeed with that. (security authentication was disabled in the settings while I tested). I'd be very happy if someone could give me an full example for the correct command (preferably with and without the use of the authentication token) @MichaelDvP @bbqkees: thanks for your warnings and safety hints. I fully agree, that someone, who is not certified to work with higher voltages should never experiment with such things (and especially not with that sort of dangerous relay-shields without optocouplers and proper insulation or reliable ems-protection). |
With the latest API changes all commands that can set something are supposed to be done via a HTTP POST or PUT. The Wemos relay shield is 'shocking' figuratively but also in real life. |
@marc1de The v3 api is POST with url |
Isn't GPIO36 only for digital input, not output, as they don't have any push/pull resistors? worth checking... |
Yes, io36 is input only, and io25 is DAC output, it needs value 255 to set it high. I've tested with io19 and it works. |
aargh, so in fact, my problems were mostly related to a wrong choice of Pins! @proddy: you're right: Pin 36 is input only. That was a typo in my post. In fact I used Pin 25 and 26 for my test's. I now found some other sources that pointed out, which ports should be avoided: GPIO: 34,35,36,39: only Inputs, no Pullups so that leaves only GPIO 16,17,19,21,22,32,33 free for safe use. after changing to Pin 19 (32 and 33 are also verified) I was able to set the values via URL (api-V2) .... and after correcting the script in HA it also worked. but maybe I'll give it a try to check out the api-v3-Method as Michael suggested. Thanks @ALL for your great help!!! (but still would be happy, if the OUTPUT-feature could be implemented in the code, so that the values could be set in the web-ui of ems-esp - or even better: if some of the GPIO's could be connected directly with some of the (binary-)entities in the web-ui so that they can act as StatusLEDS's without needing an other program) eg: LED1 - internal StatusLED for EMS-ESP LEDx - Boiler/Thermostat critical Error (ok, the last one will be difficult, because there is no defined Errorstatus, so it will probably neccessary to set this status in an external Program (eg: if statuscode = xxx or xxy or xxz set LED on) |
We'll mention the pins in the wiki/doc - good to point that out. |
nearly all right, ADC2 is used for Wifi, but the pins can be used
i think safe to use is:
I think if i enhance the analog config to digital output, i can also add DAC and PWM channel 0,1,2.
|
added. https://emsesp.github.io/docs/#/Configure-firmware?id=adding-external-sensors |
Can we add a big warning notice in the wiki and a permanent warning notice in EMS-ESP for this feature? We need to keep in mind that the circuit board is also directly connected to the EMS bus of expensive boilers and very expensive heat pumps. Most users are of course not electrical engineers and thus lack thorough knowledge of electronics. In the next revision of the S32 there will be some additional protection but I can build in as much protection as I want, there will always be better fools out there. Aside from the risk of blowing stuff up, some electronics will also introduce noise or other disturbances into the system. The more features we enable, the more people will use those features. We need to stay aware of the consequences. |
after the last update to v3.4.0b6 my scripts for changing the DigitalOutputs didn't work any more. According to your last update in the docs (commit 3d3bfe0) I tried this (and several similar varitions) in the mqtt-explorer: but that didn't work: Same problems occured with the browser-commands. I tried: but also failed! as a suggestion: I think, the provided information is very difficult to understand for "non-programmers". Maybe it would be easier, if you could add some more examples in the docs for this commands. ... and a second suggestion: I think the name"analogsensor" is meanwhile a little bit misleading in case of "digital In/Outputs, Counters or PWM's". Maybe "gpio" is a better term that covers all the possible cases (including the analogsensors). |
You're right, mqtt does not work due to missing subscriptions. I'll add them for dallassensor and analogsensor. For api you have to use the v2 OR v3 api, you can not combine the syntax. |
Make sure you have the bearer token with POSTs as in the example. I just tested and it works with rest_command:
emsesp_set_gpio39_on:
url: http://ems-esp.local/api/analogsensor/setvalue
method: POST
headers:
authorization: "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkkWluIiwiYWRtaW4iOnRydWV9.2bHpWya2C7Q12WjNUBD6_7N3RCD7CMl-EGhyQVzFdDg"
content_type: "application/json"
payload: '{"id":39,"value":1}' Note., I created a Digital Out on GPIO 39 in EMS-ESP |
@proddy: But now I found the reason for the fault: (never thought, that this could be the problem, since that was never needed before. I can usualy reach the gateway with http://ems-esp or http://ems-esp.local) |
ah great! EMS-ESP starts a multicast DNS server (mDNS) which itself uses the .local domain prefix. Unless you added an entry in your router you can always resort to .local. Also if you turn off authentication in the settings you won't need the Bearer token for POSTs. It's only there to add a little more security. |
@proddy, @MichaelDvP, [Fault Description:]
After a reset of ems-esp everything worked fine again. But while investigating the situation, I noticed two remarkable things.
The second remarkable point was:
[Hardware description]
Result:
again "freezing" of ems-esp! it was still sending data via mqtt but no ping to ems-esp and webinterface was not reachable! |
@proddy, @MichaelDvP Again having the same issue again yesterday and last night, I did some experiments and finally found the reason for the "partial freezing". I found out, that I was still able to change the digitalOutputs in this "freezing-state" via mqtt but not with the restful ApiV3-commands, After some more experiments I found, that the problem was related to DNS! After changing my scripts to the IP instead of dns-names the script worked again. Summary:
it worked again (without reset of ems-esp). I have no clue, why the dns-entry gets outdated and I am a little bit confused, why the mqtt-command: |
ok, so EMS-ESP wasn't crashing, the router was just losing the cache of the mdns entries. I've read the native MDNS can be a bit flakey on the ESP32. If this problem persists I'll look into an alternative like https://github.com/khoih-prog/MDNS_Generic |
@proddy
|
Best if we create a new issue for this and close this one (related to GPIOs). I looked the MDNS code again and compared to Tasmota and esphome and its similar so I'm not convinced its a s/w issue. But I'll try the same as you and check with the DNS service can resolve the ems-esp.local in a cron job. |
I've tested this and it seems the mDNS is broken after a network reconnect. To reproduce simply go to network settings and click |
genius! didn't think of that. @MichaelDvP feel free to push a change direct to the repo |
closing this issue, as it was implemented in 3.4 |
Did you ever think about adding GPIO-output capabilities?
Thought, this might be a great feature to:
The text was updated successfully, but these errors were encountered: