How to Assign a Static / Fixed IP Address | ESP8266 | ESP32 | Arduino

Поделиться
HTML-код
  • Опубликовано: 5 сен 2024
  • Mish Mash Labs present how to set a static of fixed IP address for your Espressif ESP8266, ESP32 or Arduino Board.
    If you’re running a web server or client over WiFi or Ethernet with your Espressif ESP8266, ESP32 or Arduino Board and every time you restart your board it has a new IP address which is what happens when you use the default DHCP (Dynamic Host Configuration Protocol) you can follow this tutorial to change the settings to assign a static or fixed IP address.
    Code used:
    Before the setup loop:
    // Set your Static IP Address Settings
    IPAddress local_IP(192, 168, 1, 199);
    IPAddress gateway(192, 168, 1, 1);
    IPAddress subnet(255, 255, 0, 0);
    IPAddress primaryDNS(8, 8, 8, 8); // this is optional
    IPAddress secondaryDNS(8, 8, 4, 4); // this is optional
    In the setup loop:
    // Print feedback if the settings are not configured
    if (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS)) {
    Serial.println("STA Failed to configure");
    }
    See our GitHub for complete sketch:
    github.com/mis...
    #ESP32 #ESP8266 #Arduino #Static #IP #tutorial #mishmash
    Instagram: mishmashlabs
    Twitter: mishmashlabs/
    Music Credits:
    Intro & Outro by audionautix.com

Комментарии • 49

  • @benditovicentecosta1710
    @benditovicentecosta1710 3 года назад +4

    My god, i just thank you a lot, this video helped me so much that i can-t find the right words to express my joy ☺

    • @MishMashLabs
      @MishMashLabs  3 года назад +1

      You're very welcome. This is the reason we make videos.

  • @am604
    @am604 9 месяцев назад +1

    Thanks so much bro i really needed this for a school project ive been strugging to find a way so the ip is constant and wont change.
    Once again thank you so much!

  • @enredao_electronico2737
    @enredao_electronico2737 4 года назад +2

    Nice explainned. It would be interesting (if you are running a bult in webserver in the ESPXX) :1- Begin as AP (Access Point) with predefined Host. 2- Once your device get connected to the AP through built in webserver, have the ability to SCAN near by WIFI SSIDs (including your Wifi router) . 3- After selection and reboot you get logged and ESPXX became STA (station) .4- Since you are connected to it through webserver and your SOHO router asigned an IP (DHCP method) , will be outstanding to have the option to do that particular IP Fixed. It is a long process but once (in my opinion) you get it done would be easier for an "End-User" instead of using Arduino/VScode IDE.

    • @MishMashLabs
      @MishMashLabs  4 года назад +2

      That's a really nice idea. And it has so many applications for IoT prototypes, I guess you would need to use eeprom or some form of memory and maybe a button on a GPIO pin to use a reset to the hardcoded AP setting you mentioned, perhaps I'll give it a go in a few weeks.

    • @enredao_electronico2737
      @enredao_electronico2737 4 года назад +1

      @@MishMashLabs you are right ! it would need a "Factory default" (hard-Switch or Software) and should keep saved the parameters on eeprom ( ESP32XX flash memory) . If you decide to you go into that that would be interesting . Thanks for A Detailed Yet Simple to Understand Guide.

  • @forgeteverythingyouknow5413
    @forgeteverythingyouknow5413 2 года назад +1

    This is so useful and I'm so surprised... You're the only one I've seen share this information

  • @evilmode100
    @evilmode100 2 года назад +2

    As always people that deserves credits dont get them.. I watched perhaps 100 videos trying to to do what you made me (understand) in 4 minutes... No words to thank you and sorry for my english.

    • @MishMashLabs
      @MishMashLabs  2 года назад

      Thanks for the kind words George! Please like the video and subscribe if you enjoy the style and content. This is a marathon project. Not a sprint!

  • @mohsenjavaher7782
    @mohsenjavaher7782 4 месяца назад

    Im going to test this, and if this solves my problems i will PRAY for you❤

  • @jgunther3398
    @jgunther3398 2 года назад

    i got some errors when i complied your gethub file, but was able to get the info to do what i needed. i guess there are a lot of different libraries out there. thanks!!!

  • @fernsgilbert
    @fernsgilbert 2 года назад +1

    thanks a lot. Worked fine for me except one error > Serial.printIn is not recognised so changed to > Serial.print

    • @MishMashLabs
      @MishMashLabs  2 года назад +1

      Hi there,
      Both are correct, the difference is Serial.println starts printing on a new line from the next Serial.print or Serial.println function. While Serial.print will continue on the same line.
      You may have had another error if there was an issue uploading, missing a semicolon perhaps?
      Thanks for the feedback!

  • @divyshah8437
    @divyshah8437 3 года назад +3

    thank you for this video
    it solved a big problem in my project
    thank you once again

  • @mohammadhosienanji5885
    @mohammadhosienanji5885 3 года назад +1

    Thanks for this video. I did as the video but the IP that serial sent is different from the IP that I see in my phone's hotspot.(IP is as previous). What's the problem?

    • @MishMashLabs
      @MishMashLabs  3 года назад +1

      Each device on a network will have a unique IP. The range should be the same, for example if your phone/hotspot IP is 192.168.0.1, your ESP can be 192.168.0.X where X can be any number between 2-254.

  • @poruatokin
    @poruatokin 2 года назад +1

    This is wonderful stuff. You deserved a larger following.

  • @techinstack7572
    @techinstack7572 3 года назад

    hello brother,can you please try this method without router,instead of router coonect with mobile hotspot ..??? please do same with mobile subnet and gateway credntials ...

  • @isxckk.
    @isxckk. 8 месяцев назад

    For me it does not work, i am trying to give my ESP8266 (That is functioning as a server for some domotica devices) a static IP, it is connected to my laptop hotspot. But for some reason it does not stay static..

  • @juanjo2d
    @juanjo2d Год назад

    Just what I needed!! Thank youuuuu

    • @meryamhad2916
      @meryamhad2916 4 месяца назад

      did this work ?

    • @juanjo2d
      @juanjo2d 4 месяца назад

      ​@@meryamhad2916it worked for me, yes

  • @lukmannet
    @lukmannet 2 года назад

    I am trying but cant compile: no matching function for call to 'WiFiClass::config(IPAddress&, IPAddress&, IPAddress&, IPAddress&, IPAddress&)'

  • @dienau6313
    @dienau6313 11 месяцев назад

    what if I use ESPAsyncWebServer instead of Webserver?

  • @0124akash
    @0124akash Год назад

    How to find
    Local ip
    Gateway
    Subnet
    Primary dns
    Mac address
    ??

  • @domoledlight
    @domoledlight 2 года назад

    hello Sir good video how to read from spiffs a IPAddress local_IP(192, 168, 1, 199); i want to put it as a variable sored in the memory

  • @lokhenderkummari5773
    @lokhenderkummari5773 2 года назад

    how to we remove the wifi network hosted from esp?

  • @edudiy9438
    @edudiy9438 Год назад

    Where i find gatewayIP my phone is a router
    ??

  • @rafaoli9918
    @rafaoli9918 3 года назад +1

    hi i don't know if you can help me but i i have an ip adess that i gave to my esp32 when i create a webserver it works fine but when i change the esp32 adress to a static ip the webserver doesn't work i also tried to ping and i get no response coudl you help me?

  • @dhavalsolanki3562
    @dhavalsolanki3562 Год назад

    This is greatest stuff.

  • @rushabhkulkarni363
    @rushabhkulkarni363 3 года назад

    tried network id and pass of my router didnt work

  • @avidiy555
    @avidiy555 Год назад

    My esp8266 not connect mobile hotspot, ssid and password ok, but not connect😢😢

  • @africantech5
    @africantech5 2 года назад +1

    Am using esp8266

  • @sweetygangane4551
    @sweetygangane4551 Год назад

    Ip address is not comming

  • @monamohammadi4572
    @monamohammadi4572 3 года назад

    Hello, thank you, these are good and practical tutorials
    I compiled the code but it warned
    (no matching function for call to 'WiFiClass :: config (IPAddress &, IPAddress &, IPAddress &, IPAddress &, IPAddress &)))
    Please guide me to fix this error

    • @MishMashLabs
      @MishMashLabs  3 года назад +1

      Confirm you have the esp32 boards installed and have selected the correct board before upload.

    • @monamohammadi4572
      @monamohammadi4572 3 года назад

      @@MishMashLabs I use the 8266 range.
      The library of this board is installed.
      Set up a HTTP Web Server and Control program works without any problems, but this program displays the following warning.
      no matching function for call to 'WiFiClass :: config (IPAddress &, IPAddress &, IPAddress &, IPAddress &, IPAddress &)'

    • @rushabhkulkarni363
      @rushabhkulkarni363 3 года назад

      @@MishMashLabs me too facing same issue
      no matching function

  • @erdimsengun1672
    @erdimsengun1672 11 месяцев назад

    Thanks

  • @afghanistantechnology3833
    @afghanistantechnology3833 3 года назад

    Hi sir
    When i search the ip address
    it asks me for username and password.
    What should i write?