The image below shows how the ICSP connection between Shield and Arduino Nano should be. The connection must be made in such a way that the shields are connected as shown in the image below. In addition to the ICSP connection, it is necessary to jump pins D13, D12, D11 and D10.
The source code of the project is 100% compatible with the two Ethernet Shields based on the w5100 chip (Mini Shield and Arduino Uno).
page The HTML page must be opened in the browser and can be executed from computers or Android devices.
The header shows the time, temperature, humidity and Mode. Only in Automatic (Scheduled) mode, direct activation of the outputs is allowed. The page updates the time and status of the card outputs every 5 seconds.
The page has a functionality to change the time recorded in the DS1307
Allows you to change the scheduling times of the relay outputs
And in manual mode, the buttons are enabled to trigger the outputs directly
On the page the board access IP is configured, if the board’s IP is changed, it is necessary to change the ipArduino variable with the new access IP.
Arduino source code.
The source code of the Arduino uses the same basis as the Aquadroid project. Below I highlight three important items, the first is the configuration of the I2C address of the LCD, the source code is configured with the address “0x3F”, it is the default address of the LCDs 1602, some LCDs 4004 use the address 0x27, it is necessary to identify the correct address for LCD operation, in case of problems, use the I2cScanner. The second item is the IP, if it is necessary to change, change the content of the variable byte ip  with the new IP.
The program has the variable EEPROMCommands that is assigned the value false . Changing to true it will record the last commands received in the EEPROM, thus, if a power failure occurs and the card restarts, it will be reestablished with the last commands sent by the user. The Arduino EEPROM has a useful life of 100,000 recordings, keeping all the commands received in the EEPROM will make it useless, so check the number of commands sent daily to determine the useful life. The scheduling time and mode variables are recorded directly in the EEPROM and must not be removed.
Let’s see a video of the project.
The first step is to retest the connection before starting the settings, if a problem occurs it will be more difficult to identify the cause.
A DPC3925 router will be used, it is one of the models provided in lending over the Net.
And then on the PortRange Forwarding submenu.
We must configure a line in the table with:
External Start Port and EndPort: Fill with the port that will be used for access, we must choose a port other than 80, which is usually blocked by the operators, as a suggestion use port 8091.
IP Address: This is the IP of the internal network that will be redirected through port 8091 for external access, enter the IP 192.168.0.202 configured in the Arduino connections.
Start Port and End Port: These are the ports used in the IP that is being configured, in Arduino we use port 80.
Protocol: Select the TCP option.
Enable: Check the option to enable the setting.
Testing external access
To test external access we need to find out the external IP of our router, the easiest way is to access the website www.meuip.com.br.
The html page can be changed for external access, just change the variable with the IP and Port.
For example, If the router’s IP is 126.96.36.199 the change should be:
var ipArduino = ‘http://188.8.131.52:8091’, do not forget to put: between the IP and Port.
The setup page must open correctly.
Configuring the Android application.
The configuration of the Android application is simple, we should just change the IP of the Arduino for the IP of the Router and configured port, as done in the setup page.
The configuration of the external access of the router requires special attention. If someone finds out your IP and the protocol of the card will have full access to your automation card! Is there any way to resolve this? Yes, but with some router models that allow updating to firmware that supports the creation of a VPN, the VPN creates a tunnel between the router and the device it is accessing. But that is a subject for a future post. Never access your open or unsecured network card.