не могу отправить сообщение в telegram bot через micropython
import urequests
import json
import network
import webrepl
webrepl.start()
gc.collect()
def wifi_connect():
from machine import Pin
import time
led = Pin(2,Pin.OUT)
sta_if = network.WLAN(network.STA_IF)
if not sta_if.isconnected():
print('подключаемся к сети...')
sta_if.active(True)
sta_if.connect('wifi 2.4 ggh', 'Stimg123')
while not sta_if.isconnected():
pass
print('настройки сети:', sta_if.ifconfig())
wifi_connect()
def get_ip(API_KEY= None):
data = urequests.get("http://worldtimeapi.org/api/ip")
ip = json.loads(data.text)["client_ip"]
return ip
print (get_ip())
token = "мой токен"
chat_id = "мой id"
url = "https://api.telegram.org/bot{}/sendMessage?text={}&chat_id={}".format(token,get_ip(), chat_id)
urequests.get(url)
Ответ от устройства:
MPY: soft reboot
WebREPL daemon started on ws://192.168.0.65:8266
Started webrepl in normal mode
настройки сети: ('192.168.0.65', '255.255.255.0', '192.168.0.1', '192.168.0.1')
46.250.75.18
Traceback (most recent call last):
File "boot.py", line 37, in <module> --->>> это urequests.get(url)
File "urequests.py", line 116, in get
File "urequests.py", line 62, in request
OSError: -40
raw REPL; CTRL-B to exit
из под python на windows код работает, а в чем проблема с микро? Пользую ESP8266