Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with ESP12F #1

Open
boinjoe opened this issue Jan 1, 2021 · 6 comments
Open

Problems with ESP12F #1

boinjoe opened this issue Jan 1, 2021 · 6 comments

Comments

@boinjoe
Copy link

boinjoe commented Jan 1, 2021

Thanks for this nice library. I’ve tried it on ESP32 and it works well. But with ESP12F (ESP8266) it’s not working. No idea if where is the problem.

@Benemenn
Copy link

i've tried it on the ESP8266 as well, but it doesn't work there, no clue why

@jordiprats
Copy link
Owner

Can you provide a sample app that's not working if it produces any relevant error message?

Thanks,

@smc8050
Copy link

smc8050 commented Jan 31, 2021

Hi,
Nice Library :-)
I also have tested your library in a ESP8266 (Wemos Lolin D1 Mini Pro) and unfortunately it does not work. I tested your demo project and it returns BOT LISTENING in the terminal but it does not react to a /ping message. I also tested to send a message with

bot.send('CHAT_ID', 'Bot started...')

But no response on Telegram. I also checked the Wifi connection with sta_if.ifconfig() and looks good, so no connection problems. I get the following error on the first start of the code:

  File "main.py", line 5, in <module>
  File "utelegram.py", line 4, in <module>
  File "urequests.py", line 181, in <module>
KeyboardInterrupt: 

I have seen in your utelegram.py you are using the urequests and I suppose it has to do with following error from the urequests together with the telegram API. This error can be replicated with following code:

import urequests

def do_connect():
    import network
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    if not wlan.isconnected():
        print('connecting to network...')
        wlan.connect('SSID', 'WIFI_PASSWORD')
        while not wlan.isconnected():
            pass
    print('network config:', wlan.ifconfig())

do_connect()

msg = "Testmessage"
token = "XXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
user_id = "XXXXXXXXXX"
urequests.get(f'https://api.telegram.org/bot{token}/sendMessage?text={msg}&chat_id={user_id}')

And returns following error:

Traceback (most recent call last):
  File "main.py", line 20, in <module>
  File "urequests.py", line 162, in get
  File "urequests.py", line 104, in request
OSError: -40
MicroPython v1.13 on 2020-09-11; ESP module with ESP8266

I have tried to find a solution but I have no clue....
Unfortunately I have no ESP32 on hand to try your code so I suppose this urequests error is only appearing on ESP8622 with the Telegram API, because using urequests.get("https://www.google.com") gets a valid reply...

Maybe this helps with solving the error.
Cheers:)

@jordiprats
Copy link
Owner

Hi,
With the latest merge we are explicitly freeing the urequests objects once they are no longer needed. I believe this could have been your issue. Could you please give it a try?

@joaomede
Copy link

OSError: -40 on ESP 8266 (ESP01).
very strange to work on esp32 and not on esp8266

@ghost
Copy link

ghost commented Jul 26, 2022

OSError: -40 on ESP 8266 (ESP01). very strange to work on esp32 and not on esp8266

This might be related to a ESP8266 specific TLS problem other urequests users (like me) encounter

micropython/micropython#3198 (comment)
micropython/micropython-lib#400 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants