Android Question Do I need the adafruit libraries to use adafruit.io.

Lee Ingram

Member
Licensed User
Longtime User
I have an adafruit.io account and a cloudmqtt account. The connect parameters are different. I'm not sure how to connect to adafruit.io

Thank you, Lee
 

Lee Ingram

Member
Licensed User
Longtime User
adafruit.io is adafruit's MQTT broker.

https://io.adafruit.com

I been able to successfully connect to clouldMQTT but I have not been able to connect successfully to adafruit.io.
With B4J I can connect but I am not been able to publish or subscribe. Adafruit has a nice platform for debugging and testing topics and payloads.
Thank you,Lee

I have also been able to connect using Arduino IDE, but not using B4R.
I really want to just use B4X products
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm able to connect with this code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
     mqtt.Initialize("mqtt", "tcp://io.adafruit.com:1883", "b4a")
     Dim mo As MqttConnectOptions
     mo.Initialize("user", "ccccccccccccccc840e")
     mqtt.Connect
   End If
End Sub

Sub MQTT_Connected (Success As Boolean)
   Log(Success) 
End Sub
 
Upvote 0

Lee Ingram

Member
Licensed User
Longtime User
Thank you for the helped. Adafruit.io is pretty awesome, and so is B4X.
It was a bit tricky to publish/subscribe. The below code was very helpful to my success.
Thank you for the snip-it also.
Shalom, Lee

B4X:
Dim s As String = "abcde"
Dim bytes() As Byte = s.GetBytes("UTF8")
'and back
s = BytesToString(bytes, 0, bytes.Length, "UTF8")
 
Upvote 0
Top