Stamp LoRa-1262
Stamp LoRa-1262 is an SX1262 LoRa transceiver for the Stamp Series FPC12
interface. StampLoRa1262 selects the current host’s FPC12 GPIO mapping,
enables the RF switch, and provides synchronous send, receive, and radio
configuration operations.
Support the following products:
The following are the host’s support for Stamp LoRa-1262:
Controller |
Status |
|---|---|
StampC5 |
✔ |
StampC6 |
✔ |
StampS3Mini |
✔ |
The supported RF frequency range is 868-923 MHz. Attach a suitable antenna
before transmitting. The module’s SHUT_DOWN signal is not part of the
Stamp Series FPC12 interface and is not controlled by this driver.
Pin Mapping
Position |
Signal |
StampC5 |
StampC6 |
StampS3Mini |
|---|---|---|---|---|
1 |
3V3 |
3V3 |
3V3 |
3V3 |
2 |
3V3 |
3V3 |
3V3 |
3V3 |
3 |
SW |
G23 |
G8 |
G38 |
4 |
IRQ |
G0 |
G0 |
G21 |
5 |
BUSY |
G24 |
G18 |
G39 |
6 |
RST |
G25 |
G19 |
G40 |
7 |
GND |
GND |
GND |
GND |
8 |
MISO |
G26 |
G20 |
G41 |
9 |
MOSI |
G27 |
G21 |
G42 |
10 |
CS |
G11 |
G22 |
G43 |
11 |
GND |
GND |
GND |
GND |
12 |
CLK |
G12 |
G23 |
G44 |
UiFlow2 Example
Sender
Open the stamp_lora1262_sender_example.m5f2 project in UiFlow2. It sends a sequence message once per second.
UiFlow2 Code Block:
Receiver
Open the stamp_lora1262_receiver_example.m5f2 project in UiFlow2. It starts continuous reception and prints each packet with RSSI and SNR.
UiFlow2 Code Block:
MicroPython Example
Sender
1# SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
2#
3# SPDX-License-Identifier: MIT
4
5import time
6
7import M5
8from stamp import StampLoRa1262
9
10
11radio = None
12sequence = None
13
14
15def setup():
16 global radio, sequence
17
18 M5.begin()
19 radio = StampLoRa1262()
20 sequence = 0
21
22
23def loop():
24 global radio, sequence
25
26 M5.update()
27 message = "Stamp LoRa1262 %d" % sequence
28 radio.send(message)
29 print("sent:", message)
30 sequence = (sequence + 1) & 0xFF
31 time.sleep_ms(1000)
32
33
34if __name__ == "__main__":
35 try:
36 setup()
37 while True:
38 loop()
39 except (Exception, KeyboardInterrupt) as e:
40 try:
41 from utility import print_error_msg
42
43 print_error_msg(e)
44 except ImportError:
45 print("please update to latest firmware")
Receiver
1# SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
2#
3# SPDX-License-Identifier: MIT
4
5import M5
6from stamp import StampLoRa1262
7
8
9radio = None
10
11
12def receive_event(packet):
13 print("received:", packet.decode())
14 print("rssi:", packet.rssi, "snr:", packet.snr / 4)
15
16
17def setup():
18 global radio
19
20 M5.begin()
21 radio = StampLoRa1262()
22 radio.set_rx_callback(receive_event)
23 radio.start_recv()
24
25
26def loop():
27 M5.update()
28
29
30if __name__ == "__main__":
31 try:
32 setup()
33 while True:
34 loop()
35 except (Exception, KeyboardInterrupt) as e:
36 try:
37 from utility import print_error_msg
38
39 print_error_msg(e)
40 except ImportError:
41 print("please update to latest firmware")
API
- class stamp.lora1262.StampLoRa1262(freq_khz=868000, bw='250', sf=8, coding_rate=8, preamble_len=12, syncword=18, output_power=10, sw=None, irq=None, busy=None, reset=None, miso=None, mosi=None, cs=None, clock=None, spi_id=1)
Bases:
objectSX1262 LoRa radio connected through the Stamp FPC12 interface.
Passing
Nonefor a pin uses the current Stamp host’s FPC12 mapping. StampC5, StampC6, and StampS3Mini are supported by default. Other hosts can be used when every signal pin is provided explicitly.- set_freq(freq_khz=868000)
Set the LoRa carrier frequency.
- Parameters:
freq_khz (int) – Carrier frequency in kHz, from 868000 to 923000.
- Raises:
ValueError – If
freq_khzis outside the supported range.
UiFlow2 Code Block:

MicroPython Code Block:
radio.set_freq(868000)
- set_sf(sf)
Set the LoRa spreading factor.
- Parameters:
sf (int) – Spreading factor, from 6 to 12.
- Raises:
ValueError – If
sfis outside the supported range.
UiFlow2 Code Block:

MicroPython Code Block:
radio.set_sf(8)
- set_bw(bw)
Set the LoRa bandwidth.
- Parameters:
bw (str) – Bandwidth in kHz. Use one of
BANDWIDTHS.- Raises:
ValueError – If
bwis not supported.
UiFlow2 Code Block:

MicroPython Code Block:
radio.set_bw("250")
- set_coding_rate(coding_rate)
Set the coding-rate denominator for 4/N coding.
- Parameters:
coding_rate (int) – Coding-rate denominator, from 5 to 8.
- Raises:
ValueError – If
coding_rateis outside the supported range.
UiFlow2 Code Block:

MicroPython Code Block:
radio.set_coding_rate(8)
- set_syncword(syncword)
Set the LoRa sync word.
- Parameters:
syncword (int) – Sync word value, from 1 to 255.
- Raises:
ValueError – If
syncwordis outside the supported range.
UiFlow2 Code Block:

MicroPython Code Block:
radio.set_syncword(0x12)
- set_preamble_len(preamble_len)
Set the LoRa preamble length.
- Parameters:
preamble_len (int) – Preamble length in symbols, from 5 to 255.
- Raises:
ValueError – If
preamble_lenis outside the supported range.
UiFlow2 Code Block:

MicroPython Code Block:
radio.set_preamble_len(12)
- set_output_power(output_power)
Set the LoRa output power.
- Parameters:
output_power (int) – Output power in dBm, from -9 to 22.
- Raises:
ValueError – If
output_poweris outside the supported range.
UiFlow2 Code Block:

MicroPython Code Block:
radio.set_output_power(10)
- send(packet, tx_at_ms=None)
Send a packet and return its transmission timestamp.
- Parameters:
packet – String, bytes-like object, list, tuple, or integer payload. Strings are encoded as UTF-8 and integers are sent as one-byte payloads.
tx_at_ms (int) – Optional scheduled transmission timestamp.
- Returns:
Transmission timestamp in milliseconds.
- Return type:
UiFlow2 Code Block:

MicroPython Code Block:
radio.send("hello")
- recv(timeout_ms=None, rx_length=255, rx_packet=None)
Receive one packet.
- Parameters:
- Returns:
Received packet, or
Noneon timeout.- Return type:
RxPacket or None
UiFlow2 Code Block:

MicroPython Code Block:
packet = radio.recv(timeout_ms=1000)
- start_recv()
Start continuous packet reception.
UiFlow2 Code Block:

MicroPython Code Block:
radio.start_recv()
- set_tx_callback(callback)
Register a callback for completed transmissions.
- Parameters:
callback – A no-argument callable, or
Noneto clear it.
UiFlow2 Code Block:

MicroPython Code Block:
radio.set_tx_callback(on_transmit)
- set_rx_callback(callback)
Register a callback for valid packets in continuous reception.
- Parameters:
callback – A callable accepting one
lora.RxPacket, orNoneto clear it. Callstart_recv()to enable continuous reception.
UiFlow2 Code Block:

MicroPython Code Block:
radio.set_rx_callback(on_receive)
- standby()
Put the radio in standby mode and stop continuous reception.
UiFlow2 Code Block:

MicroPython Code Block:
radio.standby()
- sleep()
Put the radio in sleep mode and stop continuous reception.
UiFlow2 Code Block:

MicroPython Code Block:
radio.sleep()
- irq_triggered()
Return whether a radio IRQ has been triggered.
- Returns:
Trueif an IRQ is pending; otherwiseFalse.- Return type:
UiFlow2 Code Block:

MicroPython Code Block:
radio.irq_triggered()
- deinit()
Stop reception and put the radio in sleep mode.
UiFlow2 Code Block:
Use the deinit block in UiFlow2.
MicroPython Code Block:
radio.deinit()


