China Mobile Onetnet Cloud Platform uses WiFi module to transmit data stream ESP8266 TCP transmission mode

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+cipmux=0

Set up a single link, pass-through can only be done in single-connection mode, so be sure to use it before establishing the connection (at+cipmux=0 Setup single connection)

7.

At+cipmode=1

Set the pass mode

8.

at+cipstart="TCP","183.230.40.33",

Connecting Onenet servers

9.

At+cipsend

Initiate a pass-through transmission

10.

post/devices/79146/datapoints http/1.1API-key:pmWLtnkDBSreKfvg7GsClUXdXa4AHost:api.heclouds.comConnection:closeContent-length: -{"Datastreams":[{"ID":"TEMP","datapoints":[{"value": -}]}]}

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.

Connection:colse this one if added, the server will be disconnected once the data is received, if it is not continuously sent. If you do not send it for a long time, the link will also be closed.

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!

11.

+++

Send + + + Exit Pass mode, this command does not need to enter

12. To the server to see whether the data upload success, this is no longer described, the previous log has written.

13. With the above steps, you can send data to the Onenet server via the ESP8266 TCP transmission mode

China Mobile Onetnet Cloud Platform uses WiFi module to transmit data stream ESP8266 TCP transmission mode

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.