Programming

Waspmote Plug & Sense! can be programmed using Libelium's Integrated Development Environment (IDE).

For further details on how to install the Waspmote IDE and how to compile and upload your first programs, we advise to read the "Waspmote IDE: User Guide". This guide contains step-by-step indications to get started; it can be found on the Plug & Sense! Development section:

https://development.libelium.com/plug-and-sense/software

Real Time Clock - RTC

Waspmote Plug & Sense! has a built-in Real Time Clock -- RTC, which keeps it informed of the time. This allows to program and perform time-related actions such as:

"Sleep for 1h 20 min and 15sec, then wake up and perform the following action.."

Or even programs to perform actions at absolute intervals, e.g.:

"Wake on the 5th of each month at 00:20 and perform the following action.."

All RTC programming and control is done through the I2C bus.

Alarms:

Alarms can be programmed in the RTC specifying day/hour/minute/second. That allows total control about when the mote wakes up to capture sensor values and perform actions programmed on it. This allows Waspmote Plug & Sense! to be in the saving energy mode (Deep Sleep) and makes it wake up just at the required moment.

As well as relative alarms, periodic alarms can be programmed by giving a time measurement, so that the node reprograms its alarm automatically each time one event is triggered.

Waspmote Plug & Sense! can keep the RTC time correctly even if the on/off button is switched to off position.

RTC module has an internal compensation mechanism for the oscillation variations produced in the quartz crystal by changes in temperature (Temperature Compensated Crystal Oscillator -- TCXO).

The RTC is responsible for waking the node up from energy saving mode called Deep Sleep. In addition, it controls when it has to wake up the node and perform a particular action.

All information about their programming and operation can be found in the RTC Programming Guide. All the documentation is located in the Development section in the Libelium website.

Interruptions

Interruptions are signals received by the microcontroller which indicate it must stop the task it is doing to handle an event that has just happened. Interruption control frees the microcontroller from having to control sensors all the time. It also makes the sensors warn Waspmote Plug & Sense! when a determined value (threshold) is reached.

Waspmote Plug & Sense! is designed to work with two types of interruptions: Synchronous and asynchronous:

  • Synchronous interruptions: They are scheduled by timers. They allow to program when we want them to be triggered. There are two types of timer alarms: periodic and relative.

    • Periodic alarms are those to which we specify a particular moment in the future, for example: "Alarm programmed for every fourth day of the month at 00:01 and 11 seconds". They are controlled by the RTC.

    • Relative alarms are programmed taking into account the current moment, eg: "Alarm programmed for 5 minutes and 10 seconds". They are controlled through the RTC and the microcontroller's internal Watchdog.

  • Asynchronous Interruptions: These are not scheduled, so it is not known when they will be triggered. Types:

    • Sensors: The sensor boards can be programmed so that an alarm is triggered when a sensor reaches a certain threshold.

    • Accelerometer: The accelerometer can be programmed so that certain events such (as a fall or change of direction) generate an interruption.

All interruptions, both synchronous and asynchronous can wake Waspmote Plug & Sense! up from the Sleep and the Deep Sleep modes.

All information about the programming and operation of interruptions can be found in the Interruption Programming Guide.

Watchdog

The ATmega1281 microcontroller inside the Waspmote Plug & Sense! has an internal Enhanced Watchdog Time -- WDT. The WDT precisely counts the clock cycles generated by a 128 kHz oscillator. The WDT generates an interruption signal when the counter reaches the set value. This interruption signal can be used to wake the microcontroller from the Sleep mode or to generate an internal alarm when it is running in on mode, which is very useful when developing programs with timed interruptions.

The WDT allows the microcontroller to wake up from a low consumption Sleep mode by generating an interruption. For this reason, this clock is used as a time-based alarm associated with the microcontroller's Sleep mode. This allows very precise control of small time intervals: 16 ms, 32 ms, 64 ms, 128 ms, 256 ms, 500 ms, 1 s, 2 s, 4 s, 8 s. For intervals over 8 s (Deep Sleep mode), the RTC is used and not the microcontroller.

All information about their programming and operation can be found in the Interruptions Program Guide. All the documentation is located in the Development section in the Libelium website.

RTC Watchdog for reseting Waspmote

One of the alarms of the RTC (Alarm 2) is connected to a Watchdog reset circuit that is able to reset the microcontroller of Waspmote Plug & Sense! when the alarm is generated. This Watchdog has been implemented for reseting Waspmote Plug & Sense! if it gets stuck. That periodical reset avoids erratic behaviour. This is highly recommended for applications that need to be very robust and can never stop working. The use of the Watchdog feature ensures us that our Waspmote will never stop working.

The Watchdog feature requires the physical watchdog switch to be put in "enable" position (default state in Waspmote Plug & Sense! Devices).

All information about their programming and operation can be found in the RTC Programming Guide. All the documentation is located in the Development section in the Libelium website.

Last updated