GithubHelp home page GithubHelp logo

andrevargas22 / esp8622_access_point Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 89 KB

Simple code to run an ESP8266 as an access point to send and receive JSON data to clients

Python 25.87% C++ 74.13%
esp8266 esp-12e esp-12f access-point arduino-ide json flask client-server

esp8622_access_point's Introduction

ESP8622 Access Point + Flask Client Example

This is a very simple code to run an ESP8266 as an access point to send and receive JSON data from clients, with a Flask code in Python to test it.

Instructions

Step 1 - Install ESP8266 boards on Arduino IDE:

Step 2 - Upload server.ino on the ESP8622:

  • After installing the ESP8266 boards, they should be available under Tools > Board > ESP8266 Boards. I'm using board NodeMCU 1.0 (ESP-12E Module) because I have an ESP-12F in my possession, which is equivalent.

alt text

Step 3 - Get ESP IP address:

  • After succesfully uploading the program, open the Serial Monitor and copy the Access Point IP address, which will be used to make client-side requests. There is an LED pin declared in the server.ino code, which will keep blinking if no client is connected, and will be ON if a client is connected.

alt text

This is it for the server. It is running and ready to accept requests. In the route '/json1', any connected client request a JSON from the ESP, and in the route '/json2', any connected client sends a JSON to the ESP.

Flask-Client Test Example Python Code:

There are different ways to send requests. You could for example use Postman, just connect to the ESP Soft AP and send requests using the ESP IP address:

http:// + ESP_IP + /json1 -> Get Json

http:// + ESP_IP + /json2 -> Post Json

For this repo I created a small Flask server application that can be used to communicate with the ESP. To test it out, do the following steps:

Step 1 - Install Requirements:

> pip install -r requirements.txt

Step 2 - Paste ESP_IP on client.py:

  • Update the ESP_IP variable with the same address copied from the ESP Serial Monitor

Step 3 - Connect to the soft AP:

  • The password is at server.ino

Step 4 - Run flask code

On cmd:

> set FLASK_APP=client
> flask run

On PowerShell:

> $env:FLASK_APP="client.py"
> flask run

This should open a small page with instructions to both routes:

alt text

Open /json1 to get a JSON from the ESP:

alt text

Open /json2 to post a JSON to the ESP:

alt text

Responses on the ESP8266:

alt text

esp8622_access_point's People

Contributors

andrevargas22 avatar

Stargazers

 avatar

Watchers

 avatar

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.