Arduino Findernet Opta All In One Industrial IoT gateway
Arduino library for the Arduino Opta series https://opta.findernet.com/fr/arduino
The goal of this library is to implement an easy to use MQTT/Modbus gateway and more for industrial equipments.
Web page and config are inspired by "Remoto" (27-12-2024) by Alberto Perro under CERN-OHL-P license at https://github.com/albydnc/remoto
- Support Opta RS485 AFX00001, Opta Wifi AFX00002, Opta Lite AFX00003
- Support for digital expansion board Arduino Pro Opta Ext D16O8E AFX0000 and Arduino Pro Opta Ext D16O8S AFX00006
- Support OTA firmware update (wifi and ethernet)
- Partition formating (first boot or on demand) with Wifi firmware update
- Configurable Ethernet with DHCP or static IP
- Configurable Wifi STA or AP and with DHCP or static IP
- Configurable bidirectionnal MQTT Client with password support
- Configurable Modbus RTU or TCP, Client or Server
- Abstract inputs and ouputs structure to expose many informations
- Inputs and outputs counter and timer
- RS485 helpers
- Serial monitor and commands
- Password protected Web server for visualization and configuration
- Persistent configuration storage in flash memory
- Watchdog
- Multithreading loop
- Lots of simple methods to deal with inputs/outputs/storage...
- Fast MQTT publishing of input change state
- ...
- Support for analog expansions boards
- Code documentation
- More examples
- Bootloader check
As this library is for industrial usage, expansion numbering and input numbering and output numbering start at 0, not 1 as printed on Opta device. This means that the first input of the opta board is named as I0.0 in industry.
- For now, only digital expansions are supported.
- Just plug in expansion and reboot Opta, Inputs and Ouputs are automatically added.
- First expansion has number 1, second has 2, ... the main board (The Opta device) has number 0.
Wifi AP mode
If Wifi SSID is not configured and Wifi is set as prefered network, the Wifi goes into Access Point mode.
Default SSID is optalinker + device ID and password is optalinker.
Wifi STA mode
If Wifi SSID and password are configured and Wifi is set as prefered network, the wifi goes into Standard mode.
Ethernet mode
If Ethernet is set as prefered network, wifi is disbaled.
DHCP
If DHCP mode is enabled in configuration, connection is tried to be established with dynamic IP,
else configured static IP address is used. By default static IP is 192.168.1.231.
Network settings are configured in setup process and can not be changed without a device reboot.
This library display activity on serial port and also support several commands.
These commands are not case sensitive.
print version: Send to serial monitor the OptaLinker library versionprint config: Send to serial monitor the contents of device configuration backup fileprint io: Send to serial monitor the contents of io backup fileprint store: Send to serial monitor the list of flash memory stored fileprint boot: Send to serial the number of time device rebootprint loop: Send to serial monitor the number of loops per secondprint ip: Send to serial monitor the device IPv4 addressswitch dhcp: Switch ethernet DHCP mode in configurationswitch wifi: Switch Wifi/Ethernet mode in configurationprint time: Send to serial monitor the device timeupdate time: Query NTP server to update device local timeflash memory: Create/format partitions and rebootreset config: Reset to default device configuration and rebootreset io: Rest IO values to default and rebootpublish mqtt: Publish to MQTT device informations and IO statesreboot: Reboot device
You should do a REBOOT after SWITCH DHCP, SWITCH WIFI actions to take effect.
This library has MQTT client that supports MQTT 3.3.1 and broker with password credentials.
MQTT broker IP, port, user, password, topic, delay can be configured through web server interface (recommanded) or define.h file.
Publishing inputs statistics topics:
<base_topic>/<device_id>/input/x/stateThe digital state of the input<base_topic>/<device_id>/input/x/voltageThe voltage of the input<base_topic>/<device_id>/input/x/pulseThe total number of pulse of the input<base_topic>/<device_id>/input/x/partialPulseThe partial number of pulse of the input (resetable)<base_topic>/<device_id>/input/x/highThe total time (ms) of high level of the input<base_topic>/<device_id>/input/x/partialHighThe partial time (ms) of high level of the input (resetable)
Publishing outputs statistics topics:
<base_topic>/<device_id>/output/x/stateThe digital state of the output<base_topic>/<device_id>/output/x/voltageThe voltage of the output (not implemented)<base_topic>/<device_id>/output/x/pulseThe total number of pulse of the output<base_topic>/<device_id>/output/x/partialPulseThe partial number of pulse of the output (resetable)<base_topic>/<device_id>/output/x/highThe total time (ms) of high level of the output<base_topic>/<device_id>/output/x/partialHighThe partial time (ms) of high level of the output (resetable)
Publishing device informations topics:
<base_topic>/<device_id>/device/typeThe human readable device type (Opta Lite...)<base_topic>/<device_id>/device/ipThe device IPv4 address<base_topic>/<device_id>/device/revisionThe device OptaLinker library version<base_topic>/<device_id>/rs485The RS485 received values
Command output state and device counters and device information topics:
<base_topic>/<device_id>/input/x/resetTo reset partial counters for an input (value doesn't matter)<base_topic>/<device_id>/output/x/resetTo reset partial counters for an ouput (value doesn't matter)<base_topic>/<device_id>/output/x/setTo set state of an output with0= OFF,1= ON<base_topic>/<device_id>/device/getto force device information publishing (value doesn't matter)<base_topic>/firmware/versionTo alert board about a firmware update version
In notation, x mean Input or Output uniq ID, it is made of "Expansion number" and "Input Number" starting at 0 for main board.
For example to set the output O1.3 of the device 98 (device 98, expansion 1, Output 3, the ouput print as 4 on the device) to 1 : opta/98/output/103/set = 1.
Input state can also be published on demand by sending an HTTP request to the /publish URL.
This library support one of these modbus types at a time:
- Modbus TCP server (Ethernet or Wifi)
- Modbus TCP client (Ethernet or Wifi)
- Modbus RTU server (Rs485)
- Modbus RTU client (Rs485)
To use modbus RTU (client or server), RS485 must be disabled in configuration.
See dedicated Modbus document
This library OTA update feature is not written to work with ArduinoIotCould plateforme but it may work with...
OTA file
To learn more about OTA and on how to create .ota file, see official documentation at https://docs.arduino.cc/tutorials/portenta-h7/over-the-air-update/
The OptaLinker library contains python tools to create OTA file. Available in "extra" directory. (There is also a compiled dll version for Windows 11) There is also some .ota files from example .ino sketch to test OTA update.
OTA workflow
On web server device configuration page, there is a field named "Firmware file URL", you must fill in with the URL of your firmware .ota file.
OptaLinker library listen on MQTT topic <base topic>/firmware/version for latest available version.
It is also possible to announce new firmware through modbus Holding Registers. (see modbus documentation)
Every hour, device check if a newer firmware version are available and if so, launch OTA update process.
In background, the firmware is downloaded and uncompressed, the bootloader is edited and if all is OK, device reboot and install new Firmware.
Important note
The update is processed in background and may take up to 10 minutes, during process the board is still active and works normally except the Web server is offline. (as both Web server and OTA process use same HTTP client.)
This library provides a web interface for visualization and configuration through a web server with basic authentication. Web server is available in both Ethernet and Wifi mode.
- Default static IP address for web server is
192.168.1.231 - Default user and password for web interface are
admin:adminand can be changed in configuration.
Available web server entrypoints are:
GET /: HTML IO visualization pagePOST /form: send new json data to this URL to udpate configurationGET /config: json device configuration dataGET /data: json device information dataGET /io: json device IO dataGET /device: HTML device configration pageGET /favicon.ico: Icon for HTML pagesGET /publish: Publish to MQTT device and inputs state
Note: All pages require basic authentication !
During boot:
- Fast blink Green : Waiting for user to press button to fully reset device
- Fast blink Green to Red : Device is going to reboot
- Fix Green and red : Device is doning a long task (connection...)
After boot:
- Fix Green and Red with no blue : Connecting networks (this freeze device)
- Fast blink Green to Red : Device is going to reboot
- Fast short blink Green and Red : heartbeat
- Slow blink Red : No network connection
- Slow blink Green : No MQTT connection (network connection is OK)
- Fix Green : MQTT connection OK
Wifi device:
- Fix Blue : Wifi in STA mode
- Slow blink Blue : Wifi in AP mode
- No Blue : Not in Wifi mode
Button pushed duration make different actions :
During boot:
- +5s : On fast blink green LED, user can reset device to default by pressing button more than 5 seconds
After boot:
- +5s : User can reset device to default by pressing button more than 5 seconds
- +1s : Without network, user can switch WIFI mode by pressing button more then 1 second
- -1s : Without network, user can change DHCP mode by pressing button less than 1 second
- -1s : With network and MQTT connection, user can force publishing input state to MQTT by pressing button less than 1 second
Note that actions take effect on button release. WIFI and DHCP actions reboot device.
A watchog is present. If device does not respond until 30s, the device reboot. (Maximum timeout of Opta board is 32270 milliseconds and cannot be stop.)
There is a bug on USB, there is no way to detect if cable is disconnected. And on cable disconnetion, board reboot after about 10 seconds.
For Arduino Finder Opta on its M7 core.
From Arduino IDE menu: Tools > Boards > Boards Manager, you must install:
Arduino Mbed OS Opta Boardsby Arduino
From Arduino IDE menu: Tools > Manage libraries, you must install:
ArduinoHttpClientby Arduino at https://github.com/arduino-libraries/ArduinoHttpClientArduinoMqttClientby Arduino at https://github.com/arduino-libraries/ArduinoMqttClientArduinojsonby Benoit Blanchon at https://github.com/bblanchon/ArduinoJson.gitArduinoRS485by Arduino at https://github.com/arduino-libraries/ArduinoRS485ArduinoModbusby Arduino at https://docs.arduino.cc/libraries/arduinomodbus/Arduino_KVStoreby arduino at https://github.com/arduino-libraries/Arduino_KVStoreArduino_Opta_Blueprintby Daniele Aimo at https://github.com/arduino-libraries/Arduino_Opta_BlueprintArduino_Portenta_OTAby Arduino at https://github.com/arduino-libraries/Arduino_Portenta_OTANTPClientby Fabrice Weinberg at https://github.com/arduino-libraries/NTPClient
- Tools > Boards > Arduino Mbed OS Opta Boards > Opta
- Tools > Security > None
- Tools > Flash split > 2Mb M7
- Tools > Target core > Main Core
- Copy folder
OptaLinkerto your Arduino IDElibrariesfolder, - Restart your Arduino IDE
- Select your Opta board and port
- In menu go to: file > Examples > Examples from Custom Libraries > Opta Linker and select an example.
- Upload sketch to your Opta board. Enjoy.
To use OptaLinker in your sketch, see example OptaLinkerSimple.ino
Note: In your .ino loop() function, do not forget to add yield(); function to its end or your loop will become very slow.
- Alberto Perro (remoto author)
- Jean-Christian Paul Denis (OptaLinker author)
You are welcome to contribute to this code.
CERN-OHL-P-2.0 license