homieiot / homie-esp8266

💡 ESP8266 framework for Homie, a lightweight MQTT convention for the IoT
http://homieiot.github.io/homie-esp8266
MIT License
1.36k stars 308 forks source link

Correct way for adding config.json by SPIFFS #509

Closed psamim closed 6 years ago

psamim commented 6 years ago

Hi!

I am new to Homie and Platformio. I read the documents and what I do for adding the config.json file is running:

Is the order correct? Does it matter? Do I have to do them both? I am asking this because sometimes even after doing the uploadfs I get the error config.json doesn't exist, but sometimes it works. Sometimes everything is working but suddenly it reboots and the configuration is gone/erased. So I thought maybe I am doing something wrong.

Thanks

psamim commented 6 years ago

This is the log:

Flagged for reset by pin

Device is idle
Configuration erased
Setting next boot mode to 2
Triggering ABOUT_TO_RESET event...
↻ Rebooting into config mode...
✖️ MQTT disconnected
Triggering MQTT_DISCONNECTED event...
✖️ Wi-Fi disconnected
Triggering WIFI_DISCONNECTED event...

 ets Jan  8 2013,rst cause:2, boot mode:(1,6)

 ets Jan  8 2013,rst cause:4, boot mode:(1,6)

wdt reset

Is some pin reserved for config erase?

euphi commented 6 years ago

Yes, pressing Pin 0 (named D3 on Wemos D1 Mini) for 5 seconds deletes the configuration.

You can disable this function with (see http://marvinroger.github.io/homie-esp8266/docs/2.0.0-beta.3/advanced-usage/resetting/)

void setup() {
  Homie.disableResetTrigger(); // before Homie.setup()
  // ...
}
psamim commented 6 years ago

Thanks! And does the order matter? Is the way I put config.json correct?

On Tue, Mar 27, 2018, 11:47 PM Ian Hubbertz notifications@github.com wrote:

Yes, pressing Pin 0 (named D3 on Wemos D1 Mini) for 5 seconds deletes the configuration.

You can disable this function with (see http://marvinroger.github.io/homie-esp8266/docs/2.0.0-beta.3/advanced-usage/resetting/ )

void setup() { Homie.disableResetTrigger(); // before Homie.setup() // ... }

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/marvinroger/homie-esp8266/issues/509#issuecomment-376642845, or mute the thread https://github.com/notifications/unsubscribe-auth/AByDh8iWcUkqYqNmq13QYzNhVICfaHBpks5tipBQgaJpZM4S9QUL .

euphi commented 6 years ago

The order doesn't matter, so the way you upload it is correct.

However, please be careful with the flash size, because this has impact on the layout ("partitioning") of the program segment and SPIFFS.

For some boards (ESP-07, Wemos D1 Mini) the actual flash size differs from what is pre-configured in platformio, so you need to configure it manually with build_flags in platformio.ini. See http://docs.platformio.org/en/latest/platforms/espressif8266.html#custom-flash-size

If configured flash size does not match the actual flash size you may be stuck in a reset loop or the config.json cannot be found (I think, what happens then is related to flashing the application binary or the SPIFFS image first....)

psamim commented 6 years ago

@euphi Thanks for the insights.