Development v12

Warning - Product Update

All the resources present on this section belong to Waspmote v12, Waspmote Plug & Sense! v12 and Meshlium v3.8.

If you have a Waspmote v15, Waspmote Plug & Sense! v15 or Meshlium v4.0 please go to this development section.

Check what is your version and what are the differences between the old and the new one in this document.

» Ag 11: Watermark Sensor

In this example the Agriculture 2.0 sensor board is turned on and the Soil Moisture sensor, placed on its first socket, read every second (the sensor reading time must be added to this time) approximately, printing the result through the USB port.

Required Materials

1 x Waspmote
1 x Battery
1 x Agriculture 2.0 board or Agriculture PRO 2.0 board
1 x Soil Moisture sensor (Watermark)


* Remember to connect the battery to Waspmote for proper operation.
* The connection of the sensor is described in the Agriculture 2.0 technical guide.
* When turning on the temperature sensor you will be powering all the low consumption group sensors. See the Agriculture 2.0 board technical guide for more information.
* To read a Soil Moisture sensor on any of the other two connectors you just have to replace the socket name in the readValue function.
* This example can only be executed in Waspmote v12


 *  --[Ag_11] - Reading the Watermark at Agriculture v20 board-- 
 *  Explanation: Turn on the Agriculture v20 board and read the 
 *  Watermark 1 sensor on it once every second
 *  Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L. 
 *  This program is free software: you can redistribute it and/or modify 
 *  it under the terms of the GNU General Public License as published by 
 *  the Free Software Foundation, either version 3 of the License, or 
 *  (at your option) any later version. 
 *  This program is distributed in the hope that it will be useful, 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
 *  GNU General Public License for more details. 
 *  You should have received a copy of the GNU General Public License 
 *  along with this program.  If not, see <>. 
 *  Version:           0.1 
 *  Design:            David Gascón 
 *  Implementation:    Manuel Calahorra

#include <WaspSensorAgr_v20.h>

// Variable to store the read value
float value;

void setup()
  // Turn on the USB and print a start message

  // Turn on the sensor board
  // Turn on the RTC
void loop()
  // Part 1: Sensor reading
  // Turn on the sensor and wait for stabilization and response time
  SensorAgrv20.setSensorMode(SENS_ON, SENS_AGR_WATERMARK_1);
  // Read the Watermark 1 sensor 
  value = SensorAgrv20.readValue(SENS_AGR_WATERMARK_1);
  // Turn off the sensor
  SensorAgrv20.setSensorMode(SENS_OFF, SENS_AGR_WATERMARK_1);
  // Part 2: USB printing
  // Print the Soil Moisture value through the USB
  USB.print(F("Frequency: "));


Frequency: 51.4257812500Hz
Frequency: 186.5845642089Hz
Frequency: 4219.4091796875Hz
Frequency: 5277.0449218750Hz
Frequency: 6006.0058593750Hz
Frequency: 6644.5180664062Hz
Frequency: 7299.2700195312Hz
Frequency: 7604.5625000000Hz
Frequency: 7662.8354492187Hz
Frequency: 7692.3076171875Hz
Frequency: 7722.0078125000Hz

Quick Publish: