node-red-contrib-easybotics-air-quality
Version:
use a serial mux to read multiple atmospheric sensors on the raspi, in a user friendly way
301 lines (264 loc) • 8.94 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('sensor-manager',
{
category: 'config',
defaults:
{
name: {value:""},
autoConfigC02: {value: "auto", required: true},
},
oneditprepare: function ()
{
},
icon: "arrow-in.png",
label: "Sensor Manager",
});
</script>
<script type="text/x-red" data-template-name="sensor-manager">
<p>
<b> Only create one Sensor Manager config node </b> <br>
<b> auto calibration:</b> <br>
auto calibration on the MHZ19 C02 sensor pins the lowest value read in 24 hours to 400ppm <br>
probably should be kept off if your sensor is located indoors
</p>
<div class="form-row">
<label for="node-config-input-autoConfigC02"> <i class= "icon-bookmark"></i>Automatic C02 calibration</label>
<select id = "node-config-input-autoConfigC02">
<option value="auto"> auto </option>
<option value="man"> manual <option>
</select>
</div>
</script>
<script type="text/x-red" data-help-name="sensor-manager">
<p>
<b> Version 1.0, I bet it crashes if it can't get a hold of its serial port... </b>
</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('MHZ19-C02-Sensor',
{
category: 'Air Quality',
color: '#D7A1D1',
defaults:
{
name: {value:""},
handle: { type:'sensor-manager', required:true},
},
inputs: 1,
outputs: 1,
icon: "arrow-in.png",
label: function()
{
return this.name || "MH-Z19 C02";
},
});
</script>
<script type="text/x-red" data-template-name="MHZ19-C02-Sensor">
<div class = "form-row">
<label for="node-config-input-name"><i class="icon-tag"></i> Name </label>
</div>
<div class='form-row'>
<label for="node-config-input-handle"><i class='fa fa-tag'></i> Handle</label>
<input type='text' id='node-input-handle'/>
</div>
</script>
<script type="text/x-red" data-help-name="MHZ19-C02-Sensor">
<p>
Outputs the current C02 concentration in PPM <br>
Automatic calibration, sets the lowest concentration in 24 hours to 400PPM, you can enable or disable this in the MUX-HANDLE config node, it is disabled by default <br><br>
To manually zero the sensor to 400PPM inject a message with a string payload of 'zero'; do this outdoors or when you think the local c02 level is equal to outdoors
</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('PMS5003-PM-Reading',
{
category: 'Air Quality',
color: '#009933',
defaults:
{
name: {value:""},
handle: { type:'sensor-manager', required:true},
},
inputs: 0,
outputs: 3,
icon: "arrow-in.png",
label: function()
{
return this.name || "PM concentration";
},
});
</script>
<script type="text/x-red" data-template-name="PMS5003-PM-Reading">
<div class = "form-row">
<label for="node-config-input-name"><i class="icon-tag"></i> Name </label>
</div>
<div class='form-row'>
<label for="node-config-input-handle"><i class='fa fa-tag'></i> Handle</label>
<input type='text' id='node-input-handle'/>
</div>
</script>
<script type="text/x-red" data-help-name="PMS5003-PM-Reading">
<p>
Three outputs: <br>
<b> PM 1.0: </b> <br>
<b> PM 2.5: </b> <br>
<b> PM 10: </b> <br>
</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('PMS5003-Particle-Concentration',
{
category: 'Air Quality',
color: '#C1FF40',
defaults:
{
name: {value:""},
handle: { type:'sensor-manager', required:true},
},
inputs: 0,
outputs: 6,
icon: "arrow-in.png",
label: function()
{
return this.name || "Particulate per ML of air";
},
});
</script>
<script type="text/x-red" data-template-name="PMS5003-Particle-Concentration">
<div class = "form-row">
<label for="node-config-input-name"><i class="icon-tag"></i> Name </label>
</div>
<div class='form-row'>
<label for="node-config-input-handle"><i class='fa fa-tag'></i> Handle</label>
<input type='text' id='node-input-handle'/>
</div>
</script>
<script type="text/x-red" data-help-name="PMS5003-Particle-Concentration">
<p>
Six outputs: <br>
<b> Count of particles above 0.3um diamter in 0.1L of air <br>
<b> Count of particles above 0.5um diamter in 0.1L of air <br>
<b> Count of particles above 1.0um diamter in 0.1L of air <br>
<b> Count of particles above 2.5um diamter in 0.1L of air <br>
<b> Count of particles above 5.0um diamter in 0.1L of air <br>
<b> Count of particles above 10um diamter in 0.1L of air <br>
</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('BME280-Parse',
{
category: 'Air Quality',
color: '#C1FF40',
defaults:
{
name: {value:""},
},
inputs: 1,
outputs: 3,
icon: "arrow-in.png",
label: function()
{
return this.name || "BME280 Parser";
},
});
</script>
<script type="text/x-red" date-template-name="BME280-Parse">
<div class = "form-row">
<label for="node-config-input-name"><i class="icon-tag"></i> Name </label>
</div>
</script>
<script type="text/x-red" data-help-name="BME280-Parse">
<p>
Takes the output from the shipped BME-280 node as input <br> <br>
Three outputs: <br>
<b> Temperature in Celsius <br>
<b> Percentage Humidity <br>
<b> Pressure in hPa <br>
</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('publish-to-influxdb',
{
category: 'Air Quality',
color: '#C1FF40',
defaults:
{
name: {value:""},
hostname: {value: "66.228.55.221"},
port: {value: "8086"},
database: {value: "db0"}
},
credentials:
{
username: {type: "text"},
password: {type: "password"},
geohash: {type: "text"},
location_name: {type: "location_name"}
},
inputs: 1,
outputs: 1,
icon: "arrow-in.png",
label: function()
{
return this.name || "Publish to Influxdb/Grafana";
},
});
</script>
<script type="text/x-red" data-template-name="publish-to-influxdb">
<div class = "form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name </label>
<input type='text' id='node-input-name'/>
</div>
<div class="form-row">
<label for="node-input-hostname"><i class="fa fa-server"></i> Host: </span></label>
<input class="input-append-left" type="text" id="node-input-hostname" value="66.228.55.221" style="width: 40%;" >
<label for="node-input-port" style="margin-left: 10px; width: 35px; "> Port: </label>
<input type="text" id="node-input-port" value="8086" style="width:45px">
</div>
<div class="form-row">
<label for="node-input-database"><i class="fa fa-database"></i> Database: </label>
<input type="text" value="db0" id="node-input-database">
</div>
<p> Influxdb username and password, these should have been provided</p>
<div class="form-row">
<label for="node-input-username"><i class="icon-tag"></i> Username</label>
<input type="text" id="node-input-username">
</div>
<div class="form-row">
<label for="node-input-password"><i class="icon-tag"></i> Password</label>
<input type="password", id="node-input-password">
</div>
<p> Geohash is a code that represents a location on earth. <br>
This website <a href="http://geohash.gofreerange.com/"> here</a> can be used to generate a geohash<br>
Be mindful of how many characters you use. <br>
A 4 digit code is about the area of a city <br>
A 5 digit code is about the area of a small town <br>
A 6 digit code narrows down to the street or even building <br>
If you care about security, and don't need a specific location, don't go over 4 or 5 digits.<br>
Defauts to somewhere in the artic circle..
</p>
<div class="form-row">
<label for="node-input-geohash"><i class="icon-tag"></i>Geohash</label>
<input type="text", id="node-input-geohash">
</div>
<p> Location name is an optional field that is used to tag your data for reading later. <br>
By default we use your raspberry-pi's unique serial number, which is a string of random letters <br>
But using a Location Name makes things more user-friendly <br>
For example, you could access your data from aqeasy.com/waiakea vs aqeasy.com/Ahgf992 <br>
<b> Location name must be unique, or data will mix together with anyone else using that name </b><br>
Don't use a name like 'school', or 'house' that someoone else might use <br>
If you aren't sure it'll be unique, just leave this field blank
</p>
<div class="form-row">
<label for="node-input-location_name"><i class="icon-tag"></i>Location Name</label>
<input type="text", id="node-input-location_name">
</div>
</script>
<script type="text/x-red" data-help-name="publish-to-influxdb">
<p>
Takes input from any air-quality sensor nodes (BME-parse, PM, C02), and formats it for use in the easybotics grafana database <br>
Outputs a url where you can find graphs of your data <br>
<br>
Output to influxdb is ratelimited to once per 30 seconds per data topic, all inputs in the 30 second window are averaged <br>
</p>
</script>