Project in progress
Connected Soil Moisture Sensor

Connected Soil Moisture Sensor © GPL3+

Simple Arduino/Genuino 101 BLE connected soil moisture sensor. Pair with IoT service to monitor and record measurements.

  • 4,213 views
  • 0 comments
  • 7 respects

Components and supplies

Ardgen 101
Arduino 101 & Genuino 101
×1
Soil Moisture Sensor
Can also use Sparkfun's moisture sensor
×1
Mfr 25frf52 10k sml
Resistor 10k ohm
Pullup for analog input.
×1

About this project

This is a very basic project that connects an analog moisture sensor to an Arduino/Genuino 101 board. The firmware takes measurements every 500ms and stores the value in a BLE characteristic that can be read. Use nRF Connect or write your own BLE code to read the values as they change.

This is one of a few sensors I'm creating for a larger smart home automation concept. Most of them will work in a similar manner, with either an analog or digital value being read and then shared via BLE.

Code

Soil Moisure Sensor Arduino/Genuino 101 CodeArduino
Upload the code to your Arduino/Genuino 101. Use an app like nRF Connect or write your own BLE code to read/receive updated values for the soil moisture sensor.
#include <BLEAttribute.h>
#include <BLECentral.h>
#include <BLECharacteristic.h>
#include <BLECommon.h>
#include <BLEDescriptor.h>
#include <BLEPeripheral.h>
#include <BLEService.h>
#include <BLETypedCharacteristic.h>
#include <BLETypedCharacteristics.h>
#include <BLEUuid.h>
#include <CurieBLE.h>

//Soil sensor analog input pin
const int soilPin = A0;

BLEPeripheral blePeripheral;

//Soil Service and Characteristic - Custom UUID
BLEService soilService("19B10030-E8F2-537E-4F6C-D104768A1214");
BLEIntCharacteristic soilCharacteristic("19B10031-E8F2-537E-4F6C-D104768A1214", BLERead | BLENotify);





void setup() {
  //Set peripheral name and advertised services.
  blePeripheral.setLocalName("SoilSense");
  blePeripheral.setAdvertisedServiceUuid(soilService.uuid());
  blePeripheral.addAttribute(soilService);
  blePeripheral.addAttribute(soilCharacteristic);
  //set initial soil value to 0
  soilCharacteristic.setValue(0);
  //start peripheral
  blePeripheral.begin();
}

void loop() {
  //poll peripheral and read/set value
  blePeripheral.poll();
  int soilValue = analogRead(soilPin);
  Serial.println(soilValue);
  boolean soilChanged = (soilCharacteristic.value() != soilValue);

  if (soilChanged) {
    soilCharacteristic.setValue(soilValue);
  }
  //delay
  delay(500);
 }

Schematics

Soil Moisture Sensor Layout
Fritzing layout of basic soil moisture sensor.
soilSensor.fzz

Comments

Similar projects you might like

Soil Moisture Sensor With LCD Display

Project tutorial by Patel Darshil

  • 22,303 views
  • 6 comments
  • 39 respects

The Quantified Cactus: An Easy Plant Soil Moisture Sensor

Project tutorial by Jen Looper

  • 7,444 views
  • 2 comments
  • 26 respects

Thirsty Flamingo Soil Moisture Sensor

Project tutorial by circuito.io team

  • 2,583 views
  • 1 comment
  • 7 respects

BLE Sharp Dust Sensor - ARTIK IoT Cloud

Project tutorial by Elijah Scheele

  • 4,323 views
  • 1 comment
  • 21 respects

Using the YL-39 + YL-69 Soil Humidity Sensor with Arduino

Project tutorial by Sorin Trimbitas

  • 28,112 views
  • 6 comments
  • 17 respects

DIY Soil Moisture Monitor With Arduino and a Nokia 5110 D...

Project tutorial by Nick Koumaris

  • 2,864 views
  • 0 comments
  • 12 respects
Add projectSign up / Login