Getting data to Edison by using MQTT
We have been talking about home automation controlling electrical loads, but everything has a starting point. The most basic kick-starter is controlling Edison over the Internet—that's what it's all about.
When you have a device that is controllable over the Internet, we recommend controlling the electrical loads. In this other mini-project, we are going to control a simple LED that is already attached to pin 13
of Intel Edison. There is no need for any external hardware for this, as we are using an in-built functionality. Now, open your editor and type in the following code:
var mraa = require('mraa'); var mqtt = require('mqtt'); varledPin=new mraa.Gpio(13); ledPin.dir(mraa.DIR_OUT); var client = mqtt.connect('mqtt://iot.eclipse.org'); client.subscribe('avirup/control/#') client.handleMessage=function(packet,callback) { var payload = packet.payload.toString() console.log(payload); if(payload=='ON') ledPin.write(1); if(payload=='OFF') ledPin...