Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
DS1620 Class Reference
Example: More...
#include <DS1620.h>
Public Member Functions | |
| float | getTemperature () |
| Get the temperature in degrees Celsius. | |
| float | getHighResolutionTemperature () |
| Get the temperature in degrees Celsius. | |
| unsigned short | readTemperatureRaw () |
| Read the TEMPERATURE REGISTER. | |
| unsigned char | readConfig () |
| Read the CONFIGURATION/STATUS REGISTER. | |
| void | writeConfig (unsigned char config) |
| Write to the CONFIGURATION/STATUS REGISTER. | |
| unsigned short | readTLRaw () |
| Read the TL (Thermostat Low Limit) REGISTER. | |
| void | writeTLRaw (unsigned short temperature) |
| Write to the TL (Thermostat Low Limit) REGISTER. | |
| unsigned short | readTHRaw () |
| Read the TH (Thermostat High Limit) REGISTER. | |
| void | writeTHRaw (unsigned short temperature) |
| Write to the TH (Thermostat High Limit) REGISTER. | |
| unsigned short | readCounter () |
| Read the COUNTER REGISTER. | |
| unsigned short | readSlope () |
| Read the SLOPE REGISTER. | |
| void | loadSlope () |
| Loads the SLOPE REGISTER into the COUNTER REGISTER. | |
| void | startConversion () |
| Starts a temperature conversion. | |
| void | stopConversion () |
| Stops a temperature conversion. | |
| void | setSerialClockFrequency (clock_frequencies_t frequency) |
| Sets the clock frequency for the serial interface. | |
Detailed Description
Example:
// Send the temperature to your computer #include "mbed.h" #include "DS1620.h" DS1620 temperatureSensor(p11, p12, p13); Serial pc(USBTX, USBRX); int main() { //Set mode to CPU & One Shot if it's not already set. if((temperatureSensor.readConfig() & 0x03) != 0x03) { temperatureSensor.writeConfig(0x03); } float temperature = 0.0; while(1) { temperatureSensor.startConversion(); wait(1.0); //Wait for the temperature conversion to complete. You can also poll the DONE flag in the STATUS REGISTER temperature = temperatureSensor.getHighResolutionTemperature(); pc.printf("%.2f C\r\n", temperature); } }
Definition at line 74 of file DS1620.h.
Member Function Documentation
| float getHighResolutionTemperature | ( | ) |
Get the temperature in degrees Celsius.
- Returns:
- The temperature in Celsius calculated using the COUNTER and SLOPE REGISTERS as a float
- Note:
- The DS1620 must be in 1SHOT mode for accurate results.
Definition at line 49 of file DS1620.cpp.
| float getTemperature | ( | ) |
Get the temperature in degrees Celsius.
- Returns:
- The temperature in Celsius with 0.5 degree resolution as a float
Definition at line 38 of file DS1620.cpp.
| void loadSlope | ( | ) |
Loads the SLOPE REGISTER into the COUNTER REGISTER.
Definition at line 187 of file DS1620.cpp.
| unsigned char readConfig | ( | ) |
Read the CONFIGURATION/STATUS REGISTER.
- Returns:
- The value of the CONFIGURATION/STATUS REGISTER
Definition at line 81 of file DS1620.cpp.
| unsigned short readCounter | ( | ) |
| unsigned short readSlope | ( | ) |
| unsigned short readTemperatureRaw | ( | ) |
Read the TEMPERATURE REGISTER.
- Returns:
- The temperature in Celsius with 0.5 degree resolution as stored in the DS1620 registers
Definition at line 66 of file DS1620.cpp.
| unsigned short readTHRaw | ( | ) |
Read the TH (Thermostat High Limit) REGISTER.
- Returns:
- The value to write to the TH (Thermostat High Limit) REGISTER in the DS1620 format
Definition at line 129 of file DS1620.cpp.
| unsigned short readTLRaw | ( | ) |
Read the TL (Thermostat Low Limit) REGISTER.
- Returns:
- The value to write to the TL (Thermostat Low Limit) REGISTER in the DS1620 format
Definition at line 100 of file DS1620.cpp.
| void setSerialClockFrequency | ( | clock_frequencies_t | frequency ) |
Sets the clock frequency for the serial interface.
- Parameters:
-
frequency (freq500k, freq250k, freq125k, freq20k, freq10k, freq1k)
- Note:
- Defaults to 500KHz (freq500k)
Definition at line 208 of file DS1620.cpp.
| void startConversion | ( | ) |
Starts a temperature conversion.
Definition at line 194 of file DS1620.cpp.
| void stopConversion | ( | ) |
Stops a temperature conversion.
Definition at line 201 of file DS1620.cpp.
| void writeConfig | ( | unsigned char | config ) |
Write to the CONFIGURATION/STATUS REGISTER.
- Parameters:
-
config The value to write to the CONFIGURATION/STATUS REGISTER
Definition at line 91 of file DS1620.cpp.
| void writeTHRaw | ( | unsigned short | temperature ) |
Write to the TH (Thermostat High Limit) REGISTER.
- Parameters:
-
temperature The value to write to the TH (Thermostat High Limit) REGISTER in the DS1620 format
Definition at line 144 of file DS1620.cpp.
| void writeTLRaw | ( | unsigned short | temperature ) |
Write to the TL (Thermostat Low Limit) REGISTER.
- Parameters:
-
temperature The value to write to the TL (Thermostat Low Limit) REGISTER in the DS1620 format
Definition at line 115 of file DS1620.cpp.
Generated on Sat Jul 16 2022 05:13:57 by
1.7.2