Skip to content

Commit 6281f36

Browse files
jmhobbsdeadprogram
authored andcommitted
MAX6675 example & smoke test
1 parent ccfcfa8 commit 6281f36

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

examples/max6675/main.go

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"machine"
6+
"time"
7+
8+
"tinygo.org/x/drivers/max6675"
9+
)
10+
11+
// example for reading temperature from a thermocouple
12+
func main() {
13+
// Pins are for an Adafruit Feather nRF52840 Express
14+
machine.D5.Configure(machine.PinConfig{Mode: machine.PinOutput})
15+
machine.D5.High()
16+
17+
machine.SPI0.Configure(machine.SPIConfig{
18+
Frequency: 1_000_000,
19+
SCK: machine.SPI0_SCK_PIN,
20+
SDI: machine.SPI0_SDI_PIN,
21+
})
22+
23+
thermocouple := max6675.NewDevice(machine.SPI0, machine.D5)
24+
25+
for {
26+
temp, err := thermocouple.Read()
27+
if err != nil {
28+
println(err)
29+
return
30+
}
31+
fmt.Printf("%0.02f C : %0.02f F\n", temp, (temp*9/5)+32)
32+
time.Sleep(time.Second)
33+
}
34+
}

smoketest.sh

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/mcp9808/mai
139139
tinygo build -size short -o ./build/test.uf2 -target=pico ./examples/tmc2209/main.go
140140
tinygo build -size short -o ./build/test.hex -target=pico ./examples/tmc5160/main.go
141141
tinygo build -size short -o ./build/test.uf2 -target=nicenano ./examples/sharpmem/main.go
142+
tinygo build -size short -o ./build/test.hex -target=feather-nrf52840 ./examples/max6675/main.go
142143
# network examples (espat)
143144
tinygo build -size short -o ./build/test.hex -target=challenger-rp2040 ./examples/net/ntpclient/
144145
# network examples (wifinina)

0 commit comments

Comments
 (0)