Project showcase

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

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

  • 949 views
  • 1 comment
  • 10 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

Development Board for AtTiny MCU

by Vincenzo G.

  • 159 views
  • 0 comments
  • 5 respects

The Magnetic Field and RGB Tester

Project tutorial by Kutluhan Aktar

  • 344 views
  • 0 comments
  • 5 respects

Version 2.0 Advanced Attendance System (Without Ethernet)

Project tutorial by GadgetProgrammers

  • 3,059 views
  • 5 comments
  • 44 respects

Ultrasonic Security System

Project tutorial by Krepak

  • 532 views
  • 2 comments
  • 7 respects

Control LED Using Your Voice Command

by IoTBoys

  • 1,113 views
  • 1 comment
  • 12 respects
Add projectSign up / Login