I cannot get the master(non Arduino) to receive the correct response from my slave (Arduino Nano) (Tesla Electronics is under construction). I have no control over the master as it comes from a wheelchair that I bought.
If the master(non Arduino) asks for a single byte it works. But when it asks for multiple ones then oscilloscope shows weird signals:
In the above screenshot, the correct response after the request 0x50 2C should be 0x00, 0x08, 0x03 but only the first byte is correctly displayed.
However, when we look at the previous request 0x80, the slave returned 1 byte 0x00 which is correctly displayed.
More info:
Master project (in the test system) + overall project description: GitHub - johnnyhoichuen/wheelchair-master
And slave project (in both test & target system): wheelchair-slave/main.cpp at main · johnnyhoichuen/wheelchair-slave · GitHub
Slave code:
const byte rrResponse[11][4] = {
{0x28, 0x00, 0x5A, 0x5A},
{0x2C, 0x00, 0x08, 0x03},
{0x30, 0x00, 0x07, 0x88},
{0x34, 0x00, 0x00, 0x00},
{0x38, 0x00, 0x00, 0x70},
{0x3C, 0x00, 0x00, 0x00},
{0x40, 0x00, 0x00, 0x83},
{0x44, 0x00, 0x00, 0x79},
{0x48, 0x00, 0x00, 0x00},
{0x4C, 0x00, 0x00, 0x78},
{0x50, 0x00, 0x00, 0x00}};
void setup()
{
...
Wire.onRequest(requestHandler);
...
}
void requestHandler()
{
...
byte buffer[3];
buffer[0] = rrResponse[i][1];
buffer[1] = rrResponse[i][2];
buffer[2] = rrResponse[i][3];
Wire.write(buffer, 3);
...
}
Master code (this master is for me to test the responses from slave only)
// function used in master
void readRegister(int address, int targetAddr)
{
Wire.beginTransmission(address);
Wire.write(0x50);
Wire.write(targetAddr);
Wire.endTransmission();
Wire.requestFrom(address, 3);
}
// main.cpp
int readAddr[11] = {
0x28,
0x2C,
0x30,
0x34,
0x38,
0x3C,
0x40,
0x44,
0x48,
0x4C,
0x50};
void setup() {
...
for(size_t i = 0; i < sizeof(readAddr) / sizeof(readAddr[0]); i++) {
readRegister(SLAVE_ADDR, readAddr[i]);
}
...
}
.
.
.
I then perform a test where the master is changed to an Arduino board. The new master basically just outputs the same requests (I copied the original master's signal from the oscilloscope). They are correct.
I'm pretty sure the original master (non Arduino) is able to receive multiple bytes. At this point, I'm not sure what's the culprit.




