Development v12

Warning - Product Update

All the resources present on this section belong to Waspmote v12, Waspmote Plug & Sense! v12 and Meshlium v3.8.

If you have a Waspmote v15, Waspmote Plug & Sense! v15 or Meshlium v4.0 please go to the new Development Section.

Check what is your version and what are the differences between the old and the new one in this document.

» 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

/*
 *  ------ [Ut_1] Waspmote Using EEPROM Example --------
 *
 *  Explanation: This example shows how to use the EEPROM memory of Waspmote
 *
 *  Copyright (C) 2016 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 3 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:           3.0
 *  Design:            David Gascón 
 *  Implementation:    Marcos Yarza
 */

// Variables

// address in EEPROM
int address = 1024; 
// value to write
int value =10;  
int aux = 0;
 
 
void setup()
{
  // Init USB
  USB.ON();
}

void loop()
{
  // 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
  
  // Writing in the EEPROM  
  Utils.writeEEPROM(address,value);
  
  // Reading the EEPROM
  aux = Utils.readEEPROM(address);
  USB.print(F("Address EEPROM:  "));
  USB.print(address,DEC);
  USB.print(F(" -- Value: "));
  USB.println(aux,DEC);
  
  address++;
  value++;
  
  if(address == 4096) // there are 4 kB available
  {
    address = 1024;
    USB.println("END");
    delay(10000);    
  }
  delay(1);
}

Output

H#
Address EEPROM: 1024 -- Value: 10
Address EEPROM: 1025 -- Value: 11
Address EEPROM: 1026 -- Value: 12
Address EEPROM: 1027 -- Value: 13
Address EEPROM: 1028 -- Value: 14
Address EEPROM: 1029 -- Value: 15
Address EEPROM: 1030 -- Value: 16
Address EEPROM: 1031 -- Value: 17
Address EEPROM: 1032 -- Value: 18
Address EEPROM: 1033 -- Value: 19
Address EEPROM: 1034 -- Value: 20
Address EEPROM: 1035 -- Value: 21
Address EEPROM: 1036 -- Value: 22
Address EEPROM: 1037 -- Value: 23
Address EEPROM: 1038 -- Value: 24
...

Quick Publish: