×

虚拟邮递员开源硬件

消耗积分:0 | 格式:zip | 大小:13.87 MB | 2023-02-02

陈韵瑄

分享资料个

描述

介绍:

尽管明信片的使用越来越少,但它仍然主要在印度使用。与 gmail 不同 每小时检查一次邮箱并不容易,因为它涉及体力劳动。进入 AWS 服务,借助 AWS IOT 和 Amazon Push Notification Service,将物理世界和数字世界融合在一起,解决这个问题变得非常简单。

IMG_20160201_031713.jpg?auto=compress%2Cformat&w=740&h=555&fit=max
 

 

概念:

CAD 模型显示了邮件到达的缝隙。想法是当 LED 光源和 LDR 之间的路径被中断时,通过光的变化来检测邮件的进入情况。

Letterbox_AWS_2.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

 

使用的平台:

AWS IOT 和 SNS:  AWS IOT 使以可靠的方式连接设备变得方便和安全。在这里,我们使用 MQTT 对 AWS IOT 资源进行身份验证和通信。MQTT 是一种机器对机器协议,主要用于物联网应用程序。AWS IOT 充当 MQTT 代理,Intel Galileo Gen 2 上的 python 代码充当 MQTT 客户端,可实现安全通信。

Grove 入门套件: 该项目使用 Seed Studio 的 Groove 入门套件中的 LDR 和 LED。它包含一个 arduino 外形尺寸的扩展板,能够以简单的即插即用方式快速制作原型。

设置 AWS IOT 和 SNS:

在提供的所有服务中,我们今天选择了 AWS IOT。

1.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

遍历入门页面后,单击创建资源

2.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

现在创建一个东西。所有机器都在 AWS IOT 中考虑事物,需要身份验证才能与 AWS IOT 资源进行通信。

3.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

适当地命名资源并单击创建

4a.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

创建后我们可以看到没有附加证书,所以点击连接设备。

5a.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

即使我们在 Intel Galileo 中使用 python,我们也必须使用 NodeJs 来生成身份验证所需的证书文件。

6.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

下载证书文件并观察显示的 json 格式结构,这将在对客户端进行编程时使用。

7a.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

让我们设置 SNS 以接收推送通知。

1-2.PNG?auto=compress%2Cformat&w=740&h=555&fit=max
标题(可选)
 

创建主题并输入主题名称和邮件主题。

1.png?auto=compress%2Cformat&w=740&h=555&fit=max
标题(可选)
 
2.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

现在订阅邮件地址并验证它。

3.png?auto=compress%2Cformat&w=740&h=555&fit=max
 
4.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

单击确认订阅后,您现在可以接收推送通知。

6.png?auto=compress%2Cformat&w=740&h=555&fit=max
标题(可选)
 

为了测试它,让我们发布一条消息来体验一下。

7.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

填写消息并点击发布。

8.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

是的!我收到了我的邮件。

9.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

现在我们已经创建了我们的机器,让我们创建 AWS IOT 和 SNS 之间的链接,我们需要为此创建一个规则。

10.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

现在根据您的喜好填写详细信息,其中最重要的是强制它列出特定主题的主题过滤器。

topic_ldr.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

现在让我们通过创建一个新角色来验证它。

13.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

在选择操作下拉列表框中选择 SNS。

create_new_role.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

然后设置角色名称。

Iam_role.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

验证 SNS 主题集的详细信息。

14.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

现在每次我们收到一个帖子,都会生成一个推送通知。

orig_details.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

 

设置 Intel Galileo Gen 2:

此处概述了主要步骤:

1. 格式化您的 8GB SD 卡:

Format.png?auto=compress%2Cformat&w=740&h=555&fit=max
标题(可选)
 

2. 使用 dd 命令将 Intel Yocto dev-kit 镜像写入合适的磁盘:

dd_command.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

3. 启动后使用 Connmanctl 设置 USB Wifi,如下所示:

wifi_connection.png?auto=compress%2Cformat&w=740&h=555&fit=max
输入您的密码
 

4.配置connmanctl的nameservers:

connmanctl config your_wireless_card_as_used_above --nameservers 8.8.8.8 8.8.4.4

5.设置点子:

curl -L "https://bootstrap.pypa.io/get-pip.py" > get-pip.py
python get-pip.py

6. 安装 MQTT:

pip install paho-mqtt

7. 为 GPIO 控制设置 WiringX86:

curl -O -L http://github.com/emutex/wiring-x86/archive/master.tar.gz 
tar zxvf master.tar.gz
cd wiring-x86-master/
sudo python setup.py install

 

使用 MQTT 客户端进行调试:

AWS IOT 托管 MQTT 客户端以方便调试。让我们检查一下我们一起破解的内容是否有效。

单击 AWS IOT 控制台上的 MQTT 客户端,然后选择您想要收听的适当主题。这是主题/ ldr

1b.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

python 脚本在 Intel Galileo Gen 2 上运行

3b.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

AWS 上的 MQTT 客户端开始接收消息。

2b.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

设置证书:

除了从 AWS IOT 控制台下载的证书外,您还需要下载以下文件。

还可以使用 scp 将文件从 Mac 传输到 Intel Galileo Gen 2。

final.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

临界点:

LDR 值急剧下降,因为来自 LED 的光路被切断,因此从实验中我发现,如果瞬时差异大于 300,则不会设置阈值,而是会触发邮件。您可以使用 mqtt.publish 函数中的有效负载选项自定义要在邮件上显示的消息。

4b.png?auto=compress%2Cformat&w=740&h=555&fit=max
 

任务完成 :)

 

 

 


声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

评论(0)
发评论

下载排行榜

全部0条评论

快来发表一下你的评论吧 !

'+ '

'+ '

'+ ''+ '
'+ ''+ ''+ '
'+ ''+ '' ); $.get('/article/vipdownload/aid/'+webid,function(data){ if(data.code ==5){ $(pop_this).attr('href',"/login/index.html"); return false } if(data.code == 2){ //跳转到VIP升级页面 window.location.href="//m.obk20.com/vip/index?aid=" + webid return false } //是会员 if (data.code > 0) { $('body').append(htmlSetNormalDownload); var getWidth=$("#poplayer").width(); $("#poplayer").css("margin-left","-"+getWidth/2+"px"); $('#tips').html(data.msg) $('.download_confirm').click(function(){ $('#dialog').remove(); }) } else { var down_url = $('#vipdownload').attr('data-url'); isBindAnalysisForm(pop_this, down_url, 1) } }); }); //是否开通VIP $.get('/article/vipdownload/aid/'+webid,function(data){ if(data.code == 2 || data.code ==5){ //跳转到VIP升级页面 $('#vipdownload>span').text("开通VIP 免费下载") return false }else{ // 待续费 if(data.code == 3) { vipExpiredInfo.ifVipExpired = true vipExpiredInfo.vipExpiredDate = data.data.endoftime } $('#vipdownload .icon-vip-tips').remove() $('#vipdownload>span').text("VIP免积分下载") } }); }).on("click",".download_cancel",function(){ $('#dialog').remove(); }) var setWeixinShare={};//定义默认的微信分享信息,页面如果要自定义分享,直接更改此变量即可 if(window.navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger'){ var d={ title:'虚拟邮递员开源硬件',//标题 desc:$('[name=description]').attr("content"), //描述 imgUrl:'https://'+location.host+'/static/images/ele-logo.png',// 分享图标,默认是logo link:'',//链接 type:'',// 分享类型,music、video或link,不填默认为link dataUrl:'',//如果type是music或video,则要提供数据链接,默认为空 success:'', // 用户确认分享后执行的回调函数 cancel:''// 用户取消分享后执行的回调函数 } setWeixinShare=$.extend(d,setWeixinShare); $.ajax({ url:"//www.obk20.com/app/wechat/index.php?s=Home/ShareConfig/index", data:"share_url="+encodeURIComponent(location.href)+"&format=jsonp&domain=m", type:'get', dataType:'jsonp', success:function(res){ if(res.status!="successed"){ return false; } $.getScript('https://res.wx.qq.com/open/js/jweixin-1.0.0.js',function(result,status){ if(status!="success"){ return false; } var getWxCfg=res.data; wx.config({ //debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId:getWxCfg.appId, // 必填,公众号的唯一标识 timestamp:getWxCfg.timestamp, // 必填,生成签名的时间戳 nonceStr:getWxCfg.nonceStr, // 必填,生成签名的随机串 signature:getWxCfg.signature,// 必填,签名,见附录1 jsApiList:['onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo','onMenuShareQZone'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2 }); wx.ready(function(){ //获取“分享到朋友圈”按钮点击状态及自定义分享内容接口 wx.onMenuShareTimeline({ title: setWeixinShare.title, // 分享标题 link: setWeixinShare.link, // 分享链接 imgUrl: setWeixinShare.imgUrl, // 分享图标 success: function () { setWeixinShare.success; // 用户确认分享后执行的回调函数 }, cancel: function () { setWeixinShare.cancel; // 用户取消分享后执行的回调函数 } }); //获取“分享给朋友”按钮点击状态及自定义分享内容接口 wx.onMenuShareAppMessage({ title: setWeixinShare.title, // 分享标题 desc: setWeixinShare.desc, // 分享描述 link: setWeixinShare.link, // 分享链接 imgUrl: setWeixinShare.imgUrl, // 分享图标 type: setWeixinShare.type, // 分享类型,music、video或link,不填默认为link dataUrl: setWeixinShare.dataUrl, // 如果type是music或video,则要提供数据链接,默认为空 success: function () { setWeixinShare.success; // 用户确认分享后执行的回调函数 }, cancel: function () { setWeixinShare.cancel; // 用户取消分享后执行的回调函数 } }); //获取“分享到QQ”按钮点击状态及自定义分享内容接口 wx.onMenuShareQQ({ title: setWeixinShare.title, // 分享标题 desc: setWeixinShare.desc, // 分享描述 link: setWeixinShare.link, // 分享链接 imgUrl: setWeixinShare.imgUrl, // 分享图标 success: function () { setWeixinShare.success; // 用户确认分享后执行的回调函数 }, cancel: function () { setWeixinShare.cancel; // 用户取消分享后执行的回调函数 } }); //获取“分享到腾讯微博”按钮点击状态及自定义分享内容接口 wx.onMenuShareWeibo({ title: setWeixinShare.title, // 分享标题 desc: setWeixinShare.desc, // 分享描述 link: setWeixinShare.link, // 分享链接 imgUrl: setWeixinShare.imgUrl, // 分享图标 success: function () { setWeixinShare.success; // 用户确认分享后执行的回调函数 }, cancel: function () { setWeixinShare.cancel; // 用户取消分享后执行的回调函数 } }); //获取“分享到QQ空间”按钮点击状态及自定义分享内容接口 wx.onMenuShareQZone({ title: setWeixinShare.title, // 分享标题 desc: setWeixinShare.desc, // 分享描述 link: setWeixinShare.link, // 分享链接 imgUrl: setWeixinShare.imgUrl, // 分享图标 success: function () { setWeixinShare.success; // 用户确认分享后执行的回调函数 }, cancel: function () { setWeixinShare.cancel; // 用户取消分享后执行的回调函数 } }); }); }); } }); } function openX_ad(posterid, htmlid, width, height) { if ($(htmlid).length > 0) { var randomnumber = Math.random(); var now_url = encodeURIComponent(window.location.href); var ga = document.createElement('iframe'); ga.src = 'https://www1.elecfans.com/www/delivery/myafr.php?target=_blank&cb=' + randomnumber + '&zoneid=' + posterid+'&prefer='+now_url; ga.width = width; ga.height = height; ga.frameBorder = 0; ga.scrolling = 'no'; var s = $(htmlid).append(ga); } } openX_ad(828, '#berry-300', 300, 250);