Adafruit IO is a cloud service built for IoT solutions. It provides two interfaces: MQTT and REST API. It is very simple to use it with B4X as demonstrated in this example.
It is more than a MQTT broker. It also saves the historic values and allows integration with other services.
As this is a cloud service you can use it over the internet, which is very nice.
Each topic is mapped to a "feed". For this example we will be using two feeds:
The ping feed is required for the reconnect method.
In this example an ESP8266 is connected to a BMP180 temperature sensor and it sends the temperature to the temperature topic.
Other connected devices monitor the temperature:
And:
Tips
- The Arduino connects to the non-ssl port. Other platforms should connect to the ssl port.
- You need to update the username and password in the examples. The password is the AIO key.
- The payload should be a string. Raw bytes will not be sent properly. If you need to send more complex messages then you can use B4RSerializator and convert the bytes to a hex string (ByteConverter.HexFromBytes) and then back from a hex string to bytes.
- The B4A, B4i and B4J code is very similar. The main difference is that in B4A the communication is managed in the Starter service.
It is more than a MQTT broker. It also saves the historic values and allows integration with other services.
As this is a cloud service you can use it over the internet, which is very nice.
Each topic is mapped to a "feed". For this example we will be using two feeds:
The ping feed is required for the reconnect method.
In this example an ESP8266 is connected to a BMP180 temperature sensor and it sends the temperature to the temperature topic.
Other connected devices monitor the temperature:
And:
Tips
- The Arduino connects to the non-ssl port. Other platforms should connect to the ssl port.
- You need to update the username and password in the examples. The password is the AIO key.
- The payload should be a string. Raw bytes will not be sent properly. If you need to send more complex messages then you can use B4RSerializator and convert the bytes to a hex string (ByteConverter.HexFromBytes) and then back from a hex string to bytes.
- The B4A, B4i and B4J code is very similar. The main difference is that in B4A the communication is managed in the Starter service.
Attachments
Last edited: