查看树莓派实战GPRS的源代码
←
树莓派实战GPRS
跳转到:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您刚才请求的操作只有这个用户组中的用户才能使用:
用户
您可以查看并复制此页面的源代码:
==SIM800 GPRS/GSM== 老牌GPRS芯片, 所以兼容性好. Arduino 都有很好的支持, 更不用说数梅派这种Linux操作系统的. ==树梅派串口环回== 数梅派上使用SIM800的主要问题是串口经常被占用. 而且系统很复杂, 多种渠道会占用唯一的硬件串口资源. 一旦串口能正常工作, 在数梅派上使用SIM800是一件很轻松的事情. 所以串口环回试验一定要做。就是 将RX/TX 拿杜邦线短接,启动 minicom -D /dev/ttyS0 (或者 /dev/ttyAMA0) 这样就能看到键盘敲入的字符都有回显。如果minicom开启了本地回显(CTRL+A E), 每一个敲入的字符都显示为两个。 如果不能得到正确的回显或者各种运行错误, 请按照下面步骤排查。 确保kernel不使用串口做为console sudo raspi-config 禁用 "Advanced" choose "Serial" (Enable/Disable shell and kernel messages on the serial connection) 确保 /boot/cmdline.txt 不包含串口选项 类似这样: dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait 不能是这样的(树莓派版本不同,下面的AMA0 有可能是 ttyS0) dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait 禁用 serial-getty 服务 sudo systemctl disable serial-getty@ttyAMA0.service sudo systemctl mask serial-getty@ttyAMA0.service 确保e UART pins (15 and 16 wPi) are in state ALT0 gpio readall 应该是如下: Phy 8 ALT0 NAME TXD 如果不是,可以用如下命令修改 gpio mode 15 ALT0; gpio mode 16 ALT0 确保 uart 在 /boot/config.txt使能,特别是如上步骤操作后 /dev/ttyAMA0 (ttyS0) 消失的情况 确保 enable_uart=1 在 /boot/config.txt 内 ==简单AT命令== === 查询SIM卡状态=== at+cpin? ===查询网络状态=== At+cops? +cops 0,0,“Chian mobile” ===读取国际识别码=== AT+CIMI ===发送短消息=== > AT+CMGF=1 OK > AT+CMGS="+861533xxxx3" > test sms > ctl+z +CMGS: 0 === TCP 连接=== <source> at+cipstart="tcp","api.thingspeak.com","443" AT+cipDI=0 at+cipsend > POST /update?api_key=5J9GD27HXIMASDRC&field1=5000&headers=false HTTP/1.1 >GET /update?api_key= at-cipshut </source> [https://github.com/carrascoacd/ArduinoSIM800L sim800 Arduino HTTP] [https://www.rhydolabz.com/wiki/?p=16325 PPP Via Sim800 modem] ==串口拨号== [https://www.rhydolabz.com/wiki/?p=16325 教程] <source lang="bash"> sudo apt-get install ppp screen elinks ls /etc/ppp/peers/ sudo vim /etc/ppp/peers/gprs </source> 要保持115200的波特率, 9600的话速度非常低。 ==默认路由== ppp 已经设置了默认路由. <source lang="bash"> route add default ppp0 </source> ==启动deamon程序== <source lang="bash"> #Start daemon sudo start-stop-daemon --start -b --pidfile /run/ppp --startas /usr/bin/pon gprs #More easy and dirty way sudo setsid ./start-lora > /dev/null 2>&1 < /dev/null & cat start-lora #!/bin/bash cd /home/pi/loraGW/ ./lora_gateway_pi2 --mode=2|python ./post_processing_gw.py >>/var/log/lora </source> ==使用systemd 服务== <source lange=bash> cat /etc/systemd/system/lora-gw.service [Unit] Description=Lora GateWay Service #After=network.target [Service] ExecStart=/home/pi/star/loraGW/start-lora StandardOutput=null Restart=always #WorkingDirectory=/home/pi/star/loraGW [Install] WantedBy=multi-user.target Alias=lora-gw.service </source>
返回到
树莓派实战GPRS
。
个人工具
登录
名字空间
页面
讨论
变换
查看
阅读
查看源代码
查看历史
操作
搜索
导航
首页
社区专页
新闻动态
最近更改
随机页面
帮助
工具箱
链入页面
相关更改
特殊页面