E32-868T20D is a wireless serial port module (UART) based on SEMTECH's SX1276 RF chip. It has multiple transmission modes working in the 862MHz~893MHz range (default 868MHz).
No | Pin | Description |
---|---|---|
1 | M0* | Work with M1 to set 1 of 4 operating modes. |
2 | M1* | Work with M0 to set 1 of 4 operating modes. |
3 | RXD* | TTL UART input. Can be configured as open-drain or pull-up input. |
4 | TXD* | TTL UART output. Can be configured as open-drain or push-pull output. |
5 | AUX* | Indicates module’s working status. Can be configured as open-drain output orpush-pull output (floating is allowed). |
6 | VCC | Power supply 2.3-5.2V DC |
7 | GND | Ground. |
(*) All communication pins are 3.3V only !!!
No | Mode | M1 | M0 | Description |
---|---|---|---|---|
0 | Normal | 0 | 0 | UART and LoRa radio are on. |
1 | Wake Up | 0 | 1 | Same as normal but preamble code is added to transmitted data to wake up the receiver. |
2 | Power Save | 1 | 0 | UART is off, LoRa radio is on WOR(wake on radio) mode which means the device will turn on when there is data to be received. Transmission is not allowed. |
3 | Sleep | 1 | 1 | UART is on, LoRa radio is off. Is used to get/set module parameters or to reset the module. |
For the E32-868T20D, the minimum frequency is 862 MHz and the maximum is 893 MHz. The working frequency of the module is set by the channel number. The formula is :
Transparent transmission\ All modules have the same address and channel and can send/receive messages to/from each other (demo mode). The messages don't include address and channel information.
Fixed transmission\ All modules can have different addresses and channels. The transmission messages are prefixed with the destination address and channel information. If these differ from the settings of the transmitter, then the configuration of the module will be changed before the transmission. After the transmission is complete, the transmitter will revert to its prior configuration.
Fixed transmission P2P\
The transmitted message has the address and channel information of the receiver. Only this module will receive the message. This is a point to point transmission between 2 modules.\
Fixed transmission broadcast\
The transmitted message has address FFFF and a channel. All modules with any address and the same channel of the message will receive it.\
Fixed transmission monitoring\ The receiver has adress FFFF and a channel. It will receive messages from all modules with any address and the same channel as the receiver.
The module can only be configured when in sleep operating mode (M0 high & M1 high). The UART baudrate has to be 9600 and parity 8N1.
No | Command | Description |
---|---|---|
1 | C0 + config* | Set the configuration persistently. Send C0 + 5 configuration bytes in hex format. |
2 | C1+C1+C1* | Get the module configuration. Send 3x C1 in hex format. |
3 | C2 + config* | Set the configuration temporary. Send C2 + 5 configuration bytes in hex format. |
4 | C3+C3+C3** | Get the module version information. Send 3x C3 in hex format. |
5 | C4+C4+C4 | Reset the module |
(*) Default configuration bytes for E32-868T20D : C0 00 00 1A 06 44\ (**) Default version bytes for E32-868T20D : C3 45 0D 14
No | Item | Description | Remark |
---|---|---|---|
0 | HEAD | Header | 0xC3 |
1 | FREQ | Frequency (MHz) | 0x32=433, 0x38=470, 0x45=868, 0x44=915, 0x46=170 |
2 | VERS | Version number | 0x0D |
3 | FEAT | Features number | 0x14 |
To make sense of the different communication pins of the E32 LoRa module, a simple USB logic analyzer and an opensource software comes to the rescue :)\ I looked at these scenario's :
Transparent transmission\
The device is in normal mode (M0 and M1 both low). Some time after the message data is received on the RXD pin of the module, the AUX pin goes low. The AUX pin stays low until all data has been transmitted by the LoRa radio, after which it goes high again.
Fixed transmission in normal mode\
The device is in normal mode (M0 and M1 both low). Some time after the message data is received on the RXD pin of the module, the AUX pin goes low. The message is prefixed with the address and channel info. The AUX pin stays low until all data has been transmitted by the LoRa radio, after which it goes high again.
Fixed transmission in wakeup mode\
The device is in wakeup mode (M0 high, M1 low). Some time after the message data is received on the RXD pin of the module, the AUX pin goes low. The message is prefixed with the preamble wakeup signal, the address and channel info. The AUX pin stays low until all data has been transmitted by the LoRa radio, after which it goes high again.
Receiving\
The device is in normal mode (M0 and M1 both low). When the LoRa radio receives a signal, the AUX pin goes low. The AUX pin stays low until all data has been sent to the TXD pin, after which it goes high again.
Command set config with persistent save\
The device is in sleep mode (both M0 and M1 high). Some time after the set config command is received on the RXD pin of the module, the AUX pin goes low. After the config response is sent to the TXD pin, the AUX pin goes high.
Command set config with temporary save\
The device is in sleep mode (both M0 and M1 high). Some time after the set config command is received on the RXD pin of the module, the AUX pin goes low. After the config response is sent to the TXD pin, the AUX pin goes high.
Command get config\
The device is in sleep mode (both M0 and M1 high). Some time after the get config command is received on the RXD pin of the module, the AUX pin goes low. After the config response is sent to the TXD pin, the AUX pin goes high.
Command get version\
The device is in sleep mode (both M0 and M1 high). Some time after the get version command is received on the RXD pin of the module, the AUX pin goes low. After the version response is sent to the TXD pin, the AUX pin goes high.
Command reset device\
The device is in sleep mode (both M0 and M1 high). Some time after the reset command is received on the RXD pin of the module, the AUX pin goes low and stays low while the device is resetting. After the module is ready again, the AUX pin goes high.\
E32 Pin | Wire | ESP32 pin |
---|---|---|
M0 | cyan | GPIO25 |
M1 | cyan | GPIO26 |
RXD | yellow | SD3 (UART1-TXD) |
TXD | green | SD2 (UART1-RXD) |
AUX | purple | GPIO27 |
VCC | red | 3.3V |
GND | black | GND |
class ebyteE32:
''' class to interface an ESP32 via serial commands to the EBYTE E32 Series LoRa modules '''
def __init__(self, PinM0, PinM1, PinAUX, Model='868T20D', Port='U1', Baudrate=9600, Parity='8N1', AirDataRate='2.4k', Address=0x0000, Channel=0x06, debug=False):
''' constructor for ebyte E32 LoRa module '''
def start(self):
''' Start the ebyte E32 LoRa module '''
def sendMessage(self, to_address, to_channel, payload, useChecksum=False):
''' Send the payload to ebyte E32 LoRa modules in transparent or fixed mode. The payload is a data dictionary to
accomodate key value pairs commonly used to store sensor data and is converted to a JSON string before sending.
The payload can be appended with a 2's complement checksum to validate correct transmission.
- transparent mode : all modules with the same address and channel of the transmitter will receive the payload
- fixed mode : only the module with this address and channel will receive the payload;
if the address is 0xFFFF all modules with the same channel will receive the payload'''
def recvMessage(self, from_address, from_channel, useChecksum=False):
''' Receive payload messages from ebyte E32 LoRa modules in transparent or fixed mode. The payload is a JSON string
of a data dictionary to accomodate key value pairs commonly used to store sensor data. If checksumming is used, the
checksum of the received payload including the checksum byte should result in 0 for a correct transmission.
- transparent mode : payload will be received if the module has the same address and channel of the transmitter
- fixed mode : only payloads from transmitters with this address and channel will be received;
if the address is 0xFFFF, payloads from all transmitters with this channel will be received'''
def calcChecksum(self, payload):
''' Calculates checksum for sending/receiving payloads. Sums the ASCII character values mod256 and returns
the lower byte of the two's complement of that value in hex notation. '''
def reset(self):
''' Reset the ebyte E32 Lora module '''
def stop(self):
''' Stop the ebyte E32 LoRa module '''
def sendCommand(self, command):
''' Send a command to the ebyte E32 LoRa module. The module has to be in sleep mode '''
def getVersion(self):
''' Get the version info from the ebyte E32 LoRa module '''
def getConfig(self):
''' Get config parameters from the ebyte E32 LoRa module '''
def decodeConfig(self, message):
''' decode the config message from the ebyte E32 LoRa module to update the config dictionary '''
def encodeConfig(self):
''' encode the config dictionary to create the config message of the ebyte E32 LoRa module '''
def showConfig(self):
''' Show the config parameters of the ebyte E32 LoRa module on the shell '''
def waitForDeviceIdle(self):
''' Wait for the E32 LoRa module to become idle (AUX pin high) '''
def saveConfigToJson(self):
''' Save config dictionary to JSON file '''
def loadConfigFromJson(self):
''' Load config dictionary from JSON file '''
def calcFrequency(self):
''' Calculate the frequency (= minimum frequency + channel * 1MHz)'''
def setTransmissionMode(self, transmode):
''' Set the transmission mode of the E32 LoRa module '''
def setConfig(self, save_cmd):
''' Set config parameters for the ebyte E32 LoRa module '''
def setOperationMode(self, mode):
''' Set operation mode of the E32 LoRa module '''
Transmission mode | Transmitter | Receiver |
---|---|---|
transparent | code | code |
fixed P2P | code | code |
fixed broadcast | code | code |
fixed monitor | code | code |
To validate the proper working of the ebyteE32 micropython class this simple sensor measuring scenario has been implemented :
Sensor nodes
Monitor node (code)
Receiving fixed monitor :
address 1 - channel 2 - message {'pres': '101860', 'temp': '25', 'node': '02'}
204
..................
Receiving fixed monitor :
address 1 - channel 2 - message {'hum': '21', 'temp': '24', 'node': '01'}
204
..............................................
Receiving fixed monitor :
address 1 - channel 2 - message {'pres': '101852', 'temp': '25', 'node': '02'}
204
..................
Receiving fixed monitor :
address 1 - channel 2 - message {'hum': '20', 'temp': '25', 'node': '01'}
204
..............................................
Receiving fixed monitor :
address 1 - channel 2 - message {'pres': '101850', 'temp': '25', 'node': '02'}
204
..................
Receiving fixed monitor :
address 1 - channel 2 - message {'hum': '20', 'temp': '25', 'node': '01'}
204
..............................................
Receiving fixed monitor :
address 1 - channel 2 - message {'pres': '101853', 'temp': '25', 'node': '02'}
204
Influxdb server
> select * from node_01
name: node_01
time field value
---- ----- -----
1586888687213847522 hum 27
1586888687213847522 temp 12
1586889000758763606 hum 27
1586889000758763606 temp 11
...
1586951625631028963 hum 12
1586951625631028963 temp 41
1586951939053618579 hum 12
1586951939053618579 temp 41
> select * from node_02
name: node_02
time field value
---- ----- -----
1588858703347986765 pres 101987
1588858703347986765 temp 26
1588858809623716125 pres 101992
1588858809623716125 temp 26
...
1588871763234526547 pres 101853
1588871763234526547 temp 25
1588872076830457467 pres 101854
1588872076830457467 temp 25
Grafana server