I have a sketch which I have been provided from an Internet forum. It compiles properly and includes a thingProperties.h file which allows the variables to be defined.
Now I wish to create a dashboard for this project and I have found as described in many forum posts that the thingProperties files is overwritten to support the new dashboard and so of course the project has errors in the compile with undeclared variables.
I have been looking for a way of exporting the thingProperties file to the data for a dashboard but that is not the way the cloud interface works. I have therefore created a new dashboard, copied my original sketch into the created sketch for the dashboard and tried to create all the variables again from the dashboard to get as close as possible to the original thingProperties.h file.
Am I approaching this wrongly?
It seems reasonable to use examples provided on the web and (with permission) and continue to add value. But the dashboard file does not exist (related to the thingProperites.h file )does not appear to have a file definition to import from and the synchronisation only works from dash to thing.
I have read the documentation, viewed the YouTube of IOT etc. but cannot find a way to "import" the dashboard.
Your problem happens when you switch from cloud to IDE and/or backwards. IF you use the upload/download in the IDE cloud interface that will not happen. Here is screen shot showing where that is. Of course, I think you HAVE to start in the cloud to register the board and create the thing. I would also at least open the sketch and add a comment then close it then work on it in the IDE after downloading it.
Here are some screen shots, notice the 3 things related, pull sketch, push sketch, open in Cloud Editor.
SONOFCY
Thank you for taking the time to explain this so clearly. I have been working in the past lots of times in the IDE and this is my first cloud based implementation and why I used a contributed project as a base. I have been round and round the internet and could not identify the problem.
Thanks again for easing my pain!
Hi @Iredsell. I'm glad that the problem has been resolved thanks to the assistance from @sonofcy. I just wanted to add a note regarding this:
This is not necessarily true. If you use the Arduino Cloud IoT Variables from an existing Thing in a dashboard, then this won't result in any change whatsoever to the thingProperties.h
file.
There is no such thing as a "dashboard file". The Arduino Cloud IoT Thing doesn't need to have any special configuration for its Variables to be used in a dashboard. So you can add and remove the Variables of your existing Things in dashboards all you like without having to make any changes at all to the Things, or to reupload the Thing sketch program to the boards.
Although I (eventually) have created some Iot cloud apps, I was never sure what might get overwritten (as mentioned by Cloud-generated comments) and what would NEVER get overwritten.
Is there an easy-to-understand document that shows users the rules for what gets overwritten, when, and what NEVER gets overwritten?
The thingProperties.h
file of the Thing sketch is regenerated from scratch any time you make a change to relevant parts of the Thing's setup, such as adding or removing a Variable. Any changes you made to that file will be lost when that occurs.
If you add a variable to the Thing, content is added to the primary .ino
file of the Thing sketch, but the existing code in the file will not be overwritten:
If the .ino
file contains the standard header comment that is added when the Thing sketch is initially generated:
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled 5"
https://create.arduino.cc/cloud/things/ea476a39-6dc3-43db-8cb5-c97afbd74fe2
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
bool foo;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
then the list of variables in that comment will be updated. If you removed or replaced the comment then this will not be done.
If you added a Variable with "Read & Write" permissions, then an empty definition for the Variable's callback function will be added to the bottom of the .ino
file. For example:
/*
Since Bar is READ_WRITE variable, onBarChange() is
executed every time a new value is received from IoT Cloud.
*/
void onBarChange() {
// Add your code here to act upon Bar change
}
If you remove a Variable with "Read & Write" permissions, the definition of the removed Variable's callback function will not be removed from the .ino
file.
In summary, as long as you heed the warning in the thingProperties.h
file ("DO NOT EDIT
"), you don't need to worry about things in your sketch being overwritten when you change the configuration of the Thing via the "Setup" tab.
Not that I am aware of, but really the comment in the thingProperties.h
file is all you need to know.
When I did my first cloud app that is what I understood, but then something happened (at least that is what my 83yo brain recalls) that made me hesitant to use the cloud for larger sketches. I also do not remember if I ever lost some code or not but that vague memory persists.
I will try to think of a project for the cloud and first do it 'by the book' and once working play loose with it to see if it breaks or not.
When I get around to this I will provide feedback. (health issues are slowing me down consideraby)