Package: ebyte-lora-e32-rpi
This is a porting of the Arduino library for EBYTE LoRa E32 devices to RaspberryPiA complete tutorial on my sitewww.mischianti.orgLoRa E32 device for Arduino, esp32 or esp8266: settings and basic usageLoRa E32 device for Arduino, esp32 or esp8266: libraryLoRa E32 device for Arduino, esp32 or esp8266: configurationLoRa E32 device for Arduino, esp32 or esp8266: fixed transmissionLoRa E32 device for Arduino, esp32 or esp8266: power saving and sending structured dataLoRa E32 device for Arduino, esp32 or esp8266: WOR (wake on radio) the microcontroller and Arduino shieldLoRa E32 device for Arduino, esp32 or esp8266: WOR (wake on radio) microcontroller and new WeMos D1 mini shieldChangelog2023-12-27 0.0.3 Fix json requirements2023-05-02 0.0.2 Fix 900MHz devices frequency2023-03-21 0.0.1 Fully functional libraryLibrary usageHere an example of constructor, you must pass the UART interface and (if you want, but It's reccomended)
the AUX pin, M0 and M1.InstallationTo install the library execute the following command:pipinstallebyte-lora-e32-rpiInitializationfromlora_e32importLoRaE32importserialloraSerial=serial.Serial('/dev/serial0')#, baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS)lora=LoRaE32('433T20D',loraSerial,aux_pin=18,m0_pin=23,m1_pin=24)Start the module transmissioncode=lora.begin()print(ResponseStatusCode.get_description(code))Get Configurationfromlora_e32importLoRaE32,print_configuration,Configurationfromlora_e32_operation_constantimportResponseStatusCodecode,configuration=lora.get_configuration()print(ResponseStatusCode.get_description(code))print_configuration(configuration)The result----------------------------------------
HEAD : 0b11000000 192

AddH : 0
AddL : 2
Chan : 23  ->  433

SpeedParityBit    : 0b0  ->  8N1 (Default)
SpeedUARTDatte : 0b11  ->  9600bps (default)
SpeedAirDataRate  : 0b10  ->  2.4kbps (default)
OptionTrans       : 0b1  ->  Fixed transmission (first three bytes can be used a
s high/low address and channel)
OptionPullup      : 0b1  ->  TXD, RXD, AUX are push-pulls/pull-ups (default)    
OptionWakeup      : 0b0  ->  250ms (default)
OptionFEC         : 0b1  ->  Turn on Forward Error Correction Switch (Default)
OptionPower       : 0b0  ->  20dBm (Default)
----------------------------------------Set Configurationconfiguration_to_set=Configuration('433T20D')configuration_to_set.ADDL=0x02configuration_to_set.OPTION.fixedTransmission=FixedTransmission.FIXED_TRANSMISSIONcode,confSetted=lora.set_configuration(configuration_to_set)The configuration object has a lot of parameters.classConfiguration:classSpeed:def__init__(self,model):self.model=modelself.airDataRate=AirDataRate.AIR_DATA_RATE_010_24self.uartBaudRate=UARTBaudRate.BPS_9600self.uartParity=UARTParity.MODE_00_8N1classOption:def__init__(self,model):self.model=modelself.transmissionPower=TransmissionPower(self.model).get_transmission_power().get_default_value()self.fec=ForwardErrorCorrectionSwitch.FEC_1_ONself.wirelessWakeupTime=WirelessWakeUpTime.WAKE_UP_250self.ioDriveMode=IODriveMode.PUSH_PULLS_PULL_UPSself.fixedTransmission=FixedTransmission.TRANSPARENT_TRANSMISSIONclassConfiguration:def__init__(self,model):self.HEAD=0self.ADDH=0self.ADDL=0self.SPED=Speed(model)self.CHAN=23self.OPTION=Option(model)I create a CONSTANTS class for each parameter, here a list:
AirDataRate, UARTBaudRate, UARTParity, TransmissionPower, ForwardErrorCorrectionSwitch, WirelessWakeUpTime, IODriveMode, FixedTransmissionSend string messageHere an example of send data, you can pass a stringlora.send_transparent_message('pippo')lora.send_fixed_message(0,2,23,'pippo')Here the receiver codewhileTrue:iflora.available()>0:code,value=lora.receive_message()print(ResponseStatusCode.get_description(code))print(value)time.sleep(2)ResultSuccess!
pippoSend dictionary messageHere an example of send data, you can pass a dictionarylora.send_transparent_dict({'pippo':'fixed','pippo2':'fixed2'})lora.send_fixed_dict(0,0x01,23,{'pippo':'fixed','pippo2':'fixed2'})Here the receiver codewhileTrue:iflora.available()>0:code,value=lora.receive_dict()print(ResponseStatusCode.get_description(code))print(value)print(value['pippo'])time.sleep(2)ResultSuccess!
{'pippo': 'fixed', 'pippo2': 'fixed2'}
fixedWiringRaspberry PiLoRa E32 (EBYTE LoRa SX1278/SX1276) series Library for Arduino, esp8266 and esp32-I create a library to manage EBYTE E32 series of LoRa device, very powerfull, simple and cheap device.LoRa E32-TTL-100You can find hereAliExpress (3Km device)AliExpress (8Km device)They can work over a distance of 3000m to 8000m, and they have a lot of features and parameter.So i create this library to simplify the usage.Please refer to my article to get updated SchemaLibraryYou can find my library here.To download.Click the DOWNLOADS button in the top right corner, rename the uncompressed folder LoRa_E32.Check that the LoRa_E32 folder contains LoRa_E32.cpp and LoRa_E32.h.Place the LoRa_E32 library folder your /libraries/ folder.You may need to create the libraries subfolder if its your first library.Restart the IDE.PinoutE32 TTL 100You can buy hereAliExpressPin No.Pin itemPin directionPin application1M0Input（weak pull-up）Work with M1 & decide the four operating modes.Floating is not allowed, can be ground.2M1Input（weak pull-up）Work with M0 & decide the four operating modes.Floating is not allowed, can be ground.3RXDInputTTL UART inputs, connects to external (MCU, PC) TXD outputpin. Can be configured as open-drain or pull-up input.4TXDOutputTTL UART outputs, connects to external RXD (MCU, PC) inputpin. Can be configured as open-drain or push-pull output5AUXOutputTo indicate module’s working status & wakes up the external MCU. During the procedure of self-check initialization, the pin outputs low level. Can be configured as open-drain output orpush-pull output (floating is allowed).6VCCPower supply 2.3V~5.5V DC7GNDGroundAs you can see you can set various modes via M0 and M1 pins.ModeM1M0ExplanationNormal00UART and wireless channel is good to goWke-Up01Same as normal but a preamble code is added to transmitted data for waking-up the receiver.Power-Saving10UART is disable and wireless 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.Sleep11Used in setting parameters. Transmitting and receiving disabled.As you can see there are some pins that can be use in a static way, but If you connect It to the library you gain in performance and you can control all mode via software, but we are going to explain better next.Fully connected schemaAs I already say It’s not important to connect all pin to the output of microcontroller, you can put M0 and M1 pins to HIGH or LOW to get desidered configuration, andif you don’t connect AUX the library set a reasonable delay to be sure that the operation is complete.AUX pinWhen transmitting data can be used to wake up external MCU and return HIGH on data transfer finish.LoRa E32 AUX Pin on transmissionWhen receiving AUX going LOW and return HIGH when buffer is empty.LoRa e32 AUX pin on receptionIt’s also used for self checking to restore normal operation (on power-on and sleep/program mode).LoRa e32 AUX pin on self-checkesp8266 connection schema is more simple because It work at the same voltage of logical communications (3.3v).LoRa E32 TTL 100 Wemos D1 fully connectedIt’s important to add pull-up resistor (4,7Kohm) to get good stability.M0D7M1D6RXPIN D2 (PullUP 4,7KΩ)TXPIN D3 (PullUP 4,7KΩ)AUXD5 (Input)3.3vGNDArduino working voltage is 5v, so we need to add a voltage divider on RX pin M0 and M1 of LoRa module to prevent damage, you can get more information hereVoltage divider: calculator and application.You can use a 2Kohm resistor to GND and 1Kohm from signal than put together on RX.LoRa E32 TTL 100 Arduino fully connectedM07 (Voltage divider)M16 (Voltage divider)RXPIN D2 (PullUP 4,7KΩ & Voltage divider)TXPIN D3 (PullUP 4,7KΩ)AUX5 (Input)VCC3.3vGNDGNDBasic configuration optionADDHHigh address byte of module (the default 00H)00H-FFHADDLLow address byte of module (the default 00H)00H-FFHSPEDInformation about data rate parity bit and Air data rateCHANCommunication channel（410M + CHAN*1M）, default 17H (433MHz),valid only for 433MHz device00H-1FHOPTIONType of transmission, pull-up settings, wake-up time, FEC, Transmission powerSPED detailUART Parity bit:  _UART mode can be different between communication parties|7|6|UART parity bit|Const value|
|---|---|---|---|---|
|0|0|8N1 (default)|MODE_00_8N1|
|0|1|8O1|MODE_01_8O1|
|1|0|8 E1|MODE_10_8E1|
|1|1|8N1 (equal to 00)|MODE_11_8N1|UART baud rate: UART baud rate can be different between communication parties, The UART baud rate has nothing to do with wireless transmission parameters & won’t affect the wireless transmit / receive features.543TTL UART baud rate（bps）Constant value0001200001240001048000119600 (default)100192001013840011057600111115200Air data rate: The lower the air data rate, the longer the transmitting distance, better anti- interference performance and longer transmitting time, The air data rate must keep the same for both communication parties.210Air data rate（bps）Constant value0000.3kAIR_DATA_RATE_000_030011.2kAIR_DATA_RATE_001_120102.4k (default)AIR_DATA_RATE_010_240114.8kAIR_DATA_RATE_011_481009.6kAIR_DATA_RATE_100_9610119.2kAIR_DATA_RATE_101_19211019.2k (same to 101)AIR_DATA_RATE_110_19211119.2k (same to 101)AIR_DATA_RATE_111_192OPTION detailTransmission mode: in fixed transmission mode, the first three bytes of each user’s data frame can be used as high/low address and channel. The module changes its address and channel when transmit. And it will revert to original setting after complete the process.7Fixed transmission enabling bit（similar to MODBUS）Constant value0Transparent transmission modeFT_TRANSPARENT_TRANSMISSION1Fixed transmission modeFT_FIXED_TRANSMISSIONIO drive mode: this bit is used to the module internal pull- up resistor. It also increases the level’s adaptability in case of open drain. But in some cases, it may need external pull-upresistor.6IO drive mode ( default 1)Constant value1TXD and AUX push-pull outputs, RXD pull-up inputsIO_D_MODE_PUSH_PULLS_PULL_UPS0TXD、AUX open-collector outputs, RXD open-collector inputsIO_D_MODE_OPEN_COLLECTORWireless wake-up time: the transmit & receive module work in mode 0, whose delay time is invalid & can be arbitrary value, The transmitter works in mode 1 can transmit the preamble code of the corresponding time continuously, when the receiver works in mode 2, the time means the monitor interval time (wireless wake-up). Only the data from transmitter that works in mode 1 can bereceived.543wireless wake-up timeConstant value000250ms (default)WAKE_UP_250001500msWAKE_UP_500010750msWAKE_UP_7500111000msWAKE_UP_10001001250msWAKE_UP_12501011500msWAKE_UP_15001101750msWAKE_UP_17501112000msWAKE_UP_2000FEC: after turn off FEC, the actual data transmission rate increases while anti- interference ability decreases. Also the transmission distance is relatively short, both communication parties must keep on the same pages about turn-on or turn-off FEC.2FEC switchConstant value0Turn off FECFEC_0_OFF1Turn on FEC (default)FEC_1_ONTransmission powerYou can change this set of constant by apply a define like so:Applicable forE32-TTL-100, E32-TTL-100S1, E32-T100S2.The external power must make sure the ability of current output more than 250mA and ensure the power supply ripple within 100mV.Low power transmission is not recommended due to its low power supplyefficiency.10Transmission power (approximation)Constant value0020dBm (default)POWER_200117dBmPOWER_171014dBmPOWER_141110dBmPOWER_10Applicable for E32-TTL-500。The external power must make sure the ability of current output more than 700mA and ensure the power supply ripple within 100mV.Low power transmission is not recommended due to its low power supply efficiency.10Transmission power (approximation)Constant value0027dBm (default)POWER_270124dBmPOWER_241021dBmPOWER_211118dBmPOWER_18Applicable for E32-TTL-1W, E32 (433T30S), E32 (868T30S), E32 (915T30S)The external power must make sure the ability of current output more than 1A and ensure the power supply ripple within 100mV.Low power transmission is not recommended due to its low power supplyefficiency.10Transmission power (approximation)Constant value0030dBm (default)POWER_300127dBmPOWER_271024dBmPOWER_241121dBmPOWER_21You can configure Channel frequency olso with this define:Normal transmission modeNormal/Transparent transmission mode is used to send messages to all device with same address and channel.LoRa E32 transmitting scenarios, lines are channelsFixed mode instead of normal modeAt same manner I create a set of method to use with fixed transmissionFixed transmissionYou need to change only the sending method, because the destination device don’t receive the preamble with Address and Channel.Fixed transmission have more scenariosThanks