Instantiation

These two examples show you how to properly prepare the E32 module’s class.

Basic

Shows you how to instantiate a E32Device with raw pins grabbed from the board module. The constructor will handle the process of making DigitalInOut class out of them.

None of the module’s parameters are customized in this example.

examples/instantiation_basic.py
 1# SPDX-FileCopyrightText: 2023 Herwin Bozet
 2#
 3# SPDX-License-Identifier: Unlicense
 4
 5import board
 6
 7import ebyte_e32
 8
 9PIN_M0 = board.IO13
10PIN_M1 = board.IO12
11PIN_RXD = board.IO11  # Pin marked as RX on the module
12PIN_TXD = board.IO10  # Pin marked as TX on the module
13PIN_AUX = board.IO9
14
15e32 = ebyte_e32.E32Device(PIN_M0, PIN_M1, PIN_AUX, PIN_TXD, PIN_RXD)
16
17# The E32 module should be available and configured with the these parameters by default:
18#  * Address: 0x0000
19#  * UART parity: 8N1 (8 data bits, no parity)
20#  * UART rate: 9600 bps
21#  * Air data rate: 2.4 kbps
22#  * Channel: 0
23#  * TX mode: Transparent
24#  * IO drive mode: TX and AUX as push-pull, RX as pull-up
25#  * Wake-up time: 250ms
26#  * Forward error correction: Enabled
27#  * TX power: The lowest available

Complete

Shows you how to instantiate a E32Device with all the module’s parameters specified and left at their default value.

examples/instantiation_full.py
 1# SPDX-FileCopyrightText: 2023 Herwin Bozet
 2#
 3# SPDX-License-Identifier: Unlicense
 4
 5import board
 6
 7import ebyte_e32
 8
 9PIN_M0 = board.IO13
10PIN_M1 = board.IO12
11PIN_RXD = board.IO11  # Pin marked as RX on the module
12PIN_TXD = board.IO10  # Pin marked as TX on the module
13PIN_AUX = board.IO9
14
15e32 = ebyte_e32.E32Device(
16    pin_m0=PIN_M0,
17    pin_m1=PIN_M1,
18    pin_aux=PIN_AUX,
19    pin_tx=PIN_TXD,
20    pin_rx=PIN_RXD,
21    uart_buffer_size=64,  # Default for `busio.UART`
22    address=0x0000,
23    uart_parity=ebyte_e32.SerialParity.PARITY_DEFAULT,
24    uart_rate=ebyte_e32.SerialBaudRate.BAUD_DEFAULT,
25    data_rate=ebyte_e32.AirDataRate.RATE_DEFAULT,
26    channel=0,  # Between: [0; 31]
27    tx_mode=ebyte_e32.TransmissionMode.TRANSMISSION_DEFAULT,
28    io_drive_mode=ebyte_e32.IODriveMode.DRIVE_DEFAULT,
29    wake_up_time=ebyte_e32.WakeUpTime.WAKE_TIME_DEFAULT,
30    forward_error_correction=ebyte_e32.ForwardErrorCorrection.FEC_DEFAULT,
31    tx_power=0b11,  # Highest: 0b00 => Lowest: 0b11
32)
33
34# All the config parameters have the same value as if they weren't given to the constructor.