Descrizione
MIKROE-1978: è un sensore che rileva umidità, pressione e temperatura progettato specificamente per un basso consumo di corrente e stabilità a lungo termine. Il click è alimentato da una tensione continua di 3,3 V. Comunica con il microcontrollore di destinazione tramite l’interfaccia SPI o I2C. ( https://www.mikroe.com/weather-click )
LED Driver 3 click è in grado di pilotare un LED RGB con un massimo di 30 mA per segmento, tramite l’interfaccia I2C digitale. Viene fornito con un LED RGB integrato ed è in grado di visualizzare una tavolozza di 32768 colori. (https://www.mikroe.com/led-driver-3-click )
Compatibilità
- Arancino Board
- Arancino Mignon
Sketch Arduino
Librerie Arduino necessarie
- https://github.com/sparkfun/SparkFun_BME280_Arduino_Library/
- : https://github.com/RAKWireless/RAK14001-NCP5623-Library/
- https://download.smartme.io/artifactory/arancino-library/
#include <SparkFunBME280.h>
#include <Arancino.h>
#include <Wire.h>
#include <NCP5623.h>
#define BME280ADDR 0x76
NCP5623 rgb;
#define BME280ADDR 0x76
BME280 bme280_sensor;
float umidita;
float temperatura;
float pressione;
ArancinoMetadata amdata = {
.fwname = "01.1 - Set Example",
.fwversion = "1.0.1",
.tzoffset = "+1000"
};
void setColor(int red, int green ,int blue) {
rgb.setColor ( blue, green, red);
}
void setup() {
Arancino.begin (amdata);
Wire.begin();
bme280_sensor.setI2CAddress(BME280ADDR);
if (bme280_sensor.beginI2C() == false) ;
delay(5000);
rgb.setCurrent(26);
}
void loop() {
temperatura = bme280_sensor.readTempC();
umidita = bme280_sensor.readFloatHumidity();
pressione = bme280_sensor.readFloatPressure() / 100;
if (temperatura>=18.0 && temperatura<25.0){
setColor (0,255,0);
} else if (temperatura>=25.0 && temperatura <30.0){
setColor (255,255,0);
} else if (temperatura>=30.0 && temperatura <35.0){
setColor (255,0,0);
} else if (temperatura>=40.0 ){
setColor(128,0,128);
} else{
setColor( 255,255,255);
}
Arancino.set("TP", temperatura);
Arancino.set("HY", umidita);
Arancino.set("PS", pressione);
delay(200);
}
Flusso Node-Red
Per visualizzare i dati ricevuti dai sensori tramite Node-Red fare riferimento a questa guida …
[
{
"id": "a23b2932.24b558",
"type": "tab",
"label": "Weather Click",
"disabled": false,
"info": ""
},
{
"id": "48bc7551.99a8bc",
"type": "inject",
"z": "a23b2932.24b558",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "60",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 130,
"y": 260,
"wires": [
[
"d58ed673.0bf0b8",
"c8719e90.5831",
"8ea59fe2.3e96b"
]
]
},
{
"id": "d58ed673.0bf0b8",
"type": "function",
"z": "a23b2932.24b558",
"name": "temp",
"func": "msg.payload=['TP'];\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 390,
"y": 140,
"wires": [
[
"b85d9a14.593c18"
]
]
},
{
"id": "55ef5992.6578d8",
"type": "debug",
"z": "a23b2932.24b558",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 1070,
"y": 120,
"wires": []
},
{
"id": "c8719e90.5831",
"type": "function",
"z": "a23b2932.24b558",
"name": "umidità",
"func": "msg.payload=['HY'];\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 400,
"y": 260,
"wires": [
[
"1d1cdd34.460dc3"
]
]
},
{
"id": "b632a057.a220b",
"type": "debug",
"z": "a23b2932.24b558",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 1130,
"y": 260,
"wires": []
},
{
"id": "8ea59fe2.3e96b",
"type": "function",
"z": "a23b2932.24b558",
"name": "pressione",
"func": "msg.payload=['PS'];\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 400,
"y": 380,
"wires": [
[
"66053787.223ec8"
]
]
},
{
"id": "3cf09009.92771",
"type": "debug",
"z": "a23b2932.24b558",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 950,
"y": 400,
"wires": []
},
{
"id": "1d1cdd34.460dc3",
"type": "redis-command",
"z": "a23b2932.24b558",
"server": "64a576f8.c30928",
"command": "get",
"name": "",
"topic": "",
"x": 540,
"y": 260,
"wires": [
[
"d9fd3d28.ec485",
"b632a057.a220b",
"2aeec13d.12aaae"
]
]
},
{
"id": "66053787.223ec8",
"type": "redis-command",
"z": "a23b2932.24b558",
"server": "64a576f8.c30928",
"command": "get",
"name": "",
"topic": "",
"x": 540,
"y": 380,
"wires": [
[
"500a7545.88751c",
"3cf09009.92771",
"f7e088c1.025ff8"
]
]
},
{
"id": "2b9b0ea1.da17f2",
"type": "function",
"z": "a23b2932.24b558",
"name": "",
"func": "x = msg.payload;\ny = parseFloat(x);\n\nmsg.payload = y.toFixed(1);\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 710,
"y": 140,
"wires": [
[
"89412515.ce9b68",
"55ef5992.6578d8"
]
]
},
{
"id": "d9fd3d28.ec485",
"type": "function",
"z": "a23b2932.24b558",
"name": "",
"func": "x = msg.payload;\ny = parseFloat(x);\n\nmsg.payload = y.toFixed();\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 710,
"y": 220,
"wires": [
[]
]
},
{
"id": "500a7545.88751c",
"type": "function",
"z": "a23b2932.24b558",
"name": "",
"func": "x = msg.payload;\ny = parseFloat(x);\n\nmsg.payload = y.toFixed();\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 750,
"y": 360,
"wires": [
[]
]
},
{
"id": "b85d9a14.593c18",
"type": "redis-command",
"z": "a23b2932.24b558",
"server": "64a576f8.c30928",
"command": "get",
"name": "",
"topic": "",
"x": 540,
"y": 140,
"wires": [
[
"2b9b0ea1.da17f2"
]
]
},
{
"id": "89412515.ce9b68",
"type": "ui_gauge",
"z": "a23b2932.24b558",
"name": "",
"group": "54c6f671.f2d768",
"order": 0,
"width": "6",
"height": "6",
"gtype": "gage",
"title": "Temperature",
"label": "units",
"format": "{{value}}",
"min": 0,
"max": "50",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 930,
"y": 200,
"wires": []
},
{
"id": "2aeec13d.12aaae",
"type": "ui_gauge",
"z": "a23b2932.24b558",
"name": "",
"group": "54c6f671.f2d768",
"order": 0,
"width": "6",
"height": "6",
"gtype": "gage",
"title": "Humidity",
"label": "units",
"format": "{{value}}",
"min": 0,
"max": "45",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 880,
"y": 300,
"wires": []
},
{
"id": "f7e088c1.025ff8",
"type": "ui_gauge",
"z": "a23b2932.24b558",
"name": "",
"group": "54c6f671.f2d768",
"order": 0,
"width": "6",
"height": "6",
"gtype": "gage",
"title": "Pressure",
"label": "units",
"format": "{{value}}",
"min": 0,
"max": "2000",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 760,
"y": 440,
"wires": []
},
{
"id": "64a576f8.c30928",
"type": "redis-config",
"z": 0,
"host": "127.0.0.1",
"port": "6379",
"dbase": " 0",
"pass": ""
},
{
"id": "54c6f671.f2d768",
"type": "ui_group",
"z": "",
"name": "Enviroment",
"tab": "e0c0ad7a.7f6c8",
"disp": true,
"width": "18",
"collapse": false
},
{
"id": "e0c0ad7a.7f6c8",
"type": "ui_tab",
"z": "",
"name": "Sensors",
"icon": "dashboard",
"order": 5,
"disabled": false,
"hidden": false
}
]