Posts with «email» label

How To Keep An Unruly Dryer In Line

If necessity is the mother of invention, then inconvenience is its frustrating co-conspirator. Faced with a finicky dryer that would shut down mid-cycle with a barely audible beep if its load was uneven (leaving a soggy mass of laundry), [the0ry] decided to add the dryer to the Internet of Things so it could send them an email whenever it shut itself down.

After opening a thinger.io account, adding the soon-to-be device, and setting up the email notification process, [the0ry] combined the ESP8266 Development Board, a photosensitive resistor, and a 5V power supply on a mini breadboard. All that was left was to mount it on the dryer and direct the LDR (light-dependent resistor) to the machine’s door lock LED to trigger an email when it turned off — indicating the cycle had finished or terminated prematurely. A little tape ensured the LDR would only be tripped by the desired light source.

If you’re an apartment-dweller have WiFi in the wash area it would be awesome to see a battery-powered version you take with you. But in general this is a great hardware blueprint as many device have status LEDs that can be monitored in a similar way. If you want to keep the server in-house (literally in this case) check out the Minimal MQTT series [Elliot Williams] recently finished up. It uses a Raspberry Pi as the center server and an ESP8266 is one of the limitless examples of hardware that plays nicely with the protocol.

We love seeing hacks like this because not only does it conserve water and energy by reducing instances of rewashing, but it’s also a clever way to extend the life of an appliance and potentially save hundreds of dollars in replacing it. Add this to the bevvy of hacks that add convenience to one’s home — some of which produce delicious results.


Filed under: Arduino Hacks, home hacks

An Arduino Device that Monitors Your External IP Address

[Bayres’] dad setup a webcam as a surveillance camera for a remote property. The only problem was that the only stable Internet connection they could get at this property was DSL. This meant that the external IP address of the webcam would change somewhat often; the needed a way to keep track of the external IP address whenever it changed. That’s when [Bayres] built a solution using Arduino and an Ethernet shield.

The main function of this device is to monitor the public IP address and report any changes. This is accomplished by first making a request to checkip.dyndns.org. This website simply reports your current public IP address. [Bayres] uses an Arduino library called Textfinder in order to search through the returned string and identify the IP address.

From there, the program compares this current value to the previous one. If there is any change, the program uses the Sendmail() function to reach out to an SMTP server and send an e-mail alert to [Beyres’] dad. The system also includes a small LCD. The Arduino outputs the current IP address to this display, making it easy to check up on the connection. The LCD is driven by 74HC595 shift register in order to conserve pins on the Arduino.

The system is also designed with a pretty slick setup interface. When it is booted, the user can enter a configuration menu via a Serial terminal. This setup menu allows the user to configure options such as SMTP server, email address, etc. These variables are then edited and can be committed to EEPROM as a more permanent storage solution. Whenever the system is booted, these values are read back out of the EEPROM and returned to their appropriate variables. This means you can reconfigure the device on the fly without having to edit the source code and re-upload.


Filed under: Arduino Hacks

Tutorial – Send email with the Arduino Yún

Introduction

This is the third in a series of tutorials examining various uses of the Arduino Yún. In this article we’ll examine how your Arduino Yún can send email from a Google email account. Doing so gives you a neat and simple method of sending data captured by the Arduino Yún or other notifications.

Getting Started

If you haven’t already done so, ensure your Arduino Yún can connect to your network via WiFi or cable – and get a Temboo account (we run through this here). And you need (at the time of writing) IDE version 1.5.4 which can be downloaded from the Arduino website.

Finally, you will need a Google account to send email from, so if you don’t have one – sign up here. You might want to give your Arduino Yún an email address of its very own.

Testing the Arduino Yún-Gmail connection

In this first example we’ll run through the sketch provided by Temboo so you can confirm everything works as it should. This will send a simple email from your Arduino Yún to another email address. First, copy the following sketch into the IDE but don’t upload it yet:

/*
  SendAnEmail

  Demonstrates sending an email via a Google Gmail account using the Temboo Arduino Yun SDK.

  This example code is in the public domain.
*/

#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information

/*** SUBSTITUTE YOUR VALUES BELOW: ***/

// Note that for additional security and reusability, you could
// use #define statements to specify these values in a .h file.

// your Gmail username, formatted as a complete email address, eg "bob.smith@gmail.com"
const String GMAIL_USER_NAME = "sender@gmail.com";

// your Gmail password
const String GMAIL_PASSWORD = "gmailpassword";

// the email address you want to send the email to, eg "jane.doe@temboo.com"
const String TO_EMAIL_ADDRESS = "recipient@email.com";

boolean success = false; // a flag to indicate whether we've sent the email yet or not

void setup() {
  Serial.begin(9600);

  // for debugging, wait until a serial console is connected
  delay(4000);
  while(!Serial);

  Bridge.begin();
}

void loop()
{
  // only try to send the email if we haven't already sent it successfully
  if (!success) {

    Serial.println("Running SendAnEmail...");

    TembooChoreo SendEmailChoreo;

    // invoke the Temboo client
    // NOTE that the client must be reinvoked, and repopulated with
    // appropriate arguments, each time its run() method is called.
    SendEmailChoreo.begin();

    // set Temboo account credentials
    SendEmailChoreo.setAccountName(TEMBOO_ACCOUNT);
    SendEmailChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
    SendEmailChoreo.setAppKey(TEMBOO_APP_KEY);

    // identify the Temboo Library choreo to run (Google > Gmail > SendEmail)
    SendEmailChoreo.setChoreo("/Library/Google/Gmail/SendEmail");

    // set the required choreo inputs
    // see https://www.temboo.com/library/Library/Google/Gmail/SendEmail/ 
    // for complete details about the inputs for this Choreo

    // the first input is your Gmail email address
    SendEmailChoreo.addInput("Username", GMAIL_USER_NAME);
    // next is your Gmail password.
    SendEmailChoreo.addInput("Password", GMAIL_PASSWORD);
    // who to send the email to
    SendEmailChoreo.addInput("ToAddress", TO_EMAIL_ADDRESS);
    // then a subject line
    SendEmailChoreo.addInput("Subject", "Email subject line here");

     // next comes the message body, the main content of the email   
    SendEmailChoreo.addInput("MessageBody", "Email content");

    // tell the Choreo to run and wait for the results. The 
    // return code (returnCode) will tell us whether the Temboo client 
    // was able to send our request to the Temboo servers
    unsigned int returnCode = SendEmailChoreo.run();

    // a return code of zero (0) means everything worked
    if (returnCode == 0) {
        Serial.println("Success! Email sent!");
        success = true;
    } else {
      // a non-zero return code means there was an error
      // read and print the error message
      while (SendEmailChoreo.available()) {
        char c = SendEmailChoreo.read();
        Serial.print(c);
      }
    } 
    SendEmailChoreo.close();

    // do nothing for the next 60 seconds
    delay(60000);
  }
}

Before uploading you need to enter five parameters – the email address to send the email with, the password for that account, the recipient’s email address, and the email’s subject line and content. These can be found in the following lines in the sketch – for example:

const String GMAIL_USER_NAME = "sender@gmail.com";
const String GMAIL_PASSWORD = "emailpassword";
const String TO_EMAIL_ADDRESS = "recipient@email.com";
SendEmailChoreo.addInput("Subject", "This is the subject line of the email");
SendEmailChoreo.addInput("MessageBody", "And this is the content of the email");

So enter the required data in the fields above. If you’re sending from a Google Apps account instead of a Gmail account – that’s ok, just enter in the sending email address as normal. Temboo and Google will take care of the rest.

Finally, create your header file by copying the the header file data from here (after logging to Temboo) into a text file and saving it with the name TembooAccount.h in the same folder as your sketch from above. You know this has been successful when opening the sketch, as you will see the header file in a second tab, for example:

Now you can upload the sketch, and after a few moments check the recipient’s email account. If all goes well you will be informed by the IDE serial monitor as well (if your Yún is connected via USB). It’s satisfying to see an email come from your Arduino Yún, for example in this short video.

If your email is not coming through, connect your Arduino Yún via USB (if not already done so) and open the serial monitor. It will let you know if there’s a problem in relatively plain English – for example:

Error
A Step Error has occurred: “An SMTP error has occurred. Make sure that your credentials are correct and that you’ve provided a fully qualified Gmail
username (e.g., john.smith@gmail.com) for the Username input. When using Google 2-Step Verification, make sure to
provide an application-specific password. If this problem persists, Google may be restricting access to your account, and you’ll need to
explicitly allow access via gmail.com.”. The error occurred in the Stop (Authentication error) step.
HTTP_CODE
500


So if this happens, check your email account details in the sketch, and try again.

Sending email with customisable subject and content data

The example sketch above is fine if you want to send a fixed message. However what if you need to send some data? That can be easily done. For our example we’ll generate some random numbers, and integrate them into the email subject line and content. This will give you the framework to add your own sensor data to emails from your Arduino Yún. Consider the following sketch:

/*
  SendAnEmail

  Demonstrates sending an email via a Google Gmail account using the Temboo Arduino Yun SDK.

  This example code is in the public domain.
*/

#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information

/*** SUBSTITUTE YOUR VALUES BELOW: ***/

// Note that for additional security and reusability, you could
// use #define statements to specify these values in a .h file.

// your Gmail username, formatted as a complete email address, eg "bob.smith@gmail.com"
const String GMAIL_USER_NAME = "sender@gmail.com";

// your Gmail password
const String GMAIL_PASSWORD = "gmailpassword";

// the email address you want to send the email to, eg "jane.doe@temboo.com"
const String TO_EMAIL_ADDRESS = "recipient@email.com";

int a,b; // used to store our random numbers
boolean success = false; // a flag to indicate whether we've sent the email yet or not

void setup() 
{
  Serial.begin(9600);
  // for debugging, wait until a serial console is connected
  delay(4000);
  while(!Serial);
  Bridge.begin();
  randomSeed(analogRead(0)); // fire up random number generation
}

void loop()
{
  // generate some random numbers to send in the email
  a = random(1000);
  b = random(1000);
  // compose email subject line into a String called "emailSubject"
  String emailSubject("The random value of a is: ");
  emailSubject += a;
  emailSubject += " and b is: ";
  emailSubject += b;  
  // compose email content into a String called "emailContent"
  String emailContent("This is an automated email from your Arduino Yun. The random value of a is: ");
  emailContent += a;
  emailContent += " and b is: ";
  emailContent += b;  
  emailContent += ". I hope that was of some use for you. Bye for now.";  

  // only try to send the email if we haven't already sent it successfully
  if (!success) {

    Serial.println("Running SendAnEmail...");

    TembooChoreo SendEmailChoreo;

    // invoke the Temboo client
    // NOTE that the client must be reinvoked, and repopulated with
    // appropriate arguments, each time its run() method is called.
    SendEmailChoreo.begin();

    // set Temboo account credentials
    SendEmailChoreo.setAccountName(TEMBOO_ACCOUNT);
    SendEmailChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
    SendEmailChoreo.setAppKey(TEMBOO_APP_KEY);

    // identify the Temboo Library choreo to run (Google > Gmail > SendEmail)
    SendEmailChoreo.setChoreo("/Library/Google/Gmail/SendEmail");

    // set the required choreo inputs
    // see https://www.temboo.com/library/Library/Google/Gmail/SendEmail/ 
    // for complete details about the inputs for this Choreo

    // the first input is your Gmail email address
    SendEmailChoreo.addInput("Username", GMAIL_USER_NAME);
    // next is your Gmail password.
    SendEmailChoreo.addInput("Password", GMAIL_PASSWORD);
    // who to send the email to
    SendEmailChoreo.addInput("ToAddress", TO_EMAIL_ADDRESS);
    // then a subject line
    SendEmailChoreo.addInput("Subject", emailSubject); // here we send the emailSubject string as the email subject

     // next comes the message body, the main content of the email   
    SendEmailChoreo.addInput("MessageBody", emailContent); // and here we send the emailContent string

    // tell the Choreo to run and wait for the results. The 
    // return code (returnCode) will tell us whether the Temboo client 
    // was able to send our request to the Temboo servers
    unsigned int returnCode = SendEmailChoreo.run();

    // a return code of zero (0) means everything worked
    if (returnCode == 0) {
        Serial.println("Success! Email sent!");
        success = true;
    } else {
      // a non-zero return code means there was an error
      // read and print the error message
      while (SendEmailChoreo.available()) {
        char c = SendEmailChoreo.read();
        Serial.print(c);
      }
    } 
    SendEmailChoreo.close();

    // do nothing for the next 60 seconds
    delay(60000);
  }
}

Review the first section at the start of void loop(). We have generated two random numbers, and then appended some text and the numbers into two Strings – emailContent and emailSubject.

These are then inserted into the SendEmailChoreo.addInput lines to be the email subject and content. With a little effort you can make a neat email notification, such as shown in this video and the following image from a mobile phone:

Conclusion

It’s no secret that the Yún isn’t the cheapest development board around, however the ease of use as demonstrated in this tutorial shows that the time saved in setup and application is more than worth the purchase price of the board and extra Temboo credits if required.

And if you’re interested in learning more about Arduino, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a third printing!) “Arduino Workshop” from No Starch Press.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

The post Tutorial – Send email with the Arduino Yún appeared first on tronixstuff.

Tronixstuff 23 Nov 01:40
arduino  email  gmail  google  iot  lesson  mail  review  send  temboo  tronixstuff  tutorial  wifi  yún  

Comunikino, an Arduino based communication system

Comunikino is a box, connected to a PC which runs a script in Python.  When receiving a mail, the subject will be printed to its LCD. You can then use one of three Comunikino’s buttons to send a mail back to say “Yes”,  “No” or “Readed”  (this button can also to be used to say: “Hey! I’m thinking of you”).

 

 

The project has been developed by Eraticlux, check here the full project.

 

 

 

Arduino Blog 31 May 19:26