element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum A couple of Arduino libraries I wrote, AS3935 lightning detector and TCS3471 color/light sensor
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 36 replies
  • Subscribers 393 subscribers
  • Views 3658 views
  • Users 0 members are here
  • sensors
  • prototyping
  • arduino
Related

A couple of Arduino libraries I wrote, AS3935 lightning detector and TCS3471 color/light sensor

Former Member
Former Member over 12 years ago

A bit of a shameless self-promotion image I wrote two libraries for two interesting sensor chips, first is AS3935 lightning detector chip, that can warn you about coming storm while it is still 40 kilometers away and the second in high dinamic range 16bit resolution color and light sensor chip TCS34717. Both libraries in my opinion are interesting in the way communications are implemented, library code does not access any other library, like SPI or Wire, directly, but rather relies on user sketch to provide functions to communicate over SPI or i2c bus, which makes them usable with almost any imaginable setup and scenario.

Both libraries can be downloaded from my github - https://github.com/raivisr?tab=repositories

 

And break-outs if anyone is interested in these, can be purchased here - https://www.tindie.com/shops/TAUTIC

  • Sign in to reply
  • Cancel
Parents
  • Former Member
    Former Member over 11 years ago

    Hello to all,

    I am learning something new everyday, but I have no idea how to change the "Noisefloor" in the AS3935 lightning detector. Could someone please give me a kick in the right direction since I am fairly new to all of this?

     

    Ken, W8DZN

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 11 years ago in reply to Former Member

    If you are using my library, then there is function for that:

    int AS3935::setNoiseFloor(int noisefloor)

    {

    registerWrite(AS3935_NF_LEV,noisefloor);

    return getNoiseFloor();

    }

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 11 years ago in reply to Former Member

    Thank you for the reply. I have tried using your suggest before I wrote my question. I am not sure how to use it for sure. As I stated I am learning and very new to this all. I have a couple more ideas to try. Hands-on is the best way for me to learn and to keep trying ideas to find a solution. If you could give me a hint on how to use the code.

    Regards,

    Ken, W8DZN

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 11 years ago in reply to Former Member

    Well, there is example included with library. Other than working with specific chip, this library follows generic arduino programming paradigm.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • Former Member
    Former Member over 11 years ago in reply to Former Member

    Well, there is example included with library. Other than working with specific chip, this library follows generic arduino programming paradigm.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • Former Member
    Former Member over 11 years ago in reply to Former Member

    Thank you for the library.

    Of course it compiles and such but it (the example code) complains that the tuning is out of range.

    Tried it with an arduino uno and a pro mini. Also tried 3,3V instead of 5V.

    The bestdiff value it finds during calibrate is 3125.

     

    Any ideas?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 11 years ago in reply to Former Member

    Let me guess, you have Embedded Adventures breakout?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 11 years ago in reply to Former Member

    Indeed I do.

    They require anything special?

    I have two of them in fact and both fail. Both in i2c and spi.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 11 years ago in reply to Former Member

    I get a lot of support requests because of those breakouts and I have no idea if that is because they are only ones left who make them or if that is because those guys do something wrong, like use not so high quality caps in tank circuit. Since they seem to refer people to me for support, I kindly asked them to send me one of their modules, but got no reply whatsoever.

     

    Anyway, a few days ago I wrote instructions on how to connect to UNO R3, untested, because I neither have Uno, nor breakout by Embedded Adventures:

     

    module
    Uno r3
    VCC
    5V
    CS
    10 SS
    IRQ
    2
    SCL
    13 SCK
    MISO
    12 MISO
    MOSI
    11 MOSI
    GND
    GND

     

    Open example sketch and comment out the line

    attachInterrupt(1,AS3935Irq,RISING);

    and uncomment line

    // attachInterrupt(0,AS3935Irq,RISING);

    at the end of setup() function.

     

    If you still get that dreaded tuning error, make sure your wires are short and module is away from EMI sources (especially ones that are susceptible to be around 500kHz) during tuning. After tuning sample sketch prints some register values, if all of those are zeros then most likely there is something wrong with SPI comms.

     

    My library does not support I2C, but there is a fork on github that is modified for that - https://github.com/SloMusti/AS3935-Arduino-Library

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 11 years ago in reply to Former Member

    If you like I can buy you one?

    If so, please contact me at mail@vanheusden.com

     

    In the mean time I'll give your suggestion a try tonight.

    Note that I also attached such a device to a raspberry pi. It communicates with the rpi but does not detect any lightnings. Well unless none did strike in the last 10 days, that's also possible I guess.

     

    regards

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 11 years ago in reply to Former Member

    Thanks, but no thanks image I could buy one myself if I wanted, but I don't, too much of different stuff piling up and gathering dust as it is, besides, I wrote the library as a courtesy to my friend Jayson of TAUTIC Electronics, who made first breakouts of this chip and I had never had real interest in detecting lightnings.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to Former Member

    Downloaded the library, and made the "adjustments'' to the code to operate with UNO. I connected the sensor to my UNO, and was stuck at "Noise floor" message, with a clearly non responsive sensor. Changed noise Floor settings from 0-7, but still no go (also followed other suggestions you made). Ordered 4 Tautic boards, (arrived yesterday), noise floor message still appears - but the sensor responds to disrupters (such as every time I operate my barbeque lighter)  thus I would expect lightning to trigger the sensor! It's a very nice and easy to use library you have written - I almost feel lazy, as it makes using the sensor "too easy". I live in far north Queensland, and storm season is imminent. Will roll out 4 sensors in various locations, and process the information via the internet, and my Arduino Mega GSM project. Thanks again for a great library, and clear instructions to get started. I will post updates on my project when completed, and after some storms have been detected. My expectations are realistic, I do not expect to detect every strike - but to simply have the sensor detect the storm, and give some guidance of strike numbers and distance.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to Former Member

    Thanks for the kind words and good luck with your project image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to Former Member

    Using UNO R3 + Embedded Adventures under I2C interface

    Try the following connections:

    EA -  UNO R3

    Vcc -  5 VDC

    GND - GND

    SCL -> A5 (analog PIN)

    SDA -> A4 (analog PIN)

    IRQ -  2 (digital pin)

    That is according the information from I2C library: for UNO R3 SDA (data line) is on analog input pin 4, and SCL (clock line) is on analog input pin 5.(https://github.com/rambo/I2C)

    Check your EA board version. If you have the hardware v4 release the I2C address must be changed in the code  to 0x03 (Embedded Adventures - Products - MOD-1016 AS3935 Lightning and Storm Sensor Module).

     

    After run the code I obtained the following result:

     

    regW 3 C0 0 read 1 write 1 err 0

    regW 8 80 1 read 0 write 80 err 0

    regW 8 F 0 read 80 write 80 err 0

    regW 8 F 1 read 80 write 81 err 0

    regW 8 F 2 read 81 write 82 err 0

    regW 8 F 3 read 82 write 83 err 0

    regW 8 F 4 read 83 write 84 err 0

    regW 8 F 5 read 84 write 85 err 0

    regW 8 F 6 read 85 write 86 err 0

    regW 8 F 7 read 86 write 87 err 0

    regW 8 F 8 read 87 write 88 err 0

    regW 8 F 9 read 88 write 89 err 0

    regW 8 F A read 89 write 8A err 0

    regW 8 F B read 8A write 8B err 0

    regW 8 F C read 8B write 8C err 0

    regW 8 F D read 8C write 8D err 0

    regW 8 F E read 8D write 8E err 0

    regW 8 F F read 8E write 8F err 0

    regW 8 F 2 read 8F write 82 err 0

    regW 8 80 0 read 82 write 2 err 0

    Difference 0

    regW 0 3E 12 read 24 write 24 err 0

    regW 3 20 0 read 0 write 0 err 0

    Noise floor is: 2

    Spike rejection is: 2

    Watchdog threshold is: 2

    Noise level too high, try adjusting noise floor

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube