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 motion and ambient conditions sensor node

    Scheduled Pinned Locked Moved Projects
    wipy
    8 Posts 3 Posters 3.3k Views 3 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.
    • R Offline
      robmarkcole
      last edited by

      So far I have a PIR motion sensor which toggles the Wipy LED from yellow to red when triggered by motion, and it is printing the temp/pressure data from a DHT22. Bit of work to understand some dubious readings from the DHT, and need to add MQTT.

      My code (below) needs improvement - in particular some motion events are missed, or there appears to be a delay of a couple of seconds before it is triggered. Perhaps my use of time.sleep() is the problem. Any advice on how to improve the code appreciated :-)
      Cheers
      Robin

      0_1496779440147_upload-06bc49ea-f31e-4114-8969-4243be57820c

      1 Reply Last reply Reply Quote 0
      • R Offline
        robmarkcole
        last edited by

        Unfortunately I can't post the code directly as I keep getting this wretched 'spam error', so see main.py on https://github.com/robmarkcole/Wipy_multisensor

        1 Reply Last reply Reply Quote 0
        • RobTuDelftR Offline
          RobTuDelft
          last edited by

          @robmarkcole Hey Robin, your callback takes more than 500 ms. Since they will be queued sequentially you might experience these delays I guess, 16 x 500 ms = 8 seconds.

          Which kind of PIR sensor is that?

          Without data you're just another person with an opinion.
          Hackster | About me

          R 1 Reply Last reply Reply Quote 0
          • P Offline
            peekay123
            last edited by peekay123

            @robmarkcole, I would take the publish and rgbled code out of the callback and only set a global flag. In your while True loop, read the flag and take action when set. This will minimize the callback timing. As for your rgbled, you could use non-blocking delays instead of hard delay().

            R 1 Reply Last reply Reply Quote 0
            • R Offline
              robmarkcole @RobTuDelft
              last edited by

              Hi @RobTuDelft the sensor is AM312 Mini PIR Sensor, https://www.amazon.co.uk/gp/product/B016Y10B3O/ref=as_li_ss_tl?tag=brau03-21&ie=UTF8&psc=1&linkCode=ll1&linkId=0bb8888d752ec23f1d451691989542c8

              R 1 Reply Last reply Reply Quote 0
              • R Offline
                robmarkcole @peekay123
                last edited by

                Hi @peekay123 thanks for the advice. Rather than using sleep() would I be better off triggering the data post e.g. on the second?

                Re using a flag, I guess you mean something like below? I notice that the LED doesn't switch to red when motion is registered.
                Cheers

                0_1496900425753_upload-725d0341-0b36-4eb2-89c1-046bf914fe6f

                RobTuDelftR 1 Reply Last reply Reply Quote 0
                • RobTuDelftR Offline
                  RobTuDelft @robmarkcole
                  last edited by

                  @robmarkcole It is not really useful to only read the temperature once and keep validating that result in your if-loop? Maybe also include result = th.read() in the while True-loop.

                  Without data you're just another person with an opinion.
                  Hackster | About me

                  1 Reply Last reply Reply Quote 0
                  • R Offline
                    robmarkcole @robmarkcole
                    last edited by

                    @robmarkcole said in Wipy motion and ambient conditions sensor node:

                    Hi @RobTuDelft the sensor is AM312 Mini PIR Sensor, https://www.amazon.co.uk/gp/product/B016Y10B3O/ref=as_li_ss_tl?tag=brau03-21&ie=UTF8&psc=1&linkCode=ll1&linkId=0bb8888d752ec23f1d451691989542c8

                    It is used in https://github.com/bruhautomation/ESP-MQTT-JSON-Multisensor and has on-board processing as described in the linked video

                    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