mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-30 14:16:32 +00:00
Merge pull request #4738 from phreakmonkey/ds18b20_pullup
Add INPUT_PULLUP option for single DS18B20
This commit is contained in:
commit
6f5596425c
@ -283,6 +283,7 @@
|
|||||||
//#define USE_DS18x20_LEGACY // Optional for more than one DS18x20 sensors with dynamic scan using library OneWire (+1k5 code)
|
//#define USE_DS18x20_LEGACY // Optional for more than one DS18x20 sensors with dynamic scan using library OneWire (+1k5 code)
|
||||||
#define USE_DS18x20 // Optional for more than one DS18x20 sensors with id sort, single scan and read retry (+1k3 code)
|
#define USE_DS18x20 // Optional for more than one DS18x20 sensors with id sort, single scan and read retry (+1k3 code)
|
||||||
// #define W1_PARASITE_POWER // If using USE_DS18x20 then optimize for parasite powered sensors
|
// #define W1_PARASITE_POWER // If using USE_DS18x20 then optimize for parasite powered sensors
|
||||||
|
// #define DS18B20_INTERNAL_PULLUP // Use INPUT_PULLUP internal pullup resistors for single DS18B20
|
||||||
|
|
||||||
// -- I2C sensors ---------------------------------
|
// -- I2C sensors ---------------------------------
|
||||||
#define USE_I2C // I2C using library wire (+10k code, 0k2 mem, 124 iram)
|
#define USE_I2C // I2C using library wire (+10k code, 0k2 mem, 124 iram)
|
||||||
|
@ -42,7 +42,11 @@ uint8_t OneWireReset(void)
|
|||||||
uint8_t retries = 125;
|
uint8_t retries = 125;
|
||||||
|
|
||||||
//noInterrupts();
|
//noInterrupts();
|
||||||
|
#ifdef DS18B20_INTERNAL_PULLUP
|
||||||
|
pinMode(ds18x20_pin, INPUT_PULLUP);
|
||||||
|
#else
|
||||||
pinMode(ds18x20_pin, INPUT);
|
pinMode(ds18x20_pin, INPUT);
|
||||||
|
#endif
|
||||||
do {
|
do {
|
||||||
if (--retries == 0) {
|
if (--retries == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -52,7 +56,11 @@ uint8_t OneWireReset(void)
|
|||||||
pinMode(ds18x20_pin, OUTPUT);
|
pinMode(ds18x20_pin, OUTPUT);
|
||||||
digitalWrite(ds18x20_pin, LOW);
|
digitalWrite(ds18x20_pin, LOW);
|
||||||
delayMicroseconds(480);
|
delayMicroseconds(480);
|
||||||
|
#ifdef DS18B20_INTERNAL_PULLUP
|
||||||
|
pinMode(ds18x20_pin, INPUT_PULLUP);
|
||||||
|
#else
|
||||||
pinMode(ds18x20_pin, INPUT);
|
pinMode(ds18x20_pin, INPUT);
|
||||||
|
#endif
|
||||||
delayMicroseconds(70);
|
delayMicroseconds(70);
|
||||||
uint8_t r = !digitalRead(ds18x20_pin);
|
uint8_t r = !digitalRead(ds18x20_pin);
|
||||||
//interrupts();
|
//interrupts();
|
||||||
@ -81,7 +89,11 @@ uint8_t OneWireReadBit(void)
|
|||||||
pinMode(ds18x20_pin, OUTPUT);
|
pinMode(ds18x20_pin, OUTPUT);
|
||||||
digitalWrite(ds18x20_pin, LOW);
|
digitalWrite(ds18x20_pin, LOW);
|
||||||
delayMicroseconds(3);
|
delayMicroseconds(3);
|
||||||
|
#ifdef DS18B20_INTERNAL_PULLUP
|
||||||
|
pinMode(ds18x20_pin, INPUT_PULLUP);
|
||||||
|
#else
|
||||||
pinMode(ds18x20_pin, INPUT);
|
pinMode(ds18x20_pin, INPUT);
|
||||||
|
#endif
|
||||||
delayMicroseconds(10);
|
delayMicroseconds(10);
|
||||||
uint8_t r = digitalRead(ds18x20_pin);
|
uint8_t r = digitalRead(ds18x20_pin);
|
||||||
//interrupts();
|
//interrupts();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user