User Tools

Site Tools


amc2020:group_n:ds18b20

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
amc2020:group_n:ds18b20 [2020/07/18 19:47] – [1. About the Sensor Module] jonas001amc2020:group_n:ds18b20 [2021/08/24 17:35] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +<html>
 +  <left>
 +    <a href="https://wiki.eolab.de/doku.php?id=amc2020:group_n:start"; onmouseover="style.color='green'";>
 +      <span style="color:#2E71B8"; onmouseover="style.color='green'"; onmouseout="style.color='#2E71B8'";>
 +        &#8617 Back to the main page
 +      </span>
 +    </a>
 +  </left>
 +</html>
 +
 ====== DS18B20 Waterproof Digital Temperature Sensor ====== ====== DS18B20 Waterproof Digital Temperature Sensor ======
  
Line 33: Line 43:
 The 64-bit ROM and the 1-Wire port are connected through the memory control logic to the scratchpad. The scratchpad is a high-speed internal memory that is used for storing small, often temporary, pieces of data which can be rapidly retrieved if needed. The scratchpad memory, which gets erased after powering down, is connected to the temperature sensor itself and stores its data in a 2-byte register. Furthermore, the module has a small EEPROM (Electronically Erasable Programmable Read Only Memory), that means a nonvolatile data storage, which retains the data even when the device is powered down. The Arduino UNO and the ESP32 also have such storages, but of larger size. The module can transfer the aforementioned alarm temperatures TH and TL, as well as the configuration register from the scratchpad into the EEPROM and reload them back to the scratchpad memory after powering up again (figure 2). The 64-bit ROM and the 1-Wire port are connected through the memory control logic to the scratchpad. The scratchpad is a high-speed internal memory that is used for storing small, often temporary, pieces of data which can be rapidly retrieved if needed. The scratchpad memory, which gets erased after powering down, is connected to the temperature sensor itself and stores its data in a 2-byte register. Furthermore, the module has a small EEPROM (Electronically Erasable Programmable Read Only Memory), that means a nonvolatile data storage, which retains the data even when the device is powered down. The Arduino UNO and the ESP32 also have such storages, but of larger size. The module can transfer the aforementioned alarm temperatures TH and TL, as well as the configuration register from the scratchpad into the EEPROM and reload them back to the scratchpad memory after powering up again (figure 2).
  
-{{:amc2020:group_n:ds18b20_block_diagram.png?direct| Figure 2}} +^{{:amc2020:group_n:ds18b20_block_diagram.png?direct| Figure 2}}^ 
-**//Figure 2//** DS18B20 block diagram (Source: {{https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf|DS18B20 datasheet}} p. 5)+|**//Figure 2//** DS18B20 block diagram (Source: {{https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf|DS18B20 datasheet}} p. 5)|
  
 ==== 2.3 Temperature Register ==== ==== 2.3 Temperature Register ====
Line 40: Line 50:
 Normally the sensor is in an idle state after powering up. When the MCU issues a Convert T command, the sensor measures the temperature and does an analog to digital conversion and stores the result in the scratchpad 2-byte temperature register (figure 3) and the sensor goes back into idle state. Normally the sensor is in an idle state after powering up. When the MCU issues a Convert T command, the sensor measures the temperature and does an analog to digital conversion and stores the result in the scratchpad 2-byte temperature register (figure 3) and the sensor goes back into idle state.
  
-{{:amc2020:group_n:temperature_register.png?direct| Figure 3}} +^{{:amc2020:group_n:temperature_register.png?direct&800| Figure 3}}^ 
-**//Figure 3//** Structure of the temperature register, LS = Least Significant, MS = Most Significant, S = Sign.+|**//Figure 3//** Structure of the temperature register, LS = Least Significant, MS = Most Significant, S = Sign.|
  
 In the register, the 5 leading bits are representing the sign of the temperature. If the temperature is below 0°C, S = 1 and if it is above 0°C, S = 0. The other 11 bits represent the temperature indicated in figure 3, where bit 0, 1 and 2 can be undefined depending on the resolution stored in the configuration register: In the register, the 5 leading bits are representing the sign of the temperature. If the temperature is below 0°C, S = 1 and if it is above 0°C, S = 0. The other 11 bits represent the temperature indicated in figure 3, where bit 0, 1 and 2 can be undefined depending on the resolution stored in the configuration register:
Line 51: Line 61:
 The maximum range of values that can be displayed is thus -127.9375 – 127.9375, which exceeds the range of the temperature sensor. Some examples of different temperatures displayed in 12-bit resolution can be seen in table 1. The maximum range of values that can be displayed is thus -127.9375 – 127.9375, which exceeds the range of the temperature sensor. Some examples of different temperatures displayed in 12-bit resolution can be seen in table 1.
  
-**//Table 1//** Different temperature values and how they are stored in the temperature register.+^**//Table 1//** Different temperature values and how they are stored in the temperature register.^^^
 ^ **MS Byte**  ^ **LS Byte**  ^ **Temperature**  ^ ^ **MS Byte**  ^ **LS Byte**  ^ **Temperature**  ^
 | 0000 0111    | 1101 0000    | + 125 °C         | | 0000 0111    | 1101 0000    | + 125 °C         |
Line 64: Line 74:
 The configuration register is stored in the scratchpad memory (and EEPROM) and contains 1 byte of data. The MSB (bit 7) and the 5 LSB (bit 0 – 4) are reserved for internal use and cannot be changed. Bit 6 (R1) and bit 5 (R0) can be changed to adjust the resolution (figure 4). As can be seen, the conversion time doubles each time the resolution is increased by 1. A 12-bit resolution measurement takes 8 times as long as a 9-bit conversion. The configuration register is stored in the scratchpad memory (and EEPROM) and contains 1 byte of data. The MSB (bit 7) and the 5 LSB (bit 0 – 4) are reserved for internal use and cannot be changed. Bit 6 (R1) and bit 5 (R0) can be changed to adjust the resolution (figure 4). As can be seen, the conversion time doubles each time the resolution is increased by 1. A 12-bit resolution measurement takes 8 times as long as a 9-bit conversion.
  
-{{:amc2020:group_n:configuration_register.png?direct| Figure 4}} +^{{:amc2020:group_n:configuration_register.png?direct&800| Figure 4}}^ 
-**//Figure 4//** Schematic of the configuration register and the different thermometer resolution configurations.+|**//Figure 4//** Schematic of the configuration register and the different thermometer resolution configurations.|
  
 ==== 2.5 1-Wire Bus ==== ==== 2.5 1-Wire Bus ====
Line 89: Line 99:
  
 ===== 3. Technical Specifications and Setup of the Sensor ===== ===== 3. Technical Specifications and Setup of the Sensor =====
-When connecting the pins (figure 1), pin 1 (red) is VDD, pin 2 (black) is GND and pin 3 (yellow) is the data pin. In this project two sensors, one measuring the temperature at the bottom of the pond and one at the surface, are connected to the ESP32. As each sensor can be addressed individually by its serial code, the data pins can be connected to the same GPIO pin of the ESP32 (here pin 14 was used). As mentioned before, the sensors need a pullup resistor connecting the data pin with VDD. As both sensors are connected in the same data bus, only a single 5kΩ resistor between their data pins and VDD needs to be added.+When connecting the pins (figure 1), pin 1 (red) is VDD, pin 2 (black) is GND and pin 3 (yellow) is the data pin. In this project two sensors, one measuring the temperature at the bottom of the pond and one at the surface, are connected to the ESP32. As each sensor can be addressed individually by its serial code, the data pins can be connected to the same GPIO pin of the ESP32 (here pin 14 was used). As mentioned before, the sensors need a pullup resistor connecting the data pin with VDD. As both sensors are connected in the same data bus, only a single 5kΩ resistor between their data pins and VDD needs to be added (see figure 5).
  
 Like the DHT-22, VDD can be anywhere between 3.0 V to 5.5 V and can thus be powered by the ESP32 without a problem. Further information on the sensor’s specifications can be found in table 2 and in the datasheet. Like the DHT-22, VDD can be anywhere between 3.0 V to 5.5 V and can thus be powered by the ESP32 without a problem. Further information on the sensor’s specifications can be found in table 2 and in the datasheet.
  
-**//Table 2//** Specifications of the DS18B20 digital temperature sensor (local power supply with ESP32). +^**//Table 2//** Specifications of the DS18B20 digital temperature sensor (local power supply with ESP32).^^^^ 
-^ Sensor                                               ^ DS18B20                                 |||+^ Sensor                                               ^ DS18B20                                 ^^^
 | Supply Voltage $V_{DD}$                              | 3.3 V                                   ||| | Supply Voltage $V_{DD}$                              | 3.3 V                                   |||
 | Pullup Supply Voltage $V_{PU}$                       | 3.3 V                                   ||| | Pullup Supply Voltage $V_{PU}$                       | 3.3 V                                   |||
Line 109: Line 119:
 | :::                                                  | 11 bit           | 0.125 °C   | 187.5 ms  | | :::                                                  | 11 bit           | 0.125 °C   | 187.5 ms  |
 | :::                                                  | 12 bit           | 0.0625 °C  | 93.75 ms  | | :::                                                  | 12 bit           | 0.0625 °C  | 93.75 ms  |
 +
 +^{{:amc2020:group_n:esp32_ds18b20_breadboard.png?direct&650|Figure 5}}^
 +|**//Figure 5//** ESP32 connected to two DS18B20s, here the DS18B20s have 4 pins, white is the data bus, orange is not used.|
 ===== 4. Programming the DS18B20 ===== ===== 4. Programming the DS18B20 =====
  
Line 311: Line 324:
  
 The first sensor (1) was measuring the room temperature on a rather warm day. The second sensor (2) measured the temperature of my hand. Both measurements seem reasonable and when both sensors measure the room temperature, their results are almost equal. However, the temperature probes need some time to get to thermal equilibrium with their environment. When submerged in the water of the pond continuously, this should not be a problem whatsoever. The first sensor (1) was measuring the room temperature on a rather warm day. The second sensor (2) measured the temperature of my hand. Both measurements seem reasonable and when both sensors measure the room temperature, their results are almost equal. However, the temperature probes need some time to get to thermal equilibrium with their environment. When submerged in the water of the pond continuously, this should not be a problem whatsoever.
 +
 +<html>
 +  <center>
 +    <span>
 +    <a href="javascript:self.scrollTo(0,0)"; onmouseover="style.color='green'";>
 +      <span style="color:#2E71B8"; onmouseover="style.color='green'"; onmouseout="style.color='#2E71B8'";>
 +        Back to the top &#10548
 +      </span>
 +    </a>
 +    </span>
 +  </center>
 +</html>
amc2020/group_n/ds18b20.1595094474.txt.gz · Last modified: 2021/08/24 17:34 (external edit)