Skip to content

SE-intern/flask-ESP-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask ESP Simulator

Overview

This project simulates an ESP device using Flask and MQTT. It allows you to:

  • Publish simulated motor responses and sensor data to MQTT topics
  • Subscribe to MQTT topics via HTTP endpoints

Requirements

  • Python 3.8+
  • MQTT broker (e.g., Mosquitto, EMQX)
  • See requirements.txt for Python dependencies

Setup

  1. Install dependencies:
    pip install -r requirements.txt
  2. Create a .env file in the project root with the following variables:
    MQTT_BROKER=your_mqtt_broker_url
    MQTT_PORT=8883
    ESP_TOKEN=your_esp_token
    APPLICATION_RUNNING_PORT=5005

Usage

Start the Flask server:

python app.py

Endpoints

  • POST /publish-motor-response
    Publish a motor response to a topic.
    Body: { "motor_response": {...}, "topic": "your/topic" }

  • POST /publish-realtime-sensor-data
    Publish simulated sensor data.
    Body: { "espId": "...", "userId": "...", "topic": "your/topic" }

  • POST /subscribe
    Subscribe to MQTT topics.
    Body: { "topics": ["topic1", "topic2"] }

Notes

  • Uses TLS for MQTT (insecure, for development only)
  • Prints MQTT events to the console

About

Create to simulate the ESP device to MQTT broker data sending.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages