This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
arduino-docs [2015/04/01 20:54] cimba007 [ESP Specific Libs] |
arduino-docs [2015/07/19 01:19] apedro [EEPROM] |
||
---|---|---|---|
Line 8: | Line 8: | ||
==== Wire ==== | ==== Wire ==== | ||
- | |||
content | content | ||
==== EEPROM ==== | ==== EEPROM ==== | ||
+ | EEPROM functionality is similar to the standard Arduino library with the exception of having to declare memory size and committing writes. | ||
+ | ===example=== | ||
+ | <code c++> | ||
+ | #include <EEPROM.h> | ||
- | content | + | void setup() |
+ | { | ||
+ | //Init EEPROM, note the size requirement. I believe 4096B is the maximum available. | ||
+ | //You could use a smaller amount/size. | ||
+ | EEPROM.begin(4096); | ||
+ | for( int i = 0; i < 4096; i++ ) | ||
+ | { | ||
+ | EEPROM.write(i,i); | ||
+ | } | ||
+ | EEPROM.commit(); //note here the commit! | ||
+ | } | ||
+ | </code> | ||
+ | NOTE: EEPROMAnything can be used with one simple modification. | ||
+ | Find the EEPROMAnything.h and add EEPROM.commit(); after the EEPROM.write(ee++, *p++); | ||
- | ==== ESP Specific Libs ==== | + | EEPROMAnything provides nice functionality to save any type of variable including structers. |
+ | <code c++> | ||
+ | #include <EEPROMAnything.h> | ||
- | ===== SDK-API (1.0.0) ===== | + | struct eepromInfoType |
+ | { | ||
+ | uint8_t MyUnsigned8BitInt; | ||
+ | char MyCharArray[25] | ||
+ | } myStructOriginal, myStructCopy; | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | myStructOriginal.MyUnsigned8BitInt = 0; //assign some value | ||
+ | strcpy( myStructOriginal.MyCharArray, "Less than 25 chars" ); //assign some value | ||
+ | EEPROM_writeAnything( 0, myStructOriginal ); //remember to modify EEPROM_writeAnything by adding .commit(). | ||
+ | //Lets read it back | ||
+ | EEPROM_readAnything( 0, myStructCopy ); | ||
+ | } | ||
+ | |||
+ | void loop() | ||
+ | { | ||
+ | //nothing here | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | ===== ESP Specific Libs ===== | ||
+ | |||
+ | ==== SDK-API (1.0.0) ==== | ||
Line 74: | Line 115: | ||
==== ESP8266WiFi ==== | ==== ESP8266WiFi ==== | ||
- | content | + | **Connect with static IP** |
+ | |||
+ | If you experience problems regarding DNS resolving check out https://github.com/esp8266/Arduino/issues/369 | ||
+ | <code c> | ||
+ | #include <ESP8266WiFi.h> | ||
+ | #include <WiFiClient.h> | ||
+ | #include <IPAddress.h> | ||
+ | const char* ssid = "....."; | ||
+ | const char* password = "....."; | ||
+ | |||
+ | void setup(void) | ||
+ | { | ||
+ | Serial.begin(115200); | ||
+ | |||
+ | |||
+ | // Connect to WiFi network | ||
+ | WiFi.begin(ssid, password); | ||
+ | //set static ip part | ||
+ | WiFi.config(IPAddress(192,168,1,118), IPAddress(192,168,1,1), IPAddress(255,255,255,0)); | ||
+ | |||
+ | // Wait for connection | ||
+ | while (WiFi.status() != WL_CONNECTED) { | ||
+ | delay(200); | ||
+ | } | ||
+ | |||
+ | | ||
+ | Serial.println(WiFi.localIP()); | ||
+ | | ||
+ | } | ||
+ | |||
+ | </code> | ||
==== ESP8266mDNS ==== | ==== ESP8266mDNS ==== | ||