-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- DS18B20 - BME280 (I2C) - DHT11
- Loading branch information
Showing
9 changed files
with
151 additions
and
15 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,9 @@ | ||
// Copyright (C) 2025 Toitware ApS. | ||
// Use of this source code is governed by a Zero-Clause BSD license that can | ||
// be found in the tests/LICENSE file. | ||
import .test | ||
|
||
main: | ||
// We just have a board1 test, so that the actual test runs on board2. | ||
run-test: print "nothing to do" |
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,26 @@ | ||
// Copyright (C) 2025 Toitware ApS. | ||
// Use of this source code is governed by a Zero-Clause BSD license that can | ||
// be found in the tests/LICENSE file. | ||
import bme280 | ||
import expect show * | ||
import gpio | ||
import i2c | ||
|
||
import .test | ||
|
||
main: | ||
run-test: test | ||
|
||
test: | ||
scl := gpio.Pin 32 | ||
sda := gpio.Pin 33 | ||
bus := i2c.Bus --scl=scl --sda=sda | ||
device := bus.device bme280.I2C-ADDRESS-ALT | ||
driver := bme280.Driver device | ||
|
||
2.repeat: | ||
temperature := driver.read-temperature | ||
print temperature | ||
expect 12 < temperature < 35 | ||
sleep --ms=200 |
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,9 @@ | ||
// Copyright (C) 2025 Toitware ApS. | ||
// Use of this source code is governed by a Zero-Clause BSD license that can | ||
// be found in the tests/LICENSE file. | ||
import .test | ||
|
||
main: | ||
// We just have a board1 test, so that the actual test runs on board2. | ||
run-test: print "nothing to do" |
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,23 @@ | ||
// Copyright (C) 2025 Toitware ApS. | ||
// Use of this source code is governed by a Zero-Clause BSD license that can | ||
// be found in the tests/LICENSE file. | ||
import expect show * | ||
import gpio | ||
import dhtxx.dht11 | ||
|
||
import .test | ||
|
||
main: | ||
run-test: test | ||
|
||
test: | ||
data := gpio.Pin 14 | ||
driver := dht11.Dht11 data | ||
|
||
2.repeat: | ||
measurements := driver.read | ||
print measurements | ||
expect 12 < measurements.temperature < 35 | ||
expect 15 < measurements.humidity < 80 | ||
sleep --ms=500 |
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,9 @@ | ||
// Copyright (C) 2025 Toitware ApS. | ||
// Use of this source code is governed by a Zero-Clause BSD license that can | ||
// be found in the tests/LICENSE file. | ||
import .test | ||
|
||
main: | ||
// We just have a board1 test, so that the actual test runs on board2. | ||
run-test: print "nothing to do" |
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,22 @@ | ||
// Copyright (C) 2025 Toitware ApS. | ||
// Use of this source code is governed by a Zero-Clause BSD license that can | ||
// be found in the tests/LICENSE file. | ||
import ds18b20 | ||
import expect show * | ||
import gpio | ||
|
||
import .test | ||
|
||
main: | ||
run-test: test | ||
|
||
test: | ||
data := gpio.Pin 15 | ||
driver := ds18b20.Ds18b20 data | ||
|
||
2.repeat: | ||
temperature := driver.read-temperature | ||
print temperature | ||
expect 12 < temperature < 35 | ||
sleep --ms=200 |
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,4 +1,13 @@ | ||
dependencies: | ||
bme280: | ||
url: github.com/toitware/bme280-driver | ||
version: ^1.1.0 | ||
dhtxx: | ||
url: github.com/toitware/toit-dhtxx | ||
version: ^1.4.0 | ||
ds18b20: | ||
url: github.com/toitware/toit-ds18b20 | ||
version: ^2.1.0 | ||
hc_sr04: | ||
url: github.com/lask/toit-hc-sr04 | ||
version: ^2.1.1 |