Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Nander
#69380 Hi,

I have a NodeMcu Lua ESP8266 ESP-12E which i want to use to control a relais via Wifi network.

The first step was to write an Arduino Sketch which scans networks and connects to the WIFI network. However, even the std example didn't work.

To rule out hardware problems I tried the LUA version, which worked.

I gave the INO version another try and it seemed to work as well. However, it turned out it only works if the previous firmware has been the firmware from http://nodemcu.com/index_en.html

To I need to include a library or sth?

Thanks in advance,
Nander
User avatar
By Nander
#69388 One more strange thing.
The WIFI only works as long as I don't power down the chip (unplug USB).

I can do a reset and it will successfully reconnect to the WLAN. However, once I'm restarting it WLAN is gone
User avatar
By QuickFix
#69403 No, the only thing I can think of right now, is that you haven't correctly set your board in Arduino IDE:
  • "Tools" -> "Board:" -> "NodeMCU x.x (ESP-12x Module)"
  • "Tools" -> "Flash size" -> "4M (3M SPIFFS)"
The others settings should be fine (I guess).
Other possible things that can go wrong is flashing "Buggy" code that write beyond memory borders, resulting in weird results while running, but also after reflashing another project.

You should be able to re-flash an ESP as much as you want (within reason: you can reflash around 10.000 times without failures or so), without having to clear the flash memory first or first flashing a "Known working" binary.
User avatar
By Nander
#69438 (By googling) I figured out the problem and a work-around. The problem seems to be that the RF module is not properly initialised when the device is powered on or awakes from reset.

Sadly there seems to be no manual mode to switch on the RF module.

However, I found a workaround. First I made the connection to enable deep sleep, for that, we need to tie the `RST` pin to `D0`/`GPIO 16` on the ESP8266.

Then I added the following code to setup

extern "C" {
#include "user_interface.h"
}

void setup(){
if (resetInfo->reason != REASON_DEEP_SLEEP_AWAKE) {

ESP.deepSleep(10, WAKE_RF_DEFAULT)
}

Basically whenever the system comes into setup from something else than deep sleep, the system goes to deep sleep and when powering back on the RF module is enabled.