Board configuration and programming

Hardware configuration

The Waspmote Agriculture v3.0 Board hardly requires a manual hardware configuration, since all the power control and sensor reading operations can be carried out digitally. It will be only necessary to ensure that the sensors are connected in the right way to their sockets for a proper measurement.


The Agriculture Sensor Board v3.0 for Waspmote has its own library which contains the set of necessary instructions to easily configure and read each one of the sensors which can be connected to the board. Next, each one of the functions is described and the process of configuration is detailed for each sensor. The specific configuration which must be applied to each one of the sensors is explained in the specific sensor's section.
When using the Agriculture Sensor Board v3 on Waspmote, remember it is mandatory to include the WaspSensorAgr_v30 library by introducing the next line at the beginning of the code:
#include <WaspSensorAgr_v30.h>
Each agriculture sensor needs its own object. So, between the include of the library and the global variables declaration, the object must be created following the next structure:
  • Name of the class: leafWetnessClass.
  • Name of the object: We recommend to use the name of the sensor. In this case lwSensor.
  • Only in watermark sensor you need put in brackets the socket. For example: SOCKET_B or SOCKET_1.

Agriculture Class

  • Turn on the sensor board by enable the 3.3 V and 5 V.
  • Turn off the sensor board by disable the 3.3 V and 5 V.
  • Read distance in cm when the ultrasound sensor is connected.
  • Read temperature in ºC when the BME280 is connected.
  • Read pressure in PA when the BME280 is connected.
  • Read humidity in % when the BME280 is connected.
  • Read luxes in lux when the TSL2561 is connected, in this case its
    necessary include the place of sensor (INDOOR or OUTDOOR) into
    the brackets.
The function Agriculture.sleepAgr() is an adaptation of the function deepSleep() in the library WaspPWR.cpp that allows to put Waspmote to sleep, turning the power of the board completely off or keeping the pluviometer circuits on if the interruptions of this sensor are going to be used to wake up the microcontroller. The parameters TIME, OFFSET, MODE and OPTION allow to define the time the mote will be in deep sleep mode before waking up with an RTC interruption and the modules that will be inactive during this time, like in the original function (read the Waspmote technical guide and Programming Guide for more information). To activate the pluviometer interruptions, the parameter AGR_INTERRUPTION must be assigned with the value SENS_AGR_PLUVIOMETER (remember not to deactivate the sensor board when defining the parameter OPTION for a correct operation of the interruptions).
A basic program to detect events from the board will present a similar structure to the following, subject to changes in dependence of the application:
  • 1.The board is switched on using the function Agriculture.ON
  • 2.When the mote wakes up, disable interruptions from the board using function Agriculture.detachPluvioInt().
  • 3.Store or send via a radio module the gathered information.
  • 4.Return to step 4 to enable interruptions and put the mote to sleep.


  • Read the dendrometer value in Agriculture Pro. dnd.readDendrometer();


  • Read the soil temperature in Agriculture Normal. ds18b20.readDS18b20();


  • Read the leaf wetness % in Agriculture Normal and Pro.lw.getLeafWetness();


  • Read the soil temperature in Agriculture Pro. soilTemp.readPT1000();


  • Read the solar Radiation in Agriculture Pro. solarRadiation.readRadiation();


  • In this case it is necessary to specify the socket where watermark is connected and also instance object.watermarkClass wmSensor1(SOCKET_1);
  • Read the soil water content (Hz) in Agriculture Normal and Pro.wmSensor1.readWatermark();


  • Read the wind speed in Agriculture Normal and Pro. wh.readAnemometer();
  • Read the vane direction in Agriculture Normal and Pro.wh.readVaneDirection();
‌The attachPluvioInt() function enables the interruptions generated by the pluviometer. Take into account that this sensor is permanently powered all the time if the board is on, so it will keep on triggering interruptions as long as they are enabled. wh.AttachPluvioInt();
Complementing the previous function, the aim of detachPluvioInt() is to deactivate the interrupts generated by the pluviometer. After its execution, the microcontroller will ignore any interruption which arrives from this sensor until the attachPluvioInt() instruction is called again. wh.detachPluvioInt();
  • Read pluviometer value. wh.readPluviometerCurrent();
  • Read pluviometer value in 1 hour. wh.readPluviometerHour();
  • Read pluviometer value in 1 day. wh.readPluviometerDay();