Code Monkey home page Code Monkey logo

esp32-to-esp32's Introduction

ESP32-to-ESP32

GitHub stars

Build firmware GitHub license

ESP32 to ESP32 communication example using Arduino framework. Secure, P2P, low latency connection between devices is established. Button connected to the first ESP32 controlls LED connected to second ESP32.

  • ESP32 acts both as a HTTP server (based on ESPAsyncWebServer library) and HTTP client (based on AsyncTCP)
  • ESP32 automatically detects all peers in the same Husarnet VPN network
  • when the button is pressed, HTTP request is sent to all other peers and turn the LED on
  • when the button is released, HTTP request is sent to all other peers and turn on the LED off

Default hardware configuration:

  • LED is connected to pin: 27
  • button is connected to pin: 0

Running a project

  1. Clone this repo

  2. Open the repo folder using VSC with installed Platformio extension

  3. Provide your Wi-Fi networks credentials here:

// WiFi credentials
const char* wifiNetworks[][2] = {
  {"wifi-ssid-one", "wifi-pass-one"},
  {"wifi-ssid-two", "wifi-pass-two"},
} 
  1. Get your Husarnet VPN Join Code (allowing you to connect devices to the same VPN network)

You will find your Join Code at https://app.husarnet.com
-> Click on the desired network
-> Add element button
-> Join Code tab

  1. Place your Husarnet Join Code here:
const char *husarnetJoinCode = "fc94:b01d:1803:8dd8:b293:5c7d:7639:932a/xxxxxxxxxxxxxxxxxxxxxx";
  1. Flash at least two ESP32 devices and enjoy

Note that each ESP32 runs it's own HTTP server, so you can test not only ESP32 <> ESP32 communication but also web browser <> ESP32 (by just typing http://random:8001/led/1/state/0). Remember to use the same Join Code to connect your laptop to the same VPN network as ESP32.

Extra notes

If you want to add Over The Air (OTA) firmware update from GitHub Actions workflow, check out this project - https://github.com/husarnet/esp32-internet-ota

esp32-to-esp32's People

Contributors

dominikn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

esp32-to-esp32's Issues

Issue when compiling

Hello,

When I compile the code I get this error message at the end

exit status 1
invalid user-defined conversion from 'IPv6Address' to 'const char*' [-fpermissive]

in reference to this line

client_tcp->connect(peerAddr, PORT);

listPeers error

Hi, I am working on a project and I need to connect two ESP32 with Husarnet. I tried to copy this code, but the method Husarnet.listPeers() is not recognised in VSC with PlatformIO extension...

Sending UDP messages

Hi,

I am working on a project and I need two ESP32 to communicate over the network sending simple UDP packets.
I have been able to do this using WIFiUDP library, but everything works only if the two microcontrollers are in the same network (I can't do port forwarding for project's reasons).

To solve this issue I thought of using VPN and I found Husarnet that works really well.
I have been able to create the network and add the two ESP32 to it, the problem is that the controllers see each other and get the IPv6 and name of the peer, but WiFiUDP methods to send the packets only work with IPv4 or host name.
Since I don't have the IPv4, I tried to use the host name but it seems it does not work since I get the error "could not get host from dns: 11".

What am I doing wrong? How can I solve the problem?

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.