File tree 2 files changed +13
-0
lines changed
2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change 283
283
//#define USE_DS18x20_LEGACY // Optional for more than one DS18x20 sensors with dynamic scan using library OneWire (+1k5 code)
284
284
#define USE_DS18x20 // Optional for more than one DS18x20 sensors with id sort, single scan and read retry (+1k3 code)
285
285
// #define W1_PARASITE_POWER // If using USE_DS18x20 then optimize for parasite powered sensors
286
+ // #define DS18B20_INTERNAL_PULLUP // Use INPUT_PULLUP internal pullup resistors for single DS18B20
286
287
287
288
// -- I2C sensors ---------------------------------
288
289
#define USE_I2C // I2C using library wire (+10k code, 0k2 mem, 124 iram)
Original file line number Diff line number Diff line change @@ -42,7 +42,11 @@ uint8_t OneWireReset(void)
42
42
uint8_t retries = 125 ;
43
43
44
44
// noInterrupts();
45
+ #ifdef DS18B20_INTERNAL_PULLUP
46
+ pinMode (ds18x20_pin, INPUT_PULLUP);
47
+ #else
45
48
pinMode (ds18x20_pin, INPUT);
49
+ #endif
46
50
do {
47
51
if (--retries == 0 ) {
48
52
return 0 ;
@@ -52,7 +56,11 @@ uint8_t OneWireReset(void)
52
56
pinMode (ds18x20_pin, OUTPUT);
53
57
digitalWrite (ds18x20_pin, LOW);
54
58
delayMicroseconds (480 );
59
+ #ifdef DS18B20_INTERNAL_PULLUP
60
+ pinMode (ds18x20_pin, INPUT_PULLUP);
61
+ #else
55
62
pinMode (ds18x20_pin, INPUT);
63
+ #endif
56
64
delayMicroseconds (70 );
57
65
uint8_t r = !digitalRead (ds18x20_pin);
58
66
// interrupts();
@@ -81,7 +89,11 @@ uint8_t OneWireReadBit(void)
81
89
pinMode (ds18x20_pin, OUTPUT);
82
90
digitalWrite (ds18x20_pin, LOW);
83
91
delayMicroseconds (3 );
92
+ #ifdef DS18B20_INTERNAL_PULLUP
93
+ pinMode (ds18x20_pin, INPUT_PULLUP);
94
+ #else
84
95
pinMode (ds18x20_pin, INPUT);
96
+ #endif
85
97
delayMicroseconds (10 );
86
98
uint8_t r = digitalRead (ds18x20_pin);
87
99
// interrupts();
You can’t perform that action at this time.
0 commit comments