Arduino自动电子邮件通知

Pet*_*ter 5 email notifications arduino sensor

我想开始涉及arduino和电子邮件通知的项目.我不确定以前做过这样的事情,但我猜它有某种形式.让我解释.基本上我想用一些压电传感器或kinect设置arduino,以便当执行动作(或感测到压力)时,将自动发送电子邮件(或推文).我确信这可以做到,但我不知道从哪里开始,我想知道是否有人有想法?提前致谢.

ZnA*_*ArK 1

我还没有测试下面的代码,但这是您想要做的最基本的结构。

在 Arduino 上,当您想要发送电子邮件时,将您的代码设置为在串行线路(“arduino_output”)上输出一些内容。然后在计算机上等待该事件。

Linux 非常简单,因为串口可以像读取文件一样对待。

#!/usr/bin/perl
use open ':std';
use MIME::Lite;

#Open the COM port for reading
#just like a file
open FILE, "<", "/dev/usbTTY0" or die $!;

#setup e-mail message
$msg = MIME::Lite->new(
    From        => '"FirstName LastName" <something@gmail.com>',
    To          => "somebody@hotmail.com",
    Subject     => "subject",
    Type        => "text/plain"
);

#loop forever (until closed w/ ctrl+c)
while (1){
    while (<FILE>){
        # if there is output from the arduino (ie: Serial.write(...))
        # then the e-mail will be sent
        if ($_ == "arduino_output"){
            MIME::Lite->send('smtp','mailrelay.corp.advancestores.com',Timeout=>60);
            $msg->send();
        }
    }  
}
Run Code Online (Sandbox Code Playgroud)

祝你的项目好运。