In order to connect our Things to Internet, we need to select some Internet communication protocol so that different Internet device can talk with each other. Some commonly used IoT protocols are HTTP, MQTT etc.
In this lesson, we will learn how to use HTTP protocol and how to make simple HTTP web server with Osoyoo MEGA-IoT shield and MEGA2560 micro-controller and show a “Hello World!” web page to remote browser . The web page also shows the input voltage of A0 pin that is detected by Arduino analogRead() functions.
1).please plug OSOYOO MEGA-IoT Extension Board into OSOYOO Advanced Board for MEGA2560 Board:
2)Use jumper Cap to connect ESP8266 RX with A8, TX with A9)
Software Installation
Open-source Software(IDE) |
Download IDE here: https://www.arduino.cc/en/Main/Software?setlang=en |
|
7 zip is a free zip utility that un-zips zip files |
Download 7zip here for free https://www.7-zip.org/ |
Step 1 Install latest IDE (If you have IDE version after 1.1.16, please skip this step).
Download IDE from https://www.arduino.cc/en/software, then install the software.
Step 2 OSOYOO MEGA-IoT extension TX/RX pin to A9/A8 pin by default. So in your sketch code, we need use Software Serial Port to communicate with ESP8266 (set A9 as TX and A8 as RX in SoftwareSerial object).we need download WiFiEsp-master library from following link firstly: https://osoyoo.com/driver/WiFiEsp-master.zip
Step3 Open the IDE ->Sketch ->Include Library ->Add ,Zip library to load above zip files into Arduino IDE.
Step 4 After installing above library, please download the main code from following link.unzip the download zip file lesson3.zip, you will see a folder called smarthome-lesson3.
https://osoyoo.com/driver/smarthome/smarthome-lesson3.zip
Step 5 After above operations are completed, connect the OSOYOO MEGA2560 Board to the PC with USB cable.
Step 6 Open the IDE and choose corresponding board type and port type for your project.
Step 7 IDE: Click file -> click Open -> choose code “smarthome-lesson3”, load the sketch onto your board.
Note: In the sketch, find following lines:
char ssid[] = "******"; // your network SSID (name) char pass[] = "******"; // your network password
please replace the ****** with your correct wifi SSID and password, otherwise your project can not connect to Internet.
After loading the sketch to IDE , open the serial monitor in the upper-right corner of IDE, you will see following result:
From the serial monitor , you can see the IP address of your MEGA2560 board in the read circle (in above picture, 192.168.50.102).
Then use your browser to visit the website http://mega2560-ip-address (in above case, http://192.168.50.102), you will see following result:
Above result also shows the A0 pin input voltage through analogRead(0) function in line 94. analogRead() can read the input 0-5V voltage and return a value between 0 to 1023 standing for the voltage.
If we connect A0 to GND via jumper wire, Analog input A0: shows 0
If we connect A0 to 5V via jumper wire , Analog input A0: shows 1023.
Sometimes when running lesson3 project, ESP8266 might have initialization problem with MEGA2560 A8,A9 pins and this cause WifiESP initializing error showing in Serial monitor as following:
[WiFiEsp] Initializing ESP module [WiFiEsp] >>> TIMEOUT >>> [WiFiEsp] >>> TIMEOUT >>> [WiFiEsp] >>> TIMEOUT >>> [WiFiEsp] >>> TIMEOUT >>> [WiFiEsp] >>> TIMEOUT >>> [WiFiEsp] Cannot initialize ESP module
To solve the problem, we need use Stable pin D10,D11 to initialize ESP8266 and then switch back to A8,A9.
To do this, please do as per following steps:
Original line 15 is :
SoftwareSerial softserial(A9, A8); // RX, TXPlease change above line to:
SoftwareSerial softserial(10, 11); // RX, TX
Step 3) Load the sketch to IDE and the Initializing normally will pass through and show
[WiFiEsp] Initilization successful - 1.5.4 SSI
DownLoad Url osoyoo.com
You must be logged in to post a comment.
I am getting this error on the serial monitor:
[WiFiEsp] Initializing ESP module
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] Cannot initialize ESP module
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] No tag found
WiFi shield not present
Does this mean that my ESP shield is bad?
Nevermind. I solved the problem. The diagram showing the jumper cap connection is not very descriptive.
Hi Cbales!
I’m running into the same problem but I am sure I have the jumpers right.
What did you end up doing exactly?
Do I need a third jumper on Tx0 and Rx0 or something?
Check if your hotspot name and password are correct
Nevermind Cbales:
I had some bent pins on the board.
This is the message I am getting – what could I be doing wrong. I checked to make sure the ssid and password are correct and the pins are entered correctly.
[WiFiEsp] Initializing ESP module
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] Cannot initialize ESP module
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] No tag found
WiFi shield not present
I’m running into the same problem. The pins are OK.
What shall I do ?
Hi gents
I get the same problem and jumpers seem to be ok
How did you solve yours?
The wifi module works when I do the troubleshooting steps for connecting to 10, 11. However, when I try to roll back to the A8, A9 it is not working.
can anyone help by showing a picture of how the cables should be connected to A8, A9 — do i use the pnp jumpers or do i use the regualr jumper cables. Please help.
I’ll reply you by email
Hi David,
I havent received the reply yet.
Thanks
have you sent it yet?
The mailbox prompts that the mail was delivered successfully