Building remote for my media center PC

Around a year back I had posted on how I built my media center PC aka HTPC (Home Theater Personal Computer) . I had been operating that using my wireless keyboard and mouse which satisfied all my functional requirements. To work as a true media center though i felt it had to work with a standard television remote.

I had therefore thought of adding a Infrared receiver (IR) connected to my media center PC which would allow me to use a regular TV/ DVD remote control to operate it. I looked around for some ready made IR receivers but the only one i found decent enough was Flirc . The price was on higher side though which was around 20 USD in addition to availability only in US. This meant that I had to wait for someone coming back to India from US in addition to paying a good amount of money. I therefore decided to go ahead and build my own.

Requirement:

A micro controller based circuit which will accept commands from any existing remote control and pass these as keyboard commands.

Components required -:

  1. Pro Micro 5V 16M Mini Leonardo Micro-controller Development Board For Arduino
  2. TSOP1738 Infrared receiver.

Details-:

The Pro micro Arduino board has a great feature that it can act as standard USB keyboard to your PC with the help of a library. This made the work a lot easier as I then only had to read the IR remote commands and then convert them into equivalent USB keys and send them to PC. For the PC , it appears like it is just a standard keyboard and therefore no special driver or any software is required to be installed on the PC. Every IR remote sends a different set of commands for every key and after some debugging, I had the list of commands which my DVD remote was using. After coding that into the arduino code and writing some new code to map it to PC keys, the thing was working as expected. I then used a old Nokia charger which I had lying around to place the arduino and the IR receiver. Below is the working video and some pics of the board and the final product.

.

 

 

My water fountain

As a part of my DIY hobby projects I had recently created a indoor water fountain out of the things which were lying around the house unused.  This project used the following -:

  1. A submersible pump (18 w) which is used in air coolers, fountains. I did not select this for the rating but because it was available on a good discount on Amazon.
  2. A clay pot which was at home.
  3. My daughters water bottle.
  4. Base of the plant pot

Working:

The pump is connected to the base of the water bottle and pushes water upwards. The cap of the water bottle has holes drilled which allows the water to come out.  Also added few money plants to give it a natural look. Below are few pics and a video.

Slow updates with DNF in Fedora

The DNF utility in my Fedora 28 system had been running slow recently. For quite some i had ignored it assuming it to be a bandwidth issue at my end or at their end. Since this happened for quite some time, i had to look for some help and i did find it. Apparently there is a config “fastestmirror=true” which needs to be done in /etc/dnf/dnf.conf . Post this the system was back to its blazing fast mode 🙂 .

Make your existing router use hotspot wifi internet

I have a NETGEAR WNR612 router which is simple no frills device and does the job its made for. It connects to a modem with Ethernet output for Internet and connects its wired and wireless clients to Internet. Recently i decided to drop my wired broadband and go for JIOFI device which uses the Reliance Jio network and has really attractive prices.

Problem: How to connect my existing router to use the internet from the Jio hotspot device

JioFI and other hotspot variants are technically 2 devices combined into 1 . There is a modem which takes your SIM and connects to the network for internet . There is another piece of hardware which takes this internet and creates a wifi network. The usual routers available in market assume that there will always be a wired internet available at an RJ45 Ethernet WAN port for which they have to create the wifi network. Technically if you are using a hotspot device there is no need for another router which also does the same job. Well in my case my router is responsible for creating my home LAN network and also has a much larger range than the hotspot device. I have a wireless printer which connects to my home network for print jobs. There are other devices which use the router WIFI for internet. The problem statement here was to somehow add the functionality in my router so that it can get the internet from the hotspot and beam it own Wifi network so that the other clients are not disturbed. They get the same internet as always and are unaware that anything has changed, which is how it should be.

A google search revealed several posts and videos which recommend to use WDS ie Wireless Distribution System. My router did not support this mode. Also WDS is a variant of repeater mode which means your hotspot would be responsible for creating and maintaining the LAN using DHCP.  Your older router would act as a subordinate which is what i did not want as the hotspot did not offer much customization.

Solution: I put my R&D hat on. I had an old Linksys router lying around on which I had installed DDWRT the powerful firmware sometime back but was not using it. DDWRT  is a beautiful and powerful piece of software which turbo chargers your routers with features which the manufactures never intended to built into the product. I had written about it in the past here. There are modes in which the router can be configured.

Access point is the mode in which we expect our routers to operate in which it converts wired to wifi. ‘Client’ mode is what would solve my problem. In this mode the devices acts as a client and connects to the hotspot wifi and provides the internet in to the router LAN ports. This LAN port of the intermediate router needs to be connected to the WAN port of the main router. This is all that is needed.

My main router now connects to the Linksys router with DDWRT which in turn connects to the wifi hotspot for internet. Another day , new learning!

 

Parallel slowdown

https://en.wikipedia.org/wiki/Parallel_slowdown

Important concept for developers when they go full throttle on multi-threading. Too much context switching by the manager/master/coordinator becomes expensive as the parallel threads increase. Simple analogy would be to visualize a teacher teaching 20 students. If the student count is increased to 100 then we have a chaos in making as the teacher would not be able to give enough attention to the children.

My old wired printer made wireless

I have a wired HP printer which is quite old but in working condition. It was from the pre -mobile era so it assumed that it would always be sitting next to a desktop machine. Times change and we now have WIFI, mobile and everyone expects everything to be wireless and from a mobile. Being the resident IT support guy i decide to do something about it. I actually worked on it twice.

The first version was few years back before the RaspberryPi came. It was setup using a ASUS router which had a USB port and tomato usb third party firmware similar to DD_WRT which magically adds features to your router which the manufacturer never intended to.I wont explain this much now as I think it wont benefit anyone  NOW (and i am too lazy to type 🙂  ).

The 2nd version which I setup few months back is when the 1st version hardware stopped working and when the RaspberryPi ZeroW was launched. So I decided to go for a Pi based network print server. Its a very powerful piece of hardware and is well worth the money for the form factor. It is a full fledged Linux machine with USB and WIFI ! .This is a ideal machine to be used in kiosk type hardware. I hope they make it lot cheaper so that it becomes a no-brainer choice for such projects.

Hardware:

  1. Raspberry Pi ZeroW.
  2. I had to buy a OTG cable  to connect my USB printer to the pi as the pi zerow comes in with microusb only to save space.
  3. It is powered by the commonly available 5v mobile chargers.

Software:

  1. Installed raspbian OS which is tailor made for Pi.
  2. Setup pi to work in headless mode (no display) as it required a micro HDMI connector and i did not wanted to spend on one. This involves giving a static IP to the Pi and enabling SSH so that you can remotely log in from other machines through SSH and do whatver you want.
  3. Installed CUPS the powerful print server software which converts the innocent pi to a Network enabled printer.

Linux – I tested this setup on Fedora. Almost all linux OS’s have built in support of CUPS based printer and their configuration utilities will auto detect once you provide the IP of the pi.

Windows – I currently dont have a windows machine but I am pretty sure this should also work on Windows out of the box.

Android – There is a app available on android called LetsPrintDroid which easily setups CUPS enabled print server found on the network and allows you to print documents directly from the mobile without requiring any desktop/laptop. This is slowly becoming my preferred mode when all i want is a quick print without waiting for my desktop to be UP and running.

Whenever the printer is powered ON, the pi also boots up and within a minute connects to the WIFI and is ready to serve print requests from my home network.

Arduino based automatic aquarium fish feeder

I had setup a aquarium at home recently and realized the need to feed the fish twice a day. Since necessity is the mother of invention, I therefore decided to setup some kind of mechanism which will feed the fishes at regular intervals.

I looked at assembling something with 555 timers but found after some research on internet that they are not suitable for such long delays (twice a day). The next option was digital timer circuits and pre-assembled modules but looking at the cost factor arduino seemed a good option although using a micro controller for such a project seems to be a overkill but i think what matters is it fulfills the functional requirement with the lowest cost. I wont mind even using a RaspberryPi if its the cheapest 🙂

With an old vaseline box, few electric concealing pipes and a stepper motor I managed to setup something which did what i wanted it to do. Every 12 hours the arudino code is triggered and it signals a stepper motor to rotate 1 clockwise and 1 anticlockwise rotation. There was no particular reason for the clockwise and anticlockwise part , its just that i felt that it would be more fun that way.

The demo video shows a plate which acts as the manual override which can be used to test the system till we are confident that everything is working as expected.

How i built my Media Center PC (HTPC)

Below is my current desktop machine (YES i still use a desktop) configuration.  I use Fedora Linux with GNOME desktop.

AboutPC

Listed below are very short steps which would serve just as a pointer to setup a Linux based Media Center PC aka Home Theater PC as there is a lot of information available on the internet for each pointer.

  1. Added RPM fusion repository in software source.
  2. Installed gstreamer multimedia codecs as by default Fedora cant play various media formats due to license restrictions.
  3. Installed pulseaudio volume control GUI app.
  4. Since I have a SPDIF connection from my desktop to my Yamaha Audio Video receiver, I selected the SPDIF option in pulse audio volume control configuration.
  5. Configured pulseaudio to play the surround sound formats.pulseaudiovoumecontrol_spdif
  6. Installed KODI , the excellent media center app.
  7. Configured Kodi to enable SPDIF Passthrough.
  8. Made Kodi aware that my AV receiver can understand Dolby Digital AC3 and DTS surround sound format.
  9. Enabled Dolby digital transcoding so that Kodi does the hard work of converting the new surround formats such as EAC3 to the format which my AV receiver understands.This I feel is an excellent feature as this enables me to play newer formats without the need to upgrade my AV receiver.kodi_spdif
  10.  Get a file with surround sound format to test your setup. I used a simple but excellent one available at http://www.lynnemusic.com/surround.html .
  11. Play and Enjoy surround sound music!  🙂

 

Browsers and http session keep alives

Recently came across a situation when I found out that Chrome and Internet explorer behave differently in case of http session keep alive’s. The behaviour observed was that Internet explorer closes a connection after a fixed interval whereas Chrome keeps the connection alive for a longer duration.

When a web page is requested, the browser downloads the required page along with other components.  If the server wants the http/https session to be kept alive, IE will keep the connection open TILL its own timeout limit . The default is 1 minute. After this the browser has to open a new http/https connection in case there is a need. Chrome on the other hand keeps the connection alive by sending a TCP keep alive packet 45 seconds after the last http session request.

When a connection is kept alive, the server would keep the port and its related resources like threads/memory on the server longer. Whenever a new connection is made, it requires a handshake to be done between the browser and the server where they speak on which port would they use, which protocol etc. While this may be light handshake for a http session, https means they need to talk about security certificates and the encryption keys which means a lot more talking. The user has wait till this talking is done and his webpage displayed or banking transaction is completed. With low powered mobiles which have a less number of CPU cores, low RAM or a poor network connection this might not be a pleasant experience. This would also mean the battery drains faster as the CPU has to do extra work.

Chrome therefore could be keeping the connection alive so that end user has a better user experience even though it puts some extra load on the server.

While it seems obvious that it should be the default behaviour, there may a reason why IE behaves this way. For a long time, IE has the browser which has the largest installed user base. With longer keep alives, servers would need to keep extra resources to support those users. With increased processing power at the desktops along with faster internet bandwidth, reconnecting a disconnected http/https session would not be so costly as was earlier with low power CPU/ low RAM and low network bandwidth. Disconnecting a minute after the last request was made sounds a reasonable design decision.