Esp8266 07 + Mega

Hi all.
I have been trying to figure this out non stop for the past 26 hours and nothing has come up that works with my project.

I have a Mega and a esp8266-07 on a board that already has the componants for 5 volts.

I have a modbus sketch running on my mega connected to all kinds of sensors and switches. I am running ethernet shield to a wireless router so that I can use HMI Droid on my android phone and look at all the sensors and switches. I would like to make away with the router and use the wifi module instead.

I want the wifi module to work as a switch, wifi to serial etc.
Problem is most of the examples and tutorials is for a wifi shield which is not 100% the same.

I still have the original firmware on the wifi module which is 1.5.7.

How can I setup the esp8266 to pass all the info from my mega pins and registers to my android phone via TCP/IP.

that's only one link after googling "modbus tcp esp8266"

You must learn about configuring esp8266 in softap mode, that allows it to act both as router and a station.

My mega has static ip. I have configured the esp8266 via AT commands as only AP mode and also set the baud rate to 19200. I have also set the esp dhcp ip and netmasks into the same range I want to use. I tested using my uno with softwareserial and used pins 10 and 11 as rx tx, so that i cam read analog input 0 of the arduino.
I will not be using the esp8266 as an arduino and no arduino programming to it.
Just an access point like a router. I still searching and tried everything since my first post. I have since upgraded the esp firmware to sdk 2.0

If dispensing of external router is all what you want, a fast and dirty workaround is to save esp8266 as access point, with ssid, passwd and ip , only powered at 3.3v and let everything else as it is. Have the arduino with wifi shield and your application both connect to new esprouter and let them talk to each other.

Ok more details about the wifi module at...
I want the wifi module to see all the info and modbus registers from my mega and be able to relay them to my android app.
I read that the module has serial to wifi passthrough or UART to wifi passthrough.
Have been trying to make that work but it seems like it wont happen without custom firmware for the wifi module.
Looking and searching now at other firmware.
Thanks for your input.

This library claims it can use deafult,AT command firmware of esp8266

Thank you. This library is alot different then the modbus library I am using. So I will test it with my uno and report back.

I have tested the above mentioned library.
It does not even compile and missing library esp8266.h.
When I find another one i get others errors. When I leave out the esp stuf then the example code does not compile for board Arduino Uno.
Tomorrow I will try searching more, if I can not find anything by tomorow night I will abandon this idea and rather use my router as it is now.
Thanks for the link.

I have not used any esp8266 modules but this is what I suggest:

esp8266 setup as port server (tcp or udp)
A Modbus RTU library in the Arduino
Modbus RTU protocol in HMI Droid

Now I have tested HMI Droid with Arduino Uno and esp8266-01 using this open source library:

After two small modifications in "ModbusIP_ESP8266AT.cpp" it works real good.

  1. Timeout time for reading, 10 ms, is too short. (At least at 9600 baud)

  2. The server should not close the connection after response is sent.