TOP Contributors

  1. MIKROE (2784 codes)
  2. Alcides Ramos (392 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (123 codes)
  5. Bugz Bensce (97 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (140544 times)
  2. FAT32 Library (73037 times)
  3. Network Ethernet Library (58043 times)
  4. USB Device Library (48215 times)
  5. Network WiFi Library (43826 times)
  6. FT800 Library (43295 times)
  7. GSM click (30359 times)
  8. mikroSDK (28987 times)
  9. PID Library (27116 times)
  10. microSD click (26721 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
Library

DS18X20 One Wire Library

Rating:

5

Author: Richard Lowe

Last Updated: 2013-09-19

Package Version: 1.0.0.3

Category: Measurement

Downloaded: 3479 times

Followed by: 1 user

License: MIT license  

Easily add DS18x20 sensor functions to your project.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "DS18X20 One Wire Library" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "DS18X20 One Wire Library" changes.

Do you want to report abuse regarding "DS18X20 One Wire Library".

  • Information
  • Comments (0)

Library Blog


This is the first version.  This library assumes that it is the only sensor on the bus.  Sensor addressing is not yet supported.


Requirements: stdbool ( boolean definition file ) found on libstock


To use this library, you will need to edit the header file and define your port and pin.

Example:
//#define DS18X20_BASE_ADDRESS    &PORTA
//#define DS18X20_PIN             3
#define DS18X20_BASE_ADDRESS    &GPIOA_BASE
#define DS18X20_PIN             3

The example file included shows 2 different methods the library supports, polled and immediate.

Temp sensors are SLOW.  On a 8Mhz AVR with resolution set at 10 you will achieve 5-6 readings per second.  If the reading is not critical, then using the polled method works best.

There is also a formatted string function: ds18x20_get_str_temp( DS18X20_MODE_C ); that produces a formatted string based on MODE_C or MODE_F.

UPDATE:

Forgot about compiling into a library and macros....

This new version has a different initialization:

Example:

#include "ds18x20.h"

#define msg( txt ) UART1_Write_Text( txt )

void main() 
{
    ds18x20_config_t sensor;
    char txt_buffer[50];
    
    sensor.port = &PORTA;
    sensor.pin = 7;
    sensor.resolution = RES12;
    sensor.alarm_high = 0x22;
    sensor.alarm_low = 0x01;
    
    UART1_Init( 38400 );
    Delay_ms( 100 );
    
    ds18x20_init( &sensor );
    
    while(1)
    {
        sprintf( txt_buffer, "Temp is: %f\r\n", ds18x20_get_temp() );
        msg( txt_buffer );
        Delay_ms( 1000 );
    }

}

ALSO FROM THIS AUTHOR

RTC 1307 Library

10

Makes easy addition of ds1307 RTC.

[Learn More]

Dynamic List Library

5

Dynamic double linked list library that is not only fast but efficient.

[Learn More]

BarGraph Library

5

BarGraphs are wonderful for visual feedback. This library makes it easy to add one. Based on BarGraph click board.

[Learn More]