This commit is contained in:
topicchi
2026-03-20 17:18:15 +00:00
parent 438d6354ae
commit 99748d82ac
105 changed files with 4770 additions and 3467 deletions

View File

@@ -23,23 +23,23 @@ void setup()
Serial.begin(9600);
Serial.println(__FILE__);
Serial.println("Dallas Temperature Demo");
sensors.begin();
// Get ID of first sensor (at index 0)
sensors.getAddress(deviceAddress,0);
sensors.getAddress(deviceAddress, 0);
// By default configuration and alarm/userdata registers are also saved to EEPROM
// when they're changed. Sensors recall these values automatically when powered up.
// Turn OFF automatic saving of configuration and alarm/userdata registers to EEPROM
sensors.setAutoSaveScratchPad(false);
// Change configuration and alarm/userdata registers on the scratchpad
int8_t resolution = 12;
sensors.setResolution(deviceAddress,resolution);
sensors.setResolution(deviceAddress, resolution);
int16_t userdata = 24680;
sensors.setUserData(deviceAddress,userdata);
sensors.setUserData(deviceAddress, userdata);
// Save configuration and alarm/userdata registers to EEPROM
sensors.saveScratchPad(deviceAddress);
@@ -53,28 +53,28 @@ void setup()
// EEPROM by index:
//
// sensors.saveScratchPadByIndex(0);
// Print current values on the scratchpad (resolution = 12, userdata = 24680)
printValues();
}
void loop(){
void loop() {
// Change configuration and alarm/userdata registers on the scratchpad
int8_t resolution = 10;
sensors.setResolution(deviceAddress,resolution);
sensors.setResolution(deviceAddress, resolution);
int16_t userdata = 12345;
sensors.setUserData(deviceAddress,userdata);
sensors.setUserData(deviceAddress, userdata);
// Print current values on the scratchpad (resolution = 10, userdata = 12345)
printValues();
delay(2000);
// Recall configuration and alarm/userdata registers from EEPROM
sensors.recallScratchPad(deviceAddress);
// recallScratchPad can also be used without a parameter to recall the configuration
// and alarm/userdata registers of ALL connected sensors from EEPROM:
//
@@ -84,23 +84,23 @@ void loop(){
// from EEPROM by index:
//
// sensors.recallScratchPadByIndex(0);
// Print current values on the scratchpad (resolution = 12, userdata = 24680)
printValues();
delay(2000);
}
void printValues() {
Serial.println();
Serial.println("Current values on the scratchpad:");
Serial.print("Resolution:\t");
Serial.println(sensors.getResolution(deviceAddress));
Serial.print("User data:\t");
Serial.println(sensors.getUserData(deviceAddress));
}