Ok, now I can get it to connect to Blynk. Somehow, It got “timeout waiting for first EOF” error after connected to Blynk. I use this library GitHub - vshymanskyy/blynk-library-python: Blynk library for Python. Works with Python 2, Python 3
Here’s the error log:
registering in GSM network...
connected to GSM network2
get GPRS connection...
get UTC...
04:22:38 31-08-2021
Connecting to Blynk...
Connecting to blynk.cloud:443...
Connecting to blynk.cloud:443...
Blynk ready. Ping: 252 ms
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/bin/ampy", line 11, in <module>
load_entry_point('adafruit-ampy==1.1.0', 'console_scripts', 'ampy')()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/Users/chamroeun/Library/Python/3.8/lib/python/site-packages/ampy/cli.py", line 338, in run
output = board_files.run(local_file, not no_output, not no_output)
File "/Users/chamroeun/Library/Python/3.8/lib/python/site-packages/ampy/files.py", line 309, in run
self._pyboard.execfile(filename, stream_output=True)
File "/Users/chamroeun/Library/Python/3.8/lib/python/site-packages/ampy/pyboard.py", line 285, in execfile
return self.exec_(pyfile, stream_output=stream_output)
File "/Users/chamroeun/Library/Python/3.8/lib/python/site-packages/ampy/pyboard.py", line 277, in exec_
ret, ret_err = self.exec_raw(command, data_consumer=data_consumer)
File "/Users/chamroeun/Library/Python/3.8/lib/python/site-packages/ampy/pyboard.py", line 266, in exec_raw
return self.follow(timeout, data_consumer)
File "/Users/chamroeun/Library/Python/3.8/lib/python/site-packages/ampy/pyboard.py", line 230, in follow
raise PyboardError('timeout waiting for first EOF reception')
ampy.pyboard.PyboardError: timeout waiting for first EOF reception
And here’s my code:
import time
import cellular
import machine
import ntptime
import BlynkLib
from BlynkTimer import BlynkTimer
#machine.watchdog_on(30)
print("registering in GSM network...")
time.sleep_ms(200) #need only for serial output to be printed
while cellular.is_network_registered() == False:
time.sleep_ms(1000)
print("connecting...")
time.sleep_ms(200) #need only for serial output to be printed
print("connected to GSM network2")
time.sleep_ms(200) #need only for serial output to be printed
print("get GPRS connection...")
time.sleep_ms(200) #need only for serial output to be printed
try:
cellular.gprs("smart", "", "")
except Exception as e:
print('gprs exception:\n ' + repr(e))
time.sleep_ms(200) #need only for serial output to be printed
BLYNK_AUTH = 'mya'
print("get UTC...")
time.sleep_ms(200) #need only for serial output to be printed
while time.localtime()[0] == 2017: #2017 is year in A9G module by default at start
try:
ntptime.settime()
except Exception as e:
print('ntp exception:\n ' + repr(e))
time.sleep_ms(1000)
t = time.localtime()
print("{:02d}:{:02d}:{:02d} {:02d}-{:02d}-{}".format(t[3], t[4], t[5], t[2], t[1], t[0])) #print formatted time
time.sleep_ms(200) #need only for serial output to be printed
print("Connecting to Blynk...")
# Initialize Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)
# insecure=True, # disable SSL/TLS
# server='blynk.cloud', # set server address
# port=80, # set server port
# heartbeat=30, # set heartbeat to 30 secs
# log=print # use print function for debug logging
# )
@blynk.on("connected")
def blynk_connected(ping):
print('Blynk ready. Ping:', ping, 'ms')
@blynk.on("disconnected")
def blynk_disconnected():
print('Blynk disconnected')
@blynk.on("V*")
def blynk_handle_vpins(pin, value):
print("V{} value: {}".format(pin, value))
while True:
blynk.run()