Go Down

Topic: Weak RSSI from RFM69HW (Read 35 times) previous topic - next topic

vador98

I've been working on building a home automation system similar to that built by Eric Tsai, but I'm having some signal issues with my RFM69HW chips.  I have one chip connected to a Arduino Pro Mini, and another connected to a Raspberry Pi.  The chips are able to communicate (most of the time), but the best signal I've seen so far is -93 with a distance of about 4 feet.  Each chip has a 3 inch antenna attached currently, but I've tried as much as a 13 inch antenna with no better signal. 

I'm using almost identical code to Eric Tsai's mailbox sensor, however, I've noticed that if I leave the "setHighPower" uncommented, then the unit fails to transmit.  If I leave it commented out, then it transmits fine, but the signal is weak.  Also, in order to upload new sketches to the arduino, I need to remove power from the RFM chip. 

Is my issue due to a low input power?  I've tried powering everything via the power regulator onboard the arduino, as well as using a seperate 3.3v regulator.  At all times, this was being powered by a USB port off my PC.  I've just run the power pin from the FTDI connector to the raw pin or the voltage regulator instead.

Here's my code:

Code: [Select]
/*
Original Author:  Eric Tsai
License:  CC-BY-SA, https://creativecommons.org/licenses/by-sa/2.0/
Date:  7-21-2014
File: Mailbox.ino
This sleeps until interrupted, then sends data via RFM69

Modifications Needed:
1)  Update encryption string "ENCRYPTKEY"
*/

//RFM69  --------------------------------------------------------------------------------------------------
#include <RFM69.h>
#include <SPI.h>
#define NODEID        41    //unique for each node on same network
#define NETWORKID     101  //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    "xxxxxxxxxxxxxxxx" //exactly the same 16 characters/bytes on all nodes!
#define IS_RFM69HW    //uncomment only for RFM69HW! Leave out if you have RFM69W!
#define ACK_TIME      30 // max # of ms to wait for an ack

#define SERIAL_BAUD   9600  //must be 9600 for GPS, use whatever if no GPS
//deviceID's

typedef struct {
  int           nodeID;
  int deviceID;
  unsigned long var1_usl;
  float         var2_float;
  float var3_float;
} Payload;
Payload theData;

char buff[20];
byte sendSize=0;
boolean requestACK = false;
RFM69 radio;

//end RFM69 ------------------------------------------


//analog read
int analogPin = 0;
byte adcsra_save;

//-------------------------
#include <avr/sleep.h>

const byte LED = 8;
const byte redLED = 4;
const byte greenLED = 5;
int scan_num = 0; //keep track of how many times opened.
long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time; increase if the output flickers
int buttonState;             // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin
boolean stable = false;      // determines whether the button reading is stable

void wake ()
{
  // must do this as the pin will probably stay low for a while
  detachInterrupt (1);
  // cancel sleep as a precaution
  sleep_disable();

}  // end of wake

void setup ()
  {
    digitalWrite (2, HIGH);  // enable pull-up
    Serial.begin(SERIAL_BAUD);  //Begin serial communcation
   
    adcsra_save = ADCSRA; //save ADCSRA to re-enable later.
   
    Serial.println("starting");
    //RFM69-------------------------------------------
    radio.initialize(FREQUENCY,NODEID,NETWORKID);
    #ifdef IS_RFM69HW
      radio.setHighPower(); //uncomment only for RFM69HW!
    #endif
    radio.encrypt(ENCRYPTKEY);
    char buff[50];
    sprintf(buff, "\nTransmitting at %d Mhz...", FREQUENCY==RF69_433MHZ ? 433 : FREQUENCY==RF69_868MHZ ? 868 : 915);
    Serial.println(buff);
    theData.nodeID = 41;  //this node id should be the same for all devices in this node
    pinMode (LED, OUTPUT);
    pinMode (redLED, OUTPUT);
    pinMode (greenLED, OUTPUT);
    digitalWrite (greenLED, HIGH);
    Serial.println("finished setup");
  }  // end of setup

void loop ()
{
  // read the state of the switch into a local variable:
  int reading = digitalRead(3);
  if (reading){
    digitalWrite (LED, HIGH);
     
    //re-enable analog:
    ADCSRA = adcsra_save;
   
    scan_num = scan_num + 1;
    //send data
    theData.nodeID = 41;
    theData.deviceID = 2;
    theData.var1_usl = millis();
    theData.var2_float = scan_num;
   
    //radio.sendWithRetry(GATEWAYID, (const void*)(&theData), sizeof(theData));
    delay(500);
    theData.var3_float = (analogRead(A3))*3.30/1023.00*2.00;
   
    //use either send;  sendwithretry sends it 3 times if no ack
    //radio.sendWithRetry(GATEWAYID, (const void*)(&theData), sizeof(theData));
    radio.send(GATEWAYID, (const void*)(&theData), sizeof(theData));
   
   
    digitalWrite (LED, LOW);
    radio.sleep();
   
    // disable ADC
    ADCSRA = 0; 
  }
 
 
  set_sleep_mode (SLEEP_MODE_PWR_DOWN); 
  sleep_enable();

  // Do not interrupt before we go to sleep, or the
  // ISR will detach interrupts and we won't wake.
  noInterrupts ();
 
  // will be called when pin D2 goes HIGH 
  attachInterrupt (1, wake, HIGH);
 
  // turn off brown-out enable in software
  // BODS must be set to one and BODSE must be set to zero within four clock cycles
  MCUCR = bit (BODS) | bit (BODSE);
  // The BODS bit is automatically cleared after three clock cycles
  MCUCR = bit (BODS);
 
  // We are guaranteed that the sleep_cpu call will be done
  // as the processor executes the next instruction after
  // interrupts are turned on.
  interrupts ();  // one cycle
  sleep_cpu ();   // one cycle

  } // end of loop

vador98

Maybe another way to approach this is, How can I tell which side has the issue, sender or receiver?  Perhaps it's both, but is there a good way to find out, outside of an oscilloscope?  If I put a multimeter across the transceiver, I don't see a significant change in mA during transmission.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy