Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Sketch for Lightning Sensor

Sketch for Lightning Sensor

Scheduled Pinned Locked Moved Development
58 Posts 14 Posters 31.6k Views 11 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • hekH Offline
    hekH Offline
    hek
    Admin
    wrote on last edited by
    #12

    Sweet. Would you want to create a pull request when you're ready with this example (including AS3935 library)?

    SparkmanS 3 Replies Last reply
    0
    • hekH hek

      Sweet. Would you want to create a pull request when you're ready with this example (including AS3935 library)?

      SparkmanS Offline
      SparkmanS Offline
      Sparkman
      Hero Member
      wrote on last edited by
      #13

      @hek Thanks and yes, will do.

      1 Reply Last reply
      0
      • hekH hek

        Sweet. Would you want to create a pull request when you're ready with this example (including AS3935 library)?

        SparkmanS Offline
        SparkmanS Offline
        Sparkman
        Hero Member
        wrote on last edited by Sparkman
        #14

        @hek The AS3935 Sensor also registers the energy intensity. What sensor type would be the best way to send that data to the controller? I'm using S_DISTANCE for the calculated distance, but would also like to capture the energy intensity. The energy intensity is returned as a 32 bit integer.

        Also, the AS3935 returns the distance in km, but I believe S_DISTANCE is in cm. Is there a way to specify different units or should I have the sketch convert it to cm and then have the controller convert back to km?

        Thanks
        Al

        H 1 Reply Last reply
        0
        • hekH Offline
          hekH Offline
          hek
          Admin
          wrote on last edited by
          #15

          Oh.. than sensor is more advanced than I thought.

          Send distance in "meter" for now. Stupid thing that the distance sensor example we're sending in cm in the first place.

          Energy intensity is harder. What unit that is that? Maybe you could send it in VAR_1 for now?

          SparkmanS 1 Reply Last reply
          0
          • hekH hek

            Oh.. than sensor is more advanced than I thought.

            Send distance in "meter" for now. Stupid thing that the distance sensor example we're sending in cm in the first place.

            Energy intensity is harder. What unit that is that? Maybe you could send it in VAR_1 for now?

            SparkmanS Offline
            SparkmanS Offline
            Sparkman
            Hero Member
            wrote on last edited by
            #16

            @hek The sensor has a number of registers that can be set and/or read, so depending what someone wants to do with it, additional parameters may be sent.

            Ok, will do regarding the units. The energy intensity is just a relative value with no units associated with it. I saw one sketch for a different breakout board for the same chip that converted the intensity to a value in the range of 1-10. The actual value returned can be as large as 16843008. I'll take a look at VAR_1, but don't believe the HomeSeer plugin supports that yet. As a test I used I used V_WATT/S_POWER for now.

            Cheers
            Al

            1 Reply Last reply
            0
            • jeylitesJ Offline
              jeylitesJ Offline
              jeylites
              wrote on last edited by
              #17

              @Sparkman

              If you can give me some time say around June or July, I'll be going to a tropical country with lots of lightning. I could test it out for you using Vera.

              SparkmanS 1 Reply Last reply
              0
              • jeylitesJ jeylites

                @Sparkman

                If you can give me some time say around June or July, I'll be going to a tropical country with lots of lightning. I could test it out for you using Vera.

                SparkmanS Offline
                SparkmanS Offline
                Sparkman
                Hero Member
                wrote on last edited by
                #18

                @jeylites Thanks, I appreciate the offer. July/August are prime thunderstorm season where I live and they are forecasting a possible thunderstorm for today, so I'm hoping to confirm that everything is working today :-)

                Cheers
                Al

                1 Reply Last reply
                1
                • sowardS Offline
                  sowardS Offline
                  soward
                  wrote on last edited by
                  #19

                  I put one of these together a short while ago -- just missed a storm rolling though, but another round might come through later. There's a reference in the code to AS3935_CAPACITANCE and a comment suggesting it be set to "THE NUMBER LISTED ON YOUR BOARD", however I'm seeing no number listed on the board. Am I just over looking it or is it something you derive?

                  thanx,
                  JpS

                  SparkmanS 1 Reply Last reply
                  0
                  • sowardS soward

                    I put one of these together a short while ago -- just missed a storm rolling though, but another round might come through later. There's a reference in the code to AS3935_CAPACITANCE and a comment suggesting it be set to "THE NUMBER LISTED ON YOUR BOARD", however I'm seeing no number listed on the board. Am I just over looking it or is it something you derive?

                    thanx,
                    JpS

                    SparkmanS Offline
                    SparkmanS Offline
                    Sparkman
                    Hero Member
                    wrote on last edited by Sparkman
                    #20

                    @soward So far the thunderstorms have skirted our area, but more to come tonight. Here's hoping ;-)

                    The Capacitance value is written on the bag the sensor came in. If you don't have the bag anymore, send an email to TechnicalSupport@PlayingWithFusion.com and they should be able to cross reference your order and provide the value. How does your sketch compare to mine?

                    Cheers
                    Al

                    sowardS 1 Reply Last reply
                    0
                    • SparkmanS Sparkman

                      @soward So far the thunderstorms have skirted our area, but more to come tonight. Here's hoping ;-)

                      The Capacitance value is written on the bag the sensor came in. If you don't have the bag anymore, send an email to TechnicalSupport@PlayingWithFusion.com and they should be able to cross reference your order and provide the value. How does your sketch compare to mine?

                      Cheers
                      Al

                      sowardS Offline
                      sowardS Offline
                      soward
                      wrote on last edited by
                      #21

                      @Sparkman great thanx, I do have the bag somewhere in the pile-of-parts-bags. So far I have only used the demo sketch from playingwithfusion, but once it appears to detect something I'll probably use yours as a base and branch out form there. I'm using a Vera so I can try to use VAR_1 as hek suggested.

                      1 Reply Last reply
                      0
                      • SparkmanS Sparkman

                        @hek The AS3935 Sensor also registers the energy intensity. What sensor type would be the best way to send that data to the controller? I'm using S_DISTANCE for the calculated distance, but would also like to capture the energy intensity. The energy intensity is returned as a 32 bit integer.

                        Also, the AS3935 returns the distance in km, but I believe S_DISTANCE is in cm. Is there a way to specify different units or should I have the sketch convert it to cm and then have the controller convert back to km?

                        Thanks
                        Al

                        H Offline
                        H Offline
                        hleidecker
                        Plugin Developer
                        wrote on last edited by hleidecker
                        #22

                        Also, the AS3935 returns the distance in km, but I believe S_DISTANCE is in cm. Is there a way to specify different units or should I have the sketch convert it to cm and then have the controller convert back to km?

                        The actual value returned can be as large as 16843008. I'll take a look at VAR_1, but don't believe the HomeSeer plugin supports that yet. As a test I used I used V_WATT/S_POWER for now.

                        Two mechanisms have been implemented in the HomeSeer controller plugin (1.0.5574.17274) to support custom unit strings in the controller UI:

                        • V_UNIT_PREFIX (only available in the development branch of the MySensors library). The prefix provided in the V_UNIT_PREFIX message will precede the default metric unit (defined by the plugin e.g. m (meter) for the distance sensor). The sensor configuration (metric/imperial) can be set by the user as a property on S_ARDUINO_NODE device via the HomeSeer UI. Please note, the prefix will not take effect when the sensor configuration is set to imperial.
                        • A user defined unit string. A unit string can be defined by the user. The metric/imperial configuration unit string and unit prefix will be ignored if a user defined unit string exists. The user defined unit string can be set by the user as a property on the device e..g. S_DISTANCE via the HomeSeer UI.

                        The HomeSeer MySensors plugin is available here.

                        Best regards,
                        Henrik

                        SparkmanS 1 Reply Last reply
                        0
                        • H hleidecker

                          Also, the AS3935 returns the distance in km, but I believe S_DISTANCE is in cm. Is there a way to specify different units or should I have the sketch convert it to cm and then have the controller convert back to km?

                          The actual value returned can be as large as 16843008. I'll take a look at VAR_1, but don't believe the HomeSeer plugin supports that yet. As a test I used I used V_WATT/S_POWER for now.

                          Two mechanisms have been implemented in the HomeSeer controller plugin (1.0.5574.17274) to support custom unit strings in the controller UI:

                          • V_UNIT_PREFIX (only available in the development branch of the MySensors library). The prefix provided in the V_UNIT_PREFIX message will precede the default metric unit (defined by the plugin e.g. m (meter) for the distance sensor). The sensor configuration (metric/imperial) can be set by the user as a property on S_ARDUINO_NODE device via the HomeSeer UI. Please note, the prefix will not take effect when the sensor configuration is set to imperial.
                          • A user defined unit string. A unit string can be defined by the user. The metric/imperial configuration unit string and unit prefix will be ignored if a user defined unit string exists. The user defined unit string can be set by the user as a property on the device e..g. S_DISTANCE via the HomeSeer UI.

                          The HomeSeer MySensors plugin is available here.

                          Best regards,
                          Henrik

                          SparkmanS Offline
                          SparkmanS Offline
                          Sparkman
                          Hero Member
                          wrote on last edited by
                          #23

                          @hleidecker Thanks Henrik!

                          1 Reply Last reply
                          0
                          • SparkmanS Offline
                            SparkmanS Offline
                            Sparkman
                            Hero Member
                            wrote on last edited by
                            #24

                            Hi all,

                            Well I was finally home when a thunderstorm rolled through and I was able to test the sensor and the sketch. Even though the sensor appeared to be working at 3.3V, I had to change it to 5V to get it to work properly with the USB powered Nano I have it connected to. I modified the sketch slightly (updated in my earlier post) to no longer send data when disturbers or unknown interrupt sources were detected. It's working great now and just need to put it into a case. I may use a different Arduino as well.

                            Cheers
                            Al

                            1 Reply Last reply
                            1
                            • hekH hek

                              Sweet. Would you want to create a pull request when you're ready with this example (including AS3935 library)?

                              SparkmanS Offline
                              SparkmanS Offline
                              Sparkman
                              Hero Member
                              wrote on last edited by Sparkman
                              #25

                              @hek said:

                              Sweet. Would you want to create a pull request when you're ready with this example (including AS3935 library)?

                              Hi Henrik,

                              Pull request submitted. Hopefully I did it correctly.

                              Cheers
                              Al

                              1 Reply Last reply
                              1
                              • hekH Offline
                                hekH Offline
                                hek
                                Admin
                                wrote on last edited by
                                #26

                                Nice that you finally got some lightings to test your sketch.

                                Pull request looks all ok!

                                1 Reply Last reply
                                0
                                • Tore André RosanderT Offline
                                  Tore André RosanderT Offline
                                  Tore André Rosander
                                  wrote on last edited by
                                  #27

                                  Is it possible to detect the distance to the lightningstrike?
                                  I was thinking to get some sort of detector to notify me if there is ligning registered X km away from my home.

                                  B SparkmanS 2 Replies Last reply
                                  0
                                  • Tore André RosanderT Tore André Rosander

                                    Is it possible to detect the distance to the lightningstrike?
                                    I was thinking to get some sort of detector to notify me if there is ligning registered X km away from my home.

                                    B Offline
                                    B Offline
                                    boozz
                                    wrote on last edited by
                                    #28

                                    @Tore-André-Rosander

                                    You would need a sound detector for the thunder. Time (in milliseconds) between lightning and thunder times 0.34[m].

                                    Same as you would do it with your own sensors (eyes and ears) :-)

                                    BR,

                                    Boozz

                                    1 Reply Last reply
                                    0
                                    • Tore André RosanderT Tore André Rosander

                                      Is it possible to detect the distance to the lightningstrike?
                                      I was thinking to get some sort of detector to notify me if there is ligning registered X km away from my home.

                                      SparkmanS Offline
                                      SparkmanS Offline
                                      Sparkman
                                      Hero Member
                                      wrote on last edited by
                                      #29

                                      @Tore-André-Rosander Yes, the sensor can detect the distance. See the details of the sensor here: http://playingwithfusion.com/productview.php?pdid=22&catid=1001. Although I'm starting to believe that it's actually a lightning repeller rather than a lightning sensor as we've had very little lightning in our area after I installed it :laughing:

                                      Cheers
                                      Al

                                      1 Reply Last reply
                                      0
                                      • alexsh1A Offline
                                        alexsh1A Offline
                                        alexsh1
                                        wrote on last edited by
                                        #30

                                        I found a similar sensor in the UK and added this to the list of my to be sensors for the weatherstation. Can I use it inside or it has to be placed outside to have a direct vision?

                                        http://www.embeddedadventures.com/as3935_lightning_sensor_module_mod-1016.html

                                        Tore André RosanderT 1 Reply Last reply
                                        0
                                        • alexsh1A alexsh1

                                          I found a similar sensor in the UK and added this to the list of my to be sensors for the weatherstation. Can I use it inside or it has to be placed outside to have a direct vision?

                                          http://www.embeddedadventures.com/as3935_lightning_sensor_module_mod-1016.html

                                          Tore André RosanderT Offline
                                          Tore André RosanderT Offline
                                          Tore André Rosander
                                          wrote on last edited by
                                          #31

                                          @alexsh1 What i read when researching this chip it can be placed inside.

                                          @Sparkman Nice, i see that it has a detection range about 40km so thats already a pretty good distance to get a notification when lightning is detected.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          17

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular