Components and supplies

About this project

This project based on our ArduiTouch kit for Arduino MKR. You can combine any Arduino MKR board and an optional shield with a wall mounting enclosure and a coloured TFT touchscreen. In our example we will use it to create a nice looking MODBUS thermostat.

Assembly

In the first step you have to assemble the PCB of the ArduiTouch MKR kit. In the video above you can see the assembled PCB, the enclosure and how to plug the Arduino MKR1010 and the Arduino MKR 485 shield into the slots of the ArduiTouch PCB.

Assembled ArduiTouch MKR PCB

ArduiTouch PCB backside with plugged MKR modules

Configuration of MKR 485 shield

You will find a 3pole DIP switch in front of the MKR 485 shield. Please set the DIP switches to following positions:

DIP switch configuration

Connection to RS485 bus

We will use the half duplex mode of the RS485. Please note: you have to connect A and B line of the RS485 bus to the Y and Z terminal of the MKR 485 shield:

You can also download the library also directly as ZIP file and uncompress the folder under yourarduinosketchfolder/libraries/

After installing the Adafruit libraries, restart the Arduino IDE.

Run the demo

Please open this sample in the Arduino IDE. Compile and upload it.

After compilation and upload you will see the main screen with default values for room temperature, set temperature and ventilation. You can change the set temperature and ventilation level without RS485 connection also.

You can open via the gear in the upper right corner an option menu. Thismenu includes a function to adjust the Modbus ID number and a screen cleaning function.

Modbus test

We will use in this example the PC as MODBUS master. You've to download Modbustester. Please unpack the zip archive to a new directory on your harddisk.Open the software and change the marked fields as in the picture above. You have to connect the USB-RS485-adaptor before. For simple tests a serial connection via USB cable between your PC andthe NodeMCU will also work. Please choose the right COM-port for this adaptor in Modbustester.

You can press the Read button in Modbustester. This command will read 6 bytes of the memory of our new slave device the ArduiTouch. You can click also in the fields beside the addresses and manipulate the values. With the write button you will send this manipulated values to the ArduiTouch. Please see the table below about the register function.