Dynamic DNS Library (DDNS_Generic). Now supports AVR Mega, megaAVR, Teensy

DDNS_Generic Library

How To Install Using Arduino Library Manager

Why do we need this Async DDNS_Generic Library

Many of us are using Dynamic DNS service because Dynamic IP addresses is much cheaper than the expensive static IP address.

Dynamic IP addresses present a problem if we wants to provide a service to other users on the Internet, such as a web service, Blynk Local Server, etc. As the IP address may change frequently (due to power outtage/surge, power on/off, DSL/Fiber issues, etc.), the corresponding domain names must be quickly re-mapped in the DNS, to maintain accessibility using a well-known URL.

Many providers offer commercial or free Dynamic DNS service for this scenario. The automatic reconfiguration is generally implemented in the user's router or computer, which runs software to update the DDNS service. The communication between the user's equipment and the provider is not standardized, although a few standard web-based methods of updating have emerged over time.

This Library is created to automatically update your DDNS Domains with the latest dynamic IP address, using one of the many available boards / shields. See Currently Supported Boards.

The time between checks to update the DDNS Service is configurable to match your use case, and is set in the examples at 10 minutes.

The DDNS_Generic code is very short, can be immersed in your Projects and to be called in the loop() code.

It currently supports DuckDNS, No-ip, DynDNS, Dynu, enom, all-inkl, selfhost.de, dyndns.it, strato, freemyip, afraid.org. Expansion to support more DDNS sevice providers is very easy and can be done by yourself.

This DDNS_Generic Library is based on and modified from Ayush Sharma's EasyDDNS Library to add support to many boards and shields besides ESP32 and ESP8266.

Initial Releases v1.0.0

  1. Initial coding for Generic boards using many different WiFi/Ethernet modules/shields.
  2. Add more examples

Currently Supported Boards

  • ESP8266
  • ESP32
  • AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox etc..
  • Arduino SAMD21 (ZERO, MKR, NANO_33_IOT, etc.).
  • Adafruit SAM21 (Itsy-Bitsy M0, Metro M0, Feather M0, Gemma M0, etc.).
  • Adafruit SAM51 (Itsy-Bitsy M4, Metro M4, Grand Central M4, Feather M4 Express, etc.).
  • Seeeduino SAMD21/SAMD51 boards (SEEED_WIO_TERMINAL, SEEED_FEMTO_M0, SEEED_XIAO_M0, Wio_Lite_MG126, WIO_GPS_BOARD, SEEEDUINO_ZERO, SEEEDUINO_LORAWAN, SEEED_GROVE_UI_WIRELESS, etc.)
  • STM32 (Nucleo-144, Nucleo-64, Nucleo-32, Discovery, STM32F1, STM32F3, STM32F4, STM32H7, STM32L0, etc.).
  • SAM DUE
  • STM32F/L/H/G/WB/MP1 (Nucleo-64 L053R8,Nucleo-144, Nucleo-64, Nucleo-32, Discovery, STM32Fx, STM32H7, STM32Lx, STM32Gx, STM32WB, STM32MP1, etc.) having 64K+ Flash program memory.

Currently Supported WiFi Modules/Shields

  • ESP8266 built-in WiFi
  • ESP32 built-in WiFi
  • WiFiNINA using WiFiNINA or WiFiNINA_Generic library.
  • ESP8266-AT, ESP32-AT WiFi shields using WiFiEspAT or ESP8266_AT_WebServer library.

Currently Supported Ethernet Modules/Shields

  • W5x00's using Ethernet, EthernetLarge, Ethernet2 or Ethernet3 Library.
  • ENC28J60 using new EthernetENC and UIPEthernet library
  • LAN8742A using STM32duino LwIP,STM32duino STM32Ethernet libraries

Sample Code

This is the nRF52_Ethernet_DuckDNS_Client example

#include "defines.h"

#if (ESP8266 || ESP32 || USE_WIFI_NINA || DDNS_USING_WIFI)
  int status = WL_IDLE_STATUS;     // the Wifi radio's status
#endif

void onUpdateCallback(const char* oldIP, const char* newIP)
{
  Serial.print("DDNSGeneric - IP Change Detected: ");
  Serial.println(newIP);
}

void setup()
{
  Serial.begin(115200);
  while (!Serial);

  Serial.print("\nStart nRF52_Ethernet_DuckDNS_Client on " + String(BOARD_NAME));
  Serial.println(" with " + String(SHIELD_TYPE));


  // For other boards, to change if necessary
#if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 || USE_ETHERNET_ENC )
  // Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries

  Ethernet.init (USE_THIS_SS_PIN);

#elif USE_ETHERNET3
  // Use  MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer
  #ifndef ETHERNET3_MAX_SOCK_NUM
    #define ETHERNET3_MAX_SOCK_NUM      4
  #endif

  Ethernet.setCsPin (USE_THIS_SS_PIN);
  Ethernet.init (ETHERNET3_MAX_SOCK_NUM);

#endif  //( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2  || USE_ETHERNET_ENC )

  // start the ethernet connection and the server:
  // Use DHCP dynamic IP and random mac
  uint16_t index = millis() % NUMBER_OF_MAC;
  // Use Static IP
  //Ethernet.begin(mac[index], ip);
  Ethernet.begin(mac[index]);

  Serial.print(F("\nHTTP WebServer is @ IP : "));
  Serial.println(Ethernet.localIP());

  server.begin();

  DDNSGeneric.service("duckdns");    // Enter your DDNS Service Name - "duckdns" / "noip"

  /*
    For DDNS Providers where you get a token:
    DDNSGeneric.client("domain", "token");

    For DDNS Providers where you get username and password: ( Leave the password field empty "" if not required )
    DDNSGeneric.client("domain", "username", "password");
  */
  DDNSGeneric.client("account.duckdns.org", "12345678-1234-1234-1234-123456789012");

  DDNSGeneric.onUpdate(onUpdateCallback);
}

void loop() 
{
  // Check for New Ip Every 10 mins.
  DDNSGeneric.update(600000);
}

Debug Termimal Output Samples

  1. This is terminal debug output when running nRF52_Ethernet_DuckDNS_Client example on Adafruit nRF52 NRF52840_FEATHER.
Start nRF52_Ethernet_DuckDNS_Client on NRF52840_FEATHER with ENC28J60 using EthernetENC Library
HTTP WebServer is @ IP : 192.168.2.83
[DDNS] Access whatismyipaddress
[DDNS] httpCode = 200
[DDNS] Current Public IP = aaa.bbb.ccc.ddd
[DDNS] response = aaa.bbb.ccc.ddd
[DDNS] Sending HTTP_GET to duckdns
[DDNS] HTTP_GET = http://www.duckdns.org/update?domains=account.duckdns.org&token=token&ip=aaa.bbb.ccc.ddd
[DDNS] httpCode = 200
DDNSGeneric - IP Change Detected: aaa.bbb.ccc.ddd
[DDNS] Updated IP = aaa.bbb.ccc.ddd

Releases v1.1.0

  1. Add support to Arduino AVR ATmega2560 such as Mega, Mega2560, Mega ADK, etc.
  2. Add support to Arduino ATmega4809 such as UNO WiFi Rev2, AVR_NANO_EVERY, etc.
  3. Remove dependency on .
  4. Add OVH.com support.
  5. Update and add examples for AVR and megaAVR
  6. Add Version string
  7. Add Table-of-Contents

Releases v1.2.0

  1. Add support to Teensy boards such as Teensy LC, 3.0, 3.1, 3.2, 3.5, 3.6, 4.0, 4.1 using ESP-AT, WiFiNINA, W5x00 / ENC28J60 Ethernet
  2. Add support to Teensy 4.1 boards using NativeEthernet

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.