diff --git a/README.md b/README.md index 96db2cf..6c3963e 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,19 @@ It was the goal to replace the original Hoymiles DTU (Telemetry Gateway) with th ### Symbolic view ![Symbolic](docs/Wiring_ESP32_Symbol.png) +### Change pin assignment +Its possible to change the pin assignment for the following pins: +* CE +* CS +* IRQ + +This can be achieved by editing the 'platformio.ini' file and add one or more of the following lines to the 'build_flags' parameter: +``` +-DHOYMILES_PIN_CE=4 +-DHOYMILES_PIN_CS=5 +-DHOYMILES_PIN_IRQ=16 +``` + ## Flashing and starting up * Install [Visual Studio Code](https://code.visualstudio.com/download) * In Visual Studio Code, install the [PlatformIO Extension](https://marketplace.visualstudio.com/items?itemName=platformio.platformio-ide) diff --git a/lib/Hoymiles/src/HoymilesRadio.cpp b/lib/Hoymiles/src/HoymilesRadio.cpp index 757bcfe..102492f 100644 --- a/lib/Hoymiles/src/HoymilesRadio.cpp +++ b/lib/Hoymiles/src/HoymilesRadio.cpp @@ -8,7 +8,7 @@ void HoymilesRadio::init() { _dtuSerial.u64 = 0; - _radio.reset(new RF24(PIN_CE, PIN_CS)); + _radio.reset(new RF24(HOYMILES_PIN_CE, HOYMILES_PIN_CS)); _radio->begin(); _radio->setDataRate(RF24_250KBPS); _radio->enableDynamicPayloads(); @@ -22,7 +22,7 @@ void HoymilesRadio::init() Serial.println(F("Connection error!!")); } - attachInterrupt(digitalPinToInterrupt(PIN_IRQ), std::bind(&HoymilesRadio::handleIntr, this), FALLING); + attachInterrupt(digitalPinToInterrupt(HOYMILES_PIN_IRQ), std::bind(&HoymilesRadio::handleIntr, this), FALLING); openReadingPipe(); _radio->startListening(); diff --git a/lib/Hoymiles/src/HoymilesRadio.h b/lib/Hoymiles/src/HoymilesRadio.h index 2105c75..52434c2 100644 --- a/lib/Hoymiles/src/HoymilesRadio.h +++ b/lib/Hoymiles/src/HoymilesRadio.h @@ -14,9 +14,17 @@ #define MAX_RESEND_COUNT 3 -#define PIN_IRQ 16 -#define PIN_CE 4 -#define PIN_CS 5 +#ifndef HOYMILES_PIN_IRQ +#define HOYMILES_PIN_IRQ 16 +#endif + +#ifndef HOYMILES_PIN_CE +#define HOYMILES_PIN_CE 4 +#endif + +#ifndef HOYMILES_PIN_CS +#define HOYMILES_PIN_CS 5 +#endif class HoymilesRadio { public: