Aruino cloud and IoT projects

Salve a tutti; di solito frequento il sito in Inglese, ma per quanto vorrei chiedere penso che esprimermi e, spero, ricevere risposte nella mia lingua possa essere più semplice e costruttivo.
Scusate se questo messaggio sarà un pò lungo, ma visto che sono stato 'sgridato' per alcuni post senza tutte le informazioni...

E' il mio primo tentativo di approcciarmi alla gestione remota via Cloud di dispositivi (board e sensori) . L'obiettivo, intelligente e compesso , è di comandare il LED_BUILTIN del modulo da remoto.
In IoT Cloud ho creato una 'thing' con una variabile bool LedOn e l'ho associata allla board con le credenziali sicure di accesso, definendo il modulo: ESP8266 LOLIN(WEMOS) D1 R2 & mini sulla porta COM disponibile.
Nell'Editor ho generato lo sketch che riporto qui:

/* 
  Sketch generated by the Arduino IoT Cloud Thing "TestWemos"
  https://create.arduino.cc/cloud/things/db798eae-1f5e-4aea-9d35-f85ba2065c90 

  Arduino IoT Cloud Variables description

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

  bool ledOn;

  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 "thingProperties.h"

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); 

  // 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();
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  
  
}

/*
  Since LedOn is READ_WRITE variable, onLedOnChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onLedOnChange()  {
  // Add your code here to act upon LedOn change
  if (!ledOn) {
    digitalWrite(LED_BUILTIN, HIGH);
  } else {
    digitalWrite(LED_BUILTIN, LOW);
  }
}

Ho verificato e salvato lo sketch: tutto ok (a parte l'assurda occupazione di memoria !):



/usr/local/bin/arduino-cli compile --fqbn esp8266:esp8266:d1_mini:baud=115200,dbg=Disabled,eesz=4M,exception=disabled,ip=lm2f,lvl=None____,vt=flash,wipe=none,xtal=80 --build-cache-path /tmp --output-dir /tmp/3064935687/build --build-path /tmp/arduino-build-131BA481FCAADB356FF3D51866588896 /tmp/3064935687/TestWemos_jul09a

Sketch uses 419772 bytes (40%) of program storage space. Maximum is 1044464 bytes.

Global variables use 35896 bytes (43%) of dynamic memory, leaving 46024 bytes for local variables. Maximum is 81920 bytes.

Ho fatto l'upload e pare che tutto sia andato bene:



/usr/local/bin/arduino-cli compile --fqbn esp8266:esp8266:d1_mini:baud=115200,dbg=Disabled,eesz=4M,exception=disabled,ip=lm2f,lvl=None____,vt=flash,wipe=none,xtal=80 --build-cache-path /tmp --output-dir /tmp/4257058225/build --build-path /tmp/arduino-build-131BA481FCAADB356FF3D51866588896 /tmp/4257058225/TestWemos_jul09a

Sketch uses 419772 bytes (40%) of program storage space. Maximum is 1044464 bytes.

Global variables use 35896 bytes (43%) of dynamic memory, leaving 46024 bytes for local variables. Maximum is 81920 bytes.

Upload started

Programming with: Serial

Flashing with command:C:/Users/Utente/.arduino-create/esp8266/esptool/2.5.0-3-20ed2b9/esptool.exe -vv -cd nodemcu -cb 115200 -cp COM13 -ca 0x00000 -cf C:/Users/Utente/AppData/Local/Temp/arduino-create-agent3234640918/TestWemos_jul09a.bin

esptool v0.4.13-1-gf80ae31 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>

setting board to nodemcu

setting baudrate from 115200 to 115200

setting port from COM1 to COM13

setting address from 0x00000000 to 0x00000000

espcomm_upload_file

espcomm_upload_mem

setting serial port timeouts to 1000 ms

opening bootloader

resetting board

trying to connect

flush start

setting serial port timeouts to 1 ms

setting serial port timeouts to 1000 ms

flush complete

espcomm_send_command: sending command header

espcomm_send_command: sending command payload

read 0, requested 1

trying to connect

flush start

setting serial port timeouts to 1 ms

setting serial port timeouts to 1000 ms

flush complete

espcomm_send_command: sending command header

espcomm_send_command: sending command payload

espcomm_send_command: receiving 2 bytes of data

espcomm_send_command: receiving 2 bytes of data

espcomm_send_command: receiving 2 bytes of data

espcomm_send_command: receiving 2 bytes of data

espcomm_send_command: receiving 2 bytes of data

espcomm_send_command: receiving 2 bytes of data

espcomm_send_command: receiving 2 bytes of data

espcomm_send_command: receiving 2 bytes of data

Uploading 423920 bytes from C:/Users/Utente/AppData/Local/Temp/arduino-create-agent3234640918/TestWemos_jul09a.bin to flash at 0x00000000

erasing flash

size: 0677f0 address: 000000

first_sector_index: 0

total_sector_count: 104

head_sector_count: 16

adjusted_sector_count: 88

erase_size: 058000

espcomm_send_command: sending command header

espcomm_send_command: sending command payload

setting serial port timeouts to 15000 ms

setting serial port timeouts to 1000 ms

espcomm_send_command: receiving 2 bytes of data

writing flash

................................................................................ [ 19% ]

................................................................................ [ 38% ]

................................................................................ [ 57% ]

................................................................................ [ 77% ]

................................................................................ [ 96% ]

.............. [ 100% ]

starting app without reboot

espcomm_send_command: sending command header

espcomm_send_command: sending command payload

espcomm_send_command: receiving 2 bytes of data

closing bootloader

flush start

setting serial port timeouts to 1 ms

setting serial port timeouts to 1000 ms

flush complete

Fatto questo, non so più cosa fare., ovvero: dalla Dashboard commuto lo stato della variabile col grazioso interurrore, ma sulla mia board non succede nulla.
Alla pagina Things dell'IoT mi dice che la mia board è OffLine, nonostante lo sketch sia stato uploadato. Durante l'upload i led TX/RX blinkano regolarmente.

Prima domanda (sicuramente stupida, scusate): sul mio PC dove è connessa il modulo, devo avere l'IDE aperto (con lo sketch caricato) oppure dovrebbe funzionare anche senza l'editor locale?

Seconda domanda: la pagina di gestione del mio router TIM non visualizza alcuna connessione WiFi con Wemos: non dovrebbe appararire visto che la connessione in rete pare esserci stata? (oppure viene chiusa immediatamente?)

Terza domanda: al primo avvio, se ricordo bene, della verifica dello sketch ho ricevuto questo alert (io uso Win10 64), ripetuto 4 o 5 volte, ai quali ho sempre dato l'OK:
Alert
E' normale che lo ripeta più volte ?

Bene, se non siete ancora stramazzati per terra dopo questa cronistoria, vi ringrazio da subito per qualsiasi informazione utile vogliate darmi.

EDIT 10/07/23
Ho scoperto il Monitor dell'Editor e forse ho avuto qualche indicazione utile, anche se non per me.

***** Arduino IoT Cloud - configuration info *****
Device ID: fbb7b74f-20b7-4b1b-8eb7-dae7dc988b9e
MQTT Broker: mqtts-up.iot.arduino.cc:8884
WiFi.status(): 6....
Connection to "TIM-CC" failed
Retrying in  "4000" milliseconds
Connected to "TIM-CC"
ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to mqtts-up.iot.arduino.cc:8884
ArduinoIoTCloudTCP::handle_ConnectMqttBroker 1 connection attempt at tick time 14195
ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to mqtts-up.iot.arduino.cc:8884
ArduinoIoTCloudTCP::handle_ConnectMqttBroker 2 connection attempt at tick time 20450
.......

Serve questo per capire cosa succede?
Grazie ancora

EDIT 12/07/232: SOLVED
Vedere il post # 3

Guarda, la mia impressione è che qui, nella sezione Italiana del forum, non molti conoscono bene "IoT Cloud" e possano aiutarti; esiste una sezione del forum dedicata alle problematiche di "IoT Cloud" e la trovi QUI solo che ... è nella sezione internazionale ed occorre scrivere solo ed esclusivamente in Inglese.

Ovviamente, se qualcuno qui saprà aiutarti .... ben venga :slight_smile:

Guglielmo

Grazie Guglielmo, lo sospettavo. Non è che io abbia diificoltà ad usare la sezione Inglese, ma i frequentatori sono in genere piuttosto 'avanti' e le spiegazioni che ricevo sono talvolta troppo 'oltre' per me. Cercavo indicazioni caserecce senza timore di essere picchiato :laughing:

Comunque alla fine sono riuscito ad accendere BEN 2 led da remoto e dal cell.
Quasi sicuramente il problema era dovuto alla configurazione errata del 'device'. L'ho eliminato e ricostruito e adesso è tutto ok.

Restano alcuni problemini con l'aggiornamento dello sketch (l'Editor è un pò oscuro su questo) e la lentezza delle operazioni da remoto. Per la mia curiosità e queste prime prove sono ostacoli superabili.

Ora se riesco faccio l'Edit del mio post per indicare che è stato risolto.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.