12

I am working on a mesh network based on ESP8266 and it all seems to be working fine using sample code from EasyMesh by Coopdis. In his/her example, 3 ESP8266's enroll in the mesh and serves a simple web interface. This is working perfectly for me too.

In my solution however, I need one of these nodes to be connected to the internet so that the entire Mesh can access it (or at least the mesh can be accessed). This is also mentioned in the ESP8266 Mesh User Guid Documentation (page 4) from Espressif. I've also found a couple of other documents they publish all talking about this as it's just normal but without any example code that I could readily understand.

How do I configure the mesh to also connect to a router. Is it as simple as using the same SSID and Pass key for the mesh network as I'm using on my Wi-Fi router or do I need to make something like a Raspberry Pi part of the Wi-Fi mesh which can then be connected to my router via the Ethernet connection? I don't think the latter should be required from the research I've done though.

I need the hello world sample code for this. AT commands are not going to help me, I think.

3
  • 1
    Regarding the 3 nodes example, do you have up and running a web interface as well, like the one on the phone in this video? Aug 21, 2017 at 11:50
  • 1
    @BenceKaulics I haven't tested it specifically since I've done this before and this is not a problem for me. Why do you ask? I was thinking that this could be a fallback option where a "Server" could simply access the Mesh network via REST calls hosted on the mesh, but I'm intrigued by the ROOT NODE option, which sounds like the correct architecture (IMHO).
    – Gineer
    Aug 21, 2017 at 11:58
  • 1
    I see. I was thinking the same that it can be an alternative option to access your network. Not suggesting as a solution though, thus just a comment what it was. I did not know that you have already thought about it. ;) Aug 21, 2017 at 12:01

2 Answers 2

6

Another option to easy mesh is to use painlessMesh by BlackEdder and introduce there a bridge for commuting the data to outer world.

There is an issue on connecting to other network from a mesh in painlessMesh gitlab that explains four different solutions. Solutions maybe work also in easyMesh, because the issue was raised initially there, but for sure in painlessMesh.

I looked at them and the most working solutions needed both extra devices to the mesh to handle the actual connection to the outer network.

First one would introduce fourth esp8266 for your project. It would be connected to Internet and communicate to one of your nodes via serial connection.

Another would be using a Raspberry PI device to collect the data and connect with another wifi card to other network.

The other two were not good, one was discouraged by the author and other so complicated and limited with esp8266 that I would not have a try.

The whole guide in gitlab.

5

I would modify a bit the existing implementation of EasyMesh, as currently it does not seem to implement node roles. Each node is equal and they can build connections only with each other. As I see there is no way to add a server to their routing tables nor to mark a specific connection record in the tables that has connectivity to a server.

The nodes use a connection list for message routing/forwarding. What you need is a node which has a connection record for the server, this is what the root node is.

Now, currently when a node is powered it will scan the available APs (Access Points), filters out the ones the do not start with the mesh prefix and then connects to the AP with the best RSSI. Also every node creates its own AP with a name mesh prefix + node unique chip ID.

If no other node is available, it will simply wait for others to connect. And this is the first point where changes should be applied. You could hardcode or make somehow configurable a unique AP with a name like mesh prefix + "Server" and if no other EasyMesh AP is available the node should connect to this AP and should store a pre-defined meshConnectionType object in its connection list.

This object's filed won't be determined by message exchange between the server and the node but can be fixed values, except for the espconn field. That one should be acquired like in the other cases. In the following struct you will only need the first to member variable.

struct meshConnectionType {
    espconn             *esp_conn;
    uint32_t            chipId = 0;
    String              subConnections;
    timeSync            time;
    uint32_t            lastRecieved = 0;
    bool                newConnection = true;

    (...)
};

The chipId will be the address of the server in the mesh network. You should choose one value that can't be an ESP8266 chip ID.

So basically the first node to power up in your network will be the "root" node. If other nodes want to send messages to the server then the message will be sent to the "root" node based on the in-direct connection (called sub-connections in the code) records.

The "root" node then will find out that it has direct connection to the server (to the router/internet) and as it is a message to the server that it should forward this message in an other way (not a mesh like way). Obviously additional information is needed here like the server's IP address and the used port for example. These also should be stored an the node (on every node) by default or by some configuration method.

So lastly the "root" node will send an IP message to the server, this should be implemented by you again.


TL;DR; Conclusion:

  • There should be a server AP and the first node (only the first node to be powered up) should connect to it, this will be the root node.
  • The server should have an address (destId) that will be used in the mesh network when sending messages to the server. This information should be available to all nodes by default.
  • The root node should know that it is connected "directly" to the server/internet. This can be achieved by adding a connection record with the server's destId to the root node's connection list.
  • The root node knowing that it is connected to the server can forward the messages appropriately via the Internet.

This is just a theoretical idea I come up with by reading through the implementation of the EasyMesh. I may have missed some important fact that would make this hard or impossible to implement. Also it may not the most efficient way to solve the problem. I am not a mesh network expert.

Having a root node in the network asks "What happen if the root gets disconnected? How a new root will be chosen?".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.