Closed famphuelva closed 3 months ago
The serial does not seem to work well, with a simple code on a new board this code does not show anything: `void setup(){ Serial.begin(9600); }
void loop(){
Serial.println("sgfdhsgfhs"); delay(1000); }`
thank you very much, solved.
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
include
define XPOWERS_CHIP_AXP2101
include "XPowersLib.h"
include "utilities.h"
XPowersPMU PMU;
// See all AT commands, if wanted
define DUMP_AT_COMMANDS
define TINY_GSM_RX_BUFFER 1024
define TINY_GSM_MODEM_SIM7080
include
include "utilities.h"
ifdef DUMP_AT_COMMANDS
include
StreamDebugger debugger(Serial1, Serial); TinyGsm modem(debugger);
else
TinyGsm modem(SerialAT);
endif
const char *register_info[] = { "Not registered, MT is not currently searching an operator to register to.The GPRS service is disabled, the UE is allowed to attach for GPRS if requested by the user.", "Registered, home network.", "Not registered, but MT is currently trying to attach or searching an operator to register to. The GPRS service is enabled, but an allowable PLMN is currently not available. The UE will start a GPRS attach as soon as an allowable PLMN is available.", "Registration denied, The GPRS service is disabled, the UE is not allowed to attach for GPRS if it is requested by the user.", "Unknown.", "Registered, roaming.", };
enum { MODEM_CATM = 1, MODEM_NB_IOT, MODEM_CATM_NBIOT, };
define randMax 35
define randMin 18
// Credenciales de la red const char apn[] = "***"; const char gprsUser[] = "****"; const char gprsPass[] = "*";
// cservidor mosqitto const char server[] = "***"; const int port = 1883; char buffer[1024] = {0}; char username[] = "**"; char password[] = "**"; char clientID[] = "temperatura"; int data_channel = 0;
// Número máximo de intentos de reconexión const int maxReconnectAttempts = 10;
bool isConnect() { modem.sendAT("+SMSTATE?"); if (modem.waitResponse("+SMSTATE: ")) { String res = modem.stream.readStringUntil('\r'); return res.toInt(); } return false; }
void restartModem() { digitalWrite(BOARD_MODEM_PWR_PIN, LOW); delay(100); digitalWrite(BOARD_MODEM_PWR_PIN, HIGH); delay(1000); digitalWrite(BOARD_MODEM_PWR_PIN, LOW); delay(3000); // Esperar a que el módem se reinicie completamente }
void reconnectMQTT() { int attempts = 0; while (attempts < maxReconnectAttempts) { modem.sendAT("+SMCONN"); if (modem.waitResponse(30000) == 1) { Serial.println("MQTT Conectado!"); return; } Serial.println("Conexión fallida, reconectando con MQTT ..."); delay(1000); attempts++; } Serial.println("Número máximo de intentos de reconexión alcanzado, reiniciando el módem..."); restartModem(); }
void setup() { Serial.begin(115200); while (!Serial);
}
void loop() { if (!isConnect()) { Serial.println("MQTT Cliente desconectado!"); reconnectMQTT(); delay(1000); return; }
}
This code works perfectly, it sends the data to the mqtt server, but it does not show me information on the PC console, is the board broken? I have changed the code for a simple one that the console writes and it doesn't show anything either. Is the board bad?