Configuration
These examples will show you how to configure you device.
Manual
1# SPDX-FileCopyrightText: 2023 Herwin Bozet
2#
3# SPDX-License-Identifier: Unlicense
4
5import binascii
6import board
7
8import ebyte_e32
9
10PIN_M0 = board.IO13
11PIN_M1 = board.IO12
12PIN_RXD = board.IO11 # Pin marked as RX on the module
13PIN_TXD = board.IO10 # Pin marked as TX on the module
14PIN_AUX = board.IO9
15
16e32 = ebyte_e32.E32Device(PIN_M0, PIN_M1, PIN_AUX, PIN_TXD, PIN_RXD)
17
18# The E32 module should be available and configured with the these parameters by default:
19# * Address: 0x0000
20# * UART parity: 8N1 (8 data bits, no parity)
21# * UART rate: 9600 bps
22# * Air data rate: 2.4 kbps
23# * Channel: 0
24# * TX mode: Transparent
25# * IO drive mode: TX and AUX as push-pull, RX as pull-up
26# * Wake-up time: 250ms
27# * Forward error correction: Enabled
28# * TX power: The lowest available
29
30# /!\ Each configuration change will cause the module to go into sleep mode and flush the UART buffer /!\
31
32# Changing the address
33print(f"Old address: 0x{e32.address:x}")
34e32.address = 0x1337
35print(f"New address: 0x{e32.address:x}")
36
37# TODO: Other parameters...
Reading from class
Each of the module’s parameters can be read via the class property as shown in the Configuration > Manual example,
which will return the E32Device
class value.
Reading from module
If you want to fetch the module’s current configuration, you can use the E32Device.get_config()
method and
get a named tuple with all the values.
1# SPDX-FileCopyrightText: 2023 Herwin Bozet
2#
3# SPDX-License-Identifier: Unlicense
4
5import binascii
6import board
7
8import ebyte_e32
9
10PIN_M0 = board.IO13
11PIN_M1 = board.IO12
12PIN_RXD = board.IO11 # Pin marked as RX on the module
13PIN_TXD = board.IO10 # Pin marked as TX on the module
14PIN_AUX = board.IO9
15
16e32 = ebyte_e32.E32Device(PIN_M0, PIN_M1, PIN_AUX, PIN_TXD, PIN_RXD)
17
18# /!\ This operation will cause the module to go into sleep mode and flush the UART buffer /!\
19
20# Grabbing the config in a named tuple.
21config = e32.get_config()
22
23print(config)
24
25# Output:
26# E32DeviceConfig(
27# address=b'\x00\x00',
28# uart_parity=0,
29# uart_rate=3,
30# data_rate=2,
31# channel=0,
32# tx_mode=0,
33# io_drive_mode=1,
34# wake_up_time=0,
35# forward_error_correction=1,
36# tx_power=3
37# )