def setup_module():
    global device
    try:
        print('Setting up I2C connection...')
        i2c = board.I2C()
        try:
            interrupt = board.D25
        except AttributeError:
            interrupt = board.D7
        device = as3935.AS3935_I2C(i2c, interrupt_pin=interrupt)
    except ValueError:
        print('No I2C connection found.')
        print('Setting up SPI connection...')
        spi = board.SPI()
        try:
            cs = board.D24
            interrupt = board.D25
        except AttributeError:
            cs = board.D5
            interrupt = board.D7
        device = as3935.AS3935(spi, cs, interrupt_pin=interrupt)
def setup_module():
    global device
    try:
        print('Setting up I2C connection...')
        i2c = board.I2C()
        try:
            interrupt = board.D25
        except AttributeError:
            interrupt = board.D7
        device = as3935.AS3935_I2C(i2c, interrupt_pin=interrupt)
    except ValueError:
        print('No I2C connection found.')
        print('Setting up SPI connection...')
        spi = board.SPI()
        try:
            cs = board.D24
            interrupt = board.D25
        except AttributeError:
            cs = board.D5
            interrupt = board.D7
        device = as3935.AS3935(spi, cs, interrupt_pin=interrupt)