Git Product home page Git Product logo

Comments (20)

rickarddahlstrand avatar rickarddahlstrand commented on August 17, 2024

Btw, I'm using this breakout https://www.tindie.com/products/TAUTIC/as3935-lightning-sensor-board/

And I get this error:

root@blixten:~/dev/RaspberryPi-AS3935# python lightning.py
Traceback (most recent call last):
File "lightning.py", line 8, in
sensor.calibrate()
File "/root/dev/RaspberryPi-AS3935/AS3935.py", line 16, in calibrate
self.set_byte(0x3C, 0x96)
File "/root/dev/RaspberryPi-AS3935/AS3935.py", line 101, in set_byte
self.i2cbus.write_byte_data(self.address, register, value)
IOError: [Errno 5] Input/output error

from raspberrypi-as3935.

pcfens avatar pcfens commented on August 17, 2024

The only potential issue that I see in your wiring is that you have Vdd set to 5V but your SI is at 3.3V. The datasheet seems to suggest that SI needs to be the same as Vdd to enable I2C.

I operated the entire device with Vdd at 3.3V from pin 1 and didn't connect 5V anywhere.

from raspberrypi-as3935.

rickarddahlstrand avatar rickarddahlstrand commented on August 17, 2024

Hi,

I tried 3v3 to start with but thougt it might be a amp-issue. Is the code on github the most recent, I found some compiler errors and I thougt you might have updated it?

Rickard.

from raspberrypi-as3935.

pcfens avatar pcfens commented on August 17, 2024

The code posted is the latest. Are you getting the same error when Vdd and SI are both connected to the 3.3V supply? If not, what error are you getting?

from raspberrypi-as3935.

pcfens avatar pcfens commented on August 17, 2024

While I was typing the readme file I realized that newer Pis will need adjustments to the lightning.py file. If you have a newer Pi give that a try. Hopefully that will take care of the problem.

from raspberrypi-as3935.

rickarddahlstrand avatar rickarddahlstrand commented on August 17, 2024

Hi,

Running on a old pi. Yes, changed back to 3v3 and get the same error:

#python lightning.py
Traceback (most recent call last):
File "lightning.py", line 8, in
sensor.calibrate()
File "/root/dev/RaspberryPi-AS3935/AS3935.py", line 16, in calibrate
self.set_byte(0x3C, 0x96)
File "/root/dev/RaspberryPi-AS3935/AS3935.py", line 101, in set_byte
self.i2cbus.write_byte_data(self.address, register, value)
IOError: [Errno 5] Input/output error

from raspberrypi-as3935.

rickarddahlstrand avatar rickarddahlstrand commented on August 17, 2024

I even changed to another breakout board (had 2)

from raspberrypi-as3935.

pcfens avatar pcfens commented on August 17, 2024

What output do you get when you run sudo i2cdetect -y 0?

Did you add resistors R2 and R3? I'm not convinced that you need them since the Pi includes 1.8k pull up resistors, but you could test this fairly easily on a breadboard without having to modify your breakout board. Any value resistor between 2.4k and 10k should be safe to use assuming the only devices on the bus are the Pi and the AS3935.

from raspberrypi-as3935.

rickarddahlstrand avatar rickarddahlstrand commented on August 17, 2024

I only get a hit on 00 if I type i2cdetect. -a 0.

No pullups, do you have them? I thought I didn't need them.

Btw did you read about the bug in the firmware that made the chip drop the first packet if you used 00?

from raspberrypi-as3935.

pcfens avatar pcfens commented on August 17, 2024

My breakout board came with pull up resistors already installed, so I didn't bother to mess with them, but given the setup you shouldn't need them.

I have read about the bug, but haven't encountered it.

What happens if you write a short python script that reads 0x01 from address 0x00? Something like

import smbus
i2cbus = smbus.SMBus(0)
as3935_data = i2cbus.read_i2c_block_data(0x00, 0x01)
print as3935_data

from raspberrypi-as3935.

rickarddahlstrand avatar rickarddahlstrand commented on August 17, 2024

That works great!!

root@blixten:~/dev# python ss.py
[36, 34, 194, 1, 0, 0, 0, 63, 0, 173, 0, 37, 3, 1, 34, 131, 1, 31, 67, 2, 27, 99, 3, 24, 20, 5, 20, 157, 7, 17, 106, 11]

from raspberrypi-as3935.

pcfens avatar pcfens commented on August 17, 2024

What happens when you expand it to also include a write?

import smbus
i2cbus = smbus.SMBus(0)
as3935_data = i2cbus.read_i2c_block_data(0x00, 0x01)
print as3935_data[0x03]
i2cbus.write_byte_data(0x00, 0x03, as3935_data[0x03] | 0x20) // Set the disturber mask
as3935_data = i2cbus.read_i2c_block_data(0x00, 0x00)
print as3935_data[0x03]

from raspberrypi-as3935.

rickarddahlstrand avatar rickarddahlstrand commented on August 17, 2024

Sometimes it actually works:

root@blixten:/dev# python ss2.py
1
Traceback (most recent call last):
File "ss2.py", line 5, in
i2cbus.write_byte_data(0x00, 0x03, as3935_data[0x03] | 0x20)
IOError: [Errno 5] Input/output error
root@blixten:
/dev# python ss2.py
1
32
root@blixten:/dev# python ss2.py
Traceback (most recent call last):
File "ss2.py", line 3, in
as3935_data = i2cbus.read_i2c_block_data(0x00, 0x01)
IOError: [Errno 5] Input/output error
root@blixten:
/dev# python ss2.py
33
Traceback (most recent call last):
File "ss2.py", line 5, in
i2cbus.write_byte_data(0x00, 0x03, as3935_data[0x03] | 0x20)
IOError: [Errno 5] Input/output error
root@blixten:/dev# python ss2.py
Traceback (most recent call last):
File "ss2.py", line 3, in
as3935_data = i2cbus.read_i2c_block_data(0x00, 0x01)
IOError: [Errno 5] Input/output error
root@blixten:
/dev# python ss2.py
33
Traceback (most recent call last):
File "ss2.py", line 5, in
i2cbus.write_byte_data(0x00, 0x03, as3935_data[0x03] | 0x20)
IOError: [Errno 5] Input/output error
root@blixten:/dev# python ss2.py
Traceback (most recent call last):
File "ss2.py", line 3, in
as3935_data = i2cbus.read_i2c_block_data(0x00, 0x01)
IOError: [Errno 5] Input/output error
root@blixten:
/dev# python ss2.py
33
32
root@blixten:/dev# python ss2.py
Traceback (most recent call last):
File "ss2.py", line 3, in
as3935_data = i2cbus.read_i2c_block_data(0x00, 0x01)
IOError: [Errno 5] Input/output error
root@blixten:
/dev# python ss2.py
33
Traceback (most recent call last):
File "ss2.py", line 5, in
i2cbus.write_byte_data(0x00, 0x03, as3935_data[0x03] | 0x20)
IOError: [Errno 5] Input/output error
root@blixten:/dev# python ss2.py
33
32
root@blixten:
/dev# python ss2.py
33
Traceback (most recent call last):
File "ss2.py", line 6, in
as3935_data = i2cbus.read_i2c_block_data(0x00, 0x00)
IOError: [Errno 5] Input/output error
root@blixten:/dev# python ss2.py
Traceback (most recent call last):
File "ss2.py", line 3, in
as3935_data = i2cbus.read_i2c_block_data(0x00, 0x01)
IOError: [Errno 5] Input/output error
root@blixten:
/dev# python ss2.py
Traceback (most recent call last):
File "ss2.py", line 3, in
as3935_data = i2cbus.read_i2c_block_data(0x00, 0x01)
IOError: [Errno 5] Input/output error
root@blixten:/dev# python ss2.py
33
32
root@blixten:
/dev# python ss2.py
Traceback (most recent call last):
File "ss2.py", line 3, in
as3935_data = i2cbus.read_i2c_block_data(0x00, 0x01)
IOError: [Errno 5] Input/output error
root@blixten:/dev# python ss2.py
33
Traceback (most recent call last):
File "ss2.py", line 5, in
i2cbus.write_byte_data(0x00, 0x03, as3935_data[0x03] | 0x20)
IOError: [Errno 5] Input/output error
root@blixten:
/dev# python ss2.py
Traceback (most recent call last):
File "ss2.py", line 3, in
as3935_data = i2cbus.read_i2c_block_data(0x00, 0x01)
IOError: [Errno 5] Input/output error
root@blixten:~/dev# python ss2.py
33
32

from raspberrypi-as3935.

rickarddahlstrand avatar rickarddahlstrand commented on August 17, 2024

Would you like to have access to the server yourself? I can give you a login.

from raspberrypi-as3935.

rickarddahlstrand avatar rickarddahlstrand commented on August 17, 2024

Made this script:

import smbus
i2cbus = smbus.SMBus(0)

for i in range(0,1):
    while True:
        try:
            as3935_data = i2cbus.read_i2c_block_data(0x00, 0x01)
            print "success.."
            print as3935_data[0x03]
        except:
            print "fail.."
            continue
        break


for i in range(0,1):
    while True:
        try:
            i2cbus.write_byte_data(0x00, 0x03, as3935_data[0x03] | 0x20)
            print "success.."
        except:
            print "fail.."
            continue
        break


for i in range(0,1):
    while True:
        try:
            as3935_data = i2cbus.read_i2c_block_data(0x00, 0x00)
            print as3935_data[0x03]
            print "success.."
        except:
            print "fail.."
            continue
        break

And get this output:

root@blixten:/dev# python ss3.py
success..
33
success..
fail..
fail..
fail..
fail..
fail..
fail..
fail..
fail..
fail..
32
success..
root@blixten:
/dev# python ss3.py
success..
33
fail..
fail..
fail..
fail..
fail..
fail..
fail..
fail..
fail..
fail..
success..
32
success..
root@blixten:/dev# python ss3.py
fail..
fail..
fail..
fail..
fail..
fail..
success..
33
success..
32
success..
root@blixten:
/dev# python ss3.py
success..
33
success..
32
success..
root@blixten:/dev# python ss3.py
fail..
success..
33
success..
32
success..
root@blixten:
/dev# python ss3.py
fail..
success..
33
success..
32
success..
root@blixten:/dev# python ss3.py
fail..
fail..
success..
33
success..
255
success..
root@blixten:
/dev#

from raspberrypi-as3935.

pcfens avatar pcfens commented on August 17, 2024

You might want to power cycle the sensor. That you got back 255 seems kind of weird there unless something is confused or broken.

Also, since the error is presenting itself intermittently, try changing the first read operation to read register 0x00, just to see what happens.

from raspberrypi-as3935.

rickarddahlstrand avatar rickarddahlstrand commented on August 17, 2024

I did a power cycle and now I get 32 back every time, but I still get error. Could it be that issue mentioned or am I having i2c-issues. Perhaps I should try another pi, I have a few of them lying around.

root@blixten:/dev# python ss3.py
success..
32
fail..
fail..
fail..
fail..
fail..
success..
success..
32
root@blixten:
/dev# python ss3.py
fail..
fail..
fail..
fail..
fail..
success..
32
success..
success..
32
root@blixten:/dev# python ss3.py
success..
32
fail..
fail..
fail..
fail..
fail..
fail..
fail..
success..
success..
32
root@blixten:
/dev# python ss3.py
success..
32
fail..
fail..
fail..
fail..
fail..
fail..
fail..
success..
success..
32
root@blixten:/dev# python ss3.py
success..
32
fail..
fail..
fail..
fail..
fail..
fail..
success..
success..
32
root@blixten:
/dev# python ss3.py
fail..
fail..
fail..
fail..
success..
32
success..
success..
32
root@blixten:/dev# python ss3.py
fail..
fail..
fail..
fail..
fail..
fail..
success..
32
success..
success..
32
root@blixten:
/dev# python ss3.py
fail..
fail..
success..
32
success..
success..
32
root@blixten:/dev# python ss3.py
fail..
fail..
fail..
fail..
fail..
fail..
fail..
success..
32
success..
success..
32
root@blixten:
/dev# python ss3.py
fail..
fail..
success..
32
success..
success..
32
root@blixten:/dev# python ss3.py
fail..
fail..
success..
32
success..
success..
32
root@blixten:
/dev# python ss3.py
success..
32
fail..
fail..
fail..
fail..
fail..
success..
success..
32
root@blixten:/dev# python ss3.py
success..
32
fail..
fail..
fail..
fail..
fail..
success..
success..
32
root@blixten:
/dev# python ss3.py
success..
32
fail..
fail..
fail..
fail..
success..
success..
32
root@blixten:/dev# python ss3.py
fail..
fail..
fail..
fail..
fail..
fail..
success..
32
success..
success..
32
root@blixten:
/dev# python ss3.py
success..
32
fail..
fail..
fail..
fail..
fail..
fail..
fail..
success..
success..
32
root@blixten:/dev# python ss3.py
success..
32
fail..
fail..
fail..
fail..
success..
success..
32
root@blixten:
/dev# python ss3.py
success..
32
fail..
fail..
fail..
fail..
fail..
success..
success..
32
root@blixten:~/dev#

from raspberrypi-as3935.

TAUTIC avatar TAUTIC commented on August 17, 2024

I've been told there are issues with this particular revision of the silicon while trying to access register 0x00 over I2C, I would recommend utilizing the board in SPI mode. Here's another individual who identified the I2C issues and has contacted AMS : http://fll-freak.com/blog/?p=554

I have a new version of the board in the works which will allow a user selectable I2C address, and hope to have more detail around the 0x00 issue by that time.

from raspberrypi-as3935.

pcfens avatar pcfens commented on August 17, 2024

Have you had a chance to play with this anymore? If this is a hardware issue then I'd like to close it, but want to make sure that there isn't something that I could change in order to fix things first.

from raspberrypi-as3935.

rickarddahlstrand avatar rickarddahlstrand commented on August 17, 2024

I don't know but I assume it's a hardware bug. I'm a bit to novice to make the SPI-implementation myself, so I have to wait until I find some code for that.

from raspberrypi-as3935.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.