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:

Stamp LoRa-1262

The following are the host’s support for Stamp LoRa-1262:

Stamp LoRa-1262 host support

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

Stamp LoRa-1262 FPC12 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:

stamp_lora1262_sender_example.png

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:

stamp_lora1262_receiver_example.png

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: object

SX1262 LoRa radio connected through the Stamp FPC12 interface.

Passing None for 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_khz is outside the supported range.

UiFlow2 Code Block:

set_freq.png

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 sf is outside the supported range.

UiFlow2 Code Block:

set_sf.png

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 bw is not supported.

UiFlow2 Code Block:

set_bw.png

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_rate is outside the supported range.

UiFlow2 Code Block:

set_coding_rate.png

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 syncword is outside the supported range.

UiFlow2 Code Block:

set_syncword.png

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_len is outside the supported range.

UiFlow2 Code Block:

set_preamble_len.png

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_power is outside the supported range.

UiFlow2 Code Block:

set_output_power.png

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:

int

UiFlow2 Code Block:

send.png send_return.png send_with_time_return.png

MicroPython Code Block:

radio.send("hello")
recv(timeout_ms=None, rx_length=255, rx_packet=None)

Receive one packet.

Parameters:
  • timeout_ms (int) – Optional receive timeout in milliseconds.

  • rx_length (int) – Maximum receive length in bytes.

  • rx_packet (RxPacket) – Optional packet object to reuse.

Returns:

Received packet, or None on timeout.

Return type:

RxPacket or None

UiFlow2 Code Block:

recv.png recv_data_param.png

MicroPython Code Block:

packet = radio.recv(timeout_ms=1000)
start_recv()

Start continuous packet reception.

UiFlow2 Code Block:

start_recv.png

MicroPython Code Block:

radio.start_recv()
set_tx_callback(callback)

Register a callback for completed transmissions.

Parameters:

callback – A no-argument callable, or None to clear it.

UiFlow2 Code Block:

send_event.png

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, or None to clear it. Call start_recv() to enable continuous reception.

UiFlow2 Code Block:

receive_event.png

MicroPython Code Block:

radio.set_rx_callback(on_receive)
standby()

Put the radio in standby mode and stop continuous reception.

UiFlow2 Code Block:

standby.png

MicroPython Code Block:

radio.standby()
sleep()

Put the radio in sleep mode and stop continuous reception.

UiFlow2 Code Block:

sleep.png

MicroPython Code Block:

radio.sleep()
irq_triggered()

Return whether a radio IRQ has been triggered.

Returns:

True if an IRQ is pending; otherwise False.

Return type:

bool

UiFlow2 Code Block:

irq_triggered.png

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()