IoT block reference
For more IoT details, see the following free online IoT service reference
Connect to an IoT server
This block connects to an IoT server. Enter the server address in the first field and the username and password in the second and third fields. If the service does not require credentials, enter a space in those fields.
Note 1: this connection runs in a web page and requires MQTT over WebSocket. If you use an external broker, check that it supports WebSocket connections.
Note 2: browser security prevents mixing encrypted and unencrypted connections in the simulator. Use wss:// when testing in the simulator.
Send message "__" to topic "__"
This block sends a message to a topic. For example, send a humidity message to the sprinkler topic.
When a message is received from "__"
When a message arrives on the specified topic, this block runs the program placed inside it. For example, after receiving a humidity-sensor message, start watering if the humidity is below 50.
Received message
When a message arrives on the specified topic, this block runs the program placed inside it. For example, after receiving a humidity-sensor message, start watering if the humidity is below 50.
Free online IoT service reference
What is MQTT?
MQTT is a messaging protocol based on the publish ∕ subscribe model. Think of a magazine publisher: it sends each issue through distributors or bookstores rather than directly to every reader.
A broker can store messages from publishers. Subscribers tell the broker which topics they want to receive. When a new message arrives, the broker forwards it to the subscribers for that topic. Because the broker relays the messages, the two clients do not need to know each other's IP address.
Available MQTT server resources include:
Name | Broker Address | TCP Port | TLS Port | WebSocket Port | WebSocket Port over TLS | WebSocket URI | Topic Prefix | Message Retention | Persistent Session | Sign Up Requred | Account / Password |
Eclipse | mqtt.eclipseprojects.io | 1883 | 8883 | 80 | 443 | /mqtt | -- | YES | YES | NO | -- |
Mosquitto | test.mosquitto.org | 1883 | 8883 | 8080 | 8081 | -- | YES | YES | NO | -- | |
EMQX | broker.emqx.io | 1883 | 8883 | 8083 | 8084 | /mqtt | -- | YES | YES | NO | -- |
HiveMQ | broker.mqttdashboard.com | 1883 | -- | 8000 | -- | /mqtt | -- | YES | YES | NO | -- |
adafruit | io.adafruit.com | 1883 | 8883 | -- | 443 | /{username}/feeds/{feeds_name} | -- | YES | YES | YES | User sign up |
Nuwa | public-mqtt.nuwarobotics.com | 1883 | 8883 | 80 | 443 | /mqtt | public | YES | YES | YES | public / testpublic |
MQTT topics
You can choose an MQTT topic name. For example, name a topic for humidity readings "humidity".
Topic names can be hierarchical. For example, a light sensor in a home kitchen could use the topic home/kitchen/light-sensor. Use English topic names in practice.
Free online IoT service
Follow these steps to try it:
1. Visit https://io.adafruit.com/ and sign up for a free account.
2. Select IO/Feeds/view all。
3. Select New Feed。
4. Enter the information, then click Create。
5. Click the Feeds。
6. Select Feed Info。
7. Note the MQTT by key。
8. Click IO/My Key。
9. Remember the IO_USERNAME and IO_KEY。
10. Enter the information obtained in the steps above: 1 =wss://io.adafruit.com 2= IO_USERNAME 3=IO_KEY 4/5=MQTT by key。
11. Send the program to the robot and test it.
When you touch the robot's head, an MQTT message makes it smile and say hello.
12. You can also see the sent messages under the corresponding aaaokk>Feeds>MQTT_TEST.
Further examples: https://io.adafruit.com/api/docs/mqtt.html?cpp#adafruit-io-mqtt-api