Git Product home page Git Product logo

esp32-ds18b20's Introduction

esp32-ds18b20

Docs: couldn't get build status

Introduction

This is a ESP32-compatible C component for the Maxim Integrated DS18B20 Programmable Resolution 1-Wire Digital Thermometer device.

It supports multiple devices on the same 1-Wire bus.

It is written and tested for v2.1, v3.0-3.3 and v4.1-beta1 of the ESP-IDF environment, using the xtensa-esp32-elf toolchain (gcc version 5.2.0).

Dependencies

Requires esp32-owb.

Example

See esp32-ds18b20-example for an example that supports single and multiple devices on a single bus.

This fork has been extended to implement some of the functionality of the example above.

Folder contents

the component esp32-ds18b20 contains two source file in C language ds18b20.c and ds18b20_wrapper.c. these files are located in the root folder.

esp-idf projects are build using cmake. the project build configuration is contained in CMakeLists.txt files that provide set of directives and instructions describing the project's source files and targets (executable, library, or both).

below is short explanation of remaining files in the project folder.

├── doc                         
├── include                     header file directory
│   ├── ds18b20_wrapper.h       the header file for the wrapper component
│   └── ds18b20.h               the header file for the component
├── .gitignore                  describes what files and folders git should ignore
├── .travis.yml                 build rules for creating docs via doxygen
├── CMakeLists.txt              base project cmake file (describes dependencies, include dir and src dir)
├── component.mk                component make file
├── ds18b20_wrapper.c           core src file of the wrapper component
├── ds18b20.c                   core src file of the component
├── Kconfig.projbuild           kconfig description file to add build time vars
├── LICENSE.md                  MIT license file
└── README.md                   this file

for more information on structure and contents of esp-idf projects, please refer to Section Build System of the esp-idf programming guide.

Features

In cooperation with the underlying esp32-owb component, this component includes:

  • External power supply mode.
  • Parasitic power mode (VDD and GND connected) - see notes below.
  • Static (stack-based) or dynamic (malloc-based) memory model.
  • No globals - support any number of DS18B20 devices on any number of 1-Wire buses simultaneously.
  • 1-Wire device detection and validation, including search for multiple devices on a single bus.
  • Addressing optimisation for a single (solo) device on a bus.
  • CRC checks on temperature data.
  • Programmable temperature measurement resolution (9, 10, 11 or 12-bit resolution).
  • Temperature conversion and retrieval.
  • Separation of conversion and temperature retrieval to allow for simultaneous conversion across multiple devices.

Parasitic Power Mode

Consult the datasheet for more detailed information about Parasitic Power mode.

Parasitic power operation can be detected by ds18b20_check_for_parasite_power() followed by a call to owb_use_parasitic_power(), or simply set explicitly by a call to the latter.

This library has been tested on the ESP32 with two parasitic-power configurations, with two DS18B20 devices at 3.3V:

  1. Disconnect power to each device's VDD pin, and connect that pin to GND for each device. Power is supplied to each device through the OWB data line.
  2. Connect the OWB data line to VCC via a P-channel MOSFET (e.g. BS250) and current-limiting resistor (e.g. 270 Ohm). Ensure your code calls owb_use_strong_pullup_gpio() with the GPIO connected to the MOSFET Gate. The GPIO will go high during temperature conversion, turning on the MOSFET and providing power from VCC to each device through the OWB data line.

If you set up configuration 1 and do not see CRC errors, but you get incorrect temperature readings around 80 - 85 degrees C, then it is likely that your DS18B20 devices are running out of power during the temperature conversion. In this case, consider reducing the value of the pull-up resistor. For example, I have had success obtaining correct conversions from two parasitic DS18B20 devices by replacing the 4k7 Ohm pull-up resistor with a 1 kOhm resistor.

Alternatively, consider using configuration 2.

Note that use of parasitic power mode disables the ability for devices on the bus to signal that an operation has completed. This means that DS18B20 devices in parasitic power mode are not able to communicate when they have completed a temperature conversion. In this mode, a delay for a pre-calculated duration occurs, and then the conversion result is read from the device(s). If your ESP32 is not running on the correct clock rate, this duration may be too short!

Documentation

Automatically generated API documentation (doxygen) is available here.

License

The code in this project is licensed under the MIT license - see LICENSE for details.

Links

Acknowledgements

Parts of this code are based on references provided to the public domain by Maxim Integrated.

"1-Wire" is a registered trademark of Maxim Integrated.

esp32-ds18b20's People

Contributors

abraha2d avatar chmorgan avatar davidantliff avatar lukecyca avatar wolffshots avatar

esp32-ds18b20's Issues

refactor out whatever isn't used

ideally i want the core components to be stripped down and separated out as well as the wrapper
this will probably only happen at the end of my project or if flash becomes an issue

access temp from outside component

we have two option for interfacing with the temp component from a separate main src file:

  • setting a global var/vars for them (not ideal)
  • returning the temp var/vars
  • creating an appropriately sized var and passing the pointer to the read function (probably best bet)

fix travis cd for docs

the travis cd job to generate docs needs my github token to publish them to github pages

once this is complete - uncomment line to link to the pages page in the readme

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.