Fetching the IP address using MicroPython
Question:
Trying to use pybricks-micropython
Want to get the localhost name/IP address. Can do in CPython with this code… but doesn’t seem to be an equivalent I can find in MicroPython?
hostName = socket.gethostname()
hostIPA = socket.gethostbyname(hostName)
Searching on the net, but cannot seem to find anything I can use?
Answers:
Special Thanks to David Lechner who pointed me in the right direction and gave 95% of this answer.
os.popen('hostname -I'.read().strip().split(" "))
Gives you the IP4 address!
Trying to use pybricks-micropython
Want to get the localhost name/IP address. Can do in CPython with this code… but doesn’t seem to be an equivalent I can find in MicroPython?
hostName = socket.gethostname()
hostIPA = socket.gethostbyname(hostName)
Searching on the net, but cannot seem to find anything I can use?
Special Thanks to David Lechner who pointed me in the right direction and gave 95% of this answer.
os.popen('hostname -I'.read().strip().split(" "))
Gives you the IP4 address!