DO MOTEINO NODES INTERFERE WITH ONE ANOTHER?

Started by evh, April 17, 2015, 07:00:11 PM

evh

I seem to have a spooky problem with nodes working sometimes,  not at other times.

I am running the example Gateway and Node programs, modified so that a line is transmitted every 8 seconds, and speed set to 1200.

My two nodes seem to work OK when separated by some distance.  However, when I put them within a few feed of each other, it seems like one or the other wants to quit sending.  Is there something that might explain this?

Felix

Does that happen with the STANDARD Gateway/Node code (only radio settings adjusted to match hardware)?

evh


I have not done anything special to the radio parameters, except for the baud rate, and uncommenting the HW define.

evh

#3
..here is the code ... 

#include <MemoryFree.h>
#include <LiquidCrystal.h>
#include <RFM69.h>    //get it here: https://www.github.com/lowpowerlab/rfm69
#include <SPI.h>
#include <SPIFlash.h> //get it here: https://www.github.com/lowpowerlab/spiflash
#include <Wire.h>
#include <LowPower.h>

#define NODEID        13    //unique for each node on same network
#define NETWORKID     100  //the same on all nodes that talk to each other
#define GATEWAYID     1
//Match frequency to the hardware version of the radio on your Moteino (uncomment one):
//#define FREQUENCY   RF69_433MHZ
//#define FREQUENCY   RF69_868MHZ
#define FREQUENCY     RF69_915MHZ
#define ENCRYPTKEY    "sampleEncryptKey" //exactly the same 16 characters/bytes on all nodes!
#define IS_RFM69HW    //uncomment only for RFM69HW! Leave out if you have RFM69W!
#ifdef __AVR_ATmega1284P__
  #define LED           15 // Moteino MEGAs have LEDs on D15
  #define FLASH_SS      23 // and FLASH SS on D23
#else
  #define LED           9 // Moteinos have LEDs on D9
  #define FLASH_SS      8 // and FLASH SS on D8
#endif

#define SERIAL_BAUD   1200

float ff;
int xxx;
char temperature_txt[10];

 char out_temp[30];
     char inbuffer[50];
     int loopcounter=0;



char highbyte, lowbyte;

int temp_address = 72;


int TRANSMITPERIOD = 1500; //transmit a packet to gateway so often (in ms)
char payload[] = "123 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char buff[20];
byte sendSize=0;
boolean requestACK = false;
SPIFlash flash(FLASH_SS, 0xEF30); //EF30 for 4mbit  Windbond chip (W25X40CL)
RFM69 radio;





int get_275_text(char *inbuffer )
{
 
word t;
int my_temp;
char tempHighByte;
char tempLowByte;
float temperature1;
float temperature2; 
Wire.beginTransmission(0x48);
  Wire.write(1);
  Wire.write(B11100001);
  Wire.endTransmission();
  Wire.beginTransmission(0x48);
  Wire.write(0);
  Wire.endTransmission();
  Wire.requestFrom(0x48,2);
  delay(250);
  tempHighByte = Wire.read();
  tempLowByte  = Wire.read();
  t = word(tempHighByte,tempLowByte)/16;
  temperature1=t/16.0;
  //Serial.println(temperature1,4);
  my_temp = temperature1*100;
  
  sprintf(inbuffer,"{%x} {%x}",tempHighByte,(tempLowByte & 0xf0)>>4   );
  //sprintf(outtemp,"{%d}",my_temp);
  return my_temp;

 
}








void setup() {
  
  
  //Create a Wire Object
  Wire.begin();

  radio.initialize(FREQUENCY,NODEID,NETWORKID);
#ifdef IS_RFM69HW
  radio.setHighPower(); //uncomment only for RFM69HW!
#endif
  radio.encrypt(ENCRYPTKEY);
  //radio.setFrequency(919000000); //set frequency to some custom frequency
  char buff[50];
  sprintf(buff, "\nTransmitting at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
  Serial.println(buff);
  
  if (flash.initialize())
  {
    Serial.print("SPI Flash Init OK ... UniqueID (MAC): ");
    flash.readUniqueId();
    for (byte i=0;i<8;i++)
    {
      Serial.print(flash.UNIQUEID[i], HEX);
      Serial.print(' ');
    }
    Serial.println();
  }
  else
    Serial.println("SPI Flash Init FAIL! (is chip present?)");
}

long lastPeriod = 0;
void loop() {

     Serial.begin(9600); 
     
     
  
    //sprintf(out_temp,"{LFP AAAD %d}",get_275());
    get_275_text(inbuffer);
    inbuffer[17]=0;
    sprintf(out_temp,"testB%s@",inbuffer);

    out_temp[17]=0;
     
    radio.send(GATEWAYID, out_temp, 14 );
  
       
       
    //Serial.print("freeMemory()=");
    //Serial.println(freeMemory());

    delay(200);
       
   
   
   
   Serial.end();

    //Serial.println();
    Blink(LED,3);
    // ATmega328P, ATmega168
    for( loopcounter=0;loopcounter<10; loopcounter++)
    {
      
    radio.sleep();
    flash.sleep();
    //LowPower.idle(SLEEP_8S, ADC_OFF, BOD_OFF); 

    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
    //LowPower.idle(SLEEP_8S, ADC_OFF, TIMER2_OFF, TIMER1_OFF, TIMER0_OFF, 
      //          SPI_OFF, USART0_OFF, TWI_OFF);
             

    
    }            

    //delay(15000);
  
}

void Blink(byte PIN, int DELAY_MS)
{
  pinMode(PIN, OUTPUT);
  digitalWrite(PIN,HIGH);
  delay(DELAY_MS);
  digitalWrite(PIN,LOW);
}

evh

NOTE:   The posted code as "testB" transmitted by the node.  The other nodes use the same code, except that some other letter is substituted for the B ... like X, Y, Z etc.

TomWS

Quote from: evh on April 18, 2015, 02:53:58 AM
NOTE:   The posted code as "testB" transmitted by the node.  The other nodes use the same code, except that some other letter is substituted for the B ... like X, Y, Z etc.
And you change the NODEID for each one?

Tom

evh


No  they all have the same NODE ID.   Each unit is set to transmit 20 characters once every 80 seconds. 

evh



...so, I just gave each unit a different NODE ID .... will see how that works....

TomWS

Quote from: evh on April 18, 2015, 03:15:06 PM

No  they all have the same NODE ID.   Each unit is set to transmit 20 characters once every 80 seconds.
Since your case isn't having the Gateway send back to the nodes, it might not make any difference, but with the unique nodeid, you wouldn't need the preamble on the message.

Is there any reason that you didn't use 'sendWithRetry()' rather than send?  'sendWithRetry()' will require the gateway to respond with an Ack, but that's pretty straightforward, and sendWithRetry will take care of cases where two nodes send at the same time.  Of course, if you do change to retry, then you absolutely must use unique nodeids...

Tom

evh


I changed it "sendWithRetry()"

Now, the node is sending two identical messages, rather than one.  The Gateway gets the first message, but the node sends another message anyway.  It seems like the Node is not getting the Ack, so it just sends off a second attempt.  Any thoughts?

evh

#10
..oops ... I forgot to have the Gateway send the ACK ...  the following code had to be uncommented ...  works OK now!   Thanks.

if (radio.ACKRequested())
    {
      byte theNodeID = radio.SENDERID;
      radio.sendACK();
      Serial.print(" - ACK sXent.");

      // When a node requests an ACK, respond to the ACK
      // and also send a packet requesting an ACK (every 3rd one only)
      // This way both TX/RX NODE functions are tested on 1 end at the GATEWAY
      
    }