Hi all!
I've been playing with arduinos for a while, making simple stuff here and there and basically having fun. For a while, I had been tinkering with the idea of having some sort of network of interconnected devices in my house. Think about not only home automation, but a network of smart things! (Does my coffee maker knows I'm out of bed? Does my tv knows I'm in the couch? Does my A/C know what's the weather like out there?, etc)
So I've been connecting stuff here and there with ethernet cables, I2C, etc. And then I found the Moteinos!
I just received two Moteinos today and I've been playing with them. I got the sender/gatewau sketches to work so now I wanna do more things. I've been reading Felix's blog, the examples and the forum and I love to see how many different projects are being enabled by such a simple kit. Awesome.
The project I want to start with is a very simple thing:
In the office I sit about 6ft from my colleague and he's always blasting some sweet tunes on his headphones, so of course it's impossible to get him to respond to anyone calling his name. So the idea is to have a big red button next to my keyboard plugged to a sender Moteino, and have a gateway Moteino right next to my colleague's computer connected to a light display and a vibration motor. Something simple and fun to get this guy to respond when everyone else is screaming his name.
I just have a question: How do I send the data? I think I don't need to send anything else but a character, say a 'n' (for Nag) and then have the gateway respond to that with some light and vibration.
I know this should be kind of straightforward, but I haven't been able to send anything when I press a button... Maybe I'm just too tired after a long weekend and a longer Monday, but I'd appreciate some insights here.
Many thanks and keep the good stuff!
Frix
Hi Frix, thanks for joining and your thoughts,
Your question is indeed very simple, you just need to read a button press (momentary) and on the remote node just light an LED.
For that I think you can just take the stock Node/Gateway skeetches and tweak them to read the button and light the LED. So instead of all the complexity of the Node, you just keep reading the momentary button input. You would wire the momentary to a pulled up PIN and the other side to GND (in setup do pinMode(mypin, INPUT_PULLUP)).
When that button is pressed it pulls the PIN low and you can detect that with digitalRead(), or better with the debouncing library.
But really, for this all you care is that the pin was pulled low once, then send a packet and wait another say 5-10 seconds before you would repeat, so debouncing is not really necessary.
Here's some on the fly code:
on the sender:
void loop()
{
if (digitalRead(mypin) == LOW)
{
radio.sendWithRetry(BUDDY_DESK_NODE_ID, "WAAKEUUUP!",10); //send longer string for the fun of it, but only expect 1 char on the other end (a 'W')
delay(5000);
}
}
on the receiver:
loop()
{
if (radio.receiveDone() && radio.DATALEN == 10 && radio.DATA[0]=='W')
{
Serial.println("I need to wake up...");
digitalWrite(BIG_RED_LED, HIGH); //turn it ON, or perhaps BLINK IT a few times...
delay(5000);
digitalWrite(BIG_RED_LED, LOW);
}
}
For fun - I found these red alert "Visual Signal Indicator (http://www.delcomproducts.com/products_USBLMP.asp)". I've not worked on it yet, but I think it could add a bit of wow to a project.
Also, if you're interest in having a single button have 4 different functions, take a look at this sketch (http://jmsarduino.blogspot.com/2009/10/4-way-button-click-double-click-hold.html) for ideas.
Thanks Felix and Dom!
That's exactly what I was thinking, Felix, thanks! I just didn't know how to structure the command. Do I have to send 10 characters? Or can the message be shorter, say 1 char? I was thinking that having all the commands documented on a Wiki would be super useful. What are your thoughts on that?
Dom, they look really cool! I'll try to get my hands into one of them and hack it. For the time being, I have this massive 1W Blue LED that I'm gonna use to blind my colleague every time we need him hahaha.
I'll post the code and pictures as soon as I'm done.
Cheers!
Frix
You're welcome, you can send just 1 char, it's up to you.
All commands in the library? Yeah a wiki would be nice but my time is so limited... I tried to document the usage using concrete sketch examples. I will add more of those as I come up with new usages/devices runnning on Moteino.
frix, do post here if you figure out the red alert one. I'd be interested.
Here's one additional idea to get their attention: "Who broke the build (http://www.papercut.com/blog/chris/2011/08/19/who-broke-the-build/)"
https://www.youtube.com/v/1EGk2rvZe8A