How to exchange data between 2 Arduino Mega with two ESP8266

Hello there,
First of all, this is my very first post in this forum. I followed the “How to get the best out of this forum”-post as good as I could and I did my best to choose the right section, but if it isn’t right, please let me know which one is the right one and I will delete this post.
So, I started with Arduino a while ago and worked on some easy and basic projects to get into it – so I’d say, I’m still a beginner. Please do not be too harsh on me

Currently I’m working on a psychological study project which is about telepresence. Therefore, we’re building two tables, each of them has an interactive surface, which is split up in several parts, so that if you put something on the table, it lights up.

This project by itself already exists and was realized by CreativityHero and HowToMechatronics. We really liked that project, so we wanted to use this as an environment for our study project.

Therefore, we want to add a ESP8266 to both tables, which allows us to let the part of both tables light up if someone is putting something down on the one table – so basically the person at the other table sees, that someone is using the other table and vice versa. (To detect that something is on the table we’re using IR sensors and a WS2812B LED Strip).

To be honest, I thought it would be “easy” to get into the ESP and on my way trying to understand how it works, I (re)build some nice IOT projects. But when it comes to sending the data one Arduino receives from an IR Sensor to a esp which then sends it to another esp, where it is used by the second Arduino seems more advanced than I expected…

I read so many documentary’s and watched many videos, tried out many things but at the end of the day I am still were I started.

Basically, there are three parts of this project were I’m not quite sure how to realize them in this particular project:

    1. What is the best way to use the ESP with the Arduinos and how to implement it?
      o (I came across several project where they used an ESP for the WIFI Connection but in many different ways – I guess it is related to the further use in the respective project – still having trouble to make sure which is the right way for this project)
    1. How to send the actual data between the two Arduino with the esp’s.
      o (There are many information’s and instructions on how to send data from one to another esp with a client-server Wi-Fi Communication, but I’m having trouble to actually make it possible to not only send data from one (client) to another (server) but also let the previous client also be a server and the previous server also be a client – so it’s possible to exchange data both ways)
    1. Because I’m not sure how the preceded data sending’s are realized I’m also not sure how the data will be received and worked with
      o (I guess this question will be answered when the problems I’ve mention in the previous questions are solved)

I know that out there are many examples for the individual components and connections but for me the hardest part is when it all comes together and should work with each component.

I’ve looked up many other posts and projects in this and other forums but still wasn’t able to find something similar which helps me to realize this project.

If anyone knows a similar project – maybe a forum post I wasn’t able to find – or knows how to deal with those particular components I’m using in this project, please let me know.

I've listed the hardware we’re using below and added two pictures, one of the ESP8266 we’re using and the other one is the circuit schematic.

The circuit is from the website HowToMechatronics and besides the bluetooth module its exactly what we are using for each table by itself.

Hardware:

  • 2x Arduino Mega 2560
  • 2x Esp8266 NodeMCU ESP-12F
  • 60x WS2812B LED Strip + 2x 330 ohm resistor
  • 50x IR Proximity Sensor (infrared)
  • 2x 5V 10A 50W Trafo (for the Led’s and the Arduino‘s) + 2x plug

Any help will be appreciated.

Thanks
buck_converter_99

read this please ESP8266 TCP/IP communication - Arduino Stack Exchange

one option how to use esp8266 with Arduino is use a firmware in esp8266 and a corresponding WiFi library in Arduino. is is the same as use Ethernet shield or module with Ethernet library or use some WiFi shield or module with WiFi, WiFi101, WiFly ... library. These all use the standard Arduino networking so it is easy to port networking code to other adapter.

most common firmware for esp8266 is the AT firmware by esp8266 manufacturer Espressif. There is a WiFiEsp library for old versions of the AT firmware and my WiFiEspAT firmware for AT 1.7+

(the biggest limitation of AT firmware is that it supports only one TCP server (without any good reason I must add))

other option how to use esp8266 with other board is to write a sketch for esp8266 and code the communication between the MCUs.

ESPNOW