moisture measure + servo with XMC 1300 Boot Kit

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hello Community,

My task is to realise a project to water flowers. I have done this project for my arduino already but have no experience with the XMC 1300. The circuit on the Arduino goes like this:


/*  
moisture measure:

digital 2---*
|
\
/
\ R1
/
|
|
analog 0----*
|
|
*----> wire 1

*----> wire 2
|
|
|
digital 3---*

Servo:
yellow: A1
red: 5V
black: GND
*/
#define moisture_input 0
#define divider_top 2
#define divider_bottom 3

#include

Servo servo1;

int moisture; // analogical value obtained from the experiment

int SoilMoisture(){
int reading;
// set driver pins to outputs
pinMode(divider_top,OUTPUT);
pinMode(divider_bottom,OUTPUT);

// drive a current through the divider in one direction
digitalWrite(divider_top,LOW);
digitalWrite(divider_bottom,HIGH);

// wait a moment for capacitance effects to settle
delay(1000);

// take a reading
reading=analogRead(moisture_input);

// reverse the current
digitalWrite(divider_top,HIGH);
digitalWrite(divider_bottom,LOW);

// give as much time in 'reverse' as in 'forward'
delay(1000);

// stop the current
digitalWrite(divider_bottom,LOW);

return reading;
}


void setup () {
servo1.attach(A1);
servo1.write(0);
Serial.begin(19200);

}

void loop (void) {
moisture=SoilMoisture(); // assign the result of SoilMoisture() to the global variable 'moisture'
Serial.print("Soil moisture: ");
Serial.print(moisture);
Serial.println();
if(moisture < 100)
{
Serial.print("watering flower");
Serial.println();

servo1.write(180);
delay(1000);
servo1.write(0);
}
delay(100);
}


But I have no idea how to realise it for the XMC 1300. Please help me.

I would be happy if someone could help me.
0 Likes
7 Replies
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
Hi Honsebanger,

Can you provide what are the device which is to be connected to the XMC1300? eg servo motor etc...

Best Regards
Travis
0 Likes
Juergen
Employee
Employee
Hi,

From your schematic I am guessing that you are using conductivity to measure soil humidity, am I correct?
A better way may be to use capacitance. The advantage is that you are not affected by corrosion. We do have a very good module in our XMC1200 which was primarily designed for capacitive touch sensing. I have however used it successfully for measuring water level in my aquarium. The idea is to make a capacitor of two copper plates(can be copper area on a pcb). These plates have, in your case, soil as the dielectric. The dielectric constant changes as the moisture content of the soil changes which in turn changes the capacitance. Our module(LEDTS) works on the principle of an RC oscillator with a fixed resistor and a variable capacitor( the sensor element). The beauty of this is that you can have everything on one pcb, including the sensing copper area and you can insulate this. Let me know if you are interested in that, I can let you have some example code.

Best Regards
Jurgen
0 Likes
Not applicable
I am using a servo motor to water the flower.

@Juergen
I am really interested in some example code.

Thanks for your help 🙂
Honsebanger
0 Likes
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
Honsebanger wrote:
I am using a servo motor to water the flower.

@Juergen
I am really interested in some example code.

Thanks for your help 🙂
Honsebanger


Hi Honsebanger,

I believe you are using a hobby servo motor which uses simple PWM to control the motor.

656.attach

If Yes, then you can use the PWMSP001 app to generate the necessary frequency and duty cycle to control your servo motor. Example of this apps can be obtain from

http://www.infineon.com/cms/en/product/promopages/aim-mc/DAVE_3_Support_Portal/DAVE_Example_Project_...

More detail about servo motor basic...

http://www.jameco.com/jameco/workshop/howitworks/how-servo-motors-work.html


G@@d LUCK
Travis
0 Likes
Not applicable
Thank you Travis. This helps me a lot 😄
0 Likes
Not applicable
Hi Honsebanger,

I did similar project on XMC4500 relax lite kit:
- measure moisture(with same sensor), temperature(termistor) and light(based on solar panel output voltage),
- turn on pump(also with servo, becuase I did not have a proper switch)
- make a shadow with servo and piece of paper
- also small web server run on XMC and you can see all parameters and run shudow/watering from the net

you can find small(and ugly 🙂 ) video here:
http://www.youtube.com/watch?v=9qMNGCtV-RQ

I'll try to find sources, but it seems hat it could be lost 😞
0 Likes
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
Hi u Sasha,

Can you take this moment to post your wonderful project with this video clip into the Technical center?

http://www.infineonforums.com/forums/18-technical-center

Best Regards
Travis
0 Likes