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/11/21 21:33] – ktokarz | 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' | ||
Line 64: | Line 64: | ||
<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 | + | //connect oneWire to DallasTemperature library |
- | float tempCelsius; | + | float tempCelsius; |
void setup() | void setup() | ||
{ | { | ||
- | Serial.begin(9600); | + | Serial.begin(9600); |
- | tempSensor.begin(); | + | tempSensor.begin(); |
} | } | ||
Line 84: | Line 84: | ||
{ | { | ||
tempSensor.requestTemperatures(); | tempSensor.requestTemperatures(); | ||
- | //command to read temperatures | + | //command to read temperatures |
tempCelsius = tempSensor.getTempCByIndex(0); | tempCelsius = tempSensor.getTempCByIndex(0); | ||
- | //read temperature (in Celsius) | + | //read temperature (in Celsius) |
Serial.print(" | Serial.print(" | ||
- | Serial.print(tempCelsius); | + | Serial.print(tempCelsius); |
Serial.println(" | Serial.println(" | ||
Line 96: | Line 96: | ||
</ | </ | ||
+ | |||
+ | < | ||
== Humidity Sensor == | == Humidity Sensor == | ||
Line 107: | Line 109: | ||
<figure humiditysensor2> | <figure humiditysensor2> | ||
- | {{ : | + | {{ : |
< | < | ||
</ | </ | ||
Line 131: | Line 133: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | <note important> | ||
== Sound Sensor == | == Sound Sensor == | ||
Line 184: | Line 188: | ||
<figure gassensor2> | <figure gassensor2> | ||
- | {{ : | + | {{ : |
< | < | ||
</ | </ | ||
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 299: | Line 304: | ||
<figure sensor_bme280_2> | <figure sensor_bme280_2> | ||
- | {{ : | + | {{ : |
< | < | ||
</ | </ |