Implementing the application process
Since the application process is not a part of the deployed Firebase application that we built in the previous chapter, we will create a new folder for it (for this chapter, it will be named firebase-process
).
First, we will be copying over the get-sensor-readings.js
module from the previous implementations (shown here for reference):
var sensor =require('node-dht-sensor')const getSensorReadings =(callback)=>{ sensor.read(11,4,function(err, temperature, humidity){if(err){returncallback(err)}callback(null, temperature, humidity)})} module.exports = getSensorReadings
Next, we implement the core module:
/** * Import the "get-sensor-readings" module, as well as the firebase admin module */const getSensorReadings =require('./get-sensor- readings')var admin =require('firebase-admin')/** * Read the JSON key that was downloaded from firebase, in this case, it has * been placed in the "/home/pi" directory...