• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

ESP32 MicroPython Static (fixed) IP address

Q&A Forum › Category: ESP32 › ESP32 MicroPython Static (fixed) IP address
0 Vote Up Vote Down
Jacques Vermaak asked 3 years ago

I recently purchased the MicroPython ESP32 ebook.

On one of the Random Nerd websites (DS18B20) an example is given using MicroPython to create a webserver for the temperature display.

I would like to assign a fixed (static) IP address to the code. The current code gets the IP address from the DHCP server, and time and again the address changed.

I have tried to add the following line just after the line

station.active(True)
station.ifconfig('192.168.100.205','255.255.255.0','192.168.100.2','8.8.8.8')

BUT, no matter in what format I enter the station.ifconfig….. information, the moment I add that line, the compiler fails with errors.

I am using Thonny, as uPyCraft does not want to connect to the ESP32 unless I do a firmware download each time.

Could you possibly give example code on how to setup a static IP address using micropython for an ESP32?

Thanks

3 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi Jacques,

We don’t have any example about static ip address with MicroPython.

But can you tell me the errors you’re getting?

Note that the ifconfig function should accept a tuple.
So, I think that if you use the following line instead (with double parentheses), it should work:

station.ifconfig(('192.168.100.205','255.255.255.0','192.168.100.2','8.8.8.8'))

See in this discussion: https://forum.micropython.org/viewtopic.php?t=2378

Let me know if this solves your issue.

Regards,
Sara

0 Vote Up Vote Down
Jacques Vermaak answered 3 years ago

Hi Sara,

I had the line in both single and double quotes (tuple) but neither of them worked.

This morning I flashed my ESP32 with the latest and greatest available firmware, (esp32-idf3-20191202-v1.11-611-g7f24c2977.bin) and there you go, problem solved. 

I hope I can get all my other modifications done before I hit the next obstacle.

Thank you 

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

I’m glad the problem is solved now.
I’ll mark this issue as resolved.
If you need further help, you just need to open a new question.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] SMART HOME with RPi, ESP32, and ESP8266 (version 1.2) March 8, 2023
  • [eBook Updated] ESP32-CAM Projects (version 1.3) January 7, 2023

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2023 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.