Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Feather M0 RFM96 and TFT
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Feather M0 RFM96 and TFT

by meinsm on Wed Mar 18, 2020 4:13 pm

Hello,
i am totally new at Adafruit, CircuitPython etc.

I wanted to have the M0 RFM96 to display the received data at the display.
With USB and serial i see the output, but i dont get the TFT FeatherWing - 2.4" working.

Code: Select all | TOGGLE FULL SIZE
# Simple demo of sending and recieving data with the RFM95 LoRa radio.
# Author: Tony DiCola
import board
import busio
import digitalio

import adafruit_rfm9x


# Define radio parameters.
RADIO_FREQ_MHZ = 433.0  # Frequency of the radio in Mhz. Must match your
# module! Can be a value like 915.0, 433.0, etc.

# Define pins connected to the chip, use these if wiring up the breakout according to the guide:
CS = digitalio.DigitalInOut(board.RFM9X_CS)
RESET = digitalio.DigitalInOut(board.RFM9X_RST)
# Or uncomment and instead use these if using a Feather M0 RFM9x board and the appropriate
# CircuitPython build:
# CS = digitalio.DigitalInOut(board.RFM9X_CS)
# RESET = digitalio.DigitalInOut(board.RFM9X_RST)

# Define the onboard LED
LED = digitalio.DigitalInOut(board.D13)
LED.direction = digitalio.Direction.OUTPUT

# Initialize SPI bus.
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)

tft_cs = digitalio.DigitalInOut(board.D9)
tft_dc = digitalio.DigitalInOut(board.D10)


from adafruit_rgb_display import ili9341, color565
display = ili9341.ILI9341(spi, cs=tft_cs, dc=tft_dc)
   
display.fill(color565(255, 0, 0))   
# Initialze RFM radio
rfm9x = adafruit_rfm9x.RFM9x(spi, CS, RESET, RADIO_FREQ_MHZ)

# Note that the radio is configured in LoRa mode so you can't control sync
# word, encryption, frequency deviation, or other settings!

# You can however adjust the transmit power (in dB).  The default is 13 dB but
# high power radios like the RFM95 can go up to 23 dB:
rfm9x.tx_power = 23

# Send a packet.  Note you can only send a packet up to 252 bytes in length.
# This is a limitation of the radio packet size, so if you need to send larger
# amounts of data you will need to break it into smaller send calls.  Each send
# call will wait for the previous one to finish before continuing.
rfm9x.send(bytes("Hello world!\r\n", "utf-8"))
print("Sent Hello World message!")

# Wait to receive packets.  Note that this library can't receive data at a fast
# rate, in fact it can only receive and process one 252 byte packet at a time.
# This means you should only use this for low bandwidth scenarios, like sending
# and receiving a single message at a time.
print("Waiting for packets...")

while True:
   packet = rfm9x.receive()
   # Optionally change the receive timeout from its default of 0.5 seconds:
   # packet = rfm9x.receive(timeout=5.0)
   # If no packet was received during the timeout then None is returned.
   if packet is None:
      # Packet has not been received
      LED.value = False
   else:
      # Received a packet!
      LED.value = True
      # Print out the raw bytes of the packet:
      print("Received (raw bytes): {0}".format(packet))
      # And decode to ASCII text and print it too.  Note that you always
      # receive raw bytes and need to convert to a text format like ASCII
      # if you intend to do string processing on your data.  Make sure the
      # sending side is sending ASCII data before you try to decode!
      packet_text = str(packet, "ascii")
      print("Received (ASCII): {0}".format(packet_text))
      # Also read the RSSI (signal strength) of the last received message and
      # print it.
      rssi = rfm9x.rssi
      print("Received signal strength: {0} dB".format(rssi))


This is mainly from the example.
The serial output is working but the TFT FeatherWing - 2.4" does not work.
What do i wrong?

And the next problem i have is that sometimes the CircuitPython main.py is not editable and is shown empty if i open it.
What wrong there?

meinsm
 
Posts: 5
Joined: Wed Mar 18, 2020 4:06 pm

Re: Feather M0 RFM96 and TFT

by mikeysklar on Wed Mar 18, 2020 5:31 pm

Hello meinsm,

You will need to setup the required libraries for using the TFT 2.4" featherwing.

https://learn.adafruit.com/adafruit-2-4 ... eatherwing

Try getting the display going first before adding in the RFM relevant code.

As far as main.py occasionally being empty that is a sign of a corrupted filesystem. I would recommend upgrading to the latest CircuitPython release (5.x) and libraries.

https://learn.adafruit.com/adafruit-gem ... ive-issues

mikeysklar
 
Posts: 1259
Joined: Mon Aug 01, 2016 8:10 pm

Re: Feather M0 RFM96 and TFT

by meinsm on Thu Mar 19, 2020 10:35 am

Thank you.
But it isnt working anyhow.
I get the error that the displayio module is not found.

But i copied the adafruit_ili9341 and adafruit_display_text to the lib-folder.
And i have the latest version 5.0.0 installed.

meinsm
 
Posts: 5
Joined: Wed Mar 18, 2020 4:06 pm

Re: Feather M0 RFM96 and TFT

by tannewt on Fri Mar 20, 2020 1:55 pm

Unfortunately `displayio` isn't available on M0 non-Express boards. They simply do not have enough flash space to store all the needed code.

tannewt
 
Posts: 1691
Joined: Thu Oct 06, 2016 8:48 pm

Re: Feather M0 RFM96 and TFT

by meinsm on Fri Apr 03, 2020 1:55 am

Ah ok. Thank you very much

meinsm
 
Posts: 5
Joined: Wed Mar 18, 2020 4:06 pm

Please be positive and constructive with your questions and comments.