Hi All. I’m brand new to Blynk and am currently reading through the documentation and forums. I have a question about sketch organization.
I typically divide my larger sketches input multiple .cpp files in the Arduino IDE. That makes organizing large projects easier than having one huge .ino file. It also allows me to take advantage of file-level scoping of variables and functions.
So, my question is – will the Blynk callback functions such as BLYNK_READ() and BLYNK_WRITE() work as expected if they are placed in other (.cpp) files rather than the main .ino file? Obviously, I’ll put the proper #include statements in the .cpp files.
No, You have to put all Blynk- related functionality on one file currently.
Actually, it is much easier to maintain - as you can have Blynk integration and your other logic separated.
You can also have multiple .ino files, which will be concatenated together as a single file before compiling. See the Multi-file sketches section of the Arduino Build Process document. Note that what the document refers to as tabs with no extension actually have a .ino extension “under the covers”.
You can follow as @vshymanskyy suggested. I implemented similar way in my multi file project and it just works perfect. All the Blynk callback functions are also in a cpp file.
hi @gfvalvo,
do you have any examples that you could show me of how you did this. I have made separate files for the blynk setup and blynk run, but for some reason only one of them works. I have used the same process in each of my setup and run .h and .cpp files but its still not working.