Close

22 juni 2016

Smart Doorbell project with Adafruit Feather HUZZAH ESP8266

My doorbell is nothing more than a simple pushbutton. So if I wire a microcontroller to my doorbell, I just have to figure out some simple code that executed the following: if the doorbell is pushed, then send a push notification to my iPhone. So I need a doorbell, gladly my house is provided with one, a microcontroller (Feather HUZZAH), some wiring, a push notification service (Pushover) and at last some code.

Hardware:

  • Adafruit Feather HUZZAH (cheap, simple and WiFi onboard!)
  • Wires
  • Breadboard
  • Resistor 10K ohm
  • LED
  • Doorbell including wires

Software:

  • Arduino IDE (from arduino.cc)
  • Basic Button tutorial from Arduino.cc
  • Pushover Library for ESP8266 (Github)
  • Pushover API – Pushover has no monthly subscription fees and users will always be able to receive unlimited messages by making a one-time license purchase ($ 4,99) for our Android, iOS, or Desktop apps.

Steps:

  1. IN PROGRESSConnect Wires: 3.3V to + and GND to – on the breadboard.
  2. IN PROGRESS: Upload the code to the Feather via Arduino IDE – beware of the settings!

Example code:

#include
#include "Pushover.h"

void setup() {
Serial.begin(115200);
WiFi.begin("myNetwork", "secureWPAKii");
while (WiFi.status() != WL_CONNECTED) delay(50);
Serial.println("Connected");

Pushover po = Pushover("SecureAppToken","UserToken");
po.setDevice("Device1");
po.setMessage("Testnotification");
po.setSound("bike");
Serial.println(po.send()); //should return 1 on success
}

void loop() {
}
/*
  Button

 Turns on and off a light emitting diode(LED) connected to digital
 pin 13, when pressing a pushbutton attached to pin 2.


 The circuit:
 * LED attached from pin 13 to ground
 * pushbutton attached to pin 2 from +5V
 * 10K resistor attached to pin 2 from ground

 * Note: on most Arduinos there is already an LED on the board
 attached to pin 13.


 created 2005
 by DojoDave <http://www.0j0.org>
 modified 30 Aug 2011
 by Tom Igoe

 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/Button
 */

// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
  } else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}

Geef een reactie

Het e-mailadres wordt niet gepubliceerd. Verplichte velden zijn gemarkeerd met *