Feather M0 LoRa module TX/RX UART connection to Raspberry Pi

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
CluelessRic
 
Posts: 16
Joined: Thu Feb 11, 2021 4:27 am

Feather M0 LoRa module TX/RX UART connection to Raspberry Pi

Post by CluelessRic »

I want to display sensor data on A LED matrix connected to a Adafruit RGB Matrix Bonnet & Pi Zero. The Pi is supposed to receive the data from an https://learn.adafruit.com/adafruit-fea ... le/pinouts but this not happening, and I would be grateful if someone can tell me how to fix this problem.

My wiring between the Feather & Pi are detailed in the attached image
Feather-Pi wiring
Feather-Pi wiring
Feather-Pi wiring.jpg (666.46 KiB) Viewed 187 times
.

To test the connection I am running the following code on the Feather:

// https://roboticsbackend.com/raspberry-p ... unication/

void setup() {
Serial.begin(9600);
}

void loop() {
Serial.println("Hello from Arduino!");
delay(1000);
}


The Feather terminal window shows the following which is encouraging:
12:28:36.080 -> Hello from Arduino!
12:28:37.064 -> Hello from Arduino!
12:28:38.053 -> Hello from Arduino!

I am running the following test code on the Pi Zero:

# https://roboticsbackend.com/raspberry-p ... unication/

#!/usr/bin/env python3
import serial

if __name__ == '__main__':
ser = serial.Serial('/dev/serial0', 9600, timeout=3)
ser.reset_input_buffer()

while True:
if ser.in_waiting > 0:
line = ser.readline().decode('utf-8').rstrip()
print(line)


I am currently get no errors but no results from the Pi, when viewed on Thonny.
If I comment out "if ser.in_waiting > 0:", then the Thonny (Shell) output scrolls down with blank lines.
I have tried changing serial0 to serial1 with no better results.
Typing "ls -l /dev" on the Pi terminal includes the following rows in the output:
lrwxrwxrwx 1 root root 7 Dec 1 12:17 serial0 -> ttyAMA0
lrwxrwxrwx 1 root root 5 Dec 1 12:17 serial1 -> ttyS0

Can you please tell me why the Pi is not receiving the test message from the Feather?

User avatar
CluelessRic
 
Posts: 16
Joined: Thu Feb 11, 2021 4:27 am

Re: Feather M0 LoRa module TX/RX UART connection to Raspberr

Post by CluelessRic »

It seems the problem is with the Feather M0, because I replaced it with a Sparkfun ESP8266 Thing Dev board, using the same wiring as above. Using the same Arduino sender code as above, the "Hello from Arduino" message is received on the Pi per attached screenshot.
Unfortunately the ESP8266 does not have the required transmission range for my project, so I still need to find out why the Feather won't connect to the Pi.
Any ideas how to get the Feather to send to the Pi?

User avatar
Franklin97355
 
Posts: 23911
Joined: Mon Apr 21, 2008 2:33 pm

Re: Feather M0 LoRa module TX/RX UART connection to Raspberr

Post by Franklin97355 »

Take a look at this user that had a similar problem:https://forum.arduino.cc/t/connecting-f ... lem/531104

User avatar
CluelessRic
 
Posts: 16
Joined: Thu Feb 11, 2021 4:27 am

Re: Feather M0 LoRa module TX/RX UART connection to Raspberr

Post by CluelessRic »

This screen shot shows the Pi receiving a message from an ESP board; but it won't receive from the Feather board using same wiring and code!
Attachments
Thonny screen for ESP to Pi
Thonny screen for ESP to Pi
Thonny for ESP to Pi code.png (367.73 KiB) Viewed 165 times

User avatar
CluelessRic
 
Posts: 16
Joined: Thu Feb 11, 2021 4:27 am

Re: Feather M0 LoRa module TX/RX UART connection to Raspberr

Post by CluelessRic »

Franklin, your link to a similar post seems to focus on logic level conversion, but in my case both the Feather and Pi boards use 3.3V logic?

User avatar
adafruit_support_carter
 
Posts: 29168
Joined: Tue Nov 29, 2016 2:45 pm

Re: Feather M0 LoRa module TX/RX UART connection to Raspberr

Post by adafruit_support_carter »

The TX/RX pins on the Feather are accessed via Serial1:
https://learn.adafruit.com/adafruit-fea ... -2825153-9

User avatar
CluelessRic
 
Posts: 16
Joined: Thu Feb 11, 2021 4:27 am

Re: Feather M0 LoRa module TX/RX UART connection to Raspberr

Post by CluelessRic »

Hi Carter, as mentioned in my original post, I have already tried using the line "ser = serial.Serial('/dev/serial1', 9600, timeout=3)" in the Pi code, without success.
What else should I be doing to use Serial1?

User avatar
dastels
 
Posts: 15659
Joined: Tue Oct 20, 2015 3:22 pm

Re: Feather M0 LoRa module TX/RX UART connection to Raspberr

Post by dastels »

Use Serial1 instead of Serial in the Feather code. Serial is the USB/Serial connection.

Dave

User avatar
CluelessRic
 
Posts: 16
Joined: Thu Feb 11, 2021 4:27 am

Re: Feather M0 LoRa module TX/RX UART connection to Raspberr

Post by CluelessRic »

Thanks for the advise Dave.
When I use "Serial1.begin(9600);" in the Feather code above, the Feather sends messages, but the Pi still receives nothing.
When I then also use "Serial1.println("Hello from Arduino!");" in the Feather code, the Feather does not send messages, and obviously the Pi receives nothing.
Should I do something else?

User avatar
adafruit_support_carter
 
Posts: 29168
Joined: Tue Nov 29, 2016 2:45 pm

Re: Feather M0 LoRa module TX/RX UART connection to Raspberr

Post by adafruit_support_carter »

You will not see anything in the Serial Monitor if you only print to Serial1. Try printing to both Serial (for debugging) and Serial1 (for talking to Pi) in your Arduino sketch.

EDIT - you may also need to "enable" serial on the Pi. You can do that via rpi-config or by direct text file editing:
https://learn.adafruit.com/raspberry-pi ... 2827368-10

User avatar
CluelessRic
 
Posts: 16
Joined: Thu Feb 11, 2021 4:27 am

Re: Feather M0 LoRa module TX/RX UART connection to Raspberr

Post by CluelessRic »

Hi Carter, I changed the Feather code to include both lines : Serial.println("Hello from Arduino!"); and Serial1.println("Hello from Arduino!"); .
Mt boot/config.txt file already included an uncommented line: enable_uart=1
Only when I changed the Pi code from serial1 to serial0 ie the code line: ser = serial.Serial('/dev/serial0', 9600, timeout=3) , did the messages finally start appearing in Thonny!
The messages also appear in the Pi's Terminal screen when I run the file.
Thanks for solving my problem!
I will now move to the next stage of this project; sending temperature data from the Feather to the Pi/display hat for LED matrix display purposes.

Locked
Please be positive and constructive with your questions and comments.

Return to “Feather - Adafruit's lightweight platform”