Processing Serial Carrier Sense


I am reading data from a serial bus using the Serial library.
On the bus there are many different hosts/clients. Currently I’m only listening but eventually I want to send my own messages in between others.
There is a specification about idle time between frames. Is there a way to detect when no message is send?
I imagine something like CSMA/CD.


Is this part working?

Not clear. Who is sending the messages and who will be sending messages in quite times? Correct me if I am wrong, but you are tapping into a “serial” bus? Like we are talking about serial communication, coms between devices or an actual serial bus in a card?

What are your cards specs and what protocol would you be using?


Hi Kf,

Yes, that part is working (now that I figured out my last mistakes it even works on multiple connections parallel).

It is actually a hob that is sending the messages (the cooking thing).

My program and other parts of the hob.

I am indeed. And I want to send messages to it.

I am connected to the hob via several FTDI connectors running custom protocolls.

Not sure how much I can tell you about that.

Ok so now that I answered all your questions I am glad to be able to present you my solution. I didn’t recognize this was possible at first since I only looked into the “SimpleRead” example:

void serialEvent(Serial thisPort) {
  if (serials.get(0).myPort == thisPort) {
    //println("Recieved somthing @ " + millis() + " from SERIALS[0]. Last contact was @ " + lastmillis);
    lastmillis = millis();

That piece of code is called whenever there is an event on the serial connection. And looking a the protocoll definition:


one can clearly see there is an idle time in between the acknowledge and the next frame. I figured out the timing of it and came up with this which is included in my main loop:

if (millis() - lastmillis >= 3) {
  println("here i can send data");

I hope this helps anyone who wants to do something similar since I didn’t find any tutorial for it.


1 Like