Notifications
Clear all

Troubleshooting Raspberry Pi and Arduino communication.  

Page 1 / 4
  RSS

Bill21
(@bill21)
Active Member
Joined: 2 months ago
Posts: 16
2020-07-13 9:18 pm  

I have followed the dronebot tutorial and, as far as i can see, replicated the experiment exactly. However, it is not working for me. Does anyone have any thoughts on why this might be and how I could test the problem?

The I2C bus is enabled on the Raspberry Py. The Arduino program compiles on the Arduino IDE and uploads to the Arduino Uno clone. The Python program compiles on Geany and runs exactly as it does in the tutorial on the Raspberry Py 3b. The physical wiring is exactly as demonstrated in the tutorial. The LED remains off. I type 1 and enter and nothing happens.

I first tried the experiment with a 4 channel logic converter and a LED with a capacitor that had worked with that LED before. When it didn't work I tried a different but identical led and capacitor. When it still didn't work I removed the logic converter and rewired the Raspberry Py directly to the Arduino as I was only operating a LED. When it still didn't work I removed the LED and tried the experiment with the built in LED on the Arduino with still no success.

There are no error messages on the Raspberry Py and the Python program runs normally except the LED doesn't light up. Does anyone have any ideas?

thanks, Bill21


Quote
teddy
(@teddy)
Trusted Member
Joined: 9 months ago
Posts: 62
2020-07-13 9:38 pm  

1)  Raspberry Pi

     Are you using BCM or BOARD in the setup of Python. Remember, this tell weather your

     going to use the GPIO Pins, or the actual BOARD PINs.  Also check that GPIO is installd

     and working by executing: gpio -v

 

2) Arduino

    Make sure you chose the correct board, (UNO) and the correct Serial Port. Then load the

    Basic BLINK INO  download to the board, and execute...you should then get the ON-BOARD LED

    (or Pin 13) blinking.  If that doesn't work, you most like have a bad Arduino, or the

    Boot-loader needs reinstalling.

 

This post was modified 1 month ago 6 times by teddy

ReplyQuote
Spyder
(@spyder)
Prominent Member
Joined: 1 year ago
Posts: 803
2020-07-15 7:53 pm  

@bill21

Have you tried (as a troubleshooting procedure) using the USB port from the Pi to the Arduino ?

This would remove any wiring issue or potential failed component issue. If that works, then you can go back to implementing the I2C in phases, adding one piece at a time until it either works, or you find the failure point


ReplyQuote
Bill21
(@bill21)
Active Member
Joined: 2 months ago
Posts: 16
2020-07-15 9:53 pm  

@spyder

Hi Spider

 

Tried the USB with no result. thinks for the suggestion. I'd welcome any other ideas.

 

Bill21


ReplyQuote
teddy
(@teddy)
Trusted Member
Joined: 9 months ago
Posts: 62
2020-07-15 10:04 pm  
Posted by: @bill21

@spyder

Hi Spider

 

Tried the USB with no result. thinks for the suggestion. I'd welcome any other ideas.

 

Bill21

If your talking about the Pi, did you add a serial translator board if talking to an Arduino?

Pi is 3.3V on GPIO, Arduino is 5V on GPIO.

 


ReplyQuote
Bill21
(@bill21)
Active Member
Joined: 2 months ago
Posts: 16
2020-07-15 10:34 pm  

@teddy

Hi Teddy

I'm not sure what you mean by BCM or BOARD in the setup of Python? I'm not familiar with python but I used Geany and entered the code exactly as Bill demonstrated. what are these and where and how can I check them?

GPIO is installed and enabled. 

UNO is selected for the Arduino.

The blink program works as intended.

I've run servos from that Arduino as well. it has always worked as intended.

the Raspberry Pi is pretty much vanilla. I2C is enabled but would there be anything else I may not have enabled?

thanks

Bill21


ReplyQuote
Bill21
(@bill21)
Active Member
Joined: 2 months ago
Posts: 16
2020-07-15 10:38 pm  

@teddy

I meant the USB connection between the pi and the Arduino. is that not what Spider was talking about?

Bill21


ReplyQuote
teddy
(@teddy)
Trusted Member
Joined: 9 months ago
Posts: 62
2020-07-15 11:32 pm  
Posted by: @bill21

@teddy

I meant the USB connection between the pi and the Arduino. is that not what Spider was talking about?

Bill21

If that's the case, he would most like need a USB HUB or a crossover cable.

Personally, I'd go Serial to Serial, but with a level convertor board from Sparkfun.

Another route to take is watch DroneBot's YouTube on how to do this...


ReplyQuote
Spyder
(@spyder)
Prominent Member
Joined: 1 year ago
Posts: 803
2020-07-16 1:12 am  
Posted by: @teddy

need a USB HUB or a crossover cable

Why ?

You program the arduino with no special cable from usb to usb

My arduino mega sends ultrasonic sensor data to my jetson over the USB link without any extra gizmos

Besides, I've never heard of a usb crossover cable. Is this something new I've missed ? Unless yer talking about a USB cable with no power. That I can understand, but if the arduino is GETTING power from the pc, then no worries, cuz at that point, it NEEDS that power to turn on...

Hold on... I think I just figured it out...

POWER

@bill21

I wonder if that lidar is drawing more power from the arduino than the computer can supply


ReplyQuote
teddy
(@teddy)
Trusted Member
Joined: 9 months ago
Posts: 62
2020-07-16 8:08 pm  
Posted by: @spyder
Posted by: @teddy

need a USB HUB or a crossover cable

Why ?

You program the arduino with no special cable from usb to usb

My arduino mega sends ultrasonic sensor data to my jetson over the USB link without any extra gizmos

Besides, I've never heard of a usb crossover cable. Is this something new I've missed ? Unless yer talking about a USB cable with no power. That I can understand, but if the arduino is GETTING power from the pc, then no worries, cuz at that point, it NEEDS that power to turn on...

Hold on... I think I just figured it out...

POWER

@bill21

I wonder if that lidar is drawing more power from the arduino than the computer can supply

Although not used much anymore, YES! there is a USB crossover cable since the 90's.

It wasn't popular, so USB HUBs came along to handle multiple cables in 2 to 16 channels.

Buy now, there are 96 channel USB HUBs.

 


ReplyQuote
MadMisha
(@madmisha)
Eminent Member
Joined: 5 months ago
Posts: 34
2020-07-16 8:18 pm  
Posted by: @bill21

@teddy

Hi Teddy

I'm not sure what you mean by BCM or BOARD in the setup of Python? I'm not familiar with python but I used Geany and entered the code exactly as Bill demonstrated. what are these and where and how can I check them?

GPIO is installed and enabled. 

Bill21

It should be declared somewhere in your code for BCM or BOARD. It would change what pin you are trying to control. BCM is the broadcom SOC channel output pin label and is what is labeled on the card that comes with the Raspberry Pi. Different versions of the Pi can move these around. BOARD is where you use the number for the physical pin. So the physical pin may be 12 but GPIO18. If any other script or program is running on the Pi has it set to the other mode, you might run into trouble. I don't believe you can use both at the same time.

 

If you have WiringPi installed, there are commands to check things like this and check I2C communication.

http://wiringpi.com/the-gpio-utility/


ReplyQuote
MadMisha
(@madmisha)
Eminent Member
Joined: 5 months ago
Posts: 34
2020-07-16 8:47 pm  

Actually, I would suggest starting simple. Simply upload a blink sketch or make your own on the Uno to make sure nothing is wrong with your LED. I've been thwarted by simple polarity mistakes before. If this has no luck then all troubleshooting attempts for the I2C line will be in vain.

 

If your Uno and LED are working fine, double check that the pins you are using on the Pi are correct. Different versions of the Pi have them in different places.

 

If you have a version of the Uno that have the extra 2 I2C lines above the D13, Gnd and AREF, try using those instead.


ReplyQuote
teddy
(@teddy)
Trusted Member
Joined: 9 months ago
Posts: 62
2020-07-16 8:57 pm  
Posted by: @madmisha
Posted by: @bill21

@teddy

Hi Teddy

I'm not sure what you mean by BCM or BOARD in the setup of Python? I'm not familiar with python but I used Geany and entered the code exactly as Bill demonstrated. what are these and where and how can I check them?

GPIO is installed and enabled. 

Bill21

It should be declared somewhere in your code for BCM or BOARD. It would change what pin you are trying to control. BCM is the broadcom SOC channel output pin label and is what is labeled on the card that comes with the Raspberry Pi. Different versions of the Pi can move these around. BOARD is where you use the number for the physical pin. So the physical pin may be 12 but GPIO18. If any other script or program is running on the Pi has it set to the other mode, you might run into trouble. I don't believe you can use both at the same time.

 

If you have WiringPi installed, there are commands to check things like this and check I2C communication.

http://wiringpi.com/the-gpio-utility/

madmisha - NO you can't assign BCM or BOARD at the same time.  It's a matter of choice.  I prefer BOARD!  If your using debian buster, wiringPi is already installed.  To prove this, enter: gpio -v for version, or gpio readall to see the status of each pin.

 

This post was modified 4 weeks ago by teddy

ReplyQuote
MadMisha
(@madmisha)
Eminent Member
Joined: 5 months ago
Posts: 34
2020-07-16 9:14 pm  

@teddy I know you can't declare both in the same script. I am fairly sure that if another program or script is using it, that could change the value for you or fail to change it to your parameters. I thought there was a way to check what it currently is set to in the command line but I can't remember nor do I see it coming up in a search. It is probably in the Wiringpi utility and I just don't see it.

 

But looking back at the tutorial, neither is declared. I am not sure if this is because it is assuming the default or if it doesn't matter because it can just inject the message to the bus.

 

EDIT:

Also, here is a tutorial I happened to see that can help detect if the I2C address is present that is fairly easy.

https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c


ReplyQuote
teddy
(@teddy)
Trusted Member
Joined: 9 months ago
Posts: 62
2020-07-16 11:19 pm  

@madmisha - I have 93 How-To's for setting up just about anything you can think of in linux on a Pi!

If I understand you correctly, your asking about wiringPi, which you check with gpio -v

It is already installed in "buster".

If you talking about i2c, enter: i2cdetect -y 1   this will give you a map of i2c HEX of what is being used

if you have an i2c device connected, and you turned ON i2c in config.


ReplyQuote
Page 1 / 4