Ag xtr 21: Board serial number reading
Basic example that reads serial number and turn off the sensor. Sensor serial number is stored in the corresponding class variable and printed by the serial monitor.

Required Materials

- 1 Waspmote Plug & Sense! Smart Agriculture Xtreme

Notes

- This example is only valid for Waspmote v15

Code

1
/*
2
----------- [Ag_xtr_21] - Board serial number reading --------------------
3
4
Explanation: Basic example that reads serial number and turn off the sensor.
5
Sensor serial number is stored in the corresponding class variable and
6
printed by the serial monitor.
7
8
Measured parameters:
9
- Smart Agriculture Xtreme board serial number
10
11
Copyright (C) 2018 Libelium Comunicaciones Distribuidas S.L.
12
http://www.libelium.com
13
14
This program is free software: you can redistribute it and/or modify
15
it under the terms of the GNU General Public License as published by
16
the Free Software Foundation, either version 3 of the License, or
17
(at your option) any later version.
18
19
This program is distributed in the hope that it will be useful,
20
but WITHOUT ANY WARRANTY; without even the implied warranty of
21
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
GNU General Public License for more details.
23
24
You should have received a copy of the GNU General Public License
25
along with this program. If not, see .
26
27
Version: 3.1
28
Design: David Gascón
29
Implementation: J.Siscart, V.Boria
30
*/
31
32
#include <WaspSensorXtr.h>
33
34
void setup()
35
{
36
37
if (SensorXtr.readBoardSerialNumber() == 1)
38
{
39
USB.print(F("Board serial number:"));
40
41
USB.printHex(SensorXtr.boardSerialNumber[0]);
42
USB.print(F("-"));
43
USB.printHex(SensorXtr.boardSerialNumber[1]);
44
USB.print(F("-"));
45
USB.printHex(SensorXtr.boardSerialNumber[2]);
46
USB.print(F("-"));
47
USB.printHex(SensorXtr.boardSerialNumber[3]);
48
USB.println();
49
}
50
else
51
{
52
USB.println("Error reading board serial number");
53
}
54
55
}
56
57
void loop()
58
{
59
delay(5000);
60
}
Copied!

Output

1
H#
2
Board serial number:00-35-C6-76
Copied!
Last modified 1yr ago