Greetings, I am an embedded systems developer for the SmartHome project at Washington State University. We are attempting to implement a method to track item movement and have chosen the Shimmer2r platform for this.
Currently we have a SPAN device setup as a base station which receives information from the Shimmer2r devices that track motion of objects, however, the battery does seem to only last for about a day at most and I believe the radio, even though I have not wired the receive modules, is remaining on in between transmissions. The Shimmer 2r devices only need to send out a packet stating when the object it is attached to is "in motion" and "not in motion", and don't need to receive any packets. Our current use for the Shimmer2r devices is to track item use and motion and relay that information back to a computer with a SPAN device plugged in that is loaded with the BaseStation code that is located in the tinyos-2.0/apps/BaseStation directory with a nodeID of 0xFF00. There is then a Python program that retrieves the information from the USB port and logs and performs actions with that data. The tilt sensor was a little too sensitive for our use and so a couter and timer was implemented to require the tilt sensor to fire a number of times before a "in motion" message would be sent, then after a few seconds of no movement a "not in motion" message will be sent. I have attempted to implement the power saving features of the radio and tinyos, but have not been successful, it seems some of the calls I am doing are not defined for the CC2420 module for some reason even though I believe I have wired the correct components in. I would really like to implement the low power features of the Shimmer2r and the radio so the devices can run as long as possible without requiring a recharge. The radio really only needs to be active to send the "in motion" and "not in motion" messages and does not need to receive any information. I would like to just disable the receive portions of the radio if that is possible. Also I am using the DS2411 as a serial number for the device and am not sure I am reading the lasered serial number correctly as I only get the lower 4 bytes of it, unless the upper two bytes are zero. If possible I would like to retrieve all 8 bytes, including the family code and CRC byte of the DS2411 chip to be used as the serial number. I believe the CC2420 radios have auto collision detection and retransmittion built in, but not sure if it is done in hardware or that is something that I need to implement in software. My concern is if two of the Shimmer2r devices transmit at the exact same time, will they automatically retry if they have a collision, or is that something that I need to handle in software? I have one concern about the node addressing in the devices. Currently we have the base station SPAN set to 0xFF00, and the Shimmer2r devices starting at 0x0001. Do the nodeIDs have to be unique between the devices? Currently we are using the DS2411 serial number to identify each Shimmer2r, and wondering if it is a problem to have more than one Shimmer2r with the same nodeID. I believe it could interfere with the receipt ack and confuse the nodes if more than one has the same address though. If this is the case, then we can implement a script to increment the nodeID each time a Shimmer2r is programmed. We currently have 24 more Shimmer2r devices on order at this time, which will be used for a deployment soon. As I am still new to the Tinyos platform, if you notice anything that is not optimal or that can be done better, please let me know. Thanks for your time, Allan Drassal Washington State University =================================== ShakeWirelessLpApp.nc =================================== /** * @author Allan R Drassal <[email protected]> * @date August 24, 2010 */ #include "ShakeWirelessLp.h" configuration ShakeWirelessLpAppC { } implementation { components MainC, ShakeWirelessLpC, LedsC, TiltDetectorC, HplDs2411C; components new TimerMilliC() as Timer; components ActiveMessageC; components new AMSenderC(AM_SHAKEWIRELESSRADIO); components ShakeWirelessLpC as App; components CC2420ActiveMessageC as LPLProvider; App -> MainC.Boot; App.Leds -> LedsC; App.Tilt -> TiltDetectorC; App.Timer -> Timer; App.Packet -> AMSenderC; App.AMPacket -> AMSenderC; App.AMSend -> AMSenderC; App.AMControl -> ActiveMessageC; App.IDChip -> HplDs2411C; App.LPL -> LPLProvider; } =================================== ShakeWirelessLc.nc =================================== /** * @author Allan R Drassal <[email protected]> * @date August 24, 2010 */ #include "UserButton.h" #include "ShakeWirelessLP.h" module ShakeWirelessLPC { uses interface Boot; uses interface Leds; uses interface Notify<button_state_t> as Tilt; uses interface Timer<TMilli>; uses interface Packet; uses interface AMPacket; uses interface AMSend; uses interface SplitControl as AMControl; uses interface IDChip as IDChip; uses interface LowPowerListening as LPL; } implementation { uint8_t counter = 0; bool moving = FALSE; bool busy = FALSE; message_t pkt; uint8_t hw_address[9]; event void Boot.booted() { // get the DS2411 address call IDChip.read(hw_address); // start the radio call LPL.setLocalSleepInterval(LPL_INTERVAL); call AMControl.start(); // enable the tilt sensor call Tilt.enable(); } task void MsgMoving() { if (!busy) { ShakeWirelessMsg* btrpkt = (ShakeWirelessMsg*)(call Packet.getPayload(&pkt, NULL)); btrpkt->nodeid = TOS_NODE_ID; btrpkt -> nodeid_0 = hw_address[0]; btrpkt -> nodeid_1 = hw_address[1]; btrpkt -> nodeid_2 = hw_address[2]; btrpkt -> nodeid_3 = hw_address[3]; btrpkt -> nodeid_4 = hw_address[4]; btrpkt -> nodeid_5 = hw_address[5]; btrpkt -> data = MSG_MOVING; btrpkt -> terminator = MSG_TERMINATOR; call LPL.setRxSleepInterval(&pkt, 0); if (call AMSend.send(AM_ACCESSPOINT_ADDR, &pkt, sizeof(ShakeWirelessMsg)) == SUCCESS) { busy = TRUE; } } else { post MsgMoving(); } } task void MsgNotMoving() { if (!busy) { ShakeWirelessMsg* btrpkt = (ShakeWirelessMsg*)(call Packet.getPayload(&pkt, NULL)); btrpkt->nodeid = TOS_NODE_ID; btrpkt -> nodeid_0 = hw_address[0]; btrpkt -> nodeid_1 = hw_address[1]; btrpkt -> nodeid_2 = hw_address[2]; btrpkt -> nodeid_3 = hw_address[3]; btrpkt -> nodeid_4 = hw_address[4]; btrpkt -> nodeid_5 = hw_address[5]; btrpkt -> data = MSG_NOTMOVING; btrpkt -> terminator = MSG_TERMINATOR; call LPL.setRxSleepInterval(&pkt, 0); if (call AMSend.send(AM_ACCESSPOINT_ADDR, &pkt, sizeof(ShakeWirelessMsg)) == SUCCESS) { busy = TRUE; } } else { post MsgNotMoving(); } } event void Tilt.notify(button_state_t state) { if (counter == 3) { call Timer.startOneShot( TIMER_PERIOD_MILLI ); if (!moving) { call Leds.led2On(); moving = TRUE; post MsgMoving(); } } else { counter++; } } event void Timer.fired() { call Leds.led2Off(); counter = 0; moving = FALSE; post MsgNotMoving(); } event void AMControl.startDone(error_t err) { // check if the radio started, if it is not, then try again if (err != SUCCESS) { call AMControl.start(); } } event void AMControl.stopDone(error_t err) { } event void AMSend.sendDone(message_t* msg, error_t error) { if (&pkt == msg) { busy = FALSE; } } } =================================== ShakeWireless.h =================================== /** * @author Allan R Drassal <[email protected]> * @date August 24, 2010 */ #ifndef SHAKEWIRELESS_H #define SHAKEWIRELESS_H typedef nx_struct ShakeWirelessMsg { nx_uint16_t nodeid; nx_uint8_t nodeid_0; nx_uint8_t nodeid_1; nx_uint8_t nodeid_2; nx_uint8_t nodeid_3; nx_uint8_t nodeid_4; nx_uint8_t nodeid_5; nx_uint8_t data; nx_uint8_t terminator; } ShakeWirelessMsg; enum { AM_SHAKEWIRELESSRADIO = 6, TIMER_PERIOD_MILLI = 1000, MSG_MOVING = 0x01, MSG_NOTMOVING = 0x00, AM_ACCESSPOINT_ADDR = 0xFF00, MSG_TERMINATOR = 0x0A, LPL_INTERVAL = 2000, }; #endif =================================== TiltDetectorC.nc =================================== #include <UserButton.h> configuration TiltDetectorC { provides interface Notify<button_state_t>; } implementation { components HplTiltDetectorC; components new SwitchToggleC(); SwitchToggleC.GpioInterrupt -> HplTiltDetectorC.GpioInterrupt; SwitchToggleC.GeneralIO -> HplTiltDetectorC.GeneralIO; components UserButtonP; Notify = UserButtonP; components new TimerMilliC() as debounceTimer; UserButtonP.NotifyLower -> SwitchToggleC.Notify; UserButtonP.debounceTimer -> debounceTimer; } =================================== HplTiltDetectorC.nc =================================== configuration HplTiltDetectorC { provides interface GeneralIO; provides interface GpioInterrupt; } implementation { components HplMsp430GeneralIOC as GeneralIOC; components HplMsp430InterruptC as InterruptC; components new Msp430GpioC() as TiltDetectorC; TiltDetectorC -> GeneralIOC.Port24; GeneralIO = TiltDetectorC; components new Msp430InterruptC() as InterruptTiltDetectorC; InterruptTiltDetectorC.HplInterrupt -> InterruptC.Port24; GpioInterrupt = InterruptTiltDetectorC.Interrupt; } =================================== Makefile =================================== COMPONENT=ShakeWirelessLpAppC #CFLAGS+=-DCC2420_HW_ACKNOWLEDGEMENTS #CFLAGS+=-DPACKET_LINK #CFLAGS+=-DTOSH_DATA_LENGTH=114 #CFLAGS+=-I%T/lib/printf #CFLAGS+=-DCC2420_HW_SECURITY #CFLAGS+=-DCC2420_DEF_CHANNEL=0x1A #CFLAGS+=-DRF230_DEF_CHANNEL=0x1A CFLAGS += -DLOW_POWER_LISTENING -DLPL_SLEEP_INTERVAL=512 include $(MAKERULES)
_______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
