The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Quick demo of MQTT on UserSpice (with code!)
#4
MQTT is great and so simple. I'm going to work on some videos. Promise.

If you already have an mqtt broker you can add your credentials on the dashboard. Just go to the button at the top that says IOT and MQTT. Enter your server and note the id. It will probably be 2.

Then in your code, you can just do...
Code:
mqtt(2,"Hello","World!");
//sends Msg of "World!" with topic of "Hello" to MQTT server 2.

If you don't already have an mqtt server, you can install it on ubuntu with

Code:
sudo apt-get install mosquitto mosquitto-clients

From there, just enter your server ip and port 1883. You don't really need to worry about username and password during your early testing. Eventually you'll want one for production and there are tons of guides for that.

If you have a raspberry pi laying around you can do...
Code:
wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
Code:
sudo apt-key add mosquitto-repo.gpg.key
Code:
sudo wget http://repo.mosquitto.org/debian/mosquitto-wheezy.list
Code:
sudo -i
Code:
apt-get update
Code:
apt-get install mosquitto
  Reply


Messages In This Thread
Quick demo of MQTT on UserSpice (with code!) - by mudmin - 12-02-2017, 12:08 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)