UT 01: Using EEPROM
This example shows how to use the EEPROM memory of Waspmote

Required Materials

1 x Waspmote 1 x Battery 1 x MiniUSB wire

Notes

- WARNING: Reserved EEMPROM addresses below @1024. 'Utils.writeEEPROM' do not let the user to write below this address. Do not try to write below this address as you could over-write important configuration. Available addresses: from 1024 to 4095 - This example can be executed in Waspmote v12 and Waspmote v15

Code

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

Output

1
H#
2
Address EEPROM: 1024 -- Value: 10
3
Address EEPROM: 1025 -- Value: 11
4
Address EEPROM: 1026 -- Value: 12
5
Address EEPROM: 1027 -- Value: 13
6
Address EEPROM: 1028 -- Value: 14
7
Address EEPROM: 1029 -- Value: 15
8
Address EEPROM: 1030 -- Value: 16
9
Address EEPROM: 1031 -- Value: 17
10
Address EEPROM: 1032 -- Value: 18
11
Address EEPROM: 1033 -- Value: 19
12
Address EEPROM: 1034 -- Value: 20
13
Address EEPROM: 1035 -- Value: 21
14
Address EEPROM: 1036 -- Value: 22
15
Address EEPROM: 1037 -- Value: 23
16
Address EEPROM: 1038 -- Value: 24
17
...
Copied!
Last modified 1yr ago