DIY Home Security Part 1 – Setup A Red5 RTMP Live Stream

The goal of this guide is setup an RTMP live stream from your home or office.  Once the stream is setup, I’m going to show you how to play your stream on a webpage or on your android phone.  It’s surprisingly simple if you have a basic knowledge of linux to install red5.  You can see an example of this work on the bar to the right.  I’ve set up a few features like ‘privacy mode’ and I’ll do my best to cover these in a later guide.  For now, get booted into your CentOS server and get ready to install and compile some packages! Click here to check out the full guide!

Arduino LCD HD44780 + LM335 Temperature Sensor

This was the next logical step in my home monitoring project.  I’ve simply added an LM335A temperature sensor to the breadboard and have the output being posted to the LCD every second.

 

First the drawing:

The next step was to write the code that reads the temperature on Analog Pin 0, then writes it the LCD.  This could not have been easier.

 

Code:

#include <LM335A.h>
#include <LiquidCrystal.h>
float raw;
 
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
 
LM335A InsideTemp(0); //pass the analog input pin number
void setup() {
  lcd.begin(16, 2);
}
 
void loop() {
  lcd.clear();
  //user must call ReadTemp before any valid temp data is available
  raw = analogRead(0);
  InsideTemp.ReadTemp();
  lcd.print(InsideTemp.Fahrenheit());
  lcd.print((char)223);
  lcd.print("F");
  lcd.setCursor(0, 1); // bottom left
  delay(1000);
}

Working project:

 

 

Things are coming along on the home monitor.  I’ll soon be using some multiplexers and 8bit shift registers to help reduce the number of pins used on the arduino.  Keep checking back for more updates!

Arduino LCD HD44780 Simple Tutorial

Connecting any LCD using the HD44780 standard to an arduino is extremely simple.  I’ve created a quick schematic showing how to connect the 16×2  HD44780 to an arduino.  I’ll be using this setup in my future projects, so this is simply for future reference.

 

Arduino to be sold at radio shack!

Big news broke today for home electronic enthusiasts.  Radio Shack is going to start caring Arduino products.  Surely we will be paying a premium for the convenience, but this is a good sign for those of us who enjoy tinkering at home.  There is a new wave of DIYers that are learning how easy it can be to automate simple tasks around the house and office.  Increasing the accessibility of Arduino should also increase the options of sensors and IC’s we see at our local stores as well.  This is great news, I can’t wait to see where this takes us.  Click Here to read the full blog post.

Arduino LM335 Temperature Sensor Tutorial

Getting started with the LM335 Temperature sensor can be a bit tricky.  I ran into some problems when I started getting incorrect data.  I googled around for the problem, and all of the schematics and drawings at the top of google were incorrect.  They either had a static resistor on the data pin, or they show the data pin on the arduino directly connected to the LM335 Temperature sensor’s data pin.

The trick to correctly calibrating the temperature sensor is to connect a 10k potentiometer to the data pin.  Once the potentiometer is wired in place, you can calibrate the LM335 to read the correct temperature.  The correct wiring of the LM335 can be seen below:

 

 

 

 

 

Once everything is wired up, I simply used the lm335a.h library written by greenrobotics.net.  This is a nice library, a quick test sketch can be seen below here:

// Example using the LM335A library for reading temperatures
// Created by Jonathan Merrill, February 20, 2010.
// http://www.greenrobotics.net
//  Released into the public domain.
 
#include 
 
LM335A InsideTemp(0); //pass the analog input pin number
void setup() {
Serial.begin(57600);
Serial.println("starting");
 
}
 
void loop() {
  delay(3000);
  //user must call ReadTemp before any valid temp data is available
  InsideTemp.ReadTemp();
  Serial.print("Fahrenheit: ");
  //functions to get the temperature in various unitsfs
  Serial.println(InsideTemp.Fahrenheit());
  Serial.print("Celsius: ");
  Serial.println(InsideTemp.Celsius());
  Serial.print("Kelvin: ");
  Serial.println(InsideTemp.Kelvin());
 
}

Once I get motived, I’ll be sending this temperature data from my home to my blog, here.  I’ll be sure to post more updates as they come.

Flot Example: Format data in Flot readable JSON

I recently started learning the flot library.  Unfortunately, there aren’t any good examples of how to format the data with JSON in a flot friendly manner.  Below is some basic code that should retrieve data from a database, format it and then JSON encode it. I’ve written the example mostly in psuedo-code, most beginners should be able to pick up the key points of the following example.

 

The script below simply returns JSON, you should create this script in a web accessible directory:

getDataforFlot.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
$mergedData = array();
 
//Get the first set of data you want to graph from the database
$databaseData1 = someFunctionToGetDataFromDatabase($id);
 
//loop through the first set of data and pull out the values we want, then format
foreach($databaseData1 as $r)
{
    $x = $r['x_value'];
    $y = $r['y_value'];
    $data1[] = array ($x, $y);
}
 
//send our data values to $mergedData, add in your custom label and color
$mergedData[] =  array('label' => "Data 1" , 'data' => $data1, 'color' => '#6bcadb');
 
//Get the second set of data you want to graph from the database
$databaseData2 = someFunctionToGetDataFromDatabase($id);
 
 
foreach($databaseData2 as $r)
{
    $x = $r['x_value'];
    $y = $r['y_value'];
    $data2[] = array ($x, $y);
}
 
//send our data values to $mergedData, add in your custom label and color
$mergedData[] = array('label' => "Data 2" , 'data' => $data2, 'color' => '#6db000');
 
 
//now we can JSON encode our data
echo json_encode($mergedData);
?>

Next, just put the following JQuery into your page to render the data using AJAX:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$(document).ready(function(){
 
    $.ajax({
                // usually, we'll just call the same URL, a script
                // connected to a database, but in this case we only
                // have static example files so we need to modify the
                // URL
                url: "/getDataforFlot.php",
                method: 'GET',
                dataType: 'json',
                success: onOutboundReceived
            });
 
    function onOutboundReceived(series) {
        var length = series.length;
        var finalData = series;
        var options = {
            lines: { show: true },
            points: { show: true, hoverable:true },
            grid: { hoverable: true, clickable: true }
        };
        $.plot($("#YOUR-DIV-ID-HERE), finalData, options);
    }
});

Ninja Bread Men!!

I made these ninja bread men.  Being the coolest cookies I’ve ever seen, I had to post them.  Attack of the ninja bread men!!!

You can buy your own set of ninja bread men here

Reddit Secret Santa 2010

It looks like I’m three for three with these reddit gift exchanges.  This year I think was the best year so far.

I came home today from a hard days work to find a bomb waiting for me in the mail!

Fortunately, this bomb is a little softer and a little less explosive.

I also received a RED team parking permit!! This will look great next to my linux jesus shark.
This year I bought my secret santee a thinkgeek wool hat that says “Geek”.   I read my santees post on redditgifts and he seems to be very happy with it.  He’s a long distance runner in New Jersey who apparently needed a new hat anyway.
This has been a great holiday season so far.  Happy Holidays.

Got hacked, back up

It finally happened, my server was hacked.  The attacker was on a path of destruction and simply destroyed all of my data and locked me out of the server.  Fortunately, I keep good backups.  Unfortunately, I’ve been busy with a new job so I haven’t been able to restore any of it until today

Notes:

I believe this attack was initiated by a former co-worker, as the timing for the intrusion lines up directly with my leaving my old position.  This leads me to believe that the server/sites were not necessarily mis-configured or vulnerable, rather a former manager / co-worker who knew some of my common passwords simply logged in and destroyed my data.

It also could have been a Steam phisher that I upset a few months back.  He messaged me a link to his phishing page saying that I would receive a free game for logging in.  I immediately knew what was going on and started taunting the phisher and then ddosed his phishing page.  The attacker very well could be related.

However, this is no execuse.  I broke one of the basic first rules of web security, use different passwords for everything.  Now, all services and users have their own unique password….so far….so good.

Dump Asterisk Realtime Voicemail users into Voicemail.conf

While I’ve been lazy about updating my site, I have not been lazy with writing new scripts and coming up with ideas to write about.

The first in the set that I’m going to make public is a script to dump your Asterisk Realtime Voicemail database users into a flat voicemail.conf file. I used this technique while troubleshooting to revert back to the standard setup while I was working on the realtime config.

#!/bin/bash
function get_mailbox {
 
   mailbox=$( mysql -u dbuser --password=dbpass asterisk -e "select mailbox from voicemail_users where uniqueid = '$i'")
   mailbox=`echo $mailbox | awk '{print $2}'`
 
}
 
function get_password {
 
    password=$(mysql -u dbuser --password=dbpass asterisk -e "select password from voicemail_users where uniqueid = '$i'")
    password=`echo $password | awk '{print $2}'`
 
}
 
function get_fullname {
 
    name=$(mysql -u dbuser --password=dbpass asterisk -e "select fullname from voicemail_users where uniqueid = '$i'")
    name=`echo $name | awk '{print $2}'`
 
}
 
function get_email {
 
    email=$(mysql -u dbuser --password=dbpass asterisk -e "select email from voicemail_users where uniqueid = '$i'")
    email=`echo $email | awk '{print $2}'`
 
}
 
function write_file {
 
    echo "$mailbox => $password,$name,$email,,attach=yes|saycid=no|envelope=no|delete=no" >> /root/test_dump.txt
 
}
 
for (( i=1; i<=151; i++))
do
get_mailbox
get_password
get_fullname
get_email
write_file
done
Unfortunately you don't have Adobe Flash-Player.... Klicken Sie hier fü kostenlosen Adobe Flash-Player.