@henc if you open the link in the start post, you see the readme.
thanks
Good afternoon. For dumb people like me, can I make a step-by-step guide to changing the program to implement your option ??
@henc this is referred to in the github readme:
@madradrakie did you manage to fix youre problem … I have same one using HC-SR04 …
or anybody else … so i can trigger animation through the API but sensors wont start it, i have tested sensors on same pins with ESPhome and everything works …
thanks …
i’ve just made some changes to the code and now works as expected
https://youtu.be/AtkBV9D7CaU
test/Animated_Staircase.h at main · dinamicus/test · GitHub
can be turned on or off using by API
curl -X POST -H “Content-Type: application/json”
-d ‘{“staircase”:{“segment-first-last”:true,“brightnes-firstlast”:10}}’
xxx.xxx.xxx.xxx/json/state
Hi,
I’m running into some difficulties hope you guys can help me out.
Currently i have the following config.
#ifndef TOP_PIR_PIN
#define TOP_TRIGGER_PIN 32
#define TOP_ECHO_PIN 33
#endif
#ifndef BOTTOM_PIR_PIN
#define BOTTOM_TRIGGER_PIN 25
#define BOTTOM_ECHO_PIN 26
#endif
(The pir definitions commented out ofcourse)
If i compile my esp32 with just the ultrasonic for the bottom trigger/echo it works as expected (on detection)
If i try it with the api/json command however, it does return a success:true response, but nothing happens).
If i compile it with both the top and the bottom sensor. It just keeps ‘dark’.
For some reason the top pins conflict and breaks it down
My best guess is i’ve defined the wrong pins. But seems to me 32/33 should be fine.
I have a ESP-WR00M-32 dev kit module.
The sensors are both HC-SR04.
Any advice (in different gpio pins or other solution) is much appreciated.
Cheers
Sebastiaan
Since the usermod is now part of the official distribution of WLED, the README can now be found here: WLED/README.md at master · Aircoookie/WLED · GitHub
I still cant figure it out … so if I use only one HC-SR04 it works, but if I use two it does not …
so this doesn’t work:
#ifndef TOP_PIR_PIN #define TOP_TRIGGER_PIN 13 #define TOP_ECHO_PIN 12 #endif #ifndef BOTTOM_PIR_PIN #define BOTTOM_TRIGGER_PIN 4 #define BOTTOM_ECHO_PIN 5 #endif
but this silly compilation works (but of course only for one way ):
#ifndef TOP_PIR_PIN #define TOP_TRIGGER_PIN 4 #define TOP_ECHO_PIN 5 #endif #ifndef BOTTOM_PIR_PIN #define BOTTOM_TRIGGER_PIN 4 #define BOTTOM_ECHO_PIN 5 #endif
#ifndef TOP_PIR_PIN #define TOP_TRIGGER_PIN 13 #define TOP_ECHO_PIN 12 #endif #ifndef BOTTOM_PIR_PIN #define BOTTOM_TRIGGER_PIN 13 #define BOTTOM_ECHO_PIN 12 #endif
Have you commented the PIR section out completely in all examples? Hence, is WLED is looking for two HC-SR04’s now? Delete the #'s at the beginning of the links anyhow. You select PIRs with commenting the subsequent links in. If commenteer out, the setup will look for ultrasonic instead…
yes they are commented …
// Please change the pin numbering below to match your board.
// #define TOP_PIR_PIN
// #define BOTTOM_PIR_PIN
// Or uncumment and a pir and use an ultrasound HC-SR04 sensor,
// see README.md for details
#ifndef TOP_PIR_PIN
#define TOP_TRIGGER_PIN 13
#define TOP_ECHO_PIN 12
#endif
#ifndef BOTTOM_PIR_PIN
#define BOTTOM_TRIGGER_PIN 4
#define BOTTOM_ECHO_PIN 5
#endif
and I even try:
// #ifndef TOP_PIR_PIN
#define TOP_TRIGGER_PIN 13
#define TOP_ECHO_PIN 12
// #endif
// #ifndef BOTTOM_PIR_PIN
#define BOTTOM_TRIGGER_PIN 4
#define BOTTOM_ECHO_PIN 5
// #endif
It should be something like this:
// Please change the pin numbering below to match your board.
#define TOP_PIR_PIN 25
// #define BOTTOM_PIR_PIN
// Or uncumment and a pir and use an ultrasound HC-SR04 sensor,
// see README.md for details
#ifndef TOP_PIR_PIN
#define TOP_TRIGGER_PIN 13
#define TOP_ECHO_PIN 12
#endif
#ifndef BOTTOM_PIR_PIN
#define BOTTOM_TRIGGER_PIN 4
#define BOTTOM_ECHO_PIN 5
#endif
This example uses a PIR at the top at pin 25 and an ultrasonic at the bottom with trigger pin 4 and echo pin 5.
What board do you use?
In my case esp32 wroom-32 dev board i’ve had the same issue.
For some reason the pulseIn
method doesn’t register if called once.
If you edit Animated_Staircase.h look for the method ultrasoundRead
then add the following lines before `return pulseIn(echoPin, HIGH, maxTimeUs) > 0;
------- lines to add: -----
float duration; duration = pulseIn(echoPin, HIGH, maxTimeUs);
@Rolfje did you look into this issue already ?
you can also replace the complete method with the following:
bool ultrasoundRead(uint8_t signalPin,
uint8_t echoPin,
unsigned int maxTimeUs) {
digitalWrite(signalPin, HIGH);
delayMicroseconds(10);
digitalWrite(signalPin, LOW);
// duration only being calculated right if called twice…
float duration;
duration = pulseIn(echoPin, HIGH, maxTimeUs);
return pulseIn(echoPin, HIGH, maxTimeUs) > 0;
}
Just bear in mind that this isn’t a “production ready” fix… but at least both sensors work
@holdemblow: Not sure if you address your message to sergiocro, but his setup has a working ultrasonic sensor as he wrote in his initial post. We may have had similar reports for the WROOM32 board, surprising but we’ll have a look.
@pa1okz I was… and he also has the problem with 2 ultrasonic. And the solution i provided was for fixing a setup with 2 ultrasonic sensors
@holdemblow youre fix doesnt work for me (or it doesnt work for esp8266) now i get all leds on from start … later I can give a try with ESP32 …
It simply doesn’t work with two ultrasonics … cant find out why …
@sergiocro this “fix” was purely for esp32 board and probably even wroom32 specific.
I’ll try to setup a test env with an esp8266 tomorrow evening to find if i can replicate your situation.
@sergiocro We will look into it, it appears to be related to the ESP board type but have to dig a bit dieper to fix it
Hi all
Dunno if this is the best place to ask however I have a t junction staircase that goes left and right and then down. How easy would it be to modify the code to allow for another top ultrasonic sensor, I don’t mind paying someone a small fee if they are able to help as it will allow me to learn as well.
Thank you
Is anybody interested to test new implementation for this mode with ability to configure in GUI?