<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[ESP8266 WiFi settings in EEPROM]]></title><description><![CDATA[<p dir="auto">Hi!</p>
<p dir="auto">Is there a way to use WiFi SSID/password/etc. stored in EEPROM?<br />
As I can see all WiFi initialization hidden from "end-user".</p>
<p dir="auto">I want to read config from EEPROM or filesystem and use some web-based (re-)configuration (as example <a href="https://github.com/tzapu/WiFiManager" rel="nofollow ugc">https://github.com/tzapu/WiFiManager</a>)  but can't because WiFi stack initialized internally with defines.</p>
<p dir="auto">BTW, while general wifi settings can be re-defined to local variables, MQTT Client Gateway uses "inplace" string join so can not be compiled with variables.</p>
]]></description><link>https://forum.mysensors.org/topic/3099/esp8266-wifi-settings-in-eeprom</link><generator>RSS for Node</generator><lastBuildDate>Tue, 17 Mar 2026 03:34:04 GMT</lastBuildDate><atom:link href="https://forum.mysensors.org/topic/3099.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 11 Feb 2016 13:42:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ESP8266 WiFi settings in EEPROM on Fri, 12 Feb 2016 11:06:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/yveaux" aria-label="Profile: Yveaux">@<bdi>Yveaux</bdi></a> I have 34 of 80k RAM used for this sketch, so 128 bytes looks like "a bit more".</p>
<p dir="auto">You can not use progmem with ESP and mysensors now because PSTR redefined as <code>PSTR(x) (x)</code> so all strings are really in RAM :(</p>
]]></description><link>https://forum.mysensors.org/post/31386</link><guid isPermaLink="true">https://forum.mysensors.org/post/31386</guid><dc:creator><![CDATA[Alexander Voronin]]></dc:creator><pubDate>Fri, 12 Feb 2016 11:06:35 GMT</pubDate></item><item><title><![CDATA[Reply to ESP8266 WiFi settings in EEPROM on Fri, 12 Feb 2016 10:52:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/yveaux" aria-label="Profile: Yveaux">@<bdi>Yveaux</bdi></a> said:</p>
<blockquote>
<p dir="auto">scarce ATMega RAM...</p>
</blockquote>
<p dir="auto">I mean ESP RAM ofcourse... :facepunch:</p>
]]></description><link>https://forum.mysensors.org/post/31383</link><guid isPermaLink="true">https://forum.mysensors.org/post/31383</guid><dc:creator><![CDATA[Yveaux]]></dc:creator><pubDate>Fri, 12 Feb 2016 10:52:48 GMT</pubDate></item><item><title><![CDATA[Reply to ESP8266 WiFi settings in EEPROM on Fri, 12 Feb 2016 10:51:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/yveaux" aria-label="Profile: Yveaux">@<bdi>Yveaux</bdi></a> Not all but enough. Hmm how do you plan to use mqtt with wifi with ATMega? ;) IMHO it is not so good :)</p>
<p dir="auto">So this solution is for somebody, who need dynamic reconfiguration of system settings. Remember, that char[] sizes just example and may be reduced or changed to String(...).c_str(). But I don't know arduino well (prefer pure C) and can't predict memory usage/fragmentation on that way.</p>
<p dir="auto">BTW, as an idea - add wifi and/or mqtt settings as MyMessage to be changed via "standard" way</p>
]]></description><link>https://forum.mysensors.org/post/31382</link><guid isPermaLink="true">https://forum.mysensors.org/post/31382</guid><dc:creator><![CDATA[Alexander Voronin]]></dc:creator><pubDate>Fri, 12 Feb 2016 10:51:41 GMT</pubDate></item><item><title><![CDATA[Reply to ESP8266 WiFi settings in EEPROM on Fri, 12 Feb 2016 10:28:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alexander-voronin" aria-label="Profile: Alexander-Voronin">@<bdi>Alexander-Voronin</bdi></a> Great to hear your issue is solved, but this solution will permanently claim 128 of the scarce ATMega RAM...</p>
]]></description><link>https://forum.mysensors.org/post/31375</link><guid isPermaLink="true">https://forum.mysensors.org/post/31375</guid><dc:creator><![CDATA[Yveaux]]></dc:creator><pubDate>Fri, 12 Feb 2016 10:28:37 GMT</pubDate></item><item><title><![CDATA[Reply to ESP8266 WiFi settings in EEPROM on Fri, 12 Feb 2016 10:24:06 GMT]]></title><description><![CDATA[<p dir="auto">OK!<br />
All, except MY_MQTT_xxx_TOPIC_PREFIX can be used as variables:</p>
<pre><code>char ssid[32] = "MyAP";
char pwd[32] = "MyPass";
word mqttPort = 1883;
char mqttHost[64] = "my.mqtt.example.com";

#define MY_GATEWAY_ESP8266
#define MY_GATEWAY_MQTT_CLIENT
#define MY_ESP8266_SSID (ssid)
#define MY_ESP8266_PASSWORD (pwd)

#define MY_PORT (mqttPort)
#define MY_CONTROLLER_URL_ADDRESS (mqttHost)
#define MY_MQTT_CLIENT_ID  (String("MyS_") + String(ESP.getChipId(), HEX)).c_str()

// DOES NOT SUPPORT VARS:
#define MY_MQTT_PUBLISH_TOPIC_PREFIX "/MySe/00/out"
#define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "/MySe/00/in"

#include &lt;MySensor.h&gt;

void before() {
  // read config into local vars, e.g. from FS via json
  strncpy(ssid, "AltSSID", sizeof(ssid)); // example
}

void setup() {
}

void loop() {
}
</code></pre>
<p dir="auto">FYI, The wifi manager from first post is not so useful here for me - on first look there is some issues with dhcp vs static ip, so I'll try to find another solution or write my own :)</p>
]]></description><link>https://forum.mysensors.org/post/31373</link><guid isPermaLink="true">https://forum.mysensors.org/post/31373</guid><dc:creator><![CDATA[Alexander Voronin]]></dc:creator><pubDate>Fri, 12 Feb 2016 10:24:06 GMT</pubDate></item><item><title><![CDATA[Reply to ESP8266 WiFi settings in EEPROM on Fri, 12 Feb 2016 08:26:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hek" aria-label="Profile: hek">@<bdi>hek</bdi></a> Thanks! Looks promising. I''ll try it.</p>
<p dir="auto">This may solve an issue with AP (compiled ok but untested <code>char[]</code> as MY_ESP8266_SSID) but not for MQTT transport - a lot of <code>PSTR(MY_MQTT_XXX) "/+/+/+"</code> code required refactoring to be used with at least <code>const char*</code></p>
]]></description><link>https://forum.mysensors.org/post/31350</link><guid isPermaLink="true">https://forum.mysensors.org/post/31350</guid><dc:creator><![CDATA[Alexander Voronin]]></dc:creator><pubDate>Fri, 12 Feb 2016 08:26:57 GMT</pubDate></item><item><title><![CDATA[Reply to ESP8266 WiFi settings in EEPROM on Fri, 12 Feb 2016 08:13:32 GMT]]></title><description><![CDATA[<p dir="auto">There's a new<br />
<code>before()</code><br />
you can add to init stuff <em>before</em> the library.</p>
<p dir="auto">Example:<br />
<a href="https://github.com/mysensors/Arduino/blob/469cbb7d0ccd4698079a44e8632f660fbe50cf18/libraries/MySensors/examples/RelayActuator/RelayActuator.ino#L49-L56" rel="nofollow ugc">https://github.com/mysensors/Arduino/blob/469cbb7d0ccd4698079a44e8632f660fbe50cf18/libraries/MySensors/examples/RelayActuator/RelayActuator.ino#L49-L56</a></p>
]]></description><link>https://forum.mysensors.org/post/31346</link><guid isPermaLink="true">https://forum.mysensors.org/post/31346</guid><dc:creator><![CDATA[hek]]></dc:creator><pubDate>Fri, 12 Feb 2016 08:13:32 GMT</pubDate></item><item><title><![CDATA[Reply to ESP8266 WiFi settings in EEPROM on Fri, 12 Feb 2016 08:07:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/yveaux" aria-label="Profile: Yveaux">@<bdi>Yveaux</bdi></a> This is slightly not my case. The ESP stores only SSID/Password, but I want to store extra config for at least MQTT broker.</p>
<p dir="auto">The main issue is that <code>WiFi.begin()</code> and awaiting for WiFi.state == WL_CONNECTED logic executed <em>before</em> <code>setup()</code> so I can not invoke web-config or change hardcoded AP name. In my previous "pure" arduino sensor (<a href="https://bitbucket.org/esp8266/sensor-v2" rel="nofollow ugc">https://bitbucket.org/esp8266/sensor-v2</a>) I use WiFiMulti to connect first available pre-configured AP's, so I need at least two AP/password settings (for example home and work wifi)</p>
<p dir="auto">BTW, de-facto MySensors internally "ignores" last saved AP because calls begin(SSID, PWD) in MyGatewayTransportXXX.cpp but it is good idea as for me. As an option - do not call WiFi.begin() if wifi state already "connected" but required some functionality to force reconnect to /other/ AP</p>
<p dir="auto">So I need 4 steps:</p>
<ol>
<li>Try connect to saved AP (may be more than one)</li>
<li>If not success, bring up softAP and Web/Telnet configurator</li>
<li>Reconnect to new configured AP or reboot an goto step 1</li>
<li>Start MySensors with already connected WiFi and new SSID</li>
</ol>
]]></description><link>https://forum.mysensors.org/post/31345</link><guid isPermaLink="true">https://forum.mysensors.org/post/31345</guid><dc:creator><![CDATA[Alexander Voronin]]></dc:creator><pubDate>Fri, 12 Feb 2016 08:07:06 GMT</pubDate></item><item><title><![CDATA[Reply to ESP8266 WiFi settings in EEPROM on Fri, 12 Feb 2016 07:57:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alexander-voronin" aria-label="Profile: Alexander-Voronin">@<bdi>Alexander-Voronin</bdi></a> I recently found out that the ESP will always store the last access point &amp; password it connected to in flash anyway, so just connecting once with new settings should be sufficient (does however need modifications to MySensors library to not pass this stuff on connect)<br />
Maybe the same holds for IP address etc.</p>
]]></description><link>https://forum.mysensors.org/post/31340</link><guid isPermaLink="true">https://forum.mysensors.org/post/31340</guid><dc:creator><![CDATA[Yveaux]]></dc:creator><pubDate>Fri, 12 Feb 2016 07:57:23 GMT</pubDate></item><item><title><![CDATA[Reply to ESP8266 WiFi settings in EEPROM on Fri, 12 Feb 2016 07:04:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hek" aria-label="Profile: hek">@<bdi>hek</bdi></a> This is my first try with MySensors, so just thinking of loud:</p>
<p dir="auto">One way: Globally redesign internal initialization sequence and add extra EEPROM arguments. Also provide function to write new SSID/password to EEPROM and reboot. Read SSID/IP/password/etc from config in TransportXXX</p>
<p dir="auto">Another way: Be more Arduin-ish. All standard Arduino classes have function <code>begin</code> or/and class initializer. So I want to call for example <code>mySensors.begin()</code> for basic init, and some kind of <code>mySensorsTransportXXXBegin(ssid, password, ip, topic, etc)</code> for specific transport init. As an option should be flag like "already connected" or "do not reconnect" for WiFi</p>
<p dir="auto">As for me, the second way is preferred. If I decide to make my next sensor on MySensors instead of "pure" C/Arduino, I'll refactor at least <code>MyMainESP8266.c:loop_wrapper</code> by removing setup call and adding separate public _begin() alternative</p>
]]></description><link>https://forum.mysensors.org/post/31338</link><guid isPermaLink="true">https://forum.mysensors.org/post/31338</guid><dc:creator><![CDATA[Alexander Voronin]]></dc:creator><pubDate>Fri, 12 Feb 2016 07:04:44 GMT</pubDate></item><item><title><![CDATA[Reply to ESP8266 WiFi settings in EEPROM on Thu, 11 Feb 2016 15:11:38 GMT]]></title><description><![CDATA[<p dir="auto">If you have some idea how to solve it, please submit a PR.</p>
]]></description><link>https://forum.mysensors.org/post/31273</link><guid isPermaLink="true">https://forum.mysensors.org/post/31273</guid><dc:creator><![CDATA[hek]]></dc:creator><pubDate>Thu, 11 Feb 2016 15:11:38 GMT</pubDate></item></channel></rss>