GithubHelp home page GithubHelp logo

bill-callahan / esp32-axum-helloworld Goto Github PK

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

A working basic (Hello World) Axum server on ESP32.

License: MIT License

Rust 100.00%
axum esp-wifi esp32 rust tokio

esp32-axum-helloworld's Introduction

[Rust] Tokio/Axum running on esp32!

After going down various and several rabbitholes, trying to get my little ESP32 to serve a webpage, I stumbled across Jasta's esp32-tokio-demo which did exactly what I was trying to do:

  • - Get my ESP32 to startup wifi, and connect to it
  • - [Bonus] do it asynchronously
  • use Tokio's TcpListener to bind to the wifi address
  • - startup a webserver (various out there like Axum, Actix, Tide, etc but all heavily use Tokio, which until now wasn't ESP32 friendly)

This repo demonstrates a working hello world utilizing upstreamed tokio support for esp32.
The tokio executor and I/O reactor are both working fully with no known gotchas. Third party libraries utilizing tokio can also be used freely, such as coap-server-rs. I elected to do an axum server, in this repo.

Quickstart

Recommended that you use an ESP32C3 as upstream Rust support is currently better, though if you do choose any other in the ESP32 family be sure to check out the guides in the Rust on ESP Book.

  • This repo works on an ESP32
git clone https://github.com/bill-callahan/esp32-axum-helloworld your-project-name
cd your-project-name
code .
#  src/main.rs # <-- edit the WIFI_SSID/WIFI_PASS variables!
cargo run --release   <-- greatly reduces size of binary, and takes awhile to compile first-time

After the board connects to Wi-Fi, you can test that things are working with:

  • A web browser - point to http://{ip-obtainded-from-wifi}:3000
  • ThunderClient (vscode extension) - 'New Request" --> http://{ip-addr}:3000/ --> "Send" -- you should see an HTML Response and a Status: 200 OK

Try:

  • / - simple Hello World response
  • /clock - a static page that displays the time (in browser)

You may optionally use cargo run --target xtensa-esp32-espidf or any of the other supported targets which should work provided that you followed the esp-rs installation instructions above.

esp32-axum-helloworld's People

Contributors

bill-callahan 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.