Go Down

Topic: DS18B20 Copy to EEPROM  Command (Read 2184 times) previous topic - next topic


Have a few DS18B20 talking Ok to the Duemilanove, and displaying temp via a Max7219. The problem I have is retaining the setAlarm Temp after powering down the unit. I know I need the copyscratch [hex48] but unable to find it in the OneWire or DallasTemperature lib's. What are my options.


I'm curious why you're worried about the internal flags when you're got them wired up to a fully fledged microcontroller ?. The library writers probably didn't bother implementing the function because they couldn't see a use for them when you've got a relatively powerful processor to do it.  You could store the values in the Arduino's eeprom and upload them to the one wire devices in the setup part of the sketch. Or you could have the arduino deciding if an alarm condition exists from what the thermometers are telling it.


I'm not using the Hi Lo  registers for alarms but to store an identifier code. This allows me to change a faulty DS18B20  and initialize the new DS with the same identifier. This is how I've set up the PC application.
and Dallas units.
Also the DallasTemperature lib, does have setHighAlarmTemp and setLowAlarmTemp, but this would have to be sent each time the Arduino unit was powered up. This does not make sense to me.


this would have to be sent each time the Arduino unit was powered up.

This makes sense from a defensive programming point-of-view.
Per Arduino ad Astra


That's true from a defensive programmer point of view, but equally if the set points were read first and compared with what they should be, and if different one could suspect that the DS hardware could be possibly faulty. What I'm attempting to do is check the hardware devices for possible flakeness. Also I will have over 30 temperature sensors and keeping track of what one is where is often a difficult task. By having the identifier in the Hi Lo registers simplifies this task, plus allows me to easily replace sensors with a simple look-up table in the PC application.


Apr 26, 2010, 10:05 pm Last Edit: Apr 26, 2010, 10:06 pm by Fe2o3Fish Reason: 1
   You can do something like this to make up for the lack of CopyScratchPad command:
Code: [Select]
OneWire ow(OWpin);
#define OW_CMD_COPY_SCRATCH  0x48

ow.write(OW_CMD_COPY_SCRATCH, 0);

Use 0 if providing separate power for the sensors.
Use 1 if the sensors are using parasitic power.

The Copy ScratchPad to EEPROM command is specific to the
temperature sensors so they wouldn't go in the OneWire class.



Oh, the DallasTemperature library I have saves the scratchpad to EEPROM when a DallasTemperature::writeScratchPad() is called.


Tks for the constructive reply, but (hum always a BUT somewhere) still lost the new alarm value after powering off.

OneWire oneWire(ONE_WIRE_BUS)
oneWire.write(0x48, 0);

Also the DallasTemperature::writeScratchPad() looks like it only writes to the scratch pad and leaves the EEPROM as is.

There is a third option, and that is I'm doing something wrong, anyway will have another play with it tonight.


Now fixed, and thanks for putting me on the correct track.
What was missing was a
before the    
  ow.write(OW_CMD_COPY_SCRATCH, 0);


Apr 28, 2010, 04:03 am Last Edit: Apr 28, 2010, 04:16 am by Fe2o3Fish Reason: 1
Yes, using the work-around I gave you.

Still, we may have different DallasTemperature libraries.
The README file in mine states:
Arduino Library for Dallas Temperature ICs, version 2.5.0
but I just got the 3.5.0 version.  Both versions copy the scratchpad into EEProm in the writeScratchPad().  Removing the _wire->reset()
call still applies.  :-)

Go Up