This section assumes the ESP-link firmware is already installed on the ESP8266 chip, and it is broadcasting a WiFi hotspot called ESP_XXXXXX for the initial setup.
Connect to the Wifi hotspot and navigate to http://192.168.4.1 from a browser.
Select the WiFi Station tab on the left side panel. Switch the chip to STA+AP (Station Point and Access Point) mode to allow scanning for available WiFi networks.
Select your home WiFi, enter the password for it, and hit Connect!
Once you press Connect button the ESP chip will join your home WiFi and display its final IP address.
Connect back to your home WiFi and open the link displayed on your device from a browser. Another way of getting the IP is checking your router’s DHCP leases and looking for a device named esp-link, or scanning the local network for connected devices using a tool like https://www.advanced-ip-scanner.com/ (Windows), on Linux you can install nmap [ sudo apt-get install nmap ] and scan your local network range [ sudo nmap -sn 192.168.X.X/24 ]
To set password protection on the broadcasted WiFi hotspot, navigate to the Wifi Soft-AP tab on the left side panel. Under Soft-AP Settings set up a preferred hotspot name and password, and set the Authentication to WPA2_PSK. Optionally you can make the hotspot hidden by checking the Soft-AP SSID hidden option. Once done click the Change Soft-AP Settings! to configure the WiFi, wait a bit for the new hotspot name to appear.
Enabling Soft-AP SSID hidden means the device’s Wi-Fi Access Point will not broadcast its network name. This makes the network invisible to others unless they manually enter the SSID to connect.
Optionally after connecting to the home WiFi network the hotspot can be disabled. For this go to the WiFi Station tab switch the ESP chip into STA mode (Station). In this mode, the ESP-link will only be available on the home network IP address and the hotspot is only activated if the connection cannot be established with the home WiFi. To spare resources I would recommend disabling the hotspot.
Optionally on the WiFi station tab you can set a static IP, this helps to ensure the device always gets the same IP. Alternatively, you can use DHCP reservations on your router. Before enabling it make sure you have the WiFi Hotspot enabled as a fallback.
On the Debug log tab make sure to disable the UART debug log by clicking the off button to free up resources. Only re-enable this feature if you need to debug REST API or MQTT messages and make sure to disable it once you finish working with it.
Now that the ESP-link firmware is in place and configured, it's time to test communication between the ESP and Arduino chips using the SLIP protocol, you need to enable this under the REST/MQTT tab, by checking the Enable SLIP on serial port box.
We are going to verify connectivity using a 10 line code that initializes serial output of both Arduino and ESP-link, then prints a test text on the Arduino`s and the ESP-link`s Microcontroller Console serial log. Using this technique you can print the same message on both outputs and it will be displayed on the Arduino's serial log and the on the ESP-Link`s Microcontroller Console.
Navigate to the µC Console tab and adjust the Baud rate and Fmt parameters on the top of the Microcontroller Console page. On the sample board, this is Baud 115200 and Fmt 8N1.
Expected test result: “Marko” getting logged on the Arduino`s serial output and “Polo” on the ESP-Link`s Microcontroller Console every 5 seconds.
In this sketch, we are going to query an NTP server from the internet and update the Arduino stored time based on the response. The sketch uses the improved Arduino Time Library. Once the time is in sync the Arduino Time Library will keep the time up to date using the internal timer and re-sync with the NTP server on predefined intervals. (In the Test sketch every 30 seconds, the final Gbox420 sketch every 60 minutes). The neat trick in using NTP and the Arduino Time library is that it does not require having a Real-Time Clock module installed and can still keep the time accurately.
On the Services tab adjust the GMT timezone offset to match your region. You can also change the SNTP server:
Worldwide - pool.ntp.org
Asia - asia.pool.ntp.org
Europe - europe.pool.ntp.org
North America - north-america.pool.ntp.org
Oceania - oceania.pool.ntp.org
South America - south-america.pool.ntp.org
Expected test result: After startup, an internet NTP server is queried for the current time, if it responds in 30 seconds the time is stored and the internal clock will keep track of the time passed since the sync. If the NTP server does not reply the internal time will start counting from 00:00:00 Thursday, 1 January 1970 UNIX Epoch time. Sync will trigger every 30 seconds.
You can telnet to port 23 or 2323 of the ESP-link IP address and read the Arduino serial output: telnet XXX.XXX.XXX.XXX 23
Legend has it that you can upload an Arduino sketch wirelessly using the ESP-link's telnet session. Never managed to get this working...
Last but not least the most important step: Uploading the control interface to the ESP-link's web server. The latest interface is available on Github or inside the Gbox420-master folder under the Gbox420-master\Gbox420_Mega_Main\Webpages folder that was downloaded in the Arduino IDE chapter.
Note: This part is only supported with ESP chips with at least 16Mbit (2MB) flash space!
To upload these files navigate to the Web Server tab and select Choose Files button, select all 3 HTML files, and hit the Submit button.
Once the upload is complete refresh the web-page. You should see three new tabs appearing: Logs, Settings, and GrowBox.
Logs: Contains the embedded Google Sheets page where sensor readings are logged to. At this point the page shows the sample Google Sheets page, in the next Logging chapter, we'll create your own Google Sheets log and modify the Logs.html file to point to it.
Settings: Contains a few rarely used settings like turning on/off the sound and debug logs, changing between Metric/Imperial units, and setting the Google Sheets relay ID.
GrowBox: This is the most frequently used page where the current status of all modules are displayed and commands can be sent from. At this point, all readings should be blank, as the Main sketch is not running on the Arduino Mega2560 to fill out the blanks. We'll get back to this page during the setup of the Main module, for now just verify the page is uploaded and looks something like this:
After uploading the Main module to the Arduino Mega2560 the website should get filled with data. You can view the JSON formatted data getting relayed from the Main module from Google Chrome's developer console:
Open the GrowBox tab on the ESP-link homepage (http://192.168.X.X/GrowBox.html)
Open Chrome's the dev console using CTRL + SHIFT + i
Navigate to the Network tab
Refresh the web page: F5
On the right side look for a load ((http://192.168.X.X/GrowBox.html.json?reason=load), or refresh event (http://192.168.X.X/GrowBox.html.json?reason=refresh)
The relayed sensor data will be in a JSON format: