Skip to content

Instantly share code, notes, and snippets.

@vdemay
Last active December 1, 2015 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vdemay/40a1b924568146b78148 to your computer and use it in GitHub Desktop.
Save vdemay/40a1b924568146b78148 to your computer and use it in GitHub Desktop.
ds.search(addr); // address on 1wire bus
if (addr[0] == DS18B20) // check we are really using a DS18B20
{
ds.reset(); // rest 1-Wire
ds.select(addr); // select DS18B20
ds.write(0x4E); // write on scratchPad
ds.write(0x00); // User byte 0 - Unused
ds.write(0x00); // User byte 1 - Unused
ds.write(0x7F); // set up en 12 bits (0x7F)
ds.reset(); // reset 1-Wire
ds.select(addr); // select DS18B20
ds.write(0x48); // copy scratchpad to EEPROM
delay(15); // wait for end of write
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment