Asynchronous Communication Sniffer

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:

  1. Sniff asynchronous data between 2 circuit boards using arduinoMega2560.
  2. Analyze what each data does to either side of the boards.
  3. 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! :slight_smile:

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!

If you think you are seeing signal from one serial line, then you need an Arduino with more than one serial port. Then you can connect the second serial port as you have the first one and see what both are sending. Maybe alternately or may be simultaneously.

Paul

Hi Paul
Thanks for such quick reply.

I have an arduinoMega2560 which has several serial ports so I will try by setting up the 'read' with a separate serial port.

However, I think the reason I am getting funny values with Serial.read() is due to poor programming.
Maybe I am not differentiating between int,char,etc or just simply not understand how serial data is being read from a device.
Could you perhaps assist with programming correctly?

imbatronics:
I'm trying to use an arduino board to intercept a asynchronous communication between 2 circuit boards,

Does this mean that you have two boards happily talking to each other and you want to monitor the conversation?

If so, connect the Tx from each board to two separate HardwareSerial Rx pins on the Mega (plus a GND connection) and you should be able to print the byte values that are passing between the boards. I suggest you print the data on the Serial Monitor in different columns so you can easily see which board the data comes from.

...R

Hi Robin
I really appreciate your help for this and last posts.

They coffee machine boards are indeed happily talking to each other and functions well on its own.
I have linked it up to the Rx pins on arduino, however

you should be able to print the byte values

is where you are wrong. Because I'm clueless when it comes to arduino :sob: and don't know how to Serial.read which may be a simple task.

When I read as Serial.read and open serial monitor, it gives me values I can't really understand.
I does show a specific pattern, like it continuously shows '111' and one '0' and one '63' then continuously shows '111' again.
I would like it to show either '0' as decimal or 0b00000000 in that format.
What am I doing wrong?

"When I read as Serial.read and open serial monitor, it gives me values I can't really understand."

Have you actually determined the communication type/protocol that is being used between the two components? Is it rs232, CAN bus, IC2, or whatever? Just getting back to basics.

As far as I am aware, its asynchronous serial communication?

So it has no dedicated clock signal, other than baudrate of 9600.
It only has Rx and Tx from both devices and +V and GND.

imbatronics:
What am I doing wrong?

First thing is that you have not posted the latest version of your program - please post it in your next Reply.

...R

int data1 ;
void setup() 
{
Serial.begin(9600, SERIAL_8E2);
}
void loop() 
{
if (Serial.available())
{
  data1 = Serial.read();
  Serial.println(data1);
}  
}

It is really a simple googled code :frowning:

imbatronics:
As far as I am aware, its asynchronous serial communication?

So it has no dedicated clock signal, other than baudrate of 9600.
It only has Rx and Tx from both devices and +V and GND.

Are Rx and Tx printed on a circuit board somewhere? Just wondering how you arrived at that conclusion.

Yes, the Tx and Rx is printed on the circuit board on both side.
So on one board, it is Tx and Rx, and on other board, it is Rx and Tx.
So Tx goes to Rx, Rx goes to Tx on another board.

Looking at your initial post with the logic analyser screen captures it looks like the serial logic is inverted. To get meaningful results you may need to invert the signal your reading to make it compatible with the Arduino serial interface.

imbatronics:
It is really a simple googled code :frowning:

That program is not suitable.

You need to connect each of the two devices you want to monitor to Rx1 and Rx2 on the Mega and read the data from Serial1 and from Serial2 and then display in the Serial Monitor with Serial.print().

Serial is connected to pins 0 and 1 and to the USB connection. Serial1 is connected to pins 19 and 18 and Serial2 is connected to pins 17 and 16.

PLUS, perhaps, what @Riva has said in Reply #11

...R