PIR in 3.3V and ESP8266-01

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
engberg
Normal user
Posts: 11
Joined: 21 Feb 2017, 16:42

PIR in 3.3V and ESP8266-01

#1 Post by engberg » 21 Feb 2017, 16:53

Hi

So I'm new..

I'd like to make a wifi motion sensor.
I want to power it this way:
https://www.youtube.com/watch?v=j21CMZ6Lrfc

and use this feature to make it go on 3.3V
https://www.youtube.com/watch?v=5jhTQAV-hg0

And then I want it connected to my Domoticz server.

- only, I'm blank as to how I'll connect the PIR with the ESP.. And do I need extras? Resistors or such?

I think I can figure out the programming part.

I hope someone will take the time to help a newbie..

NietGiftig
Normal user
Posts: 103
Joined: 16 Sep 2015, 20:32

Re: PIR in 3.3V and ESP8266-01

#2 Post by NietGiftig » 21 Feb 2017, 18:13

I have my PIR's powered with 5v with the + & - from the ESP..
The output goes directly to an ESP input pin.
The usual pirs have a onboard 3.3 voltage converter.
As far as I know is the output level of the PIR 3.3v

I do not fiddle with all kinds of esp's or voltage converters
Just use a Wemos D1 mini with a cheap 5v phone power adapter, in the end much quicker and more reliable
Works in my install for > 6 month's with EspEasy & Domoticz
Have you read the wiki?

Shardan
Normal user
Posts: 1122
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: PIR in 3.3V and ESP8266-01

#3 Post by Shardan » 21 Feb 2017, 19:14

Hello,

Internally this PIR HC-SR501 sensor works with 3,3 V as the ESP does, it uses it's own on board voltage regulator.
So it's no problem to connect the output pin of the sensor to a GPIO of the ESP, no need for resistors and such.
Using a ESP-01 I'd prefer to use GPIO-2.

Generally i'd say using the 3,3V from the ESP works but it isn't best practice.

You need a voltage regulator for the ESP-01 anyways to get 3,3 V.

I'd prefer a LF-33 CV for the ESP, use a small heatsink if necessary, then you may use 5...12 V for power supply.
As said the HC-SR501 PIR sensor has it's own voltage regulator. According to datasheet it can be powered with 5....20 V.
So i'd use a 5...12 Volt power supply to power the PIR and the regulator for the ESP.
This gives separated 3,3V lines for ESP and PIR, resulting in better stability.
There is no more additional stuff or expense, it's just a different wiring.

As said the sensor uses 3,3V internally anyways so this doesn't give any issues with connecting the PIR to the ESP.

Regards
Shardan
Regards
Shardan

engberg
Normal user
Posts: 11
Joined: 21 Feb 2017, 16:42

Re: PIR in 3.3V and ESP8266-01

#4 Post by engberg » 21 Feb 2017, 20:28

I did read the wiki, but didn't find much about wiring in it..

So let me se if I get this right..

I split the usb 5V wires, so one pair goes to PIR and one pair goes like in the powersupply video I linked.

And then I connect the GPIO-2 on the ESP to the output of the PIR - and that's it?

I've tried to draw it - is that about right?

http://pasteboard.co/B7iVU8Xrq.jpg
Last edited by engberg on 21 Feb 2017, 22:09, edited 1 time in total.

Shardan
Normal user
Posts: 1122
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: PIR in 3.3V and ESP8266-01

#5 Post by Shardan » 21 Feb 2017, 21:21

Hello,
Sorry i don't see the Image.

But basically that is right.

+5V to the PIR and the voltage regulator as shown in the video.
Output from the PIR to GPIO-2
and don't forget ground! Ground should be connected to the ESP ground.

Regards
Shardan
Regards
Shardan

engberg
Normal user
Posts: 11
Joined: 21 Feb 2017, 16:42

Re: PIR in 3.3V and ESP8266-01

#6 Post by engberg » 21 Feb 2017, 22:23

Thanx for all the help so far !

You can't see the image by clicking the link?

http://pasteboard.co/B7iVU8Xrq.jpg

Well the ground to ground.. is that neccessery, when both are connected to gnd from the usb / regulator, like in the picture?

Just stumpled upon this USB pinout, that I'll have to use also..:

https://www.moddiy.com/product_images/u ... or-usb.jpg

Shardan
Normal user
Posts: 1122
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: PIR in 3.3V and ESP8266-01

#7 Post by Shardan » 21 Feb 2017, 22:49

Hello,
you may connect to the USB-Ground either, that should be OK.
A 5V power supply (wall plug) might be easier to handle and avoids risk of damaging the USB of your computer... ;)

The wiring seems ok to me.

Regards
Shardan
Regards
Shardan

engberg
Normal user
Posts: 11
Joined: 21 Feb 2017, 16:42

Re: PIR in 3.3V and ESP8266-01

#8 Post by engberg » 21 Feb 2017, 23:01

Yes, absolutely on the power supply.

Going for an old Ipad-charger.. :P

Now I just have to wait for the TTL-module and the capasitor to ship to me, so that I can get started!

Justblair
Normal user
Posts: 63
Joined: 08 Aug 2016, 23:42

Re: PIR in 3.3V and ESP8266-01

#9 Post by Justblair » 22 Feb 2017, 10:04

I am using a PIR module with a Sonoff wireless smart switch.

https://www.itead.cc/sonoff-wifi-wireless-switch.html

I modified the PIR module to bypass its 3.3v power regulator and then connected the PIR sensor to the 3.3v power header in the Sonoff switch.

Works very reliably in my kitchen switching my under unit and other spotlights. Love it. The sonoff is very reasonably priced, and basically gives you everything that you need to complete the project.

engberg
Normal user
Posts: 11
Joined: 21 Feb 2017, 16:42

Re: PIR in 3.3V and ESP8266-01

#10 Post by engberg » 22 Feb 2017, 16:06

Justblair>> Thanks for your input - I like the transparancy in this project for me.
Buying a Sonoff switch somehow defeats the purpose of this project to me.

But I might do it anyway, if my original idea fails ;-)

engberg
Normal user
Posts: 11
Joined: 21 Feb 2017, 16:42

Re: PIR in 3.3V and ESP8266-01

#11 Post by engberg » 24 Feb 2017, 17:55

So I'm just gonna document here..

Got my FTDI232 device and found drivers here:
http://www.ftdichip.com/Drivers/VCP.htm

Then connected the FTDI232 and the esp8266 this way:
http://iot-playground.com/blog/2-uncate ... are-update

And followed the flash instructions here:
http://www.letscontrolit.com/wiki/index ... are_Upload

I had to do it twice, before it worked..

engberg
Normal user
Posts: 11
Joined: 21 Feb 2017, 16:42

Re: PIR in 3.3V and ESP8266-01

#12 Post by engberg » 28 Feb 2017, 15:48

It only runs on standart power, if I connect both the VCC and the CH_PD to 3,3V

helio58
Normal user
Posts: 20
Joined: 11 Mar 2017, 10:21

Re: PIR in 3.3V and ESP8266-01

#13 Post by helio58 » 25 Mar 2017, 08:16

Hi Justblair please could you share your PIR Sonoff configuration and rules?
Thanks
Justblair wrote:
22 Feb 2017, 10:04
I am using a PIR module with a Sonoff wireless smart switch.

https://www.itead.cc/sonoff-wifi-wireless-switch.html

I modified the PIR module to bypass its 3.3v power regulator and then connected the PIR sensor to the 3.3v power header in the Sonoff switch.

Works very reliably in my kitchen switching my under unit and other spotlights. Love it. The sonoff is very reasonably priced, and basically gives you everything that you need to complete the project.

Justblair
Normal user
Posts: 63
Joined: 08 Aug 2016, 23:42

Re: PIR in 3.3V and ESP8266-01

#14 Post by Justblair » 27 Mar 2017, 13:03

espeasy.items

Code: Select all

Switch	kitchenPIR			"Kitchen Motion Sensor"	<kitchen>	(Sensor)		{ mqtt="<[broker:/KitchenMood/pir/Switch:command:ON:1],<[broker:/KitchenMood/pir/Switch:command:OFF:0]" }
Switch	kitchenDownlights	"Kitchen Lights" 	<light>	(lights,downstairs_lights,backroom_lights)	[ "Switchable" ]	{ mqtt=">[broker:/KitchenMood/gpio/12:command:ON:1],>[broker:/KitchenMood/gpio/12:command:OFF:0]" }
espeasy.rules

Code: Select all

var Number counter = 0
var Number lastCheck = 0

rule "kitchenLightOn"
    when   
            Item kitchenPIR changed from OFF to ON
    then   
            counter = counter + 1
            //sendCommand(br_x10_lamp, ON)
            sendCommand(kitchenDownlights, ON)
    end

rule "kitchenLightOff"
    when   
		Time cron "0 0/3   * * * ?"
    then   
            if(lastCheck == counter) {
                    counter = 0
                    lastCheck = -1;
                    //sendCommand(br_x10_lamp, OFF)
                    sendCommand(kitchenPIR, OFF)
                	sendCommand(kitchenDownlights, OFF)
            } else {
                    lastCheck = counter
            }
    end
    

On the Sonoff:
rule

Code: Select all

on pir#Switch do
    if [pir#Switch]=0
        gpio,13,1
    else
        gpio,13,0
    endif
endon
Task 1: System Uptime (not needed really)

Task 2:

Code: Select all

Device:	Switch input
Name:	pir
Delay:	0 (Optional for this device)
IDX / Var:	1
1st GPIO:	GPIO-12
Pull UP:	false
Inversed:	false
Switch Type:	switch
Switch Button Type:	Normal Swtch
Send Boot state:	false
Send Data:		true	
Global Sync:		false
Optional Settings	Value
Value Name 1:	Switch
Task 3:

Code: Select all

Device:	Switch input
Name:	status
Delay:	0 (Optional for this device)
IDX / Var:	5
1st GPIO:	GPIO-12
Pull UP:	false
Inversed:	false
Switch Type:	Switch
Switch Button Type:	Normal Switch
Send Boot state:	false
Send Data:		true
Global Sync:		false
Optional Settings	Value
Value Name 1:		Switch

helio58
Normal user
Posts: 20
Joined: 11 Mar 2017, 10:21

Re: PIR in 3.3V and ESP8266-01

#15 Post by helio58 » 27 Mar 2017, 14:23

Thanks

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 6 guests