📡 Connect to PADI via Wi-Fi. Sending data via MQTT

After analyzing the work with the most popular interface and PADI I / O ports, it is time to move on to the most complex and interesting - the integrated Wi-Fi wireless module.

After analyzing the work with the most popular interface and PADI I / O ports, it is time to move on to the most complex and interesting – the integrated Wi-Fi wireless module.

As already discussed in the comparison article, we have access to the network at 2.4 GHz of the 802.11 b / g / n standard, which is more than enough for projects for which the module is designed – and these are mainly smart home control devices.

In this article, we will introduce the MQTT protocol, find out how to use it with the RTL8710 from the Arduino environment, and learn how to send notifications to an Android device!

MQTT is a network protocol that uses TCP / IP for transport. It was first developed by IBM in 1999, but the peak of popularity came with cheap Wi-Fi modules ESP8266, on which it is used to communicate with smart home systems, sensors, or something else.

But RTL8710, as we know, is no worse, and only better than its predecessor, so the protocol is easily implemented on it.

All today’s examples will be downloaded from the Arduino IDE.

So, let’s deal with the basics of the protocol. The main device in the MQTT network — the server or broker — handles all client requests. Clients – any devices that connect to the broker.

Communication between customers occurs through the topics. Here, association with forum life is already being looked through – and so it is! Each client can subscribe to any topic, and then he will receive all messages sent by other customers to this topic.

Accordingly, everyone has the right to write on topics. In this case, the server can be presented as a remote forum, and the clients are ordinary users discussing a problem.

A broker can be raised on a home computer or a minicomputer – then you can make the system isolated from the outside world. In our example, we will use the remote free service CloudMQTT. With the registration on it and start!

We hope that everyone will be able to specify the e-mail, click on the button and confirm the registration, so we will go straight to creating a connection. Here is the Console page:

Click “Create”, enter the connection name, select the nearest server. The plan is Cute Cat (for free):

Once again press “Create”, and we’ll get to the main screen:


 For clients to work with a broker, you need to know a bunch of connection parameters. They can be recognized by clicking on the “Details” button:


 First, you need to create a user. CloudMQTT allows a specific user to prohibit or allow writing to a specific topic using processing rules. Create a user with the login test and the password test:

After that, let’s move on to editing the rules, let him read and write all the topics:

 Save – now we are ready to connect to the broker!

As clients, we will use Android-smartphone on the one hand and PADI on the other. The client software must be installed on the smartphone – we liked the Linear MQTT most of all – it allows you to organize the control interface without any difficulties and transferring large packages (as it is supposed in the IoT Manager). In PADI, the sketch from the examples will be sewn up, slightly modified for visual work.

Let’s start with the application settings. Download and install Linear MQTT, then go to App Settings and enter the data from the CloudMQTT service:


 To receive push notifications, you can tick this option and enter the path to the topic, when new information is entered into it.

Pay attention! The username and password must be entered by the ones you asked when creating the user.

Save the changes, and if everything is in order, the MQTT inscription circle turns green – there is a connection! If this is not the case, check all data for correctness!

To add control widgets, click on Pause, the Plus button will appear:

 Add the “Value” widget, specify the outTopic topic in the Subscription Topic:

Now, when receiving data from any client who writes something to the outTopic topic, the data will also be displayed on the screen. We turn to the settings PADI.

There are already ready examples for working with MQTT – AmebaMQTTClient-mqtt_basic. All we need is to correct the data to connect:

In lines 21 and 22, we write the Wi-Fi network name and password, respectively, in line 25 — the server address, in line 79 — we change the standard port 1883 to the port given by CloudMQTT (the very first, not SSL, not WebSockets), in line 49 add the name and password of the test user, as shown below:

 Now you can upload a sketch. Use a debugger to the PADI USB-UART and watch the process:


 The module successfully connected to the broker and sent the message “hello world” to the outTopic topic. If you configured the widget correctly, the data will appear on it:


Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on pinterest