Anywhere Internet Access to Arduino Controls
Fixing the Dynamic IP Issue
Goal: Provide internet access for any internet-enabled device, anywhere, to my Arduino based control system.
Keywords: IoT, Arduino, control system, ESP8266, nodeMCU, dynamic IP
I needed to access my Arduino control system from anywhere via cell phone, tablet or computer. I get my internet access services from a cable TV supplier. No problem there except that they provide a dynamic IP address to my cable-modem and a fixed/static IP cost more money.
Home Setup:
My cable-modem is connected to a wifi-modem servicing the house and work shop (via a wifi-extender.) The control system accesses the internet via the wifi-extender>wifi-modem>cable-modem>cable supplier>internet. My development computer access the control system via my wifi-modem’s intranet or by a direct USB-cable. But when not at home or via my cell phone’s G4 network, access is problematic due to the cable-modem’s dynamic IP issue. Fixing my dynamic IP issue is the problem solved herein.
Approach:
control-sensors>Arduino(s)>ESP8266 nodeMCU> …Internet… >my-website
I use a hosting service’s shared server for my website development. The website has a simple API providing read and write access to the Arduino(s). It can also provide control system analysis, historical data storage and alert/alarms notifications.
The ESP8266 nodeMCU acts as an internet gateway. It has a small API monitoring the gateway’s access-point and uses a bi-directional I2C interface for communications with the Arduino(s).
The website API is written as a single PHP Class. The nodeMCU’s small API is written entirely from within the Arduino IDE as if it was an Arduino board itself. I added a bi-directional LLC (5V - 3.3V) for the I2C connection - a must include for HiLetgo’s “ESP8266 NodeMCU LUA CP2102 ESP-12E Internet WIFI Development Board.”
Once initiated (plugged in) the nodeMCU starts polling the website’s API which simply stores locally the nodeMCU’s current IP. Valid user requests to the website’s API, then use the last stored IP to build an appropriate HTTP request for the nodeMCU’s API.
The polling and reuse of the last-current-IP enables a pseudo fixed-IP look and feel to the Arduino(s).
Implemented:
user request > website > control system > response to website > response to user
Requirements:
- Arduino(s) and sensors as needed,
- HiLetgo’s ESP8266 NodeMCU ESP-12E Development Board, (or like)
- Logic Level Converter Bi-Directional Module 5V to 3.3V, and
- Webspace w/ PHP.
Note: fabioc84, as you know, I tried this with the Arduino Uno-WiFi but without success. Argh!
Greg