@vcr3at3 this is the second “need help…” topic that you’ve created today without providing the information that is requested with this type of topic. This information is requested for a good reason - so that forum members can provide you with assistance without having to ask lots of additional questions.
You’ve also chosen to ignore this information about how to correctly format your code when you post it to the forum.
This is the pre-populated information that you’ve chosen to ignore…
Add details :
• Hardware model + communication type. For example: Arduino UNO with Ethernet Shield
• Smartphone OS (iOS or Android) + version
• Blynk server or local server
• Blynk Library version
• Add your sketch code. Code should be formatted as example below.
Simply paste your code between ``` If you don’t format your code, your topic can be deleted by moderators.
```cpp
void loop()
```
Maybe you would like to edit your initial post in this topic and fill-in the blanks, and re-post your code in the requested format?
I did not chose to ignore the info, I just missed it.
I think you are the community forum moderator and I am just a guy who is looking for help.
this is the second “need help…” topic that you’ve created today without providing the information that is requested with this type of topic.
You’ve also chosen to ignore this information about how to correctly format your code when you post it to the forum.
@vcr3at3 - Pete is a well respected member of this community, no need for snotty comments. everyone here are community and want to help, loss of business to blynk is a poor comment and really not much else out there that offers the pricing and value, so either work with us to help you or move swiftly along.
Let’s look at you code now:
Looking at you code provided, you are not allowing for checks and balances:
some ESP32 wifi connections can take +/- 20-30 seconds to connect.
which Blynk Library version are you using?
Are you using the new Blynk app and not the old one?
What errors are you getting (from your print statements?
• ESP 32 Dev Module as a WiFi Station
• Android 10
• Using Blynk server
• Blynk Library version https://github.com/blynkkk/lib-python
• Adding code
I am using the new Blynk Version.
I do not get any errors, simpy the Blynk Logo that comes when we initialize Blynk
import blynklib
import network
import esp
import gc
import time
import machine
from machine import Pin, PWM
esp.osdebug(None)
gc.collect()
wifi_status = Pin(2, Pin.OUT)
wht_pin = PWM(Pin(13), freq=1000, duty=0)
ylw_pin = PWM(Pin(12), freq=1000, duty=0)
ssid_01 = 'thunderACT'
ssid_02 = 'A8'
password = '###'
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
avl_networks = wlan.scan()
print(avl_networks)
print('{} networks available!'.format(len(avl_networks)))
for i in range(len(avl_networks)):
while (wlan.isconnected() == False):
wifi_status.off()
if b'thunderACT' in avl_networks[i]:
wlan.connect(ssid_01, password)
break
else:
wlan.connect(ssid_02, password)
break
break
print('Connected with {}'.format(wlan.config('essid')))
wifi_status.on()
print('IP Configuration: {}'.format(wlan.ifconfig()))
BLYNK_AUTH = '###'
# initialize Blynk
blynk = blynklib.Blynk(BLYNK_AUTH)
WRITE_EVENT_PRINT_MSG = "[WRITE_VIRTUAL_PIN_EVENT] Pin: V{} Value: '{}'"
# register handler for virtual pin V4 write event
@blynk.handle_event('write V1')
def write_virtual_pin_handler(ylw_pin, value):
print(WRITE_EVENT_PRINT_MSG.format(1, value))
@blynk.handle_event('write V0')
def write_virtual_pin_handler(wht_pin, value):
print(WRITE_EVENT_PRINT_MSG.format(0, value))
###########################################################
# infinite loop that waits for event
###########################################################
while True:
blynk.run()
@SmsAlert please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```
I checked that my network was not connected properly. After getting a proper connection, I ran the following code snippet
if WIFI.isconnected():
print('---> Network Config:', WIFI.ifconfig())
GenRes = WIFI.status('rssi')
# Get External IP Address
try:
EXTIP = usocket.getaddrinfo("google.com",1)[0][-1][0]
print ('---> External IP: ' + str(EXTIP))
WIFISTATUS = 1
WIFIFAILED = 0
except:
print ('---> No Internet Access On: ' ,WIFISSID)
WIFI.disconnect() # Disconnect
WIFI.active(False) # De-activate The Wi-Fi
The code ran successfully.
After that, I again ran this code below -
# Initialize Blynk
import blynklib, blynk_timer
import time
BLYNK_AUTH = '###'
# initialize Blynk
blynk = blynklib.Blynk(BLYNK_AUTH)
tmr_start_time = time.time()
while True:
blynk.run()
t = time.time()
if t - tmr_start_time > 1:
print("1 sec elapsed, sending data to the server...")
blynk.virtual_write(0, "time:" + str(t))
tmr_start_time += 1
Now I get the following error -
Connecting to blynk.cloud:443...
.Traceback (most recent call last):
File "<stdin>", line 8, in <module>
File "/lib/blynklib.py", line 214, in __init__
File "/lib/blynklib.py", line 81, in __init__
File "/lib/blynklib.py", line 226, in connect
OSError: -202
I also had a few issues in the beginning and had to make quite a few changes to the new blynk library, go to the blynk library and change the following code at line 223 to 226 to the below code snippet:
On the OS Error issue: OSError is a built-in exception in Python and serves as the error class for the os module, which is raised when an os specific system function returns a system-related error, including I/O failures such as “file not found” or “disk full”.
I tried changing the new blynk library code as you showed above but now I am getting this new error while executing the virtual_write example in the library.
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ \/ '_/
/____/_/\_, /_//_/_/\_\
/___/ for Python v1.0.0 (esp32)
Traceback (most recent call last):
File "<stdin>", line 7, in <module>
File "/lib/BlynkLib.py", line 222, in __init__
File "/lib/BlynkLib.py", line 85, in __init__
File "/lib/BlynkLib.py", line 253, in connect
NameError: name 's' isn't defined
After pasting the new code snippet shared by you, my blynk library connect function looks like this -
The device went online once. But again I am getting OSError
My code -
import BlynkLib
import time
BLYNK_AUTH = '###'
# initialize Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)
tmr_start_time = time.time()
while True:
blynk.run()
t = time.time()
if t - tmr_start_time > 1:
print("1 sec elapsed, sending data to the server...")
blynk.virtual_write(0, "time:" + str(t))
tmr_start_time += 1
Error output -
Connecting to blynk.cloud:443...
Traceback (most recent call last):
File "<stdin>", line 7, in <module>
File "/lib/BlynkLib.py", line 214, in __init__
File "/lib/BlynkLib.py", line 81, in __init__
File "/lib/BlynkLib.py", line 240, in connect
OSError: [Errno 12] ENOMEM
```