RS485 & Openmote B Board

Get the most out of your openmote with RS485 communication
February 17, 2022 by
RS485 & Openmote B Board
Boot & Work Corp. S.L., Fernandez Queralt Martinez


The main OpenMote-B board includes an expansion port (8 pins with 2.54 mm spacing) that can be used for debugging or to connect daughter boards like the OpenMote-B sensors board. The expansion board includes a VCC (2.5V) and a GND pin, as well as six configurable pins.

In this blog post, we are going to use three of these six configurable pins to connect an Openmote B board with an Arduino based PLC through RS485. 

Latest Posts

Your Dynamic Snippet will be displayed here... This message is displayed because you did not provided both a filter and a template to use.


  1. Arduino based PLC >>>

  2. Openmote B board >>>

  3. Wires 

  4. Max485 from TTL to RS485 converter

  5. Power supply >>>

  6. B type cable to program the Arduino based PLC

1. How to connect the openmote B board to a MAX485 converter

First of all, we are going to connect the wires as shown in the picture below.

 Note that the antennas and batteries are not needed in the openmote. Also, power your Arduino based PLC.

Connection of the wires - RS485 & Openmote B Board

2. Arduino code

Then, we will need to have the Arduino IDE installed in our computer, and also the Industrial Shields boards for programming our Arduino based PLC.

1- Open the Arduino IDE.

2- Go to the Menu > Tools > Board > Select your Industrial Shields Board.

3- Go to the Menu > Tools > Model > Select your Industrial Shields Board model.

4- Go to the Menu > Tools > Port > And select the one that you are connecting your PLC to.

5- Finally, paste the code below and Upload the sketch to the Arduino board.

   Copyright (c) 2017 Boot&Work Corp., S.L. All rights reserved
   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   GNU Lesser General Public License for more details.
   You should have received a copy of the GNU Lesser General Public License
   along with this program.  If not, see <>.

#if defined(HAVE_RS485)
#include <RS485.h>
#define RS485 Serial2
#define RATE          9600UL
#define PERIOD        1000
#define DUPLEX        HALFDUPLEX
#define LEDS_ENABLED  0
#define SEND_LN       0
#define LED_BLINK     20
#define TX_LED        Q0_0
#define RX_LED        Q0_1
unsigned long lastSent = 0;
unsigned long txPinStart = 0;
unsigned long rxPinStart = 0;
void setup() {
  Serial.println("rs485-periodic-sender started");
  pinMode(TX_LED, OUTPUT);
  pinMode(RX_LED, OUTPUT);
  RS485.begin(RATE, DUPLEX);
void loop() {
  if (millis() - lastSent > PERIOD) {
void updateLeds() {
  updateLed(TX_LED, txPinStart);
  updateLed(RX_LED, rxPinStart);
void updateLed(int pin, unsigned long startTime) {
  if (millis() - startTime > LED_BLINK) {
    digitalWrite(pin, LOW);
void tx() {
  static uint8_t counter = 0;
  RS485.write(counter + '0');
  lastSent = millis();
  digitalWrite(TX_LED, HIGH);
  txPinStart = millis();
  Serial.print("TX: ");
  Serial.println(counter, HEX);
  counter = (counter + 1) % 10;

void rx() {
  if (RS485.available()) {
    byte in =;

    digitalWrite(RX_LED, HIGH);
    rxPinStart = millis();

    Serial.print("RX: ");
    Serial.println(in, HEX);

If you open the Serial monitor, you will see what you are sending: a counter from 0 to 9.

3. Openmote B code

a. First of all, visit this blog post and go to the second point called: 2. HOW TO DOWNLOAD OPENMOTE B FILES

b. Once listed, we will need to install docker-compose. Please, install it from here >>>

c. Then, inside the test folder, there is the folder called test-rs485-rx, which will be the project that we are going to execute.

So, from the openmote-fw/ folder, we will run the following command:

docker-compose run --rm openmote test-rs485-rx

d. Finally, install the screen if you do not have it:

sudo apt update
sudo apt install screen

And check how you receive the counter from 0 to 9 that we are sending through our Arduino based PLC:

screen /dev/ttyUSB1 115200

counter from 0 to 9 - RS485 & Openmote B Board

Press Ctrl+a and \ to exit screen.

 Make sure that the uart0 baud rate from the openmote code is the same as the baud rate of the screen running command. And that the uart1 baud rate from the openmote code is the same as the RS485 baud rate from the Arduino code.

​Search in our Blog

RS485 & Openmote B Board
Boot & Work Corp. S.L., Fernandez Queralt Martinez February 17, 2022
Share this post

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.

Industrial PLC comparison >>>