Git Product home page Git Product logo

Comments (6)

ebolisa avatar ebolisa commented on August 15, 2024 1

@ebolisa, could you show a complete example?

First make wifimgr.py work without Blynk.
Then modify its html code to accept the blynk token.
Modify its py code so it can be read.

Then in boot.py:

try:
    wlan = wifimgr.get_connection()
    BLYNK_AUTH = wifimgr.get_profiles()[2]
    print('** Wifi connection established **')
    if wlan is None:
        print("Could not initialize the network connection.")
        while True:
            pass  # you shall not pass :D
except Exception:
    print('Wifi connection error...')
    umachine.reset()

in main.py:

# Initialize Blynk
try:
#     blynk = BlynkLib.Blynk(BLYNK_AUTH) # faster
    
#      or....

    blynk = BlynkLib.Blynk(BLYNK_AUTH,
        insecure=True,          	       # disable SSL/TLS
        server='lon1.blynk.cloud',	# lon1 fra1.blynk.cloud or blynk.cloud
        port=80,                	               # set server port
        heartbeat=30, 		       # set heartbeat to 30 secs      
        log=dprint              	       # use print function for debug logging
        )
except OSError as e:
    umachine.restart()
    
    
@blynk.on("connected")
def blynk_connected(ping):
    print('Blynk ready. Ping:', ping, 'ms')
    blynk.sync_virtual()


@blynk.on("disconnected")
def blynk_disconnected():
    print('Blynk disconnected')
    utime.sleep(5)
    umachine.reset()

from blynk-library-python.

EugeneRymarev avatar EugeneRymarev commented on August 15, 2024

@vshymanskyy, could you suggest?

from blynk-library-python.

ebolisa avatar ebolisa commented on August 15, 2024

could you suggest?

I used wifimgr.py. Modified the html/py code to collect credentials by storing them in wifi.dat and then, used them in my main code.

from blynk-library-python.

EugeneRymarev avatar EugeneRymarev commented on August 15, 2024

@ebolisa, I mean the implementation of the Blynk.Inject function for connecting in the application, as in this video

from blynk-library-python.

ebolisa avatar ebolisa commented on August 15, 2024

@ebolisa, I mean the implementation of the Blynk.Inject function for connecting in the application, as in this video

I undestood you. wifimgr.py puts your device in AP mode like shown in the video. Then you introduce your router and Blynk credentials. At reboot, your device will automatically connect to Blynk. At least, that's the way I do it.

from blynk-library-python.

EugeneRymarev avatar EugeneRymarev commented on August 15, 2024

@ebolisa, could you show a complete example?

from blynk-library-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.