UnKnocki

by raghav_anand98 in Circuits > Remote Control

625 Views, 5 Favorites, 0 Comments

UnKnocki

unKnocki

The Knocki is a device that released on Kickstarter a while back and has (as of writing this article) received over half a million dollars in funding. The premise behind the Knocki is that it allows us to access different functions around the house using knocks on different surfaces. The Knocki is meant to be something that uses the context of the location to enable intuitive functions, for example knocking on your bedside table in the morning should turn off your alarm, or knocking on your kitchen counter should turn the microwave on. The idea is to reengage ourselves with technology in a more tactile way. Everything sounds good, right?

Not so much. While the idea is terrific, each Knocki costs $69 (at the Kickstarted super-early bird price) and will probably cost almost $100 at retail. The biggest issue with this is it limits someone who doesn't have $300-$400 of spare cash to a single Knocki (atmost). But a single Knocki cannot deliver the full experience of connecting with technology around the house in a tactile manner. So my friend and I decided to create a DIY version of the Knocki that works just as well, but costs much less. The end product of our design (with miniaturization taken into account) cost approximately $70 for 3 "unKnocki's" all costs taken into account. Adding each unKnocki only requires $8-$10 because we only add a transmitter module and use a common command center.

For those of you who want to build this from scratch, follow the instructable. For the others who'd just like a good story of the challenges we faced building the unKnocki, continue reading here.

UPDATE: We're working on a version that is cheaper and easier to use than even this one, so stay tuned!

The Parts

There are a few different components to this project - namely the transmitter, the receiver and the command center.

Transmitter

  • Arduino (any Arduino is fine)
  • Piezo Buzzer
  • 1 megaohm resistor
  • RF Transmitter (433 Mhz)

Receiver

  • Another arduino
  • RF Receiver (433 MHz)

General Components

  • Breadboards
  • Jumper Cable
  • Laptop (to program the Arduino)

Command Center

A raspberry pi or any old unused laptop or pc with access to the internet and the ability to run python will do.

Wiring and Programming the Transmitter

transmitter_bb.jpg

Follow the diagram to wire the transmitter circuit.

Code

Upload the following code after downloading the VirtualWire Library to your arduino IDE.

#include <VirtualWire.h>// you must download and install the VirtualWire.h to your hardware/libraries folde

int sensorPin = A0;    // select the input pin for the potentiometer
  int counter = 0;
   int thold = 8;
   int bpin = 2;
   int maxm = 0;
  int pvalue = 0;
  bool reset = false;
  
 char str[1];

void setup() {
  
  Serial.begin(9600);
  pinMode(bpin,INPUT);
  pinMode(13,OUTPUT);

  vw_set_ptt_inverted(true); // Required for RF Link module
 vw_setup(1000);                 // Bits per sec
 vw_set_tx_pin(11);   </p><p>Serial.println("hi");
}

void loop() {

if (digitalRead(bpin) == HIGH){
  thold = 0;
  maxm = 0;
  reset = true;
}
  while (digitalRead(bpin) == HIGH){
    
    pvalue = analogRead(sensorPin);

    if (maxm


if (reset){
  reset = false;
    thold = maxm-(maxm*0.4);
    Serial.print("Max Value set to: ");
    Serial.println(thold);
  }


  counter = 0;
  // read the value from the sensor:
  int pin = analogRead(sensorPin);</p><p>  if (pin>thold){
    counter=1;
   unsigned long currentMillis = millis();
   delay(50);

   
     while((unsigned int)(millis()thold){
        counter++;
        delay(50);

     }
      
    }
    
    //delay(50);
    Serial.print(counter);
 str[0] = (10+counter);
 
 vw_send((uint8_t *)str, strlen(str));
  //vw_wait_tx();  // Wait for message to finish
digitalWrite(13,1);
delay(100);
digitalWrite(13,0);
   Serial.println(" sent"); }

  delay(5);

}

IMPORTANT: The code uses a button to set a threshold value to detect the knock. To set the threshold value, hold down the button and knock as you would normally on the table. Knocking too hard while setting the threshold will result in a very high threshold making it difficult to detect the knock, and knocking too softly will result in the slightest of taps as being interpreted as a knock. Make sure you find a sweet spot. Using the serial monitor to check how many knocks are being detected is a good way of going about this.

You can create as many transmitters as you want, but be sure to change the code such that the number transmitted is different for each transmitter. A good way to do this is to add ten to the number of knocks for the first transmitter, twenty to the number of knocks for the second and so on. In this process you will receive signals like the number 22, which means the second transmitter was knocked twice. This change needs to be done in the line that says

<p>str[0] = (10+counter);</p>

Wiring and Programming the Receiver

receiver_bb.jpg

Use the diagram to wire the receiver.

Upload the following code into the Arduino.

#include <VirtualWire.h>  // you must download and install the VirtualWire.h to your hardware/libraries folder

int numbers[3]; // Change 3 to number of integers you wish to send.

void setup()
{
 Serial.begin(4800);// Initialise the IO and ISR
 vw_set_ptt_inverted(true);    // Required for RX Link Module
 vw_setup(1000);                   // Bits per sec
 //vw_set_rx_pin(2);           // We will be receiving on pin 23 (Mega) ie the RX pin from the module connects to this pin.
 vw_rx_start();     
 pinMode(11, OUTPUT);// Start the receiver</p><p> Serial.println("Receiver ready!");
}

void loop(){
 uint8_t buf[VW_MAX_MESSAGE_LEN];
 uint8_t buflen = VW_MAX_MESSAGE_LEN;</p><p> if (vw_get_message(buf, &buflen)) // check to see if anything has been received
 {
  for (int i = 0; i < buflen; i++)
   {
     //Serial.print("buf[");
     //Serial.print(i, DEC);
    // Serial.print("]=");
int val = (buf[i]);
    
     Serial.println(val);
   }
 }
 
 delay(50);
}

The receiver is done!

Programming the Command Center

Using a raspberry pi and python create an IFTTT Account after downloading the app onto the phone whose functionality you want to activate based on the knocks. Next connect a "Maker Account" to your IFTTT. You will be provided with a URL of the following form (it might be easy to continue these steps on a web browser):

https://maker.ifttt.com/trigger/{event}/with/key/{...

The token should show up on your IFTTT account. Now setup an event with a trigger like 12, or 23 (the number received based on the location of the unKnocki and the number of knocks). After this upload the following code to your raspberry pi or any laptop, and you're good to go! The code below contains functionality to send a message through telegram as well, because IFTTT doesn't support telegram. This part of the code is optional, only the Python requests to the URL trigger the IFTTT actions.

IMPORTANT: Be sure to install all relevant libraries for the python code. Also download an Arduino IDE on the Raspberry Pi/ Laptop and find the name of the port to which the Arduino is connected. It should be of the form "/dev/cu.usbmodem641". Replace the port from your Arduino in the python code below and fire up the raspberry Pi/ Laptop after connecting the transmitter Arduino to it. Thats it! You can now trigger almost any event around the house thanks to the wide support IFTTT offers!

import telegram 

import serial
from time import gmtime, strftime
import requests

roodid = {telegram chat id};

bot = telegram.Bot(token='{telegram api token}')

ser = serial.Serial('/dev/cu.usbmodem641', 9600)

while True:
  	val =  int(ser.readline())

 	print val
  	if (val==12):
 		bot.sendMessage(chat_id=myid, text="Someone is at your door")
   
   	elif (val == 13):
   		r = requests.get('https://maker.ifttt.com/trigger/13/with/key/{token}')
   	elif val==24:
   		r = requests.get('https://maker.ifttt.com/trigger/23/with/key/{token}')

Miniaturization and Cost

Miniaturizing the transmitter circuit is just a matter of replacing the full size Arduino with an ATMega328P chip on a perfboard. This has the added benefit of being a much cheaper solution. The total cost of transmitter components is (all costs are from AliExpress/ Ebay)

  1. ATMega328P - $1.3
  2. Perfboard - $0.2
  3. 16MHz Crystal - $0.5
  4. 16uf ceramic capacitor - $0.5
  5. Male and female headers - $0.2
  6. Piezo buzzer - $0.3
  7. 28 Pin Socket - $0.2
  8. RF Transmitter/ Receiver Pair - $0.6

The total cost of receiver components is

  1. Arduino - $2 to $20 (the extremely cheap ones are the arduino clones which work reasonably well for this project)
  2. RF Receiver Transmitter pair - $0.6 (RF Receivers or transmitters can't be obtained alone)
  3. Small breadboard - $0.6
  4. Solid gauge wire - $0.8

The control center cost depends on what you have lying around. If you have an old laptop/ PC or are able to get an old one at a very low cost, then it drastically reduces the cost of the project. However to compare with the Knocki, we shall use the cheapest Raspberry Pi we can find as a comparison. A used Raspberry Pi 2 Model B is more than sufficient for our use and costs around $25 on Ebay. For real barebones usage, you can use the 5$ Raspberry Pi Zero and make an amazingly cheap device. Or you can use the $9 C.H.I.P.

Knocki (at Kickstarter Super-early bird price)

1 Unit : $69

2 Units: $138

3 Units: $207

unKnocki

1 Unit: Approximately $40 - $45

2 Units : Approximately $47-$52

3 Units: Approximately $54-$59

Evidently, the cost of adding an unKnocki is much cheaper because only components for the transmitter need to be bought. The receiver and command center are common for all the transmitters and are a one-time purchase.

We are not saying a DIY solution is necessarily better than the Knocki. For the average person who may not be interested in electronics, the Knocki is a convenient easy way to get started. We simply offer a much cheaper and more widely applicable solution than the Knocki, due to our integration with IFTTT.

For a better understanding of the various iterations this project went through, click here.