Geek Time, Ep 1, The Gate

While back in California we were in the process of selling mom’s house.  However, there was an electric gate on the driveway and in order for real estate agents to show the house someone had to open the gate.  The gate has an electric motor that is activated with a simple keyfob.  Of course, you have to be within range of the gate in order for the keyfob to work (simple RF tech).  A lock box on the gate was not practical to hold the keyfob and house keys and no one was living in the house at the time to open the gate at a moments notice. So Tina, being the early riser, would take care of morning gate opening duties and I would usually close the gate each evening.  We were staying in an RV park nearby, but the daily hassle of getting to mom’s house each day, twice a day was wearing on us…

But wait, can’t technology save us?  Would a raspberry pi solve this problem?  Yes. Yes it could… and did!

Of course, for those non-geeks in the audience I am referring to a computer called a Raspberry Pi (not pie).  It is a wonderful little invention.  A full blown computer the size of a credit card (well almost).

Here is a picture of one of my current RPi’s.  I purchased 3 RPi’s several years ago and have used them in various projects.  Now I’m down to only two since the RPi I used in mom’s gate I left with the new home owner.  This picture is of a project I am finishing up for the Maine Forest and Logging Museum and will be featured in an upcoming episode of “Geek Time” ( I know, right!?  You can wait).   That means I’ll be down to a single, 4 year old RPi.  “Honey, I’m out of RPi’s can I buy a couple of new ones?”.  In this pic you also see a power supply and a USB thumb-drive plugged into the RPi…

 

 

 

The goal:  Get a non-internet connected gate motor to open and close at specific times of the day without anyone being present to push a button.  The gate is not in range of any Wifi and no way to hook it to the internet (at least within a reasonable cost) so there’ll be no remote/internet control either.

After doing a little internet research I was able to take parts and pieces of code and ideas from other people who used a RPi for similar projects and apply them to my own system.

Items and software needed (as I remember – this was 8 months ago):

  • Webserver/webhost
  • Captive portal
  • Wifi dongle
  • Relay switch
  • Power Supply
  • Cron job
  • Time Keeper software
  • odds and ends

 

 

Here’s the simple version.

  1. Find terminals on the gate motor circuit board that activate the gate simply by applying a small current (found circuit diagram online). Done
  2. Install Apache webserver on RPi to broadcast a webpage. Use captive portal to force clients to a single page. Done
  3. Write simple code to send 5V signal to GPIO on RPi board from button on webpage. Done (stolen from internet)
  4. Attach relay switch to GPIO pins. Pins send signal to relay switch which then sends power to gate circuit board, opening gate. Done
  5. Build simple webpage with a single button that when pressed sends signal to relay and thus opens/closes gate. Done
  6. Attach Rpi to board with 110V plug (power taken from gate motor), relay switch, and RPi power plug. Done
  7. Squeeze the whole mess into the gate motor enclosure trying not to break any terminals. Done
  8. Setup cron job to open gate each morning and close it again each evening.
  9. During power outage RPi loses it’s clock time, that can foul up a a schedule. So, installed nifty little app that stores time and resets clock to last known time on reboot.  If power out for only a few minutes clock is reset and only a few minutes off – close enough.  If it’s out for hours, you’d know about it and need to fix it. Done
  10. Test. Done.

The system worked great for about 3 months while the house was on the market.  I explained the system to the new owner who was completely bewildered.  I offered to remove it, but he wanted to keep it just in case he could find someone who knew what I was talking about.  A couple of months later I was talking to a neighbor and asked how my gate system was working, he said the new owner had completely broken the gate and motor, now they can’t even use their keyfobs, they’re opening the gate by hand… so sad…  🙁

Here’s the circuit board for the motor. The center green module with no wires is where I send the signal to open or close the gate.
On the backside of the motor is my mounting location for the RPi contraption. Not much space at all!

 

 

Here’s the final contraption that just barely fit into the motor housing.

In the above pic you see:

  • The blue relay switches ( I could only find a 4 pack unit, but I only used one of the switches).
  • 3 black wires connecting the appropriate GPIO pins to the relay board to activate the relay.
  • 2 black wires from the relay switch to the green module that plugs into the motor control circuit board.  When the relay is activated by the RPi it closes the circuit allowing electricity to pass from one terminal to the other on the motor circuit board and that causes the gate to open.  The relay only closes for a brief second then opens again, breaking the electricity flow, but that’s all it takes to activate the open/close function on the motor control board.
  • A standard 110V wall plug.  I stole power from the motor’s power supply to power my RPi and relay.
  • Not shown is the power plug that plugged into the outlet then plugged into the RPi for it’s power source.

I searched and searched my phones gallery for pictures of the web interface and the RPi contraption stuffed into the motor housing, but just can’t find them.  So you’ll have to trust me that it all worked and looked great!

I think I should make these and sell them online.  You all could be my first customers!  Yeah!  Who’s first to pre-order?

OK, time for me to get back on the tractor and haul some more logs around…