Saturday, March 4, 2017

Changing the halogen headlights to xenon - Night and Day !



Why ?

  •  Factory installed low beam bulbs in headlights were awful, tried changing better bulbs from auto zone and other places, but in the end they were still halogen
  • Little bit spare time on weekends and creative juices...

Precautions & Needed Items

  •  Remove your apple watch before working
  • Have a 6 pack of beer handy
  • Make sure you have a helper (I needed someone to use a flashlight, as I don't have a good work light)
  • HID Kit (there are multiple ones on amazon and ebay). 
    • I bought a Kensun kit with 6K intensity  (mainly because they were very helpful in determining what I needed and whether it will work in my vehicle or not...)
    • I also bought a warning canceller kit to go along with the HID kit ('cos I was installing it in a mercedez.... )
    • I also bought a 1 inch drill bit (as I knew that i'll have to drill a hole in the headlamp dust cover after talking to the Kensun folks)
  • Wear gloves
  • Finally, you need Patience !

Instructions

  • Pop out the dust cover 
  • Identify your low beam bulbs
  • Detach the 2 wires  to the bulb and pop the bulb out carefully.
  • Assemble the HID  xenon kit. 
    • The instructions with each kit are self explanatory and you basically have to connect the wires to each part in the harness and bulb.
    • I had to insert the  warning canceller cable in between
    • There are two separate assemblies for the driver's and passenger's side
  •  Drill a 1 inch hole in the dust cap
    • Before
    • After
  • Carefully, remove the bulb and insert into the dust cover assembly ( you just need the bulb and the wire connector to be inside the dust cover, all other cables will be outside the dust cover - towards the engine)
  • Carefully plug the bulb in, align it..
  • Test it... In my case, I had the polarities on the bulb reversed, as Mercedez  used a yellow and a brown for the wire colors, and I had to figure out that brown was negative and yellow was positive.. and Mercedez warning console warned me right away....


     


  • As you can see, I tested one side before first, See the huge night and day difference !
  • Snap the dust cover back in and repeat steps for the other side
  • Mount he HID harness and kit inside the engine, make sure you don't mount or attach to moving or heated parts.

Don't be afraid of trying this, in the worst case, you can always take it to the dealer, if you screw up !


Friday, March 3, 2017

Motion sensor integration with a Raspberry PI


  1. Why ?
    • Background
      • I am a cloud solutions architect, and work from home....
      • I have customized my work space to make it comfortable and productive
      • I have done various projects with the raspberry pi, and have a bunch of spare hardware lying around
    • I just wanted to do some cool automation in my work space using a raspberry pi
    • The end result seems pretty simple, but , as you'll see in the demo... I walk into my work space, and get greeted "Welcome to the study room" !
  2. How ?
    • Hardware needed
      • Raspberry PI model B 
      • Motion sensor detector
          • I used the HC-SR501, but you can use whatever you like... I'd bought five of these for $10 about six months ago on amazon.
      • 1p-1p connector wires (female to female)
        • You can buy 40 of these for a $. We just need 3 wires in this experiment.
      • USB keyboard
      • HDMI cable and monitor
      • Normal computer speakers
      • Ethernet connectivity to the PI
    • Now the fun stuff ..
      • Prepare the software load on the PI
        • I used the NOOBS build (2.2.0 at the time of the blog), and then installed the  full Raspbian (debian jessie) build on the PI
        • Connect your USB keyboard, LAN cable, HDMI cable, Audio out from the Raspberry PI to your peripherals
        • Just get your IP address when the PI boots up, and then you can ssh and scp to it... I won't bore you with the minor details
          • The default  login is pi/raspberry , and you will have to enable ssh login by either using the "sudo raspi-config" or use the UI to enable ssh logins
      • Wire the hardware

        • You can review the pin layouts of the sensor and the PI as provided above, and match the three wires i used (red, yellow, black) to get a better understanding.
        • Red wire
          • Sensor - Power in
          • PI - Pin 14 (DC out)
        • Yellow Wire
          • Sensor - Hi/Lo output (DC out)
          • PI- Pin 26 (GPIO 7)
        •  Black Wire
          • Sensor - Ground
          • PI  - Pin 16 (Ground)
        • ..
      • Program the PI
        • scp the mp3 or m4a audio file you want to play when motion is detected. I called mine study-room.m4a and tested out my audio connection to speakers with the following command
          • omxplayer -o local study-room.m4a
        • Create the following file (e.g. final.py) using vi or scp or whatever tool you like, and run it : "sudo python final.py" 
        • import RPi.GPIO as GPIOimport time
          import os

          GPIO.setmode(GPIO.BCM)
          PIR_PIN = 7
          GPIO.setup(PIR_PIN, GPIO.IN)

          def MOTION(PIR_PIN):
                         print 'Motion Detected!'
                         os.system("omxplayer -local study-room.m4a")

          print 'PIR Module Test (CTRL+C to exit)'
          time.sleep(2)
          print 'Ready'

          try:
             GPIO.add_event_detect(PIR_PIN, GPIO.RISING, callback=MOTION)
                         while 1:
                             time.sleep(100)
          except KeyboardInterrupt:
                         print ' Quit'
                         GPIO.cleanup()
      • Test it out
        • Trigger the motion sensor and watch the output on the screen and the audio on the speaker
        • Fine tune the motion sensor hardware , if needed
      •  Complete the setup
        • Added a wifi usb adapter and configured it, so that i can remove the wired lan cable
        • Added the command sudo python /home/pi/motion-test/final.py & to /etc/rc.local and modified the python code to provide the full path to the .m4a file - os.system("omxplayer -local \/home\/pi\/motion-test\/study-room.m4a")
    • Demo
    • What's next ?
      • Amazon Echo Dot integration...
      • Add more sensors ......
      • Turn on a lamp, if its dark and motion detected....