LowPowerLab Forum

Hardware support => General topics => Topic started by: jcsingle21 on October 08, 2014, 09:55:33 PM

Title: Serial Commands to SwitchMote On/Off
Post by: jcsingle21 on October 08, 2014, 09:55:33 PM
I am a NOOB and hope someone can help me.  I am trying to figure out the actual serial command to turn a switchmote on/off.  I have everything setup, but can not figure out how to do this remotely.  I read the switchmote sketch, but its more than I can read.  Sorry for the NOOB questions.
Title: Re: Serial Commands to SwitchMote On/Off
Post by: Felix on October 09, 2014, 08:58:18 AM
At the moment of writing it is setup to listen for SSR:1/0 or BTNX:0/1 commands.
SSR:1 turns the relay on (and middle button status GREEN).
SSR:0 does the reverse and RED.

BTN0:1 turns the top  button status ON (no relay but would notify SYNCed switchmotes)
BTN1:1 or 0 is the middle button/relay
BTN2:1 or 0 is bottom button.

So just send it the bold commands.
Hope this helps.
Title: Re: Serial Commands to SwitchMote On/Off
Post by: jcsingle21 on October 09, 2014, 09:06:26 AM
That's just what I was looking for. I will have to test when I get home. Is there a format to send to a node?
Title: Re: Serial Commands to SwitchMote On/Off
Post by: Felix on October 09, 2014, 09:21:44 AM
Format?
Not really, except you have to give it what it expects, something valid like SSR:1 or BTN1:1, these both do the same thing.
To see an example of how to send check this example: https://github.com/LowPowerLab/RFM69/blob/master/Examples/Node/Node.ino
You can just call this to send a packet, after radio is properly initialized in your sketch:

radio.sendWithRetry(SwitchMoteID, "SSR:1", 5) //5== length of message in # of bytes

This would turn on the relay.
Title: Re: Serial Commands to SwitchMote On/Off
Post by: charlieroot on January 06, 2015, 12:34:59 AM

Has anyone created a nice web interface for controlling the switchmote?
Title: Re: Serial Commands to SwitchMote On/Off
Post by: Felix on January 06, 2015, 08:08:33 AM
Well I did but I would not call it uber nice. I am trying to find time to build something better. What I have publishes right now can be seen in the video I posted for HAD Prize. I did not publish the code for that but it's quite easy to add it to the sample gateway I shared here (http://lowpowerlab.com/blog/2013/10/11/raspberrypi-home-automation-gateway-hardware-and-demo/).
Title: Re: Serial Commands to SwitchMote On/Off
Post by: charlieroot on January 06, 2015, 12:49:18 PM

Hi Felix

I'm already using your garagemote web code and it's working quite well. I've started looking at how you've done it in both the index.php and in the garagemote_base sketch but I'm a total programming noob so it's all trial and error for me.

Are you willing to share the switchmote web code you've done?

Thanks
Title: Re: Serial Commands to SwitchMote On/Off
Post by: Felix on January 08, 2015, 08:00:12 PM
Ok ... really sorry ... this took me a while. But I managed to add some sample code. This is actual working code demoed in this video:
https://www.youtube.com/watch?v=I9MNZQgqKHA&list=UUqOeqH8YqacRSXQmaFrIt1A

The code is now shared in Github:
https://github.com/LowPowerLab/RaspberryPi-Gateway/blob/master/gateway.js
https://github.com/LowPowerLab/RaspberryPi-Gateway/blob/master/index.php
https://github.com/LowPowerLab/RFM69/tree/master/Examples/PiGateway
Title: Re: Serial Commands to SwitchMote On/Off
Post by: charlieroot on January 12, 2015, 08:52:10 PM

Maybe it's just me, but I don't see any difference in the code on github.
Title: Re: Serial Commands to SwitchMote On/Off
Post by: Felix on January 13, 2015, 09:03:44 AM
My bad, I submitted the change but forgot to sync... one click can make a difference. Please take a new look now.
Title: Re: Serial Commands to SwitchMote On/Off
Post by: jcsingle21 on January 21, 2015, 06:48:34 AM
I currently have a gateway moteino setup for motion motes.  With upgrading the gateway to this INO, will I still be able to monitor my motion motes and have my python scripts text me?  Or should I have two gateways?  I am thinking only one program can monitor that serial/USB port at any one time. 

Further info:
I do not have a garage mote.  I am looking to only control my switchmotes with this setup and text me when I have motion on my motion sensors.  I do however plan to do water usage as well as fire alarm triggers so I will always be notified when away.  I would like only one gateway moteino, but not sure this can occur.  If it can, I guess I need to get more experience in coding.
Title: Re: Serial Commands to SwitchMote On/Off
Post by: Felix on January 21, 2015, 08:44:55 AM
You can adapt the code in python to do the same thing in nodejs... the scripts are only provided as samples. You are encouraged to change them and adapt however fits your needs. When I have a new version that is more interactive/dynamic I will publish it, it's something on my list but for now what I published is all there is, but look at it as an opportunity to learn and explore.
Title: Re: Serial Commands to SwitchMote On/Off
Post by: jcsingle21 on January 21, 2015, 12:03:01 PM
I agree, its great practice to learn more of coding.  I got my system up and running and was able to turn on the switch mote on and off through the web interface.  The only hiccup I see I want to iron out is for when you first load the page to request status of the current position of the switch mote.  It defaults to off and after two clicks it gets in sync, not a huge deal, just my personal agenda.  Other than that, thanks for all the help and great stuff here.   I love messing with this.
Title: Re: Serial Commands to SwitchMote On/Off
Post by: Felix on January 21, 2015, 04:34:12 PM
I will make this much nicer, the downside is you have to wait :)
Still this is quite nice to be able to do with stuff you can buy online and without any service agreements and monthly service fees to some big corporate, not to mention software and personal data kept in their cloud. Complete control :D
Title: Re: Serial Commands to SwitchMote On/Off
Post by: jcsingle21 on January 21, 2015, 04:42:29 PM
I agree Felix, I am in your debt for all you have provided us.  Your attention to detail and willingness to share is priceless.  You have done so much for all of us.  I just dropped more money on your items, all because I firmly believe what you just said.
Title: Re: Serial Commands to SwitchMote On/Off
Post by: Felix on January 21, 2015, 07:23:12 PM
Thanks for the compliments, I plan to continue this adventure. Time is the limiting factor unfortunately.