Chat freely about anything...

User avatar
By Jim Booth
#80374 Hi all,

Well, I have a few general questions as I have been pretty unsuccessful trying to get the mega to communicate with the ESP 01. I have been successful in getting the ESP 01 in standalone configuration to upload some data to my php page. I used the <ESP8266WiFi.h> and <ESP8266HTTPClient.h> when I flashed the ESP 01. Below was the request made from the ESP 01 that works perfectly.. NOTE: it is bogus data (no variables) just to see if i could post something.

char httpRequest[160] = "http://mywebsite.com/cgi-bin/myphp.php?volts=14&temp=80&humd=80&press=1010";

But in general, I don't think i have a clear understanding of how I should architect this project when i introduce the Mega into the mix.

My goal is to get data from various sensors such as the BME280 and others to the mega, then the ESP 01 should get that data from Serial 2 pin 16 and 17 on the mega and upload it. So here are my questions;

1. Do i have to use AT commands? (for some reason i have struggled to get them to work)
2. Should or do i have to flash the ESP 01 at all? I read somewhere if i flash i lose the AT ability
3. I assume, I will gather the info from the sensors, then WRITE to serial 2 where the ESP 01 will READ that data and post. That sound correct?

I have an UNO with built in wifi that sends data to a PHP perfectly.. so I am puzzled why I can't seem to make this work or why this seems to much more difficult.

I realize this should be easy, but I am convinced I am missing a critical point or concept. There are plenty of examples of the UNO and Esp but not so many of the Mega. And those i have found I could not adapt to my needs.

Thanks for any suggestions, or any links to something close to what I am doing. Preferably not AT commands.

Jim
User avatar
By Jim Booth
#80403 Well from the time i posted to the time my post went live i got it working. Since the question was about the architecture of the project i thought i would mention what i did.

I flashed code to the mega and to the esp 01S and the esp 01s posts the data to the php.

The mega listens to the serial and serial 2 port. Serial port listens to the laptop them posts the data to the serial 2 port.

The esp 01s listens on the serial port znd returns a success on the serial port.

What is kind of a pain is i had to do a lot of configuring of the breadboard to flash the esp 01s then move the esp 01 to reconnect/wire it differently to test with the mega, then repeat. The flashing the esp 01s once, then to reflash it i had to unplug it from the usb or i would get an error after compiling the script..

Maybe there is an easier way..

Jim
User avatar
By QuickFix
#80433
Jim Booth wrote:1. Do i have to use AT commands? (for some reason i have struggled to get them to work)

No; the default AT command firmware sucks and is only nice to get to know the ESP, not to actually use
Jim Booth wrote:2. Should or do i have to flash the ESP 01 at all? I read somewhere if i flash i lose the AT ability

I think you should and yes, you will lose AT functionality since you can only have one piece of firmware in the ESP at a time (the AT functionality is also just firmware)
Jim Booth wrote:3. I assume, I will gather the info from the sensors, then WRITE to serial 2 where the ESP 01 will READ that data and post. That sound correct?

Depending on the number and type of sensors you could just ditch the ATMega and directly connect the sensors to the ESP.
If you need more GPIO's (the ESP-01 only has 4 I/O's), you should pick another module, like the ESP-12 (with 11 usable I/O-lines).

But of course you could also write some firmware that's able to convert the serial data sent by the ATMega into a valid URL and let the ESP handle the entire communication-part.