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!)
#1
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=IYEoLhkp...e=youtu.be
  Reply
#2
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
  Reply
#3
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
  Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)