Merge pull request #221 from sensebox/block/add-sps30
init implementation of sps30 block
This commit is contained in:
commit
345c15ed77
@ -562,3 +562,31 @@ Blockly.Blocks["sensebox_sensor_dps310"] = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sensirion SPS30 Fine Particular Matter Sensor
|
||||||
|
* added 02.12.2022
|
||||||
|
*/
|
||||||
|
|
||||||
|
Blockly.Blocks["sensebox_sensor_sps30"] = {
|
||||||
|
init: function () {
|
||||||
|
this.appendDummyInput().appendField(Blockly.Msg.senseBox_sps30);
|
||||||
|
this.appendDummyInput()
|
||||||
|
.setAlign(Blockly.ALIGN_LEFT)
|
||||||
|
.appendField(Blockly.Msg.senseBox_value)
|
||||||
|
.appendField(
|
||||||
|
new Blockly.FieldDropdown([
|
||||||
|
[Blockly.Msg.senseBox_sps30_1p0, "1p0"],
|
||||||
|
[Blockly.Msg.senseBox_sps30_2p5, "2p5"],
|
||||||
|
[Blockly.Msg.senseBox_sps30_4p0, "4p0"],
|
||||||
|
[Blockly.Msg.senseBox_sps30_10p0, "10p0"],
|
||||||
|
]),
|
||||||
|
"value"
|
||||||
|
)
|
||||||
|
.appendField(Blockly.Msg.senseBox_sps30_dimension);
|
||||||
|
this.setOutput(true, Types.DECIMAL.typeName);
|
||||||
|
this.setColour(getColour().sensebox);
|
||||||
|
this.setTooltip(Blockly.Msg.senseBox_sps30_tooltip);
|
||||||
|
this.setHelpUrl(Blockly.Msg.senseBox_sps30_helpurl);
|
||||||
|
},
|
||||||
|
};
|
@ -434,7 +434,8 @@ if (airSensor.begin() == false)
|
|||||||
while (1)
|
while (1)
|
||||||
;
|
;
|
||||||
}`;
|
}`;
|
||||||
Blockly.Arduino.setupCode_["scd30_staleData"] = "airSensor.useStaleData(true);";
|
Blockly.Arduino.setupCode_["scd30_staleData"] =
|
||||||
|
"airSensor.useStaleData(true);";
|
||||||
var code = "";
|
var code = "";
|
||||||
switch (dropdown) {
|
switch (dropdown) {
|
||||||
case "temperature":
|
case "temperature":
|
||||||
@ -693,3 +694,57 @@ Blockly.Arduino.sensebox_sensor_dps310 = function () {
|
|||||||
}
|
}
|
||||||
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sensirion SPS30 Fine Particlar Matter
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
Blockly.Arduino.sensebox_sensor_sps30 = function () {
|
||||||
|
var dropdown_name = this.getFieldValue("value");
|
||||||
|
Blockly.Arduino.libraries_["library_senseBoxIO"] = "#include <senseBoxIO.h>";
|
||||||
|
Blockly.Arduino.libraries_[
|
||||||
|
"sps30"
|
||||||
|
] = `#include <sps30.h> // http://librarymanager/All#`;
|
||||||
|
Blockly.Arduino.variables_["sps30_measurement"] =
|
||||||
|
"struct sps30_measurement m;";
|
||||||
|
Blockly.Arduino.variables_["sps30_auto_clean_days"] =
|
||||||
|
"uint32_t auto_clean_days = 4;";
|
||||||
|
Blockly.Arduino.variables_["sps30_interval_intervalsps"] =
|
||||||
|
"const long intervalsps = 1000;";
|
||||||
|
Blockly.Arduino.variables_["sps30_time_startsps"] =
|
||||||
|
"unsigned long time_startsps = 0;";
|
||||||
|
Blockly.Arduino.variables_["sps30_time_actualsps"] =
|
||||||
|
"unsigned long time_actualsps = 0;";
|
||||||
|
Blockly.Arduino.codeFunctions_["sps30_getData"] = `
|
||||||
|
void getSPS30Data(){
|
||||||
|
|
||||||
|
uint16_t data_ready;
|
||||||
|
int16_t ret;
|
||||||
|
|
||||||
|
do {
|
||||||
|
ret = sps30_read_data_ready(&data_ready);
|
||||||
|
if (ret < 0) {
|
||||||
|
} else if (!data_ready) {}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
delay(100); /* retry in 100ms */
|
||||||
|
} while (1);
|
||||||
|
ret = sps30_read_measurement(&m);
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
Blockly.Arduino.setupCode_["sps30_begin"] = "sensirion_i2c_init();";
|
||||||
|
Blockly.Arduino.setupCode_["sps30_setFanCleaningInterval"] =
|
||||||
|
"sps30_set_fan_auto_cleaning_interval_days(auto_clean_days);";
|
||||||
|
Blockly.Arduino.setupCode_["sps30_startMeasurement"] =
|
||||||
|
"sps30_start_measurement();";
|
||||||
|
Blockly.Arduino.loopCodeOnce_["getSPS30Data();"] = `
|
||||||
|
time_startsps = millis();
|
||||||
|
if (time_startsps > time_actualsps + intervalsps) {
|
||||||
|
time_actualsps = millis();
|
||||||
|
getSPS30Data();
|
||||||
|
}`;
|
||||||
|
var code = `m.mc_${dropdown_name}`;
|
||||||
|
return [code, Blockly.Arduino.ORDER_ATOMIC];
|
||||||
|
};
|
||||||
|
@ -175,7 +175,7 @@ Die Messwerte für Temperatur, Luftfeuchtigkeit und Luftdruck können direkt ver
|
|||||||
* Feinstaubsensor (SDS011)
|
* Feinstaubsensor (SDS011)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
senseBox_sds011: "Feinstaubsensor",
|
senseBox_sds011: "Feinstaubsensor SDS011",
|
||||||
senseBox_sds011_dimension: "in µg/m³ an",
|
senseBox_sds011_dimension: "in µg/m³ an",
|
||||||
senseBox_sds011_pm25: "PM2.5",
|
senseBox_sds011_pm25: "PM2.5",
|
||||||
senseBox_sds011_pm10: "PM10",
|
senseBox_sds011_pm10: "PM10",
|
||||||
@ -200,4 +200,23 @@ Die Messwerte für Temperatur, Luftfeuchtigkeit und Luftdruck können direkt ver
|
|||||||
- "wurde gedrückt": Mit diesem Modus kannst du abfragen ob der Block gedrückt wurde. Erst wenn der Knopf gedrückt und wieder losgelassen wurde erhältst du TRUE zurück
|
- "wurde gedrückt": Mit diesem Modus kannst du abfragen ob der Block gedrückt wurde. Erst wenn der Knopf gedrückt und wieder losgelassen wurde erhältst du TRUE zurück
|
||||||
- "als Schalter": Wenn du diesen Block verwendest kannst du den Knopf wie ein Lichtschalter verwenden. Der Status wird gespeichert bis der Button erneut gedrückt wird`,
|
- "als Schalter": Wenn du diesen Block verwendest kannst du den Knopf wie ein Lichtschalter verwenden. Der Status wird gespeichert bis der Button erneut gedrückt wird`,
|
||||||
senseBox_button_helpurl: "",
|
senseBox_button_helpurl: "",
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Feinstaubsensor Sensirion SPS30
|
||||||
|
*/
|
||||||
|
|
||||||
|
senseBox_sps30: "Feinstaubsensor Sensirion SPS30",
|
||||||
|
senseBox_sps30_dimension: "in µg/m³",
|
||||||
|
senseBox_sps30_1p0: "PM1.0",
|
||||||
|
senseBox_sps30_2p5: "PM2.5",
|
||||||
|
senseBox_sps30_4p0: "PM4.0",
|
||||||
|
senseBox_sps30_10p0: "PM10",
|
||||||
|
senseBox_sps30_tooltip:"Dieser Block gibt dir den Messwert des Sensirion SPS30 Feinstaubsensor. Schließe den Feinstaubsensor an einen der 5 **I2C** Anschlüssen an. Im Dropdown Menü zwischen PM1.0, PM2.5, PM4.0 und PM10 auswählen. Der Messwert wird dir als **Kommazahl** in µg/m3",
|
||||||
|
senseBox_sps30_helpurl:
|
||||||
|
"https://docs.sensebox.de/hardware/sensoren-feinstaub/",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
@ -205,4 +205,23 @@ The measured values for temperature, humidity and air pressure can be used direc
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
senseBox_watertemperature: "Water Temperature",
|
senseBox_watertemperature: "Water Temperature",
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Feinstaubsensor Sensirion SPS30
|
||||||
|
*/
|
||||||
|
|
||||||
|
senseBox_sps30: "Particulate Matter Sensor (Sensirion SPS30)",
|
||||||
|
senseBox_sps30_dimension: "in µg/m³",
|
||||||
|
senseBox_sps30_1p0: "PM1.0",
|
||||||
|
senseBox_sps30_2p5: "PM2.5",
|
||||||
|
senseBox_sps30_4p0: "PM4.0",
|
||||||
|
senseBox_sps30_10p0: "PM10",
|
||||||
|
senseBox_sps30_tooltip:
|
||||||
|
"This block gives you the measured value of the Sensirion SPS30 fine dust sensor. Connect the fine dust sensor to one of the 5 **I2C** connectors. Select between PM1.0, PM2.5, PM4.0 and PM10 in the dropdown menu. The measured value will be displayed as **decimal** in µg/m3",
|
||||||
|
senseBox_sps30_helpurl:
|
||||||
|
"https://docs.sensebox.de/hardware/sensoren-feinstaub/",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -61,6 +61,7 @@ class Toolbox extends React.Component {
|
|||||||
<Block type="sensebox_sensor_uv_light" />
|
<Block type="sensebox_sensor_uv_light" />
|
||||||
<Block type="sensebox_sensor_bmx055_accelerometer" />
|
<Block type="sensebox_sensor_bmx055_accelerometer" />
|
||||||
<Block type="sensebox_sensor_sds011" />
|
<Block type="sensebox_sensor_sds011" />
|
||||||
|
<Block type="sensebox_sensor_sps30" />
|
||||||
<Block type="sensebox_sensor_pressure" />
|
<Block type="sensebox_sensor_pressure" />
|
||||||
<Block type="sensebox_sensor_dps310" />
|
<Block type="sensebox_sensor_dps310" />
|
||||||
<Block type="sensebox_sensor_bme680_bsec" />
|
<Block type="sensebox_sensor_bme680_bsec" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user