Installing Android Studio

In one of my older posts, Getting started with the Android SDK, I made a mention of Android Studio and how it would be replacing the Eclipse ADT plugin. Well sometime since then, it looks like the switchover has indeed happened and its time for me to ditch Eclipse take a leap into Android Studio.

Downloading Android Studio

Now that there is only one option to choose from, Google has streamlined the download process significantly since my last post.

android-studio-download

Simply head over to the Android Developer page, and click Download Android Studio. Do your usual reading of the license agreement (you all do that, right?), accept, and you should be downloading all 800MB of Android Studio goodness!

Installing Android Studio

Like I said, they’ve streamlined this process quite significantly. No more extracting, no more renaming folders, and no more copying files around into different folders. Its a single executable file. Double click, and BAM, you’re on your way! The installer is supposed to walk you through downloading JDK now as well, which was not the case before. I don’t have any experience on that part though… I already had JDK from the previous installation of Eclipse and ADT.

android-studio-setup

You’ll want to make sure you install all the components (Android Studio, Android SDK, and Android Virtual Device. Follow the rest of the prompts and you’ll be on your way.

android-studio-completed

Opening Android Studio for the first time

When you open Android Studio for the first time, there is additional configuration that it takes you through. The first will be whether or not you want to import existing Android Studio projects. If you’re just getting started then likely you’ll have nothing to import.

android-studio-downloading-components

Next it will start to download the latest version of the SDK Tools, unzipping them, along with any additional components needed. The nice thing about this again was that its all streamlined… once it started going, it required little to no interaction from me… sweet!

Welcome to Android Studio

welcome-to-android-studio

That’s it! Start a new project, or import projects from your old Eclipse workspace. Hopefully I will make some time to play around with it soon and post on my findings!

Temperature Sensing with DHT11 on Arduino

Ahhh temperature sensing, something so simple yet can be integrated into so many different projects. How about a temperature controlled RGB LED? Or perhaps an Arduino controlled thermostat? Heck, even a full blown weather station! Your imagination is the limit.

There are a few different choices when it comes to temperature sensing such as a completely water proof analog temperature probe to digital sensors. I will be focusing on the DHT11 which is a very affordable (~$1) digital temperature and humidity sensor. Its good for sensing 20% to 80% humidity within 5% accuracy, and 0c to 50c within 2% accuracy, which is more than enough for any indoor projects. If you want something a little more capable and accurate, the DHT22 is another option for digital sensors.

dht11-temperature-sensing

 

The DHT11 has 4 pins in total as seen above (with 0.1″ spacing – perfect for breadboards). VCC, a Data pin, and Ground. Pin 3 is not used.

temperature-sensing-arduino

Wiring it up is fairly straight forward. Start by connecting VCC on the DHT11 to VCC on your Arduino, and Ground to GND. Next connect the DHT11 data pin to pin 10 on the Arduino. Lastly, we need a 10k (Brown Black Orange) resistor in parallel to the DHT11 connected between the VCC and Data pins. This is our pull up resistor.

Now its just a matter of uploading our sketch and checking the output in the serial monitor

Now, with a little heavy breathing on the sensor, we should be able to see it change every few seconds (specifically the humidity… its a little harder to breath temperature changes), but they both will work!

temperature-sensing-serial-console

Serial console with Arduino Pro Mini

As I was doing some debugging in the serial console with my Arduino Uno R3, something occurred to me… The serial console is absolutely invaluable for debugging, yet in my first Arduino post (Getting started with Arduino) I did not even mention it at all.

If you’re using the Arduino Uno or Duemilanove for example, the serial console is fairly straight forward as you just use the same USB cable you use to program with. These boards differ from the Pro Mini as they already have a Serial to USB converter on board.

However, when working with the much more affordable Pro Mini, there is no built in Serial to USB, so things get a little more interesting.

First things first, lets create a simple sketch that will setup the serial console with Arduino, and send a message to the serial console

Next, you’ll need to get your hands on a couple of things.

serial-console-with-arduino

  • USB to TTL Adapter
  • Set of 4 female to female “dupont” cables

Both of these can be found on eBay for dirt cheap if you don’t already have them.

The Arduino as well as the USB adapter should have their pin out silk screened on to their boards, and should look like this

arduino-to-usbttl-pinoutDepending on which Pro Mini you have, you’ll want to wire them together using the correct voltage (3.3v or 5.0v are both available on the USB TTL adapter). In my case I have a 5v Arduino Pro Mini, so I will tie VCC to 5.0v, and GND to GND. If you have the 3.3v version of the Pro Mini, then you need to tie VCC with 3.3v instead. The data wires need to “cross-over”, so the RX connects to TX, and TX to RX. This way, when the Arduino is transmitting the USB TTL adapter is receiving, and vise versa. All said and done, you should have something that looks like this.

arduino-to-usbttl-wiredup

Still with me? Awesome! Now plug everything in and upload your sketch to your Arduino using your USBasp programmer, (hopefully you’re using Codebender) select your com port/speed and click “Open Serial Monitor”. With any amount of luck, you should see some text printing in your serial console!

serial-console-with-arduino-output

 

Build your own Arduino starter kit

I have a friend that keeps asking me about micro controllers and costs associated with getting started. He has no prior programming experience, and doesn’t own a soldering iron. By the sounds of it, he’s a little on the fence (rightfully so) and isn’t sure whether he should try it or not. Totally understandable when starting with something new. So I figured hey, lets break it all down and see just what it would take to build your own Arduino starter kit!

Before I get into the actual costs I just want to point out that while previous programming experience is handy when it comes to Arduino, its not at all necessary! The Arduino community is literally huge (250k+ members worldwide, 2 million posts) which means finding a sketch and wiring examples that do exactly what you want it to do (at least when you are first getting started) is going to be very easy. My recommendation when starting out is to concentrate on small projects with the thousands of ready made examples (blinking, fading, controlling, etc.). This will allow you to familiarize yourself with the platform (uploading, debugging, etc.). Once you have a solid base is when the real fun begins and you can let your imagination run wild!

Its also important to remember that Rome was not built in a day. You will at some point be stuck in a position where you have to get your hands dirty and start customizing the code yourself. And while I am by no means an expert on the subject, I consider myself a problem solver so by all means leave your messages or questions in the comments and I will definitely try to help out as much as possible!

Build your own Arduino starter kit costs

This list is just my personal recommendation. Feel free to customize it, or add/remove as you wish (or leave suggestions in the comments). My goal is to keep the kit under $20CAD ($15.87USD… man, our dollar sucks right now), so my prices will be based mostly off eBay. You of course can purchase from wherever you like, but prices will vary obviously.

Arduino Pro Mini ($2.77)
This is the Arduino board itself, the heart of all your projects. It has the atmega328 chip, comes in 5v (16Mhz) or 3.3v (8Mhz) versions, and at this price its almost cheaper than buying the atmega328 chip by itself!

USBasp Programmer ($2.24)
The Arduino Pro Mini doesn’t contain on board USB circuitry, so we need an external programmer to upload the sketches.

USB to TTL Adapter ($1.03)
Without on board USB, we also need something to debug through serial, so a USB to TTL adapter becomes necessary for debugging and communicating through serial

Assorted LED Pack – 100pcs ($1.25)
No project would be complete without some sort of flashing lights. You can find packs of 100 assorted colors of 3mm LEDs for cheap, usually containing 20 of each color (Red, Green, Blue, Yellow, and white)

Assorted Resistor Pack – 600pcs ($3.62)
Resistors are tricky… you never know what values you will need until you know what voltage you’re working with and what the limitations are of the devices you plan on using them with. Best bang for your buck is to buy a kit of assorted. You can find kits that contain 20 resistors of 30 different values.

Male 40 pin Headers – 10pcs ($0.99)
They come in handy making your own “adapters”, for example an easy to use programmer cable.  Some devices need headers soldered on before you can use them as well, so its safe to grab a couple of these since you’ll need them sooner or later.

Mini Breadboard ($0.99)
You’ll need somewhere to start wiring up your projects. Since the Arduino Pro Mini is so tiny, a mini breadboard will usually cut it for small beginner projects, but it will only cut it for so long so a full sized breadboard should be on your “not so beginners” parts list.

Breadboard Wires  (40pcs M to M – $1.74, 40pcs F to F $1.42)
You could have every part in the world, but unless you have wires to connect everything together you wont make it very far. Male to Male are the more important ones, but Female to Female have their uses as well.

PN2222A Switching Transistors – 10pcs ($1.25)
The Arduinos do have current limitations. About 20mA per output, and 200mA total. If you draw too much current from an output pin, or from all the pins combined, you risk blowing up the whole board. Transistors (and MOSFETS) will let you draw higher amounts of current directly from a power supply while only using a small amount of current from an output pin to control it. The PN2222A is a general purpose transistor that can handle up to 40v and 600mA, so its a good place to start for low current applications (eg. LEDs).

Character LCD HD44780 ($2.51)
An LCD is cool to start learning with. They are super easy to wire up, and I mean come on… its a friggin’ LCD! It doesn’t hurt to have one in your starter kit for their affordable price.

And there you have it, it’s simply that easy to build your own Arduino starter kit – a very basic starter kit – that will have you flashing or fading LEDs, building very basic LED cubes, and writing to LCD screens in no time. For a grand total of $19.81, you’ve got nothing to loose!! Sweet!

PWM control with Arduino

Just a real quick snippet today. If you followed along my first Arduino post (Getting started with Arduino) then you should already have a simple blinking LED on Pin 10 (or pin of your choice). I wanted to take that just a step further and use PWM (Pulse Width Modulation) for a fade in / fade out effect.

PWM uses a pulsing digital signal (high/low) to simulate the effect of an analog signal. If you really want to learn the technical details of PWM, head on over to the Arduino page – http://arduino.cc/en/Tutorial/PWM

arduino-blink-wiringThe best part, no hardware changes! Simply upload this new sketch with the breadboard layout in the original post (below, in case you missed it)

Tracking Down Unknown Network Devices

This is going to be a short and sweet post, but it touches on something I had to deal with just the other day.

I was going through my router, which I do on a regular basis, to check what unknown network devices were showing up in the network list. In my case I usually do this for two reasons. The first is to name all my devices in the router itself and typically assign it a static IP. The second is for pure security. I want to know what devices are on my network, and who the device belongs to.

The particular unknown network device that I noticed, and could not identify was named “GainSpand48cb6“. I usually take pride in naming my devices, so GainSpan was not something that I had setup. I made the assumption that the d48cb6 was the last 6 digits in the mac address, which I confirmed by looking at the device info more deeply.

unknown network device gainspand

 

Now, the second issue was that the device was offline, so I could not ping it, or do any traffic sniffing on it to see what it was doing. The next step was to just start searching. I started with a reverse mac address look-up, which tells me the mac is registered to a company called GainSpan Corp. Sometimes a simple mac look up will tell you everything you need to know, but when I follow the trail further GainSpan is just the company that makes the wifi radio in the device, darn… had to dig deeper.

As I kept digging, I eventually found something that caught my eye… a post containing Fitbit in the title.

*facepalm*

fitbit-aria-gainspan

The culprit turned out to be my Fitbit Aria scale, which DOES connect over wifi, but for some reason it did not occur to me.

Oh well, at least I know for next time and can share with everyone else who might have one of these scales, that the hostname shows up as GainSpan in your network device list.

Getting started with Arduino

Well its been so beautiful outside here lately *sarcasm alert* (averaging -40 degrees Celsius…) I decided now might be a good time to dust off my Arduino boards.

arduino-logo

First off, if you have any experience with Arduino micro controllers, this post probably wont be for you. Its been many… many years since I have done any work with them (ahem… high school). I need to build my own skill set back up, so this is a recap for myself, and for those who might be just starting out (or looking to start out) with Arduino boards.

Second off, if you’ve ever used or are still using the Arduino IDE… scrap that. I came across a web app: Codebender which is basically a much better version of the IDE entirely through your browser. It features a fancy editor with syntax highlighting, much better error reporting (in my opinion), a cloud based compiler, and a built in serial monitor. It has all the features of the Arduino IDE, but adds loads more.

codebender

I have several different types of Arduino boards (Pro Mini, Uno R3, Duemilanove, and some mini knock-offs that don’t work worth crap – dswy_robot), but I will probably spend most of my time with the Pro Minis. They are amazingly cheap so if you blow up a board, you’re only out a couple dollars instead of $20-$30…sweet!

arduin-pro-miniWhat You’ll Need

  • Arduino Pro Mini (or Arduino of your choice)
  • USBasp programmer (assuming you’re using the Pro Mini)
  • An LED
  • A resistor, 470 ohm is fairly safe when working with LEDs
  • Male header, or bread board wires

Getting Your Programmer Ready

Before we jump into it, we need to make a cable to connect the Arduino up to the USBasp programmer. Your programmer should have come with a ribbon cable, so its just a matter of connecting those pins up to the proper pins on the Arduino with some breadboard wires. You can use bread board wires to go from the 10 pin connector to your breadboard, or you can cut one end off completely and solder it to a header. It takes a few minutes longer to make the cable, but trust me, you’ll save time in the long run when you need to switch breadboards

usbasp-to-arduinopromini

Make sure you are oriented correctly, Pin 1 on your ribbon cable is the blue wire in the image above. When you’re all done, ideally you want to end up with a cable like this:

homemade-usbasp-cable

 

Make It Blinky Blink!

Alright, so lets get our LED wired up

arduino-blink-wiringVery simple. the anode (longer wire) of the LED connects to pin 10 on the Arduino, and the cathode (shorter wire, typically with flat side on LED) connects up to our resistor. Depending on your LED you can use a smaller resistor, I was using a very bright blue LED so I decided to go with a 470 ohm to dim a down just a touch.

Next we need to upload the sketch to the Arduino using the USBasp, so plug everything in, connect the programmer up to your computer, head over to Codebender, and upload this sketch.

With any amount of luck, you should end up with an LED that blinks every half a second

arduino-blinking-led

Break into Lynx Touch L5100 installer programming

There comes a time in every security professionals career where either an installer code was lost, changed, locked out, or forgotten.

An installer code is a 4 digit code that, when entered into the keypad, will allow you into the programming menus of an alarm panel.

Some panels however have back doors hidden in them that allow access to the installer menu without ever knowing the code. Take the Honeywell Lynx Touch L5100 for example.

honeywell-l5100-sia-lynx-touch-wireless-alarm-control-panel

This beauty is actually one of my favorite alarm panels to work with (only being beaten by the Lynx Touch L7000 of course) combining a whole hefty set of features such as Z-Wave, Wifi, and GSM into a small easy to install package.

First things first, if you are an end user and attempting to get into installer programming, you’re on your own… I take zero responsibility for anything you may or may not mess up, as well as any headaches you cause yourself or your dealer.

Second disclaimer, if your a monitored customer (eg. you pay a monthly fee to have someone call and alert you if the alarm goes off) call your monitoring station first to put your account on test, if you don’t know who the monitoring station is then call your dealer. Putting an account on test will prevent a false dispatch if anything gets messed up in programming.

Okay now for the fun stuff!

Start by powering down the Lynx Touch L5100 completely. This means both from the power outlet and the battery backup. Leave it powered down for a few seconds, then plug power back in (don’t need the battery right now, just remember to hook it back up later to prevent system troubles).

During the initial power up, when the screen displays “SYSTEM STANDBY!”, press and hold the UNLOCK key until the panel is completely booted up. You should know when its finished booting as it will display the main screen along with “System Ready”.

Once system is ready, release and press the UNLOCK key a second time (do not press and hold the second time). This will display the keypad.

Press the CLEAR button on the screen, you should see a blue bar underneath “Enter Code”.

Enter “00” on the on screen keypad. This will get you into installer programming (where you can subsequently change the installer code, or any other settings that are usually locked down).

AVG Firewall blocking virtual machine

Quick tip for those of you using AVG Firewall. I ran into an issue where, after installing AVG, my VMWare virtual machine would not longer connect to the internet. Windows still showed a connection and I could still ping (both by IP and domain names), but when I open a browser to load a web page, nothing happened.

At first I didn’t realize it was AVG that was causing the issue (it’s been a while since I last used my VM so I didnt make the connection right away). But some simple troubleshooting narrowed it down (set firewall to “Allow All“) and boom, internet started working right away.

Once I knew AVG Firewall was blocking the virtual machine, I figured it would be as simple as adding an exception in the firewall, but that didn’t work either.

Turns out the fix was even easier than adding an exception (although its slightly hidden).

First open AVG and click on Firewall.

avg-firewall

The in the bottom right hand corner, click the gear icon to access the firewall settings. In the next window that pops up, click Expert Mode.

avg-expertmode

In Expert Mode, click Advanced on the right. Put a check in the box that says “Allow any traffic from/to virtual machines supported by firewall“. Apply. And you should be all set!

avg-allowvirtualmachines

Granted, I don’t know exactly which VM Hosts are supported by this option, but I can vouch that it works with VMWare products!

Disable Directory Listing on apache2

As some of you may (or may not) know, by default apache2 allows something called “Directory Listing”. Essentially what this means is that when you visit your web server, if you browse to a directory within your www folder that does not contain an index page (index.php, index.htm, index.html, etc.), apache2 will actually spit out (or list) the entire contents of that folder. This should be a concern for anyone running a production server, and unless there is a specific need for directory listing its always a good idea to disable it. There is tonnes of different opinions on whether or not its a security issue to leave it enabled, and to this I have to say to each their own. Personally I feel it is a security risk, but at best disabling it is simply security by obscurity.

Depending on your hosting environment, there are a couple ways to disable directory listing.

Disable via .htaccess

While not my favorite method, you can disable directory listing through your .htaccess file if your web host allows server overrides. This is simple enough, simply add this to your .htaccess:

 Disable via server configuration

This is my preferred method because its system wide, which comes in handy if you have multiple vhosts, however for this you need access to the server configuration files. I always run Debian for my setups, but this also applies if you are using a Windows machine to host your apache2 server as well (location of the config files will obviously vary). If you arent sure whether you have access or not, then chances are you do not. Rarely do shared hosting plans allow access to this sort of stuff, and if you are running your own server or VPS then generally you would know you have access either physically, through SSH, or even RDP.

The specific file we are after is apache2.conf or httpd.conf depending on your version of apache2.

On Debian, this file (by default) is usually located at /etc/apache2/apache2.conf. On Windows, if you are using WAMPServer then it should be located at C:\wamp\bin\apache\apache2\conf\httpd.conf. You may need to do some searching to find the specific file, but rest assured, if you are using apache2 then it does exist somewhere.

Once in the conf file, look for the line that looks something like this:

The specific option in that line we want to disable is “Indexes“, so simply remove that from the line completely and reload apache2 – (Debian – sudo service apache2 reload, Windows (WAMP) – Click Wamp Icon > Restart All Services).

And there you have it, no more worrying about people snooping through your directory listings.