Definition and Use of the Command WiFI.mode

I am gradually getting to grips with the Arduino IDE and applications of the ESP8266nodemcu Module. I am trying to use a written script (in the public domain) to determine the WIFI network it is connected to and its allocated iP address I have tried to compile the 'script' and it has failed at a line <WiFi.mode (WIFI_STA) >which the author has given the descriptor as < //WiFi mode station (connect to wifi router only> I have tried to find out the definition of the command WiFi in the Arduino programming language but have been unsuccessful. Can any one help me out please. I bet it is quite a simple answer but I have given up trawling the 'Net' to find it !! Thanking anyone in advance who can help me out. Regards Ian Bunyard.

You make the same mistake as almost all beginners: No code visible. There is seldom a meaningful answer to such open questions. Post your code - do it correctly!

Your post was MOVED to a more suitable location.

Could you also review How to get the best out of this forum as it will help you find your way around.

Hello Rudolf,

Being a beginner I apologise if I am not following the correct protocol for posting on the Forum. Just to give you an idea of to whom you are communicating with, I am a 73 year old trained ex-electronic engineer but left the design of circuits just at the time microprocessors were coming to the fore. With the advent of COVID I have decided to renew my interest in electronics with the help of a cousin, who of similar age, is following the same interest and we are helping each other to learn. The article I was following is shown in the embedded URL below.

https://circuits4you.com/2018/03/09/esp8266-static-ip-address-arduino-example/

I have made changes where appropriate to get the program to run|(as indicated in the article) but it failed to compile at the line <WiFi.mode (WIFI_STA); // Wifi mode station (connect to wifi router only>. I hope this additional information and access to the project I was working on enables you to assist.

Thank you

Ian Bunyard.

But we can't see what you changed unless you post your sketch, nor do we know what the exact error is, what hardware the sketch is running on nor the version of the IDE or your Operating System

Do you see the problem ?

What is the error message that appears when it fails to compile? The easiest way to let us know is to use the "Copy Error Messages" button that appears on the output window of the IDE and just paste the contents into the forum reply window.

As others have said, without seeing your exact code it becomes difficult if not impossible to work out what is wrong. The line of code you supply is perfectly correct, so without the error message we can only guess at the issue. It could be as simple as a missing ; on the previous line, or a missing include block - we just don't know.

When posting your code paste it in and with the code highlighted select the </> button on the top line of the reply window - this will put it in a reply block. Failing to do that can result in the code being interpreted by the display and putting emojis in place of your text for example.

Hi countrypaul ,

Thank you for your reply and to offering to assist - much appreciated.

Now you have confirmed that the line I thought was in error is correct I am pursuing trying to solve the problem myself. I wish to continue 'debugging the problem' to reinforce my learning. If I really become frustrated with all my attempts (still failing to get the script to work) it is comforting to know that you are willing to help and I will submit the 'problem' with the evidence you need, as indicated in your reply, to assist further . Kindest Regards Ian Bunyard.

Ian,

When you do solve the problem I suggest you post the solution on this thread no matter how simple (or not) it seems to be. There are many who join this site with little experience and find it very difficult to make progress, often when the problem seems to be trivial to those with many years experience. Having examples of problems posted with solutions is therefore of much help to all.

Have fun debugging...

Hi Paul

I will do as you request but not immediately simply because ( as mentioned in my profile) I am working with my cousin on ‘educating ourselves - as very much silver surfers (:rofl::rofl:)’- in current micro-computing techniques especially with the ESP range of devices to integrate into Home Assistant (HA) for home automation.

Yesterday, as I was corresponding with you, on the problems of debugging the Sketch (I had copied from an article) my cousin found a similar article, with very much the same code, and it worked just fine so we have adopted that one.

Out of interest I will pursue debugging the code I had problems with but as we are forging ahead with use of HA and the ESP devices it won’t be immediate.

I do thank you for taking the time to get back to me - sorry I’m not immediately pursuing the debugging but we are concentrating on getting our ESP8266 and ESP 32 devices configured and integrated into HA.

Kind Regards. Ian Bunyard