Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/tutorials/hardware/bme280.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ The driver for the BME280 is not part of the standard Toit distribution,
but must be downloaded as package. See the [packages](../../setup/packages)
tutorial for details.

We are using the [bme280](https://pkg.toit.io/package/github.com%2Ftoitware%2Fbme280-driver@v1)
We are using the [bmx280](https://pkg.toit.io/package/github.com%2Ftoit-pkg%2Ftoit-bmx280@v1)
package. To install it, run the following command in your project directory:

```bash
jag pkg install github.com/toitware/bme280-driver@v1
jag pkg install github.com/toit-pkg/toit-bmx280@v1
```

<Note>

You can probably just write `jag pkg install bme280`, but the full ID together
You can probably just write `jag pkg install bmx280`, but the full ID together
with the version is more explicit, and will make sure you get the right package.

</Note>
Expand All @@ -58,7 +58,7 @@ the program whenever you save.

```toit
import i2c
import bme280
import bmx280

main:
bus := i2c.Bus
Expand All @@ -67,9 +67,9 @@ main:

// Use 'I2C-ADDRESS' if your device has address 0x76 (118).
// Use 'I2C-ADDRESS-ALT' if your device has address 0x77 (119).
device := bus.device bme280.I2C-ADDRESS
device := bus.device bmx280.I2C-ADDRESS

driver := bme280.Driver device
driver := bmx280.Driver device

print "$driver.read-temperature C"
print "$driver.read-pressure Pa"
Expand All @@ -81,7 +81,7 @@ main:

The program first instantiates an I2C bus object, which it uses to
get a handle to the device with the BME280 address. It then passes
this device to the BME280 driver. At that point the driver
this device to the BMX280 driver. At that point the driver
configures the sensor.

When `read-temperature`, `read-pressure` and `read-huminity`
Expand Down
8 changes: 6 additions & 2 deletions docs/tutorials/mqtt/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,10 @@ In some cases, the certificate might be given by the server and should be pasted
the sources.

Once we have the root certificates, the client can be created with the `tls`
named constructor as follows:
named constructor. The default TLS port, 8883, uses a certificate signed by
Mosquitto's own certificate authority. Port 8886 uses a certificate issued by
Let's Encrypt that can be verified with the common trusted roots, so we select
that port explicitly:

```toit
import mqtt
Expand All @@ -298,6 +301,7 @@ import encoding.json

CLIENT-ID ::= "toit-tutorial-ID-2023-07-06"
HOST ::= "test.mosquitto.org"
PORT ::= 8886
TOPIC ::= "toit-mqtt/tutorial"

main:
Expand All @@ -308,7 +312,7 @@ main:
decoded := json.decode payload
print "Received value on '$topic': $decoded"
}
client := mqtt.Client.tls --host=HOST --routes=routes
client := mqtt.Client.tls --host=HOST --port=PORT --routes=routes
client.start --client-id=CLIENT-ID

while true:
Expand Down
7 changes: 7 additions & 0 deletions tools/package.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
sdk: ^2.0.0-alpha.196
prefixes:
bme280: github.com/toitware/bme280-driver-1
bmx280: github.com/toit-pkg/toit-bmx280-1
cellular: github.com/toitware/cellular-2
certificate_roots: github.com/toitware/toit-cert-roots-1
cli: github.com/toitlang/pkg-cli-2
Expand Down Expand Up @@ -44,6 +45,12 @@ packages:
sensors: github.com/toitware/toit-sensors-1
url: github.com/lask/toit-hc-sr04
version: 2.3.0
github.com/toit-pkg/toit-bmx280-1:
hash: d1de0a840c125769f28b6ddaa8d446a1dc4b1f22
prefixes:
sensors: github.com/toitware/toit-sensors-1
url: github.com/toit-pkg/toit-bmx280
version: 1.0.0
github.com/toitlang/pkg-cli-2:
hash: 8f58b041d55440916a2527899df505f6c6259b20
prefixes:
Expand Down
3 changes: 3 additions & 0 deletions tools/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ dependencies:
bme280:
url: github.com/toitware/bme280-driver
version: ^1.2.0
bmx280:
url: github.com/toit-pkg/toit-bmx280
version: ^1.0.0
cellular:
url: github.com/toitware/cellular
version: ^2.8.0
Expand Down
1 change: 1 addition & 0 deletions tools/run_snippets.toit
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ DEFAULT-OUTPUT ::= "snippet.toit"

THINGS-THAT-WONT-RUN-ON-SERVER ::= [
"import bme280",
"import bmx280",
"import dhtxx",
"import ds18b20",
"import gpio",
Expand Down
10 changes: 5 additions & 5 deletions tutorial_code/bme280/bme280.toit
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
// be found in the LICENSE_BSD0 file.

import i2c
import bme280
import bmx280

main:
bus := i2c.Bus
--sda=25
--scl=26

// Use 'I2C_ADDRESS' if your device has address 0x76 (118).
// Use 'I2C_ADDRESS_ALT' if your device has address 0x77 (119).
device := bus.device bme280.I2C-ADDRESS
// Use 'I2C-ADDRESS' if your device has address 0x76 (118).
// Use 'I2C-ADDRESS-ALT' if your device has address 0x77 (119).
device := bus.device bmx280.I2C-ADDRESS

driver := bme280.Driver device
driver := bmx280.Driver device

print "$driver.read-temperature C"
print "$driver.read-pressure Pa"
Expand Down
10 changes: 5 additions & 5 deletions tutorial_code/bme280/bme280_alt.toit
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
// be found in the LICENSE_BSD0 file.

import i2c
import bme280
import bmx280

main:
bus := i2c.Bus
--sda=26
--scl=25

// Use 'I2C_ADDRESS' if your device has address 0x76 (118).
// Use 'I2C_ADDRESS_ALT' if your device has address 0x77 (119).
device := bus.device bme280.I2C-ADDRESS-ALT
// Use 'I2C-ADDRESS' if your device has address 0x76 (118).
// Use 'I2C-ADDRESS-ALT' if your device has address 0x77 (119).
device := bus.device bmx280.I2C-ADDRESS-ALT

driver := bme280.Driver device
driver := bmx280.Driver device

print "$driver.read-temperature C"
print "$driver.read-pressure Pa"
Expand Down
10 changes: 5 additions & 5 deletions tutorial_code/bme280/package.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
sdk: ^2.0.0-alpha.196
prefixes:
bme280: github.com/toitware/bme280-driver-1
bmx280: github.com/toit-pkg/toit-bmx280-1
packages:
github.com/toitware/bme280-driver-1:
hash: ca9c6451532139d506299fba8c0915cd3001982e
github.com/toit-pkg/toit-bmx280-1:
hash: d1de0a840c125769f28b6ddaa8d446a1dc4b1f22
prefixes:
sensors: github.com/toitware/toit-sensors-1
url: github.com/toitware/bme280-driver
version: 1.2.0
url: github.com/toit-pkg/toit-bmx280
version: 1.0.0
github.com/toitware/toit-sensors-1:
hash: f9f5662a0f21016259ff6907419e54d00223714a
url: github.com/toitware/toit-sensors
Expand Down
6 changes: 3 additions & 3 deletions tutorial_code/bme280/package.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dependencies:
bme280:
url: github.com/toitware/bme280-driver
version: ^1.2.0
bmx280:
url: github.com/toit-pkg/toit-bmx280
version: ^1.0.0
3 changes: 2 additions & 1 deletion tutorial_code/mqtt_mosquitto/mqtt_v2.toit
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import encoding.json

CLIENT-ID ::= "toit-tutorial-ID-2023-07-06"
HOST ::= "test.mosquitto.org"
PORT ::= 8886
TOPIC ::= "toit-mqtt/tutorial"

main:
Expand All @@ -18,7 +19,7 @@ main:
decoded := json.decode payload
print "Received value on '$topic': $decoded"
}
client := mqtt.Client.tls --host=HOST --routes=routes
client := mqtt.Client.tls --host=HOST --port=PORT --routes=routes
client.start --client-id=CLIENT-ID

while true:
Expand Down