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. General Discussion
  3. Moisture Sensor example sketch

Moisture Sensor example sketch

Scheduled Pinned Locked Moved General Discussion
7 Posts 2 Posters 1.6k Views 2 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.
  • y4CdW42Ol8Y Offline
    y4CdW42Ol8Y Offline
    y4CdW42Ol8
    wrote on last edited by
    #1

    Hello, I'm an Arduino newbie.

    This example sketch has the lines:
    #define Digital_Input_Soil_Sensor 3
    #define INTERRUPT DIGITAL_INPUT_SOIL_SENSOR-2

    Looking in the Arduino Reference Help, there is only the interrupts() function.

    I get what the 1st line does.

    What exactly does this 2nd line in code above do? Does it declare Pin 2 as an interrupt (even though nothing is connected to Pin 2 in the Moisture Sensor build example). Does the MySensor library interpret this line?

    Or is it declaring PIN 3 as the interrupt?

    I'm getting confused by the "-2"...

    Thanks.

    1 Reply Last reply
    0
    • y4CdW42Ol8Y Offline
      y4CdW42Ol8Y Offline
      y4CdW42Ol8
      wrote on last edited by y4CdW42Ol8
      #2

      Also, since this sketch does not use the Interrputs() and noInterrupts() funtions, does the library take care of handling the interrupt while sleeping? I guess interrupt handling is a bit confusing to me.

      1 Reply Last reply
      0
      • mfalkviddM Offline
        mfalkviddM Offline
        mfalkvidd
        Mod
        wrote on last edited by
        #3

        INTERRUPT is used in the gw.sleep line at the end of the sketch.

        DIGITAL_INPUT_SOIL_SENSOR-2 is an ugly way to change pin number to i terrupt number. In MySensors 2 this has been changed to use digitalPinToInterrupt() instead.

        y4CdW42Ol8Y 1 Reply Last reply
        0
        • y4CdW42Ol8Y Offline
          y4CdW42Ol8Y Offline
          y4CdW42Ol8
          wrote on last edited by
          #4

          Has MySensors 2 been released? Where can I find it and its documentation?

          1 Reply Last reply
          0
          • mfalkviddM mfalkvidd

            INTERRUPT is used in the gw.sleep line at the end of the sketch.

            DIGITAL_INPUT_SOIL_SENSOR-2 is an ugly way to change pin number to i terrupt number. In MySensors 2 this has been changed to use digitalPinToInterrupt() instead.

            y4CdW42Ol8Y Offline
            y4CdW42Ol8Y Offline
            y4CdW42Ol8
            wrote on last edited by
            #5

            @mfalkvidd
            So in the build example, should the DO pin of the sensor be hooked to D2 of the Arduino?

            mfalkviddM 1 Reply Last reply
            0
            • mfalkviddM Offline
              mfalkviddM Offline
              mfalkvidd
              Mod
              wrote on last edited by mfalkvidd
              #6

              @y4CdW42Ol8 said:

              Has MySensors 2 been released? Where can I find it and its documentation?

              No it has not been released. Looks like the target date is early July. The development version is available at https://github.com/mysensors/Arduino

              1 Reply Last reply
              0
              • y4CdW42Ol8Y y4CdW42Ol8

                @mfalkvidd
                So in the build example, should the DO pin of the sensor be hooked to D2 of the Arduino?

                mfalkviddM Offline
                mfalkviddM Offline
                mfalkvidd
                Mod
                wrote on last edited by
                #7

                @y4CdW42Ol8 said:

                So in the build example, should the DO pin of the sensor be hooked to D2 of the Arduino?

                No, D0 on the moisture sensor is connected to D3 on the Arduino. See the wiring instructions: https://www.mysensors.org/build/moisture#wiring-things-up

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


                23

                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