GithubHelp home page GithubHelp logo

vedranmv / tm4c_esp8266 Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 2.0 319 KB

ESP8266 library for TI's Tiva TM4C1294

Makefile 34.81% C 22.64% C++ 41.44% Batchfile 1.12%
tm4c129 tiva-c-series tivacseries tiva esp8266 esp8266-library

tm4c_esp8266's Introduction

ESP8266 on Tiva TM4C1294

This repository contains an example project for running ESP8266 wifi module with TM4C1294 microcontroller. Note that the project is for CodeComposer studio.

Code is taken from a bigger project I worked on and can be integrated with other modules from there (task scheduler and event logger) hence the macro switches in esp8266.cpp source :)

Wiring

ESP8266 is connected to UART7 peripheral of Tiva evaluation kit as follows:

ESP8266 EK-TM4C1294XL
ESP8266 TxD PC4(U7Rx)
ESP8266 RxD PC5(U7Tx)
ESP8266 CH_PD PC6(GPIO)
ESP8266 VCC 3.3V
ESP8266 GND GND

Library

ESP8266 library provided in this example is implemented in C++ and based on the singleton design approach. At the beginning of the program, user grabs the reference to the instance of a singleton and uses it for the rest of the program.

Library provides complete TCP functionality, both in client and server mode. Handling of clients is automatic and happens in ISR during parsing of the data received from ESP where client instances are automatically created and destroyed as connections are opened/closed.

Data received from the open sockets is passed to a hook function which user provides during initialization. Hook function is a piece of code called whenever new data arrives from a socket. This functions gets exclusive access to handle the data immediately as it's received, otherwise data resides in _espClient object where it can be accessed whenever.

Watchdog timer is another feature implemented to ensure reliability. Timer 6 is used as a watchdog timer monitoring the time between received characters. In case communications hangs, watchdog timer will abort the communication and safely return from ongoing action. Watchdog functionality is automatically handled by the library and no user interaction/configuration is needed.

For easier porting of the code to other platforms, all board-specific functions are put in HAL/<board_name>/. Main HAL include file, HAL/hal.h, then uses macros to select the right board and load appropriate board drivers.

Example code

main.c contains a simple example which demonstrates connecting to AP, opening a connection to TCP server and periodically sending data to server every 3 seconds. Server can also reply and the example code prints out whatever message arrives from server. Afterwards, it also sends a message to server to acknowledge the reception.

Baudrate of ESP8266 in this example has been set to 1000000, but it can be configured with ESP_DEF_BAUD macro in esp8266.h file.

To run the example change your AP details and local IP of your PC in main.c. Then start TCP server (in linux, tcp server can simply be run from PC by using netcat nc -l 52699). After that just compile and upload the code to MCU. Result should look something like this:

alt tag

tm4c_esp8266's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

tm4c_esp8266's Issues

Communication at high data rates takes longer than expected

When trying larger amounts of data through (+18kB/s) a socket (_espClient::SendTCP()), sending routine often times out waiting for ESP reply. This is caused by the unexpected reply from the ESP, or wrong logic in the processing function triggered by the ISR.

This bug limits the speed to 4-5kB/s instead.

Steps to reproduce:

  1. Open a socket to TCP server (ESP8266::OpenTCPSock)
  2. Periodically (200Hz) send small chunk of data (100B) using ESP8266::GetClientBySockID()->SendTCP()
  3. Observe the amount of data received on the server side
  4. Observe TX, Rx lines from the ESP with logic analyzer

Expected behavior:
Login analyzer:

  • Timing to send the data fits with the baud rate being used
  • Time between consecutive sends fits with the sending frequency
    TCP server:
  • data arrives at a rate of 19.5kB/s +/-5%

Actual behavior:
Login analyzer:

  • Timing to send the data fits with the baud rate being used
  • Time between consecutive sends is the sending frequency, plus few milliseconds that it takes for watchdog to time out
    TCP server:
  • data arrives at a rate of 4-5kB/s +/-5%

What does it mean to connect to access point in blocking mode?

Also, do I enter my access-point's ssid and password in the esp.ConnectAP?
ex...
esp.ConnectAP("accesspointname", "password", false);

Currently getting failed to acquire IP via uart over serial.

Initialized Uart...
Initialized ESP, connecting to AP...Failed to acquire IP!

Thanks for making this for the TivaC tm4c!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.