访问地址,浏览器用chome
http://10.25.34.165:8080/sitewhere/admin/
sitewhere数据上传成功
传感器的数据没关联
2019.6.18
串口1做打印
串口2做at指令控制8266
注意IDE里面宏的设置,选择stm32的型号,错了会影响系统时钟,USE_STDPERIPH_DRIVER,STM32F10X_CL
8266连接发送和接收引脚即可
115200
串口2 PD5---TX
PD6--RX
io口配置一定要看好是通过APB1还是APB2总线
macUSART_GPIO_APBxClock_FUN(macUSART_GPIO_CLK| RCC_APB2Periph_AFIO, ENABLE);
macUSART_APBxClock_FUN(macUSART_CLK, ENABLE);
是否响应at命令
AT
ATE0 关闭回显
重启WiFi模块
AT+RST
配置WiFi模组工作模式为单station 模式,(8266有三种工作模式:1 单station模式,2 AP模式,3 两者混合模式)
AT+CWMODE=1
连接AP(电脑连接的也是这个AP,此处换成你的路由器的ssid和密码)
AT+CWJAP="Neuedu-EMP","neuedu.com@nE%"
查看模块设备的IP地址(非必须)
AT+CIFSR
设置模块为单连接模式
AT+CIPMUX=0
建立TCP连接(协议是tcp,端口是在软件里面设置的,IP换成PC的。此处连接成功会有提示)
AT+CIPSTART="TCP","47.105.44.99",8086
AT+CIPSTART="TCP","10.25.34.165",1883
AT+CIPSTART="TCP","47.75.121.203",1883
查询网络的连接状态(非必须)
AT+CIPSTATUS
数据传输 (5代表数据长度大小,此处按照自己的需求进行设置,每输入这条指令就会提示让你输入数据 > )
AT+CIPSEND=5
关闭传输
AT+CIPCLOSE
设置透传
AT+CIPMODE=1
mqtt&&ip.dst==10.25.34.165
///////////////////////////////////////透传///////////////////////
模块复位
AT+RST
单station模式+AP模式
AT+CWMODE=3
AT+CWMODE=1
输入你无线路由器的用户名和密码,一定要写正确,注意大小写
AT+CWJAP="Neuedu-EMP","neuedu.com@nE%"
查询IP,因为有STA和AP两个模式,所以有两组MAC和IP,常见的是192.168.x.x局域网IP
AT+CIFSR
设置单链接
AT+CIPMUX=0
设置透传模式
AT+CIPMODE=1
连接服务器
AT+CIPSTART="TCP","47.105.44.99",8086
AT+CIPSTART="TCP","10.25.34.165",1883
AT+CIPSTART="TCP","10.1.235.164",8080
AT+CIPSTART="TCP","47.75.121.203",1883
启动透传发送
AT+CIPSEND
AT+CIPSEND=67
OK
>
//1step
104100044d51545403c20078002435633034656331382d356333642d343930662d396636652d643162656663633666363366000561646d696e000861646d696e333231
//2step
发布:
20字节
SiteWhere/input/json
5369746557686572652f696e7075742f6a736f6e
217字节
{"hardwareId": "5c04ec18-5c3d-490f-9f6e-d1befcc6f63f","type": "DeviceMeasurements","request": {"measurements":{"temperatuure": "36.00","humidity": "36.00"},"updateState": true,"eventDate": "2019-05-29T19:40:03.391Z"}}
7b2268617264776172654964223a202235633034656331382d356333642d343930662d396636652d643162656663633666363366222c2274797065223a20224465766963654d6561737572656d656e7473222c2272657175657374223a207b226d6561737572656d656e7473223a7b2274656d706572617475757265223a202233362e3030222c2268756d6964697479223a202233362e3030227d2c227570646174655374617465223a20747275652c226576656e7444617465223a2022323031392d30352d32395431393a34303a30332e3339315a227d7d
30ef0100145369746557686572652f696e7075742f6a736f6e7b2268617264776172654964223a202235633034656331382d356333642d343930662d396636652d643162656663633666363366222c2274797065223a20224465766963654d6561737572656d656e7473222c2272657175657374223a207b226d6561737572656d656e7473223a7b2274656d706572617475757265223a202233362e3030222c2268756d6964697479223a202233362e3030227d2c227570646174655374617465223a20747275652c226576656e7444617465223a2022323031392d30352d32395431393a34303a30332e3339315a227d7d
{
"hardwareId": "5c04ec18-5c3d-490f-9f6e-d1befcc6f63f",
"type":"DeviceLocation",
"request": {
"latitude": "33.75",
"longitude": "-84.39",
"elevation": "0",
"updateState": true,
"eventDate": "2019-05-29T19:40:03.390Z"
}
}
7b0a2268617264776172654964223a202235633034656331382d356333642d343930662d396636652d643162656663633666363366222c0a2274797065223a224465766963654c6f636174696f6e222c0a2272657175657374223a207b0a226c61746974756465223a202233332e3735222c0a226c6f6e676974756465223a20222d38342e3339222c0a22656c65766174696f6e223a202230222c0a227570646174655374617465223a20747275652c0a226576656e7444617465223a2022323031392d30352d32395431393a34303a30332e3339305a220a7d0a7d
7b2268617264776172654964223a202235633034656331382d356333642d343930662d396636652d643162656663633666363366222c2274797065223a20224465766963654d6561737572656d656e7473222c2272657175657374223a207b226d6561737572656d656e7473223a7b2274656d706572617475757265223a202233362e3030222c2268756d6964697479223a202233362e3030227d2c227570646174655374617465223a20747275652c226576656e7444617465223a2022323031392d30352d32395431393a34303a30332e3339315a227d7d
发送json数据
POST /devices/79146/datapoints HTTP/1.1
api-key: pmWLtnkDBSreKfvg7GsClUXdXa4A
Host:api.heclouds.com
Connection:close
Content-Length:59
{"datastreams":[{"id":"TEMP","datapoints":[{"value":50}]}]}
其中79146修改为你自己的设备ID
api-key后面的内容修改为自己的API-KEY
"TEMP"这个是我的数据流名称,修改为自己想要的
“value”后面的50就是数据,输入想要的。
然后回过头看下Content-Length:59
Connection:colse这一条如果加了,服务器接收到一次数据后会断开,如果不加可以连续发送数据。如果长时间不发送,也同样会关闭链接的。
{
"hardwareId": "5c04ec18-5c3d-490f-9f6e-d1befcc6f63f",
"type": "DeviceMeasurements",
"request": {
"measurements": {
"temperatuure": "36.00",
"humidity": "36.00"
},
"updateState": true,
"eventDate": "2019-05-29T19:40:03.391Z"
}
}
发送+++退出透传模式 ,
!!!!这个指令不用要回车(执行完这个以后模式还是1,最好执行下AT+CIPMODE=0)
关闭传输
AT+CIPCLOSE
AT+CIFSR
+CIFSR:APIP,"192.168.4.1"
+CIFSR:APMAC,"86:0d:8e:92:11:5d"
+CIFSR:STAIP,"10.1.246.65"
+CIFSR:STAMAC,"84:0d:8e:92:11:5d"
AT+CIPMODE=1
OK
AT+CIPSTART="TCP","10.25.34.165",1883
CONNECT
OK
AT+CIPSEND
OK
>20 02 01 00
公司WIFI:Neuedu-EMP
新 密 码 :neuedu.com@nE%
就是在开始输入命令mstsc
或者WIN+R键组合输入命令mstsc
计算机:47.105.44.99
用户:administrator
密码:TAOBAOjesse6838362
严格注意大小写
注意:如果你买了阿里云记得如图配置好所有端口开放千万注意:我们的阿里云上面的软件监听这个私有ip172.31.214.151,我们板子发送到公网IP47.105.44.99。我们只要发到公网ip 阿里云会自动换行到私有ip
//ÒªÁ¬½ÓµÄÈȵãµÄÃû³Æ£¬¼´WIFIÃû³Æ
#define macUser_ESP8266_ApSsid "Neuedu-EMP"
//ÒªÁ¬½ÓµÄÈȵãµÄÃÜÔ¿
#define macUser_ESP8266_ApPwd "neuedu.com@nE%"
//ÒªÁ¬½ÓµÄ·þÎñÆ÷µÄ IP£¬¼´µçÄÔµÄIP
#define macUser_ESP8266_TcpServer_IP "47.105.44.99"
//ÒªÁ¬½ÓµÄ·þÎñÆ÷µÄ¶Ë¿Ú
#define macUser_ESP8266_TcpServer_Port "8086"
评论0