Project showcase

Moisty v2 - a Plant Moisture Sensor © CC BY-NC

This is a 6x plant moisture sensor using Cayenne & a 3D printed case.

  • 499 views
  • 1 comment
  • 7 respects

Components and supplies

Necessary tools and machines

3d printer

Apps and online services

About this project

This a project is to make a device that checks up to six plants moisture levels and returns the value as a percent. I used generic soil sensors and soldered them directly to the PCB board and then the probs connect on the top. It connects to Cayenne by a ESP8266-01 chip & the main board is a Arduino Pro Mini. It energizes the soil sensor board, takes the analog reading, and then turns the board back off. This helps quite a bit in slowing corrosion of the probes. All the data is sent to Cayenne so it can be viewed on a dashboard.

I also designed simple case to hold it which I included.

Custom parts and enclosures

Case_top
STL of the top of the case
Case_bottom
bottom of the case

Schematics

Circuit
Plantmoisture schem yzrxgcbxyu

Code

Moisty codeArduino
#include <Arduino.h>
#include <CayenneESP8266Shield.h>

#define SERIAL_BUFFER_SIZE    256
#define SERIAL_TX_BUFFER_SIZE 256
#define SERIAL_RX_BUFFER_SIZE 256


char token[] = "token";
char ssid[] = "wifi";
char password[] = "wifipassword";

#define EspSerial             Serial
ESP8266 wifi(EspSerial);

const unsigned long interval = 120000;  // milliseconds to check moisture

unsigned long time1 = 0;
unsigned long onlineTime;
unsigned long prevTime;

byte disco = 0;


void setup()
{
	EspSerial.begin(9600);
	delay(10);

	pinMode(2, OUTPUT);
	pinMode(3, OUTPUT);
	pinMode(4, OUTPUT);
	pinMode(5, OUTPUT);
	pinMode(6, OUTPUT);
	pinMode(7, OUTPUT);
	pinMode(13, OUTPUT);

	Cayenne.begin(token, wifi, ssid, password);
}



void loop()
{
	Cayenne.run();

	if (millis() - time1 > interval)
	  {
		  runMoist();
		  time1 = millis();
	  }
}



void runMoist()
{
	int x = 2; // pwr pin
	int y = 0; // data
	int z = 1; // channel


	for (byte i = 0; i <= 6; i++)
	  {
		  checkMoist(x, y, z);
		  x++;
		  y++;
		  z++;

		  if (y == 4)
		    {
			    y = 6;
		    }
	  }
}


void checkMoist(byte pwrPin, byte dataPin, byte channel)
{
	digitalWrite(pwrPin, HIGH);
	delay(300);
	float plant = ( 1024 - analogRead(dataPin) );
	byte plantPer = float(plant / 800) * 100;  // ~800 is top range for my sensors

	digitalWrite(pwrPin, LOW);

	Cayenne.virtualWrite(channel, plantPer);

}





CAYENNE_CONNECTED()
{
	prevTime = millis();
	digitalWrite(13, HIGH);

}

CAYENNE_DISCONNECTED()
{
	disco++;
	digitalWrite(13, LOW);
}



CAYENNE_OUT(V23)
{
	Cayenne.virtualWrite(V23, disco);
}

CAYENNE_OUT(V24)
{
	float time2 = ( millis() / 1000 ) / 60;
	Cayenne.virtualWrite(V24, time2);
}

CAYENNE_OUT(V25)
{
	onlineTime = ( ( millis() - prevTime ) / 1000 ) / 60;
	Cayenne.virtualWrite(V25, onlineTime);
}

Comments

Similar projects you might like

Vintage Bench-Top DC Hybrid Voltmeter using Arduino

Project tutorial by Shahariar

  • 271 views
  • 0 comments
  • 6 respects

Automation of Railway Models Part 1 - Sensors

Project tutorial by Steve_Massikker

  • 821 views
  • 3 comments
  • 13 respects

Binary Clock with Arduino and Plywood

Project tutorial by Kalle Wallin

  • 250 views
  • 1 comment
  • 6 respects

Arduino Sunflower

Project tutorial by Rick_Findus

  • 1,993 views
  • 3 comments
  • 10 respects

LittleBot Simple Arduino Robot

Project showcase by Slant Concepts

  • 591 views
  • 0 comments
  • 9 respects
Add projectSign up / Login