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/18 16:08] – 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' | ||
| 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 92: | Line 96: | ||
| </ | </ | ||
| + | |||
| + | < | ||
| == Humidity Sensor == | == Humidity Sensor == | ||
| Line 103: | Line 109: | ||
| <figure humiditysensor2> | <figure humiditysensor2> | ||
| - | {{ : | + | {{ : |
| < | < | ||
| </ | </ | ||
| Line 127: | Line 133: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | <note important> | ||
| == Sound Sensor == | == Sound Sensor == | ||
| Line 180: | Line 188: | ||
| <figure gassensor2> | <figure gassensor2> | ||
| - | {{ : | + | {{ : |
| < | < | ||
| </ | </ | ||
| Line 226: | 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 240: | 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 295: | Line 304: | ||
| <figure sensor_bme280_2> | <figure sensor_bme280_2> | ||
| - | {{ : | + | {{ : |
| < | < | ||
| </ | </ | ||