// See if the SIM900 is ready
AT
OK
// SIM card inserted and unlocked?
AT+CPIN?
+CPIN: READY
OK
// Is the SIM card registered?
AT+CREG?
+CREG: 0,5
OK
// Is GPRS attached?
AT+CGATT?
+CGATT: 1
OK
// Check signal strength - should be 9 or higher
AT+CSQ
+CSQ: 20,0
OK
// Set connection type to GPRS
AT+SAPBR=3,1,”Contype”,”GPRS”
OK
// Set the APN - this will depend on your network/service provider
AT+SAPBR=3,1,”APN”,”CMNET”
OK
// Enable GPRS - this will take a moment or two
AT+SAPBR=1,1
OK
// Check to see if connection is correct and get your IP address
AT+SAPBR=2,1
+SAPBR: 1,1,”10.79.223.61”
OK
/////////////////////////////////////////////////////////////////
AT+CIPSTART=”TCP”,”183.230.40.33”,”80”
OK
CONNECT OK
/////////////////////////////////////////////////////////////
AT+CIPSEND
>
在发送框中填入一下数据这里的设备ID和APIKey需要与自己的项目中的设备相关的信//息对应 本例中设备ID和APIKey分别为4059176,jebuoO6YrgCmy2TwMfRTTNWwCMI=,则发送的内容应该替代为
POST /devices/4059176/datapoints HTTP/1.1
api-key: jebuoO6YrgCmy2TwMfRTTNWwCMI=
Host: api.heclouds.com
Content-Length: 82
{"datastreams":[{"id":"location","datapoints":[{"value":{"lon":116,"lat":30}}]}]}
SIM900A发送成功响应数据
SEND OK
服务器的响应数据
HTTP/1.1 200 OK
Date: Thu, 24 Nov 2016 13:43:28 GMT
Content-Type: application/json
Content-Length: 26
Connection: keep-alive
Server: Apache-Coyote/1.1
Pragma: no-cache
{"errno":0,"error":"succ"}
//OK
- 数据内容中的”lon”“lat”字段分别表示经度和纬度值,目前只能显示国内数据,所以在设///置该值的时候要将其设为国内的位置点
- Content-Length表示数据的长度,需要与后面的数据内容长度保持一致
- 发送的数据内容中有几个回车字符(\r\n)是不能少的
- 以16进制发送”1A”完成数据发送
参考资料:
1. http://open.iot.10086.cn/bbs/forum.php?mod=viewthread&tid=399
2. http://electronics.stackexchange.com/questions/231224/posting-to-php-server-using-sim900-gprs-with-at-commands/231225#231225 需*
3. http://jingyan.baidu.com/article/5d6edee2f03ae099eadeec36.html
4. http://www.raviyp.com/embedded/194-sim900-gprs-http-at-commands需*
5. http://www.cnblogs.com/Mysterious/p/5907125.html