Hi guys
I'm trying to use an arduino board to intercept a asynchronous communication between 2 circuit boards, record it, analyze what each data do to each other and in future replace 1 of the circuit board with an arduino. With hopes of the arduino to send exact same data to the remaining board.
I have posted a similar topic a while back, but with 0 knowledge of how things work and 0 tools and data of the circuit boards. So I didn't even know the baudrate of the boards!!
I'm back with more tools and data to help tackle this project!!
But my lack of knowledge (maybe intelligence) of programming is holding me back and need help from you guys.
The project goal is to semi-reverse engineer a coffee machine.
The coffee machine has 2 circuit boards. 1 being the micro controller to control all motors and valves, another 1 being the brain, storing menu settings, having screens for UI, button interaction,etc. The 2 boards are connected with 4 wires ( +V, GND, Tx and RX)
I am assuming that when someone selects a menu, the brain board sends some kind of commands to the controller board to turn motor for certain seconds, and open the valve for certain seconds,etc.
But I am not happy with how the manufacturer have set limitations to the machine and would like to change that by reverse engineering and give my self more options.
So my goal in this projects are:
- Sniff asynchronous data between 2 circuit boards using arduinoMega2560.
- Analyze what each data does to either side of the boards.
- Then, remove the 'brain' board with my arduino to receive and send exact same async data
to the controller to give me more freedom.
At the moment, I have a logic analyzer which is giving me tons of previously unknown info.
Attached photo shows async data being transmitted back and forth when the machine is idle.
It seems to be that if the 'brain' or main board sends some data (66 and 189) to the controller board, the controller board acknowledges with data signal of 136 (integer).
I have successfully mimicked the main board data using arduino and received a ack data back from the controller board. I have made a external circuit to invert the arduino Tx's signal.
Using this code:
int num1 = 66;
int num2 = 189;
void setup()
{
Serial.begin(9600, SERIAL_8E2);
}
void loop()
{
Serial.write(num1);
delayMicroseconds(1950);
Serial.write(num2);
delay(50);
}
Up till now, I feel very proud that I have something!
But this is where problem began.
I was assuming the controller board only sends ack data back to the main board. But it sometimes sends a series of data which I assume the main board listens to it and act differently.
So I needed to read serial data from the controller board, but I am stuck.
What I am trying to accomplish is:
Controller board will send 136 as integer (decimal)
Then with code like below from main board,
if Serial.available():
{
dataFromController = Serial.read();
}
Serial.printOrWrite(dataFromController)
Then program must output 136 as integer or decimal
so i can:
if dataFromController == 136:
{
send some data back to controller;
}
I have wrote similar code as above with proper syntax but its giving me
infinite lines of '111' and sometimes 0 and 64 on the serial monitor.
I googled 'how to arduino uart commincation send and recieve',etc but wasn't able to find the exact answer to solve this problem.
Any input to solve this problem will be greatly appreciated!