Project used to work, now fails to compile

Hi - A year ago I created an ESP8266 security device that would remotely control a relay and LED. It compiled and worked fine. It was installed at a vacation home.

I just returned to update the wifi credentials but the original code fails to compile. I get an error: “variable or field ‘BlynkWidgetWriteDefault’ declared void”. This occurs on the first of several “BLYNK_WRITE(Vx)” routines I have:

//When an iPhone App button is pushed (i.e., V10), update the hardware to match...

// When App button is pushed - switch the state
BLYNK_WRITE(V10) 
{			// virtual pin v10
	vRelayStatus = param.asInt();
	digitalWrite(relayport, vRelayStatus);
	Serial.print("Got v10 message from iPhone: "); 
	Serial.println(vRelayStatus);
}

// When App button is pushed - switch the state
BLYNK_WRITE(V11) 
{			// virtual pin v11
	vSirenLEDstatus = param.asInt();
	digitalWrite(ledport, !vSirenLEDstatus); // a zero causes LED to turn on...!
	Serial.print("Got v11 message from iPhone: "); 
	Serial.println(vSirenLEDstatus);
}

(etc...)

If I comment out those routines, this one fails:

// This is called for all virtual pins, that don't have BLYNK_WRITE handler
// It prints values as received from server if not handled
// in code BLYNK_WRITE handler...
BLYNK_WRITE_DEFAULT() 
{
	Serial.print("input from iPhone to HW V");
	Serial.print(request.pin);
	Serial.println(":");
	// Print all parameter values
	for (auto i = param.begin(); i < param.end(); ++i) 
	{
		Serial.print("* ");
		Serial.println(i.asString());
	}
}

Is this possibly an issue with library updates breaking old code?

I’m using a NODEMCU 1.0 board. My Blynk library is 0.61 (I’m not sure what version I originally used when the code properly compiled). Phone is iPhone.

I searched for this problem but couldn’t find an answer…I can post full code if anyone requests me to do so. Thanks in advance…

I’m happy to try compiling it on my machine if you post the full code.

What version of the Arduino core are you using?
(Tools, Board, Boards Manager - scroll down to the bottom, find esp8266 by ESP8266 Community)
If it’s not 2.5.0 then you might want to update it.

Pete.

does a very empty sketch with an empty BLYNK_WRITE() compile?

If not perhaps your Blynk library got removed… or your environment is messed up in some other way

I just wanted to point out,

BLYNK_WRITE_DEFAULT()

is (currently) defined as,

#define BLYNK_WRITE_DEFAULT() BLYNK_WRITE_2(Default)

BLYNK_WRITE_2 is defined as,

#define BLYNK_WRITE_2(pin) \
    void BlynkWidgetWrite ## pin (BlynkReq BLYNK_UNUSED &request, const BlynkParam BLYNK_UNUSED &param)

“pin” in this case is “Default”. “Default” is substituted for " ## pin " yielding “BlynkWidgetWriteDefault” which is (seemingly) the subject of the error.

I realize this doesn’t help much. As @PeteKnight suggested, you could try posting the “full code”. Of course, what he meant was your full Arduino sketch. The “full code” would include the Blynk library (and possibly other libraries) which is likely where the issue is at, but we can at least try to eliminate your sketch as the source of the problem.

Joe

Found the problem…

I wasn’t getting anywhere so I decided to go back to the very beginning and start with the original base code generated by the Example Builder. I discovered that the generated code had an include that apparently wasn’t required a year ago.

I added “#include <BlynkSimpleEsp8266.h>” to my file and it now compiles as it used to.

Searching these forums for “<BlynkSimpleEsp8266.h>” doesn’t bring up anything. Can anyone point me to any info on when and why that include file was first required? I’m curious, and also it might be helpful for someone else who comes along with a similar problem.

Thanks for the replies…

As far as I know, it’s been required for the past couple of years that I’ve been using Blynk.

Pete.

BlynkSimpleEsp8266.h, in turn, includes,

#include <version.h>
#include <BlynkApiArduino.h>
#include <Blynk/BlynkProtocol.h>
#include <Adapters/BlynkArduinoClient.h>
#include <ESP8266WiFi.h>
#include <BlynkWidgets.h>

BlynkApiArduino.h, in turn, includes,

#include <Blynk/BlynkApi.h>
#include <Arduino.h>

and on and on.

Hopefully, in the future, someone will take the time to search the forum for “BlynkWidgetWriteDefault” and find your solution to their problem.

Glad it’s fixed.

Joe

1 Like

Actually, I tried commenting out,

#include <BlynkSimpleEsp8266.h>

This resulted in,

variable or field 'BlynkWidgetWriteInternalPinACON' declared void

related to,

BLYNK_APP_CONNECTED()

so the error is going to vary slightly depending on which Blynk macros you use and the order in which they’re used.

If you search the forum for,

variable or field declared void 

You get several hits. Several of the issues related to macros being positioned in the sketch prior to,

#include <BlynkSimpleEsp8266.h>

Hopefully, in the future, this will point folks in the right direction.

Joe

Thanks all.

My original sketch (January 2018) definitely compiled and ran without “#include <BlynkSimpleEsp8266.h>”…I suppose I could step back to the old libraries and test to see where things went wrong…but that seems like a rathole I’d rather not go down at this point :wink:

So it took me a couple of days to update a text string to fix an SSID that had changed (this device is located in a foreign country…not easy to get to). I now understand what happened. However, from a maintenance perspective, it’s unfortunate that things can break in this way. If I didn’t have the time to spend on the problem, the remotely located device would be indefinitely offline.

Not sure how that maintenance issue might be addressed for similar situations in the future. Perhaps it might be a good idea might to always note the library versions used for compilation in case it’s necessary to revert to them in the future…

Since Blynk is in constant development, many changes to either Server (local or cloud), Libraries and the App generally require they are all kept up to date in order to keep functioning.

So, while it is possible to lock in your App version (AKA never update) and use a Local Server and Library that never changes… you may find it almost as easy to just pop in and catch up on changes and improvements every so often.

Agreed.

Now I’m a bit wiser about this…since this is a device remotely located in a foreign country, I can either a) keep a copy of the hardware device back home and make sure the mods I want to do can be implemented first locally and later remotely with current state of development, or b) do the development work (library upgrades, code changes, etc.) on site when I visit the remote location…or c) lock the code in time and space in a way that it can be recompiled anytime onsite in the future…

All methods work in their own ways. I just did (b) and came out ok. But better planning on my part would have been to test the changes (simple as they were: changing a text string) prior to the plane ride.

Just ruminating here…all turned out well this time. Not always the case… :wink:

You can freeze everything if you’re running your own local server and you never update it, or the Blynk app version on your phone, but that’s quite a messy way to do things and needs a ton of work if you want to periodically update everything to the latest versions. To test that you’d need two phones, one with the old app and another with the latest app, two local servers - your current production one and one to test the latest version.
The good thing is that deployment could be quick, as you could simply pop a new SD card in your server and re-flash the device (or swap it for a new device with the latest code).

There is also another option for remote updating, which is HTTP OTA, but you’d need to test your new code locally before deploying it to your remote device.

Pete.

To anyone searching this and finding this error. I upgraded from arduino IDE v1.8.8 to v.1.8.10 and that fixed my compiling error.

variable or field ‘BlynkWidgetWriteInternalPinACON’ declared void