motion detection with ESP8266 And Cayenne dashboard

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello in this video we are going to learn how to make this cool motion sensor widget using cayenne dashboard to get started we are using a pir motion sensor aka passive infrared sensor which detects motion and an esp8266 any version would do not mcu esp32 yeah and three male to female jumper wires so now the vcc on the pir sensor is connected to my board on the 5 volt then the output pin is connected to d12 and i have the ground connected to the ground so in my dashboard now i have the mqtt username mqtt password and client id which you already know from the previous kind dashboard tutorials then i'm going to grab these values and put them into my code already i have connected my board to the wi-fi i also want to put in username from the dashboard mqtt password and um mqtt client now the next thing to do is to define this pir i'm gonna call it int pir then i'm gonna put it into d12 so i'm gonna also add another variable which is value which is kind of the one that's gonna you know receive the value from the pir sensor if the pin detects something it's gonna be high we're gonna put it into value if the pin is low means nothing has been detected we're going to put the value low into value then we're going to go into the void setup and mention that the pir is a sensor which means it's going to give us an input we're going to say do that by saying pin pin mode then specify that pir is an input pretty easy then i think that's all we're going to go down here notice i started this codes with the the basic for you know setting up a cayenne dashboard we're just only adding few things on how to handle apir then the thing we are going to do is we need to read the value from the pir sensor into the variable that we declared which is value that's why we're going to say value will read the d this is a digital sensor then the value will have the value of digital read then we're going to read the pir now we need to cut a judge if the pir sensor is high or low how are we going to do that we're just going to use an if condition and say if if value is equal to high then we're gonna do something that something is sending the value to the dashboard so i'm gonna use the function called cayenne dot virtual right then i'm gonna specify the channel i'm gonna use the channel one put in the value in this case the sensor is high which means it detected someone i'm gonna use high then i'm going to specify that it's a type digital sensor then the unit will be digital so now the the next thing to do is else this means in case now the sensor is low but sorry we need to delay here a little to kind of give the the sensor some time off you know warming up after something is detected i'm just putting on a thousand milliseconds which goes to one second then on else here we're gonna specify that we're going to tell the cayenne dashboard that now the sensor has detected nothing and we're going to say that by sending it a value of low same here we're going to delay a lot amount of time which is a thousand millisecond equals to one second then i think we're good to go if you go to the dashboard here you're gonna see that the dashboard is waiting for the ball to connect which means if we upload this correctly these values will start you know going into the cayenne dashboard then let's hit upload hopefully it'll work uploading uploading uploading takes some times but boom how hot no errors now let's go to the dashboard and see if anything changed you can see that in the dashboard we already have something you know we have something but we need to make our own we need to go to add device add new add widget scroll down a little and choose custom widget i'm going to go ahead and choose motion i'm gonna call it motion detector go down and i'm gonna choose digital sensor unit zero and one because high and low then the channel that we specified is one then the boom add widget after i add my widget you can see that now the motion is off but as as i'm talking i'm moving so if something tries to move around around the sensor you're gonna see that we have a kind of reaction on the widget now ladies and gentlemen this is the cayenne dashboard motion sensor if you want to ask something please write in the comment and until next time guys see you then bye
Info
Channel: Idukunda Lengo
Views: 184
Rating: undefined out of 5
Keywords:
Id: 6h91XTPg020
Channel Id: undefined
Length: 6min 54sec (414 seconds)
Published: Sun Apr 11 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.