TOP Contributors

  1. MIKROE (2784 codes)
  2. Alcides Ramos (404 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (132 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 (141030 times)
  2. FAT32 Library (73566 times)
  3. Network Ethernet Library (58376 times)
  4. USB Device Library (48558 times)
  5. Network WiFi Library (44177 times)
  6. FT800 Library (43712 times)
  7. GSM click (30582 times)
  8. mikroSDK (29353 times)
  9. PID Library (27224 times)
  10. microSD click (26969 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: 3532 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

ST EEPROM Emulation

5

Adaptation of STs' EEPROM Emulator to MikroC.

[Learn More]

Add Standard bool / true / false to MikroC

0

This is not my library, but a opensource header file that adds boolean datatype to MikroC. Copy this file to the ../Mikroeleckronika/"your ide"/include/ directory. In your project that will use boolean types include this line: #include <stdbool.h>

[Learn More]

RTC 1307 Library

10

Makes easy addition of ds1307 RTC.

[Learn More]