Project showcase
Christmas Tree Water Level via Cayenne and MKR1000

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.

  • 6 respects

Components and supplies

Apps and online services

About this project


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.


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.


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.

1. Install the Arduino SAMD Boards from the Arduino Boards Manager if you have not done so already.
2. Install the WiFi101 library ( 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);
  Cayenne.begin(token, ssid, password);

void loop()

  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  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.virtualWrite(V0, analogRead(A0));
} code
Opens code in the Arduino Web Editor


Fritzing breadboard layout


Submitted to Contest


The Arduino Internet of Holiday Things


Contest1 2246 9mbxbzxnth
Ian Zahn
  • 1 project

Additional contributors

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

Published on

January 30, 2017

Members who respect this project

Tad2000Profile pictureDefault

and 3 others

See similar projects
you might like

Similar projects you might like

Arduino MKR1000 Weather Station

Project tutorial by Tadeas Dvoracek

  • 28 respects

MKR1000 Christmas IoTree with Cayenne Project Builder

Project tutorial by Benny Estes

  • 9 respects

Hackable Christmas Greeting Card

Project tutorial by Neoxelox

  • 4 respects

Control your MKR1000 with aREST Framework

Project showcase by vincent wong

  • 24 respects

Sigfox to Cayenne

Project showcase by Tadeas Dvoracek

  • 6 respects

Arduino MKR1000 & Thinger

Project tutorial by Lintang Wisesa

  • 5 respects
Add projectSign up / Login