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 the new Development Section.

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

» Ag 06: Temperature/Humidity (SHT75)

In this example the Agriculture 2.0 sensor board is turned on and the temperature and humidity sensor read every eleven seconds 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 Digital Temperature and Humidity sensor (Sensirion SHT75)

Notes

* 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.
* This example can only be executed in Waspmote v12

Code

/*  
 *  --[Ag_6] - Reading the temperature+humidity sensor on Agriculture v20 board-- 
 *  
 *  Explanation: Turn on the Agriculture v20 board and read the 
 *  temperature+humidity sensor on it once every eleven seconds
 *  
 *  Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L. 
 *  http://www.libelium.com 
 *  
 *  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 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 *  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 <http://www.gnu.org/licenses/>. 
 *  
 *  Version:           0.1 
 *  Design:            David Gascón 
 *  Implementation:    Manuel Calahorra
 */

#include <WaspSensorAgr_v20.h>

// Variable to store the temperature read value
float temperature;

// Variable to store the humidity read value
float humidity;

void setup()
{
  // Turn on the USB and print a start message
  USB.ON();
  USB.println(F("start"));
  delay(100);

  // Turn on the sensor board
  SensorAgrv20.ON();
  
  // Turn on the RTC
  RTC.ON();
  
}
 
void loop()
{
  // Part 1: Sensor reading
  // Turn on the sensor and wait for stabilization and response time
  SensorAgrv20.setSensorMode(SENS_ON, SENS_AGR_SENSIRION);
  delay(10000);
  
  // Read the temperature from the sensor 
  temperature = SensorAgrv20.readValue(SENS_AGR_SENSIRION, SENSIRION_TEMP);

  // Read the humidity from the sensor 
  humidity = SensorAgrv20.readValue(SENS_AGR_SENSIRION, SENSIRION_HUM);
  
  // Turn off the sensor
  SensorAgrv20.setSensorMode(SENS_OFF, SENS_AGR_SENSIRION);
  
  // Part 2: USB printing
  // Print the temperature and humidity values through the USB
  USB.print(F("Temperature: "));
  USB.print(temperature);
  USB.println(F("ºC"));
  USB.print(F("Humidity: "));
  USB.print(humidity);
  USB.println(F("%RH"));
  
  delay(1000);
}

Output

B#
start
Temperature: 22.7499961853ºC
Humidity: 42.5759544372%RH
Temperature: 22.8999977111ºC
Humidity: 42.3151321411%RH
Temperature: 23.0499992370ºC
Humidity: 42.8691368103%RH
Temperature: 23.1199989318ºC
Humidity: 41.9888153076%RH

Quick Publish: