Skip to content

DS18B20 temperature sensor library for AVR microcontroller

License

Notifications You must be signed in to change notification settings

radionoise/avr-ds18b20

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DS18B20 library for AVR microcontroller

Overview

This library was tested on ATmega 16 @ 8 MHz.

Features

  • Search ROM functionality.
  • Match ROM and Skip ROM functions.
  • Configuration (resolution, TH and TL thresholds) read/write/load from EEPROM/save to EEPROM functionality.

Example

Ds18b20Port port = {&DDRA, &PORTA, &PINA, PIN0};
Ds18b20Port *portPtr = &port;

uint8_t deviceCount = 10;
uint64_t *roms = malloc(deviceCount * sizeof(uint64_t));
ds18b20SearchRom(roms, deviceCount, portPtr);

for (int count = 0; count < deviceCount; count++) {
    if (roms[count] != DS18B20_NOT_FOUND_ROM && roms[count] != DS18B20_ROM_CRC_ERROR) {
        float temperature = ds18b20ReadTemperatureMatchRom(roms[count], portPtr);
        if (temperature != DS18B20_TEMPERATURE_CRC_ERROR) {
            // do something
        }
    }
}

free(roms);

About

DS18B20 temperature sensor library for AVR microcontroller

Resources

License

Stars

Watchers

Forks

Packages

No packages published