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.
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
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
I don't know how can I tell wich exactly libraries versions is Cloud Editor using, how can I check that?
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
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
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.
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.