Notifications
Clear all

Troubleshooting Raspberry Pi and Arduino communication.

47 Posts
4 Users
1 Likes
2,841 Views
MadMisha
(@madmisha)
Reputable Member
Joined: 3 years ago
Posts: 348
 

@teddy Yeah, that's it. I don't know why I didn't see that in the link I posted. I installed buster on my last Raspberry Pi project but something must have gone wrong. I had to manually install it to get it working.

 

If you have a link to your tutorials, I would greatly appreciate it. I am wanting to get more familiar with Raspberry Pi and Linux. Particularly if you have something about setting up a bare bones Pi for a purpose built project. I haven't seen anything good about having a Pi set up with only the things you need for your project to run. I did look into a daemon but it didn't go well. I ended up just using Cron tab. It took a few tries to get it right but it's now working fine.


   
ReplyQuote
teddy
(@teddy)
Trusted Member
Joined: 3 years ago
Posts: 66
 

@madmisha - I need to update MANY if these files! Many are old for Wheezy, I will update them for Buster.

I'll try and send them to you tomorrow.  I'll add a link on this message so you can download them directly. Providing DroneBot allows that!


   
MadMisha reacted
ReplyQuote
Bill21
(@bill21)
Eminent Member
Joined: 3 years ago
Posts: 18
Topic starter  

teddy and MadMisha

I’m using a Raspberry Pi 3B+ and an Arduino Uno clone if that gives anything away. All the software I am using came native with the Pi except the Arduino IDE. I2C is enabled.

 

I have tried the blink program and it works as intended. I am using the same pins that were demonstrated in Bill’s tutorial. It looks like the same machine that Bill was using. I am using the built in LED on the Arduino. Please can you tell me what is the intended purpose of the AREF pin? I have an AREF pin. However, should I switch the pin from A4 or A5 to the AREF pin? And does it make any difference that I am using the built in LED on the Arduino?

 

I tried the tutorial.

I’m not sure what this means but what I got from sudo i2cdetact –y 1 was:

 

        0   1   2   3   4   5   6   7   8   9   a   b   c   d   e   f

00                  --   --   --   --  --  08 --  -- etc.

10

20

etc.

 

Should the 08 be under the 1 instead of the 8? Or is this the way it should be as per the code in the program addr = 0x8

 

Thank you both for your help.

 

Bill21


   
ReplyQuote
MadMisha
(@madmisha)
Reputable Member
Joined: 3 years ago
Posts: 348
 

@bill21 Not the AREF pin. Some models of the Uno have 2 extra pins for SCL and SDA. The Uno Bill used in his tutorial(atleast in the hookup diagram) has them. They are often unlabeled.

 

If yours doesn't have that then you will have to look for a different option in debugging. Not a big deal.

 

Edit:

Yeah, It looks like it is addressed correctly. I totally messed up my first reading of it. I actually lines up under the 8 and that is correct. Maybe @teddy might know more.

 

It could be a conversion error. You might try it as a HEX type but because it passes the command it might need to be a string. It's worth giving it a try. I have had pieces of code that worked for others and for some reason it wanted me to declare the data type for it to work for me. I would mess around with the Arduino code and keep using that I2C detect command until you get the address sorted out.

 

I would print what is received in I2C on the Arduino to the serial monitor so you can see what it is receiving. Knowing if it matches or if you don't see anything might point you in the right direction.

 

And you can always drop your code in here and maybe we can spot the difference.


   
ReplyQuote
Bill21
(@bill21)
Eminent Member
Joined: 3 years ago
Posts: 18
Topic starter  
Posted by: @madmisha

I would print what is received in I2C on the Arduino to the serial monitor so you can see what it is receiving. Knowing if it matches or if you don't see anything might point you in the right direction.

I wonder if you could give me a step by step on how to do that? The Arduino has the two extra pins you are talking about. I tried using them (matching up the PC4 and PC5 pins) as per the diagram with no difference.

thanks, Bill21

This post was modified 3 years ago by Bill21

   
ReplyQuote
teddy
(@teddy)
Trusted Member
Joined: 3 years ago
Posts: 66
 
Posted by: @bill21

teddy and MadMisha

I’m using a Raspberry Pi 3B+ and an Arduino Uno clone if that gives anything away. All the software I am using came native with the Pi except the Arduino IDE. I2C is enabled.

 

I have tried the blink program and it works as intended. I am using the same pins that were demonstrated in Bill’s tutorial. It looks like the same machine that Bill was using. I am using the built in LED on the Arduino. Please can you tell me what is the intended purpose of the AREF pin? I have an AREF pin. However, should I switch the pin from A4 or A5 to the AREF pin? And does it make any difference that I am using the built in LED on the Arduino?

 

I tried the tutorial.

I’m not sure what this means but what I got from sudo i2cdetact –y 1 was:

 

        0   1   2   3   4   5   6   7   8   9   a   b   c   d   e   f

00                  --   --   --   --  --  08 --  -- etc.

10

20

etc.

 

Should the 08 be under the 1 instead of the 8? Or is this the way it should be as per the code in the program addr = 0x8

 

Thank you both for your help.

 

Bill21

This is 08 HEX for the i2c device you have plugged in.

This is set by the manufacture, so each HAT or device that is i2c, will have it's own HEX Address.

 


   
ReplyQuote
teddy
(@teddy)
Trusted Member
Joined: 3 years ago
Posts: 66
 
Posted by: @bill21

teddy and MadMisha

I’m using a Raspberry Pi 3B+ and an Arduino Uno clone if that gives anything away. All the software I am using came native with the Pi except the Arduino IDE. I2C is enabled.

 

I have tried the blink program and it works as intended. I am using the same pins that were demonstrated in Bill’s tutorial. It looks like the same machine that Bill was using. I am using the built in LED on the Arduino. Please can you tell me what is the intended purpose of the AREF pin? I have an AREF pin. However, should I switch the pin from A4 or A5 to the AREF pin? And does it make any difference that I am using the built in LED on the Arduino?

 

I tried the tutorial.

I’m not sure what this means but what I got from sudo i2cdetact –y 1 was:

 

        0   1   2   3   4   5   6   7   8   9   a   b   c   d   e   f

00                  --   --   --   --  --  08 --  -- etc.

10

20

etc.

 

Should the 08 be under the 1 instead of the 8? Or is this the way it should be as per the code in the program addr = 0x8

 

Thank you both for your help.

 

Bill21

Read this about the AREF Pin: https://tronixstuff.com/2013/12/12/arduino-tutorials-chapter-22-aref-pin/

 


   
ReplyQuote
Bill21
(@bill21)
Eminent Member
Joined: 3 years ago
Posts: 18
Topic starter  

@teddy

I'v had a look at the tutorial. That might be useful to me for another part of my project farther down the line. But for this issue, Im I correct in saying that the AREF pin isn't going to get me where I want to go?

 

the formatting got mixed up on my previous post. the 08 should be under the 8. does that addressing look right? I am just a beginner hobbyist who is trying to learn as I go. I'm having a lot of fun and I really appreciate people like yourself helping me as I increase my knowledge base. Is the above the HEX address and does it look correct for what I am trying to do? If so, can you think of any other setting that would need to be enabled in a vanilla pi that would stop communication between the pi and the Arduino?

thanks

Bill21


   
ReplyQuote
teddy
(@teddy)
Trusted Member
Joined: 3 years ago
Posts: 66
 
Posted by: @bill21

@teddy

I'v had a look at the tutorial. That might be useful to me for another part of my project farther down the line. But for this issue, Im I correct in saying that the AREF pin isn't going to get me where I want to go?

 

the formatting got mixed up on my previous post. the 08 should be under the 8. does that addressing look right? I am just a beginner hobbyist who is trying to learn as I go. I'm having a lot of fun and I really appreciate people like yourself helping me as I increase my knowledge base. Is the above the HEX address and does it look correct for what I am trying to do? If so, can you think of any other setting that would need to be enabled in a vanilla pi that would stop communication between the pi and the Arduino?

thanks

Bill21

I believe that AREF won't be used for your project.  It requires hardware and is used for a reference

voltage for more accuracy.

 

Yes, 08 is 08 HEX, and the columns & Rows should line up.  I have a SenseHAT for my Pi, and it takes up

6 HEX Addresses.  But none of them use 08 HEX.  Like I said, each manufacturer assigns the HEX

for for an i2c device.


   
ReplyQuote
Bill21
(@bill21)
Eminent Member
Joined: 3 years ago
Posts: 18
Topic starter  

@teddy

Should 08 HEX come under the number 8 in the first row of the address table for an Arduino Uno?

thanks

Bill21


   
ReplyQuote
Bill21
(@bill21)
Eminent Member
Joined: 3 years ago
Posts: 18
Topic starter  
Posted by: @madmisha

I would print what is received in I2C on the Arduino to the serial monitor so you can see what it is receiving. Knowing if it matches or if you don't see anything might point you in the right direction.

Can you tell me how i would do that?


   
ReplyQuote
MadMisha
(@madmisha)
Reputable Member
Joined: 3 years ago
Posts: 348
 

It should look something like this. Just print what comes over the serial. I did not test this.

 

#include <Wire.h>


void setup() {
// Join I2C bus as slave with address 8
Wire.begin(0x8);

// Call receiveEvent when data received
Wire.onReceive(receiveEvent);

}

// Function that executes whenever data is received from master
void receiveEvent(int howMany) {
while (Wire.available()) { // loop through all but the last
char c = Wire.read(); // receive byte as a character
Serial.println(c);
}
}
void loop() {
delay(100);
}



   
ReplyQuote
MadMisha
(@madmisha)
Reputable Member
Joined: 3 years ago
Posts: 348
 

@Bill21 Also, just to make sure every box is checked, I would move the ground connections around. Pick a different ground on the Arduino to put the wire. You can also use a different wire just to rule that out.

 

Then pick a different ground pin on the Raspberry Pi. I suggest to pick one that is closer to the end of the row since it is easier to locate and better chances of not miss wiring it.

 

You said you had a 3 B+ so here is the pinout for that:


   
ReplyQuote
teddy
(@teddy)
Trusted Member
Joined: 3 years ago
Posts: 66
 
Posted by: @bill21

@teddy

Should 08 HEX come under the number 8 in the first row of the address table for an Arduino Uno?

thanks

Bill21

Rows and Columns line up with the HEX Code.

 


   
ReplyQuote
teddy
(@teddy)
Trusted Member
Joined: 3 years ago
Posts: 66
 
Posted by: @madmisha

It should look something like this. Just print what comes over the serial. I did not test this.

 

#include <Wire.h>


void setup() {
// Join I2C bus as slave with address 8
Wire.begin(0x8);

// Call receiveEvent when data received
Wire.onReceive(receiveEvent);

}

// Function that executes whenever data is received from master
void receiveEvent(int howMany) {
while (Wire.available()) { // loop through all but the last
char c = Wire.read(); // receive byte as a character
Serial.println(c);
}
}
void loop() {
delay(100);
}


In order to see what's going on in the Serial Monitor, you will need to add the following code in setup()

void setup() {

  Serial.begin(57600);

}

 

Note: You can change the speed to 9600.  Without that statement, nothing will come out of the Serial Port!

 

 


   
ReplyQuote
Page 2 / 4