Mega 2560 on wifi

Hi Forum.

I have a project working for opening and closing the windows in my greenhouse, it is controlling windows based on Temperature, Rain and Humidity, i was struggling with noise but that seems to be fixed, so now i would like to go to the next step which is to get it online, my idea is to get it connected to wifi so i can log data on RPI and send commands to arduino. my idea is to log the data to a SQL database and somehow get it published on a homepage on the RPI.

my question is how do i get the Mega 2560 on WIFI without too much hazzle (don't want to spend 6 months on google to find out how to hack some doubtfull module) ;) . looking online there is many ways to go, mostly i find the ESP8266 but many versions of that one. :confused:

I found that i need to reduce TX from Arduino to 3.3V not to cause damage to ESP8266, a tutorial shoved that it could be done with 2 resistors 10K inline and 20K to ground.

ESP8266-12 on a board http://www.ebay.com/itm/5-x-ESP8266-Serial-WIFI-Module-For-Arduino-DIY-IoT-Model-Wireless-Transceiver-/262491095354?epid=1776946013&hash=item3d1db0413a:g:oBYAAOSw-4BXZ6E1

ESP8266-07 on a board http://www.ebay.com/itm/ESP8266-Serial-Wifi-Transceiver-Board-Module-for-Arduino-ESP-07-V1-0-/162082552620?epid=622677877&hash=item25bcdf7b2c:g:Rw0AAOSwEH9ZZX6k

ESP8266-12 raw http://www.ebay.com/itm/5PCS-Esp-12E-ESP8266-Serial-Port-WIFI-Transceiver-Wireless-Module-AP-STA-/221909862539?hash=item33aadbc88b:g:K8QAAOSwI-BWGRgn

ESP8266-01S on a board with an adapter http://www.ebay.com/itm/ESP-01S-ESP8266-Serial-Wi-Fi-Wireless-Module-ESP-01-Adapter-for-Arduino-/201711916394?epid=623941445&hash=item2ef6f7956a:g:4ZYAAOSwHMJYIHFW

NodeMCU Lua ESP8266 ESP-12 WeMos D1 Mini http://www.ebay.com/itm/NodeMCU-Lua-ESP8266-ESP-12-WeMos-D1-Mini-WIFI-4M-Bytes-Development-Board-Module-/401061628090?epid=860511080&hash=item5d6122c8ba:g:~jwAAOSw4YdY0JBz

hope somebody here can guide me in the right direction :) . a little link or guide showing how to set it up so it acts togeter with the Mega 2560 would be verry helpfull i find a lot of examples on how to use ESP8266 as a stand alone unit.

Best Regards Lillelund

There are two ways to go about this: [u]1. Using the pre-installed AT firmware[/u] Most ESP8266 modules come pre-loaded with an AT "interpreter". This takes some basic commands over the serial connection, for example, "act as a WiFi access point", "connect to this access point", "am I connected to an access point?", "set the IP address, subnet mask and gateway", "start a TCP socket", "send the following data over the socket", and so on. The Arduino makes all the decisions, composes all HTTP messages, reads the responses and parses them to get useful data out of them etc. The ESP8266 is just a "dumb" WiFi-to-Serial adapter. The problem with this approach is that the Arduino doesn't have a lot of RAM to handle large HTTP requests and XML or JSON files.

[u]2. Programming the ESP8266 directly[/u] The ESP8266 is a very powerful microcontroller on its own: it runs 5 to 10 times faster than most Arduino's, has a 32-bit processor, has many times more RAM (64+96KiB), it has 11 GPOI pins, an ADC, SPI interface, Serial UART interfaces ... You can also use the flash memory (up to 4MB, which is a huge amount of storage) to save web pages, datalogging etc. So it makes sense to do a lot of the processing and parsing of data on the ESP, instead of on the Arduino. If you don't need too many pins (or if you multiplex some inputs/outputs), you can even leave out the Arduino altogether. If you do need the Arduino for its pins, you can program the ESP to do all the networking stuff, and the Arduino to read all sensors, drive some relays, etc. Then all the Arduino has to do is send sensor data to the ESP, and the ESP just has to tell the Arduino to "turn off relay #5", for example.

The second approach is my personal favorite, because programming the WiFi and internet stuff is much easier on the ESP itself, instead of having to give commands all the time. And you don't waste the resources of the ESP.

If you want to get an idea of what you can do by programming the ESP directly, you can take a look at my Beginner's Guide to the ESP8266.

The NodeMCU, WeMos, Sparkfun and Adafruit boards are best suited for programming the ESP, while the ESP-## modules are a little harder to program, because they don't have a USB interface, so they tend to be used more with the AT firmware. However, the ESP8266 chips in all these boards and modules are exactly the same. One thing to watch out for is the difference in available pins and memory sizes: for example, the ESP-01 only has 4 GPIO pins broken out, and only 0.5MB of flash, while an ESP-12 or an ESP-07 has all 11 GPIO pins available, but the ESP-12 has 4MB of flash, and the ESP-07 only 1MB.

Most development boards have all pins broken out, but differ in flash size, and some other features.

If you are going to buy an ESP-07 or ESP-12 or similar, be sure to buy a breakout board as well: You'll also need a decent 3.3V voltage regulator, an LM1117-3.3 or an HT7333, for example. Development boards have these on-board.

Pieter

What is the distance between the Mega and the RPi?

if the distance is not very great and if all you want is to send data wirelessly and if you are not familiar with WiFi and web programming maybe it would be easier with nRF24L01+ transceivers. If you are familiar with web programming then stick with what you know.

Have a look at this Simple nRF24L01+ Tutorial. I don't have an RPI but I believe the TMRh20 nRF24 library also works on an RPi.

...R