Author Topic: Help using Keypad with Moteino  (Read 1632 times)

TomWS

  • Hero Member
  • *****
  • Posts: 1892
Re: Help using Keypad with Moteino
« Reply #15 on: February 10, 2018, 05:09:56 PM »
I haven't looked at your code, but there are lots of ways of doing what I think you want to do. The way to do it depends on how reliable vs how easy it is to do.

The simplest, by far, is to have your keypad transmitter simply broadcast the key code that was just pressed.  All the receivers will get the key code and, if it matches theirs, turn on.  If it doesn't, turn off.

It you want reliable with interlocks, then it gets tricky. 

Tom

aburfitt

  • Newbie
  • *
  • Posts: 24
  • Country: au
Re: Help using Keypad with Moteino
« Reply #16 on: February 10, 2018, 05:43:30 PM »
Thanks Tom,
Yes that is pretty much what I have done.
The Transmitter is sending the code out to all receivers and if the code matches their code then they turn on.
I have tried to take it to the next level of checking which is where it is getting tricky.
If you are able to have a quick look it would be much appreciated.

TomWS

  • Hero Member
  • *****
  • Posts: 1892
Re: Help using Keypad with Moteino
« Reply #17 on: February 10, 2018, 06:23:58 PM »
Thanks Tom,
Yes that is pretty much what I have done.
The Transmitter is sending the code out to all receivers and if the code matches their code then they turn on.
...
No, it isn't what you've done.  According to your code, you have set ALL of your receivers to the same ID, rendering sendWithRetry() useless.  Probably some of your receivers are getting the message, but the ACKs will collide with each other.

When I say 'broadcast' to all receivers, all receivers have a unique id and the sender sends (without retry) to RF69_BROADCAST_ADDR allowing all the receivers to see the same message.

Tom



aburfitt

  • Newbie
  • *
  • Posts: 24
  • Country: au
Re: Help using Keypad with Moteino
« Reply #18 on: February 10, 2018, 08:15:08 PM »
Quote
No, it isn't what you've done.  According to your code, you have set ALL of your receivers to the same ID, rendering sendWithRetry() useless.  Probably some of your receivers are getting the message, but the ACKs will collide with each other.
Oh... yes I see what you mean.  I did notice that on the serial monitor. 

Quote
When I say 'broadcast' to all receivers, all receivers have a unique id and the sender sends (without retry) to RF69_BROADCAST_ADDR allowing all the receivers to see the same message.

Ok cool, so I can get this correct in my head... each receiver should have its own ID like Receiver1, Receiver2, Receiver 3 etc but all part of the same network. (of course)

Can you please give me an idea of how to write the code for the command that does the broadcast to all receivers and then how the receiver receives the broadcast and looks to see if it the code is for it.
I see there is a promiscuous mode as well, although from what you have said Broadcost mode would be a better fit for me?

I had a look through the files and on the moteino website for where all this info is about the different functions and I couldn't see it.  Only examples with the different options in there.
There doesn't seem to be a document explaining all the code options, just info in the .cpp files. 
Have I missed something?
I am trying to learn at the same time myself without asking to many obvious questions.   :)

TomWS

  • Hero Member
  • *****
  • Posts: 1892
Re: Help using Keypad with Moteino
« Reply #19 on: February 10, 2018, 08:25:41 PM »
...
Can you please give me an idea of how to write the code for the command that does the broadcast to all receivers and then how the receiver receives the broadcast and looks to see if it the code is for it.
I see there is a promiscuous mode as well, although from what you have said Broadcost mode would be a better fit for me?
...
Other than giving each receiver a unique ID (as a good practice), no changes are needed in the receivers - each will receive the transmitted messages although the TARGET value will be the RF69_BROADCAST_ADDR id rather than the receiver's id. 
The transmitter uses radio.send() instead of radio.sendWithRetry(), the node id is set to the RF69_BROADCAST_ADDR id, and don't bother to check for ACK, cuz there won't be one.

Tom

aburfitt

  • Newbie
  • *
  • Posts: 24
  • Country: au
Re: Help using Keypad with Moteino
« Reply #20 on: February 10, 2018, 09:21:11 PM »
Ok Cool,
So what I need to do on the transmitter code is
Code: [Select]
#define RF69_BROADCAST_ADDR 255;

Then in place of:
Code: [Select]
if (radio.sendWithRetry(RECEIVER, "S", 1));

I use:
Code: [Select]
radio.send(RECEIVER, "S",1);

This will send to all Nodes on the network and will not ask for an ACK to be sent.

On the Receivers is there any point setting up the #define RF69_BROADCAST_ADDR 255; ?  I would guess probably not as they are just receiving?

The Command on the receiver will be the same:
Code: [Select]
if (radio.receiveDone());
And I can look for the radio data sent the same way as I did before?

Code: [Select]
if (radio.DATALEN == 1 && radio.DATA[0] == 'S')

TomWS

  • Hero Member
  • *****
  • Posts: 1892
Re: Help using Keypad with Moteino
« Reply #21 on: February 10, 2018, 11:38:21 PM »
Ok Cool,
So what I need to do on the transmitter code is
Code: [Select]
#define RF69_BROADCAST_ADDR 255;
No.  It is already a predefined constant.  Have you read the RFM69.h file at all?
Quote

Then in place of:
Code: [Select]
if (radio.sendWithRetry(RECEIVER, "S", 1));

I use:
Code: [Select]
radio.send(RECEIVER, "S",1);
sigh... no, you would use
Code: [Select]
radio.send(RF69_BROADCAST_ADDR,"S",1);
« Last Edit: February 10, 2018, 11:50:53 PM by TomWS »

aburfitt

  • Newbie
  • *
  • Posts: 24
  • Country: au
Re: Help using Keypad with Moteino
« Reply #22 on: February 11, 2018, 01:29:06 AM »
Thanks Tom,
That makes sense I will go it a try.
I appreciate your help and patience.  I am only fairly new to Arduino and so are learning all these things as I go along.

HeneryH

  • Full Member
  • ***
  • Posts: 219
Re: Help using Keypad with Moteino
« Reply #23 on: February 16, 2018, 04:22:39 PM »
This thread spurred me to take one of my stagnating projects to the next level.  Thanks aburfitt and Tom.  I will be using a standard 12-key number pad and queue keystrokes until the # key is detected then send the string to the gateway.  I won't pollute your thread but want to say thanks for the discussion here.

aburfitt

  • Newbie
  • *
  • Posts: 24
  • Country: au
Re: Help using Keypad with Moteino
« Reply #24 on: February 16, 2018, 07:49:50 PM »
Hi Henry,
Thanks for the post mate.
Glad I have inspired you  ;) 8)