Suggestions on multiplexing two sensor values

Status
Not open for further replies.

garlinto

Member
I would like to tap into the wealth of knowledge here and ask a question related to my current teensy project.

I have installed a pneumatically actuated dog door that for now is operated by a Sonoff relay using a virtual assistant. But my end goal is to use BLE and iBeacons to not only ID my dogs but to determine when to open/close the door based on their proximity to the door (RSSI). So to achieve this, I am using a T3.x with an XBee3 and an ext antenna. The system works great and is sensitive to the iBeacons.

My question is about the best way to mux the RSSI values together. For example, and to simplify the use case:
  • One beacon near, ignore all others and OPEN
  • No beacons with RSSI below threshold or undetectable: CLOSE

On the surface this seems simple, but I'm trying to find a good balance between these two states. Ideally, I think the execution of the opened/closed state should be weighted toward leaving the door open to prevent pinches, etc.

Any suggestions on an algorithm that is common in a scenario like this? I could go the infrared/ultrasonic route like the automatic doors at your favorite grocery store, but I like the simplicity of one central wireless sensing mechanism instead of installing two physical sensors, the wiring, etc.
 
Not quite clear what you want to do but if I am understanding the design goal correctly, does using https://www.pjrc.com/teensy/td_timing_elaspedMillis.html
work?

Define a 'timeSinceLastTagSeen' timer

In the loop:
Check each beacon in turn, if proximate to door, open door if closed and reset timer to 0
Once all beacons checked, if door is open and timer has reached a reasonable value then close door.

It can also be worth having a 'doorInMotion' timer that puts the other logic on hold while the mechanical parts of the door are in motion to reduce race conditions, though for a pnumatic door with sensors that would not be necessary.
 
Define a 'timeSinceLastTagSeen' timer

In the loop:
Check each beacon in turn, if proximate to door, open door if closed and reset timer to 0
Once all beacons checked, if door is open and timer has reached a reasonable value then close door.

GremlinWrangler, thank you for the suggestion. I use elapsedMillis in nearly every sketch I write. But I had not used it for a door-open interval as you suggest. I'll add that logic to the code.
 
Status
Not open for further replies.
Back
Top