Can't run a basic file on cloud (but can locally) because of"No such file or directory" problem

I had a program working fine on Arduino cloud. The I revisit 3 weeks later and I get this error. FYI all my code works locally.

Sketch uses 981537 bytes (74%) of program storage space. Maximum is 1310720 bytes.
Global variables use 48416 bytes (14%) of dynamic memory, leaving 279264 bytes for local variables. Maximum is 327680 bytes.

Flashing with command:/Users/anasjehani/.arduino-create/esp32/esptool_py/4.5.1/esptool --chip esp32 --port /dev/cu.wchusbserial110 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x1000 /var/folders/69/522d7c014k70j8brf0p2stk00000gn/T/extrafiles224550319/Smart_Restock_nov21a.bootloader.bin 0x8000 /var/folders/69/522d7c014k70j8brf0p2stk00000gn/T/extrafiles224550319/Smart_Restock_nov21a.partitions.bin 0xe000 /var/folders/69/522d7c014k70j8brf0p2stk00000gn/T/extrafiles224550319/tools/partitions/boot_app0.bin 0x10000 /var/folders/69/522d7c014k70j8brf0p2stk00000gn/T/arduino-create-agent3296676596/Smart_Restock_nov21a.bin
usage: esptool write_flash [-h] [--erase-all]
                           [--flash_freq {keep,80m,60m,48m,40m,30m,26m,24m,20m,16m,15m,12m}]
                           [--flash_mode {keep,qio,qout,dio,dout}]
                           [--flash_size {detect,keep,256KB,512KB,1MB,2MB,2MB-c1,4MB,4MB-c1,8MB,16MB,32MB,64MB,128MB}]
                           [--spi-connection SPI_CONNECTION] [--no-progress]
                           [--verify] [--encrypt]
                           [--encrypt-files <address> <filename> [<address> <filename> ...]]
                           [--ignore-flash-encryption-efuse-setting] [--force]
                           [--compress | --no-compress]
                           <address> <filename> [<address> <filename> ...]
esptool write_flash: error: argument <address> <filename>: [Errno 2] No such file or directory: '/var/folders/69/522d7c014k70j8brf0p2stk00000gn/T/extrafiles224550319/Smart_Restock_nov21a.bootloader.bin'
Executing command: exit status 2

This is the file I want to run (it's part of a "thing")
code:

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/ace034f0-bec0-4f6a-b0ef-08ef14cdb137 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing


  float ideal_Temperature;
  float item_Length;
  float number_of_Items;
  float shelf_Length;
  float temperature;

  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.
*/
#include <Wire.h>
#include <Adafruit_MCP9808.h>
#include "thingProperties.h"
#include <deque> 
#include <math.h>
// Ultrasonic Sensor Pins
#define TRIG_PIN 25 // GPIO 25 ((D2) was 15)
#define ECHO_PIN 26 // GPIO 26 (D3) (was 4)
// MCP9808 Temperature Sensor Setup
Adafruit_MCP9808 tempsensor = Adafruit_MCP9808();

// Variables for Weighted Moving Average 
const int maxReadings = 5; // Number of readings to average
float weights[maxReadings] = {0.1, 0.2, 0.3, 0.4, 0.5}; // Weights for the moving average
std::deque<float> distanceQueue; // Use deque instead of queue
std::deque<float> tempQueue; 

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(115200);
  Serial.println("starting...");
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
  // MCP9808 Initialization
  if (!tempsensor.begin(0x18)) { // Default I2C address
    Serial.println("Error: MCP9808 not detected. Check connections.");
    while (1); // Stop execution if sensor not detected
  }
  Serial.println("MCP9808 detected and initialized.");

  // Ultrasonic Sensor Pin Modes
  pinMode(TRIG_PIN, OUTPUT);
  pinMode(ECHO_PIN, INPUT);
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  float rawDistance = getUltrasonicDistance();
  float filteredDistance = getWeightedAverage(distanceQueue,rawDistance); 
  number_of_Items = round(calculateItems(filteredDistance,item_Length));
  Serial.print("Distance: ");
  Serial.print(rawDistance);
  Serial.println(" cm");
  Serial.print("filtered distance: ");
  Serial.print(filteredDistance);
  Serial.println(" cm");
  Serial.print("Items left: ");
  Serial.println(number_of_Items);
  //Read Temperature from MCP9808
  temperature = getWeightedAverage(tempQueue,tempsensor.readTempC()); // get reading from temp sensor and average with weights
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println(" °C");
  // Calculate the deviation
  float deviation = abs(ideal_Temperature - temperature);
  // Trigger webhook only when deviation exceeds 5
  if (deviation > 5) {
    Serial.println("Temperature deviation exceeds 5!");
    // The webhook will automatically send the updated temperature variable
    temperature = tempsensor.readTempC(); // Updates the cloud variable
  } else {
    Serial.println("Temperature within acceptable range.");
  }  
  delay(3000); // Simulate sensor reading interval
}
/*
  Since ShelfLength is READ_WRITE variable, onShelfLengthChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onShelfLengthChange()  {
  // Add your code here to act upon ShelfLength change
  Serial.print("shelf_Length: ");
  Serial.println(shelf_Length);
}
/*
  Since ItemLength is READ_WRITE variable, onItemLengthChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onItemLengthChange()  {
  // Add your code here to act upon ItemLength change
    Serial.print("item length: ");
    Serial.println(item_Length);
}
  
float getUltrasonicDistance() {
  digitalWrite(TRIG_PIN, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIG_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN, LOW);

  long duration = pulseIn(ECHO_PIN, HIGH);
  if (duration == 0) {
    Serial.println("No echo detected.");
    return 0;
  }
  return duration * 0.034 / 2; // Convert to cm
}

float calculateItems(float distance, float itemLength) { 
  if (itemLength <= 0) { // Prevent division by zero or invalid inputs
    Serial.println("Error: Item length is invalid (<= 0).");
    return 0; // Default to 0 items
  }
  if (distance > shelf_Length) { // Prevent negative or invalid results
    Serial.println("Error: Distance exceeds shelf length.");
    return 0;
  }
  return (shelf_Length - distance) / itemLength;
}
/*
  Since IdealTemperature is READ_WRITE variable, onIdealTemperatureChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onIdealTemperatureChange()  {
  // Add your code here to act upon IdealTemperature change
  Serial.print("temp deviation allowed: ");
  Serial.println(ideal_Temperature);
}

float getWeightedAverage(std::deque<float>& queue, float newReading) {
  // Add the new reading to the deque
  queue.push_back(newReading);

  // Remove the oldest reading if the deque exceeds the size limit
  if (queue.size() > maxReadings) {
    queue.pop_front(); // Remove the oldest element (front of the deque)
  }
  // Calculate weighted average
  float weightedSum = 0;
  float totalWeight = 0;
  int index = 0;

  for (float reading : queue) { // Range-based loop over deque
    weightedSum += reading * weights[index];
    totalWeight += weights[index];
    index++;
  }

  return weightedSum / totalWeight; // Return the weighted average
}

I get this same error even with simple code like this:

void setup() {
  Serial.begin(115200);
  Serial.println("Testing Create Agent...");
}

void loop() {
  delay(1000);
}

My laptop is a MacBook Air, with a Apple M1, 8GB of memory and Macos is 13.3. My arduino cloud agent seems to work just fine.

Hi @aj509. The Arduino Cloud developers are aware of the bug. I apologize for any inconvenience this has caused. I'll let you know if I receive any news from them about a resolution.

Until then, I can suggest using Arduino IDE as a workaround.

Arduino IDE has Arduino Cloud integration, which provides convenient access to the sketches from your Arduino Cloud account.

I'll provide instructions you can follow to set up Arduino IDE and upload your sketch:

  1. Install Arduino IDE by following the instructions here.
  2. Start Arduino IDE.
  3. Install the "esp32" boards platform by following the instructions here.
  4. Connect Arduino IDE to your Arduino Cloud account by following the instructions here
  5. You should now see the list of sketches from your Arduino Cloud account in the "SKETCHBOOK" panel of the IDE window. Click on the sketch you would like to upload to your board.
  6. Click the cloud with downward pointing arrow icon ("Pull Sketch") that appears to the right of the sketch name.
    A "Synchronizing sketchbook, pulling ..." process will start.
  7. Wait for the synchronization process to finish, as indicated by the appearance of a notification at the bottom right corner of the IDE window:

    Done pulling ...

  8. Double click on the sketch name in the "SKETCHBOOK" panel.
    The sketch will open in a new Arduino IDE window.
  9. Select the appropriate board from the IDE's Tools > Board > esp32 menu.
  10. Select the appropriate port from the IDE's Tools > Port menu.
  11. Select Sketch > Upload from the Arduino IDE menus.

The sketch should now upload successfully to the board.


ⓘ Note that you can use Arduino IDE for development of Arduino Cloud Thing sketches. It is convenient to use the Arduino Cloud web interface for the initial setup of the Thing, but after that you can open the sketch in Arduino IDE for editing and uploading to your board. You will see newly created Thing sketches under the "Cloud Sketchbook" tab of the IDE's "SKETCHBOOK" panel after you click the "Sync" icon at the bottom right corner of the panel.


Please let me know if you have any questions or problems while following those instructions.

Hello again @aj509. The Arduino Cloud developers have fixed the bug. You should now be able to upload to use Arduino Cloud Editor to upload ESP32 boards without encountering that "No such file or directory" error message.

Please let us know if you still encounter any problems using Arduino Cloud.

I apologize for any inconvenience this bug has caused.

Regards, Per