Hi everyone here we'll be working on how to get started with RangePi & Load Python File To RangePi And Install Thonny Python IDE
RangePi Introduction:Range-Pi is a low-cost portable “Plug and Play LoRaTM Dongle” based on Raspberry Pi RP2040 and LoRaTM Modules, comes with an onboard 1.14" LCD that covers 433/868/915 MHz frequency band to enable data transmission up to 5 KM.
Use thonny python IDE for programming, link of the software is given below :
Steps to load python file to RangePiStep 1 - Open thonny 📷
Step 2 - Select micropython and port in thonny for this go to run-> select interpreter 📷 📷
Step 3 - Save python file to RangePi 📷 📷 📷
Step 4 - Run(execute) and stop file (script) 📷
Uploading the ST7789 Python Firmware
The firmware includes frozen python font files and pre-compiled objects with the ST7789 C driver for a variety of devices.
- The firmware includes frozen python font files and pre-compiled objects with the st7789 C driver for a variety of devices.
The driver's library is provided as a single firmware.uf2 file, which is accessible here: https://github.com/russhughes/st7789_mpy/tree/master/firmware/RP2
- The driver's library is provided as a single firmware.uf2 file, which is accessible here: https://github.com/russhughes/st7789_mpy/tree/master/firmware/RP2
Holding down the RangePi BOTSEL button while dragging this file into the mounted RP2 folder will allow you to load it.
- Holding down the RangePi BOTSEL button while dragging this file into the mounted RP2 folder will allow you to load it.
First, you need to install firmware of 1.14 lcd screen to RangePi, for this press boot button then plug to laptop/desktop after that release the button, you see new storage device. then drag and drop firmware.uf2 file to RangePi
Receiver
- rangepi_receiver.py - Run this file if you make RangePi as a receiver ( in all cases receiver is the same)
#Transmiter code
import utime
from machine import UART,SPI
from machine import Pin
import st7789
import time
import vga1_8x16 as font1
#import vga2_8x8 as font
import vga1_16x32 as font
import vga1_16x16 as font2
spi = SPI(1, baudrate=40000000, sck=Pin(10), mosi=Pin(11))
tft = st7789.ST7789(spi,135,240,reset=Pin(12, Pin.OUT),cs=Pin(9, Pin.OUT),dc=Pin(8, Pin.OUT),backlight=Pin(13, Pin.OUT),rotation=1)
Mode0 = machine.Pin(2, machine.Pin.OUT)
Mode1 = machine.Pin(3, machine.Pin.OUT)
Mode0.value(0)
Mode1.value(0)
lora = UART(0,baudrate = 9600,tx = Pin(0),rx = Pin(1))
def info():
tft.init()
utime.sleep(0.2)
tft.text(font,"SB-COMPONENTS", 0,0)
tft.fill_rect(0, 40, 210,10, st7789.RED)
tft.text(font,"RANGEPI", 0,55,st7789.YELLOW)
tft.text(font,"RECEIVER", 0,100,st7789.YELLOW)
tft.fill_rect(0, 90, 210, 10, st7789.BLUE)
time.sleep(1)
tft.fill(0) #clear screen
tft.text(font,"RECEIVE MESSAGE", 5,10,st7789.WHITE)
info()
while True:
data_Read = lora.readline()#read data comming from other pico lora expansion
if data_Read is not None:
tft.text(font,n, 10,60,st7789.YELLOW)
utime.sleep(0.2)#wait 200ms
tft.text(font,n, 10,60,st7789.BLACK)
utime.sleep(0.2)#wait for 200ms
Transmitter
rangepi_transmitter.py - Run this file if you make RangePi a transmitter
#Transmiter code
import utime
from machine import UART,SPI
from machine import Pin
import st7789
import time
import vga1_8x16 as font1
#import vga2_8x8 as font
import vga1_16x32 as font
import vga1_16x16 as font2
spi = SPI(1, baudrate=40000000, sck=Pin(10), mosi=Pin(11))
tft = st7789.ST7789(spi,135,240,reset=Pin(12, Pin.OUT),cs=Pin(9, Pin.OUT),dc=Pin(8, Pin.OUT),backlight=Pin(13, Pin.OUT),rotation=1)
Mode0 = machine.Pin(2, machine.Pin.OUT)
Mode1 = machine.Pin(3, machine.Pin.OUT)
Mode0.value(0)
Mode1.value(0)
lora = UART(0,baudrate = 9600,tx = Pin(0),rx = Pin(1))
def info():
tft.init()
utime.sleep(0.2)
tft.text(font,"SB-COMPONENTS", 0,0)
tft.fill_rect(0, 40, 210,10, st7789.RED)
tft.text(font,"RANGEPI", 0,55,st7789.YELLOW)
tft.text(font,"TRANSMITTER", 0,100,st7789.YELLOW)
tft.fill_rect(0, 90, 210, 10, st7789.BLUE)
time.sleep(1)
tft.fill(0) #clear screen
tft.text(font,"SEND MESSAGE", 5,10,st7789.WHITE)
info()
while True:
#input("Enter the relay = ")
n = "Hello World!!\n"
lora.write(n)#send data
tft.text(font,n, 10,60,st7789.YELLOW)
utime.sleep(0.2)#wait 200ms
tft.text(font,n, 10,60,st7789.BLACK)
#Transmitter code Ends here
user_input_transmitter.py - Run this file if you make RangePi as atransmitter or you can transmit using window applications like XCTU, Tera Term, etc. 📷
- user_input_transmitter.py - Run this file if you make RangePi as atransmitter or you can transmit using window applications like XCTU, Tera Term, etc.
#Transmiter code
import utime
from machine import UART,SPI
from machine import Pin
import st7789
import time
import vga1_8x16 as font1
#import vga2_8x8 as font
import vga1_16x32 as font
import vga1_16x16 as font2
spi = SPI(1, baudrate=40000000, sck=Pin(10), mosi=Pin(11))
tft = st7789.ST7789(spi,135,240,reset=Pin(12, Pin.OUT),cs=Pin(9, Pin.OUT),dc=Pin(8, Pin.OUT),backlight=Pin(13, Pin.OUT),rotation=1)
Mode0 = machine.Pin(2, machine.Pin.OUT)
Mode1 = machine.Pin(3, machine.Pin.OUT)
Mode0.value(0)
Mode1.value(0)
lora = UART(0,baudrate = 9600,tx = Pin(0),rx = Pin(1))
def info():
tft.init()
utime.sleep(0.2)
tft.text(font,"SB-COMPONENTS", 0,0)
tft.fill_rect(0, 40, 210,10, st7789.RED)
tft.text(font,"RANGEPI", 0,55,st7789.YELLOW)
tft.text(font,"TRANSMITTER", 0,100,st7789.YELLOW)
tft.fill_rect(0, 90, 210, 10, st7789.BLUE)
time.sleep(1)
tft.fill(0) #clear screen
tft.text(font,"SEND MESSAGE", 5,10,st7789.WHITE)
info()
while True:
n = input("Enter the message = ")
lora.write(n)#send data
tft.text(font,n, 10,60,st7789.YELLOW)
utime.sleep(0.2)#wait 200ms
tft.text(font,n, 10,60,st7789.BLACK)
messenger.py - Run this file if you want to talk through a message like a messenger(run the file in both RangePi)
#Receiver code
import utime
from machine import Pin, UART,SPI
import time
import st7789
import vga1_8x16 as font1
#import vga2_8x8 as font
import vga1_16x32 as font
import vga1_16x16 as font2
Mode0 = machine.Pin(2, machine.Pin.OUT)
Mode1 = machine.Pin(3, machine.Pin.OUT)
Mode0.value(0)
Mode1.value(0)
spi = SPI(1, baudrate=40000000, sck=Pin(10), mosi=Pin(11))
tft = st7789.ST7789(spi,135,240,reset=Pin(12, Pin.OUT),cs=Pin(9, Pin.OUT),dc=Pin(8, Pin.OUT),backlight=Pin(13, Pin.OUT),rotation=1)
lora = UART(0,baudrate = 9600,tx = Pin(0),rx = Pin(1))
tft.init()
def info():
tft.init()
utime.sleep(0.2)
tft.text(font,"SB-COMPONENTS", 0,0)
tft.fill_rect(0, 40, 210,10, st7789.RED)
tft.text(font,"RANGEPI", 0,55,st7789.YELLOW)
tft.text(font,"MESSENGER", 0,100,st7789.YELLOW)
tft.fill_rect(0, 90, 210, 10, st7789.BLUE)
time.sleep(1)
tft.fill(0) #clear screen
tft.text(font,"MESSENGER", 5,10,st7789.WHITE)
tft.fill_rect(0, 50, 210,10, st7789.RED)
info()
a=4
while True:
print("For transmitter type = 1")
print("For Receiver type = 2")
choice = int(input("Enter choice = "))
if choice == 1:
n = input("Enter The Message = ")
lora.write(n)#send data
tft.text(font,n, 5,60,st7789.YELLOW)
utime.sleep(0.5)#wait 200ms
tft.text(font,n, 5,60,st7789.BLACK)
if choice == 2:
while a>0:
data_Read = lora.readline()#read data comming from other pico lora expansion
if data_Read is not None:
tft.text(font,data_Read, 5,80,st7789.YELLOW)
print(data_Read)
time.sleep(2)
tft.text(font,data_Read, 5,80,st7789.BLACK)
utime.sleep(2)#wait for 200ms
a=a-1
a=10
- rangepi_configuration.py - Rename this file as main.py and save this file inside RangePi.go to the below link to configure RangePi https://www.youtube.com/watch?v=InQ0FwF4tLk&ab_channel=SBComponentsLtd
- RangePi Getting started video
https://www.youtube.com/watch?v=ilqfkI1IL44&ab_channel=SBComponentsLtd
Comments
Please log in or sign up to comment.