Monthly Archives: December 2013

WSN application – cutting down on energy wastage

I live in Bangalore . There is a clubhouse in our community. I have noticed couple of times that the ceiling A/C is on while some windows are open. This is a real waste of electricity which can be prevented by a simple monitoring system. If any window or door is open and the A/C is on, send an alarm to the person in charge. The alarm can be a simple SMS.

What do we need ?

  • A coin battery powered wireless sensor node for each door and window. Each node will have a reed-switch to determine if the door/window is open or closed.
  • A  coin battery powered wireless node  installed near each A/C unit. This node will use a temperature sensor to determine if the A/C unit is on or not.
  • A gateway node which can send an SMS. This will be mains powered.

The system can be enhanced to send an alarm if the A/C is being switched on unnecessarily. This requires lot more intelligence though. Outdoor/indoor temperature and humidity sensors can help in making correct decisions.

Lighting is another big source of wastage.  Lights get left on in empty rooms.  Motion activated lights can be used for this purpose.  Lights get switched on even when the area is well lit during the day.  An easy solution is to use ambient light sensors and time of day information.

Automatic  control of  lights, fans and A/C units can become pretty expensive. The cheaper way out is to only monitor and send out an SMS to the person in charge of the facility. This is feasible in India since there is always a security person around.

At WiSense we are always looking for opportunities to use our sensor network technology to reduce/prevent wastage. Can you think of any scenario which can benefit from low cost sensor networks ? Let us know.

Sensor Interfacing

Most sensors available today support one or more of the interfaces listed below –

  • Logic out  (e.g. – EKMC1601112 PIR motion sensor from Panasonic)
  • 1-wire Bus (e.g.- DS1822 temperature sensor from MAXIM)
  • I2C Bus  (e.g.- LM75B temperature sensor from NXP)
  • SPI Bus  (e.g.- MPL115A1 barometer from Freescale)
  • UART  (e.g.- MB1010 LV-MaxSonar-EZ1 from Maxbotix)
  • Analog out  (e.g.- MP3V5050GP  ported pressure sensor from Freescale)

Sensors with “digital” outputs are the easiest to interface.  These sensors do all the hard work of converting analog measurements (representing a physical phenomenon such as ambient temperature) into the digital domain. You don’t have to be expert in electronics to work with such sensors. On the other hand, analog sensors are not that easy to interface. You have to worry about signal amplification, loading, analog to digital conversion, voltage level compatibility, sampling time, noise filtering, power supply etc. In short you need to be an expert in  electronics. Some “analog” sensors do provide a buffered and filtered voltage output compatible with the micro’s ADC input voltage range. In this case you just need to hook up the sensor’s output to any available ADC channel on the micro. You still need to understand concepts such as sensor output impedance, minimum sampling time requirement, ADC clocking, reference voltage, ADC power consumption etc. You get the point. If you are more of a software person, choose sensors with digital output. Needless to say, “digital” sensors are more expensive compared to “analog” ones.

There is a lot of information on the web about each of the interfaces listed above. I am not going to repeat it here.

WiSense nodes support all the interfaces listed above.

WiSense nodes are designed around two variants of MSP430 family (MSP430G2553 and MSP430G2955).  These are part of the recently introduced value line series.  These variants  are relatively inexpensive since they have limited memory and hardware functionality.  WiSense nodes implement the I2C and 1-wire protocol in software since the corresponding hardware resources are used by the SPI bus and the UART interface. We have already implemented and tested these protocols with different sensors. You can  use the corresponding libraries to interface with compatible sensors.

WISAN Network Architecture

The WiSense sensor-actuator network  (WISAN) has three types of nodes.

The network coordinator (NC) – There is only one such node in a WISAN. This node is responsible for starting and maintaining the network. It allocates short addresses to any node which joins the network. It also serves as the default gateway between a WISAN and the outside world. The NC  needs to be active at all times which means it will usually be mains powered.  An active node in sensor network terminology is one whose radio is always on. The NC participates in multi-hop mesh routing.

Full function node (FFN) – There can be more than one node of this type in a WISAN. An FFN takes part in multi-hop mesh routing. When an FFN receives a packet which is not intended for it, it will forward the packet if it has a route to the destination. Each FFN maintains a routing table. Apart from routing, a FFN can run user applications for sensing and actuation. FFNs need to be active at all times since they participate in mesh routing. They will usually be A/C powered. They can also be solar powered with battery back if installed outdoors. The panels must be able to produce sufficient energy and the batteries should have enough capacity to keep the node powered on during night time and through overcast/cloudy days.

Reduced function node (RFN) – There can be more than one node of this type in a WISAN.  An RFN does not participate in mesh routing. Each RFN has a parent through which it communicates with the rest of the WISAN.  Since RFNs  do not participate in routing they do not have to be in active mode all the time. RFNs mostly stay in deep sleep mode in which both the radio and microcontroller are put in low power consumption mode. This allows RFNs to reduce power consumption to a minimum and extend battery life. Depending on the application, an RFC can run on a 3 Volt coin cell battery for more than an year assuming it stays in deep sleep most of the time (more than 99.99 %). You can estimate battery life by calculating the average power consumption of an RFN. RFNs can be powered using very small solar panels and rechargeable batteries. High efficiency solar panels are available which can also work in indoors. This will extend the node’s battery life considerably only limited by battery chemistry.






Each node in a WISAN has two types of addresses. The first is a unique 64 bit extended address permanently allocated to a node.  WiSense provides this address. The other is a temporary 16 bit “short” address allocated by the network coordinator (NC) to each node which joins a WISAN.  If the same node leaves a WISAN and rejoins, the NC will allocate a different 16 bit short address to it.  The NC assigns itself the short address “1”. Address “0” is not allocated to any node.

WISAN routing uses 16 bit short addresses. The routing table on the NC or an FFN is a set of entries each of which has this pair <destination short address, short address of the next hop> among other information.

For example , the routing table on the NC can look like this –

Destination  short address               Next -Hop short address

  1. 0x0002                                                           0x0002
  2. 0x0003                                                           0x0002
  3. 0x0004                                                           0x0002

In the table shown above, we have three entries in the routing table. The first entry implies that node with short address 0x2 is directly reachable (it is a neighbor).  The second entry implies that node with short address 0x3 is not a neighbor to the NC and is reachable through node 0x2.  Similarly the third entry implies that node with short address 0x4 is not a neighbor to the NC and is reachable through node 0x2.

The routing table on any node (other than RFNs) is populated with the help of a routing protocol.  WISAN uses LOAD-ng which is fairly easy to understand compared to some other routing protocols such as RPL. You can take a look at the LOAD-ng spec here (

The WiSense software stack runs on an MSP430 microcontroller. Currently we use two variants. One is the MSP430G2553 with 16 KB flash and 512 bytes of RAM. The other is the MSP430G2955 with 48 KB flash and 4 KB of RAM.

Measuring Relative Humidity

Ambient humidity is an important atmospheric parameter. Humidity measurement and control is critical in wide ranging industrial and medical applications. Let’s begin with a review of some basic concepts to learn about humidity and how it changes.

Humidity refers to the amount of water vapor present in air. When water evaporates, it turns to an invisible gaseous state, called water vapor. Absolute humidity is measured in grams per cubic meter. Typically, the amount of water vapor present in air is dependent on the temperature of the air. Higher the temperature, more water can evaporate into it. The pressure exerted by the water vapor is called vapor pressure . When no more water can be evaporated into air, then the air is called saturated.

Relative Humidity (RH) is a more useful metric for describing the vapor content of air. It indicates how close to saturation the air is. RH is given as a percent. So, 100% means that the air is saturated and 0% means that the air is completely dry. When we think of controlling moisture or vapor, it is RH that we should be measuring and controlling. For instance, for building climate control, RH values of 50-60% are considered to be ideal for human comfort.

How is Relative Humidity Measured?

There are many ways to measure the RH of air. Two commonly used techniques in commercial RH sensors are:


1. Capacitive Sensor: This sensor is based on the principle of change in capacitance with change in relative humidity. In these sensors, the capacitance increases when RH increases.  Typically, the capacitance increases linearly with relative humidity, making it a useful principle to deduce the humidity. The change in capacitance is due to the change in the dielectric constant of the material used in the sensor. The main limitation of these type of sensors is that they lose accuracy at very low (less than 5%) or very high (greater than 90%) RH values. Also, the range of capacitance between 0 and 100% RH may be so high that circuit designs could be complicated.

2. Resistive Sensor: This sensor is based on the principle of change in impedance with change in relative humidity. The material used is hygroscopic (one that absorbs water) whose impedance varies with RH. Typically, the relationship is inverse. i.e., impedance drops as RH increases.

Image source:


Build a networked soil moisture sensor for your garden

If you are into gardening, this can be a fun project. Sometimes you forget to water plants and they droop. What if you could get an SMS on your phone reminding you to water the dehydrated plant.

You need the following for this project –

  • A simple moisture sensor. You can build a simple one yourself or buy one online. I have not found any in Bangalore yet.
  • At least two WiSense nodes. The “sensor” node will have a moisture sensor attached to it. The other node will be part of a “WiSense network <-> WiFi” gateway. The “sensor” node can be powered by a coin cell or could be solar powered if the node is going to be outdoors.

The challenge is in building a reliable soil moisture sensor. There are plenty of ideas on the net.   A simple sensor can monitor the electrical resistance between two nails embedded in the soil. Resistance decreases as soil moisture increases. The on board ADC on the MSP430 can be used to determine the resistance across the two conductors through a voltage divider circuit.

You need to write a simple application which will run on the “sensor” node’s micro-controller. This app can measure soil resistance periodically and send out an alarm message to the “gateway” node only when the  resistance value climbs above a threshold. It will take some trial and error to arrive at the correct threshold.  The application should keep sending alarms periodically until it detects a “watering” event (a sudden decrease in soil resistance).

I am wondering if temperature, humidity and ambient light sensors can help predict plant growth.

Build a DIY sensor-actuator network for your home

A sensor-actuator network is just a fancy name for a network which can observe as well as change the surrounding environment. Observation implies measuring some physical phenomenon such as temperature or humidity or detecting an event such as the closing or opening of a door.  Motion activated lighting is a simple example of a sensor-actuator network where ambient light condition is being sensed and actuation involves switching on/off light sources.

The WiSense low power wireless network platform can be used to build a low cost DIY sensor-actuator network.  WiSense nodes are modular. You can build a sensor node by stacking multiple boards. This stack will typically have a microcontroller board, a radio board,  a battery board and one or more sensor boards. We use high quality board to board connectors so that stacking is effortless. This design is a trade-off between the ability to reuse/upgrade nodes and higher overall cost per node.



You can build your own add on boards and write your own software.  WiSense nodes do not use ZigBee. We have written all the layers (802.15.4 MAC, networking and application) from scratch. You are free to modify the WiSense network stack to suit your needs.

We are planning to host an application store where you can sell your add on boards and associated  software.  WiSense can help in design, testing and manufacturing.  You will also be able to buy a wide variety of add on sensor boards from us. We are also looking at powering WiSense nodes using small but highly efficient solar cells.

We hope that our efforts will make such networks accessible and affordable to DIYers everywhere.

Build a motion detector using the EKMC1601112

This EKMC1601112 is a passive infra red (PIR) motion sensor.  It detects variations in IR energy in its field of view. You can learn about PIR sensors at “” and ““.

We have bought a bunch of these sensors. We interfaced one to a WiSense sensor node.  We wrote a simple app which sends out an alarm messages to an app outside the WiSense network whenever the sensor detects motion. The sensor worked as expected.


This sensor can be interfaced to a micro through an interrupt capable GPIO pin. The sensor’s output stays low as long as it does not detect any motion in it’s field of view.  When the sensor detects motion, the output pin goes high. The output goes back to low when the sensor adjusts to the new IR energy level in it’s field of view.  The GPIO pin should be configured to raise an interrupt on a positive edge (GPIO pin goes from low to high).  On a reduced function device (running on battery), any motion will wake up the micro. The application entity on the sensor node can then take appropriate action.


We have written a simple driver which interfaces with this sensor. The software implementation is divided between a driver and an application level entity (app). The driver initializes the GPIO pin allocated to this device, handles interrupts and informs the “app” whenever motion is detected. The app can then take appropriate action. Typically it will send out an alarm message to interested application entities within and outside the WiSense sensor network. It will then request the system layer to put the node back into deep sleep only waking up the next time motion is detected.

This sensor costs between $8 and $10 from different distributors.

The current consumption of this sensor (~ 200 microamperes)  is not trivial. There is another WL series (from Panasonic) with average current consumption of less than 1 microamps but it is twice as expensive. Look up EKMB1101111.


  • Manufacturer: Panasonic
  • Part Number:  EKMC1601112 (VZ series)
  • Pins: Vcc, Gnd and Vout
  • Interface: Digital out (Simply connect Vout pin to one of Micro’s interrupt capable GPIO pins)
  • Range:  Distance (5 meters), Field of view (94 Deg x 82 Deg)
  • Power supply: 3.0 Volts to 6.0 Volts
  • Current consumption:  170  micro-amperes
  • Datasheet:

Build a door alarm using a reed switch

A reed switch can be switched  on/off by applying a magnetic field.  You can read up on reed switches here –  Reed switches can be normally open or normally closed.


We bought some reed switches and magnets from Digikey. Found one local vendor ( while writing this post.

Let’s build a simple door alarm using a “normally open” reed switch, a small magnet and a WiSense sensor node. Let’s assume that the sensor node is powered by a coin cell battery.  We can use one plastic enclosure to house the sensor node and the reed switch. We also need a tiny enclosure to house the magnet.


When installing the magnet and the sensor/switch enclouse, make sure that the magnet is sufficiently close to the reed switch when the door is in the closed position.

Obviously we want the battery to last as long as possible.  The micro (MSP430) and the radio (cc2520) on the sensor node should stay in deep sleep as much as possible.  We need an interface circuit which will generate an interrupt on a GPIO pin whenever the switch changes state. This will wake up the micro-controller (from its deep sleep mode) whenever the switch opens or closes. This technique keeps energy consumption to a minimum. It also ensures that the device immediately reacts whenever the door being monitored opens or closes.


In the circuit shown above, when the reed switch is open, the GPIO pin is pulled high to Vcc.  So when the door is open, there is no magnetic field acting on the switch and it stays open. When the door is closed, the magnetic field closes the switch which pulls the GPIO pin to ground. When the doors opens, we expect the GPIO pin to go from low to high sending a positive edge triggered interrupt to the micro. When the door closes, we expect the GPIO pin to go from high to low sending a negative edge triggered interrupt to the micro. Things are not as simple because of a phenomenon called switch bounce. I will explain this in another post.

It is important to remember that not all ports on the MSP430 are interrupt capable. WiSense sensor nodes use either MSP430G2553 or MSP430G2955. In both variants, only ports P1 and P2 have interrupt capability.  I have a few useless PCBs lying around which were designed on the assumption that all ports have interrupt capability.

Let us divide the software implementation of this alarm between a reed-switch specific driver and an application layer entity (app).  The driver will be responsible for initializing the GPIO pin allocated to the switch, handling the interrupt, debouncing the switch and finally informing the application about the new state of the switch. Once the application is informed about the state change, it can take any action according to the requirement of the alarm.  Typically it will send a message indicating the new state of the door to any interested application entity within or outside the WiSense sensor network.  If the WiSense sensor network has an interface to the internet, an SMS can be sent to the property owner. In addition a message can be sent (through the WiSense network) to an AC powered alarm siren. Once the application has successfully sent out the message, it should allow the node to go back to deep sleep mode.

We have written a simple library for this switch. Refer to the files listed below. You can access the sensor_framework repository at

  • “sensor_fw/pltfrm/src/reed_switch.c”
  • “sensor_fw/pltfrm/inc/reed_switch.h”


MP3V5050GP – ported pressure sensor


The MP3V5050GP is an integrated Silicon Pressure Sensor, On-Chip Signal Conditioned, Temperature Compensated and Calibrated.

You can use this sensor to monitor the water level in a container. It’s range is from 0 to 50 kPa. The equivalent height of a  column of water is around 17 feet !! . You can use this sensor to monitor the water level in one of those big PVC tanks on the terrace if you are lucky enough to have one. Note that this device is a gauge type pressure sensor. Such sensors measure pressure with respect to atmospheric pressure.  The output of the sensor is proportional only to the pressure of the water column inside the tank.

This sensor has a barbed port which can be fitted with a tube. The other end of the tube should lie  at the bottom of the tank. This can be done by attaching a small weight to the open end of the tube. The weight is necessary since the tube has a tendency to float. The sensor can thus be attached to the outside of the tank with only the tube exposed to water. Note that the sensor does not and should not come in contact with water even through the pressure port. When the tube (with one end attached to the sensor’s port) is immersed in water, air gets trapped inside the tube. The pressure of the water compresses this air.  This compressed air transmits the water pressure to the sensor.

We have imported 100 feet of Tygon lab tubing from Cole Palmer. This tube’s inner dia is 3/32 inches and outer dia is 5/32 inches. It is a perfect fit for the MP3V5050GP. Once we attached the tube to the sensor, we could not detach it.  We tested the the output of the sensor with a voltmeter. As expected, the output tracked the water level in a bucket.

We now have a easy way to monitor the water level in a tank. Attach this sensor to a solar powered WiSense node and get water level alerts on your phone.


Power consumption is an issue. According to the spec, it’s current consumption is max 10 milli-amps which is not insignificant if battery powered. The sensor does not have a low power / shut down mode. It is always sensing. One way is to use a load switch to turn off power to the sensor.  The load switch can be controlled through a GPIO pin.

This sensor is not cheap. Digikey is selling it at $10 if you buy 10. The cost drops to $ 6.0 if you buy 100.


  • Manufacturer: Freescale
  • Part Number: MP3V5050GP
  • Package: 8 Lead SOT  (Surface-mount Device)
  • Pins: Vcc, Gnd and Vout
  • Interface: Analog voltage
  • Range:  0 kPa to 50 kPa
  • Accuracy: +/-  2.5 % VFSS
  • Power supply: 2.7 Volts to 3.3 Volts
  • Current consumption:  10 milli-amperes max
  • Data sheet:

LM75B – Temperature Sensor

lm75b_pic    lm75b_ol


The LM75B is a temperature-to-digital converter using an on-chip band gap temperature sensor and Sigma-Delta A-to-D conversion technique with an over temperature detection output.

This device will measure the ambient temperature with the specified accuracy assuming that the host PCB is at the same temperature as the surrounding air.

The current version (Version A) of the WiSense wireless sensor node uses this sensor.

This sensor is relatively inexpensive (less than $ 0.5 @ 100).

We have written a simple library for this sensor. Refer to the files listed below.

  • “sensor_fw/pltfrm/src/lm75b.c”
  • “sensor_fw/pltfrm/inc/lm75b.h”.
  • “sensor_fw/app/src/app.c”

Let us walk through a simple use case. On a battery operated node, the sensor should mostly stay in the “SHUTDOWN” mode in which it will consume less than 1 microampere of current. Periodically, the node’s microcontoller will wake up from deep sleep and change the sensor’s operating mode to “NORMAL”. This will trigger a single conversion. The microcontroller should wait for at least 10 milli-seconds (the conversion time specified in the spec) after which it can read the temperature register to get the latest value of the temperature “sensed” by the device. After reading this value, the sensor should be put back into “SHUTDOWN” mode. If this temperature value needs to be reported to some application within or outside the sensor network, the node should wake up the radio (cc2520), send out a message over the air, shutdown the radio (enter cc2520 low power mode LPM2) and put the microcontroller back into low power mode (LPM3 on MSP430).


  • Manufacturer: NXP
  • Part Number: LM75DBP
  • Package: TSSOP8 (Surface-mount Device)
  • Dimensions: 3 mm x 5.1 mm
  • Interface: Two Wire I2C Bus
  • Output format: 11 bit two’s complement (in units of .125 Deg C)
  • Range: -55 Deg C to +125 Deg C
  • Accuracy: +/- 3 Deg C
  • Power supply: 2.8 Volts to 5.5 Volts
  • Temperature to data conversion time:  10 milli-seconds

Current consumption

  • Shutdown mode (< 1 microamperes)
  • Normal mode (< 300 microamperes)

I2C specific:

  • I2C address configuration pins: 3  (Allows up to 8 such devices on one bus)
  • I2C 4-bit address prefix: 1001b
  • Frequency range 20 Hz to 400 kHz. The lower limit is important since we have implemented the I2C interface in software on the WiSense sensor nodes. This rules out single stepping through the I2C code. Refer to section 7.2.1 (Bus fault time-out) in the device spec. In any case, you should not have to debug the code since we have already tested it.

Operating modes:

  • Normal mode (continuous conversion). In this mode, the temp-to-digital conversion is executed every 100 milli-seconds. The conversion itself takes only 10 milli-seconds. The device automatically enters and stays in low power consumption mode for the remaining 90 milli-seconds.
  •  Shutdown mode (conversion suspended).  This is low power consumption mode. Only the I2C interface remains active allowing register write/read operation to be performed.

Other features:

  • The device also includes an open-drain output (OS) which becomes active when the temperature exceeds the programmed limits.

Data sheet:

Coming soon …..

I will post some graphs (from the WiSense GUI) on this sensor’s response time to changing conditions. I will be using two or more WiSense nodes and the fridge at home.