From f3721c494d041bccbac040d05ae2dc7bbd4ee144 Mon Sep 17 00:00:00 2001 From: Rob Tillaart Date: Thu, 19 Oct 2023 17:22:34 +0200 Subject: [PATCH] 0.2.1 DS18B20_RT --- libraries/DS18B20_RT/CHANGELOG.md | 7 ++ libraries/DS18B20_RT/README.md | 15 +++ .../oneWireScanner/oneWireScanner.ino | 99 +++++++++++++++++++ .../examples/oneWireSearch/oneWireSearch.ino | 35 ++++++- libraries/DS18B20_RT/library.json | 4 +- libraries/DS18B20_RT/library.properties | 2 +- libraries/DS18B20_RT/src/DS18B20.cpp | 2 +- libraries/DS18B20_RT/src/DS18B20.h | 4 +- 8 files changed, 158 insertions(+), 10 deletions(-) create mode 100644 libraries/DS18B20_RT/examples/oneWireScanner/oneWireScanner.ino diff --git a/libraries/DS18B20_RT/CHANGELOG.md b/libraries/DS18B20_RT/CHANGELOG.md index 35450e89..8787b23b 100644 --- a/libraries/DS18B20_RT/CHANGELOG.md +++ b/libraries/DS18B20_RT/CHANGELOG.md @@ -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/). +## [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 - fix #24 - remove resolution parameter from constructor. - refactor code to keep in sync with DS18B20_INT diff --git a/libraries/DS18B20_RT/README.md b/libraries/DS18B20_RT/README.md index e513a8c2..ec49fd9f 100644 --- a/libraries/DS18B20_RT/README.md +++ b/libraries/DS18B20_RT/README.md @@ -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-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) +[![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) [![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 @@ -28,7 +31,9 @@ added a number of Arduino examples to help you get started. This library is related to - 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/issues/244#event-9253126638 ## Interface @@ -183,6 +188,8 @@ and all people who contributed to that lib. - add examples - investigate performance gain of no CRC. +- Extend oneWireSearch with devicetypes + - see oneWireScanner.ino (2016 version) #### Could @@ -192,3 +199,11 @@ and all people who contributed to that lib. - 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, + diff --git a/libraries/DS18B20_RT/examples/oneWireScanner/oneWireScanner.ino b/libraries/DS18B20_RT/examples/oneWireScanner/oneWireScanner.ino new file mode 100644 index 00000000..23632990 --- /dev/null +++ b/libraries/DS18B20_RT/examples/oneWireScanner/oneWireScanner.ino @@ -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 + +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 -- + diff --git a/libraries/DS18B20_RT/examples/oneWireSearch/oneWireSearch.ino b/libraries/DS18B20_RT/examples/oneWireSearch/oneWireSearch.ino index 281f772a..2ba14a06 100644 --- a/libraries/DS18B20_RT/examples/oneWireSearch/oneWireSearch.ino +++ b/libraries/DS18B20_RT/examples/oneWireSearch/oneWireSearch.ino @@ -1,14 +1,31 @@ // // FILE: oneWireSearch.ino // AUTHOR: Rob Tillaart +// VERSION: 0.1.5 // PURPOSE: scan for 1-Wire devices + code snippet generator // DATE: 2015-june-30 // URL: https://github.com/RobTillaart/DS18B20_RT // URL: http://forum.arduino.cc/index.php?topic=333923 // // 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 @@ -18,7 +35,7 @@ void setup() Serial.begin(115200); 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); } @@ -43,7 +60,8 @@ uint8_t findDevices(int pin) Serial.print("\nuint8_t pin"); Serial.print(pin, DEC); Serial.println("[][8] = {"); - do { + do + { count++; Serial.println(" {"); for (uint8_t i = 0; i < 8; i++) @@ -53,7 +71,16 @@ uint8_t findDevices(int pin) Serial.print(address[i], HEX); 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)); Serial.println("};"); @@ -65,5 +92,5 @@ uint8_t findDevices(int pin) } -// -- END OF FILE -- +// -- END OF FILE -- diff --git a/libraries/DS18B20_RT/library.json b/libraries/DS18B20_RT/library.json index 35913bec..c02c1b7d 100644 --- a/libraries/DS18B20_RT/library.json +++ b/libraries/DS18B20_RT/library.json @@ -23,9 +23,9 @@ "version": "^2.3.5" } ], - "version": "0.2.0", + "version": "0.2.1", "license": "MIT", - "frameworks": "arduino", + "frameworks": "*", "platforms": "*", "headers": "DS18B20.h" } diff --git a/libraries/DS18B20_RT/library.properties b/libraries/DS18B20_RT/library.properties index 7fe376bc..ff5087ff 100644 --- a/libraries/DS18B20_RT/library.properties +++ b/libraries/DS18B20_RT/library.properties @@ -1,5 +1,5 @@ name=DS18B20_RT -version=0.2.0 +version=0.2.1 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for the DS18B20 temperature sensor. diff --git a/libraries/DS18B20_RT/src/DS18B20.cpp b/libraries/DS18B20_RT/src/DS18B20.cpp index f34eed6a..2f25ea44 100644 --- a/libraries/DS18B20_RT/src/DS18B20.cpp +++ b/libraries/DS18B20_RT/src/DS18B20.cpp @@ -1,7 +1,7 @@ // // FILE: DS18B20.cpp // AUTHOR: Rob.Tillaart@gmail.com -// VERSION: 0.2.0 +// VERSION: 0.2.1 // DATE: 2017-07-25 // PUPROSE: library for DS18B20 temperature sensor with minimal footprint // URL: https://github.com/RobTillaart/DS18B20_RT diff --git a/libraries/DS18B20_RT/src/DS18B20.h b/libraries/DS18B20_RT/src/DS18B20.h index 9615dcb3..f48f50a5 100644 --- a/libraries/DS18B20_RT/src/DS18B20.h +++ b/libraries/DS18B20_RT/src/DS18B20.h @@ -2,7 +2,7 @@ // // FILE: DS18B20.h // AUTHOR: Rob.Tillaart@gmail.com -// VERSION: 0.2.0 +// VERSION: 0.2.1 // DATE: 2017-07-25 // PUPROSE: library for DS18B20 temperature sensor with minimal footprint // 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