Requirements

Description

This WiFi shield is connected using Serial communication, so the Ethernet PLC family is the only one where it can be connected this module. (As for the 20I/Os Family there is no free Serial communication as they are reserved for the RS-232/RS-485 communication protocols).

The ESP8266 Shield is a cheap and popular WiFi/microcontroller system-on-chip. Furthermore it can be programmed like a normal controller. Actually ESP8266 is a serially-controlled WiFi gateway. It can be configured with AT command, so using the Industrial Shields equipment's UART it's possible to communicate to WiFi networks and interact with IoT world over TCP or UDP protocols.

The idea is simple, the ESP8266 is connected to an Ethernet PLC using Serial Communication. The interaction is done using AT Commands, so the PLC sends the AT Commands and the Wifi Shield interprets them.

Implementation

- Hardware configuration

In the table below it is showed the hardware connection between both devices:

- Software

To work with the ESP8266 Wifi Shield it is required a library. This library is supported by the owner of the Wifi Shield.

The first thing then is downloading the ESP8266 library. Follow the next steps:

On the firsts lines on HARDWARE_SERIAL declaration, change the wordsSerial for Serial1, next is showed a picture of where you must change it:

On any sketch using ESP8266 is required the function esp8266.begin(9600, ESP8266_HARDWARE_SERIAL); on the setUp() function for a proper functionality.

Put the switch selector on hardware serial position (UART HW):

AT commands

Once the device is configured and the library is ready it is time to set the ESP8266. Using AT commands it is possible to configure the ESP8266 parameters. Next are showed the main parameters, see more information on the next link:

It is required the proper sketch to use AT commands and communicate with ESP8266 through Serial1 (RX1, TX1). Using the ESP8266_Serial_Passthrough example it's possible to do that. Remember to select on the Serial monitor (Arduino IDE) parameter the Both NL & CR and 9600 baud rate.

Try the different commands to verify that you have a good wiring and code. Then configure your network using the AT commant AT+CWJAP="APname","APpass"

Running a Server

After configuring your network with AT commands the device is ready to use it with their full options.

To verify their functionality we will test another code. In this case we will run the ESP8266_Shields_Demo example that can be found into ESP8266 library examples in your Arduino IDE. Before uploading the code we will have to make a little change. Find the initializeESP8266() funtion. Into this function we have to add 9600 and ESP8266_HARDWARE_SERIAL to our esp8266.begin() function. Take a look on the next picture:

After that just select your Industrial Shields unit and the right port that is connected. Upload the sketch and open the Serial Monitor.

You will see that the program will be asking you to insert a random character to follow up the program. Next is showed two pictures and the code.

In the first one picture is showed the Serial Monitor feedback. In the second one is showed a ping from a Linux terminal. As you can see the Wi-Fi shield has initialized the server properly.

Connect with us

Explain the benefits you offer. Don't write about products or
services here, write about solutions.

Based in Barcelona and founded in October 2012, Industrial Shields is the brand under the company Boot and Work Corp S.L. We are a company with the aim to become the biggest e-commerce of industrial automation electronic devices based on Open Source Hardware electronics. Our goal is to offer the widest choice of products at a very reasonable costs compared with the products that are developed under the current market leaders.