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 needs your protection to grow sturdily. Don't forget to save it from severe weather outdoors when you have it outside for fresh air and sunshine.
This Internet of Plant is designed for people like my mother who keep flowers outdoors on the balcony. They sometimes forget to bring their plants inside when the weather is extreme, which will do harm to the plants. My design is to show them the weather condition and help remind them when they need to take actions.
4. Reflections:
The code and functions are very basic at this phase. So I think the idea of the project is very important like the space for further development, the creativity and the interaction. Besides, it is helpful to pay attention to the structure of the code for further development of complex functions.
5. Challenges encountered and solutions:
5.1 Technically, it’s a challenge to measure which turning point of the value I should put in the code so that the LED can change to indicate the change of the sensor data effectively. I did experiments to identify how the data of the sensor change with the change of the real environment.
5.2 For design, it is challenging to come up with a
way to indicate the change to the user. As I only choose to use two LEDs and a
piezo, I need to use the blinks and color of LEDs to show the interaction, and
use piezo at an appropriate point. I would think in a way that if I could have
more resources, how I would transform the current interaction into a more mature
one.
1. Use IFTTT to send the alarm to send email or message to the user to remind them in time.
2. Test the Photoregister with the change of illumination intensity, and correspond the data to the real illumination intensity level (eg. LUX).
3. Do desktop researches of how these environmental
indicators influence the growth of plants, and then adjust the changes of LEDs
and buzzer.
Through this project, I managed to put together what
we learned and practiced during the last two weeks and added some interesting
ideas of my own as well. It is more meaningful when using sensors and LEDs to
realize functions for things in the real world. I hope I can further develop my
ideas as well as my coding skills and deepen my understanding of IoT, so that I
can come up with a more mature design at the end of this course.
#include <libfixmath.h>
#include <spark-dallas-temperature.h>
#include <OneWire.h>
int sensorBend=A2;
int sensorLight=A4;
int ledRed=D2;
int ledBlue=D3;
int ledGreen=D4;
int sensorValueBend;
int sensorValueLight;
int ledAlarm=D7;
float tempC;
int BendBright;
int LightBright;
int speakerPin = D5;
// 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};
// create an array for the duration of notes.
// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {4,8,8,4,4,4,4,4 };
OneWire oneWire( D6 );
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature dallas(&oneWire);
// Create a variable that will store the temperature value
double temperature = 0.0;
void setup() {
pinMode (ledRed, OUTPUT);
pinMode (ledBlue, OUTPUT);
pinMode (ledGreen, OUTPUT);
pinMode (sensorBend, INPUT);
pinMode (sensorLight, INPUT);
pinMode( speakerPin, OUTPUT );
pinMode(ledAlarm, OUTPUT);
//Particle.variable ("fsr", sensorValue);
Particle.variable("temperature", &temperature, DOUBLE);
// setup the library
dallas.begin();
}
void loop() {
sensorValueBend = analogRead (sensorBend);
sensorValueLight = analogRead (sensorLight);
temp();
setLight();
setAlarm();
log_to_spreadsheet();
delay(2000);
}
void setColor (int red, int green, int blue){
analogWrite(ledRed, red);
analogWrite(ledBlue, blue);
analogWrite(ledGreen, green);
}
// store the time when you last published
int last_published = -1;
void log_to_spreadsheet( ){
// check if 1 minute has elapsed
if( last_published + 60000 < millis() ){
Particle.publish( "log_to_spreadsheet", String( sensorValueBend ) );
Particle.publish( "log_to_spreadsheet", String( sensorValueLight ) );
Particle.publish( "log_to_spreadsheet", String( temperature ) );
last_published = millis();
}
}
void playNotes()
{
// iterate over the notes of the melody:
for (int thisNote = 0; thisNote < 8; 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);
}
}
void setAlarm (){
if (sensorValueBend>1000 && ((temperature<15)||(temperature>30))) {
playNotes();
}//bend & extreme temperature, meaning too windy and cold/hot
if (sensorValueBend>1000 && ((temperature>=15)&&(temperature<=30))) {
digitalWrite(ledAlarm, HIGH);
delay(500);
digitalWrite(ledAlarm, LOW);
delay(500);
}//bend & moderate temperature, meaning too windy but warm
if (sensorValueBend<1000 && ((temperature<15)||(temperature>30))) {
digitalWrite (ledAlarm, HIGH);
delay(1000);
digitalWrite (ledAlarm, LOW);
delay(1000);
}//straight & extreme temperature, meaning not windy but cold/hot
if (sensorValueBend<1000 && ((temperature>=15)&&(temperature<=30))) {
digitalWrite (ledAlarm, LOW);
delay(2000);
}//straight & moderate temperature, meaning not windy and warm
}
void setLight(){
if ((sensorValueLight>=0)&&(sensorValueLight<500))
setColor(255,255,255);
else if ((sensorValueLight>=500)&&(sensorValueLight<1500))
setColor(0,255,255);
else if((sensorValueLight>=1500)&&(sensorValueLight<2500))
setColor(255,255,0);
else if((sensorValueLight>=2500)&&(sensorValueLight<=4095))
setColor(0,0,0);
}
void temp()
{
// Request temperature conversion
dallas.requestTemperatures();
// get the temperature in Celcius
tempC = dallas.getTempCByIndex(0);
// convert to double
temperature = (double)tempC;
delay(5000);
}
Click to Expand
A hands-on introductory course exploring the Internet of Things and connected product experiences.
Your plant needs your protection to grow sturdily. Don't forget to save it from severe weather outdoors when you have it outside for fresh air and sunshine.
November 6th, 2019