Must have 8 extra files in each arduino sketch folder?

The only way I can make my arduino sketch compile is to copy the 8 .h files from the demo folder to my sketch folder. Seems to me that these .h files should be in the Arduino Library. Will this happen at some time, or is this the permanent way to create a sketch for Blynk 2?

That’s how it’s meant to be. The code has been split into smaller, more manageable files to make it easier to read and manage. It’s a standard technique for managing large Arduino sketches

I don’t know if the developers plan to move some of the Blynk.Air and Provisioning functionality into the main Blynk libraries eventually, or if that’s even a practical proposition, but you should probably work on the principal that if you want to use the Edgent functionality then this is how it will be for the foreseeable future.

Pete.

Thanks for the fast reply. I can certainly copy those files for each sketch and will happily do so. The thing that bothers me about that is: what if one if the files need to change for some reason. If I have a lot of sketches, I might need to replace the changed file in all of them.

If you’ve installed the library in the Arduino IDE then when you go to File > Examples > Blynk and open the relevant Edgent example then all of the sub-files will load at the same time.
No need to copy anything from anywhere.

Pete.

Yes, I understand that the files are in the example folder, and show up as tabs in the arduino IDE. But when I create a sketch of my own, those files are not automatically placed in the sketch folder, and I get compile errors until I copy them from the example folder into my new sketch folder. Is there a way to create a new arduino sketch which automatically creates those files?

I just looked at the example folder in the library and the Edgent_ESP8266 example has those files. So, since they exist there, my include should find them.
My #include “BlynkEdgent.h” does not find them, so maybe I need to specify the path in the #include? Ive never had to do that before, Or maybe The example folder needs to be moved up in the library folder heirarchy. I’ll try that.

What I’ve been doing for simplicity is just opening up an Edgent example for whatever board is needed, adding your code to the main .ino section and then doing a “save as” file save. Easier to just start with the example sketch each time and add your code, as opposed to starting with your code and then adding all the Edgent stuff, at least in my case.

1 Like

OK, I copied the example sketch Edgent_ESP8266 to the top tier of the library and my compile found the .h files. So I guess the example was too deep in the hierarchy to be found. When I installed the library, the example folder was put at Documents/Arduino/libraries/Blynk/examples/Blynk.Edgent. That folder has the two example sketches, and each of those sketch folders has the 8 .h files.

@Strickce your approach of referencing the the library example original files is a very bad one.
You need to open the example, choose “save as” and keep a copy of the .ino and .h files in your single project folder.

This way, you have a fully self-contained sketch project in one location and any changes to the structure of the example files won’t break your project.
The Edgent examples have changed significantly between version 1.0.0 and 1.0.1 and may well change again in future.

Also, you should be editing the Settings.h file to suit the characteristics of the board that the sketch is intended for. If you only have one master Settings.h file then using multiple board types becomes impossible with the default Settings.h

The library installation put the examples in the correct place, you shouldn’t change that.

Pete.

OK, i get what you are saying, that the self contained sketch is protected from changes.
but what if the changes add some function that would benefit all of the sketches.
I will do what you suggested, and remove that copy. I hadn’t thought of editing the example and doing a save as. That’ll work OK for me. Also thanks for the Settings file advice.

Im good for now, and many thanks for your help.

It depends how the changes are implemented. If the main .ino file remains unchanged then you might be okay. However, if the ne version of the main .ino file changes in the newer release then tryi g to use your older version with changed .h files is going to break your sketch.

Far better to keep all the files of the same version together in one project folder and if you then want to make use of new features added in later releases you can do this independently, whilst still having a working fall-back position.

Pete.

I agree with Strickce, those .h files are justlike Pete said the settings.h file is probably the one you will have to change the most often and ya that should be exposed but the rest should be put in the library and out of the way of our sketches. I find by the time I’m done with my code I have a bazillion tabs !:grimacing:

the Edgent examples are examples how to put things together. you may want to change the provisioning web page. there is code for button and for indicator LED which you may not need in your project. there is example how to do OTA which you can change too. or you can remove the provisioning part and use only the OTA part…

all this is in .h files but you may like to move it to cpp files in your project
etc

And maybe you don’t need to use it :joy::joy:
I tried it at first time I use Blynk 2.0, now I prefer to use Arduino OTA and nothing else. :stuck_out_tongue_winking_eye:

1 Like