Things used in this project

Hardware components:
11113 01
SparkFun Arduino Pro Mini 328 - 5V/16MHz
×1
Esp01
Everything ESP ESP8266 ESP-01
×1
12035 01
SparkFun microB USB Breakout
×1
SparkFun Voltage Regulator - 3.3V
×1
100uf Capacitor
×2
Soil moisture sensor
×6
Blank PCB board
×1
Software apps and online services:
Cayenne logo hi
myDevices Cayenne
Hand tools and fabrication machines:
3d printer

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);
}

Credits

Fish tah1tatkn3
Mitch K
0 projects • 8 followers
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog