Want to attach pass...
 
Notifications
Clear all

Want to attach passive infrared motion sensor (HC SR501, 5V) to my Sonoff Basic (3.3V)

20 Posts
6 Users
0 Reactions
2,831 Views
jBo
 jBo
(@jbo)
Member
Joined: 4 years ago
Posts: 102
Topic starter  

Hi All,

I've been watching Dronebot Workshop for several years now, and have really benefited from this great channel. I'm new to the Forums. I have a question on a project I've started.

The project is wiring up Sonoff Basic relays and controlling some lamps. I'm starting simple, flashing the ESP-8266 with Tasmota, for increased local control and security. (Thanks, Bill, for videos on ESP-Cam and ESP-32 family). These work fine; I then grouped them together using Home Assistant running on a Pi 4.

The result is a nice display for several switches. My next thought is to drill a small hole and attach an inexpensive motion sensor, in order to gain a sense of presence. That is, someone is in the room, let's make a note of it, maybe do something.

What makes me think I can do this? Well, I was looking at The Hookup and found

Add a door sensor to any door with a Sonoff basic:

 

So, I don't want a door sensor (reed switch), at least not yet. But my idea is that a reed switch is still just a one-bit input to the Home Assistant software, so in that sense it's just like a passive infrared sensor.

 

I see a problem, though. The HC-SR501 runs on 5V, near as I can tell. Inside the Sonoff, the ESP-8266 board runs on 3.3V. This is where I attached the 4-pin header to enable flashing the new software, plus there is another set of little round solder spots, "pads?" marked Gnd, 3V3 and so on.

 

Thanks for reading this far. OK, here is my question:

Would the 3V3 output from the ESP-8266 be enough to power the HC-SR501? Should I just try it and see if it works?

 

By the way, I have watched the PIR video on this channel several times, and repeated Bill's experiments, both from the Arduino and from the Raspberry Pi. They worked, which is why I'm encouraged.

 

Anyway, what do you think? Does my idea make any sense?

 

Thanks very much,

John B.

 

 

 

In theory, theory and practice are the same.
In practice, they're different.


   
Quote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@jbo

Posted by: @jbo

Thanks for reading this far. OK, here is my question:

Would the 3V3 output from the ESP-8266 be enough to power the HC-SR501? Should I just try it and see if it works?

Is there a reason to challenge the datasheet?

If the datasheet calls for 5v, then I would give it 5v 😉

Cheers.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2045
 

@jbo

Would the 3V3 output from the ESP-8266 be enough to power the HC-SR501? Should I just try it and see if it works?

 

https://iot-playground.com/blog/2-uncategorised/42-esp8266-wifi-pir-motion-sensor-arduino-ide

 

 


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@robotbuilder

The video you posted via the link shows it being powered by 5v.

What are you implying?

 


   
ReplyQuote
(@dronebot-workshop)
Workshop Guru Admin
Joined: 5 years ago
Posts: 1104
 

@frogandtoad 

The point that I believe @robotbuilder was implying is in the Connections section of that article:

Power supply for ESP8266 is max 3.6V and PIR sensor is powered by 5V. If you check datasheet for PIR sensor you will see that internally is powered by 3.3V (see 3.3 regulator).

The point is that (a) it uses 3.3-volt logic so it's fine to use with the ESP-8266 and (b) it requires a 5-volt power supply and has an internal 3.3-volt regulator.

@jbo if you want to power the sensor with 3.3-volts then you'll need to either remove or bypass that internal 3.3-volt regulator (ie. connect pin 3 of the connector to the output pin of IC1).  Keep in mind that your 3.3-volt supply needs to have enough current to power the PIR sensor, you might need an additional filter capacitor as well.

Or you could just run it on 5-volts and use your own regulator to provide 3.3-volts to the ESP-8266, which personally is how I would build it.

😎

Bill

 

 

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
ReplyQuote
frogandtoad
(@frogandtoad)
Member
Joined: 5 years ago
Posts: 1458
 

@dronebot-workshop

Posted by: @dronebot-workshop

The point that I believe @robotbuilder was implying is in the Connections section of that article:

Indeed, I assumed as much and did highlight that as well, but without an associated comment I wasn't sure.  Aside from seeing it in the schematic, it's also shown on the breadboard using a duel rail power supply board.

Cheers.


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1136
 

@dronebot-workshop

apart from the consideration of the power requirements for the pir sensor is the consideration whether the pir sensor would act as a switch as descibed in the video.  The video shows that a switch (a reed switch in this instance) grounding the GPIO 14 pin at 3.3v will means the sonoff triggers the mains relay.    Now although you could ground the PIR sensors signal pin when it goes high, the GPIO 14 pin would not be grounded, but still supplying the pir sensor at 3.3 volts (assuming that the power input to the pir had been modified to bypass the 5v input as you indicate would be necessary)

So it appears to me that this would not work, but I'm still dabbling with electronics and I'm not confident that this is correct.  I would be interested to see what you conclude about this.


   
ReplyQuote
ZoolanderMicro
(@zoolandermicro)
Member
Joined: 4 years ago
Posts: 144
 

When someone enters the room, have it play Hooray for Captain Spalding (Animal Crackers).

ZoolanderMicro, where small ideas are a big deal


   
ReplyQuote
(@dronebot-workshop)
Workshop Guru Admin
Joined: 5 years ago
Posts: 1104
 

Perhaps a simpler solution would be to use a PIR sensor like this one that can run on 3.3-volts.

😎

Bill

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
ReplyQuote
jBo
 jBo
(@jbo)
Member
Joined: 4 years ago
Posts: 102
Topic starter  

@frogandtoad - You're right, of course. The

Should I just try it and see if it works?

was kind of a throwaway line. Sorry. What I really meant was that I'm at the level of following tutorials as exactly as possible. I have seen videos where the voltage supplied may be a little shy of the component's specs, but may work for some use cases. I would prefer to just supply 5V, but I don't seem to have it on this Sonoff board.

 

In theory, theory and practice are the same.
In practice, they're different.


   
ReplyQuote
jBo
 jBo
(@jbo)
Member
Joined: 4 years ago
Posts: 102
Topic starter  

@robotbuilder - Yeah, that is pretty close to what I'm intending, replacing Easy IoT Server with Home Assistant. But the concept is the same.

One thing I've appreciated about the various videos, especially Dronebot Workshop, is seeing the difference between examples or experiments, versus final project implementations.

@dronebot-workshop This really helps; it clarifies what the concepts are, and helps me get familiar with new (to me) industry terminology and names of components and modules.

So, the experiment with the ESP-8266 and Easy IoT Server looks great. They saved the packaging into a project enclosure or whatever for another video, which is fine. My enclosure skills are pretty much beginner level; frankly, all my skills are beginner, so that's great! Every day I learn something, and the only way is up.

So that's part of why I like the Sonoffs. I'm doing the experiments, but here's something I can actually put into use. (I have maybe a dozen or so around the house). I do want to beef up my mechanical skills and get more practice with power supplies and buck/boost converters, but for now, the Sonoffs have 1) a nice little box, and 2) a power supply cleanly separate from mains power.

 

In theory, theory and practice are the same.
In practice, they're different.


   
ReplyQuote
jBo
 jBo
(@jbo)
Member
Joined: 4 years ago
Posts: 102
Topic starter  

@dronebot-workshop - Yes, thank you for this input.

Or you could just run it on 5-volts and use your own regulator to provide 3.3-volts to the ESP-8266, which personally is how I would build it.

This may be the route I take. And I will definitely do it in "experiment" mode, with the board extracted, and supplying 3.3V via my FTDI programmer, and 5V . . . with another FTDI programmer, with jumpers set for 5V.

If that's as far as I get, I've still learned a lot. I'm just saying I want to get comfortable with these other connections before I put the board back in its original case and power it with mains power.

(For any other newbies following along, Sonoff Basic is a 10 amp relay packaged so you can make your own smart extension cord, using HTTP and/or MQTT). The article I need to review is:

Powering Your Electronics Projects – Voltage Regulators and Converters

Thanks again,

John

In theory, theory and practice are the same.
In practice, they're different.


   
ReplyQuote
(@dronebot-workshop)
Workshop Guru Admin
Joined: 5 years ago
Posts: 1104
 

@jbo

And Thank You for bringing the Sonoff Basic to my attention! I think I'll pick up a few of those, they look like something I could experiment with.

😎

Bill

"Never trust a computer you can’t throw out a window." — Steve Wozniak


   
ReplyQuote
jBo
 jBo
(@jbo)
Member
Joined: 4 years ago
Posts: 102
Topic starter  
Posted by: @byron

So it appears to me that this would not work . . .

Hi Byron,

Yes, I definitely see your point. And the device performs perfectly well in its "one trick" configuration. But there are additional pins available, and the idea is to separate out the main function (the relay) from other possible uses, like sensors. I am pulling together ideas from several different places, and it's quite possible I bit off more than I can chew  😯  - I will see if I can find that article.

Sonoff Basic R2

This is more in the way of official documentation than tutorial, but I have seen videos putting this into practice.

As long as I'm in confessional mode, I heard "everyone" on various videos calling the chip ESP-8266. I purchased the R2 version recently, and now I read in that same article:

The new version of the Sonoff Basic smart switch uses an ESP8285 SoC with the 1MB flash integrated into the same SoC chip.

. . . but in my defense, I believe the 8285 chip is close enough to the 8266, and besides, I'm dealing with the whole package, the board and whatever pins or pads it has available.

OK, so that's the physical and electronic part of it. Next, the software. As I see it, Tasmota is just built from the start to accommodate using any of the available pins for any of Tasmota's software functions. That is, if I can find a connection to GPIO 14, say, then I can have it reported as a sensor, momentary switch, toggle switch, etc. (see screen shot)

2020 12 10 145535 664x641 scrot

In theory, theory and practice are the same.
In practice, they're different.


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1136
 
Posted by: @dronebot-workshop

And Thank You for bringing the Sonoff Basic to my attention

You might also like to look at the shelly1

Cant have too many of these gadgets 😎 


   
ReplyQuote
Page 1 / 2