S
S
slickstars2015-10-01 16:27:53
Arduino
slickstars, 2015-10-01 16:27:53

How to send message from openHab to Arduino serial COM port?

Hello everyone, I have such a question, I use the openhab.serial.binding addon to receive information from the Arduino serial COM port, it works for me, but to send a message to the Arduino and read it, it doesn’t work.
I tried different methods and examples that I found for this, maybe openHab is not sending messages correctly? Has anyone experienced this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
slickstars, 2015-10-02
@slickstars

Issue resolved! Here's what I did:
1. Changed the encoding of the link
2. Used this code to read lines from the serial COM port:

String readString;
  
  void setup() {
    Serial.begin(9600);
    Serial.println("serial test 0021"); // so I can keep track of what is loaded
  }
       

  void loop() {
    while(Serial.available()) {
      delay(10);  
      char c = (char)Serial.read();
      readString += c;
    }
       
     if (readString.length() > 0) {
       Serial.println(readString);
       readString="";
     }
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question