HOME

PROJECTS

TUTORIALS

C FUNCTIONS

PROGRAMS

PRODUCTS

VIDEOS

COMPANY

SPANISH

                 

ANSI C function to read temperature sensor DS18B20

 

 

ds18b20v.jpg (103027 bytes)

 

TEMPERATURE SENSOR DS18B20

The Bolt 18F2550 system includes a novel  digital temperature sensor, manufactured by Dallas Semiconductor (DS18B20) with an encapsulation similar to a small signal transistor and having only three pins, two of which are connected to 5v. and GND, respectively.

The DS18B20 sensor has an output at its pin 2, through which it communicates with the microcontroller 18F2550, bit RA3 port A.

Its temperature range is -55 to +125 degrees Celsius, with a resolution of 0.1 degrees. The technical specification of the circuit can be obtained here: DS18B20.pdf.

 

 

ANSI C FUNCTION TO READ THE SENSOR DS18B20 ON CARD:

The DS18B20 digital temperature sensor, has a range -55 to +125 degrees Celsius. This sensor has a versatile communications protocol called "Onewire", whereby it is possible to communicate bidirectionally only with the circuit through one of its pins.

Library ONEWIRE-BOLT.h provides ANSI C C18 function that handles the DS18B20. This function returns the value of the temperature measured by the sensor, in a floating point variable in two integers and a decimal. The sensor DS18B20 is connected to pin RA3 18F2550 microcontroller. Format of this function is:

z=ds1820_read( );

 

to92.png (9028 bytes)

 

 

 

TEST PROGRAM IN C18

Test program C18-BOLT-DS18B20-FARENHEIT.c calls the function specified above and displays the result directly on the LCD display 16 x 1, as shown in the photo. Load the executable program C18-BOLT-DS18B20-FARENHEIT.hex in the system and observe the temperature on the LCD.

Since the result is a variable in floating point format, many process control applications may be developed with this function, particularly temperature control.

See here all test programs for Bolt:

C18-Bolt-18F2550-All-Test-Programs.zip