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

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 พ.ย. 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

  • @am604
    @am604 ปีที่แล้ว +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!

    • @meryamhad2916
      @meryamhad2916 6 หลายเดือนก่อน

      did this work?

  • @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

  • @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.

  • @mohsenjavaher7782
    @mohsenjavaher7782 6 หลายเดือนก่อน

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

    • @meryamhad2916
      @meryamhad2916 6 หลายเดือนก่อน

      did this work ?

  • @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!

  • @jgunther3398
    @jgunther3398 3 ปีที่แล้ว

    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!!!

  • @poruatokin
    @poruatokin 2 ปีที่แล้ว +1

    This is wonderful stuff. You deserved a larger following.

    • @MishMashLabs
      @MishMashLabs  2 ปีที่แล้ว

      Thanks for the support Paul!

  • @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!

  • @dienau6313
    @dienau6313 ปีที่แล้ว

    what if I use ESPAsyncWebServer instead of Webserver?

  • @0124akash
    @0124akash ปีที่แล้ว

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

  • @lukmannet
    @lukmannet 3 ปีที่แล้ว

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

  • @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.

  • @isxckk.
    @isxckk. 11 หลายเดือนก่อน

    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..

  • @edudiy9438
    @edudiy9438 2 ปีที่แล้ว

    Where i find gatewayIP my phone is a router
    ??

  • @divyshah8437
    @divyshah8437 3 ปีที่แล้ว +3

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

  • @juanjo2d
    @juanjo2d 2 ปีที่แล้ว

    Just what I needed!! Thank youuuuu

    • @meryamhad2916
      @meryamhad2916 6 หลายเดือนก่อน

      did this work ?

    • @juanjo2d
      @juanjo2d 6 หลายเดือนก่อน

      ​@@meryamhad2916it worked for me, yes

  • @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?

  • @lokhenderkummari5773
    @lokhenderkummari5773 2 ปีที่แล้ว

    how to we remove the wifi network hosted from esp?

  • @avidiy555
    @avidiy555 ปีที่แล้ว

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

  • @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 ...

  • @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

  • @rushabhkulkarni363
    @rushabhkulkarni363 3 ปีที่แล้ว

    tried network id and pass of my router didnt work

  • @dhavalsolanki3562
    @dhavalsolanki3562 ปีที่แล้ว

    This is greatest stuff.

  • @sweetygangane4551
    @sweetygangane4551 ปีที่แล้ว

    Ip address is not comming

  • @africantech5
    @africantech5 2 ปีที่แล้ว +1

    Am using esp8266

  • @afghanistantechnology3833
    @afghanistantechnology3833 3 ปีที่แล้ว

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

  • @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 ปีที่แล้ว

    Thanks