as3935 lightining module not detected by I2c on a Rpi4

85 views
Skip to first unread message

Pierre-Yves

unread,
Feb 16, 2024, 3:30:08 PMFeb 16
to weewx-user
Hello All,

Maybe a bit off-topic. But just in case someone would have faced to this strange behavior of a Raspberry i2c address map.


Rpi4-1: usual address map from 0x03 to 7x76.
Config.:
Weewx 4.10.2,
Bresser 7in1,
sdr driver,
RTC clock (UU),
BME280 (0x76) (pressure, temperature, humidity)
AS3935 (0x03) (lightning detector)

Weewx on Rpi4-1 running without any error.

pi@weewx:~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          03 -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- 1a -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
70: -- -- -- -- -- -- 76 --                        
pi@weewx:~ $

Rpi4-2: "abnormal" map with addresses 0x03 to 0x07 non selectable.
Config.:
Weewx 5.0.2,
Bresser 7in1,
RTC clock (UU),
AS3935 (??)

Weewx on Rpi4-2 failing : File "/etc/weewx/bin/user/as3935.py", line 182, in __init__GPIO.setup(self.pin, GPIO.IN (see log below)

pi@raspberrypi:~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- 1a -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --                        
pi@raspberrypi:~ $

Clearly, the AS3935 is not identified because the 0x03 to 0x07 address range is not active. This AS3935 module works on the Rpi4-1

Any idea on where this problem of misconfiguration could come from, firmware, kernel ?
Is there a way to reset the I2c address map ?

Thanks,

Pierre-Yves
I2c-address-map-bug-log

Pierre-Yves

unread,
Feb 16, 2024, 6:43:49 PMFeb 16
to weewx-user
Finally, I succeeded to make the weewx running and capturing AS3935 lightning detector data

For that, I had to force the detection of the i2c addresses from 0x03 to 0x77 instead of 0x08 to 0x77 with the command:
sudo i2cdetect -a -y 1 0x03 0x77

I had also to add gpio to weewx group:
sudo usermod -a -G gpio weewx

PYB

cric...@pobox.com

unread,
Feb 16, 2024, 7:10:52 PMFeb 16
to weewx-user
So... I've recently set up one of these modules from DFRobot.  I started with their sample python code
and morphed into something that fits in my set of libraries.  In my case, I have it sending events out
via mqtt.  A quick look at the code doesn't give any hints to help you.  From the sample code, I set this up:
      #I2C address
      self.config['AS3935_I2C_ADDR1']   = 0x01
      self.config['AS3935_I2C_ADDR2']   = 0x02
      self.config['AS3935_I2C_ADDR3']   = 0x03
I think the hardware module has tiny switches to change it's address.

It's dead of winter here, so no lightning to detect for a few months.  I can share some of the code,
but not all.

Chris
Message has been deleted

Karen K

unread,
Feb 17, 2024, 2:04:00 AMFeb 17
to weewx-user
May be you want to try option -a:

sudo i2cdetect -a -y 1

Adresses below 0x8 are reserved at Raspberry Pi 4. But the lightning module can address 0x0, 0x1, 0x2, or 0x3 only.

Pierre-Yves

unread,
Feb 17, 2024, 5:26:15 AMFeb 17
to weewx-user
Thanks Karen,
Yes, it is what I understood.
As I explain in my last post, I fixed the problem by extending the range to 0x03 to 0x77 by the command  sudo i2cdetect -a -y 1 0x03 0x77.
That works perfectly now
PY
Reply all
Reply to author
Forward
0 new messages