MQTT to EV3
The following application was created by a project with the purpose to connect MQTT parts with EV3 device.
The goal was to implement an application that is capable of transforming incoming MQTT topics or JSON strings over HTTP to a format that is compliant with EV3 device.
Basic information about the application and key features
The MQTT to EV3 application is based on a spring boot java microservice architecture. Therefore, one of the key features of the application is the low consumption of resources, as the framework allows for the efficient distribution and usage of resources in general.
One of the features is the configuration file with the options to control and customize the EV3 components.
Lastly, the application also supports a customize command.
Architecture and functional principles of the MQTT to Bluetooth
Preconditons
Before starting the application, you must ensure that the MQTT server and the corresponding EV3 device are running.
The current version does not have an interface that performs checks such as the above-mentioned prerequisites, as in a general operation both servers must be active.
In case these preconditions are not met, the application will throw multiple errors and will eventually crash.
Functional principles
At first, a JSON string is being sent via MQTT (HTTP is possible as well). This string is being directed into the MQTT to EV3 application, where the string is then being transformed into a EV3 device compliant format, which is predefined.
Version Informations
The application is currently stable and the actual status is stable (Version 1.0.1).
Version | Status | Change Description |
0.9.1 | Beta | |
1.0.1 | Stable |
Installation
Configuration File
The following table explains you, the individual functions of the configuration file.
File Option | Example | Meaning |
General Config | ||
CONVERTER_MODE | 0 | MQTT mode (Application works only with valid MQTT JSON commands) |
1 | HTTP mode [URL: localhost:8080/HTTPToBluetoothConverterApi?jsonMessage:{}] (Application works only with valid HTTP JSON commands) | |
2 | MQTT and HTTP mode [URL: localhost:8080/HTTPToBluetoothConverterApi?jsonMessage:{}] (Application works with valid HTTP JSON and MQTT JSON commands) | |
MQTT_HTTP_APACHE_KAFKA_STREAM_LOGGER_MODE | 0 | No logging (No logging of the input and output stream) |
1 | HTTP/MQTT stream logging (O | |
2 | Kafka stream logging (O | |
3 | HTTP/MQTT and Kafka stream logging (Logging of the input and output stream) | |
MQTT_HTTP_APACHE_KAFKA_LOGGER_PATH | Path/Micro_Services/MqttAndHttpApacheKafkaConverterLog.log | Define the log path and file |
MQTT/ HTTP Config | ||
MQTT_BROKER_HOST | tcp://MQTT_Broker_Hostname:MQTT_Broker_Port | Define the MQTT Broker Hostname or IP and the Port (Default: 1883) |
MQTT_CLIENT_ID | MQTTToApacheKafkaStreamClient | Define the MQTT client ID |
MQTT_RECEPTION_TOPIC_NAME | MQTT/Topic | Define the reception MQTT T |
MQTT/Topic;MQTT/Topic | Define the reception MQTT T | |
MQTT_SEND_TOPIC_NAME | MQTT/Topic | Define the send MQTT Topic |
MQTT/Topic;MQTT/Topic | Define the send MQTT Topics separated with ‘;’ | |
LAST_WILL_TESTAMENT_TOPIC_NAME | MQTT/Topic | Define the Last Will and Testament T |
LAST_WILL_TESTAMENT_QOS | 2 | Define the Last Will and Testament QOS |
LAST_WILL_TESTAMENT_MESSAGE | The device is currently not available. | Define the Last Will and Testament message |
Bluetooth Config | ||
BLUETOOTH_IP_ADDRESS | 10.0.1.1 | Define the Bluetooth IP address |
BLUETOOTH_SOCKET | 5000 | Define the Bluetooth socket |
BLUETOOTH_RECEPTION_SOCKET | 5000 | Define the Bluetooth reception socket |
MQTT_STREAM_DEVICEID | test | Define the Bluetooth stream DeviceID |
Requirements
- The application was developed for Java 9 and may also run under higher Java versions.
Establishment
- Download the correct file for your Operating System.
- Unpack the file and copy the Jar and configuration folder & file to your local Operating System.
- Adjust your favorite user and set the correct rights at the Jar file (
sudo chown user:user Path/MQTT_To_EV3.jar &sudo chmod 755 Path/MQTT_To_EV3.jar) - Optional by Linux and MAC OS X Systems: Copy, implement and customize the Service Script.
- Download and copy the Script from here.
- Place the Script inside your /etc/init.d directory.
- Set the correct rights to your Script (
sudo chmod 755 /etc/init.d/mqtt-to-ev3). - Set the correct owner to your Script (sudo chown root:root /etc/init.d/mqtt-to-ev3).
- Customize the path inside the Script (sudo nano /etc/init.d/mqtt-to-ev3).
- Activate the Script and implement it your system start process with (
sudo systemctl enablemqtt -to-ev3).
- Start the Service Script (
sudo servicemqtt -to-ev3 start) to run the application. - Or start the MQTT_To_EV3 Jar file (/usr/bin/java -jar Path/MQTT_To_EV3.jar &) to run the application.
Download
Donations
If you want you can support my work. The corresponding PayPal link will follow shortly.
License Agreement
You can find the license agreement here.
Support
Please, contact me if you find a bug or you need help!