0.2.1 DS18B20_RT

This commit is contained in:
Rob Tillaart 2023-10-19 17:22:34 +02:00
parent d1f3f2f1b9
commit f3721c494d
8 changed files with 158 additions and 10 deletions

View File

@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/). and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.2.1] - 2023-10-19
- update readme.md
- add oneWireScanner.ino example
- add oneWireSearch.ino example
- minor edits
## [0.2.0] - 2023-03-05 ## [0.2.0] - 2023-03-05
- fix #24 - remove resolution parameter from constructor. - fix #24 - remove resolution parameter from constructor.
- refactor code to keep in sync with DS18B20_INT - refactor code to keep in sync with DS18B20_INT

View File

@ -2,8 +2,11 @@
[![Arduino CI](https://github.com/RobTillaart/DS18B20_RT/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci) [![Arduino CI](https://github.com/RobTillaart/DS18B20_RT/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/DS18B20_RT/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/DS18B20_RT/actions/workflows/arduino-lint.yml) [![Arduino-lint](https://github.com/RobTillaart/DS18B20_RT/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/DS18B20_RT/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/DS18B20_RT/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/DS18B20_RT/actions/workflows/jsoncheck.yml) [![JSON check](https://github.com/RobTillaart/DS18B20_RT/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/DS18B20_RT/actions/workflows/jsoncheck.yml)
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/DS18B20_RT.svg)](https://github.com/RobTillaart/DS18B20_RT/issues)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/DS18B20_RT/blob/master/LICENSE) [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/DS18B20_RT/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/DS18B20_RT.svg?maxAge=3600)](https://github.com/RobTillaart/DS18B20_RT/releases) [![GitHub release](https://img.shields.io/github/release/RobTillaart/DS18B20_RT.svg?maxAge=3600)](https://github.com/RobTillaart/DS18B20_RT/releases)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/DS18B20.svg)](https://registry.platformio.org/libraries/robtillaart/DS18B20)
# DS18B20 # DS18B20
@ -28,7 +31,9 @@ added a number of Arduino examples to help you get started.
This library is related to This library is related to
- https://github.com/RobTillaart/DS18B20_INT - https://github.com/RobTillaart/DS18B20_INT
- https://github.com/RobTillaart/DS18B20_RT
- https://github.com/milesburton/Arduino-Temperature-Control-Library - https://github.com/milesburton/Arduino-Temperature-Control-Library
- https://github.com/milesburton/Arduino-Temperature-Control-Library/issues/244#event-9253126638
## Interface ## Interface
@ -183,6 +188,8 @@ and all people who contributed to that lib.
- add examples - add examples
- investigate performance gain of no CRC. - investigate performance gain of no CRC.
- Extend oneWireSearch with devicetypes
- see oneWireScanner.ino (2016 version)
#### Could #### Could
@ -192,3 +199,11 @@ and all people who contributed to that lib.
- get it working is too time consuming. - get it working is too time consuming.
## Support
If you appreciate my libraries, you can support the development and maintenance.
Improve the quality of the libraries by providing issues and Pull Requests, or
donate through PayPal or GitHub sponsors.
Thank you,

View File

@ -0,0 +1,99 @@
//
// FILE: oneWireScanner.ino
// AUTHOR: Rob Tillaart
// PURPOSE: scan for 1-Wire devices
// DATE: 2016-01-10
// URL: https://github.com/RobTillaart/DS18B20_RT
struct DSdevice
{
byte id;
char type[8];
} DSdevices[] = {
{ 0x01, "DS2401"}, // Silicon Serial Number
{ 0x05, "DS2405"}, // switch
{ 0x10, "DS18S20" }, // Temperature sensor
{ 0x22, "DS18B20" }, // Temperature sensor
{ 0x28, "DS1822" }, // Temperature sensor
{ 0x38, "DS1825" }, // Temperature sensor
};
int DStypeCount = sizeof(DSdevices)/sizeof(DSdevice);
const int startPin = 2;
const int endPin = 20;
#include <OneWire.h>
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
for (uint8_t pin = startPin; pin < endPin; pin++)
{
findDevices(pin);
}
Serial.println("\nDone...\n");
}
void loop()
{
}
uint8_t findDevices(int pin)
{
OneWire ow(pin);
uint8_t address[8];
uint8_t count = 0;
while (ow.search(address))
{
Serial.print("\nscanning pin:\t ");
Serial.println(pin, DEC);
{
count++;
// PRINT ADDRESS FOUND
for (uint8_t i = 0; i < 8; i++)
{
Serial.print("0x");
if (address[i] < 0x10) Serial.print("0");
Serial.print(address[i], HEX);
if (i < 7) Serial.print(", ");
}
Serial.print("\t");
// CHECK CRC
if (ow.crc8(address, 7) == address[7])
{
Serial.print("CRC OK \t");
}
else
{
Serial.println("CRC FAIL\t");
}
// PRINT TYPE
bool unknown = true;
for (uint8_t i = 0; i < DStypeCount; i++)
{
if (address[0] == DSdevices[i].id)
{
Serial.print(DSdevices[i].type);
unknown = false;
break;
}
}
if (unknown) Serial.print("unknown");
}
Serial.println();
}
Serial.print("nr devices found: ");
Serial.println(count);
return count;
}
// -- END OF FILE --

View File

@ -1,14 +1,31 @@
// //
// FILE: oneWireSearch.ino // FILE: oneWireSearch.ino
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// VERSION: 0.1.5
// PURPOSE: scan for 1-Wire devices + code snippet generator // PURPOSE: scan for 1-Wire devices + code snippet generator
// DATE: 2015-june-30 // DATE: 2015-june-30
// URL: https://github.com/RobTillaart/DS18B20_RT // URL: https://github.com/RobTillaart/DS18B20_RT
// URL: http://forum.arduino.cc/index.php?topic=333923 // URL: http://forum.arduino.cc/index.php?topic=333923
// //
// inspired by http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html // inspired by http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html
//
// HISTORY
// 0.1.00 initial version
// 0.1.01 first published version
// 0.1.02 small output changes
// 0.1.03 added more explicit range
// 0.1.04 added CRC check
// 0.1.5 fix do while loop (thanks pzygielo)
// UNO has pin 2..20
// MEGA and others have different range
const int startPin = 2;
const int endPin = 20;
#include <OneWire.h> #include <OneWire.h>
@ -18,7 +35,7 @@ void setup()
Serial.begin(115200); Serial.begin(115200);
Serial.println("//\n// Start oneWireSearch.ino \n//"); Serial.println("//\n// Start oneWireSearch.ino \n//");
for (uint8_t pin = 2; pin < 13; pin++) for (uint8_t pin = startPin; pin < endPin; pin++)
{ {
findDevices(pin); findDevices(pin);
} }
@ -43,7 +60,8 @@ uint8_t findDevices(int pin)
Serial.print("\nuint8_t pin"); Serial.print("\nuint8_t pin");
Serial.print(pin, DEC); Serial.print(pin, DEC);
Serial.println("[][8] = {"); Serial.println("[][8] = {");
do { do
{
count++; count++;
Serial.println(" {"); Serial.println(" {");
for (uint8_t i = 0; i < 8; i++) for (uint8_t i = 0; i < 8; i++)
@ -53,7 +71,16 @@ uint8_t findDevices(int pin)
Serial.print(address[i], HEX); Serial.print(address[i], HEX);
if (i < 7) Serial.print(", "); if (i < 7) Serial.print(", ");
} }
Serial.println(" },"); Serial.print(" },");
// CHECK CRC
if (ow.crc8(address, 7) == address[7])
{
Serial.println("\t\t// CRC OK");
}
else
{
Serial.println("\t\t// CRC FAILED");
}
} while (ow.search(address)); } while (ow.search(address));
Serial.println("};"); Serial.println("};");

View File

@ -23,9 +23,9 @@
"version": "^2.3.5" "version": "^2.3.5"
} }
], ],
"version": "0.2.0", "version": "0.2.1",
"license": "MIT", "license": "MIT",
"frameworks": "arduino", "frameworks": "*",
"platforms": "*", "platforms": "*",
"headers": "DS18B20.h" "headers": "DS18B20.h"
} }

View File

@ -1,5 +1,5 @@
name=DS18B20_RT name=DS18B20_RT
version=0.2.0 version=0.2.1
author=Rob Tillaart <rob.tillaart@gmail.com> author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com> maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for the DS18B20 temperature sensor. sentence=Arduino library for the DS18B20 temperature sensor.

View File

@ -1,7 +1,7 @@
// //
// FILE: DS18B20.cpp // FILE: DS18B20.cpp
// AUTHOR: Rob.Tillaart@gmail.com // AUTHOR: Rob.Tillaart@gmail.com
// VERSION: 0.2.0 // VERSION: 0.2.1
// DATE: 2017-07-25 // DATE: 2017-07-25
// PUPROSE: library for DS18B20 temperature sensor with minimal footprint // PUPROSE: library for DS18B20 temperature sensor with minimal footprint
// URL: https://github.com/RobTillaart/DS18B20_RT // URL: https://github.com/RobTillaart/DS18B20_RT

View File

@ -2,7 +2,7 @@
// //
// FILE: DS18B20.h // FILE: DS18B20.h
// AUTHOR: Rob.Tillaart@gmail.com // AUTHOR: Rob.Tillaart@gmail.com
// VERSION: 0.2.0 // VERSION: 0.2.1
// DATE: 2017-07-25 // DATE: 2017-07-25
// PUPROSE: library for DS18B20 temperature sensor with minimal footprint // PUPROSE: library for DS18B20 temperature sensor with minimal footprint
// URL: https://github.com/RobTillaart/DS18B20_RT // URL: https://github.com/RobTillaart/DS18B20_RT
@ -19,7 +19,7 @@
// //
#define DS18B20_LIB_VERSION (F("0.2.0")) #define DS18B20_LIB_VERSION (F("0.2.1"))
#include <OneWire.h> #include <OneWire.h>