aster94:
seems that the delay of 10ms between two bytes is not needed#define debug Serial
#define bike Serial1
#define TX_PIN 18
byte message0[] = {0xFE, 0x04, 0xFF, 0xFF};
byte message1[] = {0x72, 0x05, 0x00, 0xF0, 0x99};
void setup()
{
debug.begin(115200);
}
void loop()
{
char incomingCommand = 0;
while (debug.available() > 0)
{
incomingCommand = debug.read();
debug.print("\nCommand: ");
debug.println(incomingCommand);
}
if (incomingCommand == 'S')
{
initHonda();
}
checkResponse();
}
void checkResponse()
{
while (bike.available() > 0)
{
byte incomingByte = bike.read();
debug.print(incomingByte, HEX);
debug.print(' ');
}
}
void initHonda()
{
debug.println("Starting sequence");
bike.end();
pinMode(TX_PIN, OUTPUT);
digitalWrite(TX_PIN, LOW);
delay(70);
digitalWrite(TX_PIN, HIGH);
delay(120);
bike.begin(10400);
sendRequest(message0, sizeof(message0));
// No response is expected
// wait 25ms and avoid echo
debug.print("Echo: ");
uint32_t start_time = millis();
while (start_time + 25 > millis())
{
checkResponse();
}
sendRequest(message1, sizeof(message1));
// respond: 02 04 00 FA
debug.println("\nWaiting response");
}
void sendRequest(uint8_t request[], uint8_t len)
{
for (uint8_t i = 0; i < len; i++)
{
bike.write(request[i]);
}
bike.flush(); // wait to send all
}
if this doesn't work the problem is in the wiring, please could you post some pictures and a schematics?
No Luck. I got the same response as before:
09:11:34.417 -> Command: S
09:11:34.417 ->
09:11:34.417 -> Starting sequence
09:11:34.619 -> Echo: F8 0 FF
09:11:34.653 -> Waiting response
09:11:34.653 -> 0 0
Here's an album with pictures:
Let me know if I can clarify anything with more pics.