DigiMesh Power Management using Pin Sleep example for mbed XBeeLib By Digi

Dependencies:   XBeeLib mbed

Fork of XBeeZB_power_mngmnt_pin_sleep by Digi International Inc.

Description

This example characterizes a device that after taking samples from some sensors and sending the information collected through the radio, does nothing for a long period of time that could range from several minutes to several hours.
In that long period of inactivity it's not expected to have communication with the coordinator or other remote devices. The device will not be able to receive packets and should save as much power as possible, therefore the radio is set into low power.

The example does following cycle endlessly:

  • Some sensor is read. For demonstration, a counter is incremented.
  • For demonstration, a message containing the data collected during sampling stage is sent to a remote device.
  • After job has been done the radio will go to sleep:
  • First radio is requested to go to sleep. When radio finally sleeps, then the application waits for the time configured in the SLEEP_SECONDS define (40 seconds).
  • This time can be increased as desired.
  • After that time, the application will awake the radio through the On/Sleep pin and another cycle will start by taking a sample.

Setup

Application

Define RADIO_SLEEP_REQ and RADIO_ON_SLEEP in config.h file according to the mbed micro-controller GPIOs that will be used to control the XBee module power.

Hardware

It's necessary to wire following connections from the mbed micro-controller to the XBee radio according to the configuration done in the application:

  • From the mbed micro-controller RADIO_SLEEP_REQ to the XBee module SLEEP_RQ pin (pin 9 on THT modules, pin 10 on SMT modules) will allow the mbed micro-controller to request the radio to sleep or awake.
  • From the mbed micro-controller RADIO_ON_SLEEP to XBee module ON/SLEEP# pin (pin 13 on THT modules, pin 26 on SMT modules) will allow the mbed micro-controller to know if the radio is awake or slept.

Demo run

While the demo is running, you will see the frames sent by the XBee module through the serial console terminal.

Verify that the remote device is receiving the frames by accessing the "Console" tab of the XCTU.
If the frames are successfully sent, they will be displayed there, every 40 seconds.

     Sensor sample: 0, next sample in 40 seconds
     Sensor sample: 1, next sample in 40 seconds
Committer:
hbujanda
Date:
Mon May 11 18:03:48 2015 +0200
Revision:
0:5e030e8ab809
Automatic upload

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hbujanda 0:5e030e8ab809 1
hbujanda 0:5e030e8ab809 2 #if !defined(__CONFIG_H_)
hbujanda 0:5e030e8ab809 3 #define __CONFIG_H_
hbujanda 0:5e030e8ab809 4
hbujanda 0:5e030e8ab809 5 #define PATFORM_ARCHPRO
hbujanda 0:5e030e8ab809 6
hbujanda 0:5e030e8ab809 7 /** Library configuration options */
hbujanda 0:5e030e8ab809 8 #define ENABLE_LOGGING
hbujanda 0:5e030e8ab809 9 #define ENABLE_ASSERTIONS
hbujanda 0:5e030e8ab809 10 #define FRAME_BUFFER_SIZE 10
hbujanda 0:5e030e8ab809 11 #define MAX_FRAME_PAYLOAD_LEN 128
hbujanda 0:5e030e8ab809 12 #define ENABLE_PM_SUPPORT
hbujanda 0:5e030e8ab809 13
hbujanda 0:5e030e8ab809 14 #define SYNC_OPS_TIMEOUT_MS 2000
hbujanda 0:5e030e8ab809 15
hbujanda 0:5e030e8ab809 16 #if defined(PATFORM_ARCHPRO)
hbujanda 0:5e030e8ab809 17 #define RADIO_TX P4_28
hbujanda 0:5e030e8ab809 18 #define RADIO_RX P4_29
hbujanda 0:5e030e8ab809 19 #define RADIO_RESET P2_13
hbujanda 0:5e030e8ab809 20 //#define RADIO_RESET NC
hbujanda 0:5e030e8ab809 21 #define RADIO_SLEEP_REQ NC
hbujanda 0:5e030e8ab809 22 #define RADIO_ON_SLEEP NC
hbujanda 0:5e030e8ab809 23 #define DEBUG_TX P0_2
hbujanda 0:5e030e8ab809 24 #define DEBUG_RX P0_3
hbujanda 0:5e030e8ab809 25 #elif defined(TARGET_LPC1768)
hbujanda 0:5e030e8ab809 26 #define RADIO_TX p9
hbujanda 0:5e030e8ab809 27 #define RADIO_RX p10
hbujanda 0:5e030e8ab809 28 #define RADIO_RESET p30
hbujanda 0:5e030e8ab809 29 #define RADIO_SLEEP_REQ NC
hbujanda 0:5e030e8ab809 30 #define RADIO_ON_SLEEP NC
hbujanda 0:5e030e8ab809 31 #define DEBUG_TX P0_2
hbujanda 0:5e030e8ab809 32 #define DEBUG_RX P0_3
hbujanda 0:5e030e8ab809 33 #elif defined(TARGET_FRDM_KL25)
hbujanda 0:5e030e8ab809 34 #define RADIO_TX PTD3
hbujanda 0:5e030e8ab809 35 #define RADIO_RX PTD2
hbujanda 0:5e030e8ab809 36 #define RADIO_RESET NC
hbujanda 0:5e030e8ab809 37 #define RADIO_SLEEP_REQ NC
hbujanda 0:5e030e8ab809 38 #define RADIO_ON_SLEEP NC
hbujanda 0:5e030e8ab809 39 #define DEBUG_TX USBTX
hbujanda 0:5e030e8ab809 40 #define DEBUG_RX USBRX
hbujanda 0:5e030e8ab809 41 #elif (defined TARGET_LPC11U24)
hbujanda 0:5e030e8ab809 42 #define RADIO_TX p9
hbujanda 0:5e030e8ab809 43 #define RADIO_RX p10
hbujanda 0:5e030e8ab809 44 #define RADIO_RESET p30
hbujanda 0:5e030e8ab809 45 #define RADIO_SLEEP_REQ NC
hbujanda 0:5e030e8ab809 46 #define RADIO_ON_SLEEP NC
hbujanda 0:5e030e8ab809 47 #define DEBUG_TX USBTX
hbujanda 0:5e030e8ab809 48 #define DEBUG_RX USBRX
hbujanda 0:5e030e8ab809 49 #else
hbujanda 0:5e030e8ab809 50 #error "Define a platform"
hbujanda 0:5e030e8ab809 51 #endif
hbujanda 0:5e030e8ab809 52
hbujanda 0:5e030e8ab809 53 #endif /* __CONFIG_H_ */
hbujanda 0:5e030e8ab809 54