Monday, March 2, 2015

Using Arduino to open and close gate at home

I've had the annoying experience of rushing from home to work, and only to have the security guard in my housing area to call me and tell me that I've left my auto gate open. My suspicion is that while I have already pressed the button on my remote control to close the gate, the gate's wheel could have gotten stuck due to a pebble in the tracks which causes the closing to stop, and the gate re-opening again. Given that my office is at least 45km away from home, going back all the way to just close it is not an option for me. I normally just hope no one walks into my home and steal my shoes that I leave outside my porch.

I already have IP cameras installed at various locations in my home. One of them is pointed at the front gate, which allows me to see whether if the gate is open or close. This is useful for times when I'm driving halfway, and then having the thought of wondering whether I have closed the gate or not.
But seeing the gate open 40km away is no help as well. So I decided to blow off the dust from my knock-off Arduino Duemilanove and put it to some good use.

My gate is controlled via a 315MHz (I think) RF keychain remote control. I know there are options where I could just buy a multifunctional RF Transmitter, but I wanted to go on the cheap, and also, I needed to solve this problem fast. These remotes are relatively cheap, and I keep a spare just in case I lose the one I normally carry. You can get these remotes clone for about RM50 - RM100, depending on the style and quality of the remote.

My remote runs on 12v battery. Getting this to work with the Arduino (as I have learned painfully) requires the use of other components (as Arduino tends to run 5V). Also, the button on the remote as I've found out is a pull-up, meaning, the voltage across the button is constantly on 12V, and when you depress the button, it goes to 0V and that's when the RF signal is sent out. I've tried using the digitalWrite and analogWrite function to see if I can short the button via 2 pins on the Arduino, but to no avail.

After figuring which of the 4 pins of the button is required, I soldered the 2 wires from the 2 pins. In case you don't know, this is the bottom side of the remote. The button is on the other side.
Good thing I found couple of reference on the internet of people who were trying to do the same thing. I will put those links later when I find them again. The proper way to do this is to use an NPN transistor, in which case I used the 2N2222 923 for this. There are examples of people using a 12V relay, but given that the remote i'm using runs on a very low current, the relay is pretty much an overkill.

Before I move on, I must give the disclaimer that I have pretty much zero background in electronics. What I mean is that while I'm interested in electronics, my theory of how transistors works is pretty much useless.

Here's the remote (the case removed) sitting on an Arduino breadboard shield. This makes it easier to wire everything up.

OK, moving on. The 2N2222 923 has 3 legs. The middle one is known as the base, and that's the one you will want to connect to the arduino digital pin (i used pin 2 for this). The other 2 legs of the transistor is connected to 2 pins of the remote button. Polarity matters in this case. I can't tell for sure which goes to which, however, I noticed that if I have the polarity reversed, the pins will short and the my remote button (which has a led indicator) will light up. So all I need to do is reversed it. Then that leaves the ground cable which you will connect from the arduino ground pin (look for GND), and you need to connect that to pin 1 of the transistor (if the flat side of the transistor is facing you, then pin 1 is the one on the far left).



Here's the Arduino sketch which I use:

void setup()
{
  digitalWrite(2, HIGH);   // sets the LED on
  delay(1000);                  // waits for a second
  digitalWrite(2, LOW);    // sets the LED off
  delay(1000);                  // waits for a second
}

void loop()
{
}


I know this is extremely lazy, as I have to upload the sketch everytime I want to open or close the gate. But this is just a conceptual test. Eventually, I guess you could hook this up to a webservice and have the gate control via an Android or iOS app.

Lastly, if case you're wondering how I'm going to control this remotely, I have VNC installed on a desktop sitting in my home, and the Arduino, along with the hooked up remote control connected to it. All I need to do is just to remote home, and upload the sketch to open or close the gate.

Nifty eh? Given all this done in less than 2 hours.


Tuesday, May 14, 2013

Previewing Office attachments in Microsoft Outlook 2013

If you run into this issue when you're trying to preview Office files (xlsx, pptx, docx) in Outlook 2013, and see this message instead:

.. this could be due to a DCOM setting issue. To fix it, follow this steps:
  1. Open Control Panel
  2. Open Administrative Tools
  3. Open Component Services and expand the tree under Console Root to Computers > My Computer.
  4. Right-click on My Computer and select Properties.
  5. Select the Default Properties tab and set the following values:
    1. Default Authentication Level: Connect
    2. Default Impersonation Level: Identify.
Restart Outlook 2013 and the previewer should be fixed then.

Source: http://www.thewindowsclub.com/cannot-open-word-excel-powerpoint-files-or-email-attachments-in-office-2010






Wednesday, May 8, 2013

Fixing the PDF preview issue in Outlook

I was facing this problem where every time I tried previewing a PDF file in Outlook 2013, I get the message
"This file cannot be previewed because of an error with the following previewer:
PDF Preview Handler for Vista
To open this file in its own program, double-click it. "


I tried googling several sites and most of them said to try this fix: http://www.howtogeek.com/howto/7682/how-to-fix-pdf-previews-in-outlook-or-explorer-on-64-bit-windows/

I tried it  (both the manual registry fix, and the exe file which did the registry fix) but unfortunately, it didn't solve the problem for me. Then I saw another site that said upgrading the Adobe Reader to the latest version would fix it. I was using Adobe Reader v10, and there was a version XI available. When I've done with upgrade, I then got this message in Outlook:

"This file cannot be previewed because there is no previewer installed for it."

 I then tried checking the preview add-ins in Outlook via File>Options>Trust Center>Trust Center Settings >Attachment Handling>Attachment and Document Previewers and couldn't find any PDF Preview Handler value there.

Further searching on the web led me to the only working solution I can find so far: http://social.technet.microsoft.com/Forums/en-US/outlook/thread/203d7369-b11c-4b9c-a90c-729f1776bd65

The fix is simply to reset the preview option for Outlook via modifying the registry via regedit. All you need to do is change in the registry the key HKCU\Software\Microsoft\Office\Previewers\pdf\PONTState value's data to 0 to re-enable the "always warn before previewing" for pdf attachments.

 I finally managed to preview PDF in Outlook. FYI, I'm using Windows 7 x64 with Office 2013.

Wednesday, April 24, 2013

"Failed To Create Profile" Error when setting up on Google Apps Sync for Microsoft Outlook

Should you encounter this issue, try this:

1. Go to control panel
2. Select Mail
3. Select "Show Profiles"
4. Should you see any existing google mail profiles, select it, and click "remove".
5. Hit OK.

Then try setting up on Google Apps Sync for Microsoft Outlook.

I've tried this on Microsoft Windows 7 - 64 bit, running Microsoft Outlook 2013 - 64 bit as well.

Good luck!

Wednesday, April 17, 2013

MakerBot: Replicator 2

If you're into 3D modelling, but can't afford to get yourself a super-expensive 3D printer, then the new MakerBot: Replicator 2 may be an option for you. At USD$2,199, this is still much cheaper than the commercial 3D printers out there. The Replicator 2 uses heat extrusion method, as opposed to the more common STL (Stereolitography) method, which is much cheaper in the long run when producing your models. Previous extrusion 3D printers tend to produce very coarse results which needed post production work to smooth out the rough edges, however this new model boast a 100 micron resolution, where each layer is as thin as a piece of paper!

While the price tag could still be out of reach for most of us, expect it to drop as the demand for these printers increase. Regardless, if you already plan to buy it, check out the following link for more info: http://store.makerbot.com/replicator2.html

Monday, April 1, 2013

Yahoo! Mail on Outlook 2013

Do you want to get Yahoo! Mail on Outlook for free? Try this!

  1. Launch your Outlook (I'm using 2013 for this example, but previous versions should work as well).
  2. Select the "FILE" tab on top left corner and select "Account and Social Network Settings" under Account Information.
  3. Click on Account Settings, and in the dropdown, select "Account Settings".
  4. In the dialog window, under the E-mail tab, select New.
  5. Under Choose Service, Select "Email Account". Then click Next.
  6. Select "POP or IMAP", and hit Next.
  7. Under the POP and IMAP Account Settings, fill in your name and email address.
  8. For Server Information, fill in the following:
    1. Account Type: IMAP
    2. Incoming mail server: imap-ssl.mail.yahoo.com
    3. Outgoing mail server (SMTP): smtp.mail.yahoo.com
  9. Logon Information:
    1. User name: <youryahoologin>@yahoo.com
    2. Password: your yahoo password
    3. Check Remember Password
  10. Leave "Require logon using Secure Password Authentication (SPA)" unchecked.
  11. Hit More Settings:
    1. Under the "Outgoing Server" tab:
      1. Check "My outgoing server (SMTP) requires authentication
      2. Select "Log on using"
        1. User Name: <youryahologin>@yahoo.com
        2. Password: your yahoo password
        3. Check Remember Password
    2. Under Advanced:
      1. Under Server Port Numbers:
        1. Incoming server (IMAP): 143
        2. Leave "Use the following type of encrypted connection:" as "None" (this can help to prevent certificate issues, which can be extremely annoying).
        3. Outgoing server (SMTP): 465
        4. Select "Use the following type of encrypted connect:" as "SSL".
    3. Leave the rest as is.
  12.  Hit OK to close the dialog and return back to the settings windows.
  13. Hit Next and you should be done!
It should take a while to import all your mail, especially if you have lots of it. Your folders should also appear.

Hopefully, the settings would work for you. Let me know how it goes in the comments!

Wednesday, March 27, 2013

Getting GMail on Outlook 2013

Google Apps Sync for Outlook currently only supports up to Outlook 2010. If you're using Outlook 2013, then you're out of luck of getting your Gmail in with Outlook. However, the good news is that there's a workaround, and though it's bit tedious, the end result is worth it.

First off, if you're upgrading from Outlook 2010, and you already have your GMail setup in your Outlook 2010, then it's much simpler to pull this off. However, just take note that you need to have the right platform of the Google Apps Sync tool to work. If you're currently running Microsoft Office 32bit, that would also mean that the Google Apps Sync tool you have is also on 32 bit. Hence, when you upgrade to Office 2013, it would be best if you upgraded to a 32 bit version of the Office suite as well. The same would go if you're on 64 bit. Just upgrade to the same platform to avoid complications.

Once you're done with Office upgrade, you would notice that if you tried to launch your Outlook, you will get some error message and your email won't sync. Fret not, just try this trick:

Make sure your Outlook is closed. Then using Windows Explorer, head towards this directory:
C:\Program Files\Google\Google Apps Sync\ and locate these 2 files:


gsync32.dll 
unifiedlogin.dll   

Copy both these files and head over to C:\Program Files\Microsoft Office\Office15\ and paste them in.

Fire up your Outlook and it should work again.

Secondly, if you're on fresh PC with no Microsoft Office installed, you will need to find a copy of Microsoft Office 2010 and install with that first. (A trial version will work as well). Make sure you take note of the platform again (32 bit or 64 bit). If you're planning to use 64 bit version of the Office 2013, then make sure you install the 64 bit version of Office 2010. Once you're done, download the Google Apps Sync (again, align the platform version with the office version). Install it, and follow the instructions to setup your Google Account. Make sure your profile have been successfully created. After that, follow the instruction above to upgrade your Office to 2013 version. 

If you already have Microsoft Office 2013 installed without the Google Apps Sync setup, best is that you uninstall the 2013 and install 2010 first, setup the Google Apps Sync, then upgrade. I've tried without much success to get the Google Apps Sync to work without doing the steps I did above, and would best save you much time of having to go thru the learnings that I went thru.

Just FYI, if you tried setting up Google Apps Sync on Outlook 2013, you may encounter some of these issues:
1. After downloading the Google Apps Sync tool, and installing it, you will get this error:Your Microsoft Outlook (r) installation requires a 64-bit version of Google Apps Sync to work properly.  Please download and install the 64-bit version of Google Apps Sync.
For some reason, when you're at https://tools.google.com/dlpage/gappssync, it will download the wrong version if you have Office 2013 installed. I then tried to get the installer package directly from the source here:
Download 32-bit enterprise_gsync.msi (Outlook 2003, 2007, 2010 32-bit edition)
Download 64-bit enterprise gsync.msi (Outlook 2010 64-bit edition)

2. Installing the downloaded package is straight forward, however, when you try to set up your Google Account, you will encounter message : "Failed to create profile".
 I've not found a way to get around this error, and again, the only remedy that I could find was to do the above. 

Hopefully you will find this useful and helpful.