Arduino 1.6.6 Function not declared at this scope


I don't know if this should be in Installation and Troubleshooting or here in Programming Questions, but here goes.

Until now I have been using 1.6.0 to avoid a problem with ESP8266 boards which ocurred in 1.6.4 and 1.6.5 where the sketch would compile, upload but not run. Several of my boards behaved like bricks and so I went back to 1.6.0 and like magic they revived and functioned ok with the same sketches but I had a problem with a couple of libraries, OneWire.h and DallasTemperature.h so I decided to do a fresh install when I saw that a now Arduino had been released.

The first problem seems to be it doesn't like my way of writing sketches with functions which worked fine in 1.6.0, 1.6.4 and 1.6.5 and flags up all functions with a "not declared at this scope" when the functions are written in tabs. Transferring them back to the primary tab after the void Loop() gives the same problem. Where now is the correct place for functions? This is what I'm getting

Warning: platform.txt from core 'ESP8266 Modules' contains deprecated"{compiler.path}{}" {} {} "{build.path}/{archive_file}" "{object_file}", automatically converted to"{compiler.path}{}" {} {} "{archive_file_path}" "{object_file}". Consider upgrading this core.
Warning: platform.txt from core 'ESP8266 Modules' contains deprecated"{compiler.path}{}" {} {} "{build.path}/{archive_file}" "{object_file}", automatically converted to"{compiler.path}{}" {} {} "{archive_file_path}" "{object_file}". Consider upgrading this core.
/home/david/Arduino/sketches/ESP8266/ESP8266StepperControl3.1.2-dev/ESP8266StepperControl3.1.2-dev.ino: In function 'void loop()':
ESP8266StepperControl3.1.2-dev:179: error: 'UpdateMinutes' was not declared in this scope
mNow = UpdateMinutes(mNow, PrevMillis);
ESP8266StepperControl3.1.2-dev:213: error: 'RunStepper' was not declared in this scope
ESP8266StepperControl3.1.2-dev:281: error: 'WhatIsRequested' was not declared in this scope
int MessageOut = WhatIsRequested(req);
ESP8266StepperControl3.1.2-dev:290: error: 'MakeResponse' was not declared in this scope
Reply = MakeResponse(MessageOut, "Steps");
exit status 1
'UpdateMinutes' was not declared in this scope

Also, I am plagued by continual notification that some libraries need updating but I seem to go round in circles with some libraries proferring a different version after each update.

Is there and inherent problem with this version as it is very new?


Post your code!



This is the code I should have attached first time.

It’s very messy but I’ve only been doing C for 3 months :frowning:


ESP8266StepperControl3.1.2-dev.ino (12.3 KB)

bool BlindOpen = true;
bool BlindClosed = true;

So, the blinds are open and closed.

The compiler error messages?


Well spotted. How embar :-[ assing!! Ultimately it will make a difference to how the code runs but I'm assuming my present woes are to do with the compilation stage.

The error message were clumsily embedded in my first post!!

I get a bunch of errors when I try to compile your code, using 1.0.5. They all have to do with not having the same libraries that you have. Nothing about "not declared in this scope" except for variables that are instances of classes I don't have libraries for.


Thanks for reply.

Bit confusing but the target is an ESP8266-12 board and there are obviously specific libraries. Only by placing the functions somewhere at the top of the coding can I reduce the compiling errors. As I said, I am very new to C programming and I come from Basic and some VB programming where the functions are declared at the start of the coding and expanded at the end of the code.

i have tried to find if there are definitive styles for layout of C programs but for every opinion there seems to be an opposing view.

You could post a link to each non-core library you use, and I might be persuaded to install them all.


Thanks for taking the interest and trouble to look at this problem.

Here are the recent links for the Dallas Temperature, One Wire device communication and ESP8266 Core libraries

I might have to pull my Arduino installation apart and start again as it is a mess with 1.0.5 to 1.6.6 installed and numerous libraries for the same thing in various locations which grew like Topsy. It dates to when I knew nothing of Arduino (or C programming for that matter) and some versions of the libraries wouldn't work well with the ESP boards.

Good luck.

I downloaded the three libraries. I don't know exactly what to do with the ESP stuff, and don't want to trash my 1.6.6 version of the IDE unnecessarily.

So, I commented out all the WiFi stuff in the sketch, and the only error I get deals with the line:

  Reply = MakeResponse(MessageOut, "Steps");

because MakeResponse() is NOT defined anywhere in the code you posted.



That’s because I must have omitted to move the contents of the MakeResponse tab to the inline version before deleting the tab … ooops.

I think that you would have had to enter JSON link for the ESP8266 board from the Arduino install instructions and then select the Generic ESP8266 board from the IDE menu to compile correctly. However, it’s looking more likely that a blitz of the messy installation I have is essential. I go and do that and see if it makes a difference. BTW do you know if 1.6.6 compiles correctly as per 1.6.0 when the functions are placed in tabs as that seemed to me a very usable way of doing the programming instead of scrolling up and down a huge length of code.

I’ll post how I got on after reinstalling (a job I hate with a passion in linux) :angry:

If you are interested, I’ve attached the missing function (I hope)

MakeResp.ino (3.1 KB)

Well, I've removed all versions of the IDE and libraries, installed 1.6.6 afresh , cloned in ESP8266com from Github and reloaded the libraries I need for this sketch and I still get "function not declared in this scope". The only way I can get it to compile is to move all the functions from the bottom insert them between global variables and the void setup() and then I have to make sure they are in a specific order (i.e. GetTemp() comes before MakeResponse()).

I've tried using the tabs for the functions but I'm back to "function not declared in this scope", which for me is messy as I have to scroll through yards of code looking for the functions. Perhaps I'm doing it wrong or there is a crucial setting somewhere which makes the IDE behave!!!

Any help would be greatly appreciated

Any help would be greatly appreciated

Pretend that the IDE isn't trying to help you.

Define your own function prototypes, just like a real C programmer would.

Then, you can put the functions after setup() and loop(), in any order you like.

There is something stupid about the ESP addin that is screwing things up. Without that addin, the code compiles fine.

Yes, I was thinking along those lines ... including files or (as you say, function prototypes as in old BASIC.

The thing is, since blitzing the linux to install just 1.6.6, and now trying to get back to the 1.6.0 version I used to have, I am not able to flash a usable board. I mentioned this on the ESP Forum that the new ESPtool flash the code in one block, not in 2 blocks as before but no-one seemed to pick up on it. I did manage to get back to the original 1.6.0 installation I'd had before (I don't know how!) and the "bricked" boards flashed in two blocks and ran great. Now I'm back to flashing in one block and the boards are behaving as if bricked. I still suspect the new but how to replace it and where from is beyond me.

Thanks for your help and the shoulder to sob on :cry: . I will keep trying to get my 1.6.0 installation back.