Advertisement
Krzyspx

brama3,5dallas

Dec 2nd, 2016
3,927
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <OneWire.h>
  2. #define ONE_WIRE_BUS 13 // 1-Wire bus Arduino pin
  3. OneWire oneWire(ONE_WIRE_BUS);
  4. #include <DallasTemperature.h>
  5. DallasTemperature sensors(&oneWire);
  6. DeviceAddress tempDeviceAddress;
  7.  
  8. void sensorT() { //wysylanie ttemp do APP
  9.   int tempx10 = (((sensors.getTempCByIndex(0)) * 10) - 30); // x 10 i kalibracja
  10.   sensors.setWaitForConversion(false);  // makes it async
  11.   sensors.requestTemperatures(); // Send the command to get temperatures
  12.   int temperature = (tempx10 / 10);
  13.   int dziesietne = (tempx10 % 10);
  14.   String str = String(temperature) + "." + String(dziesietne) + " ℃"; // oszczedzam 3 kB pamieci
  15.   //  Serial.println(str);
  16.   BlynkvirtualWrite_str(6, str);
  17. }
  18.  
  19. void setdallas() //ustawienia początkowe dla Dallas
  20. {
  21.   sensors.begin();// Dallas
  22.   sensors.getAddress(tempDeviceAddress, 0);
  23.   sensors.setResolution(tempDeviceAddress, 12);
  24.   sensors.setWaitForConversion(false);  // makes it async
  25.   sensors.requestTemperatures(); // Send the command to get temperatures
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement