In this last section, we have seen how to set up the components and code needed to set up our smart weather station using Raspberry Pi 3. Now, we will work on managing the data that we receive on the API engine from the Raspberry Pi 3.
Open api-engine/server/mqtt/index.js and update it, as shown here:
var Data = require('../api/data/data.model'); var mqtt = require('mqtt'); var config = require('../config/environment'); var client = mqtt.connect({ port: config.mqtt.port, protocol: 'mqtts', host: config.mqtt.host, clientId: config.mqtt.clientId, reconnectPeriod: 1000, username: config.mqtt.clientId, password: config.mqtt.clientId, keepalive: 300, rejectUnauthorized: false }); client.on('connect', function() { console.log('Connected to Mosca at ' + config.mqtt.host + ' on...