Author Topic: Marina Control System & Nerve Center  (Read 3192 times)

HeneryH

  • Full Member
  • ***
  • Posts: 229
Marina Control System & Nerve Center
« on: September 18, 2015, 12:50:43 PM »
I own a small property with 12 boat slips which I bought about a year ago.  When I bought it, there was a combination lock on the single swing gate that everyone in town knew.

There are so many possibilities here I think I could add nodes forever...



Prerequisites - I have internet and WiFi at the location through my local cable TV provider with the router in a shed on the corner of the property.  I set my router to route https to the gateway and http to the security video page.

Quick-Fix Before the Moteino - I wanted a quick fix for the gate that was ultimately compatible with the Moteino Framework.  I added a magnetic lock controlled by a keypad controller.  The controller can be externally activated by closing a N.O. input essentially pulling an input to ground.  This models the 'exit button' feature.  I really wanted a basic keypad and do all of the logic in the Pi but time was a factor as well as finding a nice weatherproof keypad that output ascii or raw key presses.  This will have to do for now even though I can't detect which user activated the gates.


Pi-Gateway -
I assembled the Pi Gateway and master node and loaded the most recent image from Felix.  To test, I just used a MotionMote to sound the horn.  That works like a charm.  I see the post about updating the log database which I will do soon.

I also run a DuckDNS script on the Gateway to give me a dynamic dns address I can use.

Starting Simple - Gate Alarm - I have motion sensor cameras but get so many false alarms from the geese, birds and night bugs as big as birds it is almost useless.  I want an alert any time the gate is opened.  I have a GarageMote with two sets of magnets/sensors.  I will try to use them for the pedestrian gate and the sliding gate.  More to come in a further post on this progress.  I'd also like to use this to trigger the alarm input on the security video system to switch to high resolution and high frame rate recording.

Smart Phone Gate Unlock - Sounds like a basic GarageMot.  But I want separate user accounts and authentication.  Is this as simple as Linux user accounts??  We'll see.

Winter is Coming!!  - GoT - I just spend a ton of money fixing and replacing bulkheads and pilings.  There are some parts of the water susceptible to freezing. I want to turn on circulators or bubblers to prevent freezing and lifting the piles.

Motion Sensors - Sure, yep.

Lighting - The owner before me had lots of regular lights and several halogen lights that ran all light long.  I can't imaging that electric bill.  First thing I did was replace the halogens with LEDs and replaced any bad night sensors.  I'd like to go with two stage lighting with minimal lighting all night long and brighter lights when sensors detect people.  Sounds easy.

More to Come
« Last Edit: September 18, 2015, 12:53:08 PM by HeneryH »

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Marina Control System & Nerve Center
« Reply #1 on: September 18, 2015, 01:59:49 PM »
This is a nice project HeneryH, thanks for sharing, looking forward for more details!
It's a STICKY too!
FWIW - I need to fix some extra bugs and I will release a new set of files and image, hopefully in the next week or so. The current image should still work just fine. The files at Github might be out of synch with those on the image. It's getting hard to keep everything synchronized.

HeneryH

  • Full Member
  • ***
  • Posts: 229
Re: Marina Control System & Nerve Center
« Reply #2 on: October 12, 2017, 11:33:35 AM »
This project set for a while in an half-complete state (haven't we all done that?)

Revisting...

Here is the RFID gate card reader node that will open the gate by closing the "exit" button sensor on the keypad when a valid RFID tag is detected.

Raw RFID reader circuit on breadboard.  This is the AdaFruit reader.  https://www.adafruit.com/?q=pn532


I have the node detecting presented cards and sending the card ID back to the Gateway as a new metric type called RFID which looks like this
Code: [Select]
Hello!

Transmitting at 433 Mhz...
RFM69_ATC Enabled (Auto Transmission Control)

Found chip PN532
Firmware ver. 1.6

Waiting for an ISO14443A Card ...
Found an ISO14443A card
  UID Length: 4 bytes
  UID Value: 0x50 0x07 0xDE 0x16

RFID ACK:NOK...RFID UID:5007de16 BAT:4.2v   <--- I took the 4 byte UID and jammed it into a string.

Edit - Felix tells me that using hex (basically a string) has problems in that each unique code has to be predetermined and defined.  This works OK with the known cards, but not the unknown cards.  Therefore, it would be best to just convert to numeric equivalents of the hex strings.  The strings are either 4 or 7 bytes, my cards are all 4 bytes which would yield a maximum number of 0xFFFFFFFF or 4,294,967,295.  Not sure if that pushes any boundaries of data types??  On the other hand, maybe we just code the known codes and hopefully we can get a deny for any unknown ones.  Experimentation will tell....

I created an RFID Mot type of node in the gateway metrics.js file with:
Code: [Select]
RFIDMote: {
    label  : 'RFID Sensor',
    icon   : 'icon_sonar.png',   <-- create one
    settings: { lowVoltageValue: '' }, //blank will make it inherit from global settings.json lowVoltageValue, a specific value overrides the general setting, user can always choose his own setting in the UI
},

and defined a metric in the same file so that the gateway would recognize the UID tag coming in from presented cards
Code: [Select]
RFID_UID: { name:'UID', regexp:/UID\:([0-9a-fA-F]+)/i, value:'', unit:'', },

Now I am moving on to trying to figure out how to get the gateway to respond to the presented card with either an 'accepted' or 'denied' action.  The action can be matured but for now even a simple beep would suffice.

I'll start with the simple beep sound and steal from the MotionMot alert sound
Code: [Select]
  motionAlert : { label:'Motion : Alert', icon:'audio', descr:'Alert sound when MOTION is detected', serverExecute:function(node) { if (node.metrics['M'] && node.metrics['M'].value == 'MOTION' && (Date.now() - new Date(node.metrics['M'].updated).getTime() < 2000)) { io.sockets.emit('PLAYSOUND', 'sounds/alert.wav'); }; } },

Maybe going with
Code: [Select]
  RFIDAlert : { label:'RFID : Card Detected', icon:'audio', descr:'Alert sound when RFID Card is detected', 
                                         serverExecute:function(node) {
                                                if (node.metrics['UID'] && node.metrics['UID'].value == '5007de16' ) {
                                                      io.sockets.emit('PLAYSOUND', 'sounds/alert.wav');
                                                };                  <-- what is with this semicolon?  Can I put an 'else' clause here?
                                         }
                              },

Would the 'else' look like this?  Specific question about that semi-colon.  At a bare minimum, I could hard-code the allowable cards.  There will be 10-20 of them in typical usage.
Code: [Select]
  RFIDAlert : { label:'RFID : Card Detected', icon:'audio', descr:'Alert sound when RFID Card is detected', 
                                         serverExecute:function(node) {
                                                if (node.metrics['UID'] && node.metrics['UID'].value == '5007de16' ) {
                                                      io.sockets.emit('PLAYSOUND', 'sounds/access_granted.wav');
                                                } else {
                                                      io.sockets.emit('PLAYSOUND', 'sounds/access_denied.wav');
                                               };                  <-- what is with this semicolon? 
                                         }
                              },

Here are some sounds that might be cool:
https://freesound.org/people/EthanolProductions/sounds/215004/  for Access Granted and there are many others to play with.
« Last Edit: October 13, 2017, 12:29:13 PM by HeneryH »

HeneryH

  • Full Member
  • ***
  • Posts: 229
Re: Marina Control System & Nerve Center
« Reply #3 on: October 12, 2017, 01:54:17 PM »
For detecting various Normally-Open switches (like when a user enters a key-pad number or when the user presses the 'exit' button) I soldered on some spring connectors.

One side has the pull-up resistor and is using the same as the PIR input pin.  When the switch is closed, it gets pulled to ground.

This is about as basic a 'sensor' as you can have.

BLOCKED IMAGE BY GOOGLE

BLOCKED IMAGE BY GOOGLE

I plan to detect when a user presses a key on the keypad with this interface to the keypad
BLOCKED IMAGE BY GOOGLE
« Last Edit: December 13, 2018, 03:08:22 PM by Felix »

Davidson

  • NewMember
  • *
  • Posts: 1
Re: Marina Control System & Nerve Center
« Reply #4 on: October 19, 2017, 11:30:49 AM »
Amazing stuff Henery. Thanks for sharing the details and pics. What else are you working on?
I'm sure Zotrim is the best around and I love it.

HeneryH

  • Full Member
  • ***
  • Posts: 229
Re: Marina Control System & Nerve Center
« Reply #5 on: December 12, 2018, 07:45:34 PM »
Some of the Marina Control Center Components...

I have two Pi/Gateway systems running: one is an older 433mHz system on an older Pi that will actually be deployed to the marina.  The other is a 915mHz Pi-3b+ system for my lab dev center.



A) Magnetic Gate Locks - Quad Relay I2C board that talks via I2C to a Mote - this will switch the 12v magnetic gate and door locks.  Relay 1 for the Gate and Relay 2 for the door.   I started with SwitchMote code and swapped in the Quad I2C commands rather than the relay commands in the default SwitchMote sketch.  The Motion part of the SwitchMote was useful for the trigger target when someone wants to enter - I unlock for x secs using the Motion sample.

B) I need an exit button for anyone stuck inside to be able to get out by simply pushing an exit button.  I took sample code to make a button push event that will send a motion command over to the Quad Relay to open the gate for x seconds. Timeout in the video is shortened.



B1) Enter the gate via SMS - in order to enter the yard I first had a padlock, old school.  Then I had a standalone pin pad, but that started to stick.  Now I can use an SMS message to the controller to open the gate.  I also have an RFID reader I played around with.  Frankly, who doesn't have a smartphone anymore?  I may just stick with this. Timeout in the video is shortened.



C) Winter De-Icer - A dual channel SwitchMode with GFCI protection - The SwitchMote has two channels but I will only be using one here.  The De-Icer plugs into the SwitchMote.

D) Thermometer for Water Temp to control De-Icer - the plan is to mount this solar super-cap charged mote in a simple glass box with silicone sealant so it is weatherproof.  Float it in the water with the probe x inches submerged.  When the temp crosses < x then turn on the De-Icer SwitchMote, when crosses > y then turn the de-icer off.  I tested this with a glass of ice water on the bench.


I had to double-up on the super caps for my temperature probe since it was drawing down much faster than the same thing on my MotionMote.  Never got around to debugging why it was draining faster, it was just quicker to piggy-bag another cap.
« Last Edit: December 12, 2018, 08:31:12 PM by HeneryH »

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Marina Control System & Nerve Center
« Reply #6 on: December 13, 2018, 03:07:47 PM »
Great work, thanks for the follow up!
FWIW - I edited your previous post with blocked photos to remove them, if you want to post those again please do so in a new post below, thanks.

HeneryH

  • Full Member
  • ***
  • Posts: 229
Re: Marina Control System & Nerve Center
« Reply #7 on: December 13, 2018, 03:19:43 PM »
I switched to Imgur because I had a heck of a time getting pasteable URLs from Google Photos.  Thanks.

HeneryH

  • Full Member
  • ***
  • Posts: 229
Re: Marina Control System & Nerve Center
« Reply #8 on: January 09, 2019, 01:29:41 PM »
Darn, the yard is full of fiberglass boats packed tight for winter storage and all of that fiberglass seems to be preventing wireless connection between the node and the gateway.  Using 433MHz at the moment.

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Marina Control System & Nerve Center
« Reply #9 on: January 09, 2019, 03:35:32 PM »
Did you try other frequencies?
If you bring a node in LOS (line of sight), does RSSI get back in check?