extra IO with PIR or distance snsor

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
rudloffl
Normal user
Posts: 43
Joined: 04 Jul 2019, 07:17

extra IO with PIR or distance snsor

#1 Post by rudloffl » 18 Jul 2019, 05:18

Hello to all,

Is it possible to use an IO extension (Via i2c) and connect to it distance sensors or PIRs ?

I would like to automate my garage door and might be short on IOs for my requirement:
- 2 distance sensors (2 IO each)
- 1 PIR would be great (an other IO)
- 2 relays (those will be on an IO extension either way)
- Temperature (can also be done via i2c)

It's most likely possible to fit everything on the esp8266, but I think IO extension can offer more flexibility (and other sensors :-)).

Any idea ?

Thanks

Laurent

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: extra IO with PIR or distance snsor

#2 Post by enesbcs » 18 Jul 2019, 20:44

rudloffl wrote: 18 Jul 2019, 05:18 Hello to all,

Is it possible to use an IO extension (Via i2c) and connect to it distance sensors or PIRs ?

I would like to automate my garage door and might be short on IOs for my requirement:
- 2 distance sensors (2 IO each)
- 1 PIR would be great (an other IO)
- 2 relays (those will be on an IO extension either way)
- Temperature (can also be done via i2c)

It's most likely possible to fit everything on the esp8266, but I think IO extension can offer more flexibility (and other sensors :-)).

Any idea ?

Thanks

Laurent
GPIO-4 and GPIO-5 is used as I2C.
I am currently using an MCP23017 with 2 pieces of SR-501 PIR as input, 1 pc door open sensor as input and 1 pin as output with an SSR relay.
I've disabled serial and redefined gpio-3 as output for a buzzer as an extra GPIO. (as rtttl command is not meant for MCP)
GPIO13 is used for RCWL radar sensor, as it did not want to work on the MCP.
Distance sensor is added to GPIO14 and GPIO12 as it needs real GPIO pins.
And there are no more freely usable pins left.

You can use for example:
GPIO-12,GPIO-13,GPIO-14, GPIO-3 for 2 distance sensors (disable serial first and use GPIO-3 as a trigger pin)
GPIO-4&GPIO-5 for I2C to MCP23017 and HTU21D or other I2C temp sensor
1 PIR onto the MCP23017
2 relays onto the MCP23017 (it has to be tested before finalizing, as MCP output can be 25mA/pin and 150mA max)

rudloffl
Normal user
Posts: 43
Joined: 04 Jul 2019, 07:17

Re: extra IO with PIR or distance snsor

#3 Post by rudloffl » 20 Jul 2019, 15:29

Thanks for your feedback. I will work on a proof of concept

waspie
Normal user
Posts: 127
Joined: 09 Feb 2017, 19:35

Re: extra IO with PIR or distance snsor

#4 Post by waspie » 22 Jul 2019, 03:57

I run a similar setup for my garage. My 2 door openers have reed switches at each end of the rail. I'm only really concerned with the ones at the "closed" end of the rail. I use an MCP23017 expander for additional inputs.
I have a voltage divider that takes the 9v to about 3v and run those into the mcp for my open/closed state of the two doors.

I have two HC-SR04 ultrasonic sensors that determine if that bays are occupied. I use two outputs of the MCP to two transistors that "push" the buttons.

Two additional inputs to the MCP through more voltage dividers tell me if something crosses either of the two IR "beams" so I can flip lights on if its dark. I have a board all designed up to do that including a few other features including a dallas temp sensor input. I have spare boards left over that I could send you if these I/Os sound about right for what you want.

Do you use EasyEDA?
20190721_215857 (1).jpg
20190721_215857 (1).jpg (897 KiB) Viewed 13381 times

rudloffl
Normal user
Posts: 43
Joined: 04 Jul 2019, 07:17

Re: extra IO with PIR or distance snsor

#5 Post by rudloffl » 25 Jul 2019, 04:52

I have to put that project on hold for now (Sprinkler is the priority, the grass is not getting any greener...)

I have never heard of easyEDA, I will play with it

rudloffl
Normal user
Posts: 43
Joined: 04 Jul 2019, 07:17

Re: extra IO with PIR or distance snsor

#6 Post by rudloffl » 20 Aug 2019, 05:56

I'm back to that project !

Here where I am:
- 2 distance sensors directly on the esp
- 1 PCF8574 for 2 relays (both are OK and functional) and 1 for a PIR and a door sensor (those are less ok...)

Here are my questions:
- How do I monitor a PCF port ? What I tried below does not work?
- Is the monitor function compatible with PCF8574 ? Or should I go to a different GPIO extender ?
- Is it possible to use the PCF8574 for inputs (door + pir) and output (relays)

Any help will be appreciated.

Thanks

Code tried:

Code: Select all

on System#Boot do
 Monitor,PCFGPIO,2
Monitor,PCFGPIO,3
endon

 on pcfGPIO#2=1 do
  if [Plugin#pcfGPIO#Pinstate#1]=1
tasksetrun,3,1,1
  endif
 endon

 on pcfGPIO#3=1 do
  if [Plugin#pcfGPIO#Pinstate#3]=1
tasksetrun,3,1,1
  endif
 endon

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: extra IO with PIR or distance snsor

#7 Post by enesbcs » 20 Aug 2019, 09:05

rudloffl wrote: 20 Aug 2019, 05:56 - How do I monitor a PCF port ? What I tried below does not work?
Why do not you create separeted tasks for every function?
See wiki:
https://www.letscontrolit.com/wiki/index.php/PCF8574
rudloffl wrote: 20 Aug 2019, 05:56 - Is it possible to use the PCF8574 for inputs (door + pir) and output (relays)
If you create a task that will be input as default, if you want to use it an output, you do not need to create a new task, but use PCFGPIO,<pin>,<value> command, also in the wiki:
https://www.letscontrolit.com/wiki/index.php/PCF8574

rudloffl
Normal user
Posts: 43
Joined: 04 Jul 2019, 07:17

Re: extra IO with PIR or distance snsor

#8 Post by rudloffl » 21 Aug 2019, 05:12

Indeed...
I have been overthinking...

Just for my curiosity, is it possible to monitor a PCF8574 like described here ? https://espeasy.readthedocs.io/en/lates ... Rules.html

Code: Select all

on System#Boot do
 Monitor GPIO,15
endon

 on GPIO#15=0 do
  if [Plugin#GPIO#Pinstate#13]=0
   // do something
  endif
 endon

 on GPIO#15=1 do
  if [Plugin#GPIO#Pinstate#13]=1
   // do something
  endif
 endon

Post Reply

Who is online

Users browsing this forum: No registered users and 39 guests