Moisture Sensor example sketch



  • 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.



  • 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.


  • Mod

    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.



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



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


  • Mod

    @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


  • Mod

    @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


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.