Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <OneWire.h>
- OneWire oneWire (12);
- byte addrThermo5[] = {0x28, 0xFF, 0x9C, 0xF0, 0xC1, 0x16, 0x04, 0x70}; //адрес датчика 5
- float thermo5; //показания термометра 5
- void setup()
- {
- Serial.begin(9600);
- }
- void loop()
- {
- oneWire.reset();
- //oneWire.select (addrThermo5); //КОД РАБОТАЕТ
- oneWire.select (0xCC); //КОД НЕ РАБОТАЕТ
- oneWire.write (0x44);
- delay (1000);
- oneWire.reset(); //сбрасываем шину 1-Wire
- oneWire.select (addrThermo5); //выбираем нужный термодатчик по его адресу
- oneWire.write (0xBE); //отправляем в порт команду 0xBE (читать данные из датчика)
- byte data[9];
- for (byte i = 0; i < 9; i++) {data[i] = oneWire.read();} //смотрим 9 байтов
- int16_t raw = (data[1] << 8) | data[0];
- thermo5 = (float)raw / 16.0; //конвертим raw в градусы цельсия
- Serial.println( thermo5);
- }
Advertisement
Add Comment
Please, Sign In to add comment