Author Topic: mcModule as doorbell  (Read 9 times)

michaelblight

  • Newbie
  • *
  • Posts: 5
    • View Profile
mcModule as doorbell
« on: August 03, 2018, 02:08:31 am »
I'm looking to hook up a mcModule as a doorbell sending MQTT messages. I haven't been able to find any existing examples, and I'm no electrical engineer! Is it enough to connect pin 7 and GND to a push-button and define it as AnalogInputPullDown? I'm guessing not. Or do I need to connect VDD to push-button to pull-down resistor to GND and then connect pin 7 between switch and resistor?

And then is there an event to hook into that will fire when the push-button is pressed? Or do I have to poll pin 7 (which would drain the battery too fast)?

Any help would be appreciated.

Social Buttons


mc-T2

  • Administrator
  • Sr. Member
  • *****
  • Posts: 251
  • mc-Things! The opportunities are endless!
  • Location: Canada
    • View Profile
Re: mcModule as doorbell
« Reply #1 on: August 14, 2018, 10:43:08 am »
Hey michaelblight,

yes, I havent seen anyone post this project yet, however, we have done this ourselves and i know of some users who have done a button onto a mcModule. The mcModule includes a small button/switch already but if you wished, you could connect a push button and use it for a doorbell (or other purposes).

Since you are working on the older version (legacy) of the mcThings platform, you will need to work with some older code. NOTE - We are moving towards the public release of mcCloud in the next month or two so keep an eye out as the new version of mcCloud is very versatile and makes it much easier to work with multiple devices! Older equipment will not work on the new system but we are going to be offering our users discounted hardware for those who want to move to the new system. It should also be noted that we are no longer supporting the legacy system (no new firmware, big fixes, etc) as we are focusing on the new version.

Button code: The below is a code we used to send information to the IFTTT service but you can modify it to send the info to elsewhere if you wish. A standard pushbutton was soldered to PIN 0 and GRD from the button and then the device was loaded with the below code:


Code: [Select]
Class ButtonExample
   
    //The following will send an IFTTT message when the button is pressed & will light the LED when pressed
    Shared Event ButtonPressed()
        Thread.Sleep(50000)
        Thread.ClearHardwareEvent()
        'If Pin0 = False Then
        If Button0 = False Then
            Lplan.IFTTT("YOURIFTTTWEBHOOKKEYHERE", "BUTTON", "pressed")
            LedGreen = True // turn off LED
            Thread.Sleep(100000)
            LedGreen = False
            Thread.Sleep(120000000)
        End If       
    End Event   
End Class

From there, we setup an IFTTT applet which would send a notification/email/text when the button is pressed. Note, there can sometimes be some lag as you are working with a third-party service.. sometimes it is lightening fast and other times it can take up to a minute. You will also need to test and ensure that your mcGateway is in range of the device.
Hope that helps, good luck and when the new version of mcCloud is out, we will be pushing out the same above example for a button so you can do this on the new system.
Thanks
Need more mc-Modules, mc-Gateways or other mc-Things? Check out our product page: www.mcthings.com/products. mc-Development kits are available too!
Check out a live Dashboard using mcThings and Losant! Click here: https://goo.gl/ST43hB