ArduinoLoRa 休眠中断唤醒 1.4uA

提示1:锐米所有 LoRa 产品严格遵循国际标准的 LoRaWAN 协议
提示2:您可以免费复制,修改和商用本项目,请注明锐米原创
提示3:如果您有其他 LoRa 需求或建议,欢迎联系锐米 [email protected]

运行效果

LoRa 模组入网后将自动休眠,Arduino 上电后休眠,将电流表串联在上述电路中测量值为 1.4uA。当 Arduino 响应按钮中断时电流增大,随后又进入休眠。

ArduinoLoRaLowPower_INT1.4uA

ArduinoLoRa 休眠中断唤醒 1.4uA_第1张图片

低功耗是核心技术

超过 80% 的 LoRa 终端将由电池供电,这样一来,低功耗将是一个核心的技术挑战,一旦电能耗尽设备将“罢工”,在某些场合电能意味着 LoRa 终端的寿命。

ArduinoLoRa+ 是锐米推出的低成本快速开发 LoRa 终端方案,基于外部中断唤醒工作,它能达到行业第一的低功耗(1.4uA),最大延长电池续航能力。

下面,逐步解密 ArduinoLoRa+ 中断唤醒低功耗是如何实现的。

组件和材料

LoRa 开发板 x 1 采购链接


按钮按钮 x 1 采购链接


电池盒电池盒 x 1 采购链接


南孚 7 号电池7 号电池 x 2 采购链接


鳄鱼夹鳄鱼夹 x 2 采购链接


杜邦线 x 10 采购链接

工具和软件

Arduino IDEArduino IDE 下载链接


下载烧录器下载器 采购链接


数字万用表数字万用表 采购链接

技术细节

烧录休眠唤醒代码

按下表连接 LoRa 开发板 和 下载烧录器

LoRa 开发板 杜邦线 下载烧录器
VCC 3.3
GND GND
RX 绿 TXD
TX RXD
DTR DTR

设置 Arduino IDE

设置 Arduino IDE

编译和烧录下述休眠中断唤醒代码

#include 
 
/* 
 * Example code to demonstrate the sleep functions in a Arduino.
 *
 * use a pull up resistor on pin 2 to 5V.
 * and ground pin 2 momentary to wake it up again.
 *
 * When awake, the arduino will run the ledPin_blink code
 */
 
const int ledPin = 13;  // ledPin connected to digital pin 13
const int wakePin = 2;  // active LOW, ground this pin momentary to wake up
 
/* here we put the arduino to sleep */
void sleepNow()
{
/* Now is the time to set the sleep mode. In the Atmega8 datasheet
 * https://www.atmel.com/dyn/resources/prod_documents/doc2486.pdf on page 35
 * there is a list of sleep modes which explains which clocks and
 * wake up sources are available in which sleep modus.
 *
 * In the avr/sleep.h file, the call names of these sleep modus are to be found:
 *
 * The 5 different modes are:
 *     SLEEP_MODE_IDLE         -the least power savings
 *     SLEEP_MODE_ADC
 *     SLEEP_MODE_PWR_SAVE
 *     SLEEP_MODE_STANDBY
 *     SLEEP_MODE_PWR_DOWN     -the most power savings
 *
 * For now, we want as much power savings as possible,
 * so we choose the according sleep modus: SLEEP_MODE_PWR_DOWN
 *
*/  
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);  // sleep mode is set here
 
  sleep_enable();  // enables the sleep bit in the mcucr register so sleep is possible. just a safety pin
 
/* Now is time to enable a interrupt. we do it here so an
 * accidentally pushed interrupt button doesn't interrupt
 * our running program. if you want to be able to run
 * interrupt code besides the sleep function, place it in
 * setup() for example.
 *
 * In the function call attachInterrupt(A, B, C)
 * A   can be either 0 or 1 for interrupts on pin 2 or 3.  
 *
 * B   Name of a function you want to execute at interrupt for A.
 *
 * C   Trigger mode of the interrupt pin. can be:
 *             LOW        a low level triggers
 *             CHANGE     a change in level triggers
 *             RISING     a rising edge of a level triggers
 *             FALLING    a falling edge of a level triggers
 *
 * In all but the IDLE sleep modes only LOW can be used.
*/
  attachInterrupt(0, wakeUpNow, FALLING);  // use interrupt 0 (pin 2) and run function wakeUpNow when pin 2 gets LOW
 
  sleep_mode();  // here the device is actually put to sleep!!

  /* THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP */
  sleep_disable();  // first thing after waking from sleep: disable sleep...
    
  detachInterrupt(0);  // disables interrupt 0 on pin 2 so the wakeUpNow code will not be executed during normal running time.
}

/* here the interrupt is handledPin after wakeup */
void wakeUpNow()
{
  // execute code here after wake-up before returning to the loop() function
  // timers and code using timers (serial.print and more...) will not work here.
}

void flash()
{
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);
  delay(50);
  digitalWrite(ledPin, LOW);
  delay(50);
  pinMode(ledPin, INPUT);
}

void setup()
{
  ADCSRA = 0;  // disable ADC
  pinMode(wakePin, INPUT);
  digitalWrite (wakePin, HIGH);  // enable pull-up
}
 
void loop()
{
  flash();
  sleepNow();
}

硬件接线

如下图所示,使用杜邦线连接 LoRa 开发板和按钮,并使用电池供电。

ArduinoLoRa 休眠中断唤醒 1.4uA_第2张图片

你可能感兴趣的:(LoRaDevice,LoRaWAN,LoRa,LoRaWAN,Arduino,物联网,超低功耗)