This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:iot-open:hardware2:sensors_environment [2023/10/03 08:04] – pczekalski | en:iot-open:hardware2:sensors_environment [2024/05/27 12:07] (current) – ktokarz | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== Environment Sensors ==== | + | ====== Environment Sensors |
- | + | {{: | |
- | ===Temperature Sensor=== | + | == Temperature Sensor == |
A temperature sensor is a device used to determine the temperature of the surrounding environment. Most temperature sensors work on the principle that the material' | A temperature sensor is a device used to determine the temperature of the surrounding environment. Most temperature sensors work on the principle that the material' | ||
* **thermocouple** – consists of two junctions of dissimilar metals, | * **thermocouple** – consists of two junctions of dissimilar metals, | ||
Line 44: | Line 44: | ||
</ | </ | ||
- | ===Digital Temperature Sensor=== | + | == Digital Temperature Sensor == |
Digital temperature sensors automatically convert the temperature reading into some known unit, e.g. Celsius, Fahrenheit or Kelvin Degrees. Digital thermometers use one of the popular communication links. An example of a digital thermometer is DS18B20 by Dallas Semiconductors (figures {{ref> | Digital temperature sensors automatically convert the temperature reading into some known unit, e.g. Celsius, Fahrenheit or Kelvin Degrees. Digital thermometers use one of the popular communication links. An example of a digital thermometer is DS18B20 by Dallas Semiconductors (figures {{ref> | ||
Line 63: | Line 63: | ||
<code c> | <code c> | ||
- | #include < | + | #include < |
- | #include < | + | #include < |
- | const int SENSOR_PIN = 13; | + | const int SENSOR_PIN = 13; |
- | OneWire oneWire(SENSOR_PIN); | + | OneWire oneWire(SENSOR_PIN); |
- | DallasTemperature tempSensor(& | + | DallasTemperature tempSensor(& |
+ | //connect oneWire to DallasTemperature library | ||
- | float tempCelsius; | + | float tempCelsius; |
void setup() | void setup() | ||
+ | |||
{ | { | ||
- | Serial.begin(9600); | + | Serial.begin(9600); |
- | tempSensor.begin(); | + | tempSensor.begin(); |
} | } | ||
void loop() | void loop() | ||
{ | { | ||
- | tempSensor.requestTemperatures(); | + | tempSensor.requestTemperatures(); |
- | tempCelsius = tempSensor.getTempCByIndex(0); | + | //command to read temperatures |
+ | tempCelsius = tempSensor.getTempCByIndex(0); | ||
+ | //read temperature (in Celsius) | ||
Serial.print(" | Serial.print(" | ||
- | Serial.print(tempCelsius); | + | Serial.print(tempCelsius); |
Serial.println(" | Serial.println(" | ||
Line 93: | Line 97: | ||
</ | </ | ||
- | ===Humidity Sensor=== | + | < |
+ | |||
+ | == Humidity Sensor == | ||
A humidity sensor (hygrometer) is a sensor that detects the amount of water or water vapour in the environment. The most common principle of air humidity sensors is the change of capacitance or resistance of materials that absorb moisture from the atmosphere. Soil humidity sensors measure the resistance between the two electrodes. Soluble salts and water amounts influence the resistance between electrodes in the soil. The output of a humidity sensor is an analogue signal value or digital value sent with some popular protocols ((https:// | A humidity sensor (hygrometer) is a sensor that detects the amount of water or water vapour in the environment. The most common principle of air humidity sensors is the change of capacitance or resistance of materials that absorb moisture from the atmosphere. Soil humidity sensors measure the resistance between the two electrodes. Soluble salts and water amounts influence the resistance between electrodes in the soil. The output of a humidity sensor is an analogue signal value or digital value sent with some popular protocols ((https:// | ||
IoT applications include monitoring humidors, greenhouse humidity, agriculture, | IoT applications include monitoring humidors, greenhouse humidity, agriculture, | ||
Line 103: | Line 109: | ||
<figure humiditysensor2> | <figure humiditysensor2> | ||
- | {{ : | + | {{ : |
< | < | ||
</ | </ | ||
Line 128: | Line 134: | ||
</ | </ | ||
- | ===Sound Sensor=== | + | <note important> |
+ | |||
+ | == Sound Sensor == | ||
A sound sensor is a sensor that detects vibrations in a gas, liquid or solid environment. At first, the sound wave pressure makes mechanical vibrations, which transfer to changes in capacitance, | A sound sensor is a sensor that detects vibrations in a gas, liquid or solid environment. At first, the sound wave pressure makes mechanical vibrations, which transfer to changes in capacitance, | ||
Sound sensors are used in drone detection, gunshot alert, seismic detection and vault safety alarms.\\ | Sound sensors are used in drone detection, gunshot alert, seismic detection and vault safety alarms.\\ | ||
Line 158: | Line 166: | ||
void loop(void) { | void loop(void) { | ||
- | //Read the digital value whether the sound has been detected | + | //Read the digital value to determine |
soundReading = digitalRead(soundPin); | soundReading = digitalRead(soundPin); | ||
if (soundPin==LOW) { //When sound detector detected the sound | if (soundPin==LOW) { //When sound detector detected the sound | ||
Line 169: | Line 177: | ||
</ | </ | ||
- | + | == Chemical and Gas Sensor == | |
- | ===Chemical and Gas Sensor=== | + | |
Gas sensors are a group that can detect and measure the concentration of certain gasses in the air. The working principle of electrochemical sensors is to absorb the gas and create current from an electrochemical reaction. For process acceleration, | Gas sensors are a group that can detect and measure the concentration of certain gasses in the air. The working principle of electrochemical sensors is to absorb the gas and create current from an electrochemical reaction. For process acceleration, | ||
The smoke or air pollution sensors usually use LED or laser that emits light and a detector normally shaded from the light. If there are particles of smoke or polluted air inside the sensor, the light is reflected by them, which can be observed by the detector.\\ | The smoke or air pollution sensors usually use LED or laser that emits light and a detector normally shaded from the light. If there are particles of smoke or polluted air inside the sensor, the light is reflected by them, which can be observed by the detector.\\ | ||
Line 181: | Line 188: | ||
<figure gassensor2> | <figure gassensor2> | ||
- | {{ : | + | {{ : |
< | < | ||
</ | </ | ||
Line 203: | Line 210: | ||
</ | </ | ||
- | ===Smoke and Air Pollution Sensors=== | + | == Smoke and Air Pollution Sensors == |
The smoke sensors usually emit LED light, and a detector is typically shaded from the light. If there are particles of smoke present inside the sensor, the light is reflected by them, which can be observed by the detector.\\ | The smoke sensors usually emit LED light, and a detector is typically shaded from the light. If there are particles of smoke present inside the sensor, the light is reflected by them, which can be observed by the detector.\\ | ||
Smoke detectors are used in fire alarm systems.\\ | Smoke detectors are used in fire alarm systems.\\ | ||
The air pollution sensors usually use a laser directed onto the detector. Between the laser and detector, the thin stream of air flows and pollution particles create shades on the detector. Thus, the detector can distinguish the sizes of particles and count the number of them.\\ | The air pollution sensors usually use a laser directed onto the detector. Between the laser and detector, the thin stream of air flows and pollution particles create shades on the detector. Thus, the detector can distinguish the sizes of particles and count the number of them.\\ | ||
- | Air pollution sensors are used in air purifiers and air quality measurement stations to monitor current air conditions, mainly in cities. Because the air pollution sensor generates more data, the serial connection is often used for reading measurement results. An example of an air pollution sensor that can count particles of PM1.0, PM2.5, and PM10 is PMS5003. PMS series sensors are controlled with a serial port and additional signalling GPIOs with 3.3V logic, but they do require 5V to power on an internal fan that ensures correct airflow. A PMS5003 sensor is present in figures {{ref> | + | Air pollution sensors are used in air purifiers and air quality measurement stations to monitor current air conditions, mainly in cities. Because the air pollution sensor generates more data, the serial connection is often used for reading measurement results. An example of an air pollution sensor that can count particles of PM1.0, PM2.5, and PM10 is PMS5003. PMS series sensors are controlled with a serial port and additional signalling GPIOs with 3.3V logic, but they require 5V to power on an internal fan that ensures correct airflow. A PMS5003 sensor is present in figures {{ref> |
- | + | ||
- | <todo @pczekalski> | + | |
- | **PMS5003 photo** | + | |
<figure airpolution1> | <figure airpolution1> | ||
Line 230: | Line 234: | ||
<code c> | <code c> | ||
#include < | #include < | ||
- | # | + | # |
// Define the serial port for the PMS5003 sensor | // Define the serial port for the PMS5003 sensor | ||
Line 244: | Line 248: | ||
Serial.begin(9600); | Serial.begin(9600); | ||
| | ||
- | pinMode(SET_PIN, | + | pinMode(SET_PIN, |
+ | //(LOW) -> turns fan down | ||
pinMode(RESET_PIN, | pinMode(RESET_PIN, | ||
digitalWrite(SET_PIN, | digitalWrite(SET_PIN, | ||
Line 286: | Line 291: | ||
</ | </ | ||
- | ===Air Pressure Sensor=== | + | == Air Pressure Sensor == |
Air pressure sensors can measure the absolute pressure in the surrounding environment. Some popular sensors use a piezo-resistive sensing element, which is then connected to the amplifier and analogue digital converter. Frint-end uses the logic to interface the microcontroller. Usually, barometric sensor readings depend on the temperature, | Air pressure sensors can measure the absolute pressure in the surrounding environment. Some popular sensors use a piezo-resistive sensing element, which is then connected to the amplifier and analogue digital converter. Frint-end uses the logic to interface the microcontroller. Usually, barometric sensor readings depend on the temperature, | ||
- | Popular examples of barometric sensors are BME280 and BMP280. Both include barometric sensors and temperature sensors built in for compensation and possible measurement, | + | Popular examples of barometric sensors are BME280 and BMP280. Both include barometric sensors and temperature sensors built in for compensation and possible measurement, |
Communication with these sensors is done with an I2C or SPI bus. | Communication with these sensors is done with an I2C or SPI bus. | ||
Line 299: | Line 304: | ||
<figure sensor_bme280_2> | <figure sensor_bme280_2> | ||
- | {{ : | + | {{ : |
< | < | ||
</ | </ |