I have a code which I compiled in Cloud and in IDE(v2.2.1).
Using a ESP32 chip - NodeMCU-32S
My code is contains the Adafruit_PCF8574 library. And if I upload from Cloud via agent, the library doesn't find my i2c chip for inputs/outputs. If I upload the same code from IDE the code works perfectly.
I verified the compiler result on both version and gives me difference.
What could be the problem?
Another question, is there a way to upload the *.bin file from cloud?
My Code:
#include "arduino_secrets.h"
#include <Adafruit_PCF8574.h>
#include <Adafruit_PCF8575.h>
#include "thingProperties.h"
// Inputs and outputs form i2c
Adafruit_PCF8574 pcfOut, pcfIn;
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
if (!pcfOut.begin(0x24, &Wire)) {
Serial.println("Couldn't find PCF8574 for Outputs");
while (1);
}
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
// Your code here
}
Cloud compiler result:
Sketch uses 1130737 bytes (86%) of program storage space. Maximum is 1310720 bytes.
Global variables use 51776 bytes (15%) of dynamic memory, leaving 275904 bytes for local variables. Maximum is 327680 bytes.
IDE compiler result:
Sketch uses 1163449 bytes (88%) of program storage space. Maximum is 1310720 bytes.
Global variables use 58000 bytes (17%) of dynamic memory, leaving 269680 bytes for local variables. Maximum is 327680 bytes.
Different tools (compilers etc). Suppose you take a trip from one end of the continent to the other visiting several people and several others do the same. What are the odds all will have exactly the same mileage?
Open a forum reply here by clicking the "Reply" button.
Click the <CODE/> icon on the post composer toolbar.
This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
This will paste the compilation output into the code block.
Move the cursor outside of the code block markup.
Arduino IDE
Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
The "Preferences" dialog will open.
Check the box next to "Show verbose output during: ☐ compilation" in the "Preferences" dialog.
Click the "OK" button.
Select Sketch > Verify/Compile from the Arduino IDE menus.
Wait for the compilation to finish.
Right click on the black "Output" panel at the bottom of the Arduino IDE window.
From the context menu, click Copy All.
Open a forum reply here by clicking the "Reply" button.
Click the <CODE/> icon on the post composer toolbar.
This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
This will paste the compilation output into the code block.
Move the cursor outside of the code block markup before you add any additional text to your reply.
Click the "Reply" button to post the output.
In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here:
Open a forum reply here by clicking the "Reply" button.
Click the "Upload" icon () on the post composer toolbar:
A dialog will open.
In the dialog, select the .txt file you saved.
Click the "Open" button.
Click the "Reply" button to publish the post.
Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.
No. Arduino Cloud doesn't actually directly upload sketches to your board. It downloads the compiled binary file to your computer and then its helper tool "Arduino Create Agent" runs the standard uploader tool (esptool in the case of the ESP32 board) on your computer to upload the binary file to the board. So if you want to upload a binary file to your board, you can just do what Arduino Cloud would do directly.
It is useful to let Arduino Cloud generate the base upload command for you:
Upload a sketch to the board using Arduino Cloud.
Wait for the upload to finish.
Examine the contents of the black output panel at the bottom of the Arduino Web Editor page. You will need to scroll up to see it all. There you will find the command that was used to upload the binary file.
For example:
In the second question I referred for OTA, using the *.bin file. I could generate from the IDE and upload via OTA. Right now I purchased the Maker plan for arduino cloud, just for the OTA function. Cloud Compiler.txt (7.6 MB) IDE Compiler.txt (6.8 MB)
Edit:
I made another compilation with IDE and get this information:
FQBN: esp32:esp32:nodemcu-32s
Using board 'nodemcu-32s' from platform in folder: C:\Users\Bandi\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11
Using core 'esp32' from platform in folder: C:\Users\Bandi\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11
and in Cloud compiler:
Using board 'nodemcu-32s' from platform in folder: /home/builder/.arduino15/packages/esp32/hardware/esp32/2.0.5
Using core 'esp32' from platform in folder: /home/builder/.arduino15/packages/esp32/hardware/esp32/2.0.5
There is a difference between the version numbers
Attached the new ouptup *.txt files. I simplified the code to remain just the Adafruit_PCF8574 part in it. Cloud Compiler_v2.txt (424.9 KB) IDE Compiler_v2.txt (506.8 KB)
New code:
#include <Adafruit_PCF8574.h>
// Inputs and outputs form i2c
Adafruit_PCF8574 pcfOut, pcfIn;
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
if (!pcfOut.begin(0x24, &Wire)) {
Serial.println("Couldn't find PCF8574 for Outputs");
while (1);
}
}
void loop() {
// Your code here
}
Nice job of analyzing the output! I was also interested in checking for any additional differences in which library dependencies of the sketch were used, which are shown in the output:
Using library Adafruit PCF8574 at version 1.1.1 in folder: C:\Users\Bandi\Documents\Arduino\libraries\Adafruit_PCF8574
Using library Adafruit BusIO at version 1.14.5 in folder: C:\Users\Bandi\Documents\Arduino\libraries\Adafruit_BusIO
Using library Wire at version 2.0.0 in folder: C:\Users\Bandi\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11\libraries\Wire
Using library SPI at version 2.0.0 in folder: C:\Users\Bandi\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11\libraries\SPI
But I see that the same versions of the libraries are used on Arduino Cloud and Arduino IDE both.
So I do think the difference in the versions of the "esp32" boards platform is the cause of the different behavior of the sketch programs.
If you want to verify this, you could use the Arduino IDE Boards Manager to install version 2.0.5 of the "esp32" boards platform. The expectation is that, after doing that and using Arduino IDE to upload the sketch to your board again, the behavior would be the same as the behavior of the sketch program will be the same as when you uploaded the sketch using Arduino Cloud.
Unfortunately I don't have an idea of what specific difference between the two platform versions would cause this. I did browse through the large changelog between the version 2.0.11 of the platform you are using with Arduino IDE and the version 2.0.5 used by Arduino Cloud and didn't spot anything related to I2C or the Wire library.
There isn't any way to change the version of the platforms used by Arduino Cloud, so you are stuck with the 2.0.5 version there until the Arduino Cloud maintainers get around to upgrading it.
I know what is the problem. I'm using a Kincony board and the NodeMCU-32S pins for SDA & SCL is different than the original one. This is the major problem. The version difference maybe not a problem on this example.
Is there a possibility to update with my custom settings in Arduino Cloud?
Or if this isn't possible, then exists a way to just upload the compiled *.bin file by OTA?
Update:
I found the Arduino Cloud CLI solution for uploading the localy compiled *.bin file via OTA.
I will close this post
There is no way to modify the configuration of the "esp32" boards platform in Arduino Cloud. However, you should be able to configure the pins in your sketch by calling Wire.setPins(4, 5) in your sketch before passing the Wire object to pcfOut.begin:
Oh you are the best. Thanks for all of your help. It was clear and detailed. And this will be the best solution with setpins. I can use the cloud for downloading with this trick.