Notifications
Clear all

Nodemcu V3 upload problem

30 Posts
4 Users
4 Likes
1,106 Views
(@onearm)
Member
Joined: 11 months ago
Posts: 9
Topic starter  

Hi, I'm very new to this, I have tried compiling and uploading Bill's WiFi sketch, but get this error all the time:

Code:

/*Code from DroneBot Workshop.
* This sketch demonstrates how to scan WiFi networks.
* The API is almost the same as with the WiFi Shield library,
* the most obvious difference being the different file you need to include:
*/
#include "WiFi.h"
 
void setup()
{
Serial.begin(115200);
 
// Set WiFi to station mode and disconnect from an AP if it was previously connected
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
 
Serial.println("Setup done");
}
 
void loop()
{
Serial.println("scan start");
 
// WiFi.scanNetworks will return the number of networks found
int n = WiFi.scanNetworks();
Serial.println("scan done");
if (n == 0) {
Serial.println("no networks found");
} else {
Serial.print(n);
Serial.println(" networks found");
for (int i = 0; i < n; ++i) {
// Print SSID and RSSI for each network found
Serial.print(i + 1);
Serial.print(": ");
Serial.print(WiFi.SSID(i));
Serial.print(" (");
Serial.print(WiFi.RSSI(i));
Serial.print(")");
Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");
delay(10);
}
}
Serial.println("");
 
// Wait a bit before scanning again
delay(5000);
Error:

/home/bjm/Arduino/CH341SER_LINUX/dronebot_WiFi_may19a/dronebot_WiFi_may19a.ino: In function 'void setup()':
/home/bjm/Arduino/CH341SER_LINUX/dronebot_WiFi_may19a/dronebot_WiFi_may19a.ino:13:10: error: 'class WiFiClass' has no member named 'mode'
13 | WiFi.mode(WIFI_STA);
| ^~~~
/home/bjm/Arduino/CH341SER_LINUX/dronebot_WiFi_may19a/dronebot_WiFi_may19a.ino:13:15: error: 'WIFI_STA' was not declared in this scope
13 | WiFi.mode(WIFI_STA);
| ^~~~~~~~
/home/bjm/Arduino/CH341SER_LINUX/dronebot_WiFi_may19a/dronebot_WiFi_may19a.ino: In function 'void loop()':
/home/bjm/Arduino/CH341SER_LINUX/dronebot_WiFi_may19a/dronebot_WiFi_may19a.ino:40:55: error: 'WIFI_AUTH_OPEN' was not declared in this scope; did you mean 'AUTH_OPEN'?
40 | Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");
| ^~~~~~~~~~~~~~
| AUTH_OPEN
/home/bjm/Arduino/CH341SER_LINUX/dronebot_WiFi_may19a/dronebot_WiFi_may19a.ino:47:16: error: expected '}' at end of input
47 | delay(5000);
| ^
/home/bjm/Arduino/CH341SER_LINUX/dronebot_WiFi_may19a/dronebot_WiFi_may19a.ino:21:1: note: to match this '{'
21 | {
| ^

exit status 1

Compilation error: 'class WiFiClass' has no member named 'mode'

Could someone please help?

Thanks

If you can't be bothered to keep learning and helping others in life, you may as well put the other foot in the grave.


   
Quote
rommudoh
(@rommudoh)
Member
Joined: 1 year ago
Posts: 32
 

Which WiFi library did you install? It might have been the wrong one. For ESP32, it should already be included with the board. Did you select the correct board?

 

Also, you are missing a closing curly brace at the end.

Current projects:
- Modding my Gameboy Advance SP
- Turning Dalek into robot
Finished projects:
- Talking plant monitor (ESP8266)
- Mail box monitor (ESP8266-01S)
Other devices:
- Raspberry Pi 4B 4GB running Home Assistant


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6895
 

@onearm While I try to figure out what is happening, would you kindly use the help and /or the practice forums to learn how to post code? When it is not posted as code it is a little hard for us to read and understand.

Also, post the link to Bill's article, and post a screenshot of your Tools menu.

I just selected an ESP32DEV board (almost any esp32 will work) and then selected the Example WiFiScan under WiFi and as you can see it compiles fine.

Screenshot 2023 05 20 at 07.36.01
Screenshot 2023 05 20 at 07.37.30
Screenshot 2023 05 20 at 07.38.31

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6895
 

@onearm It looks like some of your sketch is missing, try using this one from the ESP32 Examples. I am both pasting it here using the Code feature, and supplying a zip file.

/*
 *  This sketch demonstrates how to scan WiFi networks.
 *  The API is based on the Arduino WiFi Shield library, but has significant changes as newer WiFi functions are supported.
 *  E.g. the return value of `encryptionType()` different because more modern encryption is supported.
 */
#include "WiFi.h"

void setup()
{
    Serial.begin(115200);

    // Set WiFi to station mode and disconnect from an AP if it was previously connected.
    WiFi.mode(WIFI_STA);
    WiFi.disconnect();
    delay(100);

    Serial.println("Setup done");
}

void loop()
{
    Serial.println("Scan start");

    // WiFi.scanNetworks will return the number of networks found.
    int n = WiFi.scanNetworks();
    Serial.println("Scan done");
    if (n == 0) {
        Serial.println("no networks found");
    } else {
        Serial.print(n);
        Serial.println(" networks found");
        Serial.println("Nr | SSID                             | RSSI | CH | Encryption");
        for (int i = 0; i < n; ++i) {
            // Print SSID and RSSI for each network found
            Serial.printf("%2d",i + 1);
            Serial.print(" | ");
            Serial.printf("%-32.32s", WiFi.SSID(i).c_str());
            Serial.print(" | ");
            Serial.printf("%4d", WiFi.RSSI(i));
            Serial.print(" | ");
            Serial.printf("%2d", WiFi.channel(i));
            Serial.print(" | ");
            switch (WiFi.encryptionType(i))
            {
            case WIFI_AUTH_OPEN:
                Serial.print("open");
                break;
            case WIFI_AUTH_WEP:
                Serial.print("WEP");
                break;
            case WIFI_AUTH_WPA_PSK:
                Serial.print("WPA");
                break;
            case WIFI_AUTH_WPA2_PSK:
                Serial.print("WPA2");
                break;
            case WIFI_AUTH_WPA_WPA2_PSK:
                Serial.print("WPA+WPA2");
                break;
            case WIFI_AUTH_WPA2_ENTERPRISE:
                Serial.print("WPA2-EAP");
                break;
            case WIFI_AUTH_WPA3_PSK:
                Serial.print("WPA3");
                break;
            case WIFI_AUTH_WPA2_WPA3_PSK:
                Serial.print("WPA2+WPA3");
                break;
            case WIFI_AUTH_WAPI_PSK:
                Serial.print("WAPI");
                break;
            default:
                Serial.print("unknown");
            }
            Serial.println();
            delay(10);
        }
    }
    Serial.println("");

    // Delete the scan result to free memory for code below.
    WiFi.scanDelete();

    // Wait a bit before scanning again.
    delay(5000);
}

 

 

 

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1657
 

Hi @onearm,

   I am sure we all recognise it is hard when you first start, and I hope that you find  Ron (@zander) 's suggestions on how to post helpful..

e.g it has just taken me about 10-15 minutes just to find the article you are working from ..

https://dronebotworkshop.com/esp32-intro/       the Load WiFI section

... so please provide links to everything you talk about ...

and unfortunately, unless you are careful when posting code and error messages, they can be very difficult to read

----------------------------------

.... However, I can see the first error ... and for 99.99% of the time, you need to fix the first error, before worrying about any other errors that follow.

13:10: error: 'class WiFiClass' has no member named 'mode'
13 | WiFi.mode(WIFI_STA);
| ^~~~

This suggests the compiler has found an include file "WiFi.h" (otherwise it would have errored on #include "WiFi.h" at the start of the sketch), but the defintion of the "WiFi" class in that file does not define a method called "mode". i.e. You computer probably has several files called "WiFi.h", and it is using the wrong one.

The Arduino system normally tries to find the right file, but unfortunately cannot detect when it has got the wrong one.

-----

As a first try to fix this, have you followed the whole of the article you are working from?

https://dronebotworkshop.com/esp32-intro/      

... it starts with setting up your computer and a simple Blink sketch section. If you have jumped straight to the WiFi section, I suggest you try again, but follow every single step from the beginning of the whole video+blog..

Bill (@dronebot-workshop) is very careful to ensure his instructions work first time, but sometimes, you need to have done something in an earlier section, and it is very easy to miss a small but vital step.

If you are still stuck, have a look through the advice about how to post code,  and provide an updated post of your situation. Note that when posting, just below the "ADD Reply" button there is another line of 'buttons' including  "Save Draft" and "Preview" .... before hitting ADD REPLY, use these to get a view of what your post will look like .. that way you can easily 'pretty-fy' it before posting if necessary.

In particular, also clarify which board you are using, and what board and library you are selecting.

Good luck, Dave

 


   
Ron reacted
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6895
 

@onearm FYI @davee As always, Dave has provided excellent advice. As I have seen this problem many many times with first timers, let me add a tiny bit more detail to Dave's instructions. The selection of a board controls what Board level (WiFi chip, for example) libraries are included. Many of these have identical names, so, for instance, I have 3 board-level WiFi.h, and 3 wifi.h. YES, the case is important. I also have in my personal library another WiFi.h. It is a special version for AT commands using esp boards.

TIP: If you are just copying one of Bill's sketches and it will not compile, the error in 99.99999% of the cases is a board selection error, or a messed up (because instructions were not followed) IDE install. All you need to post is the link to Bill's blog article (NOT Youtube Video). In your case it would be https://dronebotworkshop.com/esp32-intro/  /a> That way we can quickly try a compile in case something has changed.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
DaveE reacted
ReplyQuote
(@onearm)
Member
Joined: 11 months ago
Posts: 9
Topic starter  

@rommudoh Good morning and thanks for your reply. I had installed the ESP32 WiFi libray but when I tried uploading, it said too many WiFi libraries, so I deleted it and just tried the Arduino stock library that the code calls for, also if I changed the code to include just the ESP32 WiFi library, I don't know how it would affect the coding of the sketch. I don't understand why it comes up with this error at line 13: Compilation error: 'class WiFiClass' has no member named 'mode'. Why is this?

I did check for the end curly bracket, yes you are correct, it was missing and added one, but it makes no difference.

Something else that baffles me, is that in the Blink sketch, setting the inbuilt LED HIGH, switches the LED off!

Thanks

If you can't be bothered to keep learning and helping others in life, you may as well put the other foot in the grave.


   
ReplyQuote
(@onearm)
Member
Joined: 11 months ago
Posts: 9
Topic starter  

@zander Hi Ron, thanks so much for your comprehensive reply. I'll try that and get back to you. 

Cheers.

If you can't be bothered to keep learning and helping others in life, you may as well put the other foot in the grave.


   
ReplyQuote
(@onearm)
Member
Joined: 11 months ago
Posts: 9
Topic starter  

@davee Thanks very much for your in depth reply.

I did run the Blink sketch, but the HIGH to the inbuilt LED, actually turns it off. I had an argument with the Thai supplier about this as all the instructions I have ever seen, have HIGH on and LOW off!

I will work through your suggestions and get back to you.

I really only spend a few hours of an evening on the computer, as days are taken up with manual labour building around the place.

Cheers

If you can't be bothered to keep learning and helping others in life, you may as well put the other foot in the grave.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6895
 

@onearm You get the missing member error because you have the wrong WiFi library. There should be NO WiFi.h file in your libraries folder/directory. The correct file is supplied by the board selection of 'esp32 Dev Module'. I have loaded the same sketch that you have and it compiles just fine. I have helped dozens of newcomers with these kinds of errors, it has NEVER been an Arduino error or a bad sketch.

Show us what you are doing, show me a pic of your sorted-by-name library folder centred on the W's, show me a pic of your board selection, and show me the title bar so I can be sure the sketch is the correct one.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@davee)
Member
Joined: 3 years ago
Posts: 1657
 

Hi @onearm,

  Re: class WiFiClass' has no member named 'mode'. Why is this?

To answer this question properly, you need to be familiar with C++ .... not something that can be provided in a forum answer! So I'll try to give an oversimplified taster of an answer, to give a general indication. This will not be enough for you to understand it properly, but I hope it gives a flavour.

The libraries (in general) use the extended range of C++ code syntax, not just the 'original' C language. A major part of this extended range of syntax includes the keyword 'class'.

You are probably used to using 'function's ... essentially a block of code that does a particular task.

 

int adder(int a, int b)
{
   int c = a + b;
   return c;
}

-------

You may also be familiar with data 'struct' ..  a way of grouping a number of simple variables together, e.g:

struct Books {
     char title[100];
     char author[50];
    char description[100];
} ;

--------

A C++ 'class' combines both functions and data stuctures together to form a 'super' block of code and data together. The functions held by a class are called 'method's.

When a class is defined by the programmer it is given a name. However, the class definition itself, is like a new 'type' .... remember keywords like int and char define 'type's ... and C++ allows the programmer to define new types.

To actually use the class in a program, the programmer must create actual instantiations of the class, in the same way that "int c;" creates an instantiation of an int (integer) called 'c';

--------

Now to try to make it easier, the Arduino libraries do most of this stuff hidden away from the basic sketch ... but unfortunately, when you get an error, it tends to spill out out all over the screen ....

13:10: error: 'class WiFiClass' has no member named 'mode'

13 | WiFi.mode(WIFI_STA);
| ^~~~

This says line 13 , particularly looking at the 10th character onwards, has a problem ... a class (definition) called 'WiFiClass' has been found, but it doesn't have a method (function) called 'mode'

And it lists line 13 for reference .... which includes 'WiFi' ... the instantiated name of the class object of type 'WiFiClass'

and

'mode(WIFI_STA)' which would be method (function) called 'mode' being passed a parameter value of 'WIFI_STA'.

-------------------------------------------------------------------------------------------------------

The implication being all of the class definition and instantiation would be in the library loaded in the background, and 'stitched together' by the include file "WiFi.h" Unfortunately, although it has found some stuff it was expecting, other bits are missing ... usually because you have the wrong files or libraries ... unfortunately the some file and library names have been used more than once, plus updates can mean different versions are 'floating in the ether'.

--------------------------------------------

I hope that gives at least a feel for what is going on ... from an immediate fix point of view, I suggest you 'start again' with a new project, or even maybe a fresh Arduino install, and follow Bill's instructions from the beginning, being very careful to not to miss any steps.

---------------

In the longer term, it is worth looking into learning C++ ... or at least the 'class' bit! There are lots of free resources on the web ... but that is another story.

------------------------------------------------

As for:

I did run the Blink sketch, but the HIGH to the inbuilt LED, actually turns it off.

Perhaps you are refering to a particular point in a video or similar, but I'll try to give a 'generic' answer as to what might be happening'

You will be aware, a microcontroller output pin can usually drive an LED + series resistor ... however, the end of the LED+resistor that is NOT connected to the microcontroller. can either be connected to the ground line, or the VCC (3.3V or 5V) line.

If the end of the LED+resistor that is not connected to the microcontroller is connected to the ground line, the the microcontroller output must go high (3.3V or 5V), to apply a voltage to the LED.

However, if the end of the LED+resistor that is not connected to the microcontroller is connected to the VCC line, the microcontroller output must go low (0V), to apply a voltage to the LED.

If you are connecting your own LED to a output pin, then the choice is yours, but obviously if the LED is built into the board, then you need to know the circuit.

-------

Hope this makes some sense. There is lot to learn at the start, but it will get more familiar.

Best wishes, Dave


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6895
 

@davee He was using the builtin LED, so HIGH should indeed be ON and LOW OFF. Something very weird going on there.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6895
 

@davee FYI @onearm The fact that he found an instance of WiFi.h but not the correct version tells me he has a WiFi library in his personal 'libraries'. The reason, I am sure, is that the order of concatenation is personal library first, then board library, then built-in.

The reason there are multiple identically named libraries is that the WiFi chip is NOT the same on all boards. I have 3 for instance, as I have many different board families, 9 in total, but the other 6 board families either have no WiFi capabilities, or they use add-on libraries for WiFi support. I have 55 add-on WiFi libraries in my personal library.

I am not positive of the following but here is a possibility.

The 'standard definition of includes is "filename" is resolved from the user source and/or include dirs followed by the <filename> locations that are known here as the board's library and/or built-in.

I noticed in looking at the code for WiFiScan it uses "WiFi.h," so I then looked at the WiFiScan folder for esp32 and saw a src folder. I am guessing the src dir is in the search path, and it contains a WiFi.h and WiFi.cpp file. There are a total of 19 .h and .cpp files that are all named WiFixxxx. 

I tried an experiment and copied the WiFiScanino file to my personal source folder. I expected the compile to fail, but it succeeded, and now I am not sure what that means. 

Sorry, but I a still recovering from a serious health issue or I would dig further, but I am 100% sure the error is in your computer. Scan your personal source structure for WiFi.h and if any are found delete the entire dir it is found in.

I am attaching a pic of the compiled output The pic should be self-evident but if not ask me. Those lines are just a couple before the Global line at the end of the normal compile process. Look for them in yours and post them back, maybe it will tell us something.

Screenshot 2023 05 20 at 20.15.33

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@onearm)
Member
Joined: 11 months ago
Posts: 9
Topic starter  

@davee Hi Dave and everone else who have tried to helpThanks very much. As you said.:

Bill (@dronebot-workshop) is very careful to ensure his instructions work first time, but sometimes, you need to have done something in an earlier section, and it is very easy to miss a small but vital step.

Indeed, I find his instructions and tutorials fantastic, this is why I joined the forum.

I'm using Linux Manjaro XFCE on an HP Pavilion laptop. I think what may be a good idea, is to go back, clear out all WiFi libraries, reinstall the ESP32, make sure the Python file from Bill's ESP32 Fetting Started videofrom three years ago is installed and the run the sketch you have suggested.

Once again, thank you all for 'being kind to the old man'!

If you can't be bothered to keep learning and helping others in life, you may as well put the other foot in the grave.


   
ReplyQuote
(@onearm)
Member
Joined: 11 months ago
Posts: 9
Topic starter  

@davee Thanks for the indepth reply Dave. I'm using IDE version 2.1, which seems to put libraries in a different location to version 1.8.19. As an example, I have libraries here, /home/bjm/.arduino15/libraries/ and  /home/bjm/Arduino/CH341SER_LINUX/libraries, (this has WiFi libray too!) To make clearing of libraries easier, where should they be to avoid confusion?

A good place for me to go firstly, is library manager, knock out any WiFi libraries, close the IDE, shut the computer down and sart again. Your thoughts?

Thanks

If you can't be bothered to keep learning and helping others in life, you may as well put the other foot in the grave.


   
ReplyQuote
Page 1 / 2