Android Question Cannot send string sensor limit value

Cesar_Morisco

Active Member
Hey, guys
All very well.
Unable to send data to sensor boundary using Mqtt
could someone tell me how to do this or an example
I thank
NumberDialog:
Private Sub Button9_Click
    numdial.Number=1
    numdial.Digits=2
    numdial.Number=25
    numdial.ShowSign=False
        If numdial.Show("Limit de Temperature (°C) Max:","OK","Cancel","",Null)=DialogResponse.POSITIVE Then
        If numdial.Number > = 18 And numdial.Number < = 40 Then
        Dim Temp_Set As String
        Temp_Set = numdial.Number
                MQTT.Publish("Temp_Set" & Temp_Set,BC.StringToBytes(True,"UTF8"))' didn't give
                MQTT.Publish("Temp_Set" + Temp_Set,BC.StringToBytes(True,"UTF8"))' didn't give
                'HELP ME
        Else
                xui.MsgboxAsync("You Can Program Sensor Limit Just Between -18°C + 40°C!","Error")
        End If
    End If

End Sub

B4R:
If NumberFormat(celsius,0,0) = Temp_Set Then
        PinGPIO14.DigitalWrite(True)
    Else
        PinGPIO14.DigitalWrite(False)
    End If
 

Brian Dean

Well-Known Member
Licensed User
Longtime User
I don't know anything about MQTT, but I can see that both of these statements are totally wrong ...

B4X:
                MQTT.Publish("Temp_Set" & Temp_Set,BC.StringToBytes(True,"UTF8"))
                MQTT.Publish("Temp_Set" + Temp_Set,BC.StringToBytes(True,"UTF8"))

The MQTT.Publish routine requires two arguments, a name and a value. In your case I assume that the name is "Temp_Set". The value itself must be sent as a byte string. You appear to be trying to send a string value converted to bytes. I would expect the temperature setting to be an numeric value. but assuming that it is to be transmitted as a string here is what I would try ...

B4X:
    MQTT.Publish("Temp_Set", BC.StringToBytes(Temp_Set, "UTF8"))
 
Upvote 0

Cesar_Morisco

Active Member
I don't know anything about MQTT, but I can see that both of these statements are totally wrong ...

B4X:
                MQTT.Publish("Temp_Set" & Temp_Set,BC.StringToBytes(True,"UTF8"))
                MQTT.Publish("Temp_Set" + Temp_Set,BC.StringToBytes(True,"UTF8"))

The MQTT.Publish routine requires two arguments, a name and a value. In your case I assume that the name is "Temp_Set". The value itself must be sent as a byte string. You appear to be trying to send a string value converted to bytes. I would expect the temperature setting to be an numeric value. but assuming that it is to be transmitted as a string here is what I would try ...

B4X:
    MQTT.Publish("Temp_Set", BC.StringToBytes(Temp_Set, "UTF8"))
Hi Brian Dean
All good
It worked here
Thank you from the heart
 
Upvote 0
Top