I am using Mosquito MQTT server to broadcast messages.
How can I send a binary data (not text)?
Example:
mosquitto_pub -t test -m 0x452343
Should be received as:
0100 0101 0010 011 0100 0011
If you literally want to send that binary sequence of characters, then you can use echo to convert from a string to binary using:
echo -ne "\x45\x23\x43" | mosquitto_pub -h test.mosquitto.org -t 'test/binary' -s
This also works for the output of binary commands, such as capturing an image on a Raspberry Pi:
raspistill -o - | mosquitto_pub -h test.mosquitto.org -t 'webcam/' -s
You could put your binary data in a file, then send the file as a message:
mosquitto_pub -t test -f file
Or you could write your own client using libmosquitto or another MQTT client library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With