Weather hat software errors

Hello ,

Really new to raspi, i followed all of the install of software the hello world works and button test but nothing else just installed the os today and updated and this is what i get

Traceback (most recent call last):
File “/home/duh/weatherhat-python/examples/weather.py”, line 13, in
import weatherhat
File “/home/duh/.local/lib/python3.9/site-packages/weatherhat/init.py”, line 6, in
import ioexpander as io
File “/home/duh/.local/lib/python3.9/site-packages/ioexpander/init.py”, line 3, in
from smbus2 import SMBus, i2c_msg
can anybody help me

Unfortunately, you’ve clipped off the first line of that error message that would have told us what the problem actually is, but at a guess… have you enabled i2c on your Pi?

Thanks for the reply

But that is all that it shows

Here is line it is referring to

#!/usr/bin/env python3
import math
import pathlib
import time

import yaml

import RPi.GPIO as GPIO
import ST7789
from fonts.ttf import ManropeBold as UserFont
from PIL import Image, ImageDraw, ImageFont

import weatherhat this is line 13
from weatherhat import history

Thanks Stan

There should have been an actual error message after the traceback block you posted - something along the lines of OSError: or RuntimeError:.

The traceback is great for telling us where the problem happened, but it makes diagnosis a lot easier when we know what happened too :-)

Given you have things like Hello World working, the most likely remains a failure to enable i2c - the installer usually does it for you, but double check in raspi-config, under Interfacing Options

from smbus2 import SMBus, i2c_msg

ModuleNotFoundError: No module named ‘smbus2’

here is what i just did

duh@weather:~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – – – – – – – –
10: – – 12 – – – – – – – – – – – – –
20: – – – 23 – – – – – – – – – – – –
30: – – – – – – – – – – – – – – – –
40: – – – – – – – – – – – – – – – –
50: – – – – – – – – – – – – – – – –
60: – – – – – – – – – – – – – – – –
70: – – – – – – 76 –
duh@weather:~ $ sudo apt-get install python-smbus
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
Package python-smbus is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package ‘python-smbus’ has no installation candidate
duh@weather:~ $ import smbus
bash: import: command not found
Thanks Stan

Try

python3 -m pip install smbus2

:)

well that solved that but now i get this

Traceback (most recent call last):
File “/home/duh/weatherhat-python/examples/weather.py”, line 740, in
main()
File “/home/duh/weatherhat-python/examples/weather.py”, line 709, in main
sensordata = SensorData()
File “/home/duh/weatherhat-python/examples/weather.py”, line 649, in init
self.sensor = weatherhat.WeatherHAT()
File “/usr/local/lib/python3.9/dist-packages/weatherhat/init.py”, line 81, in init
self._ioe.on_interrupt(self.handle_ioe_interrupt)
File “/usr/local/lib/python3.9/dist-packages/ioexpander/init.py”, line 410, in on_interrupt
self._gpio.add_event_detect(self._interrupt_pin, self._gpio.FALLING, callback=callback, bouncetime=1)
RuntimeError: Failed to add edge detection

Thanks Stan

Thanks Everybody went and reinstalled the hat and it now works

Thanks Stan

1 Like