2. Arduino - banica/metering GitHub Wiki

2.1. Arduino initial setup

We start off by using the Arduino IDE setup. Follow the instructions from the respective links of each app: Arduino IDE: https://support.arduino.cc/hc/en-us/articles/360019833020-Download-and-install-Arduino-IDE You can also find out more information about the Bitmi house on its respective website: https://www.bitmi.ro/kituri-electronice/kit-arduino-smart-home-10154.html

Download the compressed files using the download button in the top right corner: https://banica.app.box.com/v/MachetaSmartHome Unzip the compressed “2025 Smart Home Bitmi.zip” file, afterwards extract the rar file “ArduinoSHS Tema 2024” and upload the libraries found into Arduino IDE as follows: Open ArduinoSHS Tema 2024 > ArduinoSHS > ArduinoSHS.ino This will open the Arduino project. Also install the following libraries: DHT.h: https://docs.arduino.cc/libraries/dht-sensor-library/#Releases ModbusRTUSlave.h: https://docs.arduino.cc/libraries/modbusrtuslave/#Releases

Now include all of the libraries you have installed as follows: Inside of the Arduino IDE application go to “Sketch > Include library > Add .ZIP Library…” and include all of the libraries from their respective locations

Arduino Libraries

To connect Arduino to Ignition Scada we needed some specific components:

  • Arduino UNO R3
  • Shield V5 (not 100% necessary but we already had it from the Bitmi House)
  • MAX485 (to create a stable Modbus connection)
  • RS485 to USB adapter These components will be connected to Ignition via Modbus RTU, following these steps:
  1. Connect components and sensors:

Table wiring

WARNING! _DE & RE must be on one of the digital pins, but not on D0 and D1, and they should be on the same pin

Wiring

2.2. Arduino code

The last code attempt on Arduino (it still did not output the values through the Modbus connection):

Arduino Code

2.3 Errors encountered

The error we encountered with the code presented above was “CHECKSUM ERROR”, we tested the program with the PowerHud Modbus Tester application (its purpose is to test slave devices) After trying to design a simpler code that would just test out the connection we ran into the “TIMEOUT” error, we are not certain what the problems with our code are. Here is the simplest code we managed to make to just test the Modbus connection:

Code sample

2.4. Why we wanted to move on from Arduino, but didn’t

The lack of proper documentation of the ModbusRTUSlave library is the main reason why we abandoned trying to use the Arduino board and Modbus connection. Also, another reason was the fact that our main goal was to eventually use PLCs, so we figured the best way to learn that was by using entry-level PLCs instead of something that does not really have any industrial function like Arduino.

Eventually we did find a really good arduino library that had everything we needed listed on its github page: https://github.com/smarmengol/Modbus-Master-Slave-for-Arduino/tree/master

This is the code we went for, that would have worked if we did not encounter other issues with the PLC setup. (tested on Modbus tester and it works perfectly fine for our use case):

Final Code