Communication problems between the Uno and Rpi 4

Hi there,

I'm currently trying to connect a Raspberry Pi 4 to an Arduino Uno via the RX/TX pins on both boards. I'm using a BOB-12009 Sparkfun level convertor to bridge between the two boards. I'm using the following code on each board to carry out basic communication:

GPIO_serial_test.ino

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

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

GPIO_serial_test.py:

#!/usr/bin/env python3                                                          
import serial                                                                   
import time                                                                     
                                                                                
if __name__ == '__main__':                                                      
    ser = serial.Serial('/dev/ttyAMA0', 9600, timeout=1)                        
    ser.flush()                                                                 
                                                                                
    time.sleep(5)                                                               
                                                                                
    while True:                                                                 
        line = ser.readline().decode('utf-8').rstrip()                          
        if (len(line) > 0):                                                     
            print(line)

I've attached an image of the wiring from the Rpi to the level convertor to the Arduino Uno.

My issue is that I'm able to power the Uno off of the Rpi, however, I'm unable to receive data from the Uno, the rx/tx led's aren't flashing and there's no output to the console on the RPi's side. In multiple diagrams I've seen of this setup, the 3.3v wire is going through the HV pin on the level convertor, when I do this in my case the arduino isn't even powered, is this an issue? I've tried multiple level convertors of this type with no joy. I'm not sure whether the level convertor is the problem or something else. The arduino is able to communicate via USB serial fine. Should I be using something like Software Serial, this isn't ideal as I want communication to be as fast as possible but is this the only way of communicating? If the issue is the level convertor, is there one you guys can recommend me? If there's any more information you guys require just let me know and I'll try to get it for you.

Thanks,

Andrew

Your wiring to the level converter is incorrect. You have +V connected to TX pins of channel 2 instead of HV and LV. Also, the HV and LV on the converter board are inputs to the board, and are not (as you appeared to be trying to do) used to convert power from 5V to 3.3V or vice versa.

So I should move +V wires up to LV -- HV and have the wire coming out of HV going into the 5v of the Arduino?

andyt97:
So I should move +V wires up to LV – HV …

Yes. The Arduino and the Pi are supplying power to the converter board.

andyt97:
… and have the wire coming out of HV going into the 5v of the Arduino?

Power the Arduino from somewhere else - a 5V supply from a PSU (Power Supply Unit) into the +5V pin (same connection as the supply to the converter), or a USB from a PC or other USB PSU, or a supply of 7V to 12V to VIN or the barrel-jack.

So I've done as you suggested, connecting both +ve cables to the LV and HV respectively. I'm now able to get the L LED on the Uno to light up solidly but nothing from the other on-board LEDs and nothing coming through on the RPi. Is there anything else I could have missed? Is there anything I should be testing? I've attached my updated board diagram to this reply.

Just to note I've looked up the solid L LED and people do report that means the board is a dud but it all still works when connected via USB cable to my laptop so I think the board is fine.

Once again, thanks for your help.

You don't show any power supplies.

Sorry, I'm powering the Arduino via a 9v battery and the Rpi via USB type C. I've updated the diagram as attached to this reply.

Thanks,

Andrew

Why not just connect the Arduino via the USB connector? That seems a lot simpler, and the level translator is not needed.

I don't know the Pi. I take it you have Pi TXD to UNO RXD and Pi RXD to UNO TXD? Do you have another converter board to try? (a long shot - I have a bag of 5, only economic way I could find to get them).

So I've tried multiple Level Convertors of the same type (Sparkfun ones) and none of them work. I have a slight suspicion it might be the software running on the Pi. The OS I'm running is Ubuntu 18.04 LTS, which isn't the same as stock Raspbian, I suspect that it might be blocking GPIO but that's only a possibility. I investigated it last night and it doesn't seem like it should be an issue. I've got another type of level converter which I was using before when I didn't really know how to do the wiring. I'll give that level converter a go with my new knowledge and see what comes of it. If that fails I have a TTL USB to UART converter which I might attempt to use instead if there are no other options.

My reasoning for using pins rather than the USB cable is that in the chasis for the prototype I'm building I have very limited space, the USB wire simply doesn't fit. I was also hoping to figure this out as at the moment there isn't really any solid information out there for communicating over pins between these two board.

Thanks again,

Andrew

andyt97:
So I've tried multiple Level Convertors of the same type (Sparkfun ones) and none of them work. I have a slight suspicion it might be the software running on the Pi.

To see if a particular logic level converter module works or not ------ just grab a multimeter, and then use the arduino to output (at one of its useable digital output pins) a voltage (eg. 5 volt) to one of the inputs to the converter module. And then use the multimeter to measure the counterpart pin of the converter ..... which should be say 3.3 volt. And when the digital pin of the arduino is then made to output 0V, then the counterpart output pin of the converter module should then become 0V as well.

The test can be done for every input pin and output of the converter module ------ to make sure it's all working.

And - the title of your thread is 'communication problem'. It's not a communication problem. It's a set-up problem. The aim is to make sure everything is suitably set-up. If the set-up isn't correct or satisfactory, then getting the arduino to communicate with the raspberry is unlikely going to happen.

So - we just got to make sure voltages are all ok, and working. And also got to make sure that the devices (such as the converter module) can handle the communications speed. If the receiving side expects to measure fairly nice square waves, but is getting distorted waveforms, then that's no good.

But there are also other aspects - such as software setup. So after the hardware is all set up properly - some basic tests in software can then be done. And eventually the system will actually work.