I already wrote a script in the IDE and works perfectly.
It is uploaded on an ESP8266 via IDE.
It already connects to my WiFi so. I can do OTA updates and such.
Now I want ome button to be able to be pressed from far away using cloud buttons on my mobile phone.
So I tried implementing all that stuff that is written into the cloud sketches once I created a Thing, Dashboard and so on into my sketch I already had in the IDE.
What didn't integrate if I remember correctly - was the connect - because Im already connected to the Internet from my script that already existed.
So basically it didn't work in the end.
Questions:
I now assumed it might not only connect to the Internet but also to the cloud service maybe and this might be the reason why it didn't work.
Is that the case?
Therefore do I need to exchange my connection method I already have in my script to the iot one?
Will I then still be able to do my now functional OTA Update?
Is there some explanation anywhere which describes how to manually integrate
cloud connectivity in an already existing IDE script?
This handles the connection to the network, and through the network to the Arduino Cloud server.
I don't have an answer to that. I suggest just giving it a try.
Not that I am aware of.
I would recommend doing it the opposite way: when you create an Arduino Cloud IoT Thing, Arduino Cloud automatically generates a "skeleton" sketch, which contains all the code necessary for the board to connect and communicate with the Arduino Cloud IoT system as a "Thing". I think it will be easiest to merge your non-IoT sketch code into that skeleton code instead of the opposite approach of merging the skeleton code into the non-IoT sketch.
To test the connection I did sync my online created connect sketch via the sync button to the IDE.
I then did connect a new test board to USB to run the connection script on that an do some testing.
But compiling the online created script gave me this error message:
In file included from c:\Users\XXX\Documents\Arduino\Sketches\libraries\ArduinoIoTCloud\src/cbor/../property/PropertyContainer.h:27:0,
from c:\Users\XXX\Documents\Arduino\Sketches\libraries\ArduinoIoTCloud\src/cbor/CBORDecoder.h:31,
from c:\Users\XXX\Documents\Arduino\Sketches\libraries\ArduinoIoTCloud\src/ArduinoIoTCloud.h:35,
from C:\Users\XXX\AppData\Local\Arduino15\RemoteSketchbook\ArduinoCloud\6e347714-1562-4efd-8f75-c1a70d71421f\ConnectTuerSketch\thingProperties.h:3,
from C:\Users\XXX\AppData\Local\Arduino15\RemoteSketchbook\ArduinoCloud\6e347714-1562-4efd-8f75-c1a70d71421f\ConnectTuerSketch\ConnectTuerSketch.ino:19:
c:\Users\XXX\Documents\Arduino\Sketches\libraries\ArduinoIoTCloud\src/cbor/../property/Property.h:38:30: fatal error: Arduino_TinyCBOR.h: No such file or directory
#include <Arduino_TinyCBOR.h>
^
compilation terminated.
exit status 1
Compilation error: exit status 1
All the thousands of libraries of the Arduino Library Manager are pre-installed on the Arduino Cloud server. This means that you don't need to worry about installing the library dependencies of your sketch projects while using Arduino Cloud Editor, as long as the dependencies are in the Library Manager.
The situation is different when using Arduino IDE. The Arduino IDE installation only comes with a few fundamental libraries, and you must install any other libraries you need.
Just as you might use libraries in your sketches, libraries may use other libraries. In this case it is necessary to install those additional libraries in order to compile the sketch. The "ArduinoIoTCloud" library that is used by your IoT Thing sketch has a dependency on the "Arduino_CloudUtils" library. The Arduino_CloudUtils library provides the Arduino_TinyCBOR.h header file. So the "Arduino_TinyCBOR.h: No such file or directory" error indicates that you have not installed the Arduino_CloudUtils library. You can fix the error by installing the missing library:
Select Sketch > Include Library > Manage Libraries... from the Arduino IDE menus to open the "Library Manager" view in the left side panel.
Type Arduino_CloudUtils in the "Filter your search..." field.
Find the "Arduino_CloudUtils" entry in the list of search results.
You will see an "INSTALL" button at the bottom of the entry. Click the button.
Wait for the installation process to finish, as indicated by a notification at the bottom right corner of the Arduino IDE window:
ⓘ Successfully installed library ...
Now try compiling or uploading the sketch again. Hopefully this time everything will work as expected.
ArduinoIoTPreferredConnection is a WiFiConnectionHandler class object. You can see the instantiation in the automatically generated thingProperties.h file of your sketch:
So ArduinoIoTPreferredConnection is just an arbitrary object name chosen by the Arduino developers. The name itself doesn't have any special significance. We could change the line above to:
WiFiConnectionHandler foobar(SSID, PASS);
and then adjust the ArduinoCloud.begin call accordingly:
ArduinoCloud.begin(foobar);
However, that change would not serve any purpose and it is not a good idea to modify the code in the thingProperties.h file, since Arduino Cloud IoT will regenerate this file if you make any changes to your Thing setup.
The WiFiConnectionHandler class is provided by the "Arduino_ConnectionHandler" library:
What it Does
There are a number of possible mechanisms a Device might use to connect to the Internet and communicate with the Arduino Cloud servers. In addition to the Wi-Fi networking technology you are using in your project, other projects might use things like:
For this reason, the network communication code in the ArduinoIoTCloud library is abstracted, rather than implementing the code that is unique to each of these communication protocols. The protocol-specific code is instead implemented in the Arduino_ConnectionHandler library. That library's ConnectionHandler class provides the abstracted communication interface that is used by the ArduinoIoTCloud library.
Yes.
Yes.
No. Arduino Cloud IoT does not use the "network" port OTA uploading system from Arduino IDE in any way. Arduino Cloud IoT provides a completely different OTA uploading feature (which is only available for certain boards):
You're right I bet I haven't that lib installed by now.
And yes I tried to install from the IDE since I can't install from online as it always says no OTA possible.
Actually I tried a Wemos D1 R1 testing board to connect instead my other one I wanted to connect lateron.
I just try to get the connection running and to understand it and then implement that in my already working script lateron.
So if I understand you correctly I need to connect to the Arduino Cloud and if I want to be able to OTA update my electronics I on top need to keep my old way for OTA from my IDE right?