博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
raspberrypi依赖_RaspberryPi + Slack:我们对办公室懒惰的微薄贡献
阅读量:2518 次
发布时间:2019-05-11

本文共 7729 字,大约阅读时间需要 25 分钟。

raspberrypi依赖

If there is one issue that permeates every culture, is not wanting to answer the door. We used to have countless hours of discussion about who would do it and led to a myriad of problems: relationships were broken, projects were lost, accidents happened on the way to answer the door phone! (Well, not really. Nothing of this happened, but IT COULD HAVE). This clearly had to be fixed. Thinking a bit, we realized we could ease the annoyance of this task if we could avoid having to do the enormous, unbearable exercise of standing up and walking to the phone. With this in mind, we decided to make the best of our and set out to solve the issue using a RaspberryPi.

如果有一个问题渗透到每种文化中,那就不想回答问题了。 我们曾经无数小时地讨论谁会这样做,并导致了无数问题:关系破裂,项目丢失,接听电话的过程中发生事故! (嗯,不是真的。什么都没有发生,但是应该有)。 这显然必须解决。 三思而后行,我们意识到,如果我们可以避免必须做的巨大而难以忍受的站立和步行到电话的工作,就可以减轻这项工作的烦恼。 考虑到这一点,我们决定充分利用 并着手使用RaspberryPi解决该问题。

We started the session by brainstorming ideas on how to answer the door from our desks, minimizing the effort done. In some way we needed to drive the electronic lock of the door remotely. Since we had a Raspberry Pi model B lying around and 2 people who had already worked with it in the team, it became our ultimate option.

会议的 开始是 通过集思广益地讨论 如何从办公桌 回答门的 想法 ,从而最大程度地减少了工作量。 我们需要以某种方式远程驱动门的电子锁。 由于我们周围有Raspberry Pi B型,并且已经有2个人与团队合作,因此它成为了我们的最终选择。

树莓派和电路 (Raspberry Pi & Circuits)

Our main initial hurdle was to deal with the electronic solution in order to be able to open the door from the Raspberry Pi. Without further knowledge than an electronic circuits high school course, we set to gain some understanding of what we needed to do, “only” with what is available online. Unsurprisingly, there are plenty of sites about the Raspberry Pi’s GPIO (General Purpose Input/Output).

我们最初的主要障碍是处理电子解决方案,以便能够从Raspberry Pi打开门。 除了电子电路高中课程以外,如果没有其他知识,我们将开始了解我们需要做的事情,“仅”了解在线提供的内容。 毫不奇怪,有很多站点都 有关Raspberry Pi的GPIO(通用输入/输出)的

RaspPiIt’s Alive!

它还活着!

As we torn down the door phone, we found out that it worked in a pretty simple way. The button closes a circuit mechanically, which opens the door. In order to unlock the door from the Raspberry Pi, we needed to electronically close that circuit. The most simple and straightforward way to do it is to use a . Relays are a rather old technology but were perfect (and cheap!) for our case. The problem was that our local providers only had 5V relays and we needed something to work with 3.3v (what the GPIO pins works with). Luckily, as there is virtually a StackOverflow answer to almost every question, we followed solution.

当我们拆下门电话时,我们发现它以一种非常简单的方式工作。 该按钮机械地闭合电路,从而打开门。 为了从Raspberry Pi上解锁门,我们需要以电子方式关闭该电路。 最简单直接的方法是使用 继电器是一种相当古老的技术,但是对于我们的案例来说是完美的(而且便宜!)。 问题在于我们的本地提供商只有5V继电器,而我们需要与3.3v配合使用的东西(GPIO引脚可以与之配合使用)。 幸运的是,由于几乎每个问题都有一个StackOverflow答案,因此我们采用了 解决方案。

After having the circuit wired, we were able to control the relay with the GPIO pins from a Python script by setting the pin up and down. Boom! Magic happens. The relay was activated by running the script and it felt similar to writing some code and have it pass every test on its first run. Later, we wired the relay to the phone circuit and using the exact same script we were able to open the door.

电路布线后,我们可以通过将引脚设置为向上和向下来使用Python脚本中的GPIO引脚控制继电器。 繁荣! 魔术发生了。 继电器是通过运行脚本来激活的,它的感觉类似于编写一些代码,并使其在首次运行时通过了所有测试。 后来,我们将继电器连接到电话电路,并使用完全相同的脚本打开了门。

from gpiozero import LEDfrom time import sleepfrom flask import Response, request, abortfrom multiprocessing import Process......def open_door_thread():    gpio = LED(17)    gpio.on()    sleep(5)    gpio.off()@app.route('/open', methods=['POST'])def open_door_endpoint():    token = request.values['token']    # Flask has a better way of handling token authentication, but for the    # purpose of testing a concept, it works.    if token == 'XXXXXXXXXXXXXXXXXXX':        p = Process(target=open_door_thread)        p.start()        resp = "aaaaand.... Opened!"        return Response(resp, content_type='text/plain; charset=utf-8')    # Not authorized    abort(401)

At that moment, we were about to leave electronics circuits behind and we were entering the software realm since the next step was to communicate with the Raspberry Pi and trigger it remotely. Setting up a Flask endpoint to open the door took us about 60 seconds. When this endpoint is hit it closes the circuit for five seconds, opening the door, and after those 5 seconds it releases the circuit again leaving the door locked.

那时,我们将电子电路抛在了后面,而我们进入了软件领域,因为下一步是与Raspberry Pi进行通信并远程触发它。 设置Flask端点打开门需要我们大约60秒钟。 触碰此端点时,它将关闭电路五秒钟,打开门,然后在这五秒钟后,它再次释放电路,使门保持锁定状态。

松弛整合 (Slack Integration)

One of the ideas we had was to use Slack as an interface. So we defined a command, “/porteitor” (as a reference to the cult class-b film “Portero Universal”) which performs a POST against our endpoint. Slack uses an Authentication Token that is sent with every request, which adds a layer of security because nobody wants strangers opening their door, right?. Having this also means that now we needed to add https to our solution, in order to avoid sending that secret in plain text over the internet. We got our self-signed certificates and installed them in an Nginx buuuuut….. we found out that Slack does not allow to use self-signed certificates with their commands. Luckily, the awesome (a trusted Certificate Authority) came to our rescue and we were able to get a free certificate for Nginx in an extremely easy way thanks to . Finally, we solved some infrastructure nuances by using tmux and autossh (just a hint if you plan on doing the same 😉 )

我们的想法之一是使用Slack作为接口。 因此,我们定义了一个命令“ / porteitor”(作为对B类邪教电影“ Portero Universal”的引用),该命令针对我们的端点执行POST。 Slack使用随每个请求发送的身份验证令牌,这增加了一层安全性,因为没人希望陌生人打开门,对吗? 拥有这个还意味着现在我们需要在解决方案中添加https,以避免通过互联网以纯文本形式发送该秘密。 我们获得了自签名证书,并将其安装在Nginx buuuuut中……..我们发现Slack不允许在其命令中使用自签名证书。 幸运的是,令人敬畏的 (受信任的证书颁发机构)来了,我们可以通过 以极其简单的方式获得Nginx的免费证书 最后,我们通过使用tmux和autossh解决了一些基础设施的细微差别(如果您打算做同样的事情,这只是一个提示)

Germán and I working on the Slack integration. Germán and I working on the Slack integration.

Germán和我从事Slack集成。

未来 (The Future)

Right now we keep working on this project, with some other ideas to implement on it. We want to develop an iOS app/widget and an Android one to open the door from our cellphones without needing to start up our Slack phone client. Also, we are working on answering the door by capturing the audio and plugging it to a HTTP stream, but this is still in progress.

现在,我们继续致力于这个项目,并有其他一些想法可以实施。 我们想要开发一个iOS应用程序/小工具和一个Android应用程序/小工具,以通过我们的手机打开大门,而无需启动我们的Slack电话客户端。 另外,我们正在通过捕获音频并将其插入HTTP流来回答问题,但这仍在进行中。

All in all, it has been an extremely fun project were we got an insight into an area we do not normally work on. Once more we enjoyed working with Raspberry Pi’s, which are beautiful, easy to deal with, and extremely powerful. More importantly, we created something useful to us and tapped into the power of the IoT (in this context, it is fun to watch this 90s ’s video).

总而言之,这是一个非常有趣的项目,我们深入了解了我们通常不从事的领域。 我们再次喜欢使用Raspberry Pi,它既美观,易用又功能强大。 更重要的是,我们创造了一些对我们有用的东西,并充分利用了物联网的强大功能(在这种情况下,观看这 90年代 的视频 很有趣 )。

We realized both that technology has come a long way over the last years and that what it is important is not to be lazier, but to spend that time doing better things (Note: slouching on the couch does not count as a “better” thing). There are yet lots of things that can be automated as there are also new devices to work with (Raspberry Zero being particularly interesting). I plan to dive deeper in this amazing world, finding new cool projects to keep working on.

我们意识到,过去几年技术都取得了长足的进步,重要的是不要变得懒惰,而要花时间做更好的事情(注意:懒散地躺在沙发上并不算是“更好”的事情。 )。 由于可以使用许多新设备,因此很多东西可以自动化(Raspberry Zero特别有趣)。 我计划在这个神奇的世界中深入研究,找到新的有趣项目继续进行下去。

Raspic2Here it’s me working in situ. *Note Jimi inspiring me on the back*
这是我在原地工作。 *请注意Jimi在背面激励着我*

翻译自:

raspberrypi依赖

转载地址:http://mzhwd.baihongyu.com/

你可能感兴趣的文章
事务分类
查看>>
《程序是怎样跑起来的》第四章读后感
查看>>
遍历datatable的几种方法(C# )
查看>>
Oracle记录(三) Scott用户的表结构
查看>>
centos静默式安装Oracle11g
查看>>
软件评测师下午题笔记
查看>>
性能测试的概念
查看>>
JavaScript中的函数上下文和apply,call
查看>>
中文排序
查看>>
少数股东损益
查看>>
SecureCRT的安装
查看>>
POJ2635-The Embarrassed Cryptographer
查看>>
css中font-family的中文字体
查看>>
学习笔记:CentOS 7学习之十二:查找命令
查看>>
delphi回调函数
查看>>
收到了TUSC寄来的V$ View For Oracle Database 11g
查看>>
gc buffer busy/gcs log flush sync与log file sync
查看>>
Java String.intern的深入研究
查看>>
动态上下线集群详解
查看>>
帝国cms修改栏目后文章列表的url错误怎么解决
查看>>