Hello guys,
I'm getting the error "[Errno 121] Remote I/O error" when I try to access a received data from Raspberry PI 3 via I2C.
Here is my raspberry pi code (in Python):
from flask import Flask
import smbus
import time
import sys
bus = smbus.SMBus(1)
address = 0x04
app = Flask('Robotica')
@app.route("/")
def index():
return "use /request/<query> to proccess a query"
@app.route("/request/<query>")
def request(query):
sendQuery(query)
return "Received query: " + query
def sendQuery(query):
data = query.split('|')
for i in data:
bus.write_byte(address, int(i))
time.sleep(0.050)
return
try:
app.run(host='192.168.15.11', threaded=True)
except KeyboardInterrupt:
print("Server closed!")
Here is my Arduino code:
#include <Wire.h>
#define SLAVE_ADDRESS 0x04
int number = 0;
int data[700];
int pos = 0;
void setup() {
Serial.begin(9600);
Wire.begin(SLAVE_ADDRESS);
Wire.onReceive(receiveData);
Wire.onRequest(sendData);
}
void loop() {
delay(50);
}
void printData(){
for (int i = 0; i < pos; i++){;
Serial.print(data[i] + " ");
}
}
void receiveData(int byteCount) {
while (Wire.available()) {
data[pos] = Wire.read();
if (data[pos] != 255){
Serial.println(data[pos]);
pos++;
}
else{
Serial.println("Trying to print the vector...");
printData();
pos = 0;
}
}
}
void sendData() {
Wire.write(number);
}
When I send the data for the first time the Arduino prints the numbers in the Serial.println inside the if but not print on else.
When I send another data for the second time, I got the error ![]()

The input data that I'm using for test is: "10|20|30|40|50|60|1|255" without quotes.
What is happening?