Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Developing IoT Projects with ESP32 - Second Edition

You're reading from  Developing IoT Projects with ESP32 - Second Edition

Product type Book
Published in Nov 2023
Publisher Packt
ISBN-13 9781803237688
Pages 578 pages
Edition 2nd Edition
Languages
Author (1):
Vedat Ozan Oner Vedat Ozan Oner
Profile icon Vedat Ozan Oner

Table of Contents (15) Chapters

Preface Introduction to IoT development and the ESP32 platform Understanding the Development Tools Using ESP32 Peripherals Employing Third-Party Libraries in ESP32 Projects Project – Audio Player Using Wi-Fi Communication for Connectivity ESP32 Security Features for Production-Grade Devices Connecting to Cloud Platforms and Using Services Project – Smart Home Machine Learning with ESP32 Developing on Edge Impulse Project – Baby Monitor Other Books You May Enjoy
Index

Consuming RESTful services

In this example, our sensor will read its configuration from a RESTful server by connecting it as a client and publishing its state on the same server. As a server, we will run a simple Flask application in a virtual Python environment. Let’s prepare the server in steps:

  1. Copy the ch6/rest_client_ex/server directory from the GitHub repository and switch to this directory. Install the Python requirements in a virtual environment:
    $ python --version
    Python 3.6.8
    $ pyenv virtualenv 3.6.8 apptest
    $ pyenv local apptest
    (apptest) $ pip install -r requirements.txt
    
  2. Set the Flask application:
    (apptest) $ export FLASK_APP=./rest_server.py
    
  3. Start the server. The -h 0.0.0.0 option makes Flask serve on all network interfaces of the machine:
    (apptest) $ flask run -h 0.0.0.0
    * Serving Flask app './rest_server.py' (lazy loading)
    <logs removed>
    * Running on http://10.8.0.2:5000/ (Press CTRL...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}