Custom MySensors [https://github.com/mysensors/MySensors] modifications for the ΕΒΥΤΕ E22-400T30D [https://www.ebyte.com/en/product-view-news.html?id=939] module (LoRa SX1278 SX1276 433MHz rf Module)
Tested with MySensors v.2.3.2 and LoRa_E32_Series_Library [https://github.com/xreef/LoRa_E32_Series_Library] v1.5.0
-
LoRa_E32_Series_Library
- Download LoRa_E32_Series_Library from [https://github.com/xreef/LoRa_E32_Series_Library]
- Place LoRa_E32.cpp, LoRa_E32.h and includes directory (statesNaming.h) in folder \MySensors\hal\transport\E32\driver (create dir if needed)
-
E32 Transport for MySensors
- Place file MyTransportE32.cpp in folder \MySensors\hal\transport\E32\
-
MySensors config files modifications. Since we define a new transport called 'MY_RADIO_E32' we have to modify the following files
- MyConfig.h Add the following definitions
#define MYLORA_DEFAULT_E32_RX_PIN (9) #define MYLORA_DEFAULT_E32_TX_PIN (8) #define MYLORA_DEFAULT_E32_AUX_PIN (7) #define MYLORA_DEFAULT_E32_M0_PIN (10) #define MYLORA_DEFAULT_E32_M1_PIN (11) #ifndef MYLORA_E32_RX_PIN #define MYLORA_E32_RX_PIN MYLORA_DEFAULT_E32_RX_PIN #endif #ifndef MYLORA_E32_TX_PIN #define MYLORA_E32_TX_PIN MYLORA_DEFAULT_E32_TX_PIN #endif #ifndef MYLORA_32_AUX_PIN #define MYLORA_32_AUX_PIN MYLORA_DEFAULT_E32_AUX_PIN #endif #ifndef MYLORA_E32_M0_PIN #define MYLORA_E32_M0_PIN MYLORA_DEFAULT_E32_M0_PIN #endif #ifndef MYLORA_E32_M1_PIN #define MYLORA_E32_M1_PIN MYLORA_DEFAULT_E32_M1_PIN #endif
These are the module RX,TX and AUX pin connections.
Also change line
// Enable sensor network "feature" if one of the transport types was enabled #if defined(MY_RADIO_RF24) || defined(MY_RADIO_NRF5_ESB) || defined(MY_RADIO_RFM69) || defined(MY_RADIO_RFM95) || defined(MY_RS485)
to
// Enable sensor network "feature" if one of the transport types was enabled #if defined(MY_RADIO_RF24) || defined(MY_RADIO_NRF5_ESB) || defined(MY_RADIO_RFM69) || defined(MY_RADIO_RFM95) || defined(MY_RS485) || defined(MY_RADIO_E32)
- MySensors.h
Change line
// TRANSPORT INCLUDES #if defined(MY_RADIO_RF24) || defined(MY_RADIO_NRF5_ESB) || defined(MY_RADIO_RFM69) || defined(MY_RADIO_RFM95) || defined(MY_RS485)
to
// TRANSPORT INCLUDES #if defined(MY_RADIO_RF24) || defined(MY_RADIO_NRF5_ESB) || defined(MY_RADIO_RFM69) || defined(MY_RADIO_RFM95) || defined(MY_RS485) || defined(MY_RADIO_E32)
Also at the section // Transport drivers include the MyTransportE32.cpp driver For example change from
// Transport drivers #if defined(MY_RADIO_RF24) #include "hal/transport/RF24/driver/RF24.cpp" #include "hal/transport/RF24/MyTransportRF24.cpp"
to
// Transport drivers #if defined(MY_RADIO_RF24) #include "hal/transport/RF24/driver/RF24.cpp" #include "hal/transport/RF24/MyTransportRF24.cpp" #elif defined(MY_RADIO_E32) #include "hal/transport/E32/MyTransportE32.cpp"
- MyCapabilities.h Optional step in // Transport section
Change line
#if defined(MY_RADIO_RF24) || defined(MY_RADIO_NRF5_ESB) #define MY_CAP_RADIO "N"
to
#if defined(MY_RADIO_RF24) || defined(MY_RADIO_NRF5_ESB) #define MY_CAP_RADIO "N" #elif defined(MY_RADIO_E32) #define MY_CAP_RADIO "E"
- MySensorsCore.cpp
Optional step add a 500ms delay in function sendSketchInfo
Change
bool sendSketchInfo(const char *name, const char *version, const bool requestEcho) { bool result = true; if (name) { result &= _sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_SKETCH_NAME, requestEcho).set(name)); } if (version) { result &= _sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_SKETCH_VERSION, requestEcho).set(version)); } return result; }
to
bool sendSketchInfo(const char *name, const char *version, const bool requestEcho) { bool result = true; if (name) { result &= _sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_SKETCH_NAME, requestEcho).set(name)); } if (version) { wait(500); result &= _sendRoute(build(_msgTmp, GATEWAY_ADDRESS, NODE_SENSOR_ID, C_INTERNAL, I_SKETCH_VERSION, requestEcho).set(version)); } return result; }
- Make sure to include the new transport (E32) to your nodes/ gateway scketches
#define MY_RADIO_E32
The ΕΒΥΤΕ E22-400T30D operates on 3.3v If using 5v host e.g., arduino make sure to include proper voltage conversion e.g. 2-Channel Logic Level Converter 3.3V to 5V TTL Bi-directional Module
Sample files garageNode.ino and E32Gateway.ino
Make sure to include a short delay betwwen communication attemps within your node e.g.
#define SHORT_WAIT 1000
send(msg);
sleep(SHORT_WAIT);
send(msg);