Skip to content

Commit 96ef29f

Browse files
committedFeb 20, 2022
Added check for attached Weatherbit sensor, and start simulated weather if none attached
1 parent a1107f1 commit 96ef29f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed
 

‎pxt.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
],
2323
"public": true,
2424
"targetVersions": {
25-
"target": "4.0.16",
25+
"target": "4.0.17",
2626
"targetId": "microbit"
2727
},
2828
"supportedTargets": [

‎weatherbit.ts

+12
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ namespace weatherbit {
4040

4141
// BME280 Addresses
4242
const bmeAddr = 0x76
43+
const bmeId = 0xD0
4344
const ctrlHum = 0xF2
4445
const ctrlMeas = 0xF4
4546
const config = 0xF5
@@ -460,6 +461,17 @@ namespace weatherbit {
460461
export function startWeatherMonitoring(): void {
461462
if (weatherMonitorStarted) return;
462463

464+
//Check if there is a BME attached - and simulate weather if not
465+
let id = readBMEReg(bmeId,NumberFormat.UInt8LE)
466+
if (id==0) {
467+
basic.showString("SIM!")
468+
simWeather()
469+
}
470+
else {
471+
basic.showString("ID=")
472+
basic.showNumber(id)
473+
}
474+
463475
// The 0xE5 register is 8 bits where 4 bits go to one value and 4 bits go to another
464476
let e5Val = 0
465477

0 commit comments

Comments
 (0)
Please sign in to comment.