#ESP32-S2 Feather & RFM95 LoRa Featherwing

1 messages · Page 1 of 1 (latest)

split dragon
#

I can't get my ESP32-S2 with TFT to work with my LoRa RFM95 featherwing. I can get the display to initialize and show a "hello world", but the display stops working as soon as I try to initialize the RFM95. I have tried initializing the SPI with busio, and board.SPI(). The CS for the RFM95 and the display should not conflict. Please some help. Thanks.

`#basic working Feather esp32-s2 w/ TFT display demo with and w/out RFM9x simpletest

import board
import terminalio
import displayio
from adafruit_display_text import label
import time
import adafruit_rfm9x
import digitalio
import busio

set some parameters used for shapes and text

BORDER = 20
FONTSCALE = 2
FOREGROUND_COLOR = 0x00ff00 # Bright Green
BACKGROUND_COLOR = 0xAA0088 # Purple
TEXT_COLOR = 0x000000 #black

#This sets up the RFM9x LoRa featherwing, the "Hello World" only displays when this is commented out.

I don't have to initalize the SPI bus when only using the display.

RADIO_FREQ_MHZ = 905.5
CS = digitalio.DigitalInOut(board.D13)
RESET = digitalio.DigitalInOut(board.D12)
#spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) #This spi init only works for the display only
spi = board.SPI()
rfm9x = adafruit_rfm9x.RFM9x(spi, CS, RESET, RADIO_FREQ_MHZ)
rfm9x.tx_power = 23
#End of the Radio stuff

#This sets up the built-in display on the ESP32-S2 TFT
tft_cs = board.D5 #This CS should not conflict with the CS for the RFM9x, which is D13
tft_dc = board.D6
display = board.DISPLAY

splash = displayio.Group()
display.show(splash)

color_bitmap = displayio.Bitmap(display.width, display.height, 1)
color_palette = displayio.Palette(1)
color_palette[0] = BACKGROUND_COLOR

bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
splash.append(bg_sprite)

Draw a smaller inner rectangle

inner_bitmap = displayio.Bitmap(
display.width - BORDER * 2, display.height - BORDER * 2, 1
)
inner_palette = displayio.Palette(1)
inner_palette[0] = FOREGROUND_COLOR
inner_sprite = displayio.TileGrid(
inner_bitmap, pixel_shader=inner_palette, x=BORDER, y=BORDER
)
splash.append(inner_sprite)

Draw a label

text = "Hello World!"
text_area = label.Label(terminalio.FONT, text=text, color=TEXT_COLOR)
text_width = text_area.bounding_box[2] * FONTSCALE
text_group = displayio.Group(
scale=FONTSCALE,
x=display.width // 2 - text_width // 2,
y=display.height // 2,
)
text_group.append(text_area) # Subgroup for text scaling
splash.append(text_group)

while True:
packet = rfm9x.receive()
if packet is None:
print("Received nothing! Listening again...")
text_area.text = "Received nothing! Listening again..."
display.show(splash)
else:
print("Received (raw bytes): {0}".format(packet))
text_area.text = "Received (raw bytes): {0}".format(packet)
display.show(splash)
time.sleep(0.1)
packet_text = str(packet, "ascii")
print("Received (ASCII): {0}".format(packet_text))
text_area.text = "Received (ASCII): {0}".format(packet_text)
display.show(splash)
time.sleep(1)
rssi = rfm9x.last_rssi
print("Received signal strength: {0} dB".format(rssi))
text_area.text = "Received signal strength: {0} dB".format(rssi)`

#

I should add that I am running the most recent "stable" release of circuit python. 7.1.1

hollow ember
#

they are board.TFT_CS and board.TFT_DC

dapper sorrel
#

those assignment statements are not doing anything anyway. It's using the default displayio.DISPLAY

#

I think the q is how to get displayio to share an SPI bus

#

I'm not sure of an example of that

hollow ember
#

OK -- I have used an rfm9x on the esp32s2 tft, but I have not tried to use the display yet.

dapper sorrel
#

The RFM9x uses the standard SPI pins, and so does the display, I think

hollow ember
#

yes

#

should be OK

dapper sorrel
#

but who is mediating the use of the SPI bus

#

adafruit_bus_device is not getting involved

hollow ember
#

ah -- I guess I don't understand.

#

actually, I may not have used the tft -- I was just using am rfm9x with a feather esp32s2

dapper sorrel
#

the display is being updated in the background, because it's the default display. So it writes to the SPI bus when it needs too. If CPy code is trying to talk to the RFM, does that communication get interrupted by the display traffic on the bus, running in the background?

hollow ember
#

so displayio does not use bus_device?
I have other displays and rfm9x running together fine -- like an ili9341

dapper sorrel
#

are they sharing the SPI bus?

hollow ember
#

yes

dapper sorrel
#

ok, maybe it does work, I am pretty unfamiliar with that.

hollow ember
#

it is not a "built-in display" it's a featherwing

dapper sorrel
#

could you point to some code?

#

in this case, the onboard display is showing the RPEL etc

#

maybe it's not an issue, maybe there is always turn-taking,

hollow ember
#

example with ili9431 featherwing

dapper sorrel
#

@split dragon how did you wire up the three pins (IRQ, CS, and RST)? Are they jumpered as in the guide? which ABCDE pins do they go to

#

@hollow ember what is this running on? I only see the MLX as the other device

hollow ember
#

this is on an a feather rp2040

dapper sorrel
#

but no display

hollow ember
#

wrong file

dapper sorrel
#

I think I am worried about a non-existent problem.

hollow ember
#

I can try the OP code on my tft - just need to rearrarnge a few things

dapper sorrel
#

@split dragon can you try to get the RFM working without the display? Do a displayio.release_displays() to disable the display, and then just try some simple RFM programs that don't use your display.

hollow ember
#

@split dragon I ran your code on my esp32s2-tft with an rfm9x featherwing using CS=D10 RST=D11 and it runs and displays the "hello word screen" I am using the "absolute latest CP builds for 7.2.0-alpha - I'll try 7.1.1

#

it does not work with 7.1.1 ....

dapper sorrel
#

thank you for testing @hollow ember

split dragon
#

Thank you everybody for your help. Updating to the alpha of circuit python worked for me. I’m not sure why I have D5 and D6 as the TFT DS and CS. Thats the first example code ive found that worked to show something on the esp32-s2 feather (someone else’s forum post)