pdf-icon

UIFlow Guide

UiFlow1 Blockly

Event

Unit

UiFlow1 Project

Unit LoRa E220-433

Example

Register LoRaE220-433 and send/receive data

from m5stack import *
from m5ui import *
from uiflow import *
import unit

setScreenColor(0x404040)
lorae220_433_0 = unit.get(unit.LORA_E220_433, unit.PORTC)

lorae220_data1 = None
lorae220_rssi1 = None
rand = None

import random

def lorae220433_Zsicmcb(received_data, rssi):
  global lorae220_data1, lorae220_rssi1, rand
  try:
    lorae220_data1 = received_data.decode()
  except:
    lorae220_data1 = str(received_data)
  lorae220_rssi1 = rssi
  print((str('receive:') + str(lorae220_data1)))
  print((str('rssi:') + str(lorae220_rssi1)))
  pass

def buttonA_wasPressed():
  global lorae220_data1, lorae220_rssi1, rand
  rand = str(random.randint(1000000, 9999999))
  print((str('send random no:') + str(rand)))
  lorae220_433_0.send(0x0020, 0, ((str('0x0020:  ') + str(rand))))
  pass
btnA.wasPressed(buttonA_wasPressed)

def buttonC_wasPressed():
  global lorae220_data1, lorae220_rssi1, rand
  rand = str(random.randint(1000000, 9999999))
  print((str('send random no:') + str(rand)))
  lorae220_433_0.send(0x0025, 0, ((str('0x0025:  ') + str(rand))))
  pass
btnC.wasPressed(buttonC_wasPressed)

lorae220_433_0.uart_setup(1, 9600, None)
lorae220_433_0.enable_receive_callback(lorae220433_Zsicmcb)

API

print((str('available of data:') + str((lorae220_433_0.available_data()))))
  • Return an integer indicating the number of bytes that can be read without blocking It will return 0 if no bytes are available, and a positive number if bytes are available
print((str('address:') + str((lorae220_433_0.read_configure_param()[0]))))
  • Obtain the device address parameter of the LoRa E200 device
print((str('receive data:') + str((lorae220_433_0.receive(1000)))))
  • Receive data in blocking mode Used to set the receive timeout in milliseconds (ms)
lorae220_433_0.enable_receive_callback(lorae220433_nFWKgcb)
  • Receive data in non-blocking mode
lorae220_433_0.send(0x0000, 0, [0x10, 0x20])
  • Send raw data to a specified target address and channel
lorae220_433_0.send(0x0000, 0, 1000)
  • Send data to a specified target address and channel
lorae220_433_0.setup(0x0000, 0, encryption_key=0x0000)
  • Set module parameters
    • address:Local address
    • channel:Local channel
    • encryption_key:Encryption key
lorae220_433_0.uart_setup(1, 9600, None)
  • Set UART ID/baud rate/parity
lorae220_433_0.disable_receive_callback()
  • Stop receiving data in non-blocking mode
On This Page