Ag xtr 22: Read write EEPROM
This example shows how to use the EEPROM memory of Smart Agriculture Xtreme board.

Required Materials

- 1 Waspmote Plug & Sense! Smart Agriculture Xtreme

Notes

- This example is only valid for Waspmote v15

Code

1
/*
2
----------- [Ag_xtr_22] - Using Agriculture EEPROM Example -----------
3
4
Explanation:This example shows how to use the EEPROM memory of
5
Smart Agriculture Xtreme board.
6
7
Copyright (C) 2018 Libelium Comunicaciones Distribuidas S.L.
8
http://www.libelium.com
9
10
This program is free software: you can redistribute it and/or modify
11
it under the terms of the GNU General Public License as published by
12
the Free Software Foundation, either version 3 of the License, or
13
(at your option) any later version.
14
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
19
20
You should have received a copy of the GNU General Public License
21
along with this program. If not, see .
22
23
Version: 3.1
24
Design: David Gascón
25
Implementation: J.Siscart, V.Boria
26
*/
27
28
#include <WaspSensorXtr.h>
29
30
// address in the Smart Agriculture Xtreme EEPROM
31
int address = 0x51;
32
// value to write
33
int value = 10;
34
// Aux variable
35
int data = 0;
36
37
38
void setup()
39
{
40
// Init USB
41
USB.ON();
42
}
43
44
void loop()
45
{
46
// WARNING: Reserved EEMPROM addresses below @0x50
47
// SensorXtr.writeEEPROM do not let the user to write
48
// below this address.
49
// Do not try to write below this address as
50
// you could over-write important configuration
51
// --> Available addresses: from 0x51 to 0x7F
52
53
// Writing in the Smart Agriculture Xtreme EEPROM
54
SensorXtr.writeEEPROM(address, value);
55
56
// Reading the Smart Agriculture Xtreme EEPROM
57
data = SensorXtr.readEEPROM(address);
58
USB.print(F("Address EEPROM: "));
59
USB.print(address,DEC);
60
USB.print(F(" -- Value: "));
61
USB.println(data, DEC);
62
63
address++;
64
value++;
65
66
if(address >= 0x7F)
67
{
68
address = 0x51;
69
USB.println("END");
70
delay(10000);
71
}
72
delay(1);
73
}
Copied!

Output

1
H#
2
Address EEPROM: 81 -- Value: 10
3
Address EEPROM: 82 -- Value: 11
4
Address EEPROM: 83 -- Value: 12
5
Address EEPROM: 84 -- Value: 13
6
Address EEPROM: 85 -- Value: 14
7
Address EEPROM: 86 -- Value: 15
8
Address EEPROM: 87 -- Value: 16
9
Address EEPROM: 88 -- Value: 17
10
Address EEPROM: 89 -- Value: 18
11
Address EEPROM: 90 -- Value: 19
12
Address EEPROM: 91 -- Value: 20
13
Address EEPROM: 92 -- Value: 21
14
Address EEPROM: 93 -- Value: 22
15
Address EEPROM: 94 -- Value: 23
16
Address EEPROM: 95 -- Value: 24
17
Address EEPROM: 96 -- Value: 25
18
Address EEPROM: 97 -- Value: 26
19
Address EEPROM: 98 -- Value: 27
20
Address EEPROM: 99 -- Value: 28
21
Address EEPROM: 100 -- Value: 29
22
Address EEPROM: 101 -- Value: 30
23
Address EEPROM: 102 -- Value: 31
24
Address EEPROM: 103 -- Value: 32
25
Address EEPROM: 104 -- Value: 33
26
Address EEPROM: 105 -- Value: 34
27
Address EEPROM: 106 -- Value: 35
28
Address EEPROM: 107 -- Value: 36
29
Address EEPROM: 108 -- Value: 37
30
Address EEPROM: 109 -- Value: 38
31
Address EEPROM: 110 -- Value: 39
32
Address EEPROM: 111 -- Value: 40
33
Address EEPROM: 112 -- Value: 41
34
Address EEPROM: 113 -- Value: 42
35
Address EEPROM: 114 -- Value: 43
36
Address EEPROM: 115 -- Value: 44
37
Address EEPROM: 116 -- Value: 45
38
Address EEPROM: 117 -- Value: 46
39
Address EEPROM: 118 -- Value: 47
40
Address EEPROM: 119 -- Value: 48
41
Address EEPROM: 120 -- Value: 49
42
Address EEPROM: 121 -- Value: 50
43
Address EEPROM: 122 -- Value: 51
44
Address EEPROM: 123 -- Value: 52
45
Address EEPROM: 124 -- Value: 53
46
Address EEPROM: 125 -- Value: 54
47
Address EEPROM: 126 -- Value: 55
48
END
Copied!
Last modified 1yr ago