Click here to Skip to main content
14,115,780 members
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

9.3K views
3 bookmarked
Posted 28 Aug 2015
Licenced CPOL

DIY: Building a Dryer End-of-Cycle Notifier with the MediaTek LinkIt™ ONE

, 28 Aug 2015
Rate this:
Please Sign up or sign in to vote.
This article will cover the development of a simple device that will text message the owner when the dryer cycle has ended.

This Review is from our sponsors at CodeProject. These reviews are intended to provide you with information on products and services that we consider useful and of value to developers.

DIY: Building a Dryer End-of-Cycle Notifier with the MediaTek LinkIt™ ONE

Many people rely on public laundry facilities. It is common that not everyone will remain with their laundry until it completes. This results in wrinkled clothes in the dryer and quite possibly very frustrated patrons that are waiting on an available machine. This article will cover the development of a simple device that will text message the owner when the dryer cycle has ended.

The LinkIt ONE Board

The MediaTek LinkIt ONE is a very impressive Arduino-compatible microcontroller board. It is programmed through the familiar Arduino IDE and is hardware compatible with the vast array of Arduino shields that are on the market today. What sets this board apart from others is the rich variety of connectivity options that are supported out of the box. The LinkIt ONE comes pre-configured with on-board GSM, GPRS, Bluetooth (2.1 and 4.0), GNSS (GPS/GLONASS/BeiDou) and Wi-Fi functionality. On top of this slew of built-in connectivity options, this board also boasts on-board features such as Audio support and also has a microSD slot for additional storage needs.

Project Requirements

This article assumes that you've already purchased your LinkIt ONE and have your development environment setup accordingly to program for it. Please access the Get Started with the LinkIt ONE Development Platform quick start guide on the MediaTek Labs website if you haven't done so already.

In this article, we are going to tap into the SMS capabilities of the board. We will be creating a notification device that will text you when a laundry cycle has ended. In order to do this, we are going to need some hardware. Here is a listing of what is being used in this project:

Let's get started on our project! There are two very important features of our device, text messaging and motion sensing. Let's dive in.

Implementing Text Messaging

One of the benefits of the LinkIt ONE is that you are not required to purchase additional hardware in order to implement GSM functionality. Setting up the hardware is as simple as connecting the antenna and inserting your SIM card, no breadboarding required!

Open the Arduino IDE and save a new file as DryerNotifier.ino. We will need to import a library to implement the text messaging. At the top of your file, enter the following include statement:

#include <LGSM.h>

Now we will need to implement code that initializes our GSM module for texting. In the setup function of your Arduino sketch, add the following code:

Serial.begin(9600);
while(!LSMS.ready()) {
  delay(1000);
}
Serial.println("SIM Initialized");

Next we will create a function that will handle the text messaging function. Append this code to the bottom of your source file:

void sendTextMessage(char const* number,
                      char const* message) {
      LSMS.beginSMS(number);
      LSMS.print(message);
      if(LSMS.endSMS()) {
         Serial.println("SMS is sent");
      }
     else {
        Serial.println("SMS is not sent");
     }
}

As seen in the code snippet above, you can see that there is three steps to sending an SMS message. The first one is to begin the SMS process with a call to LSMS.beginSMS passing the number that you are texting. The next step is to state your message using LSMS.print, and finally ending the SMS process by calling LSMS.endSMS, this method will return 0 if sending the SMS failed.

Now we are ready to test text messaging on our LinkIt ONE. Let's add a couple of variables (below your #include statement at the top of your file). Replace <YOUR CELL NUMBER HERE> with your personal cell phone number where you will receive the text messages.

char const* _number = "<YOUR CELL NUMBER
HERE>"; //8885551234 format
char const* _message = "Your dryer has completed it's cycle";

Temporarily, let's add a call into our sendTextMessage function to test things out. Append the following code so it is the last line in the setup function:

sendTextMessage(_number, _message);

Let's also temporarily add a heartbeat message by adding the following line of code in the loop function:

Serial.println("Heartbeat");
delay(5000);

Now we are able to test out text messaging on our LinkIt ONE. The first thing you will need to know is what COM ports the board is using on your PC. The LinkIt ONE uses one port for program uploads, and a second port where you'll see the Serial messages. To determine the ports in Windows, open Device Manager, expand out the Ports (COM & LPT) item, and look to see which port is assigned to which function. Make note of the MTK USB Debug Port COM number as the port you will upload your sketch to, and the other port labeled MTK USB Modem Port, this is the port you will connect to with a terminal program to see your Serial messages.

In the Arduino IDE, ensure the proper port is selected (Tools -> Port), and that the LinkIt ONE is selected as the board (Tools -> Board). Connect the USB cable and upload your sketch! You should soon receive your very first message from the LinkIt ONE!

Note: I ran the program twice, so I received two text messages.

You can also open a terminal program like CoolTerm, and monitor your serial messages (choose the port through the Options button on the toolbar).

Now that we've succeeded in sending a text message, there is one last feature to implement: motion sensing! Before we continue with that, go ahead and comment out or remove our call to sendTextMessage in the setup method.

Implementing Motion Sensing

In order to use our sensor, we must first prepare it to be breadboard friendly. Cut a couple lengths of wire, and solder them to the ends of the vibration sensor. In my example, I used a black and red wire, synonymous with ground and power, but it is important to know that the orientation of the switch (which leg you choose for each on the vibration sensor) doesn't matter. What is important is when you go to use the sensor, that you choose one leg as the ground, and one as the power. I also added heat shrink tubing to my exposed wire.

Go ahead and insert the vibration sensor in Digital Pin 13 and the ground into the ground pin right next to it.

Next, let's add a constant at the top of the file to hold the pin location of our vibration sensor. Add the following declaration directly below where we defined our text message variable:

int const _vibrationPin = 13;

Let's now add a function that will take a digital read of the sensor to determine if our device is currently being moved. Append the following code at the end of the code file:

bool isVibrating(int pin) {
  return !(bool)digitalRead(pin);
}

My sensor in this case returns a high signal when it is at rest. When it is shaken it returns a low signal – this is why the boolean value is negated upon return. To test this code out, add the following test code to the loop function:

if(isVibrating(_vibrationPin)){
  Serial.println("Vibrating");
}else{
  Serial.println("NOT Vibrating");
}

delay(500);

This code will check every half second to see if the vibration sensor is being shaken or not. Upload the code to your LinkIt ONE and test it out by shaking the board (yes, pick it up and shake it!).

Let's assume that when the vibration sensor doesn't detect vibration for 5 seconds, the dryer cycle has completed. In order to implement this logic, let's introduce a few more variables. Add the following declarations directly below your vibration pin variable declaration:

bool _shutOff = false;
int _counter = 0;
int _threshold = 20;

The shut off variable will be checked in the loop. What this variable gets set to true, it means that the board should no longer be checking for vibration as the alarm has already sounded. Counter is a variable to keep track of the number of reads that have passed since the last vibration was recorded. Once the number of reads reaches the threshold value, that is when the alarm will sound. Let's now implement this logic by replacing the loop code with the following:

if(!_shutOff) {
  if(isVibrating(_vibrationPin)){
    Serial.println("Vibrating");
    _counter = 0; //reset counter Vibration detected
  }else{
     _counter++;
    Serial.println("NOT Vibrating");
    if(_counter == _threshold) {
      _shutOff = true;
      sendTextMessage(_number, _message);
    }
  }
}
delay(250);

Let's also add in a 30 second delay before we start taking our reads. This will allow us to turn it on, place it into the dryer and start the dryer. Add this delay as the last line of code in the setup function.

delay(30000);

Here is a full listing of our final code:

#include <LGSM.h>  

char const* _number = "1231231234";
char const* _message = "Your dryer has completed it's cycle";
int const _vibrationPin = 13;
bool _shutOff = false;
int _counter = 0;
int _threshold = 20;

void setup() 
{   
  Serial.begin(9600); 
  pinMode(_vibrationPin, INPUT);
  
  while(!LSMS.ready()) {    
    delay(1000);        
  }
  Serial.println("SIM Initialized");  
  delay(30000);
}

void loop() {   
  if(!_shutOff) {
    if(isVibrating(_vibrationPin)){
      Serial.println("Vibrating");
      _counter = 0; //reset counter Vibration detected
    }else{
       _counter++;
      Serial.println("NOT Vibrating");
      if(_counter == _threshold) {
        _shutOff = true;
       sendTextMessage(_number, _message);
      }
    }
  }  
  delay(250);
} 

void sendTextMessage(char const* number,
                      char const* message) {
  LSMS.beginSMS(number);
  LSMS.print(message);
  if(LSMS.endSMS()) {
    Serial.println("SMS is sent");
  }
  else {
    Serial.println("SMS is not sent");
  }
}

bool isVibrating(int pin) {
  return !(bool)digitalRead(pin);
}

Go ahead and upload the final code to the board and test it out! Remember that the readings will not begin for thirty seconds.

The Proof of Concept

Now it's time to put our device to work! It's time to charge the battery. Switch the power to USB, and insert the battery JST connector, then plug the LinkIt ONE USB cable back into the computer (You will get a text!). While the battery is charging, we will begin assembling our pouch.

For my materials, I selected an ironing board cover material as well as an insulating material that is used to make things like oven mitts. To begin, I glued my materials together with Liquid Stitch glue, ensuring I placed the glue on the back of the ironing board fabric, and that I placed the shiny side of the insulating fabric towards the glue (you may need to peel away at the layers of the insulating fabric to determine which the shiny side is).

After the glue dried, I folded the fabric in half with right sides together. I stitched my pouch with a zig-zag stitch leaving an opening at the top large enough for me to fit the LinkIt ONE.

Turn the bag through the opening, so that the ironing board fabric is on the outside. I then added velcro to this opening so that I can shut the bag.

As for the LinkIt ONE, I placed it in the electrostatic bag. I cut a small hole at the bottom of the bag in order to fit the antenna and vibration sensor through it. I then folded the excess bag and taped it with electrical tape, making it as compact width-wise as I could.

Once the battery was charged, I changed the switch from USB power to battery power on the board, then plugged in the battery. I then sealed the top shot by folding over the top of the bag and closing it with electrical tape. While I was doing this, I did get a text from the application, but I ignored it.

Onto the dryer! I set the dryer for a timed dry. The lowest selection is 20 minutes, but I cut that shorter so that you don't have to watch 20 minutes go by. I pressed the reset button on the LinkIt ONE through the bag (it is easy to spot because it is right next to the green LED on the side of the board). You will see a red LED light up when it starts resetting. I then placed the device in the heat resistant pouch, closed it, threw it in the dryer and started my dryer cycle. Here is a video of the results:

Lessons Learned During the Proof Of Concept

The LinkIt ONE is a development board, and is big – a production device like this should be smaller, also when inserted into an actual dryer load with clothes, the antenna got bumped around enough to disconnect itself from the board. I don't recommend putting your LinkIt ONE board in the dryer.

The cellular antenna doesn't work through the anti-static bag nor the heat resistant coverings. A way to mount the cellular antenna on the outside of the production device will be needed (this is why it was poking through the bags in the video).

Conclusion

This was a real fun project that can definitely be turned into a handy device someday. I found the LinkIt ONE to be a very easy board to use. It has so many features built-in that it was nice not having to read datasheets to figure out how additional breakout boards work, a huge time saver! I was up and running with text messaging from an Arduino sketch in minutes - and GSM was something that I have never attempted before.

Another great fact is that MediaTek Labs offers resources like the MediaTek Cloud Sandbox and MediaTek Labs Partner Connect Program that can help you design your production device and bring it to fruition. Services like the complementary MediaTek Cloud Sandbox (a complimentary cloud-based IoT platform that allows you to store, display and remotely access your IoT prototype-device data) and the MediaTek Labs Partner Connect Program, which can help match-make developers with appropriate supply chain partners to turn their Wearable or IoT ideas into commercial reality. This makes the LinkIt ONE a great board to do your prototyping as you will have the support from initial development all the way to a production device.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Carey Payette
Software Developer (Senior)
United States United States
Carey Payette is a Senior Software Engineer with Trillium Innovations, a Progress Developer Expert, as well as an ASPInsider. She has interests in IoT and is a member of the Maker community. Carey is also a wife, and mom to 3 fabulous boys. She is a 2nd degree black belt in TaeKwonDo and enjoys coding for fun!

You may also be interested in...

Pro
Pro

Comments and Discussions

 
QuestionCost Pin
megaadam26-Nov-15 2:40
professionalmegaadam26-Nov-15 2:40 
QuestionWell Done Pin
Garth J Lancaster10-Sep-15 0:52
professionalGarth J Lancaster10-Sep-15 0:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06 | 2.8.190518.1 | Last Updated 28 Aug 2015
Article Copyright 2015 by Carey Payette
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid