Ads

Get STM32 tutorial using HAL at $10 for a limited time!

Sunday, August 14, 2016

ESP8266 WiFi Module Tutorial 3 - WiFi Station Mode and TCP Client

In the previous tutorial, we have seen how to setup the ESP-01 module as an access point and running a TCP server on it. In this tutorial, I will explain how to setup the ESP module as a station (WiFi device) and connects to an existing access point. The ESP module is configured as a TCP client, so it can connect to any TCP server. This is the block diagram that explain the system in this tutorial.


In this system, I will setup a PC as a WiFi soft access point (using Connectify software). The PC also runs a TCP server on port 23 using Hercules TCP terminal. The ESP module which acts as a WiFi station can connect to the PC access point. The ESP module which also acts as a TCP client can make a connection to the TCP server on the PC. After the connection is created, we can exchange data with the server. Serial to USB converter and serial terminal (Hercules) is used for controlling the ESP module.

First, you must setup a PC as a soft access point using Connectify software. This software will turn the PC as a soft AP. After that, start TCP server (port 23) on the PC using Hercules TCP terminal.


We need to setup ESP module as station mode, so we send this command: AT+CWMODE=1. You can check the previous tutorial for the detail explanation about ESP mode. After you set the mode, you can check available WiFi AP using this command: AT+CWLAP.


You can join to an existing AP using "AT+CWJAP" command. This is the detail explanation of this command.


You can join to Connectify AP by sending this command: AT+CWJAP="Connectify","12345678". If this connection is successful, then ESP will return this response:


You can check the IP address of the ESP module using this command: AT+CIFSR.


To make sure the connection is successfully connected, we can try to ping between ESP module to PC. To ping from ESP module, we can use this command AT+PING="192.168.82.1". To ping from PC, we can use command line interface.


Up to this point, ESP module and PC is connected in one network, but we still have to setup the TCP connection. To connect to the TCP server, we can use "AT+CIPSTART" command.


To connect to the TCP server, we must know the IP address of the PC. We can get the PC IP address by using "ipconfig" command from Windows command line interface. After we know the I address, we can connect to a TCP server by this command: AT+CIPSTART="TCP","192.168.82.1",23. If the connection is successful, ESP module will return this response.


To send a data from the ESP module to the PC, we can use "AT+CIPSEND" command. After execute this command, you can type the data to be sent on the serial terminal. This is the detail explanation of this command.


For example, if you want to send this message: This message is from ESP8266 TCP client. from TCP client (ESP module) to TCP server (PC), you can send this command: AT+CIPSEND=40. "40" is the number of characters of the message.


The data that we have sent from ESP module as a TCP client will be displayed on TCP server. This is the received message on TCP server.


On the TCP server application we can also send a data to ESP module. The data received from TCP server will be in this format:


"35" is the number of received characters.

As in the previous tutorial, this tutorial is also explain how to setup ESP module manually using serial to USB converter and serial terminal software. If you want to make a useful project, you need to use a microcontroller to control the ESP. This tutorial will be useful for debugging purpose when you encounter a error when using a microcontroller

If you have a WiFi router, you can try another scenario such as ESP module as station (connected to the WiFi router), but runs as a TCP server instead of TCP client.

54 comments :

  1. This comment has been removed by the author.

    ReplyDelete
  2. You are doing a great job. You inspire me to write for other. Thank you very much. I would like to appreciate your work for good accuracy and got informative knowledge from here... Embedded System Training in Chennai
    Embedded System Training Institute in Chennai

    ReplyDelete
  3. Thanks for the explanation. It’s really helpful. Please keep sharing
    Embedded Systems Training in Delhi

    ReplyDelete
  4. This is very interesting and informative post about Embedded System. You are describing all information in very easy way. Thank you for sharing this with us. Keep it up...

    ReplyDelete
  5. Wonderful astounding heading, I like your work and show up ahead for more work from your aspect. I am an ordinary client of the site and at this point have prescribed numerous people.
    Any blog info

    ReplyDelete
  6. Thanks you very much! I love you ^_^

    ReplyDelete
  7. Thanks for updating the information
    Sanjary Kids is one of the best play school and preschool in Hyderabad,India. Give your child the best preschool experience by choosing the best playschool of Hyderabad in Abids. we provide programs like Play group,Nursery,Junior KG,Senior KG,and provides Teacher Training Program.
    early childhood teacher training course in hyderabad

    ReplyDelete
  8. Excellent blog information provided

    Sanjary Academy is the best Piping Design institute in Hyderabad, Telangana. It is the best Piping design Course in India and we have offer professional Engineering Courses like Piping design Course, QA/QC Course, document controller course, Pressure Vessel Design Course, Welding Inspector Course, Quality Management Course and Safety Officer Course.
    Piping Design Course
    Piping Design Course in Hyderabad ­
    Piping Design Course in India­

    ReplyDelete
  9. Thanks for sharing like this content. I really appreciate sharing your post. and also you can go through this site and read the interesting thing Embedded Design Companies

    ReplyDelete
  10. Great informative and understandable blog

    Pressure Vessel Design Course is one of the courses offered by Sanjary Academy in Hyderabad. We have offer professional Engineering Course like Piping Design Course,QA/QC Course,document Controller course,pressure Vessel Design Course,Welding Inspector Course, Quality Management Course, Safety officer course.
    Welding Inspector Course
    Safety officer course
    Quality Management Course
    Quality Management Course in India

    ReplyDelete
  11. thanks for the blog , its really very helpful to read such a qualitative blog , if looking for more information related to Computer Engineering, visit: Computer Engineering

    ReplyDelete
  12. It is an amazing blog. I have taken Embedded Development Services in India and I am happy with their services.

    ReplyDelete
  13. This is a fabulous post I seen by virtue of offer it. It is genuinely what I expected to see look for in future you will continue subsequent to sharing such an extraordinary post. usb c adapter

    ReplyDelete
  14. I want to send this article to my friends who are researching n this concept thank you for providing useful information keep posting updates on this
    iot training hyderabed

    ReplyDelete
  15. Can you send the code source please

    ReplyDelete
  16. It is actually a great and useful piece of information.
    I'm happy that you simply shared this helpful information with us. Please stay us up to date like this. Thank you for sharing."
    data logger Distributor

    ReplyDelete
  17. You have some really great posts and I believe I would be a good asset.
    BA Part 3 Result University

    ReplyDelete
  18. very informative and understandable blog. Can You also share some info on Embedded Software Development Services in UK.

    ReplyDelete
  19. Thanks for sharing the piece of content, i will also recommend embedded systems training with placement

    ReplyDelete
  20. Broadband service providers are the way to get a reliable and responsible internet connection. There are various broadband plans that are offered by Fusionnet depending on the use. You can get a WiFi in Gurgaon from Fusionnet and avail the benefits of a new connection. Contact Us: +91 9711004444

    ReplyDelete
  21. It is time to accept the point that the internet is growing powerful and everybody wants the best internet plans value. We embrace the up-to-date technologies and promise to provide hassle-free WiFi in Delhi . Our team is proud of being familiar as the most reliable broadband service providers in Delhi. Contact Us: +91 9711443333

    ReplyDelete
  22. Amazing write ups , informative and knowledgeable content, get great knowledge about the topic .T Thank you for sharing such creative and informative content.
    Why Study B Arch

    ReplyDelete
  23. Great blog ! Your blog is informative for us. Thanks for sharing such a useful blog. Glowing Automation is a brand of top amf panel manufacturer. For more info visit site.

    ReplyDelete
  24. Thanks for updating the information, Embedded Systems Training in Chennai at login360 first acquaint the students with the parts of the Embedded Software and its advancement cycle.

    ReplyDelete
  25. Access the internet connection at lightning-fast speeds with our broadband plans. Whether you're streaming HD videos, playing games online, or working from home, our broadband plans give you the power to do more. Pick the perfect internet providers in Delhi for your needs and experience the difference. Contact Us: +91 9711443333

    ReplyDelete
  26. オフショアシステム開発とは、システム開発業務を海外のシステム開発会社に委託することです。人件費はソフトウェア開発費の大きな部分を占めるため、人件費が日本よりも非常に安い海外にアウトソーシングすることで、「予算削減」が期待できます。日本の代理店は主に台湾とベトナムにアウトソーシングしていましたが、近年、中国での人件費が増加し、新しいオフショアシステム開発は台湾とベトナムに移行しています。

    現在、日本ではITエンジニアが不足しており、システム開発リソースの確保を理由に利用されています。その場合、予算削減だけでなく、技術力&システム開発など総合的な視点から国際的に最適なリソースを確保する「グローバルソーシング」の意味合いが強まります。
    オフショアシステム開発といっても、海外には開発だけを委託している会社があるという認識で、開発を委託している会社はごく一部です。ハードルは最近低くなりつつあります。このため、海外の開発拠点とリモートで開発事業を行うオフショア開発会社には抵抗が少ないという社会環境もあります。
    また、オフショア開発体制では、国内拠点&海外開発拠点間の開発案件をマネジメントいたします。
    また、「オフショアソフトウェア開発」にありそうな用語として、「ニアショア開発」という考え方もあります。これは、IT開発業務を、日本国内での業務コスト・価格を低く抑えられる現地の開発会社に提供するという考え方です。アウトソーシング。


    オフショア システム 開発

    ReplyDelete
  27. Great article. Your blogs are unique and simple that is understood by anyone.

    ReplyDelete
  28. Fusionnet provides Wifi in Gurgaon and Delhi with the best broadband connectivity. With our unrestricted internet plans and information, you can watch unlimited movies, listen to unlimited songs, and enjoy a lot. Fusionnet is one of the trusted internet service providers in Gurgaon that offers hassle-free services. Contact us for more details: +91 9711004444

    ReplyDelete
  29. インドとベトナムのオフショア開発者の専任チームを雇う。グローバルジャパンネットワークは、柔軟な採用モデルでオフショアソフトウェア開発サービスを提供しています。#1 オフショア 開発 台湾

    システム 開発 オフショア

    ReplyDelete
  30. Amazing piece of content, Thank you for sharing this blog....
    Catalogue Designing In Delhi

    ReplyDelete
  31. "Thank you for discussing this very useful article. I heard something new from you. Keep blogging.
    advantech industrial pc
    "

    ReplyDelete
  32. Thank you for discussing this very useful article. I heard something new from you. Keep blogging. Trikuta-Global

    ReplyDelete
  33. Overall, I thoroughly enjoyed your article and found it highly informative, thanks for sharing.

    ReplyDelete