<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[AHT20 Humidity + Temperature Sensor]]></title><description><![CDATA[<p dir="auto">Does anyone know of a module that will display the output from AHT20 temperature + humidity sensors? I got these after having used the older DHTxx sensors in the past. These new sensors use I2C, and I have confirmed the sensor is wired up correctly and sending data by using an example script.</p>
<p dir="auto">Now I’d like to get the output on the Magic Mirror. While I do see some modules that read from I2C compatible sensors, I haven’t seen one that reads these.</p>
<p dir="auto">Currently I an working with these two modules, both to no avail:<br />
MMMiTemperature: <a href="https://github.com/Tom-Hirschberger/MMM-Temperature" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/Tom-Hirschberger/MMM-Temperature</a><br />
and<br />
MMM-BME280: <a href="https://github.com/awitwicki/MMM-BME280" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/awitwicki/MMM-BME280</a></p>
]]></description><link>https://forum.magicmirror.builders/topic/19617/aht20-humidity-temperature-sensor</link><generator>RSS for Node</generator><lastBuildDate>Thu, 14 May 2026 14:27:32 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/19617.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 14 Apr 2025 21:19:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to AHT20 Humidity + Temperature Sensor on Thu, 17 Apr 2025 16:47:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rkorell" aria-label="Profile: rkorell">@<bdi>rkorell</bdi></a> – My pleasure.</p>
]]></description><link>https://forum.magicmirror.builders/post/125944</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/125944</guid><dc:creator><![CDATA[JohnGalt]]></dc:creator><pubDate>Thu, 17 Apr 2025 16:47:54 GMT</pubDate></item><item><title><![CDATA[Reply to AHT20 Humidity + Temperature Sensor on Thu, 17 Apr 2025 16:47:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> – Thanks for the reminder, I’ll take a look.</p>
]]></description><link>https://forum.magicmirror.builders/post/125943</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/125943</guid><dc:creator><![CDATA[JohnGalt]]></dc:creator><pubDate>Thu, 17 Apr 2025 16:47:37 GMT</pubDate></item><item><title><![CDATA[Reply to AHT20 Humidity + Temperature Sensor on Thu, 17 Apr 2025 16:34:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/johngalt" aria-label="Profile: JohnGalt">@<bdi>JohnGalt</bdi></a> Really COOL!<br />
Thanks for sharing!<br />
Ralf</p>
]]></description><link>https://forum.magicmirror.builders/post/125942</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/125942</guid><dc:creator><![CDATA[rkorell]]></dc:creator><pubDate>Thu, 17 Apr 2025 16:34:46 GMT</pubDate></item><item><title><![CDATA[Reply to AHT20 Humidity + Temperature Sensor on Thu, 17 Apr 2025 16:34:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/johngalt" aria-label="Profile: JohnGalt">@<bdi>JohnGalt</bdi></a> css, use the developers window</p>
<p dir="auto">see the second link in my signature below</p>
]]></description><link>https://forum.magicmirror.builders/post/125941</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/125941</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Thu, 17 Apr 2025 16:34:05 GMT</pubDate></item><item><title><![CDATA[Reply to AHT20 Humidity + Temperature Sensor on Thu, 17 Apr 2025 16:24:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rkorell" aria-label="Profile: rkorell">@<bdi>rkorell</bdi></a> Yes, I can describe how I arrived at a resolution for my particular problem - which was to replace DHTxx sensors with the more accurate AHT20 temperature and humidity sensors.</p>
<p dir="auto">Caveat: I do not necessarily recommend this for the average person though, because I did not find Magic Mirror modules that natively support this sensor, and as a result had to make changes outside of the config.js and custom.css files. As usual, this puts me at risk of something breaking when the module is updated.</p>
<p dir="auto">The module being used (MMM-Temperature - found at <a href="https://github.com/Tom-Hirschberger/MMM-Temperature" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/Tom-Hirschberger/MMM-Temperature</a>) utilizes python scripts to capture the data from the sensor. While the module is quite complete, with script support for many sensors, I did create a new script in order to use this particular sensor.</p>
<p dir="auto">The sensor is supported by Adafruit (<a href="https://learn.adafruit.com/adafruit-aht20/python-circuitpython" target="_blank" rel="noopener noreferrer nofollow ugc">https://learn.adafruit.com/adafruit-aht20/python-circuitpython</a>), with instructions to install various adafruit libraries including adafruit-ahtx0 (sudo pip3 install adafruit-circuitpython-ahtx0).</p>
<p dir="auto">Using those libraries, your script needs to include the following instructions:</p>
<pre><code>import board
import adafruit_ahtx0
sensor = adafruit_ahtx0.AHTx0(board.I2C())
</code></pre>
<p dir="auto">One of the existing scripts supports I2C sensors using the Adafruit libraries, so it looked like a good candidate to use as a model. See htu21:</p>
<pre><code>#!/usr/bin/env python3
#pip3 install adafruit-circuitpython-htu21d
import board
from adafruit_htu21d import HTU21D
import json

result = {}
try:
    # Create sensor object, communicating over the board's default I2C bus
    i2c = board.I2C()  # uses board.SCL and board.SDA
    sensor = HTU21D(i2c)
    result["temperature_c"] = sensor.temperature
    result["humidity"] = sensor.relative_humidity
    result["temperature_f"] = (result["temperature_c"]*1.8) + 32
    result["error"] = False
except:
    result["temperature_c"] = 0.0
    result["humidity"] = 0.0
    result["temperature_f"] = (result["temperature_c"]*1.8) + 32
    result["error"] = True

print(json.dumps(result))
</code></pre>
<p dir="auto">My resulting script is aht20:</p>
<pre><code>#!/usr/bin/env python3
# aht20: Modeled on htu21 
# pip3 install adafruit-circuitpython-htu21d
# pip3 install adafruit-circuitpython-ahtx0
import board
import adafruit_ahtx0
import json

result = {}
try:
    # Create sensor object, communicating over the board's default I2C bus
    i2c = board.I2C()  # uses board.SCL and board.SDA
    # sensor = HTU21D(i2c)
    sensor = adafruit_ahtx0.AHTx0(board.I2C())
    result["temperature_c"] = sensor.temperature
    result["humidity"] = sensor.relative_humidity
    result["temperature_f"] = (result["temperature_c"]*1.8) + 32
    result["error"] = False
except:
    result["temperature_c"] = 0.0
    result["humidity"] = 0.0
    result["temperature_f"] = (result["temperature_c"]*1.8) + 32
    result["error"] = True

print(json.dumps(result))
</code></pre>
<p dir="auto">This module is now displaying the temperature and humidity from the sensor directly connected it it. Now all I have to do is figure out the complicated css and get it to look like the other modules on my Magic Mirror.</p>
<p dir="auto">Barring any objections, I will mark this as solved.</p>
]]></description><link>https://forum.magicmirror.builders/post/125940</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/125940</guid><dc:creator><![CDATA[JohnGalt]]></dc:creator><pubDate>Thu, 17 Apr 2025 16:24:29 GMT</pubDate></item><item><title><![CDATA[Reply to AHT20 Humidity + Temperature Sensor on Thu, 17 Apr 2025 06:25:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/johngalt" aria-label="Profile: JohnGalt">@<bdi>JohnGalt</bdi></a> cool.<br />
congratulations.<br />
It’s may be worth to show the community what you have done?</p>
<p dir="auto">Regards,<br />
Ralf</p>
]]></description><link>https://forum.magicmirror.builders/post/125929</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/125929</guid><dc:creator><![CDATA[rkorell]]></dc:creator><pubDate>Thu, 17 Apr 2025 06:25:29 GMT</pubDate></item><item><title><![CDATA[Reply to AHT20 Humidity + Temperature Sensor on Thu, 17 Apr 2025 01:01:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rkorell" aria-label="Profile: rkorell">@<bdi>rkorell</bdi></a> + <a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a>  - Thanks for the support. I think I have fixed this for myself by adapting an existing module (“MMM-Temperature”, // <a href="https://github.com/Tom-Hirschberger/MMM-Temperature" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/Tom-Hirschberger/MMM-Temperature</a>).</p>
<p dir="auto">That module calls scripts for various sensors to capture the data. I was able to adapt an existing script for use with this sensor, so I think I am good for now.</p>
]]></description><link>https://forum.magicmirror.builders/post/125928</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/125928</guid><dc:creator><![CDATA[JohnGalt]]></dc:creator><pubDate>Thu, 17 Apr 2025 01:01:11 GMT</pubDate></item><item><title><![CDATA[Reply to AHT20 Humidity + Temperature Sensor on Wed, 16 Apr 2025 21:57:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rkorell" aria-label="Profile: rkorell">@<bdi>rkorell</bdi></a> – Hi Ralf:</p>
<p dir="auto">Yes, I2C is enabled and functioning. There is a test script that does return current temperature and humidity:<br />
Invoking “python AHT20_test.py” does launch this script (Note - I launch from the terminal using ‘python’, not ‘python3’, telling me the system is indeed defaulting to python3):</p>
<pre><code># SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

"""
Basic `AHTx0` example test
"""

import time
import board
import adafruit_ahtx0

# Create sensor object, communicating over the board's default I2C bus
i2c = board.I2C()  # uses board.SCL and board.SDA
# i2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller
sensor = adafruit_ahtx0.AHTx0(i2c)

while True:
    print("\nTemperature: %0.1f C" % sensor.temperature)
    print("Humidity: %0.1f %%" % sensor.relative_humidity)
    time.sleep(2)
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/125924</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/125924</guid><dc:creator><![CDATA[JohnGalt]]></dc:creator><pubDate>Wed, 16 Apr 2025 21:57:06 GMT</pubDate></item><item><title><![CDATA[Reply to AHT20 Humidity + Temperature Sensor on Wed, 16 Apr 2025 21:47:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> – Thanks, Sam.  It looks like I intended to send <a href="http://bme280.py" target="_blank" rel="noopener noreferrer nofollow ugc">bme280.py</a> but actually copied MMM-BME280.js. I see below where Ralf did post it, so I will look at that, too.</p>
]]></description><link>https://forum.magicmirror.builders/post/125923</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/125923</guid><dc:creator><![CDATA[JohnGalt]]></dc:creator><pubDate>Wed, 16 Apr 2025 21:47:24 GMT</pubDate></item><item><title><![CDATA[Reply to AHT20 Humidity + Temperature Sensor on Wed, 16 Apr 2025 10:38:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/johngalt" aria-label="Profile: JohnGalt">@<bdi>JohnGalt</bdi></a><br />
just seen while re-reading my last posting:</p>
<p dir="auto"><a href="https://github.com/awitwicki/MMM-BME280/blob/master/node_helper.js" target="_blank" rel="noopener noreferrer nofollow ugc">nodehelper.js</a> (the part of the module which is communicating with the python program and so with the sensor) is calling <strong>python3</strong> :</p>
<pre><code>exec(`python3 ./modules/MMM-BME280/bme280.py ${deviceAddr}`, (error, stdout) =&gt; {
</code></pre>
<p dir="auto">but the python script itself is referencing <strong>python 2</strong> (see above post, source code of <a href="http://bme280.py" target="_blank" rel="noopener noreferrer nofollow ugc">bme280.py</a>, 1st line:</p>
<pre><code>#!/usr/bin/python
</code></pre>
<p dir="auto">I guess this must match and doesn’t …<br />
So may this is the cause of your problems.</p>
<p dir="auto">And if this is true it is may really hard to get this working because you may run in several incompatibilities and library-conflicts …</p>
<p dir="auto">Regards,<br />
Ralf</p>
]]></description><link>https://forum.magicmirror.builders/post/125889</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/125889</guid><dc:creator><![CDATA[rkorell]]></dc:creator><pubDate>Wed, 16 Apr 2025 10:38:36 GMT</pubDate></item><item><title><![CDATA[Reply to AHT20 Humidity + Temperature Sensor on Wed, 16 Apr 2025 09:58:18 GMT]]></title><description><![CDATA[<p dir="auto">the python script you are looking for is <a href="https://github.com/awitwicki/MMM-BME280/blob/master/bme280.py" target="_blank" rel="noopener noreferrer nofollow ugc">bme280.py</a></p>
<pre><code>#!/usr/bin/python
#--------------------------------------
#    ___  ___  _ ____
#   / _ \/ _ \(_) __/__  __ __
#  / , _/ ___/ /\ \/ _ \/ // /
# /_/|_/_/  /_/___/ .__/\_, /
#                /_/   /___/
#
#           bme280.py
#  Read data from a digital pressure sensor.
#
#  Official datasheet available from :
#  https://www.bosch-sensortec.com/bst/products/all_products/bme280
#
# Author : Matt Hawkins
# Date   : 21/01/2018
#
# https://www.raspberrypi-spy.co.uk/
#
#--------------------------------------
import smbus
import sys
import time
from ctypes import c_short
from ctypes import c_byte
from ctypes import c_ubyte

DEVICE = 0x76 # Default device I2C address

try: #override device address like '0x77'
    DEVICE = int(sys.argv[1], 16)
except:
    pass

bus = smbus.SMBus(1) # Rev 2 Pi, Pi 2 &amp; Pi 3 uses bus 1
                     # Rev 1 Pi uses bus 0

def getShort(data, index):
  # return two bytes from data as a signed 16-bit value
  return c_short((data[index+1] &lt;&lt; 8) + data[index]).value

def getUShort(data, index):
  # return two bytes from data as an unsigned 16-bit value
  return (data[index+1] &lt;&lt; 8) + data[index]

def getChar(data,index):
  # return one byte from data as a signed char
  result = data[index]
  if result &gt; 127:
    result -= 256
  return result

def getUChar(data,index):
  # return one byte from data as an unsigned char
  result =  data[index] &amp; 0xFF
  return result

def readBME280ID(addr=DEVICE):
  # Chip ID Register Address
  REG_ID     = 0xD0
  (chip_id, chip_version) = bus.read_i2c_block_data(addr, REG_ID, 2)
  return (chip_id, chip_version)

def readBME280All(addr=DEVICE):
  # Register Addresses
  REG_DATA = 0xF7
  REG_CONTROL = 0xF4
  REG_CONFIG  = 0xF5

  REG_CONTROL_HUM = 0xF2
  REG_HUM_MSB = 0xFD
  REG_HUM_LSB = 0xFE

  # Oversample setting - page 27
  OVERSAMPLE_TEMP = 2
  OVERSAMPLE_PRES = 2
  MODE = 1

  # Oversample setting for humidity register - page 26
  OVERSAMPLE_HUM = 2
  bus.write_byte_data(addr, REG_CONTROL_HUM, OVERSAMPLE_HUM)

  control = OVERSAMPLE_TEMP&lt;&lt;5 | OVERSAMPLE_PRES&lt;&lt;2 | MODE
  bus.write_byte_data(addr, REG_CONTROL, control)

  # Read blocks of calibration data from EEPROM
  # See Page 22 data sheet
  cal1 = bus.read_i2c_block_data(addr, 0x88, 24)
  cal2 = bus.read_i2c_block_data(addr, 0xA1, 1)
  cal3 = bus.read_i2c_block_data(addr, 0xE1, 7)

  # Convert byte data to word values
  dig_T1 = getUShort(cal1, 0)
  dig_T2 = getShort(cal1, 2)
  dig_T3 = getShort(cal1, 4)

  dig_P1 = getUShort(cal1, 6)
  dig_P2 = getShort(cal1, 8)
  dig_P3 = getShort(cal1, 10)
  dig_P4 = getShort(cal1, 12)
  dig_P5 = getShort(cal1, 14)
  dig_P6 = getShort(cal1, 16)
  dig_P7 = getShort(cal1, 18)
  dig_P8 = getShort(cal1, 20)
  dig_P9 = getShort(cal1, 22)

  dig_H1 = getUChar(cal2, 0)
  dig_H2 = getShort(cal3, 0)
  dig_H3 = getUChar(cal3, 2)

  dig_H4 = getChar(cal3, 3)
  dig_H4 = (dig_H4 &lt;&lt; 24) &gt;&gt; 20
  dig_H4 = dig_H4 | (getChar(cal3, 4) &amp; 0x0F)

  dig_H5 = getChar(cal3, 5)
  dig_H5 = (dig_H5 &lt;&lt; 24) &gt;&gt; 20
  dig_H5 = dig_H5 | (getUChar(cal3, 4) &gt;&gt; 4 &amp; 0x0F)

  dig_H6 = getChar(cal3, 6)

  # Wait in ms (Datasheet Appendix B: Measurement time and current calculation)
  wait_time = 1.25 + (2.3 * OVERSAMPLE_TEMP) + ((2.3 * OVERSAMPLE_PRES) + 0.575) + ((2.3 * OVERSAMPLE_HUM)+0.575)
  time.sleep(wait_time/1000)  # Wait the required time  

  # Read temperature/pressure/humidity
  data = bus.read_i2c_block_data(addr, REG_DATA, 8)
  pres_raw = (data[0] &lt;&lt; 12) | (data[1] &lt;&lt; 4) | (data[2] &gt;&gt; 4)
  temp_raw = (data[3] &lt;&lt; 12) | (data[4] &lt;&lt; 4) | (data[5] &gt;&gt; 4)
  hum_raw = (data[6] &lt;&lt; 8) | data[7]

  #Refine temperature
  var1 = ((((temp_raw&gt;&gt;3)-(dig_T1&lt;&lt;1)))*(dig_T2)) &gt;&gt; 11
  var2 = (((((temp_raw&gt;&gt;4) - (dig_T1)) * ((temp_raw&gt;&gt;4) - (dig_T1))) &gt;&gt; 12) * (dig_T3)) &gt;&gt; 14
  t_fine = var1+var2
  temperature = float(((t_fine * 5) + 128) &gt;&gt; 8);

  # Refine pressure and adjust for temperature
  var1 = t_fine / 2.0 - 64000.0
  var2 = var1 * var1 * dig_P6 / 32768.0
  var2 = var2 + var1 * dig_P5 * 2.0
  var2 = var2 / 4.0 + dig_P4 * 65536.0
  var1 = (dig_P3 * var1 * var1 / 524288.0 + dig_P2 * var1) / 524288.0
  var1 = (1.0 + var1 / 32768.0) * dig_P1
  if var1 == 0:
    pressure=0
  else:
    pressure = 1048576.0 - pres_raw
    pressure = ((pressure - var2 / 4096.0) * 6250.0) / var1
    var1 = dig_P9 * pressure * pressure / 2147483648.0
    var2 = pressure * dig_P8 / 32768.0
    pressure = pressure + (var1 + var2 + dig_P7) / 16.0

  # Refine humidity
  humidity = t_fine - 76800.0
  humidity = (hum_raw - (dig_H4 * 64.0 + dig_H5 / 16384.0 * humidity)) * (dig_H2 / 65536.0 * (1.0 + dig_H6 / 67108864.0 * humidity * (1.0 + dig_H3 / 67108864.0 * humidity)))
  humidity = humidity * (1.0 - dig_H1 * humidity / 524288.0)
  if humidity &gt; 100:
    humidity = 100
  elif humidity &lt; 0:
    humidity = 0

  return temperature/100.0,pressure/100.0,humidity

def main():

  # (chip_id, chip_version) = readBME280ID()
  # print("Chip ID     :", chip_id)
  # print("Version     :", chip_version)

  temperature,pressure,humidity = readBME280All()

  print(round(temperature,1),round(humidity,1),round(pressure,1))

if __name__=="__main__":
   main()
</code></pre>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/johngalt" aria-label="Profile: JohnGalt">@<bdi>JohnGalt</bdi></a> said in <a href="/post/125865">AHT20 Humidity + Temperature Sensor</a>:</p>
<blockquote>
<p dir="auto">Remote I/O error</p>
</blockquote>
<p dir="auto">The given error seems to by not a program but an I/O problem.<br />
I’m not familiar with this sensor so I do not know how to connect and - most important - how to figure out the right “deviceAddress” - it seems that there is the error located.</p>
<p dir="auto">Either the address isn’t the correct one or the IO channel is somehow broken.<br />
For the latter came in my mind: if this is a I2C conected device - do you have enabled I2C on your Raspi?</p>
<p dir="auto">I’ve tried to “understand” what happens in the python script above as well as in the C-exmaple program on the Bosch product page for bme280 sensor, but didn’t got it…</p>
<p dir="auto">Regards,<br />
Ralf</p>
]]></description><link>https://forum.magicmirror.builders/post/125888</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/125888</guid><dc:creator><![CDATA[rkorell]]></dc:creator><pubDate>Wed, 16 Apr 2025 09:58:18 GMT</pubDate></item><item><title><![CDATA[Reply to AHT20 Humidity + Temperature Sensor on Tue, 15 Apr 2025 21:01:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/johngalt" aria-label="Profile: JohnGalt">@<bdi>JohnGalt</bdi></a> the browser (electron) wants to display the data from the sensor, but it cant read it directly. so the module sends a request to the helper to get the data from device 0x38</p>
<p dir="auto">the module uses a python script to get the data<br />
the python script is reporting an error</p>
<p dir="auto">that is what needs to be looked at.</p>
<p dir="auto">you posted the code from the module/browser side which is not involved in getting the actual data</p>
]]></description><link>https://forum.magicmirror.builders/post/125876</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/125876</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Tue, 15 Apr 2025 21:01:26 GMT</pubDate></item><item><title><![CDATA[Reply to AHT20 Humidity + Temperature Sensor on Tue, 15 Apr 2025 20:53:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> – Hi Sam, thanks for looking in on this.</p>
<p dir="auto">I guess I don’t understand… If the module is calling a python script, and the script is polling the sensor - then it would seem to me that the browser isn’t accessing the hardware or files directly. Obviously I’m missing something here.</p>
]]></description><link>https://forum.magicmirror.builders/post/125874</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/125874</guid><dc:creator><![CDATA[JohnGalt]]></dc:creator><pubDate>Tue, 15 Apr 2025 20:53:09 GMT</pubDate></item><item><title><![CDATA[Reply to AHT20 Humidity + Temperature Sensor on Tue, 15 Apr 2025 20:17:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/johngalt" aria-label="Profile: JohnGalt">@<bdi>JohnGalt</bdi></a> the module also has a node_helper.js , this is where the python script is launched</p>
<p dir="auto">browsers cannot access hardware or files directly (for security reasons)</p>
]]></description><link>https://forum.magicmirror.builders/post/125869</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/125869</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Tue, 15 Apr 2025 20:17:45 GMT</pubDate></item><item><title><![CDATA[Reply to AHT20 Humidity + Temperature Sensor on Tue, 15 Apr 2025 20:02:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rkorell" aria-label="Profile: rkorell">@<bdi>rkorell</bdi></a> Ralf:  OK, I have a chance to work on this today - Thanks for your help.</p>
<p dir="auto">To ease troubleshooting, I have temporarily disabled MMM-Temperature and am only running MMM-BME280.  Below are the following:</p>
<ol>
<li>Config for this module</li>
<li>Error as captured using pm2 logs</li>
<li>Code listing of bme280.js, which is called by the module</li>
</ol>
<p dir="auto">Config:</p>
<pre><code>{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
	} },
</code></pre>
<p dir="auto">Errors [from pm2 logs]:<br />
0|MagicMirror  | [2025-04-15 12:57:48.599] [ERROR] exec error: Error: Command failed: python3 ./modules/MMM-BME280/bme280.py 0x38<br />
0|MagicMirror  | Traceback (most recent call last):<br />
0|MagicMirror  |   File “/home/pi/MagicMirror/./modules/MMM-BME280/bme280.py”, line 176, in <br />
0|MagicMirror  |     main()<br />
0|MagicMirror  |   File “/home/pi/MagicMirror/./modules/MMM-BME280/bme280.py”, line 171, in main<br />
0|MagicMirror  |     temperature,pressure,humidity = readBME280All()<br />
0|MagicMirror  |   File “/home/pi/MagicMirror/./modules/MMM-BME280/bme280.py”, line 82, in readBME280All<br />
0|MagicMirror  |     bus.write_byte_data(addr, REG_CONTROL_HUM, OVERSAMPLE_HUM)<br />
0|MagicMirror  | OSError: [Errno 121] Remote I/O error<br />
0|MagicMirror  |</p>
<p dir="auto">Code for <a href="http://bme280.py" target="_blank" rel="noopener noreferrer nofollow ugc">bme280.py</a>:</p>
<pre><code>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 &lt; 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();
        }
    },
});
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/125865</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/125865</guid><dc:creator><![CDATA[JohnGalt]]></dc:creator><pubDate>Tue, 15 Apr 2025 20:02:26 GMT</pubDate></item><item><title><![CDATA[Reply to AHT20 Humidity + Temperature Sensor on Tue, 15 Apr 2025 18:38:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rkorell" aria-label="Profile: rkorell">@<bdi>rkorell</bdi></a> – Thanks for responding, answers follow:</p>
<ol>
<li>
<p dir="auto">Yes, the first use case is a sensor connected directly to the Raspberry Pi 4 where the Magic Mirror is running. It will be great if I can expand this in the future to display on my office Magic Mirror the outputs from sensors on three (3) other Pis (they run Magic Mirror, NEMS network monitor and Pi-Aware flight tracking, respectively).</p>
</li>
<li>
<p dir="auto">I am just running the two Magic Mirror modules listed above. I don’t know what scripts they run.  At this point I have just looked and don’t see any obvious way to adapt them. I did try changing the address of the device from their default to 0x38, which is what I think is the address for this sensor attached to my Pi - but I still don’t get output. I should have some time this afternoon to SSH into that machine, and I can locate the scripts and log the error messages.</p>
</li>
</ol>
]]></description><link>https://forum.magicmirror.builders/post/125862</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/125862</guid><dc:creator><![CDATA[JohnGalt]]></dc:creator><pubDate>Tue, 15 Apr 2025 18:38:19 GMT</pubDate></item><item><title><![CDATA[Reply to AHT20 Humidity + Temperature Sensor on Tue, 15 Apr 2025 06:58:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/johngalt" aria-label="Profile: JohnGalt">@<bdi>JohnGalt</bdi></a> Good morning,<br />
do you have connected the sensors locally to the same PI where the mirror is running?<br />
What script are you using and what output this sends?<br />
If you are able to modify these scripts to deliver a JSON output you may can use MMM-JsonValue for displaying the results…</p>
<p dir="auto">Regards,<br />
Ralf</p>
]]></description><link>https://forum.magicmirror.builders/post/125849</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/125849</guid><dc:creator><![CDATA[rkorell]]></dc:creator><pubDate>Tue, 15 Apr 2025 06:58:29 GMT</pubDate></item></channel></rss>