Comment on page
Board configuration and programming
The Plug & Sense! Smart Agriculture Xtreme model does not require special handling of the hardware by the user, except for placing the sensors in their corresponding socket. In the previous sections each sensor connection has been described.
It is important to remark that Smart Agriculture Xtreme model is only available in the Waspmote Plug & Sense! Line. It is not available for Waspmote OEM line.
When using the Plug & Sense! Smart Agriculture Xtreme model, remember that it is mandatory to include the
WaspSensorXtr
library by introducing the next line at the beginning:#include <WaspSensorXtr.h>
The library manages the power supply and communication lines between Waspmote and the sockets. Prior reading the sensor probes, the user must declare an object of the corresponding sensor class, specifying the socket where the sensor is placed. All sensor classes inherit from the class
WaspSensorXtr
. The next table enumerates each sensor class.Sensor probe | Sensor class |
Non-contact surface temperature measurement sensor probe | Apogee_SI411 |
Leaf and flower bud temperature sensor probe | Apogee_SF421 |
Soil oxygen level sensor probe | Apogee_SO411 |
Soil oxygen level sensor probe | Apogee_SO421 |
Shortwave radiation sensor probe | Apogee_SP510 |
Solar radiation sensor probe for Smart Agriculture Xtreme | Apogee_SQ110 |
Ultraviolet radiation sensor probe for Smart Agriculture Xtreme | Apogee_SU100 |
Temperature, humidity and pressure sensor probe | bme |
Conductivity, water content and soil temperature GS3 sensor probe | Decagon_GS3 |
Conductivity, water content and soil temperature 5TE sensor probe | Decagon_5TE |
Soil temperature and volumetric water content sensor probe | Decagon_5TM |
Soil temperature and volumetric water content sensor probe | METER_TEROS11 |
Conductivity, water content and soil temperature TEROS 12 sensor probe | METER_TEROS12 |
Soil water potential sensor probe | METER_TEROS21 |
Vapor pressure, humidity, temperature and pressure in soil and air sensor probe | Decagon_VP4 |
Leaf wetness Phytos 31 sensor probe | leafWetness |
Dendrometer sensor probes for Smart Agriculture Xtreme | dendrometer |
Weather station sensor probe | weatherStation |
Solar radiation and temperature Datasol MET probe | DatasolMET |
Luminosity sensor probe | luxes |
Ultrasound sensor probe | ultrasound |
Each sensor class manages the Smart Agriculture Xtreme sensor board according to its needs, so there is no need to turn on or off the whole board, as is often needed with other Libelium sensor boards. After declaring the object, the sensor can be turned on or off independently from each other. Incidentally, do not forget to turn off the sensors to save battery when they are no longer needed.
The next snippet shows how to declare an object for the sensor 5TE and then how to turn on, read and turn off the sensor:
{
// 1. Declare an object for the sensor
Decagon_5TE mySensor(XTR_SOCKET_A);
// 2. Turn ON the sensor
mySensor.ON();
// 3. Read the sensor. Values stored in class variables
// Check complete code example for details
mySensor.read();
// 4. Turn off the sensor
mySensor.OFF();
}
The
read()
function stores the sensor values in a public class. It does not return the values directly. The user can refer to the dedicated sensor example to see how the sensor values can be accessed. In the case of the 5TE sensor, values will be printed by USB with the following snippet.{
// 4. Print information
USB.print(F(\"Dielectric Permittivity: \"));
USB.printFloat(mySensor.sensor5TE.dielectricPermittivity, 5);
USB.println();
USB.print(F(\"Electrical Conductivity: \"));
USB.printFloat(mySensor.sensor5TE.electricalConductivity, 5);
USB.println(F(\" dS/m\"));
USB.print(F(\"Soil temperature: \"));
USB.printFloat(mySensor.sensor5TE.temperature, 5);
USB.println(F(\" degrees Celsius\"));
}
The Temperature, humidity and pressure, the Ultrasound and the Luminosity sensors have their own reading functions in contrast to the rest of the Smart Agriculture Xtreme sensors. This is due to these sensors can be used in other Plug & Sense! models and they share the same functions in the Waspmote API. Refer to the dedicated sensor example for further details.
Owing to the large number of parameters that can be read by the Plug & Sense! Smart Agriculture Xtreme model, a special frame type must be used with the Frame class in order to send the values correctly.
{
// It is mandatory to specify the Smart Agriculture Xtreme type
frame.setFrameType(INFORMATION_FRAME_AGR_XTR);
}
You can find a complete example code for using the Frame class in the following link: http://www.libelium.com/development/waspmote/examples/ag-xtr-19-frame-class-utility
Refer to the Data Frame Guide for more information: https://development.libelium.com/data-frame-programming-guide/
The Smart Agriculture Xtreme sensor board has an RS-232 interface available on socket F of Plug & Sense! Smart Agriculture Xtreme.
Some users may want to integrate sensors manufactured by 3rd party companies (advanced skills are required). In case the RS-232 interface needs to be used to integrate a new sensor, a basic example is included to transmit and receive data or commands. It should be noticed that it is managed in the same way as UART1 of the microcontroller. See the Waspmote Technical Guide for more information.
First, the RS-232 interface needs to be configured with parameters like baudrate or parity:
{
// Prepare Wasp mux to talk with MAX3232 on AGR board and open UART at 115200
void configureAgrRS232()
{
Utils.setMuxAux1();
beginSerial(115200, 1);
// parity none
cbi(UCSR1C, UPM11);
cbi(UCSR1C, UPM10);
// 1 stop bit
cbi(UCSR1C, USBS1);
serialFlush(1);
delay(100);
}
}
Then, 2nd block could be a function to receive some data and save it into a buffer. Notice that the UART1 multiplexer is set to Auxiliary UART 1:
{
// Basic method to recive data and save into a buffer.
void receiveData()
{
Utils.setMuxAux1();
i = 0;
memset(rxBuffer, 0x00, sizeof(rxBuffer));
while (serialAvailable(1) > 0)
{
rxBuffer[i] = serialRead(1);
i++;
if (i > 50)
{
break;
}
delay(1);
}
}
}
Finally, a 3rd block for sending data through the RS-232, like a normal UART:
{
// send data through RS 232 transceiver on socket F
// just use the printString function.
printString(dummy, 1);
}
You can find a complete example code for using the RS-232 interface in the following link: https://development.libelium.com/ag-xtr-25-rs-232-tx-and-rx-example/
The user can find the RS-232 interface in socket F and the connection can be done using the Terminal Box probe or the DB9 probe. Contact our Sales department through the next link if you require more information: http://www.libelium.com/contact.
The RS-232 signals are wired on the terminal box according to the next table:
RS-232: Terminal box probe | RS-232: Terminal box |
1 (orange) | RS_232_TX |
2 (white) | RS_232_RX |
3 (red) | - |
4 (black) | GND |
5 (yellow) | - |
6 (green) | +12 V |
The Smart Agriculture Xtreme sensor board has two 4-20 mA interfaces available on sockets B and F of Plug & Sense! Smart Agriculture Xtreme.
Some users may want to integrate sensors manufactured by 3rd party companies (advanced skills are required). If needed, a basic example is included to read the current on the 4-20 mA loop. There is a specific class to allow the readings.
The next snippet shows how to declare an object for a generic 4-20 mA sensor and then how to turn on, read and turn off the sensor:
{
// 1. Declare an object for the sensor
_4_20mA my_4_20mA(XTR_SOCKET_B)
// 2. Turn ON the sensor
my_4_20mA.ON();
// 3. Read the sensor. Values stored in class variables
// Check complete code example for details
my_4_20mA.read();
// 4. Turn off the sensor
my_4_20mA.OFF();
}
The
read()
function stores the sensor values in a public class. The user can refer to the dedicated sensor example to see how the sensor values can be accessed. In the case of the 4-20 mA sensor, values will be printed by USB with the following snippet:{
//4. Print information
USB.println(F(\"---------------------------\"));
USB.print(F(\"4-20mA sensor current: \"));
USB.printFloat(my_4_20mA.current, 3);
USB.println(F(\"mA\"));
}
You can find a complete example code for using the Frame class in the following link: http://www.libelium.com/waspmote/examples/ag-xtr-26-4-20ma-example
The connection can be done using the Terminal Box probe or a DB9 probe. Contact our Sales department through the next link if you require more information: http://www.libelium.com/contact.
The 4-20 mA signals are wired on the Terminal Box according to the next table:
4-20 mA (socket B and F): Terminal box probe | 4-20 mA (socket B and F): Terminal box |
1 (orange) | - |
2 (white) | - |
3 (red) | - |
4 (black) | GND |
5 (yellow) | 4-20 mA |
6 (green) | +12 |
Last modified 2yr ago