49713 Designing for the Internet of Things
· 16 members
A hands-on introductory course exploring the Internet of Things and connected product experiences.
Your plant is like a kitten. It needs care. Know your plant and treat it well.
KnowYourPlant gives a unique personality to your plant. It uses signals (light and sound) to educate you on how to take care of your plant by watering properly
I have a strong personal attachment to plants. In this project, I help the plant to convey its state in an expressive way. The plant needs water to thrive, but it may not be the priority of busy human beings. Instead of an ambient device that fades into the background, it behaves like your naughty cat, catching your attention when it needs care.
I was certain that I want to sense the soil moisture level, so I built the sensor myself in the first week. I first built circuits with sensors (FSR and soil moisture sensor) and outputs (speaker and two LED light). I coded it so that it's blue with a rising tone when moisture, and red with a falling tone when dry.
Then I altered the code so that dryness will result in non-stoping falling tones to harass users. I then realized that this constant reminder can be overwhelming and there should be a trigger to stop the sound when not desired. Nevertheless, an easy stop button will discourage people from watering their plants at the moment. So I set up the trigger as an FSR sensor, with LEGO components on it. In this way, one has to hit really hard on it to stop the sound but also hurting oneself with the bumpy LEGO.
As the saying goes, you never win with violence. This device teaches people the lesson and reminds people to take care of plant properly, just as one may take care of their cats.
int speakerPin = D2;
// create an array for the notes in the melody:
//C4,G3,G3,A3,G3,0,B3,C4
//int melody[] = {1908,2551,2551,2273,2551,0,2024,1908};
//int melody[] = {1915,1700,1519,1700,1915,1915,1915,0,1700,1700,1700,0,1915,1915,1915};
int melodyLow[] = {1915,1700,1519,1300,1300};
int melodyHigh[] = {1300,1519,1700,1915,1915};
// create an array for the duration of notes.
// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {8,8,8,8,4};
// Define a pin that we'll place the FSR on and variable for reading
int fsrPin = A0;
int fsrReading = 0;
// define moist sensor and its value
int moistPin = A5;
int moistVal = 0;
int isMoist = false;
int wasMoist = isMoist;
int ledPinRed = D0;
int ledPinBlue = D5;
void setup() {
pinMode( speakerPin, OUTPUT );
pinMode(ledPinRed, OUTPUT);
pinMode(ledPinBlue, OUTPUT);
// Create a cloud variable of type integer
// called 'light' mapped to photoCellReading
Particle.variable("force", fsrReading);
Particle.variable( "soil", moistVal );
}
void loop() {
// Use analogRead to read the photo cell reading
// This gives us a value from 0 to 4095
fsrReading = analogRead(fsrPin);
// read and print moist value (between 0 and 4095)
moistVal = analogRead(moistPin);
isMoist = moistVal>300;
if (wasMoist != isMoist) {
if ( isMoist ) {
digitalWrite(ledPinBlue, HIGH);
digitalWrite(ledPinRed, LOW);
playNotes(melodyHigh);
delay(1500);
} else {
digitalWrite(ledPinBlue, LOW);
digitalWrite(ledPinRed, HIGH);
playNotes(melodyLow);
}
wasMoist = isMoist;
}
if ( !isMoist ) {
playNotes(melodyLow);
digitalWrite(ledPinRed, HIGH);
if ( fsrReading>700 ) {
delay(8500);
}
delay(500);
}
ThingsBent();
digitalWrite(ledPinRed, LOW);
}
void playNotes(int melody[])
{
// iterate over the notes of the melody:
for (int thisNote = 0; thisNote < 4; thisNote++) {
// to calculate the note duration, take one second
// divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
int noteDuration = 1000/noteDurations[thisNote];
tone(speakerPin, melody[thisNote],noteDuration);
// to distinguish the notes, set a minimum time between them.
// the note's duration + 30% seems to work well:
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
// stop the tone playing:
noTone(speakerPin);
}
}
//ThingsBent
// store the time when you last published
int last_published = -1;
void ThingsBent( ){
// check if 1 minute has elapsed
if( last_published + 60000 < millis() ){
Particle.publish( "ThingsBent", String( fsrReading ) );
last_published = millis();
}
}
A hands-on introductory course exploring the Internet of Things and connected product experiences.
Your plant is like a kitten. It needs care. Know your plant and treat it well.
November 5th, 2019