China Mobile Onetnet Cloud Platform uses WiFi module ESP8266 TCP non-transmission mode transfer data stream step

Source: Internet
Author: User

Test using tools:

WiFi Module Model: ESP8266

https://item.taobao.com/item.htm?spm=a1z10.1-c.w137712-175513579.2.btbD9X&id=520305709648

Usb-ttl Debug Tool: CP2102

https://item.taobao.com/item.htm?spm=a1z10.3-c.w4002-175517240.14.8HGQU4&id=39481188174

Connection method:

(Here is the TTL directly debug ESP8266, do not need to connect the Arduino main control board, then may affect the communication)

CP2102 ESP8266 Expansion Board

5v--> 5v

Gnd--> GND

Rx--> e-tx (direct connection to RX3 pin equivalent)

Tx--> E-rx (direct connection to TX3 pin equivalent)

debugging software using serial debugging assistant:

Link: http://pan.baidu.com/s/1nty5LSd Password: kxsh

Sscom33 This kind of assistant is a good command (you can not enter the carriage, tick the new line), but it is not very helpful here, because there are many rows of data to send. So swap with this uartassist.

But you must be careful when sending data, because it is possible to send data when more than one space or return will make the send failed! Therefore, each time the input box is recommended, first press CTRL + A to select the contents of the Send box, and then enter the instructions. Remember that basically all instructions need to add a return end!!!!

Turn on the number of callbacks, after you send a command, the module will reply to a command you send, and then return to OK, or error, see OK can proceed to the next step, see the error, there must be a problem with the operation, instructions wrong or forgot to enter, or a few return or space!

Order of sending instructions:

1.

At

This command to see there is an at OK to indicate that your power supply and TTL and WiFi module communication is normal

2.

At+cwmode=3

Set mode 3,sta+ap, actually we only use the STA

3.

At+rst

Let the module reset, can be received at the bottom of the message to see ready, indicating that the module reset success. It's Sta+ap mode after reset.

4.

At+cwjap= "Your SSID", "password"

Enter your wireless router user name and password, be sure to write correctly, note case

5.

At+cifsr

Query IP, because there are STA and AP two mode, so there are two sets of Mac and IP, common is 192.168.x.x LAN IP

6.

At+cipstart= "TCP", "183.230.40.33", 80

Connecting Onenet servers

7.

at+cipsend=201

Send the data, the total data length is 201, this 201 is required to calculate the total data to be sent, cannot write wrong

8.

Post/devices/79146/datapoints http/1.1api-key:pmwltnkdbsrekfvg7gscluxdxa4ahost: api.heclouds.comconnection:closecontent-length:59{"Datastreams": [{"id": "TEMP", "datapoints": [{"Value": 50}]} ]}

Send JSON data stream, format must be correct, most of the failures are here in the wrong format

Where 79146 is modified to be your own device ID

Api-key the contents of the following changes to their own api-key

"TEMP" This is my data stream name, modified for the one I want

The 50 after "value" is the data that you want to enter.

And look back at the content-length:59.

This 59 is the length of the entire data stream behind

A small trick, you can use the notepad++ software directly check to see how long this length, do not count yourself, the number of wrong on the tragedy!

9. Send the data to see the server returned as: (where the closed received is the WiFi module closed when the TCP connection is returned)

10. If you want to transfer data again, start the loop from step 6.

11. This step allows you to upload data to the Onenet server using TCP mode

China Mobile Onetnet Cloud Platform uses WiFi module ESP8266 TCP non-transmission mode transfer data stream step

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.