weixin_33694620 2017-08-10 12:45 采纳率: 0%
浏览 37

远程访问GPIO

I have a Raspberry pi 3. and installed web server. I have a file http1.py that listens to port 432 and with variable "a" that passes from URL, it will turn lights on and off through GPIO: "http://192.168.0.5:432/turn?a=1" I also opened the ip forwarding on my router under port 80 and it works. On my raspberry pi server I have index.html file that uses Ajax to access the http://192.168.0.5:432/turn?a=1:

function ras(str) {
    var url = "HTTP://192.168.0.17:432/turn?a="+str;
    xmlHttp = GetXmlHttpObject(stateChanged);
    xmlHttp.open("GET", url, true);
    xmlHttp.send(null); .....
}

function stateChanged() {
    if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
        Blah, blah ...

now, with-in the network, it works fine (turn GPIO on and off) but with external ipaddress 75.129.-.-:80, I see the index.html BUT when I access the link which activate the Ajax, nothing happens.

What am I doing wrong? Or, is there any better way to access the GPIO from out of my network?

  • 写回答

1条回答 默认 最新

  • weixin_33747129 2017-08-11 11:43
    关注

    Well, I found the best/effective way to control GPIO on you Raspberry Pi is through wiringpi. You must have PHP and wiring Pi installed and configured. once it is done you can use PHP in combination with Ajax to create a cool, one page GUI interface for GPIO which can be accessed from anywhere out side of your network. take necessary steps to hack proof the page

    评论

报告相同问题?

悬赏问题

  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来