Great, I still didn’t try the code yet but I checked it a bit, I saw that you are running a for loop over all the relays every time you receive a request from the browser.
I think you can just call Set_Relay_Status((RELAY_ID) unit, (RELAY_STATE) stat);
in checkcommand() function instead of calling switcher() and put the
Update_Relays_State(); call in the loop() it should work
I managed to control the relays individually using Amazon Alexa
I am planning to add a web server as well also Ota and Otahttp + public Ip sharing
Below is a demo for Alexa’s part
Atef, yep, noticed I could use the individual addressing at some point, but left it in. In the full version I have groups and some arrays defining clock times and such in conjunction with other elements. So the loop will undergo some expansion
Very glad it works, this unit will be a central switching unit obviously, which will connect to a nodemcu v3 and a raspberry for various purposes . If you have question or needs for something web related or php/mysql, javascript, linux; just send me a message and perhaps I can help out. Thanks again.
I guess that’s random and due maybe to the powering behavior could ba a missing pull down resistor on the latch pin but can you try to set all the relays to 0 during the setup function.
In my Alexa example I am reading the previous status from eeprom (stored before reset) and apply it to the relays and if there is no stored data I just set all to 0
Can you try it and let me know.
If it doesn’t work I would suggest if you have an oscilloscope try to observe the latch pin during boot also the shifter powering if latch changing while shift is powered then we will have this behavior
If software solution doesn’t work i think adding a pull down resistor may do the job.
The relay, which position I left on, comes back on after the setup post reset. (as do other relays I enable/disable)
But one caveat, the units left in ON state, I can not switch to OFF before I press ON again first.
So: all off > enable relays 4 (ON) > reset > relay 4 Comes back ON > unable to switch off unless I press ON relay 4 first.
Bonus caveat, if, after reset, I press a relay to to ON, which was not ON before reset, it works directly, BUT, the ones I had in ON state before reset, which came on after reset, suddenly go out again lol
So …
All off > relay 4 ON > reset > (4 comes back on) enable relay other then 4 (i.e. 5), 4 goes OFF and the selected relay comes on (i.e. 5).
Yep, made total sense to hehe
The other way around, seems to work, but could be part of the problem ofc. (switching OFF to ON)
I think it has something to do with the JS function and data exchange with the browser.
It would be better to use bidirectional exchange between the browser and the ESP.
For example, if you want one day to add another way to control the relays (button) you need to make sure that if the browser when open it has to be updated with the status of each relay.
And here I think the browser still thinks that the relay 4 is ON even after restart.
So maybe you need to automatically trigger the reload of the page on reset.
4 goes OFF and the selected relay comes on:
Yes makes sense because every time the shifter is loaded with all the relays status (16 bits)
if the update for relay 4 somehow got missed it will be done the next time another relay is updated (relay 5 in this case)
The current buttons work rather primitive, gives a command (switch) unit number and state.
Its a rather flat approach without feedback relating to their current state.
I will implement the push system for feedback on states and see if if makes a difference.
In my previous version I used uri encoder to transmit special characters (":" in my case), but in this newer version it gave weird results with the encoded string. I’ll look into this again to be sure it’s not causing interference.
I don’t think its due to the unit having missed a browser assignment, being processed after a reset, would be a bit obvious., as I am the one pressing the button, and if nothing happens and I reset, I should be able to reason, that it was my own action if a switch occurs but alas.
Here as well, I’ll look into excluding this as a potential cause.
Hi,
I have a page with toggle buttons as well, but I wanted the individual buttons working properly and reliable first, as my system is sort of a climate control system, it needs to work flawless when operational. The individual on off buttons were sort of a premise to the use of other functions switching stuff like heaters, fans, humidifier and extractors on or of based on a variety of sensor values.
Hoping to round up the reliability of switching today
EDIT:
After going through this thread one more time and ESPHome documentation I assume, for the 24 channel ESP-12F relay module I mentioned above the only significant change that need to be made to your config is the sr_count am I right?
sn74hc595:
- id: 'sn74hc595_hub'
data_pin: GPIO14
clock_pin: GPIO13
latch_pin: GPIO12
oe_pin: GPIO05
# Number of daisy-chained shift registers, up-to 256. Defaults to 1.
sr_count: 3 # <-- this ?
I am yet to receive the module. I’ll update the thread after testing with your code with modification for 24 channel.
Hi Christian,
I’m having trouble using a pin for a temperature sensor. The sensor does not register on the pins I used. Do you know how I can solve this?
Hello there, I might be a bit late, but have you managed to resolve this issue? I’m experiencing the exact same problem on my end. My esp8266 keeps freezing after leaving it unplugged for some time
Hi Matt,
The file that you’ve shared with the manual, code and utilities has been marked as a dangerous file for some reason where it’s being hosted by Mediafire. Is there any way you could make this available to us again through another link? I’m having a tricky time getting one of these to connect to ESPHome.