Project showcase

Christmas tree water level via Cayenne and MKR1000 © CC BY

When you have a 'real' Christmas tree, it is important to keep it watered. This project monitors the water level and emails alerts.

  • 1,045 views
  • 0 comments
  • 2 respects

Components and supplies

Apps and online services

About this project

Overview

When you have a fresh cut Christmas tree, it is very important to keep it watered. The unfortunate thing that happens when the tree dries out is the needles fall off, causing the tree to be ugly and making quite the mess under the tree. The dangerous thing that happens with a dry tree is it becomes an extreme fire hazard.

I find that remembering to keep the tree watered is sometimes a problem for me, and when I do remember to water it, I have difficulty seeing the water level in the tree stand because it is under the tree.

To solve these problems, I needed something that could remind me to put water in the tree stand when it was needed, as well as something to sense the level and indicate it locally, so I wouldn’t overfill and make a mess.

The heart of the system is an Arduino MKR1000. The on-board Wi-Fi of the MKR1000 very much simplifies the communications link from the project to internet. For remote monitoring, alerts and triggering, I chose myDevices Cayenne, an IoT project builder.

The Sensor

The sensor is a very inexpensive analog water sensor that outputs a value from 0 to 1024. All sensors are different and you should do a test to find what values are output depending on the water level on your sensor.

The range of values I found for my sensor are:

  • 0-249 near empty or dry
  • 250-349 low
  • 350-389 good
  • > 390 full

I mounted the breadboard on the side of the tree stand so I could see the level LEDs while adding water. Of course, the water sensor is on the inside at the appropriate level.

Cayenne

I set up a very simple dashboard in Cayenne that indicates the level via a gauge that also changes color depending on the value. These colors and values are the same as the LEDs on the local display.

The real power of Cayenne is in its ability to set up triggers and alerts. I entered settings to send me both text messages and e-mails.

Now when the water level in my Christmas tree stand gets low, I am alerted via e-mail and text messaging, and while filling the stand, I have level indicators right on the stand so I now know when to stop adding water.

Schematics

Fritzing breadboard layout

Code

Christmas tree water level codeArduino
/*
Cayenne MKR1000 Example

This sketch connects to the Cayenne server using an Arduino/Genuino MKR1000 and runs the main communication loop.

The Cayenne Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager.

Steps:
1. Install the Arduino SAMD Boards from the Arduino Boards Manager if you have not done so already.
2. Install the WiFi101 library (https://github.com/arduino-libraries/WiFi101) from the Arduino Library Manager if you have not done so already.
3. Select the Arduino/Genuino MKR1000 board and the correct port in the Arduino IDE.
4. Set the token variable to match the Arduino token from the Dashboard.
5. Set the network name and password.
6. Compile and upload this sketch.

For Cayenne Dashboard widgets using digital or analog pins this sketch will automatically
send data on those pins to the Cayenne server. If the widgets use Virtual Pins, data
should be sent to those pins using virtualWrites. Examples for sending and receiving
Virtual Pin data are under the Basics folder.
*/

#define CAYENNE_DEBUG         // Uncomment to show debug messages
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <CayenneMKR1000.h>

// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "put your token here";
// Your network name and password.
char ssid[] = "put your ssid here";
char password[] = "put your wifi password here";

int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;

void setup()
{
  // initialize the digital pins as an outputs.
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  
  Serial.begin(9600);
  Cayenne.begin(token, ssid, password);
}

void loop()
{
  Cayenne.run();

  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  Serial.println(sensorValue);
  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);
  if (sensorValue > 10) {digitalWrite(led1, HIGH); }
  if (sensorValue > 250) {digitalWrite(led2, HIGH); }
  if (sensorValue > 350) {digitalWrite(led3, HIGH); }
  if (sensorValue > 390) {digitalWrite(led4, HIGH); }

  
  delay(250);        // delay in between reads for stability
}

// These functions are called when the Cayenne widget requests data for the Virtual Pin.
CAYENNE_OUT(V0)
{
  Cayenne.virtualWrite(V0, analogRead(A0));
}
create.arduino.cc code
Opens code in the Arduino Web Editor

Comments

Submitted to Contest

From 11th to 25th prize

The Arduino Internet of Holiday Things

Author

Contest1 2246 9mbxbzxnth
Ian Zahn
  • 1 project
  • 5 followers

Additional contributors

  • His hackster.io project helped me get the libraries correct by Giovanni Gentile
  • His hackster.io project helped me get the cayenne code correct by Benny Estes

Published on

January 30, 2017

Members who respect this project

Tad2000Profile picture
See similar projects
you might like

Similar projects you might like

Online Attendance System (Without Ethernet)

Project tutorial by gadgetprogrammer

  • 405 views
  • 5 comments
  • 8 respects

Windows PC Lock/Unlock Using RFID

Project tutorial by Prasanth K S

  • 6,992 views
  • 6 comments
  • 30 respects

Makers (Cubecon) #1 Infrared Transmit & Infrared Receive

Project in progress by Alpha

  • 178 views
  • 0 comments
  • 4 respects

Arduino Keyboard

Project in progress by Gabriele Scordamaglia

  • 532 views
  • 4 comments
  • 5 respects
Add projectSign up / Login