Mike Schaus
Published © GPL3+

Soil Moisture Sensor Over Cellular for Remote Garden Plot

Remotely monitor soil moisture of your off-site garden plot. Data is plotted in a cloud service so you know when to go and water!

IntermediateFull instructions provided5 hours2,385
Soil Moisture Sensor Over Cellular for Remote Garden Plot

Things used in this project

Hardware components

Hologram Dash
Hologram Dash
×1
Breadboard (generic)
Breadboard (generic)
×1
Lithium Ion Battery Pack
×1
Hologram Global IoT SIM Card
Hologram Global IoT SIM Card
×1
Sugru 5g Pack
×2
SparkFun Soil Moisture Sensor SEN-13322
×1
SK-12 SK Series Polycarbonate Enclosure with Knockouts
×1

Software apps and online services

Arduino IDE
Arduino IDE
Hologram Data Router
Hologram Data Router
Losant Platform
Losant Platform

Story

Read more

Schematics

Wiring schematic

Hiiz3tvq2vzpfvwo1vgy

Wiring schematic

Thanks to Ben (benstr) Strahan for the diagram!
https://www.hackster.io/benstr-hologram
Whf4zgc57dtjtenbnkyw

Code

Soil moisture system code for Hologram Dash

Arduino
/**
 * Soil moisture monitor system with Hologram Dash
 * Mike Schaus
 * Oct 30, 2016
 * Made as part of the Hologram Hacker-In-Residence program
 * 
 * Project based on the Losant IoT Moisture Sensor Kit.
 * Hologram Dash reads sensor and sends data to Hologram cloud.
 * This data is passed to the Losant cloud service for plotting.
 */


// define pins on Dash
const int MOISTURE_POWER_PIN = D01;
const int MOISTURE_SIGNAL_PIN = A01;

void setup() {
  // put your setup code here, to run once:
  
  SerialCloud.begin(115200);
  SerialUSB.begin(9600);
  
  Dash.begin(); // start up the Dash class
  Dash.onLED(); // light on during boot section for sign of life

  pinMode(MOISTURE_POWER_PIN, OUTPUT);

  Dash.snooze(10000); // let me open the serial monitor
  Serial.println("Starting Moisture Sensor Firmware");
  SerialCloud.println("Starting Moisture Sensor Firmware");

  Dash.offLED();
}



void reportMoisture() {
  // Turn on the moisture sensor.
  // The sensor will corrode quickly with current
  // running through it all the time. We just need to send
  // current through it long enough to read the value.

  // Run LED while in this reporting loop for debugging.
  // Can skip LED during deployment to save power.
  Dash.onLED();
  
  digitalWrite(MOISTURE_POWER_PIN, HIGH);

  // Pause a short time to stablize sensor.
  Dash.snooze(100);

  int raw = analogRead(MOISTURE_SIGNAL_PIN);

  // Turn the sensor back off.
  digitalWrite(MOISTURE_POWER_PIN, LOW);

  Dash.offLED();
  
  Serial.println();
  Serial.print("Moisture level: ");
  Serial.println(raw);
  Serial.print("Battery Percentage: ");
  Serial.println(Dash.batteryPercentage());
  Serial.print("Battery millivolts: ");
  Serial.println(Dash.batteryMillivolts());

//  Let's build a JSON-compatible string to send to the cloud!
//  Complete string will look something like:
//  {"moisture": 100,"battery_level": 80}
//  FYI the " characters are escaped by typing \"
  SerialCloud.print("{\"moisture\": ");
  SerialCloud.print(raw);
  SerialCloud.print(",\"battery_level\": ");
  SerialCloud.print(Dash.batteryPercentage());
  SerialCloud.println("}");
}

void loop() {
  // put your main code here, to run repeatedly:
  
// two-way serial passthrough for seeing debug statements
  while(SerialUSB.available()) {
    SerialCloud.write(SerialUSB.read());
  }
  while(SerialCloud.available()) {
    SerialUSB.write((char)SerialCloud.read());
  }

// main operation timing code
  Dash.snooze(60000); //allow time for modem to connect
  reportMoisture();
  Dash.deepSleepMin(60);

}

Credits

Mike Schaus

Mike Schaus

2 projects • 36 followers
In addition to being a maker, I am a professional product development engineer, problem solver, and project leader.
Contact

Comments

Add projectSign up / Login