I have an esp32 working with 3 UARTS, one that just prints over the serial port, and the other 2 connected to another esp32.
The problem is that just by declaring the EEPROM library or preference, the UART stops working after some random time. The UART stops printing over the serial port and stops communicating with the other esp32.
I have set a blinking LED with a timer, and this LED is still blinking after the UART stops.
Any way to reset the esp32 after the UART stops working? Or any advice to avoid the UART stopping working?
The same code, but without the library EEPROM or preference declared, is working with no problem.
This is the code that sets up the UART.
Code: Select all
#include "conf.h"
#include "HX711.h"
#include <HardwareSerial.h>
HX711 scales[3] ;
#define UARTSPEED 115200
// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 22;
const int LOADCELL_SCK_PIN = 23;
HardwareSerial InSerial ( 1 );
HardwareSerial OutSerial ( 2 );
#define MYPORT_TX 18
#define MYPORT_RX 19
#include <EEPROM.h>
HX711 scale;
void IRAM_ATTR Timer0_ISR()
{
mainTimer();
}
void setup() {
Serial.begin(115200);
EEPROM.begin(3);
scales_init();
OutSerial.begin (UARTSPEED, SERIAL_8N1, 19, 18);
InSerial.begin (UARTSPEED, SERIAL_8N1, 16, 17 );
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
Timer0_Cfg = timerBegin(0, 80, true);
timerAttachInterrupt(Timer0_Cfg, &Timer0_ISR, true);
timerAlarmWrite(Timer0_Cfg, 1000, true);
timerAlarmEnable(Timer0_Cfg);
pinMode(2,OUTPUT);
delay(500);
// load eeprom direction
for( int i = 0; i < 3; i ++)
{
if( EEPROM.read(i) == 1 || EEPROM.read(i) == 2)
{
// Serial.println("load eportom");
direction[i] = EEPROM.read(i);
}
Serial.println(direction[i] );
}
delay(200);
// WriteEEPROM(0,1);
}
void loop() {
// Serial.println("run");
read_uart();
read_uart_2();
scales_read_same_time();
if( sendingUart )
{
// Serial.println("send first chunk");
sendingUart = false;
sendFirstData();
}
if( send_data_to_master && firstRead )
{
send_data_to_master = false;
sendNewData();
// Serial.println(millis());
}
if(sendTestData && TEST)
{
sendTestData = false;
printFloorState();
}
if( triger_calibration > 0)
{
for(byte x =0; x < 3; x ++)
{
calibrate_last100(x);
uart_calibration(x, triger_calibration);
}
triger_calibration = 0;
}