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.