How bild network using MoteinoRFM69

Started by Leonid49, November 01, 2017, 09:31:21 AM

Leonid49

Hi All.
I want bild network using Moteinos (based on RFM69HW). In this network are Master  (MoteinoRFM69HW 868MGz) and 8 Slave devices (MoteinoRFM69HW 868MGz).
I decide to try this with using examles from RFM69 library by Felix Rusu: Struct_receive (as Master) and Struct_send (as Slave).
But in both these examples loop() begins
if(radio.receiveDone())
{
  //...
}

It is Ok for Slave device - he wait command from Master. But the Master must first send a command to one of the slave devices and then receive data from it according to the command sent.
In sketch Struct_receive (as Master) I wrot like here:
void loop()
{
  if (radio.sendWithRetry(1, "P", 1, 1)) //radio.send command "P" to node 1
    Serial.println("Sent command ok!");
........................
}
but this not works.
Main sketches  Struct_receive (as Master) and Struct_send (as Slave) are in attached files.
Do can anyone help me?
Thanks.



Felix

You did not specify what IDs you use for your 9 devices, but usually the master is 1 and in your code - if your master ID is 1 then it cannot send to itself.

The examples should be working without changes as long as your settings on both ends are the same.
There is also the Node and Gateway examples for getting started.
I suggest you just follow the given working examples, they work.

Leonid49

Thank You, Felix.
Quotebut usually the master is 1 and in your code - if your master ID is 1 then it cannot send to itself.
In my code Master haves address NODEID=10 (Struct_receive), and Slave address is NODEID=1 (Struct_send) - these are differ addresses. Hence Master does not send a command to himself.
Master stnd command to Slave 1:
void loop()
{
  if (radio.sendWithRetry(1, "P", 1, 1)) //radio.send command "P" to node 1
    Serial.println("Sent command ok!");


//-----then wait from Slave 1 sedet Data

  while (!radio.receiveDone()) //Waiting receiving
  {}


  ......
}
What is not right?

Felix

I think your code is not using receiveDone() correctly and you can enter an infinite loop.
Please start from a working example, set the settings in the working examples to fit your radio hardware. Then start modifying your IDs and such.

Leonid49

Hi, Felix.
I did so as You advised: from examples in Your library I took Struct_receive (as Master) and Sruct_send (as Slave).
I removed everything I did not need. In attached files is shown both sketches.
Now about what I got.
Master send to Slave command (just simbol 'P') and wait answer. Slave receives this command, send ACK and responds with the "H" symbol to Master.
Master must receive simbol 'H' and send ACK to Slave.
But slave cannot send ACK to Master and reboot. I not undestand where I was mistaken.
Please take look on my sketches and COM port reports and help me to understand where I was mistaken.
I designed a lot differ devices with using microcontrollers (Microchip 10, 12, 16, 18 series), Arduino's, ESP8266 with Blynk. But I am newbie in radio.

Leonid49


perky

I've had a quick look, it appears you are requesting ACKs to be sent back in both the master and slave code, but no filtering out ACKs in the slave code before sending another reply. So replies being sent back from ACKs from the master maybe?

Mark.

Leonid49

Thanks, perky.
I think if Master(address 10 in my case) sends message to Slave(address 1 in my case) with using function radio.sendWithRetry(1, "P", 1, 3, 30) then this means that the Slave device after receive message from Master should to analize with using function ACKRequested(): has requested Master  ACK or not. If ACKRequested()==true then Slave device should send ACK to the Master with using function sendACK(). Exactly so I did. But if take look on to COM port monitors can be see that Slave device after output of string ACK request=1 go away in to rebooting. I cannot to understand why, what I  not correctly do.

perky

Could you post the main() routunes for the master and slave too?
Mark.

Leonid49

#9
Hi, Mark.
In attached files are the both sketches of Master and Slave. Or do You mean   somthing else?
Leonid.

Leonid49


perky