Moisture Sensor

From Nearwiki
Jump to: navigation, search


  • Code Source: n/a
  • Technical Spec: Humidytly: 5% RH - 99% RH - Temperature -40°C - 80°C - Acuracy: 2% RH / 0.5°C



Grove Moisture Sensor


Moisture sensor.jpg



Grove Moisture Circuit


Moisture sensor circuit.jpg



MyNbios Code - Example


In order to run this code you should copy the following code into the area delimited by the MY_NBIOS CUSTOM CODE banners in the Hello_World_xxx.ino example.

void Nearbus::MyNbios_0( byte portId, ULONG setValue, ULONG* pRetValue, byte vmcuMethod, PRT_CNTRL_STRCT* pPortControlStruct )
{

    //************************************
    // Reconfiguring Ports as I/O
    //************************************
    if( pPortControlStruct->portMode != MYDRIVER_ODE ) 
    {
	    PortModeConfig( portId, MYDRIVER_MODE );        
    }

    //************************************
    // Custom Function
    //************************************
    // DEFAULT:      The default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards)
    // INTERNAL:     An built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328 and 2.56 volts on the ATmega8 (not available on the Arduino Mega)
    // INTERNAL1V1:  A built-in 1.1V reference (Arduino Mega only)
    // INTERNAL2V56: A built-in 2.56V reference (Arduino Mega only)
    // EXTERNAL:     The voltage applied to the AREF pin (0 to 5V only) is used as the reference. 	
	
	
    analogReference( DEFAULT );	

    *pRetValue = (ULONG) analogRead( pPortControlStruct->anaPinId );    
  
}