From 15baa72a24f4d5111b6e0022853b0d2bd6354dc4 Mon Sep 17 00:00:00 2001 From: reaper7 Date: Thu, 17 Oct 2019 22:50:53 +0200 Subject: [PATCH 01/10] 1 stage of update --- SDM.h | 25 ++++++++++++++----- SDM_Config_User.h | 21 ++++++++++++++++ .../sdm_live_page_esp8266_hwserial.ino | 6 +++-- examples/sdm_simple/sdm_simple.ino | 16 ++++++------ 4 files changed, 51 insertions(+), 17 deletions(-) diff --git a/SDM.h b/SDM.h index 20dce3d..8cc4b37 100644 --- a/SDM.h +++ b/SDM.h @@ -35,6 +35,15 @@ #define SWAPHWSERIAL 0 //(only esp8266) when hwserial used, then swap uart pins from 3/1 to 13/15 (default not swap) #endif + #if defined ( ESP32 ) + #if !defined ( SDM_RX_PIN ) + #define SDM_RX_PIN -1 //default rx pin for selected port + #endif + #if !defined ( SDM_TX_PIN ) + #define SDM_TX_PIN -1 //default tx pin for selected port + #endif + #endif + #else #if defined ( ESP8266 ) || defined ( ESP32 ) @@ -43,6 +52,10 @@ #endif #endif + #if !defined ( SDM_RX_PIN ) || !defined ( SDM_TX_PIN ) + #error "SDM_RX_PIN and SDM_TX_PIN must be defined in SDM_Config_User.h for Software Serial option)" + #endif + #endif #if !defined ( MAX_MILLIS_TO_WAIT ) @@ -186,13 +199,13 @@ class SDM { #if defined ( ESP8266 ) // on esp8266 SDM(HardwareSerial& serial, long baud = SDM_UART_BAUD, int dere_pin = DERE_PIN, int config = SDM_UART_CONFIG, bool swapuart = SWAPHWSERIAL); #elif defined ( ESP32 ) // on esp32 - SDM(HardwareSerial& serial, long baud = SDM_UART_BAUD, int dere_pin = DERE_PIN, int config = SDM_UART_CONFIG, int8_t rx_pin=-1, int8_t tx_pin=-1); + SDM(HardwareSerial& serial, long baud = SDM_UART_BAUD, int dere_pin = DERE_PIN, int config = SDM_UART_CONFIG, int8_t rx_pin = SDM_RX_PIN, int8_t tx_pin = SDM_TX_PIN); #else // on avr SDM(HardwareSerial& serial, long baud = SDM_UART_BAUD, int dere_pin = DERE_PIN, int config = SDM_UART_CONFIG); #endif #else //software serial #if defined ( ESP8266 ) || defined ( ESP32 ) // on esp8266/esp32 - SDM(SoftwareSerial& serial, long baud = SDM_UART_BAUD, int dere_pin = DERE_PIN, int config = SDM_UART_CONFIG, int8_t rx_pin=-1, int8_t tx_pin=-1); + SDM(SoftwareSerial& serial, long baud = SDM_UART_BAUD, int dere_pin = DERE_PIN, int config = SDM_UART_CONFIG, int8_t rx_pin = SDM_RX_PIN, int8_t tx_pin = SDM_TX_PIN); #else // on avr SDM(SoftwareSerial& serial, long baud = SDM_UART_BAUD, int dere_pin = DERE_PIN); #endif @@ -220,15 +233,15 @@ class SDM { #if defined ( ESP8266 ) bool _swapuart = SWAPHWSERIAL; #elif defined ( ESP32 ) - int8_t _rx_pin=-1; - int8_t _tx_pin=-1; + int8_t _rx_pin = SDM_RX_PIN; + int8_t _tx_pin = SDM_TX_PIN; #endif #else #if defined ( ESP8266 ) || defined ( ESP32 ) int _config = SDM_UART_CONFIG; - int8_t _rx_pin=-1; - int8_t _tx_pin=-1; #endif + int8_t _rx_pin = SDM_RX_PIN; + int8_t _tx_pin = SDM_TX_PIN; #endif long _baud = SDM_UART_BAUD; int _dere_pin = DERE_PIN; diff --git a/SDM_Config_User.h b/SDM_Config_User.h index 4ce0cb9..ee3444d 100644 --- a/SDM_Config_User.h +++ b/SDM_Config_User.h @@ -25,6 +25,27 @@ //------------------------------------------------------------------------------ +/* +* define user SDM_RX_PIN and SDM_TX_PIN for esp/avr Software Serial option +* or ESP32 with Hardware Serial if default core pins are not suitable +*/ +#if defined ( USE_HARDWARESERIAL ) + #if defined ( ESP32 ) + #define SDM_RX_PIN 13 + #define SDM_TX_PIN 15 + #endif +#else + #if defined ( ESP8266 ) || defined ( ESP32 ) + #define SDM_RX_PIN 13 + #define SDM_TX_PIN 15 + #else + #define SDM_RX_PIN 10 + #define SDM_TX_PIN 11 + #endif +#endif + +//------------------------------------------------------------------------------ + /* * define user DERE_PIN for control MAX485 DE/RE lines (connect DE & /RE together to this pin) */ diff --git a/examples/sdm_live_page_esp8266_hwserial/sdm_live_page_esp8266_hwserial.ino b/examples/sdm_live_page_esp8266_hwserial/sdm_live_page_esp8266_hwserial.ino index bdd79c8..033d417 100644 --- a/examples/sdm_live_page_esp8266_hwserial/sdm_live_page_esp8266_hwserial.ino +++ b/examples/sdm_live_page_esp8266_hwserial/sdm_live_page_esp8266_hwserial.ino @@ -1,7 +1,5 @@ //sdm live page example by reaper7 -//REMEMBER! uncomment #define USE_HARDWARESERIAL in SDM_Config_User.h file too. - #define READSDMEVERY 2000 //read sdm every 2000ms #define NBREG 5 //number of sdm registers to read //#define USE_STATIC_IP @@ -33,6 +31,10 @@ TX SSer/HSer swap D8|15 |GND #include //https://github.com/reaper7/SDM_Energy_Meter #include "index_page.h" + +#if !defined ( USE_HARDWARESERIAL ) + #error "This example works with Hardware Serial on esp8266, please uncomment #define USE_HARDWARESERIAL in SDM_Config_User.h" +#endif //------------------------------------------------------------------------------ AsyncWebServer server(80); diff --git a/examples/sdm_simple/sdm_simple.ino b/examples/sdm_simple/sdm_simple.ino index 5e98364..7512e94 100644 --- a/examples/sdm_simple/sdm_simple.ino +++ b/examples/sdm_simple/sdm_simple.ino @@ -14,31 +14,29 @@ TX SSer/HSer swap D8|15 |GND |___________________________| */ -//REMEMBER! uncomment #define USE_HARDWARESERIAL in SDM_Config_User.h file too. -//#define USE_HARDWARESERIAL +//REMEMBER! uncomment #define USE_HARDWARESERIAL +//in SDM_Config_User.h file if you want to use hardware uart -#if !defined ( USE_HARDWARESERIAL ) -#include //import SoftwareSerial library -#endif #include //import SDM library #if defined ( USE_HARDWARESERIAL ) //for HWSERIAL #if defined ( ESP8266 ) //for ESP8266 -SDM sdm(Serial1, 4800, NOT_A_PIN, SERIAL_8N1); //config SDM (rx->pin13 / tx->pin15) +SDM sdm(Serial1, 4800, NOT_A_PIN, SERIAL_8N1); //config SDM #elif defined ( ESP32 ) //for ESP32 -SDM sdm(Serial1, 4800, NOT_A_PIN, SERIAL_8N1, 13, 15); //config SDM (rx->pin13 / tx->pin15) +SDM sdm(Serial1, 4800, NOT_A_PIN, SERIAL_8N1, SDM_RX_PIN, SDM_TX_PIN); //config SDM #else //for AVR SDM sdm(Serial1, 4800, NOT_A_PIN); //config SDM on Serial1 (if available!) #endif #else //for SWSERIAL +#include //import SoftwareSerial library #if defined ( ESP8266 ) || defined ( ESP32 ) //for ESP SoftwareSerial swSerSDM; //config SoftwareSerial -SDM sdm(swSerSDM, 4800, NOT_A_PIN, SWSERIAL_8N1, 13, 15); //config SDM (rx->pin13 / tx->pin15) +SDM sdm(swSerSDM, 4800, NOT_A_PIN, SWSERIAL_8N1, SDM_RX_PIN, SDM_TX_PIN); //config SDM #else //for AVR -SoftwareSerial swSerSDM(10, 11); //config SoftwareSerial (rx->pin10 / tx->pin11) +SoftwareSerial swSerSDM(SDM_RX_PIN, SDM_TX_PIN); //config SoftwareSerial SDM sdm(swSerSDM, 4800, NOT_A_PIN); //config SDM #endif From d24283f58bef1bbbeb2722c5bd206cdaedefb753 Mon Sep 17 00:00:00 2001 From: reaper7 Date: Thu, 17 Oct 2019 23:04:03 +0200 Subject: [PATCH 02/10] 2 stage of update --- README.md | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 5bcd811..224369e 100644 --- a/README.md +++ b/README.md @@ -58,23 +58,18 @@ initialization is limited to passing serial port reference (software or hardware and looks as follows: ```cpp //lib init when Software Serial is used: -#include #include +#include // for ESP8266 and ESP32 SoftwareSerial swSerSDM; -// ______________________________________________software serial reference -// | ________________________________________baudrate -// | | _____________________________dere pin for max485 -// | | | _______________software uart config -// | | | | ___________rx pin number(obligatory) -// | | | | | _______tx pin number(obligatory) -// | | | | | | -SDM sdm(swSerSDM, 9600, NOT_A_PIN, SWSERIAL_8N1, 13, 15); +// _software serial reference +// | +SDM sdm(swSerSDM); // for AVR -SoftwareSerial swSerSDM(10, 11); +SoftwareSerial swSerSDM(SDM_RX_PIN, SDM_TX_PIN); // _software serial reference // | SDM sdm(swSerSDM); @@ -92,17 +87,17 @@ If the user wants to temporarily change the configuration during the initializat then can pass additional parameters as below: ```cpp //lib init when Software Serial is used: -#include #include +#include // for ESP8266 and ESP32 SoftwareSerial swSerSDM; // ______________________________________________software serial reference -// | ________________________________________baudrate -// | | _____________________________dere pin for max485 -// | | | _______________software uart config -// | | | | ___________rx pin number(obligatory) -// | | | | | _______tx pin number(obligatory) +// | ________________________________________baudrate(optional, default from SDM_Config_User.h) +// | | _____________________________dere pin for max485(optional, default from SDM_Config_User.h) +// | | | _______________software uart config(optional, default from SDM_Config_User.h) +// | | | | ___________rx pin number(optional, default from SDM_Config_User.h) +// | | | | | _______tx pin number(optional, default from SDM_Config_User.h) // | | | | | | SDM sdm(swSerSDM, 9600, NOT_A_PIN, SWSERIAL_8N1, 13, 15); @@ -135,8 +130,8 @@ SDM sdm(Serial, 9600, NOT_A_PIN, SERIAL_8N1, false); // | ______________________________________baudrate(optional, default from SDM_Config_User.h) // | | ___________________________dere pin for max485(optional, default from SDM_Config_User.h) // | | | _______________hardware uart config(optional, default from SDM_Config_User.h) -// | | | | ________rx pin number(optional) -// | | | | | _tx pin number(optional) +// | | | | ________rx pin number(optional, default from SDM_Config_User.h) +// | | | | | _tx pin number(optional, default from SDM_Config_User.h) // | | | | | | SDM sdm(Serial, 9600, NOT_A_PIN, SERIAL_8N1, rxpin, txpin); From 93169dc620e0d69cb2b346070af888744b227c86 Mon Sep 17 00:00:00 2001 From: reaper7 Date: Thu, 17 Oct 2019 23:10:56 +0200 Subject: [PATCH 03/10] 3 stage of update --- SDM.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SDM.h b/SDM.h index 8cc4b37..9b4ecdd 100644 --- a/SDM.h +++ b/SDM.h @@ -233,15 +233,15 @@ class SDM { #if defined ( ESP8266 ) bool _swapuart = SWAPHWSERIAL; #elif defined ( ESP32 ) - int8_t _rx_pin = SDM_RX_PIN; - int8_t _tx_pin = SDM_TX_PIN; + int8_t _rx_pin; + int8_t _tx_pin; #endif #else #if defined ( ESP8266 ) || defined ( ESP32 ) int _config = SDM_UART_CONFIG; #endif - int8_t _rx_pin = SDM_RX_PIN; - int8_t _tx_pin = SDM_TX_PIN; + int8_t _rx_pin; + int8_t _tx_pin; #endif long _baud = SDM_UART_BAUD; int _dere_pin = DERE_PIN; From 96dcd79c50c6ccac620c2803e358a869ed7c778b Mon Sep 17 00:00:00 2001 From: reaper7 Date: Thu, 17 Oct 2019 23:13:59 +0200 Subject: [PATCH 04/10] 3a stage of update --- SDM.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SDM.h b/SDM.h index 9b4ecdd..3160a24 100644 --- a/SDM.h +++ b/SDM.h @@ -233,15 +233,15 @@ class SDM { #if defined ( ESP8266 ) bool _swapuart = SWAPHWSERIAL; #elif defined ( ESP32 ) - int8_t _rx_pin; - int8_t _tx_pin; + int8_t _rx_pin = SDM_RX_PIN; + int8_t _tx_pin = SDM_TX_PIN; #endif #else #if defined ( ESP8266 ) || defined ( ESP32 ) int _config = SDM_UART_CONFIG; #endif - int8_t _rx_pin; - int8_t _tx_pin; + int8_t _rx_pin = SDM_RX_PIN; + int8_t _tx_pin = SDM_TX_PIN; #endif long _baud = SDM_UART_BAUD; int _dere_pin = DERE_PIN; From 71ba46c9ca92a8029de953322e4f1a7112267aa3 Mon Sep 17 00:00:00 2001 From: reaper7 Date: Fri, 18 Oct 2019 08:03:24 +0200 Subject: [PATCH 05/10] 3b satage of update --- SDM.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/SDM.h b/SDM.h index 3160a24..50c932b 100644 --- a/SDM.h +++ b/SDM.h @@ -37,10 +37,10 @@ #if defined ( ESP32 ) #if !defined ( SDM_RX_PIN ) - #define SDM_RX_PIN -1 //default rx pin for selected port + #define SDM_RX_PIN -1 //use default rx pin for selected port #endif #if !defined ( SDM_TX_PIN ) - #define SDM_TX_PIN -1 //default tx pin for selected port + #define SDM_TX_PIN -1 //use default tx pin for selected port #endif #endif @@ -52,8 +52,15 @@ #endif #endif - #if !defined ( SDM_RX_PIN ) || !defined ( SDM_TX_PIN ) - #error "SDM_RX_PIN and SDM_TX_PIN must be defined in SDM_Config_User.h for Software Serial option)" +// #if !defined ( SDM_RX_PIN ) || !defined ( SDM_TX_PIN ) +// #error "SDM_RX_PIN and SDM_TX_PIN must be defined in SDM_Config_User.h for Software Serial option)" +// #endif + + #if !defined ( SDM_RX_PIN ) + #define SDM_RX_PIN -1 + #endif + #if !defined ( SDM_TX_PIN ) + #define SDM_TX_PIN -1 #endif #endif @@ -233,15 +240,15 @@ class SDM { #if defined ( ESP8266 ) bool _swapuart = SWAPHWSERIAL; #elif defined ( ESP32 ) - int8_t _rx_pin = SDM_RX_PIN; - int8_t _tx_pin = SDM_TX_PIN; + int8_t _rx_pin = -1; + int8_t _tx_pin = -1; #endif #else #if defined ( ESP8266 ) || defined ( ESP32 ) int _config = SDM_UART_CONFIG; #endif - int8_t _rx_pin = SDM_RX_PIN; - int8_t _tx_pin = SDM_TX_PIN; + int8_t _rx_pin = -1; + int8_t _tx_pin = -1; #endif long _baud = SDM_UART_BAUD; int _dere_pin = DERE_PIN; From 5ae9b649868fd1374590f8ec4b49dfc01b997c09 Mon Sep 17 00:00:00 2001 From: reaper7 Date: Fri, 18 Oct 2019 08:44:05 +0200 Subject: [PATCH 06/10] 2a stage of update --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 224369e..22bdaad 100644 --- a/README.md +++ b/README.md @@ -130,10 +130,10 @@ SDM sdm(Serial, 9600, NOT_A_PIN, SERIAL_8N1, false); // | ______________________________________baudrate(optional, default from SDM_Config_User.h) // | | ___________________________dere pin for max485(optional, default from SDM_Config_User.h) // | | | _______________hardware uart config(optional, default from SDM_Config_User.h) -// | | | | ________rx pin number(optional, default from SDM_Config_User.h) -// | | | | | _tx pin number(optional, default from SDM_Config_User.h) -// | | | | | | -SDM sdm(Serial, 9600, NOT_A_PIN, SERIAL_8N1, rxpin, txpin); +// | | | | ___________rx pin number(optional, default from SDM_Config_User.h) +// | | | | | _______tx pin number(optional, default from SDM_Config_User.h) +// | | | | | | +SDM sdm(Serial, 9600, NOT_A_PIN, SERIAL_8N1, 13, 15); // for AVR From 75cadc043dc949b5b8b089a5a602ecbca8c9d1f4 Mon Sep 17 00:00:00 2001 From: reaper7 Date: Fri, 18 Oct 2019 12:04:24 +0200 Subject: [PATCH 07/10] 2b stage of update --- README.md | 66 +++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 22bdaad..c5e91c5 100644 --- a/README.md +++ b/README.md @@ -92,12 +92,12 @@ then can pass additional parameters as below: // for ESP8266 and ESP32 SoftwareSerial swSerSDM; -// ______________________________________________software serial reference -// | ________________________________________baudrate(optional, default from SDM_Config_User.h) -// | | _____________________________dere pin for max485(optional, default from SDM_Config_User.h) -// | | | _______________software uart config(optional, default from SDM_Config_User.h) -// | | | | ___________rx pin number(optional, default from SDM_Config_User.h) -// | | | | | _______tx pin number(optional, default from SDM_Config_User.h) +// ________________________________________software serial reference +// | __________________________________baudrate(optional, default from SDM_Config_User.h) +// | | _______________________dere pin for max485(optional, default from SDM_Config_User.h) +// | | | _________software uart config(optional, default from SDM_Config_User.h) +// | | | | _____rx pin number(optional, default from SDM_Config_User.h) +// | | | | | _tx pin number(optional, default from SDM_Config_User.h) // | | | | | | SDM sdm(swSerSDM, 9600, NOT_A_PIN, SWSERIAL_8N1, 13, 15); @@ -126,21 +126,21 @@ SDM sdm(Serial, 9600, NOT_A_PIN, SERIAL_8N1, false); // for ESP32 -// ____________________________________________hardware serial reference -// | ______________________________________baudrate(optional, default from SDM_Config_User.h) -// | | ___________________________dere pin for max485(optional, default from SDM_Config_User.h) -// | | | _______________hardware uart config(optional, default from SDM_Config_User.h) -// | | | | ___________rx pin number(optional, default from SDM_Config_User.h) -// | | | | | _______tx pin number(optional, default from SDM_Config_User.h) +// ______________________________________hardware serial reference +// | ________________________________baudrate(optional, default from SDM_Config_User.h) +// | | _____________________dere pin for max485(optional, default from SDM_Config_User.h) +// | | | _________hardware uart config(optional, default from SDM_Config_User.h) +// | | | | _____rx pin number(optional, default from SDM_Config_User.h) +// | | | | | _tx pin number(optional, default from SDM_Config_User.h) // | | | | | | SDM sdm(Serial, 9600, NOT_A_PIN, SERIAL_8N1, 13, 15); // for AVR -// _____________________________________hardware serial reference -// | _______________________________baudrate(optional, default from SDM_Config_User.h) -// | | ____________________dere pin for max485(optional, default from SDM_Config_User.h) -// | | | ________hardware uart config(optional, default from SDM_Config_User.h) +// ______________________________hardware serial reference +// | ________________________baudrate(optional, default from SDM_Config_User.h) +// | | _____________dere pin for max485(optional, default from SDM_Config_User.h) +// | | | _hardware uart config(optional, default from SDM_Config_User.h) // | | | | // | | | | SDM sdm(Serial, 9600, NOT_A_PIN, SERIAL_8N1); @@ -158,15 +158,15 @@ List of available registers for SDM72/120/220/230/630:
https://github.com/reaper7/SDM_Energy_Meter/blob/master/SDM.h#L58 ```cpp //reading voltage from SDM with slave address 0x01 (default) -// __________register name -// | +// ____register name +// | float voltage = sdm.readVal(SDM220T_VOLTAGE); //reading power from 1st SDM with slave address ID = 0x01 //reading power from 2nd SDM with slave address ID = 0x02 //useful with several meters on RS485 line -// __________register name -// | ____SDM device ID +// _______register name +// | _SDM device ID // | | float power1 = sdm.readVal(SDM220T_POWER, 0x01); float power2 = sdm.readVal(SDM220T_POWER, 0x02); @@ -206,11 +206,11 @@ The most common problems are: You can get last error code using function: ```cpp //get last error code -// __________optional parameter, -// | true -> read and reset error code -// | false or no parameter -> read error code -// | but not reset stored code (for future checking) -// | will be overwriten when next error occurs +// ______optional parameter, +// | true -> read and reset error code +// | false or no parameter -> read error code +// | but not reset stored code (for future checking) +// | will be overwriten when next error occurs uint16_t lasterror = sdm.getErrCode(true); //clear error code also available with: @@ -222,10 +222,10 @@ https://github.com/reaper7/SDM_Energy_Meter/blob/master/SDM.h#L177
You can also check total number of errors using function: ```cpp //get total errors counter -// _________optional parameter, -// | true -> read and reset errors counter -// | false or no parameter -> read errors counter -// | but not reset stored counter (for future checking) +// _____optional parameter, +// | true -> read and reset errors counter +// | false or no parameter -> read errors counter +// | but not reset stored counter (for future checking) uint16_t cnterrors = sdm.getErrCount(true); //clear errors counter also available with: @@ -235,10 +235,10 @@ sdm.clearErrCount(); And finally you can read the counter of correctly made readings: ```cpp //get total success counter -// _________optional parameter, -// | true -> read and reset success counter -// | false or no parameter -> read success counter -// | but not reset stored counter (for future checking) +// ___optional parameter, +// | true -> read and reset success counter +// | false or no parameter -> read success counter +// | but not reset stored counter (for future checking) uint16_t cntsuccess = sdm.getSuccCount(true); //clear success counter also available with: From ab2ca03706d620cb2e2d63e5924d046c3d16b067 Mon Sep 17 00:00:00 2001 From: reaper7 Date: Fri, 18 Oct 2019 14:47:42 +0200 Subject: [PATCH 08/10] 2c stage of update --- README.md | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index c5e91c5..ea484bb 100644 --- a/README.md +++ b/README.md @@ -63,14 +63,17 @@ and looks as follows: // for ESP8266 and ESP32 SoftwareSerial swSerSDM; -// _software serial reference +// _______________________________software serial reference // | SDM sdm(swSerSDM); // for AVR SoftwareSerial swSerSDM(SDM_RX_PIN, SDM_TX_PIN); -// _software serial reference +// | |_tx pin definition(from SDM_Config_User.h) +// |_____________rx pin definition(from SDM_Config_User.h) +// +// _______________________________software serial reference // | SDM sdm(swSerSDM); ``` @@ -79,7 +82,7 @@ SDM sdm(swSerSDM); //lib init when Hardware Serial is used: #include -// _hardware serial reference +// _________________________________hardware serial reference // | SDM sdm(Serial); ``` @@ -104,9 +107,9 @@ SDM sdm(swSerSDM, 9600, NOT_A_PIN, SWSERIAL_8N1, 13, 15); // for AVR SoftwareSerial swSerSDM(10, 11); -// __________________software serial reference -// | ____________baudrate(optional, default from SDM_Config_User.h) -// | | _dere pin for max485(optional, default from SDM_Config_User.h) +// ________________________________________software serial reference +// | __________________________________baudrate(optional, default from SDM_Config_User.h) +// | | _______________________dere pin for max485(optional, default from SDM_Config_User.h) // | | | SDM sdm(swSerSDM, 9600, NOT_A_PIN); ``` @@ -116,11 +119,11 @@ SDM sdm(swSerSDM, 9600, NOT_A_PIN); #include // for ESP8266 -// _____________________________________hardware serial reference -// | _______________________________baudrate(optional, default from SDM_Config_User.h) -// | | ____________________dere pin for max485(optional, default from SDM_Config_User.h) -// | | | ________hardware uart config(optional, default from SDM_Config_User.h) -// | | | | _swap hw serial pins from 3/1 to 13/15(optional, default from SDM_Config_User.h) +// ______________________________________hardware serial reference +// | ________________________________baudrate(optional, default from SDM_Config_User.h) +// | | _____________________dere pin for max485(optional, default from SDM_Config_User.h) +// | | | _________hardware uart config(optional, default from SDM_Config_User.h) +// | | | | __swap hw serial pins from 3/1 to 13/15(optional, default from SDM_Config_User.h) // | | | | | SDM sdm(Serial, 9600, NOT_A_PIN, SERIAL_8N1, false); @@ -137,10 +140,10 @@ SDM sdm(Serial, 9600, NOT_A_PIN, SERIAL_8N1, 13, 15); // for AVR -// ______________________________hardware serial reference -// | ________________________baudrate(optional, default from SDM_Config_User.h) -// | | _____________dere pin for max485(optional, default from SDM_Config_User.h) -// | | | _hardware uart config(optional, default from SDM_Config_User.h) +// ______________________________________hardware serial reference +// | ________________________________baudrate(optional, default from SDM_Config_User.h) +// | | _____________________dere pin for max485(optional, default from SDM_Config_User.h) +// | | | _________hardware uart config(optional, default from SDM_Config_User.h) // | | | | // | | | | SDM sdm(Serial, 9600, NOT_A_PIN, SERIAL_8N1); From 0c7c1c275ede966c5731d0b97d6481a6dff3ed1f Mon Sep 17 00:00:00 2001 From: reaper7 Date: Fri, 18 Oct 2019 16:34:28 +0200 Subject: [PATCH 09/10] 2d stage of update --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ea484bb..c46473a 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,12 @@ _Tested on Wemos D1 Mini with Arduino IDE 1.8.3-1.8.10 & ESP8266 core 2.3.0-2.5. ### Configuring: ### Default configuration is specified in the [SDM.h](https://github.com/reaper7/SDM_Energy_Meter/blob/master/SDM.h#L18) file, and parameters are set to:
-Software Serial, baud 4800, uart config SERIAL_8N1, without DE/RE pin.
+Software Serial mode, baud 4800, uart config SERIAL_8N1, without DE/RE pin,
+uart pins for esp32 hwserial and esp32/esp8266/avr swserial as NOT_A_PIN (-1).

+For esp32 hwserial this means using the default pins for the selected uart port,
+specified in the core library (HardwareSerial.cpp).
+For swserial option (esp32/esp8266/avr) is necessary
+to specify the pin numbers, as described below.
User can set the parameters in two ways: - by editing the [SDM_Config_User.h](https://github.com/reaper7/SDM_Energy_Meter/blob/master/SDM_Config_User.h) file From 458b0402648032f949d384a3e5ff6791e9384ec5 Mon Sep 17 00:00:00 2001 From: reaper7 Date: Fri, 18 Oct 2019 16:36:35 +0200 Subject: [PATCH 10/10] 4a stage of update (bump version) --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 72e6cd7..3d7c455 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SDM -version=2.0.4 +version=2.0.5 author=Reaper7 maintainer=Reaper7 sentence=SDM 72/120/220/230/630 modbus energy meter