简体   繁体   English

如何将数据从客户端发送到树莓派?

[英]How to send data from client to raspberry pi?

I am trying to make a simple remote control system using raspberry pi. 我正在尝试使用树莓派制作一个简单的远程控制系统。 I deployed web client application(that is node.js-based) on AWS and I want to control raspberry pi pin through client action. 我在AWS上部署了Web客户端应用程序(基于node.js),我想通过客户端操作来控制树莓派。

For example, If I click a button on web page, LED that connected to raspberry pi pin turn on. 例如,如果我单击网页上的按钮,则连接到树莓派针脚的LED会亮起。

I'm thinking of running node.js server on raspberry pi also. 我正在考虑也在树莓派上运行node.js服务器。 A signal generated from web client will be transmitted to node.js server on AWS, after that, node.js server on AWS communicate with node.js server on raspberry pi. 从Web客户端生成的信号将传输到AWS上的node.js服务器,然后,AWS上的node.js服务器与raspberry pi上的node.js服务器通信。

But, I have no idea what should I do. 但是,我不知道该怎么办。 I want to know the idea above is proper structure. 我想知道上面的想法是正确的结构。 And What modules are needed for working it? 并且需要什么模块来工作呢? Do you have any idea or sample codes that can make it through? 您有任何想法或示例代码可以实现吗? Please help me. 请帮我。 Thx. 谢谢。

I see a couple options (I'm sure there are more) 我看到几个选项(我确定还有更多选择)

IoT (recommended, as @stdunbar said) 物联网 (推荐,如@stdunbar所说)

  • use a lib like https://github.com/aws/aws-iot-device-sdk-js 使用类似https://github.com/aws/aws-iot-device-sdk-js的库
  • have a script that always runs on the pi, listening to an IoT topic. 有一个始终在pi上运行的脚本,可监听IoT主题。 Your website on Lambda could publish a message to this IoT topic, and your pi will catch it and run a script in response. 您在Lambda上的网站可能会发布有关此IoT主题的消息,而您的pi将对其进行捕获并运行脚本作为响应。 I had this same setup on a project where you could turn on LEDs from an IoT button or website. 我在一个项目上具有相同的设置,您可以从IoT按钮或网站打开LED。

Systems Manager 系统经理

  • register your pi with AWS Systems Manager 向AWS Systems Manager注册pi
  • once it's registered, you can run shell scripts on your pi using the RunCommand api. 一旦注册,就可以使用RunCommand api在pi上运行shell脚本。
  • I have mine setup to run a 'git pull' on my pi code repo every time my AWS code pipeline runs a successful deployment. 我的设置是每次我的AWS代码管道运行成功的部署时,都在pi代码存储库上运行“ git pull”。 That way I don't have to ssh into my pi and update my code manually. 这样,我不必ssh进入pi并手动更新代码。

If you think either of these work for you, PM me and I'll help you through the details. 如果您认为这两种方法都适合您,请PM我和我将为您提供详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM