The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once



UserSpice
Quick demo of MQTT on UserSpice (with code!) - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Miscellaneous (https://userspice.com/forums/forumdisplay.php?fid=28)
+--- Forum: Off-topic Discussions (https://userspice.com/forums/forumdisplay.php?fid=10)
+--- Thread: Quick demo of MQTT on UserSpice (with code!) (/showthread.php?tid=840)



Quick demo of MQTT on UserSpice (with code!) - mudmin - 11-19-2017

Bringing MQTT to UserSpice allows you to interact with the world in a completely different way. The possibilities are endless. Here's a quick sneak peak. More videos/demos to come.

I will keep a repository of my code examples for IOT stuff up to date here
https://github.com/mudmin/usiot/archive/master.zip

You can clone the repository with
git clone https://github.com/mudmin/usiot.git

https://www.youtube.com/watch?v=IYEoLhkp9eU&feature=youtu.be


Quick demo of MQTT on UserSpice (with code!) - JUG - 11-30-2017

I'm all in. Where should I start. I will be working with SIM800C modules and I believe I can get it to work. Right now I'm communicating with userspice over GET requests and I'm unable to poll device from server, so I'm sending GET requests every 2 minutes to send server an update and ask it if it wants anything more.

I have read some bits of MQTT on internet but clearly I don't have big picture how to start implementing this to UserSpice.

Regards,
Jakob


Quick demo of MQTT on UserSpice (with code!) - JUG - 12-01-2017

I've been reading about mqtt a bit more and I believe I know the protocol. I don't know yet how to implement mqtt broker onto userspice. I saw files on git but on the mqtt.php there is a function mqtt() and I don't know where can I find this function. Yet I didnt try any of this on my server but I think it won't work unless mqtt broker is somewhere in init.php or header or navigation.

Regards,
Jakob


Quick demo of MQTT on UserSpice (with code!) - mudmin - 12-02-2017

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