# Send Hello World on the USB Nugget (ESP32s2)importboardimportbusioimportdigitalioimportadafruit_rfm9x# Initialize SPI interface.spi=busio.SPI(board.IO6,MOSI=board.IO10,MISO=board.IO8)# Initialize RFM9x LoRa radioCS=digitalio.DigitalInOut(board.IO13)RESET=digitalio.DigitalInOut(board.IO5)rfm9x=adafruit_rfm9x.RFM9x(spi,CS,RESET,915.0)rfm9x.tx_power=23# Send text without specifiyng encodingmessage="Hello World!"rfm9x.send(message)print("Sent Hello World string!")#Send the same text, specify utf-8 bytesrfm9x.send(bytes("Hello world!\r\n","utf-8"))print("Sent Hello World bytes!")
1 2 3 4 5 6 7 8 9101112131415161718192021222324
# Send Hello World on the Bluetooth Nugget (ESP32s3)importboardimportbusioimportdigitalioimportadafruit_rfm9x# Initialize SPI interfacespi=busio.SPI(board.IO6,MOSI=board.IO8,MISO=board.IO7)# Initialize RFM9x LoRa radioCS=digitalio.DigitalInOut(board.IO9)RESET=digitalio.DigitalInOut(board.IO4)rfm9x=adafruit_rfm9x.RFM9x(spi,CS,RESET,915.0)rfm9x.tx_power=23# Send text without specifiyng encodingmessage="Hello World!"rfm9x.send(message)print("Sent Hello World string!")#Send the same text, specify utf-8 bytesrfm9x.send(bytes("Hello world!\r\n","utf-8"))print("Sent Hello World bytes!")
# Recieve Hello World on the USB Nugget (ESP32s2)importboardimportbusioimportdigitalioimportadafruit_rfm9x# Initialize SPI interface.spi=busio.SPI(board.IO6,MOSI=board.IO10,MISO=board.IO8)# Initialize RFM9x LoRa radioCS=digitalio.DigitalInOut(board.IO13)RESET=digitalio.DigitalInOut(board.IO5)rfm9x=adafruit_rfm9x.RFM9x(spi,CS,RESET,915.0)rfm9x.tx_power=23whileTrue:packet=rfm9x.receive()ifpacketisNone:print("Received nothing! Listening again...")else:print("Received (raw bytes):",packet)# you always receive raw bytes and need to convert to a text# format like ASCII if you intend to do string processing.packet_text=str(packet,"ascii")print("Received (ASCII):",packet_text)# Also read the signal strength of the received message and print it.signal=rfm9x.last_rssiprint("Received signal strength:",signal)
# Recieve Hello World on the Bluetooth Nugget (ESP32s3)importboardimportbusioimportdigitalioimportadafruit_rfm9x# Initialize SPI interfacespi=busio.SPI(board.IO6,MOSI=board.IO8,MISO=board.IO7)# Initialize RFM9x LoRa radioCS=digitalio.DigitalInOut(board.IO9)RESET=digitalio.DigitalInOut(board.IO4)rfm9x=adafruit_rfm9x.RFM9x(spi,CS,RESET,915.0)rfm9x.tx_power=23whileTrue:packet=rfm9x.receive()ifpacketisNone:print("Received nothing! Listening again...")else:print("Received (raw bytes):",packet)# you always receive raw bytes and need to convert to a text# format like ASCII if you intend to do string processing.packet_text=str(packet,"ascii")print("Received (ASCII):",packet_text)# Also read the signal strength of the received message and print it.signal=rfm9x.last_rssiprint("Received signal strength:",signal)
# Repeat a received packet on the USB Nugget (ESP32s2)importboardimportbusioimportdigitalioimportadafruit_rfm9ximporttime# Initialize SPI interface.spi=busio.SPI(board.IO6,MOSI=board.IO10,MISO=board.IO8)# Initialize RFM9x LoRa radioCS=digitalio.DigitalInOut(board.IO13)RESET=digitalio.DigitalInOut(board.IO5)rfm9x=adafruit_rfm9x.RFM9x(spi,CS,RESET,915.0)rfm9x.tx_power=23# Send text without specifiyng encodingmessage="Ping!"rfm9x.send(message)print("Sent Ping!")whileTrue:packet=rfm9x.receive()# If no packet was received during the timeout then None is returned.ifpacketisNone:print("Received nothing! Listening again...")else:print("Received (raw bytes):",packet)# you always receive raw bytes and need to convert to a text# format like ASCII if you intend to do string processing.packet_text=str(packet,"ascii")print("Received (ASCII):",packet_text)# Also read the signal strength of the received message and print it.signal=rfm9x.last_rssiprint("Received signal strength:",signal)# Rebroadcast the packettime.sleep(1)print("Rebroadcasting packet...")rfm9x.send(packet_text)print("Sent!")
# Repeat a received packet on the Bluetooth Nugget (ESP32s3)importboardimportbusioimportdigitalioimportadafruit_rfm9ximporttime# Initialize SPI interfacespi=busio.SPI(board.IO6,MOSI=board.IO8,MISO=board.IO7)# Initialize RFM9x LoRa radioCS=digitalio.DigitalInOut(board.IO9)RESET=digitalio.DigitalInOut(board.IO4)rfm9x=adafruit_rfm9x.RFM9x(spi,CS,RESET,915.0)rfm9x.tx_power=23# Send text without specifiyng encodingmessage="Ping!"rfm9x.send(message)print("Sent Ping!")whileTrue:packet=rfm9x.receive()# If no packet was received during the timeout then None is returned.ifpacketisNone:print("Received nothing! Listening again...")else:print("Received (raw bytes):",packet)# you always receive raw bytes and need to convert to a text# format like ASCII if you intend to do string processing.packet_text=str(packet,"ascii")print("Received (ASCII):",packet_text)# Also read the signal strength of the received message and print it.signal=rfm9x.last_rssiprint("Received signal strength:",signal)# Rebroadcast the packettime.sleep(1)print("Rebroadcasting packet...")rfm9x.send(packet_text)print("Sent!")