Antonio Ruiz
Published © GPL3+

Characterisation of soil properties using a simple device

We developed a simple, low-cost equipment for the study of soil chemistry and morphology using an arduino microcontroller.

AdvancedWork in progress1,465
Characterisation of soil properties using a simple device

Things used in this project

Hardware components

Peristaltic Liquid Pump with Silicone Tubing - 12V DC Power
×1
IRF520 MOSFET Driver Module PWM Output 0-24V 5A for Arduino MCU ARM Raspberry Pi
×1
Adafruit RGB Color Sensor with IR filter and White LED - TCS34725
×1
SparkFun RGB LED Breakout - WS2812B
SparkFun RGB LED Breakout - WS2812B
×1
Arduino UNO
Arduino UNO
×1
Through Hole Resistor, 200 kohm
Through Hole Resistor, 200 kohm
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Code employed for the sedimentation and electrical resistance measurements

Arduino
Code used to operate the hydrometer we designed. Further details about how it works can be found within the min text.
#include <Wire.h>
#include "Adafruit_TCS34725.h"

Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_700MS, TCS34725_GAIN_1X);

#define PUMP 7

int m, n, i, Cond;
int x1 = 0;
float x, y;
int t = 0;

int val[2];

void setup(void) {
  Serial.begin(9600);

  if (tcs.begin()) {
    Serial.println("Found TCS34725 sensor");
  } else {
    Serial.println("No TCS34725 found ... check your connections");
    while (1);
  }
  
Serial.print("Time:");
Serial.print("\t");
Serial.print("Lux:");
Serial.print("\t");
Serial.print("Red:");
Serial.print("\t");
Serial.print("Green:");
Serial.print("\t");
Serial.println("B:");

pinMode (PUMP, OUTPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);

val[0] = -1;
val [1] = -2;
m = 1;
}

void loop(void) {
  uint16_t r, g, b, c, colorTemp, lux;

  tcs.getRawData(&r, &g, &b, &c);
  colorTemp = tcs.calculateColorTemperature_dn40(r, g, b, c);
  lux = tcs.calculateLux(r, g, b);

if (m==1){
    digitalWrite (PUMP, LOW);
c = analogRead (A3);
if (c>1000){
m = 2;
n = 1;
y = micros ()/1000000;
t = 0;
} 

}
if (m==2){

  x = (micros()/1000000) - y;
  Serial.print (x);
  Serial.print("\t");
  Serial.print(lux, DEC); 
  Serial.print("\t");
  Serial.print(r, DEC); 
  Serial.print("\t");
  Serial.print(g, DEC); 
  Serial.print("\t");
  Serial.print(b, DEC); 
  Serial.print("\t"); 
  Serial.print(c, DEC); 
  Serial.println("\t");

    if (n==2 && x>60){
    val[1] = lux;
  }
    if (n==1){
    val[0] = lux;
    n=2;
  }

 if (x>3000){
 m = 3;
}
}

if (m==3){

if (t<5){
  for (i=0; i<5; i++){
  digitalWrite (PUMP, HIGH);
  delay (1000);
  digitalWrite (PUMP, LOW);
  for (i=0; i<10; i++){
  Cond = analogRead (A2);
  Serial.print("\t\t\t\t\t\t");
  Serial.println(Cond);
  delay (1000);
  }
    t++;
  }

}
  digitalWrite (PUMP, LOW);
  Cond = analogRead (A2);
  Serial.print("\t\t\t\t\t\t");
  Serial.println(Cond);
  delay (1000);
  
if (x1>550){
  m = 1;
}
x1++;
}

}

Credits

Antonio Ruiz

Antonio Ruiz

7 projects • 22 followers
Research Associate at University of Cambridge

Comments