Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <OneWire.h>
- #include <DallasTemperature.h>
- #define ONE_WIRE_BUS 10
- OneWire oneWire(ONE_WIRE_BUS);
- DallasTemperature sensors(&oneWire);
- // Coloque aqui os Nos. de serie dos sensores
- DeviceAddress Sensor_1 = { 0x28, 0xFF, 0x38, 0x50, 0x73, 0x04, 0x00, 0x1A };
- float tempC;
- float tempV;
- //--------------------------------------- setup ------------------------------------
- void setup(void)
- {
- // Serial.begin(9600);
- Wire.begin(); //Inicializacao do protocolo wire
- delay (1000);
- sensors.begin();
- sensors.setResolution(Sensor_1, 10);
- }
- //--------------------------------------- Calc temperature ------------------------------------
- void printTemperature(DeviceAddress deviceAddress)
- {
- tempC = sensors.getTempC(deviceAddress);
- if (tempC == -127.00)
- {
- // Serial.print("Erro ao ler temperatura !");
- }
- else
- {
- // Serial.print("C: ");
- // Serial.print(tempC);
- }
- }
- //--------------------------------------- loop ------------------------------------
- void loop(void)
- {
- // Serial.print("SENSOR DS18B20:\n\r");
- sensors.requestTemperatures();
- // Serial.print("Temperatura Sensor 1: ");
- printTemperature(Sensor_1);
- tempV = tempC;
- delay(1000); // Aguarda 1 seg antes de acessar as informa��es do sensor
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement