Moheeb Zara
Published © MIT

Meshblu: Getting IoT Devices to Talk

The easiest and most powerful way to connect devices and apps!

BeginnerProtip18 minutes1,908
Meshblu: Getting IoT Devices to Talk

Things used in this project

Software apps and online services

Meshblu
Octoblu Meshblu

Story

Read more

Schematics

Example

File missing, please reupload.

Code

index.html

HTML
<html>  
<head>
<script src="https://cdn.octoblu.com/js/meshblu/latest/meshblu.bundle.js" type="text/javascript"></script>
<script src="./index.js" type="text/javascript"></script>
</head>
<body>
<button onClick="sendMessage()">Click Me</button> 
</body>
</html>

index.js

JavaScript
var config = {
"uuid": "UUID-FROM-PREVIOUS-STEP",
"token": "TOKEN-FROM-PREVIOUS-STEP"
};
var conn = meshblu.createConnection(config);
conn.on('ready', function(data) {
console.log("Ready!");
conn.whoami({
 "uuid": data.uuid
}, function(device) {
 console.log(device);
});
});
var sendMessage = function(){
conn.message({
 "devices": "*",
 "data": {
   "some_value": "5"
 }
});
};

main.js

JavaScript
var MeshbluSocketIO = require('meshblu'); 
var meshblu = new MeshbluSocketIO({ 
"resolveSrv": true, 
"uuid": "DEVICE-B-UUID", 
"token": "DEVICE-B-TOKEN" 
}) 
meshblu.connect(); 
meshblu.on('ready', function(data){ 
console.log('Ready'); 
}); 

Meshblu Webpage & Node App Example

Credits

Moheeb Zara

Moheeb Zara

39 projects • 136 followers
Developer Advocate at EMQ Technologies - . Co-founder - South West Maker Festival. Hardware hacker, artist, robots, HeatSync Labs

Comments