Code generated from Arduino Cloud Editor and upload from Arduino IDE doesn't work (LYLIGO T-A7670G - ESP32 WROVER-E, ESP32S3)

Hello, I have a trouble with Arduino IDE 2.3.4 to upload codes generated from Arduino Cloud.

I have programmed lots of times ESP32 boards with Arduino IoT Cloud Editor and they have worked fine and connected to the Cloud with no problem. Now I'm having a trouble and it is I want to programm the board LILYGO T-A7670G (link: T-A7670E/G/SA R2 – LILYGO®, wich has a ESP32 WROVER-E board inside) but Arduino Cloud Editor doesn't recognize it either as a ESP32 Wrover Module neither a ESP32 Dev Module, as many Youtubers do. So I decided to try programming this board with Arduino IDE 2.3.4, but first I tryed it with an known ESP32S3 board wich I have programmed many times with Arduino Cloud Editor, so I could understand if Arduino IDE Works for me, and what a surprise! the same code that works from Cloud Editor with the known ESP32S3 board doesn't work when it is uploaded from Arduino IDE 2.3.4. So now I have this issue, the board LILYGO T-A7670G isn't recognized by Arduino Cloud Editor and Arduino IDE doesn't work well for me. I have to clear up that Arduino IDE 2.3.4 did work with other codes, but didn't with codes generated from Arduino Cloud Editor.

I need please your help, so will be attentive to your answer.

Thank you very much

David

Let's start by posting the esp32s3 code that isn't working in the IDE. Post it in code tags so we can try it.

Please describe the symptoms.

Are you using the same version of the ESP32 board package and exactly the same versions of the libraries in the IDE and the Cloud Editor.

You're using IDE 2.x and posted in IDE 1.x. I suspect that this is not IDE related and hence your topic has been moved to a more suitable location on the forum

#include "arduino_secrets.h"
/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/217d464e-e325-4f34-8843-72db11529c40 

  Arduino IoT Cloud Variables description

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

  float consumo_dia;
  float corriente_l1;
  float factor_potencia;
  float frecuencia;
  float voltaje;

  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.
*/

//Bibliotecas
#include "thingProperties.h"
#include <OneWire.h>
#include <DallasTemperature.h>
#include "time.h"
#include "sntp.h"
#include <ModbusMaster.h>
#include <SoftwareSerial.h>

//inicialización variables tiempo
const char* ntpServer = "pool.ntp.org";
const char* ntpServer2 = "time.nist.gov";
const long  gmtOffset_sec = -5;
const int   daylightOffset_sec = 0;

//Inicialización comunicación MODBUS
SoftwareSerial mySerial(10, 9); // RX, TX
ModbusMaster node;

//PINES
#define ONE_WIRE_BUS 2
int puerta = 4; //pin magnetico puerta

//VARIABLES
int segundoactual;
char timeWeekDay[10];
char mes[4];
char segundo[4];
char hora[4];
char fechayhora[26];
uint16_t result;
int diaactual;
int mesactual;
float consumo_ayer;
float consumo_mes;
float consumo_mes_pasado;
float potencia_activa_l1;

//BANDERAS
bool bandera1s;
bool bandera_leer2;
bool banderaAR;
bool bandera10s;
bool bandera_leer;
bool bandera_dia;
bool bandera_mes;

//ONE WIRE
OneWire oneWire(ONE_WIRE_BUS);// Setup a oneWire instance to communicate with any OneWire device
DallasTemperature sensors(&oneWire); // Pass oneWire reference to DallasTemperature library

void setup() {
  sensors.begin();	// Start up the library, sensores OneWire
  Serial.begin(9600);
  delay(1500);

  mySerial.begin(9600);//Inicialización comunicación MODBUS a 9600 bauds
  // Modbus slave ID 1, PZEM 014
  node.begin(1, mySerial);//Comunicación con id 1

  //Inicializacion pines
  pinMode(puerta, INPUT);

  sntp_servermode_dhcp(1);

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

  // Init and get the time
  configTime(gmtOffset_sec, daylightOffset_sec, ntpServer, ntpServer2);
  printLocalTime();
}

void loop() {
  ArduinoCloud.update();
  printLocalTime();

  //----------------------------LECTURAS----------------------------//
  //Lecturas monitoreo
  if (bandera_leer2){
    bandera_leer2=0;
    //sensors.requestTemperatures(); // Send command to all the sensors for temperature conversion, sensores OneWire
    //Lectura temperatura interior 
    //temperatura_interior = sensors.getTempCByIndex(0);
    //Lectura temperatura condensador
    //temperatura_condensador = sensors.getTempCByIndex(1);
    //Lectura estado magnetico puerta
    //estado_puerta=!digitalRead(puerta);
  }

  //Comunicación Analizador PZEM 014, ID:1
  if (bandera_leer){
    bandera_leer=0;
    node.begin(1, mySerial);
    result = node.readInputRegisters(0x0000,10);
    if (result == node.ku8MBSuccess){
      voltaje=(node.getResponseBuffer(0x0000))*0.1;
      corriente_l1=(node.getResponseBuffer(0x0002)*65536 + node.getResponseBuffer(0x0001))*0.001;
      potencia_activa_l1=(node.getResponseBuffer(0x0004)*65536 + node.getResponseBuffer(0x0003))*0.1;
      frecuencia=(node.getResponseBuffer(0x0007))*0.1;
      factor_potencia=(node.getResponseBuffer(0x0008))*0.01;
      //Calculos
      consumo_dia += potencia_activa_l1*10/3600;
    }
  }

  //-----------------------------TIEMPO-------------------------------//
  //Tiempo monitoreo, cada segundo
  if (bandera1s==0){
    bandera1s=1;
    segundoactual=atoi(segundo);
  }
  if (atoi(segundo)!=segundoactual && banderaAR==0){
    bandera_leer2=1;
    bandera1s=0;
  }

  //Tiempo variables analizador PZEM 014: cada 10s
  if ((atoi(segundo)%10 == 0) && (bandera10s==0)){
    bandera_leer=1;
    bandera10s=1;
    banderaAR=1;
  }
  if (atoi(segundo)%10 != 0){
    bandera10s=0;
    banderaAR=0;
  }

  //Tiempo consumo dia
  if (bandera_dia==0){
    bandera_dia=1;
    diaactual=atoi(timeWeekDay);
  }
  if (atoi(timeWeekDay)!=diaactual){
    consumo_ayer=consumo_dia;
    bandera_dia=0;
    consumo_dia=0;
  }
  
  //Tiempo consumo mes
  if (bandera_mes==0){
    bandera_mes=1;
    mesactual=atoi(mes);
  }
  if (atoi(mes)!=mesactual){
    consumo_mes_pasado=consumo_mes;
    bandera_mes=0;
    consumo_mes=0;
  }
}


//FUNCIONES
//Funcion tiempo
void printLocalTime(){
  struct tm timeinfo;
  if(!getLocalTime(&timeinfo)){
    return;
  }
  strftime(timeWeekDay,10, "%w", &timeinfo);
  strftime(mes,4, "%m", &timeinfo);
  strftime(segundo,4, "%S", &timeinfo);
  strftime(hora,4, "%H", &timeinfo);
  strftime(fechayhora,26, "%c", &timeinfo);
}

Here is the code sonofcy thank you very much for your help, I will be attentive

You have to post ALL the code, I can bypass secrets, but I can't test without thingProperties.h. Post it as well.

// Code generated by Arduino IoT Cloud, DO NOT EDIT.

#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>

const char DEVICE_LOGIN_NAME[]  = "b7ae14a2-1159-4cb2-9235-de95088625d0";

const char SSID[]               = SECRET_SSID;    // Network SSID (name)
const char PASS[]               = SECRET_OPTIONAL_PASS;    // Network password (use for WPA, or use as key for WEP)
const char DEVICE_KEY[]  = SECRET_DEVICE_KEY;    // Secret device password


float consumo_dia;
float corriente_l1;
float factor_potencia;
float frecuencia;
float voltaje;

void initProperties(){

  ArduinoCloud.setBoardId(DEVICE_LOGIN_NAME);
  ArduinoCloud.setSecretDeviceKey(DEVICE_KEY);
  ArduinoCloud.addProperty(consumo_dia, READ, 10 * SECONDS, NULL);
  ArduinoCloud.addProperty(corriente_l1, READ, 10 * SECONDS, NULL);
  ArduinoCloud.addProperty(factor_potencia, READ, 10 * SECONDS, NULL);
  ArduinoCloud.addProperty(frecuencia, READ, 10 * SECONDS, NULL);
  ArduinoCloud.addProperty(voltaje, READ, 10 * SECONDS, NULL);

}

WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

My mistake sonofcy, here it is , thanks

Thank you as well sterretje.

  1. Symptoms are: the code does upload, with no poblem apparently, but neither the communication with sensors nor the communication with Cloud works. It stands like frozen, I don't know. When I try once and once again to upload the code from Cloud Editor it works inmediately

  2. I don't know how can I tell wich exactly libraries versions is Cloud Editor using, how can I check that?

  3. Yeah you are ricght, its IDE 2.x

Thanks sterretje, what can I do?

Your code does not compile, it is relying on a library SoftwareSerial. Here are that library properties, noticer your board is not supported. Why not just use normal Serial?

name=SoftwareSerial
version=1.0
author=Arduino
maintainer=Arduino <info@arduino.cc>
sentence=Enables serial communication on any digital pin.
paragraph=The SoftwareSerial library has been developed to allow serial communication on any digital pin of the board, using software to replicate the functionality of the hardware UART.
category=Communication
url=http://www.arduino.cc/en/Reference/SoftwareSerial
architectures=renesas,renesas_portenta,renesas_uno

Thank you Sonofcy, you tell me to use just Serial?

Yes, it is available in both the IDE and the IoT Cloud.

OK and could it work to communicate also with a RS485 device? What about HardwareSerial, could it also work?

I am not sure I understand what you want anymore. There is a builtin Serial for both the IDE and the IoT. If they are for some reason not usefull to you then start a new topic because your original topic has been shown to be false. Goodbye.

I need that the code compiles with IDE, but I also need to keep the RS485 communication, wich was done with the library SoftwareSerial, do you understand me? I need that the full code compiles not just a bit of it. Thanks

The code does compile and uploads in fact, you have to install EspSoftwareSerial, but once it uploads the board doesn't work well. Thats the problem

Please post complete code (or a stripped down version that demonstrates the issue); your snippet from post #6 does not contain a reference to SoftwareSerial.
Please post a wiring diagram / schematic.

I'm not an ESP32 user so can't further advise.

Hello @sterretje thank you very much. I did posted the code in post #4.

Hello @sonofcy and @sterretje . Hope you are doing well, thank you for your help so far.

I tried a new code, which I created in Arduino Cloud Editor and uploaded from Arduino IDE and it worked correctly, connecting to the cloud. However, the code I am having problems with, to upload from Arduino IDE and connect to the Cloud, is the following. Could you help me find the cause of the error?. I repeat, this code does upload from Arduino Cloud Editor, and also does it from Arduino IDE but doesn’t connect to the Cloud when its uploaded from Arduino IDE.

I really can't help you as I know nothing about ESP32 as well as nothing about cloud.

Only advise I can give is to take the working code and little by little start adding your sensor code till it fails to connect.

Thank you @sterretje I will try it that way

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