github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/examples/temp/temp.go (about) 1 // Read the internal temperature sensor of the chip. 2 3 package main 4 5 import ( 6 "fmt" 7 "machine" 8 "time" 9 ) 10 11 type celsius float32 12 13 func (c celsius) String() string { 14 return fmt.Sprintf("%4.1f℃", c) 15 } 16 17 func main() { 18 for { 19 temp := celsius(float32(machine.ReadTemperature()) / 1000) 20 println("temperature:", temp.String()) 21 time.Sleep(time.Second) 22 } 23 }