Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    WiPy 2.0 + Blynk

    Scheduled Pinned Locked Moved WiPy 2&3
    blynkattributeerrorimport
    7 Posts 4 Posters 2.5k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B Offline
      BitNide
      last edited by BitNide

      So I'm new to python and the blynk system but figured it couldn't be that difficult. However I'm getting stuck at importing the library. The steps I took:

      1. Update Firmware: 1.7.2.b1
      2. Build the FTP connection with Pymakr plugin on the Atom IDE
      3. Update the boot.py to connect to home wifi network (suc. connection)
      4. Run the main.py code over the connection

      The Code I want to run is from the example and tragically simple:

      import BlynkLib
      import time

      BLYNK_AUTH = "my token"

      blynk = BlynkLib.Blynk(BLYNK_AUTH)
      def v3_write_handler(value):
      print('Current slider value: {}'.format(value))
      blynk.add_virtual_pin(3, write=v3_write_handler)
      blynk.run()

      However on bootup I get the following message:
      Traceback (most recent call last):                                                                             
        File "main.py", line 2, in <module>                                                                          
        File "/flash/lib/BlynkLib.py", line 126, in <module>                                               
        File "/flash/lib/BlynkLib.py", line 127, in HwPin                                                     
      AttributeError: type object 'Timer' has no attribute 'B'

      When I try to run the program I get a different error:
      AttributeError: 'module' object has no attribute 'Blynk'
      Now I checked and the library does include the class Blynk and only shared import is "time".

      I''m using Atom IDE pymakr plugin on MicroPython v1.8.6
      If someone could help me solve this it would be awesome

      T 1 Reply Last reply Reply Quote 0
      • B Offline
        BitNide
        last edited by

        could the problem be in the HwPin class using machine.Timer.B? resulting in import error?

        L 1 Reply Last reply Reply Quote 0
        • L Offline
          livius @BitNide
          last edited by

          @BitNide
          Code is for wipy1.0 not for wipy2.0
          You must migrate it or wait for pycom for migrating (if it is somehow in progress)

          think about people first, then computers

          1 Reply Last reply Reply Quote 0
          • B Offline
            BitNide
            last edited by

            how would I go about migrating it?

            Also I have been debugging a bit further and found the following code which seems to be at fault:

            timeModule = sys.modules["time"]

            setattr(timeModule, 'sleep_ms', sleep_ms)
            setattr(timeModule, 'ticks_ms', ticks_ms)
            setattr(timeModule, 'ticks_diff', ticks_diff)

            I get the error : "keyError: time"

            It seems to me like the time module does not accapt the additional attributes.

            1 Reply Last reply Reply Quote 0
            • B Offline
              BitNide
              last edited by

              YAY I FIXED IT

              for anyone wanting to use the library and connect to blink.

              in the MachineStub.py file remove line 203+
              in the BlynkLib.py file change all the instances of:
              time.sleep_ms -> MachineStub.sleep_ms
              time.ticks_ms -> MachineStub.ticks_ms
              time.ticks_diff -> MachineStub.ticks_diff

              be sure to import both the MachineStub and machine module in the BlynkLib.py module

              1 Reply Last reply Reply Quote 2
              • C Offline
                crankshaft
                last edited by

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • T Offline
                  ttmetro @BitNide
                  last edited by

                  @BitNide
                  I got it "working" ... at least 02_virtual_read.py.

                  In BlynkLib.py I changed _TimerMap = {}.

                  Rationale: Presumably the HwPin class is not used by virtual pins. Then it would not be surprising if they are not affected by the change. Not sure yet if I even care about non-virtual pins.

                  1 Reply Last reply Reply Quote 0

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  • 1 / 1
                  • First post
                    Last post

                  Pycom on Twitter

                  Pycom