如何解决树莓派开机后无法获取到 Wi-Fi IP 问题 All In One
如何解决树莓派开机后无法获取到 Wi-Fi IP 问题 All In One
fix 树莓派开机后无法链接 Wi-Fi IP 问题
开机后自动发送 IP
接入到 钉钉/飞书/微信 消息机器人
- API 接入
- shell 脚本,开机自执行
demos
#!\usr\bin\env python3
# coding: utf8
# import time
from time import sleep
import socket
import requests
def getRaspberryPiIP():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("1.1.1.1", 80))
ip = s.getsockname()[0]
s.close()
print("ip =", ip)
return ip
def post(ip):
# ⚠️ token 替换成自己的
url = "https://sc.ftqq.com/token.send"
data = "text=%s"% ip
results = requests.get(url, data)
print("results =", results)
if __name__ == '__main__':
# 等待联网
# time.sleep(20)
sleep(20)
while True:
ip = getRaspberryPiIP()
if ip == False:
print("获取网络地址失败 ❌")
post("获取网络地址失败 ❌")
else:
post(ip)
break
# time.sleep(5)
# sleep(5)
"""
https://sc.ftqq.com/
$ sudo vim /etc/rc.local
修改 /etc/rc.local, 在 exit 0 之前添加
/usr/bin/python /home/pi/ip-robot.py & sudo reboot
/usr/bin/python3 /home/pi/ip-robot.py && sudo reboot
"""
libs
requests
https://pypi.org/project/requests/
https://requests.readthedocs.io/en/latest/
https://github.com/psf/requests
Raspberry Pi Beginner's Guide 4th Edition
November 2020
https://magpi.raspberrypi.com/books/beginners-guide-4th-ed
refs
https://github.com/xgqfrms/dd-robot-notice
How to use SSH to access the Raspberry Pi without know the Wi-Fi IP address All In One
如何在不知道 Wi-Fi IP 地址的情况下使用 SSH 访问树莓派
https://www.cnblogs.com/xgqfrms/p/17322254.html
ifconfig
/ipconfig
https://www.cnblogs.com/xgqfrms/p/12084380.html
©xgqfrms 2012-2025
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/17278676.html
未经授权禁止转载,违者必究!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2022-04-01 HTML Input Element in depth All In One
2022-04-01 CSS tint() function All In One
2022-04-01 TypeScript override & overload All In One
2022-04-01 TypeScript & Node.js crawler All In One
2022-04-01 StackOverflow Filters All In One
2022-04-01 TypeScript FAQ All In One
2022-04-01 TypeScript Compiler All in One