Created
May 2, 2019 20:07
-
-
Save natanael-araujo/8cc5b7b8627b86bd20e4e28f12603ed8 to your computer and use it in GitHub Desktop.
exercício de leitura de sensores de temperatura
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <OneWire.h> | |
#include <DallasTemperature.h> | |
#include "config.h" | |
OneWire pino(D3); | |
DallasTemperature barramento(&pino); | |
DeviceAddress sensor_1; | |
DeviceAddress sensor_2; | |
void setup() { | |
Serial.begin(115200); | |
delay(10); | |
barramento.begin(); | |
Serial.print("Neste barramento foram encontrados "); | |
Serial.print(barramento.getDeviceCount(), DEC); | |
Serial.println(" sensores."); | |
barramento.getAddress(sensor_1, 0); | |
barramento.getAddress(sensor_2, 1); | |
} | |
void loop() { | |
barramento.requestTemperatures(); | |
float temperatura_sensor_1 = barramento.getTempC(sensor_1); | |
float temperatura_sensor_2 = barramento.getTempC(sensor_2); | |
Serial.print("sensor 1: "); | |
Serial.print(temperatura_sensor_1); | |
Serial.print("C\tsensor 2: "); | |
Serial.print(temperatura_sensor_2); | |
Serial.println("C"); | |
temperatura_sensor_1 = barramento.getTempF(sensor_1); | |
temperatura_sensor_2 = barramento.getTempF(sensor_2); | |
Serial.print("sensor 1: "); | |
Serial.print(temperatura_sensor_1); | |
Serial.print("F\tsensor 2: "); | |
Serial.print(temperatura_sensor_2); | |
Serial.println("F"); | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment