Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Document Micropython compatiblity #23

Open
peterfroehlich opened this issue Feb 14, 2020 · 3 comments
Open

Document Micropython compatiblity #23

peterfroehlich opened this issue Feb 14, 2020 · 3 comments

Comments

@peterfroehlich
Copy link

Hey guys!

This awesome library can be made to work with micropython easily by using the micropython port of datetime and using the micropython versions of time and requests:

@@ -1,8 +1,8 @@
 # coding=utf-8

-import requests
+import urequests as requests
 import datetime
-from time import mktime
+import utime as time

Thats it, everything I tried worked.

What do you think, just a section in the README, an already patched file in a subfolder or a edited fork in a new repo?

XOX

@leftshift
Copy link
Owner

Thanks for the praise!
Ohh, that's actually pretty cool, thanks for trying that out :D
It appears we could also check sys.implementation.name to see whether we're running on micropython and import the right modules depending on that.
I'm not 100% sure what I think about that but it would have the advantage of not having to maintain multiple different variants.
Unfortunately, I don't have a micropython board handy right now, but I'll try around in the unix micropython variant.

@s6adhimm
Copy link

s6adhimm commented Nov 9, 2022

Hey there! I found this awesome package a couple of days ago and wanted to make it run on my ESP8266 as well.
But unfortunately any urequests.get command to mvg raises a OS Error -40 . @peterfroehlich if your still around do you have any idea where this could be coming from and how to fix it?

@Stephaela
Copy link

Stephaela commented Feb 20, 2023

Hey everyone! I'm also currently working on that topic.
@s6adhimm I am not sure if I can help you, but I'll try. If you still have this problem, could you please try the following minimal example code:

import urequests
response = urequests.get(url='https://www.mvg.de/api/fahrinfo/departure/de:09184:490?footway=0')
print(response.json())

I don't have the same microcontroller like you, I have a Raspberry Pi Pico W, and on this board the example code above works, it is supposed to display the departures from Garching.
Could you please tell me if this code works for you? :)

For me, not all parts of the code in this repository worked for my microcontroller, but I was able to adapt it in order to get all the information I wanted. :)

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

No branches or pull requests

4 participants