如何使用python从raspberry pi向电路发送输出数据 [英] How to send output data from a circuitry using python from the raspberry pi to the pc

查看:79
本文介绍了如何使用python从raspberry pi向电路发送输出数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我刚买了覆盆子pi,因为我发现它非常有趣。我想知道如何从电路(按钮打印1,2,3或4)可以显示到Web服务器或计算机中的某个位置商店。对于电路和代码的视频是:

Hi I just bought raspberry pi since I found it very interesting.I want to know how from a circuitry (push button to print 1,2,3 or 4) can be displayed to the web server or somewhere in the computer to store. For the video of circuitry and codes is :

#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
import web

GPIO.setmode(GPIO.BOARD)
GPIO.setup(13, GPIO.OUT)
GPIO.setup(11, GPIO.IN)
GPIO.setup(15, GPIO.OUT)
GPIO.setup(12, GPIO.IN)
GPIO.setup(19, GPIO.IN)
GPIO.setup(24, GPIO.IN)
GPIO.setup(21, GPIO.OUT)
GPIO.setup(26, GPIO.OUT)

while 1:
        if GPIO.input(11):
         GPIO.output(13, False)
         print "2"
         time.sleep(0.5)
        else:
         GPIO.output(13, True)
        if GPIO.input(12):
         GPIO.output(15, False)
         print "1"
         time.sleep(0.5)
        else:
         GPIO.output(15, True)
        if GPIO.input(19):
         GPIO.output(21, False)
         print "3"
         time.sleep(0.5)
        else:
         GPIO.output(21, True)
        if GPIO.input(24):
         GPIO.output(26, False)
         print "4"
         time.sleep(0.5)
        else:
         GPIO.output(26, True)



然后我使用putty无线连接到raspberry pi然后在root中运行程序,因此putty black screen将显示1如果我按下相应的按钮,则为0或0。现在我想知道如何将这些电路的输出数据发送到网络服务器或某些存储在PC中的地方(因为我的同事因为其他原因而抓住1,2,3,4。当我按下时假设显示4的按钮,它将显示在网络服务器或记事本中,例如,然后按另一个按钮显示3,这样它将在网络服务器或记事本中显示4,3等等。我确实看到了来自如何从Raspberry Pi向PC发送关于webpy的数据,但是它的手册和发送类似于hello world的类型,而不是python脚本的输出。我不是很喜欢代码它将是如果tut是特定的,很简单的例子/ video.TY,我使用wifi加密狗无线连接


Then I use putty to connect to the raspberry pi wirelessly then running the program in root so putty black screen would show 1 or 0 if I press the respective push button. Now I was wondering how to send these output data of the circuitry to the web server or some where to store in the pc(cause my colleague is goin to grab the 1,2,3,4 for other reasons. In conclusion when I press the button that suppose to display a 4, it will display in the webserver or notepad maybe for e.g. Then press another button to display 3 so it will display 4 , 3 in the webserver or notepad and so on and so forth. I did see a tut from How do I send data from the Raspberry Pi to the PC about webpy but its manual and send like"hello world" which was typed and not from the output of python scripts. I'm not really good with codes it'll be a great help if the tut is specific,easy example/video.TY,i'm connected wirelessly using a wifi dongle

推荐答案

你可以在你的网站上安装lighthttp网络服务器pi并将输出放在那里供你的同事抓住。如果你需要推送信息,你可以推送到网络服务器上的远程CGI,o r通过FTP上传数据,如果我理解你的问题还有很多其他方法。



sudo apt-get -y install lighttpd

sudo lighty-enable-mod fastcgi-php

sudo service lighttpd force-reload



例如,每隔一段时间将代码打印到一个文件中经常将文件移动到

/ var / www /



或将它们添加到位于那里的index.html文件中。



我希望这会让你走上正确的道路。
You can install the lighthttp webserver on your pi and put the outputs there for your collegue to grab. if you need to push the information, you could push to a remote CGI on a webserver, or upload the data via FTP, there are numerous other methods if I understand your question.

sudo apt-get -y install lighttpd
sudo lighty-enable-mod fastcgi-php
sudo service lighttpd force-reload

For example, print your codes to a file every so often and move the file to
/var/www/

or add them to an index.html file located there.

I hope this puts you on the right path.


这篇关于如何使用python从raspberry pi向电路发送输出数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆