2

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

The first step was to write an Arduino Sketch which scans networks and connects to the network. However, even the standard example from the examples menu didn't work (c.f.,https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/examples/WiFiScan/WiFiScan.ino) .

To rule out hardware problems I tried the LUA version from the list API doc (see below), which worked.

 -- print ap list
function listap(t)
      for k,v in pairs(t) do
        print(k.." : "..v)
      end
end

wifi.sta.getap(listap)

Using a firmware build from http://nodemcu.com/index_en.html

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 something ?

Thanks in advance, Cafebabe

4
  • What is this "std example" you speak of? Also, you're asking us to help you for free but you won't even take the time to type out the full word "standard"? What is this "LUA version" you speak of?
    – per1234
    Aug 22, 2017 at 7:22
  • you need to play with arduino esp8266's wifi.disconnect() to make sure the internal wifi settings are correctly initialized, the lua stuff likely set them in a way that happened to work when you later re-uploaded your C++.
    – dandavis
    Aug 22, 2017 at 18:22
  • How can I check whether they are correctly initialised? A simple disconnect doesn't change anything. :(
    – CAFEBABE
    Aug 22, 2017 at 19:12
  • I had no trouble running the Arduino .ino example in a nodeMCU 0.9.
    – user31481
    Aug 28, 2017 at 17:33

1 Answer 1

1

(By googling) I figured out the problem and a work-around. But not an executable solution. 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.