ebyte_e32

  • Author(s): Herwin Bozet

class ebyte_e32.AirDataRate

Data rate in bps at which LoRa modules communicate between each other.

This setting directly affects the maximum packet size and communication range !

This setting must be the same between all communicating modules.

RATE_0_3K = 0

Equal to 0.3 kbps

RATE_19_2K = 5

Equal to 19.2 kbps

RATE_1_2K = 1

Equal to 1.2 kbps

RATE_2_4K = 2

Equal to 2.4 kbps

RATE_4_8K = 3

Equal to 4.8 kbps

RATE_9_6K = 4

Equal to 9.6 kbps

RATE_DEFAULT = 2

Default air data rate on E32 devices

ebyte_e32.CHANNEL_MAX = 31

Maximal allowed channel number. (Inclusive)

ebyte_e32.CHANNEL_MIN = 0

Minimal allowed channel number. (Inclusive)

class ebyte_e32.E32Device(pin_m0: microcontroller.Pin, pin_m1: microcontroller.Pin, pin_aux: microcontroller.Pin | None, pin_tx: microcontroller.Pin, pin_rx: microcontroller.Pin, uart_buffer_size: int = 64, address: int = 0, uart_parity: int | SerialParity = 0, uart_rate: tuple[int, int] | SerialBaudRate = (3, 9600), data_rate: int | AirDataRate = 2, channel: int = 0, tx_mode: int | TransmissionMode = 0, io_drive_mode: int | IODriveMode = 1, wake_up_time: int | WakeUpTime = 0, forward_error_correction: bool | ForwardErrorCorrection = True, tx_power: int = 3)

Generic class for interacting with E32 modules over UART.

property address: int

Module’s address used to receive messages. (Must be between 0x0000 and 0xFFFF)

If the module is in fixed communications mode the address has extra some extra behaviour:

⦁ The 0xFFFF address can be used to monitor or broadcast messages on a given channel.

⦁ The address is ignored when receiving broadcast messages.

Changing this property will cause the module to temporarily go into sleep mode and flush the UART buffer.

property channel: int

Module’s channel used for any LoRa communications in non-sleep modes.

Must be between CHANNEL_MIN and CHANNEL_MAX. (Both are inclusive limits)

If the module is in fixed communications mode, it may change its channel to the targeted one and will return to the original one afterward.

Changing this property will cause the module to temporarily go into sleep mode and flush the UART buffer.

property data_rate: int | AirDataRate

Module’s data rate for any LoRa communications in non-sleep modes.

Must be between one of the values in AirDataRate.

Changing this property will cause the module to temporarily go into sleep mode and flush the UART buffer.

deinit()

Deinitializes the E32 module instance and liberates all used pins.

Returns:

None

flush_uart()

Empties out the UART buffer if possible.

Returns:

None

property forward_error_correction: bool | ForwardErrorCorrection

Module’s forward error correction toggle for any LoRa communications when in non-sleep modes.

Must be between one of the values in ForwardErrorCorrection.

Changing this property will cause the module to temporarily go into sleep mode and flush the UART buffer.

get_config() E32DeviceConfig

Get a named tuple containing the module’s current operating configuration

Returns:

A E32DeviceConfig with the module’s current operating configuration.

get_raw_config() bytes

Fetches the raw operating config from the module and returns it.

The module will temporarily go into sleep mode and flush the UART buffer.

Returns:

The raw response as a bytes object of length 6.

get_raw_version() bytes

Fetches the raw version number and returns it.

The module will temporarily go into sleep mode and flush the UART buffer.

Returns:

The raw response as a bytes object of length 4.

Raises:

E32GenericError – If the version couldn’t be fetched.

get_version() E32DeviceVersion

Fetches the module’s model, version number and its features.

Ebyte’s documentation doesn’t explain the content of the second and third values in details.

Returns:

A tuple containing the module’s model, its version number, ant its features.

Raises:

E32GenericError – If the version is invalid.

property in_buffer: int

Get the amount of bytes waiting in the UART bus’ buffer.

Returns:

Bytes in UART buffer.

property io_drive_mode: int | IODriveMode

Module’s IO drive mode for its RX, TX and AUX pins.

Must be between one of the values in IODriveMode.

Changing this property will cause the module to temporarily go into sleep mode and flush the UART buffer.

property mode: tuple[int, int] | Modes

Module’s mode as it is or should be represented on the M0 and M1 pins.

Changing this property will flush the UART buffer.

prepare_uart(baudrate: int, parity: busio.UART.Parity | None)

Prepares the UART bus for further communications.

Parameters:
  • baudrate – Baudrate used by the new UART bus.

  • parity – Parity used by the new UART bus.

Returns:

None

read(byte_count: int = -1) bytearray | None

Reads bytes waiting in the UART bus’ buffer.

Parameters:

byte_count – Tha maximum amount of bytes to read. (Default: -1)

Returns:

The data as a bytearray or None.

reset(stay_in_sleep_mode: bool = True)

Sends the RESET command to the module and stays in sleep mode waiting for further configuration unless instructed not to.

The module is left in sleep mode to prevent rogue communications with an undesired operating configuration.

The module will temporarily go into sleep mode and flush the UART buffer.

The module will likely be unresponsive for a couple of seconds !

Parameters:

stay_in_sleep_mode – Whether the module should be left in sleep mode after the reset. (Default: True)

Returns:

None

send(message: bytes, max_packet_size: int | None = None, wait_aux: bool = True)

Sends a message on the UART bus.

Parameters:
  • message – Message to be sent, may get truncated.

  • max_packet_size – Max byte count to send, if None, the message’s length will be used.

  • wait_aux – Whether the method should wait for AUX pin (Default: True)

Returns:

The numbers of bytes written.

property tx_mode: int | TransmissionMode

Module’s transmission mode used for any LoRa communications in non-sleep modes.

Must be between one of the values in TransmissionMode.

Changing this property will cause the module to temporarily go into sleep mode and flush the UART buffer.

property tx_power: int

Module’s TX power as transmitted via the save parameters command.

Must be between TX_POWER_MIN and TX_POWER_MAX, both are inclusive.

Changing this property will cause the module to temporarily go into sleep mode and flush the UART buffer.

property uart_parity: int

Module’s UART parity used on the RX and TX lines when in non-sleep modes, as transmitted via the save parameters command.

Must be between one of the values in SerialParity.

This value is automatically applied to the uart bus when switching modes.

Changing this property will cause the module to temporarily go into sleep mode and flush the UART buffer.

property uart_rate: tuple[int, int] | SerialBaudRate

Module’s UART rate used on the RX and TX lines when in non-sleep modes.

Must be between one of the values in SerialBaudRate.

This value is automatically applied to the uart bus when switching modes.

Changing this property will cause the module to temporarily go into sleep mode and flush the UART buffer.

update_config(make_permanent: bool = False, verify: bool = True) None

Applies the current config to the module.

The module will temporarily go into sleep mode and flush the UART buffer.

Parameters:
  • make_permanent – Whether the config should be saved when the module is powered-down. (Default: False)

  • verify – Whether the config should be fetched and checked afterward. (Default: True)

Returns:

None

Raises:

E32GenericError – If the config couldn’t be applied.

wait_aux(max_wait_ms: int = 250)

Wait for the AUX pin to go high meaning that the module is ready for communications.

If no AUX pin was given, or if it stays low, the waiting period will be 150ms at most.

Returns:

None

property wake_up_time: int | WakeUpTime

Module’s wake-up time when in non-sleep and non-normal modes.

Must be between one of the values in WakeUpTime.

Changing this property will cause the module to temporarily go into sleep mode and flush the UART buffer.

class ebyte_e32.E32DeviceConfig(address, uart_parity, uart_rate, data_rate, channel, tx_mode, io_drive_mode, wake_up_time, forward_error_correction, tx_power)

Named tuple returned by the E32DeviceConfig when fetching the module’s current config.

address

Alias for field number 0

channel

Alias for field number 4

data_rate

Alias for field number 3

forward_error_correction

Alias for field number 8

io_drive_mode

Alias for field number 6

tx_mode

Alias for field number 5

tx_power

Alias for field number 9

uart_parity

Alias for field number 1

uart_rate

Alias for field number 2

wake_up_time

Alias for field number 7

class ebyte_e32.E32DeviceVersion(model, version, features)

Named tuple returned by the E32DeviceConfig when fetching the module’s version.

features

Alias for field number 2

model

Alias for field number 0

version

Alias for field number 1

class ebyte_e32.ForwardErrorCorrection

On/Off statuses available for the module’s Forward Error Correction

Turning the FEC off will reduce the the transmission time and will decrease the maximum transmission distance.

FIXME: Figure out the ratio since LoRaWAN wants 5/4 !

This setting must be the same between all communicating modules.

FEC_DEFAULT = True

Default FEC status on E32 devices

FEC_DISABLED = False

Enables forward error correction

FEC_ENABLE = True

Disables forward error correction

class ebyte_e32.IODriveMode

Changes the way the module’s internal pull-up resistor works.

Using the DRIVE_OPEN setting may require you to manually add pull-up resistors.

This setting isn’t related to the LoRa transmission rate and can be different between communicating modules.

DRIVE_DEFAULT = 1

Default IO drive mode E32 devices

DRIVE_OPEN = 0

Both TX and AUX pins will be push-pull outputs.

The RX pin will be a pull-up input.

DRIVE_PULL = 1

Both TX and AUX pins will be open-collector outputs.

The RX pin will be an open-collector input.

class ebyte_e32.Modes

Refers to the E32 module’s operating modes set via the M0 and M1 pins.

The constants’ values are organized in the following manner: list[M0: int, M1_Value: int]

MODE_NORMAL = (0, 0)

UART and LoRa radio are ready to receive and return packages.

Also known as Mode 0.

MODE_POWER_SAVE = (0, 1)

The UART bus is disabled, and the module waits for incoming messages with the appropriate preambles.

Once received, AUX goes low for ~5ms and the UART bus is re-opened, it sends the message, and AUX goes high again.

Also known as Mode 2 or PS Mode.

MODE_SLEEP = (1, 1)

Puts the module in sleep mode where the LoRa radio is turned off and the UART bus can be used to set and get the module’s parameters, or reset it.

Also known as Mode 3.

MODE_WAKE_UP = (1, 0)

Same as normal mode, with a preamble added to sent data to wake up the receiver.

The preamble’s code length depends on the [???] set in the module operating configuration.

Also known as Mode 1.

class ebyte_e32.SerialBaudRate

UART baud rate for all communications between the module and the MCU in any non-sleep modes.

This setting isn’t related to the LoRa transmission rate and can be different between communicating modules.

BAUD_115200 = (7, 115200)

Equal to 115200 bps

BAUD_1200 = (0, 1200)

Equal to 1200 bps

BAUD_19200 = (4, 19200)

Equal to 19200 bps

BAUD_2400 = (1, 2400)

Equal to 2400 bps

BAUD_38400 = (5, 38400)

Equal to 38400 bps

BAUD_4800 = (2, 4800)

Equal to 4800 bps

BAUD_57600 = (6, 57600)

Equal to 57600 bps

BAUD_9600 = (3, 9600)

Equal to 9600 bps (Default)

BAUD_DEFAULT = (3, 9600)

Default baud rate on E32 devices

class ebyte_e32.SerialParity

UART bus parity for all communications between the module and the MCU in any non-sleep modes.

This setting isn’t related to the LoRa transmission rate and can be different between communicating modules.

PARITY_DEFAULT = 0

Default UART parity on E32 devices

PARITY_EVEN = 2

Same as 8E1

PARITY_NONE = 0

Same as 8N1

PARITY_ODD = 1

Same as 8O1

ebyte_e32.TX_POWER_MAX = 3

Maximal allowed TX power value. (Inclusive)

ebyte_e32.TX_POWER_MIN = 0

Minimal allowed TX power value. (Inclusive)

class ebyte_e32.TransmissionMode

Transmission modes available for LoRa communications.

TRANSMISSION_DEFAULT = 0

Default transmission mode on E32 devices.

This is not explicitly indicated in the E32 datasheets, but this is the case in practice.

TRANSMISSION_FIXED = 1

In this mode all devices will be able communicate between each other by prepending the target channel and address to each message.

You can also use the special 0xFFFF address to monitor or broadcast messages on a given channel.

The module will automatically switch channel if required and will return to it’s original one.

TRANSMISSION_TRANSPARENT = 0

In this mode all devices on the same channel and address will communicate between each other.

class ebyte_e32.WakeUpTime

???

[Not on mode 0 !]

This setting isn’t related to the LoRa transmission rate and can be different between communicating modules.

WAKE_TIME_1000MS = 3

???

WAKE_TIME_1250MS = 4

???

WAKE_TIME_1500MS = 5

???

WAKE_TIME_1750MS = 6

???

WAKE_TIME_2000MS = 7

???

WAKE_TIME_250MS = 0

???

WAKE_TIME_500MS = 1

???

WAKE_TIME_750MS = 2

???

WAKE_TIME_DEFAULT = 0

Default wake-up time on E32 devices


ebyte_e32.exceptions

  • Author(s): Herwin Bozet

exception ebyte_e32.exceptions.E32GenericError

Exception raised when the E32 module didn’t respond properly, or at all, to messages sent by the driver.


ebyte_e32.f443

  • Author(s): Herwin Bozet

ebyte_e32.f433.CHANNEL_COUNT = 32

Amount of available channels.

ebyte_e32.f433.FREQUENCY_MAXIMUM = 441.0

Maximum frequency in MHz corresponding to channel 31.

ebyte_e32.f433.FREQUENCY_MINIMUM = 410.0

Minimum frequency in MHz corresponding to channel 0.

ebyte_e32.f433.FREQUENCY_STEP = 1.0

Frequency difference between channels in MHz.

ebyte_e32.f868

  • Author(s): Herwin Bozet

ebyte_e32.f868.CHANNEL_COUNT = 32

Amount of available channels.

ebyte_e32.f868.FREQUENCY_MAXIMUM = 893.0

Maximum frequency in MHz corresponding to channel 31.

ebyte_e32.f868.FREQUENCY_MINIMUM = 862.0

Minimum frequency in MHz corresponding to channel 0.

ebyte_e32.f868.FREQUENCY_STEP = 1.0

Frequency difference between channels in MHz.

ebyte_e32.f915

  • Author(s): Herwin Bozet

ebyte_e32.f915.CHANNEL_COUNT = 32

Amount of available channels.

ebyte_e32.f915.FREQUENCY_MAXIMUM = 931.0

Maximum frequency in MHz corresponding to channel 31.

ebyte_e32.f915.FREQUENCY_MINIMUM = 900.0

Minimum frequency in MHz corresponding to channel 0.

ebyte_e32.f915.FREQUENCY_STEP = 1.0

Frequency difference between channels in MHz.


ebyte_e32.t20

  • Author(s): Herwin Bozet

class ebyte_e32.t20.TransmitPower

Available transmission power values for E32 modules with the T20 suffix.

TX_POWER_10DBM = 3

10 mW

TX_POWER_14DBM = 2

~25 mW

TX_POWER_17DBM = 1

~50 mW

TX_POWER_20DBM = 0

100mW

TX_POWER_DEFAULT = 0

Default TX power for modules with the T20 suffix

ebyte_e32.t30

  • Author(s): Herwin Bozet

class ebyte_e32.t30.TransmitPower

Available transmission power values for E32 modules with the T30 suffix.

TX_POWER_21DBM = 3

~125 mW

TX_POWER_24DBM = 2

~250 mW

TX_POWER_27DBM = 1

~500 mW

TX_POWER_30DBM = 0

1W / 1000mW

TX_POWER_DEFAULT = 0

Default TX power for modules with the T30 suffix

ebyte_e32.t33

  • Author(s): Herwin Bozet

class ebyte_e32.t33.TransmitPower

Available transmission power values for E32 modules with the T33 suffix.

TX_POWER_24DBM = 3

~250 mW

TX_POWER_27DBM = 2

~500 mW

TX_POWER_30DBM = 1

1W / 1000mW

TX_POWER_33DBM = 0

~2W / ~2000mW

TX_POWER_DEFAULT = 0

Default TX power for modules with the T33 suffix

ebyte_e32.t37

  • Author(s): Herwin Bozet

class ebyte_e32.t37.TransmitPower

Available transmission power values for E32 modules with the T37 suffix.

TX_POWER_37DBM = 0

~5W / ~5000mW

TX_POWER_DEFAULT = 0

Default TX power for modules with the T37 suffix