DS1820
Fork of DS1820 by
DS1820 Class Reference
DS1820 Dallas 1-Wire Temperature Probe. More...
#include <DS1820.h>
Public Member Functions | |
DS1820 (PinName data_pin, PinName power_pin=NC, bool power_polarity=0) | |
Create a probe object connected to the specified pins. | |
int | convertTemperature (bool wait, devices device=all_devices) |
This routine will initiate the temperature conversion within one or all DS1820 probes. | |
float | temperature (char scale='c') |
This function will return the probe temperature. | |
bool | setResolution (unsigned int resolution) |
This function sets the temperature resolution for the DS18B20 in the configuration register. | |
Static Public Member Functions | |
static bool | unassignedProbe (PinName pin) |
Function to see if there are DS1820 devices left on a pin which do not have a corresponding DS1820 object. |
Detailed Description
DS1820 Dallas 1-Wire Temperature Probe.
Example:
#include "mbed.h" #include "DS1820.h" DS1820 probe(DATA_PIN); int main() { while(1) { probe.convertTemperature(true, DS1820::all_devices); //Start temperature conversion, wait until ready printf("It is %3.1foC\r\n", probe.temperature()); wait(1); } }
Definition at line 52 of file DS1820.h.
Constructor & Destructor Documentation
DS1820 | ( | PinName | data_pin, |
PinName | power_pin = NC , |
||
bool | power_polarity = 0 |
||
) |
Create a probe object connected to the specified pins.
The probe might either by regular powered or parasite powered. If it is parasite powered and power_pin is set, that pin will be used to switch an external mosfet connecting data to Vdd. If it is parasite powered and the pin is not set, the regular data pin is used to supply extra power when required. This will be sufficient as long as the number of probes is limitted.
- Parameters:
-
data_pin DigitalInOut pin for the data bus power_pin DigitalOut (optional) pin to control the power MOSFET power_polarity bool (optional) which sets active state (0 for active low (default), 1 for active high)
Definition at line 6 of file DS1820.cpp.
Member Function Documentation
int convertTemperature | ( | bool | wait, |
devices | device = all_devices |
||
) |
This routine will initiate the temperature conversion within one or all DS1820 probes.
- Parameters:
-
wait if true or parisitic power is used, waits up to 750 ms for conversion otherwise returns immediatly. device allows the function to apply to a specific device or to all devices on the 1-Wire bus.
- Returns:
- milliseconds untill conversion will complete.
Definition at line 266 of file DS1820.cpp.
bool setResolution | ( | unsigned int | resolution ) |
This function sets the temperature resolution for the DS18B20 in the configuration register.
- Parameters:
-
a number between 9 and 12 to specify resolution
- Returns:
- true if successful
Definition at line 321 of file DS1820.cpp.
float temperature | ( | char | scale = 'c' ) |
This function will return the probe temperature.
Approximately 10ms per probe to read its RAM, do CRC check and convert temperature on the LPC1768.
- Parameters:
-
scale,may be either 'c' or 'f'
- Returns:
- temperature for that scale, or DS1820::invalid_conversion (-1000) if CRC error detected.
Definition at line 346 of file DS1820.cpp.
bool unassignedProbe | ( | PinName | pin ) | [static] |
Function to see if there are DS1820 devices left on a pin which do not have a corresponding DS1820 object.
- Returns:
- - true if there are one or more unassigned devices, otherwise false
Definition at line 94 of file DS1820.cpp.
Generated on Thu Jul 14 2022 20:30:59 by 1.7.2