Giter VIP home page Giter VIP logo

arduino-soilsense's Introduction

Arduino-SoilSense

Overview

This is a soil moisture sensor library for Arduino. Connect the pins to the analog pin (requires pull-down resistor) and the 5V pin. If you use this library, the soil moisture will be returned in the range of 0-100. You can also make your own sensor terminals using metal bars or aluminum tape.

Soil moisture sensor

Demo

/*
 * LED ------ 11 Pin
 * Speaker -- 12 Pin
 * Sensor --- A0 Pin
 */

#include <SoilSense.h>

SoilSense ss = SoilSense(A0);
int time = 0;

void setup () {
  Serial.begin(9600);
  pinMode(11, OUTPUT);
  ss.init(650, 800, 10, 95);
}

void loop () {
  byte val = ss.value();
  if(time >= 1000 / (val + 1)){
    time = 0;
    tone(12, 440, 50);
    digitalWrite(11, HIGH);
  }else{
    time++;
    digitalWrite(11, LOW);
  }
  delay(10);
  Serial.println(val);
}

Usage

Method

SoilSense SoilSense(uint8_t pin)

    pin: Analog pin number

    Create an instance.

SoilSense.init(int min, int max, byte samples = 10, byte lowpass = 20)

    min: Value when the soil is dry. Get with measure().
    max: The maximum amount of soil that can contain water. Get with measure().
    samples: The number of samplings.
    lowpass: The value of the low pass filter. The larger the value, the smoother it becomes.

    Initialize SoilSense.

SoilSense.measure(byte samples = 10)

    samples: The number of samplings.

    The raw value of the sensor. The range of values is 0 to 1023.

SoilSense.value()

    Returns the soil moisture in bytes. The range of values is 0 to 100.

License

MIT

arduino-soilsense's People

Contributors

naoto64 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.