POWER CONSUMPTION AND RFM69HW - HELP NEEDED

Started by ABL, May 27, 2015, 05:48:20 PM

ABL

Hi i am new to arduino/moteino and i have a problem with power consumption.

Mission: make a shock-sensor with moteino, able to send a massage to a receiver.

My hardware setup is as follows: moteino RFM69HW w. flash hooked up with a shock sensor ( connected to D3 and GND).

the problem is that if i run the code with RFM69HW commented out in line 55 and 80 it works perfectly, with a very little power consumption 0,03mA, BUT if i uncomment RFM69HW in line 55 and 80 the hole thing stops working and jumps to a power consumption of approx. 110mA constant.

The code i am using is the one attached.

best regards
ABL


TomWS

It's easiest to look at code if you paste it into a 'code' block - you see a little button above the input field with a '#' symbol.  Use that and then paste your code between the
'[ code ][ /code  ]' blocks.

Also, it would help if you describe what a 'shock sensor' is (part number, reference to datasheet, etc.).

Tom

ABL

#2
Ok thank you Tom  :)

The shock sensor/vibration sensor is this one https://www.elfa.se/elfa3~eu_en/elfa/init.do?item=73-026-23&toc=0

and the code

#include <RFM69.h>    //get it here: https://www.github.com/lowpowerlab/rfm69
#include <SPI.h>
#include <LowPower.h> //get library from: https://github.com/lowpowerlab/lowpower
//writeup here: http://www.rocketscream.com/blog/2011/07/04/lightweight-low-power-arduino-library/

//*********************************************************************************************
// *********** IMPORTANT SETTINGS - YOU MUST CHANGE/ONFIGURE TO FIT YOUR HARDWARE *************
//*********************************************************************************************
#define NODEID        2    //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! Remove/comment if you have RFM69W! --------- DET VIRKER PERFEKT, SÅ LÆNGE JEG KOMMENTERER DENNE LINIE UD, ALTSÅ SÆTTER DEN TIL RFM69W
//*********************************************************************************************

#define ACK_TIME      30 // max # of ms to wait for an ack
#define MOTIONPIN      1 //hardware interrupt 1 (D3)

//#define SERIAL_EN             //comment this out when deploying to an installed SM to save a few KB of sketch size
#define SERIAL_BAUD    115200
#ifdef SERIAL_EN
#define DEBUG(input)   {Serial.print(input); delay(1);}
#define DEBUGln(input) {Serial.println(input); delay(1);}
#else
#define DEBUG(input);
#define DEBUGln(input);
#endif

RFM69 radio;
volatile boolean motionDetected = false;
char sendBuf[32];
byte sendLen;

void setup() {
  Serial.begin(SERIAL_BAUD);
  radio.initialize(FREQUENCY, NODEID, NETWORKID);
#ifdef IS_RFM69HW
 radio.setHighPower(); //uncomment only for RFM69HW!
#endif
  radio.encrypt(ENCRYPTKEY);
  pinMode(MOTIONPIN, INPUT);
  attachInterrupt(MOTIONPIN, motionIRQ, FALLING);
  char buff[50];
  sprintf(buff, "\nTransmitting at %d Mhz...", FREQUENCY == RF69_433MHZ ? 433 : FREQUENCY == RF69_868MHZ ? 868 : 915);
  DEBUGln(buff);
  
}


int detectedNumber = 0; 
const int detectedRequired = 3; 
//----------

void motionIRQ()
{
  
  detectedNumber++;
  
  
  motionDetected = true;
}


void loop() 
{
  
  if (motionDetected = true && (detectedNumber == detectedRequired)); //
  {
    
    detectedNumber = 0; //reset "counter"
    
        
    
    sprintf(sendBuf, "HI");
    sendLen = strlen(sendBuf);

    if (radio.sendWithRetry(GATEWAYID, sendBuf, sendLen));
    {
      DEBUG("HI ACK:OK! RSSI:");
      DEBUG(radio.RSSI);
      
    }
    

     radio.sleep();
    
  }
  
  {
   
  }
  
  motionDetected = false; //do NOT move this after the SLEEP line below or motion will never be detected
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
  
}

Felix

Ok so assuming your sensor is low power and produces a HIGH on D3 you can pick that up with the MotionMote sketch which looks like your code is already trying to do.
If you got a HW then you definitely need to uncomment IS_RFM69HW. It's really important you are sure what the radio is : W or HW and use code accordingly.

ABL

#4
hi  :)

it should be a HW, but can i see if it is or not?

the sensor is low power, but it produces a LOW on D3, i have used the motionMOTE sketch but the result is the same. as soon as i uncomment RFM69HW it f.... up. if i comment RFM69HW it works perfectly..

if i load the gateway and node sketch and set it to RFM69HW it works perfectly,  and I have several hundred meter range.

but as soon as i use RFM69HW in the motionMOTE sketch it dosn't work.


Felix

Do you have your invoice?
If you post a photo of your Moteino underside I can tell you.

ABL

#6
i bought it at digitalmeans.co.uk,  but yes i doit says  moteino+RFM69HW+flash -868/915mhz(R4)

pic. attached

regards anders

Felix

Yes this is definitely a RFM69 HW.
You need to call radio.setHighPower(), or uncomment IS_RFM69HW.

I would advise taking back 1 step and load a stock Node-Gateway setup (adjust settings and HW etc). Make sure the node is functional and then go back to the Motion sketch. I assume your gateway is another Moteino? Any details on that?

ABL

ok i will try that, thanks  :)

yes it  is, i should be the same.. se pic.

Felix

Ok that is also a HW.
Please try the Gateway and Node sketches in the examples, to ensure you have a good starting point.

ABL

Hi Felix

The gateway and node sketches works perfectly fine.

regards
anders

Felix

Ok so we know the hardware is functional.

ABL

yes the hardware is functional, it's the code causing the problems, the strange thing is that the motionMOTE sketch is causing the exact same problem as the code i posted earlier...and it should work

TomWS

Quote from: ABL on May 28, 2015, 01:45:10 PM
Hi Felix

The gateway and node sketches works perfectly fine.

regards
anders
Does the 'Node' sleep in the example Sketch?  And, if so, did you measure the current drawn?

Tom

TomWS

Quote from: ABL on May 28, 2015, 01:43:12 AM
Ok thank you Tom  :)

The shock sensor/vibration sensor is this one https://www.elfa.se/elfa3~eu_en/elfa/init.do?item=73-026-23&toc=0

and the code

#include <RFM69.h>    //get it here: https://www.github.com/lowpowerlab/rfm69
#include <SPI.h>
#include <LowPower.h> //get library from: https://github.com/lowpowerlab/lowpower
//writeup here: http://www.rocketscream.com/blog/2011/07/04/lightweight-low-power-arduino-library/

//*********************************************************************************************
// *********** IMPORTANT SETTINGS - YOU MUST CHANGE/ONFIGURE TO FIT YOUR HARDWARE *************
//*********************************************************************************************
#define NODEID        2    //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! Remove/comment if you have RFM69W! --------- DET VIRKER PERFEKT, SÅ LÆNGE JEG KOMMENTERER DENNE LINIE UD, ALTSÅ SÆTTER DEN TIL RFM69W
//*********************************************************************************************

#define ACK_TIME      30 // max # of ms to wait for an ack
#define MOTIONPIN      1 //hardware interrupt 1 (D3)

//#define SERIAL_EN             //comment this out when deploying to an installed SM to save a few KB of sketch size
#define SERIAL_BAUD    115200
#ifdef SERIAL_EN
#define DEBUG(input)   {Serial.print(input); delay(1);}
#define DEBUGln(input) {Serial.println(input); delay(1);}
#else
#define DEBUG(input);
#define DEBUGln(input);
#endif

RFM69 radio;
volatile boolean motionDetected = false;
char sendBuf[32];
byte sendLen;

void setup() {
  Serial.begin(SERIAL_BAUD);
  radio.initialize(FREQUENCY, NODEID, NETWORKID);
#ifdef IS_RFM69HW
 radio.setHighPower(); //uncomment only for RFM69HW!
#endif
  radio.encrypt(ENCRYPTKEY);
  pinMode(MOTIONPIN, INPUT);
  attachInterrupt(MOTIONPIN, motionIRQ, FALLING);
  char buff[50];
  sprintf(buff, "\nTransmitting at %d Mhz...", FREQUENCY == RF69_433MHZ ? 433 : FREQUENCY == RF69_868MHZ ? 868 : 915);
  DEBUGln(buff);
  
}


int detectedNumber = 0; 
const int detectedRequired = 3; 
//----------

void motionIRQ()
{
  
  detectedNumber++;
  
  
  motionDetected = true;
}


void loop() 
{
  
  if (motionDetected = true && (detectedNumber == detectedRequired)); //
  {
    
    detectedNumber = 0; //reset "counter"
    
        
    
    sprintf(sendBuf, "HI");
    sendLen = strlen(sendBuf);

    if (radio.sendWithRetry(GATEWAYID, sendBuf, sendLen));
    {
      DEBUG("HI ACK:OK! RSSI:");
      DEBUG(radio.RSSI);
      
    }
    

     radio.sleep();
    
  }
  
  {
   
  }
  
  motionDetected = false; //do NOT move this after the SLEEP line below or motion will never be detected
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
  
}

Looking at this code, I wonder if you're still moving (AKA getting Pin Interrupts) while you are trying to go to sleep.  If so, you may need to delay sleeping until you are sure the shock sensor is quiescent before you try to sleep - otherwise the system may stay in a high powered state.  You should be able to sleep the radio during the delay (just make sure that you lock out any further reporting until the delay is over) and that should save a significant amount of power.

Tom