@rkorell Ralf: OK, I have a chance to work on this today - Thanks for your help.
To ease troubleshooting, I have temporarily disabled MMM-Temperature and am only running MMM-BME280. Below are the following:
- Config for this module
- Error as captured using pm2 logs
- Code listing of bme280.js, which is called by the module
Config:
{module: 'MMM-BME280', // https://github.com/awitwicki/MMM-BME280
disabled: false,
position: 'top_right',
config: {
titleText: "Office - MMM-BME280",
updateInterval: 100, //seconds
deviceAddress: "0x38", //0x76 = default
temperatureScaleType: 1, // 0=Celsius
pressureScaleType: 1, // 0 = hPa
} },
Errors [from pm2 logs]:
0|MagicMirror | [2025-04-15 12:57:48.599] [ERROR] exec error: Error: Command failed: python3 ./modules/MMM-BME280/bme280.py 0x38
0|MagicMirror | Traceback (most recent call last):
0|MagicMirror | File “/home/pi/MagicMirror/./modules/MMM-BME280/bme280.py”, line 176, in
0|MagicMirror | main()
0|MagicMirror | File “/home/pi/MagicMirror/./modules/MMM-BME280/bme280.py”, line 171, in main
0|MagicMirror | temperature,pressure,humidity = readBME280All()
0|MagicMirror | File “/home/pi/MagicMirror/./modules/MMM-BME280/bme280.py”, line 82, in readBME280All
0|MagicMirror | bus.write_byte_data(addr, REG_CONTROL_HUM, OVERSAMPLE_HUM)
0|MagicMirror | OSError: [Errno 121] Remote I/O error
0|MagicMirror |
Code for bme280.py:
Module.register("MMM-BME280", {
// Default module config.
defaults: {
updateInterval: 100, // Seconds
titleText: "Home weather",
deviceAddress: "0x76",
temperatureScaleType: 0, // Celsuis
pressureScaleType: 0 // hPa
},
// Define start sequence.
start: function () {
Log.info("Starting module: " + this.name);
this.temperature = 'Loading...';
this.humidity = 'Loading...';
this.pressure = 'Loading...';
this.update();
setInterval(
this.update.bind(this),
this.config.updateInterval * 1000);
},
update: function () {
this.sendSocketNotification('REQUEST', this.config);
},
getStyles: function () {
return ['MMM-BME280.css'];
},
// Override dom generator.
getDom: function () {
var wrapper = document.createElement("div");
var header = document.createElement("div");
var label = document.createTextNode(this.config.titleText);
header.className = 'bme-header';
header.appendChild(label)
wrapper.appendChild(header);
var table = document.createElement("table");
var tbdy = document.createElement('tbody');
for (var i = 0; i < 3; i++) {
var val = "";
var sufix = "";
var icon_img = "";
switch (i) {
case 0:
switch (this.config.temperatureScaleType) {
case 0: // Celsius
val = this.temperature;
sufix = "°C";
break;
case 1: // Fahrenheit
val = Math.round(this.temperature * 9.0 / 5.0 + 32.0);
sufix = "°F";
break;
}
icon_img = "temperature-high";
break;
case 1:
val = this.humidity;
icon_img = "tint";
sufix = "%";
break;
case 2:
switch (this.config.pressureScaleType) {
case 0: // hPa
val = this.pressure;
sufix = " hPa";
break;
case 1: // inHg
val = Math.round(this.pressure * 100 / 33.864) / 100;
sufix = " inHg";
break;
}
icon_img = "tachometer-alt";
break;
}
var tr = document.createElement('tr');
var icon = document.createElement("i");
icon.className = 'fa fa-' + icon_img + ' bme-icon';
var text_div = document.createElement("div");
var text = document.createTextNode(" " + val + sufix);
text_div.className = 'bme-text';
text_div.appendChild(text);
var td = document.createElement('td');
td.className = 'bme-td-icon';
td.appendChild(icon)
tr.appendChild(td)
var td = document.createElement('td');
td.appendChild(text_div)
tr.appendChild(td)
tbdy.appendChild(tr);
}
table.appendChild(tbdy);
wrapper.appendChild(table);
return wrapper;
},
socketNotificationReceived: function (notification, payload) {
if (notification === 'DATA') {
this.temperature = payload.temp;
this.humidity = payload.humidity;
this.pressure = payload.press;
this.updateDom();
}
},
});