diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index 0a9b2507..faee0042 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -497,7 +497,10 @@ PROGMEM const char* const custom_reset_string[] = { #define UART_MQTT_SUPPORT 0 // No support by default #endif -#define UART_MQTT_PORT Serial // Serial port +#define UART_MQTT_USE_SOFT 0 // Use SoftwareSerial +#define UART_MQTT_HW_PORT Serial // Hardware serial port (if UART_MQTT_USE_SOFT == 0) +#define UART_MQTT_RX_PIN 4 // RX PIN (if UART_MQTT_USE_SOFT == 1) +#define UART_MQTT_TX_PIN 5 // TX PIN (if UART_MQTT_USE_SOFT == 1) #define UART_MQTT_BAUDRATE 115200 // Serial speed #define UART_MQTT_BUFFER_SIZE 100 // UART buffer size diff --git a/code/espurna/uartmqtt.ino b/code/espurna/uartmqtt.ino index 07808af6..6e68ad86 100644 --- a/code/espurna/uartmqtt.ino +++ b/code/espurna/uartmqtt.ino @@ -12,6 +12,14 @@ Adapted by Xose PĂ©rez char _uartmqttBuffer[UART_MQTT_BUFFER_SIZE]; bool _uartmqttNewData = false; +#if UART_MQTT_USE_SOFT + #include + SoftwareSerial _uart_mqtt_serial(UART_MQTT_RX_PIN, UART_MQTT_TX_PIN, false, UART_MQTT_BUFFER_SIZE); + #define UART_MQTT_PORT _uart_mqtt_serial +#else + #define UART_MQTT_PORT UART_MQTT_HW_PORT +#endif + // ----------------------------------------------------------------------------- // Private // ----------------------------------------------------------------------------- @@ -75,8 +83,8 @@ void _uartmqttMQTTCallback(unsigned int type, const char * topic, const char * p // ----------------------------------------------------------------------------- void _uartmqttLoop() { - _uartmqttReceiveUART(); - _uartmqttSendMQTT(); + _uartmqttReceiveUART(); + _uartmqttSendMQTT(); } void uartmqttSetup() {