Page 1 of 2

Moisture sensor SN-M114

PostPosted: Thu Aug 30, 2012 11:59 pm
by qinhong
Hi, i plan to use this moisture sensor to determine the moisture level of the soil in my project, and the sensors are controlled by micro-controller PIC 16F877A. In the schematic diagram given, what is the function of R1 and R2? what what Q1 model is required? Besides, i don't understand the sample code given. is it using C++ or C# ?

Re: Moisture sensor SN-M114

PostPosted: Fri Aug 31, 2012 1:41 am
by kl84
qinhong WROTE:In the schematic diagram given, what is the function of R1 and R2? what what Q1 model is required?

The schematic given is actually the sensor's circuit. It's not telling you to connect in that way. What you need to do is connect power supply to Pin-2 and 3 of CON3, then your microcontroller's analog pin to Pin-1 of CON3.

qinhong WROTE:Besides, i don't understand the sample code given. is it using C++ or C# ?

The sample code is for Arduino, and it's C++ language. If you have an Arduino, you can load the program and that's it. Since you are using PIC16F, you can have a look at Cytron Tutorial page. I think there should have a project on using ADC. This page is for Getting Started with SK40C.

Re: Moisture sensor SN-M114

PostPosted: Fri Aug 31, 2012 3:00 pm
by qinhong
thanks... my project is about connecting water level sensor, moisture sensor and rain sensor together and control them by PIC16F. the thing that 1 worry is will the PIC suitable to connect all of them? the current and voltage supply enough or not?

Re: Moisture sensor SN-M114

PostPosted: Sat Sep 01, 2012 12:42 am
by ABSF
qinhong WROTE:thanks... my project is about connecting water level sensor, moisture sensor and rain sensor together and control them by PIC16F. the thing that 1 worry is will the PIC suitable to connect all of them? the current and voltage supply enough or not?


Shouldnt be any problem for the PIC. The 877A has 8 ADC channels. You may connect water level & moisture sensor to 2 analogue channels while the rain sensor goes to a digital input. Unless there are motors and fans connected, power supply is not a problem.

You can either poll the sensor devices one by one in your program or use interrupts which are all up to your program design.

Allen

Re: Moisture sensor SN-M114

PostPosted: Sat Sep 01, 2012 11:31 pm
by qinhong
thanks,.. my project consist of 4 moisture sensors, 1 water level sensor, 1 rain sensor and 3 solenoid valve. all these components are controlled by a micro-controller PIC16F877A.
~ why rain sensor need to connect to digital input?
~ what is means by interrupts? where i can get all these programming ?
~ do u have any product suggestion about the solenoid valve that use to control the water passage in piping system?
sorry, im very poor in practical...

Re: Moisture sensor SN-M114

PostPosted: Mon Sep 03, 2012 12:29 pm
by ABSF
qinhong WROTE:~ why rain sensor need to connect to digital input?


Unless you want to detect the "amount of rain" - 10% rain, small rain, heavy rain or shower, instead of just detecting raining or not_raining, then of course, you'll need an analog input.

qinhong WROTE:~ what is means by interrupts? where i can get all these programming ?


"Interrupt" is just a concept used in micro-processor and micro-controller. It's like while you're doing your homework and the phone rings. You'll attend the phone call immediately, finish the phone call, and come back to continue with your homework. The phone call is considered as an interrupt in computer analogy.

You can google "interrupt on PIC" or search for the work "interrupt" on this forum and find a lot of references to it.

qinhong WROTE:~ do u have any product suggestion about the solenoid valve that use to control the water passage in piping system?
'

No I dont have any.

qinhong WROTE:sorry, im very poor in practical...


It requires time and practice. Lots of practices make perfect.

Allen

Re: Moisture sensor SN-M114

PostPosted: Thu Sep 06, 2012 11:44 am
by qinhong
hi, i tried to test the functionality of this moisture sensor using MPLAB with the help of SK40C but it cant works... I seriously need some help...

;configurations
LIST P=16F877A,W=-302
#include <16f877a.inc>
__Config 0x3D72; HS MODE, WDT OFF, BOREN

BANK_0 EQU 0X00
BANK_1 EQU 0X80
BANK_2 EQU 0X100
BANK_3 EQU 0X180
ORG 0X00

;program starts
movlw B'111111' //set all pin as input
BANKSEL BANK1 //activate bank 1
movwf TRISA //copy w to TRISA

movlw B'00000000' //Set all pin as output
movwf TRISB //copy W to TRISB

movlw B'10000000' //send 1 to pin 7
BANKSEL BANK_0 //activate bank 0
movwf PORTB //copy W to PORTB (LED at RB7 ON)

Loop goto Loop
END

Re: Moisture sensor SN-M114

PostPosted: Fri Sep 07, 2012 1:19 am
by ABSF
Try this:

CODE: SELECT_ALL_CODE
;configurations
   LIST P=pic16F877A,W=-302
#include <p16f877a.inc>
__Config 0x3D72; HS MODE, WDT OFF, BOREN

BANK_0   EQU 0X00
BANK_1   EQU 0X80
BANK_2   EQU 0X100
BANK_3   EQU 0X180
   ORG 0X00

;program starts
   movlw   B'111111' ;//set all pin as input
   BANKSEL   BANK_1    ;//activate bank 1
   movwf   TRISA    ;//copy w to TRISA

   movlw   B'00000000' ;//Set all pin as output
   movwf   TRISB    ;//copy W to TRISB

   movlw   B'10000000' ;//send 1 to pin 7
   BANKSEL   BANK_0    ;//activate bank 0
   movwf   PORTB    ;//copy W to PORTB (LED at RB7 ON)

Loop   goto   Loop
   END


Allen

Re: Moisture sensor SN-M114

PostPosted: Mon Sep 10, 2012 2:09 pm
by qinhong
erm... in the document given, the moisture sensor will sense the resistance between the probe...
for example, 0-300 indicates dry soil, 301-700 indicates normal and >700 indicates in the water.
how my programming include all these things

Re: Moisture sensor SN-M114

PostPosted: Thu Sep 13, 2012 2:44 pm
by qinhong
anyone that can teach me how to write the programming that connect this sensor and pic16f877a together??? urgent!!!
thanks