lukasmaximus89
Published © CC BY-NC-SA

Do Plants Have Feelings?

Let your house plant show you what its feeling with this simple project that uses M5Stack and a soil moisture sensor.

IntermediateFull instructions provided1 hour750
Do Plants Have Feelings?

Things used in this project

Hardware components

M5GO Lite IoT Development Board Kit
M5Stack M5GO Lite IoT Development Board Kit
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Connect the earth sensor to port B

Make sure the grove cable is plugged the correct way round, there are some plastic nibs on the bottom of the connector which are intended to guide it into the socket in the correct orientation

Code

Plantsmood.ino

C/C++
This code also requires this avatar faces library which can be found at https://github.com/meganetaaan/m5stack-avatar
#include <M5Stack.h>
#include <Avatar.h>

using namespace m5avatar;

Avatar avatar;

const Expression expressions[] = {
  Expression::Angry,
  Expression::Sleepy,
  Expression::Happy,
  Expression::Sad,
  Expression::Doubt,
  Expression::Neutral
};

const int expressionsSize = sizeof(expressions) / sizeof(Expression);
int idx = 0;

void setup() 
{
  M5.begin();
  M5.Lcd.setBrightness(30);
  M5.Lcd.clear();

  avatar.init();
  avatar.setExpression(expressions[idx]);
  idx = 0;
}

void loop() 
{
  int adc = analogRead(36);
  adc = map(adc, 4095, 0, 0, 255);

  M5.update();
  if (adc <=5)
  {
    avatar.setExpression(expressions[idx]);
    idx = 3;
  }
  else if (adc > 10 && adc < 40)
  {
    avatar.setExpression(expressions[idx]);
    idx = 2;
  }
  Serial.println(adc);
  delay(2);
}

Credits

lukasmaximus89

lukasmaximus89

39 projects • 17 followers
I'm Luke from Manchester, UK. I've been living in shenzhen for 6 years. I do 3D design, Basic Electronics, Casting and other cool stuff.

Comments

Add projectSign up / Login