Code examples and extended information

For more information about the Waspmote hardware platform go to: https://development.libelium.com/waspmote/

In the Waspmote Development section you can find complete examples: https://development.libelium.com/waspmote/code-examples

Example:

/*
* ------ [4-20mA_01] Current Loop Basic Example --------
*
* Explanation: This sketch shows how to use the most important
* features of the 4-20 mA Current Loop Board in Waspmote. This
* standard is used to transmit information of sensor over long
* distances. Waspmote uses analog inputs for reading the sensor
* values.
*
* Copyright (C) 2014 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 2 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 Gascon
* Implementation: Ahmad Saad
*/
//Include this library for using current loop functions
#include <currentLoop.h>
//Instantiate currentLoop object in channel 1
currentLoop sensor(CHANNEL1);
void setup()
{
// Power on the USB for viewing data in the serial monitor
USB.ON();
delay(100);
// Sets the 5 V switch ON
PWR.setSensorPower(SENS_5V, SENS_ON);
delay(100);
}
void loop()
{
// Get the sensor value in int format (0-1023)
int value = sensor.readChannel();
USB.print(“Int value read from channel 1:);
USB.println(value);
// Get the sensor value as a voltage
float voltage = sensor.readVoltage();
USB.print(“Voltage value rad from channel 1:);
USB.print(voltage);
USB.println(“V”);
// Get the sensor value as a current in mA
float current = sensor.readCurrent();
USB.print(“Current value read from channel 1:);
USB.print(current);
USB.println(“mA”);
USB.println(***************************************);
USB.print(“\n”);
//Delay after reading
delay(2500);
}