-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathpython_reader.py
More file actions
22 lines (17 loc) · 857 Bytes
/
python_reader.py
File metadata and controls
22 lines (17 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
""" PY READER FROM ESP """
# Written by Junicchi - https://github.com/Kebablord
from time import sleep
import urllib.request
url = "http://ENTER ESP'S IP ADRESS HERE" # ESP's IP, ex: http://192.168.102/ (Check serial console while uploading the ESP code, the IP will be printed)
def get_data():
global data
n = urllib.request.urlopen(url).read() # get the raw html data in bytes (sends request and warn our esp8266)
n = n.decode("utf-8") # convert raw html bytes format to string :3
data = n
# data = n.split() #<optional> split datas we got. (if you programmed it to send more than one value) It splits them into seperate list elements.
# data = list(map(int, data)) #<optional> turn datas to integers, now all list elements are integers.
# Example usage
while True:
get_data()
print("Your data(s) which we received from ESP: "+data)
sleep(1)