Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9220961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:28:13+00:00 2026-06-18T03:28:13+00:00

I am trying to read data from an Arduino UNO to Raspberry Pi with

  • 0

I am trying to read data from an Arduino UNO to Raspberry Pi with the python smbus module. The only documentation I could find on the smbus module was here. I am not sure what the cmd means in the module. I can use the write to send data to the Arduino. I have written two simple programs one for read and one for write

The one for write

import smbus
b = smbus.SMBus(0)
while (0==0):
    var = input("Value to Write:")
    b.write_byte_data(0x10,0x00,int(var))

The one for read

import smbus
bus = smbus.SMBus(0)
var = bus.read_byte_data(0x10,0x00)
print(var)

The Arduino code is

#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
#include <Wire.h>
LiquidCrystal lcd(8,9,4,5,6,7);

int a = 7;

void setup() 
{ 
  Serial.begin(9600);
  lcd.begin(16,2);
  // define slave address (0x2A = 42)
  #define SLAVE_ADDRESS 0x10

  // initialize i2c as slave
  Wire.begin(SLAVE_ADDRESS);

  // define callbacks for i2c communication
  Wire.onReceive(receiveData);
  Wire.onRequest(sendData); 
}
void loop(){
}

// callback for received data
void receiveData(int byteCount) 
{
 Serial.println(byteCount);
  for (int i=0;i <= byteCount;i++){
  char c = Wire.read();
  Serial.println(c);
 }
}

// callback for sending data
void sendData()
{ 
  Wire.write(67);
  lcd.println("Send Data");
}

When I run the read program it returns “33” every time. The Arduino returns that the the sendData function is called.

I am using a Data Level Shifter and the description says it might be a little sluggish.

Has anyone gotten this to work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:28:14+00:00Added an answer on June 18, 2026 at 3:28 am

    I managed to initiate a communication between an Arduino and a Raspberry Pi. The two are connected using two 5k pullup resistors (see this page). The arduino write a byte on the i2c bus for each request. On the Raspberry Pi, hello is printed every second.

    Arduino code:

    #include <Wire.h>
    #define SLAVE_ADDRESS 0x2A
    
    void setup() {
        // initialize i2c as slave
        Wire.begin(SLAVE_ADDRESS);
        Wire.onRequest(sendData); 
    }
    
    void loop() {
    }
    
    char data[] = "hello";
    int index = 0;
    
    // callback for sending data
    void sendData() { 
        Wire.write(data[index]);
        ++index;
        if (index >= 5) {
             index = 0;
        }
     }
    

    Python code on the Raspberry Pi:

    #!/usr/bin/python
    
    import smbus
    import time
    bus = smbus.SMBus(1)
    address = 0x2a
    
    while True:
        data = ""
        for i in range(0, 5):
                data += chr(bus.read_byte(address));
        print data
        time.sleep(1);
    

    On my Raspberry Pi, the i2c bus is 1. Use the command i2c-detect -y 0 or i2c-detect -y 1 to verify if your Raspberry Pi detect your Arduino.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to read data from a website that contains only text. I'd like
I'm trying to read data from the WMI Win32_NTLogEvent class, but I only want
I am trying to read serial data from an Arduino project, and I was
I'm trying to send floating point data from arduino to python.The data is sent
I'm trying to read serial data from my Arduino using Java. I have followed
I'm trying to read data from Google Fusion Tables API into Python using the
I am specifically trying to read data from an SNMP port in python using
I'm trying to read data from an xml file and display it in a
I'm trying to read data from excel using POI. How can I check if
I am trying to read data from a sqlite database in an ios app.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.