logo
ESP8266 NodeMCU
No-IP updater with LCD and IFTTT Trigger



    This is a little project i made to update my No-IP account with the NodeMCU and a LCD display.
It also sends a trigger and the new ip address to IFTTT webhook Triggers to notify me of an ip update.
After programming its best not to power the unit from the programming port as the LCD will flicker, I have added a power only port on the other side.
I also added a reset button.
The first line in the display shows the unit wifi ip and the second shows the public ip.

PARTS

WeMos D1 USB NodeMcu Lua V3 CH340G ESP8266 Wireless Internet Development 5-9V
5V to 3.3V 4 Channel IIC I2C Logic Level Converter Bi-Directional Module
Female MICRO USB to DIP 5-Pin Pinboard 2.54mm micro USB type
IIC/I2C/TWI/SPI Serial Interface Board Module Port Arduino 1602 2004LCD Display
IIC/I2C/TWI/SP LCD Screen With Backlight Display 1602A 5v Module For Arduino
Mini Push Button Momentary OFF-ON Switch
85x58x33 Waterproof Clear Cover Electronic Cable Project Box Enclosure Case









no_ip_updater_front_s

no_ip_updater_parts_s             no_ip_updater_inside_s

no_ip_updater_power_side_s            no_ip_updater_program_side_s

  
 Below is a Sketch that works, it may not be the best put you can change it to suit your own designs
/*
 MerrittSoft
 noip updater
 26/02/2018
*/

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266WebServer.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // you may need to run the i2c_scanner sketch to get the address of the LCD Screen, mine was 0x27
const char* ssid = "your-wifi";
const char* password = "your-wifi-password";
ESP8266WebServer server;
String new_ip;
String old_ip;
void setup()
{
 Serial.begin(9600);
 WiFi.mode(WIFI_STA);
 WiFi.begin(ssid, password);
 while (WiFi.status() != WL_CONNECTED) {
   delay(500);
   Serial.print(".");
 }
 Serial.println(WiFi.localIP()); // Print the IP address
 server.begin();
 lcd.init();   // initializing the LCD
 lcd.backlight(); // Enable or Turn On the backlight
 lcd.setCursor(0, 0);
 lcd.print(WiFi.localIP()); // Start Print text to Line 1
}
void loop()
{
 if (WiFi.status() != WL_CONNECTED)
 {
   ESP.reset();
 }
 delay(2000);
 //  *********  GET PUBLIC IP
 HTTPClient http;
 http.begin("http://ipv4bot.whatismyipaddress.com/");
 int httpCode = http.GET();
 if (httpCode > 0) {
   if (httpCode == HTTP_CODE_OK) {
     new_ip = http.getString();
     // new_ip2 = new_ip;
   }
 } else {
   http.end();
   // **********   The next 4 lines if code. Should Display NO INTERNET on the bottom line if it can't reach the web address..
   if (httpCode == -1) {
     lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(0, 1);
     lcd.print("NO INTERNET");
   }
   return;
 }
 http.end();
 // ********** CHECK and UPDATE
 if (old_ip != new_ip) {
   Iftttupdat();
   delay(4000);
   Noipupdat();
   delay(4000);
   old_ip = new_ip;
 }
 lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(0, 1);
 lcd.print(new_ip);
 Serial.println(new_ip);
 delay(60000);
}
void Noipupdat() {
 if (old_ip != new_ip) {
   HTTPClient http;
   http.begin("http://your-noip-user-name:your-noip-password@dynupdate.no-ip.com/nic/update?hostname=your-noip-host-name&myip=" + new_ip);
   // add your noip user name, password, noip host name eg: http://username:password@dynupdate.no-ip.com/nic/update?hostname=mytest.testdomain.com&myip=1.2.3.4
   int httpCode = http.GET();
   if (httpCode > 0) {
     Serial.println("updatednoip");
   }
   http.end();
 }
 return;
}
void Iftttupdat() {
 if (old_ip != new_ip) {
   HTTPClient http;
   http.begin("http://maker.ifttt.com/trigger/ip_updated/with/key/your-ifttt-key?value1=" + new_ip);
   // add your IFTTT webhook EventMame inplace of the "ip_updated" in the above line, and add your IFTTT
   //key in the place here i have indicated, the new ip address will be pasted with the value1
   int httpCode = http.GET();
   if (httpCode > 0) {
     Serial.println("updatedifttt");;
   }
   http.end();
 }
 return;
}


// CODE END
 

Use this program to find out the address of your LCD Screen
i2c_scanner
Version 1
          This program (or code that looks like it) can be found in many places.
          For example on the Arduino.cc forum.
          The original author is not know.
Version 2, Juni 2012, Using Arduino 1.0.1
          Adapted to be as simple as possible by Arduino.cc user Krodal
Version 3, Feb 26  2013
          V3 by louarnold
Version 4, March 3, 2013, Using Arduino 1.0.3
           by Arduino.cc user Krodal.
           Changes by louarnold removed.
           Scanning addresses changed from 0...127 to 1...119,
           according to the i2c scanner by Nick Gammon
           http://www.gammon.com.au/forum/?id=10896
Version 5, March 28, 2013
           As version 4, but address scans now to 127.
           A sensor seems to use address 120.
 Version 6, November 27, 2015.
           Added waiting for the Leonardo serial communication.

           This sketch tests the standard 7-bit addresses
           Devices with higher bit address might not be seen properly.


#include <Wire.h>
void setup()
{
 Wire.begin();
 Serial.begin(9600);
 while (!Serial);             // Leonardo: wait for serial monitor
 Serial.println("\nI2C Scanner");
}
void loop()
{
 byte error, address;
 int nDevices;
 Serial.println("Scanning...");
 nDevices = 0;
 for (address = 1; address < 127; address++ )
 {
   // The i2c_scanner uses the return value of
   // the Write.endTransmisstion to see if
   // a device did acknowledge to the address.
   Wire.beginTransmission(address);
   error = Wire.endTransmission();
   if (error == 0)
   {
     Serial.print("I2C device found at address 0x");
     if (address < 16)
       Serial.print("0");
     Serial.print(address, HEX);
     Serial.println("  !");
     nDevices++;
   }
   else if (error == 4)
   {
     Serial.print("Unknown error at address 0x");
     if (address < 16)
       Serial.print("0");
     Serial.println(address, HEX);
   }
 }
 if (nDevices == 0)
   Serial.println("No I2C devices found\n");
 else
   Serial.println("done\n");
 delay(5000);           // wait 5 seconds for next scan
}

www.000webhost.com