-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc8a517
commit 91a1b3c
Showing
10 changed files
with
200 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include "RTC.h" | ||
#include "GPIO.h" | ||
#include "OWI.h" | ||
#include "Software/OWI.h" | ||
#include "Driver/DS18B20.h" | ||
|
||
#if defined(ARDUINO_attiny) | ||
#include "Software/Serial.h" | ||
Software::Serial<BOARD::D0> Serial; | ||
Software::OWI<BOARD::D1> owi; | ||
#else | ||
Software::OWI<BOARD::D7> owi; | ||
#endif | ||
|
||
DS18B20 sensor(owi); | ||
RTC rtc; | ||
|
||
void setup() | ||
{ | ||
Serial.begin(57600); | ||
while (!Serial); | ||
|
||
// Set sensor alarm triggers (20..25 C) and resolution (10 bits) | ||
// Iterate though all thermometers and configure. | ||
uint8_t* rom = sensor.rom(); | ||
int8_t last = owi.FIRST; | ||
do { | ||
last = owi.search_rom(sensor.FAMILY_CODE, rom, last); | ||
if (last == owi.ERROR) break; | ||
sensor.resolution(10); | ||
sensor.set_trigger(20, 25); | ||
sensor.write_scratchpad(); | ||
} while (last != owi.LAST); | ||
} | ||
|
||
void loop() | ||
{ | ||
// Check if any thermometer sersors have exceeded thresholds. | ||
// Broadcast a convert request to all thermometer sensors. | ||
// Print timestamp and sensor identity and temperature. | ||
|
||
int8_t last = owi.FIRST; | ||
uint8_t* rom = sensor.rom(); | ||
bool triggered = false; | ||
|
||
if (!rtc.tick()) return; | ||
if (!sensor.convert_request(true)) return; | ||
do { | ||
last = owi.alarm_search(rom, last); | ||
if (last == owi.ERROR) break; | ||
sensor.read_scratchpad(false); | ||
if (!triggered) { | ||
char daytime[32]; | ||
struct tm now; | ||
rtc.get_time(now); | ||
isotime_r(&now, daytime); | ||
Serial.print(daytime + 11); | ||
triggered = true; | ||
} | ||
Serial.print(F(", ")); | ||
for (size_t i = 1; i < owi.ROM_MAX - 1; i++) { | ||
if (rom[i] < 0x10) Serial.print(0); | ||
Serial.print(rom[i], HEX); | ||
} | ||
Serial.print(F(", ")); | ||
Serial.print(sensor.temperature()); | ||
} while (last != owi.LAST); | ||
if (triggered) Serial.println(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name=Arduino-OWI | ||
version=1.4 | ||
version=1.5 | ||
author=Mikael Patel | ||
maintainer=Mikael Patel <[email protected]> | ||
sentence=One-Wire Interface (OWI) library for Arduino. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.