Nexus 6P Headset Volume down button fix

Nexus 4 owners, and I am one of them, were disappointed to find out that it only support 1 button headset control, so no buttons for Vol+ and Vol-. When I bought the Nexus 6P I was hoping it will have support for 3 buttons control. After I got the phone I tested it with my Samsung headset, the play/pause button and the Volume Up button work, however, Volume Down didn’t!!!

I was hoping it is a faulty headset since that I can replace easily, but if it was a design mistake in the Nexus then it might be a problem forever. Luckily and after a quick Google search I found a post on reddit from someone asking if the Nexus 6P has support for 3 buttons headset. The answer was yes, so that is a good news, but one of the replies was from a reddit user “buddhra” who was having a similar problem as mine and did a further test to find out that the Nexus 6P acceptable resistance range for the Vol- doesn’t stretch to the maximum range which the Android specs allows.
Here is a snapshot for part of the post:

Reddit Nexus 6P 3 button headset support problemSo I tested mine and found the resistance of the third button (Vol-) to be 630 ohms, which is within the Android specs but seems out of what the Nexus 6P can recognize.  Not sure if it is a software or a hardware problem in the Nexus 6P which I won’t be able to fix easily, but I know that I can instead fix the headset itself to give the readings that the Nexus 6P expects.

So I opened up the headset control, it is very small and was glued together, but using a thin blade i managed to open it up:

Opening up Samsung headset controlZooming into the circuit board and tracing the PCB wires I figured how the resistors were connected and managed to replace one of the resistors (R3 = 356 ohms) with one of a smaller value (200 ohms) and it now works. (The resistors used in the board are size 402, however, I had one with size 603 which is a little bigger but there was enough space to fit it without any problems):

Samsung Headset Fix for Nexus 6PAll Android headset controls follow a similar way to provide the needed resistance, so your control board might differ but it should be similar.

Let your Arduino get enough sleep

The sensor I am building is based on an Arduino Pro Mini (Atmega328p) with ESP8266 wifi module and a sensor. It will run on batteries with a sample rate of 1 sample per hour. With such low sampling rate it is very obvious that I need to make my microcontroller and the wifi module sleep to reduce power consumption. To wake up the Atmega328p MCU from power down sleep I have to use either the Watchdog Timer (WDT) or an external interrupt. The problem with the WDT on that MCU is that the maximum sleep time it supports is 8 seconds. And to make it sleep longer you need to put the sleep statement in a loop that puts it back into sleep until it reaches a certain count value then resume working.

This is an example of such solution:

for (int i = 1; i <= count ; i++) {
    sleep_cpu ();

However, in 1 hour of needed sleep the MCU will wake up 450 times!

Continue reading “Let your Arduino get enough sleep”

Arduino resets when disabling Watchdog Timer!

While working on a small arduino project that will run on batteries I needed to enable deep sleep mode to reduce the energy consumption when not needed until the arduino is awaken by an external interrupt.  However, I am also using the Watchdog Timer (WDT) to make sure the system will not hang up or get into in infinite loop due to some bug or unknown situation. The maximum time that the WDT on the Atmega328p supports is 8 seconds, and if 8 seconds has passed before calling wdt_reset() the WDT will reset the microcontroller, however, my boards will sleep for way longer than 8 seconds so I have to disable the WDT before going to sleep and enable it back once waken up.

Disabling WDT should be an easy thing to do by simply calling wdt_disable(), however, calling this statement also caused the atmega328 to reset!

After looking into the content of the header file “avr/wdt.h” it seems like the Arduino IDE or AVR compiler (not sure who is responsible) is not defining the correct board/chip even though I set the correct board & processor in the Arduino IDE. And the way I solved the issue was to define the correct microcontroller before including the wdt.h:

#define __AVR_ATmega328P__
#include <avr/wdt.h>

Now the code works as intended without causing a reset.

HTML5 and H264 for Firefox on Linux

In some Linux distributions such as Fedora the amazing browser Firefox will ship with some of the video decoders turned off by default, some of it is due to the decoder being in unstable stage or due to some copyrights/patents concerns. In either way trying to play videos that uses one of these formats won’t work even if you have all the packages installed (such as the good, the bad and the ugly gstreamer plugins).

I wanted to make youtube use the HTML5 player instead of the old flash player which is mostly used to track you, show ads and by hackers. Visiting the youtube html5 player page used to be like this:

Firefox on Linux Youtube HTML5 PlayerThe items in red means they are missing which caused some youtube videos not be available in HTML5 player, or for the resolution to be limited mostly to a maximum of 720 or lower.

The solution is very simple after installing all needed packages, I got all my decoders for Fedora from RPM Fusion repos, and it is under the Firefox low level configuration page which you can get to by typing about:config in the URL box + Enter (click on the button “I’ll be careful, I promise!” if you see a warning page).

In the configuration page there is a search box at the top that makes it easy to find the settings which you need to change. So first type in “h264” and enable the disabled settings as you see in the picture below:

Firefox H264 decoder settingsThen type in “mp4” and do the same as the picture below:

firefox mediasource settingsFinally, search for “mediasource” and enable it as follows:firefox mp4 settingsWhen you are done with the settings revisit the youtube html5 page and it should look like this:

firefox youtube html5Now you can enable the HTML5 player as a default player and enjoy a faster youtube thanks to HTML5 and have the ability to play all videos in all formats.

Robo RC

When my son wanted me to buy him a toy robot I asked him if he would like to build one with me instead, he was so interested so I told him that it will be a car robot with two motorized wheels controlled from the phone over bluetooth and he needs to sketch the design then build it using Lego blocks.

IMG_20150110_115340 IMG_20150110_115358 IMG_20150110_115409IMG_20150301_184414 IMG_20150301_184527 IMG_20150301_184516 IMG_20150301_184501 IMG_20150301_184432 device-2015-03-07-210547

While he was busy with the sketches I started looking for parts, so I went to eBay and found these wheels

They come in two speeds, I ordered the slower one since it has more torque.
These wheel will need something to control them since the Arduino micro-controller is not strong enough to drive them with enough current so wanted to build an H-bridge using transistors (which I have already) but I found  a module based on the L298 chip  which is very cheap and has a voltage regulator too, awesome.

Next was the bluetooth module, and I went for the HC-06 which is easy to use and also cheap.

Bluetooth HC06-2And finally is of course the Arduino board, I got the Arduino Pro Mini for its small size and low cost.

arduino_miniEven though I actually used the Arduino Uno for the development since it is much easier to upload the code and fix mistakes.

I got them all from eBay with the cheapest price I can get so some took about a month to arrive and I wasn’t in a hurry:

2x Car Robot Wheels: $6.00
L298N Dual H Bridge: $3.00
HC-06 Bluetooth Module: $4.00
Arduino Pro Mini: $2.60
40pin Dupont Wires: $1.50
Total = about $17

You will also need an Android Phone or tablet, any with Android 3.0 and up should do. Lego blocks or anything to use for the car body.

Here is a video we made showing how to use the app and explaining the car we built and its main parts:

To get the Andriod app click on the Google play icon below:

for the Android source code click here
and for the Arduino code click here

Inside a fake ELM 327

I got myself on of those cheap Bluetooth OBDII dongles but it didn’t work in my car (2005 Dodge), it simply couldn’t detect the protocol which is SAE J1850 VPW used on most Chrysler/Dodge I believe before 2008. So I took it apart and as you can see in the picture it has two stacked circuit boards the one of top has a bluetooth chip (BEKEN BK3231Q) and a CAN protocol transceiver from NXP (TJA1040)

Fake ELM327

The flip side of the top board contains a CAN controller (MCP2515) from Microchip.

CAM controller MCP2515

However, and what is surprising is the bottom board which contains only voltage regulators for 5v and 3.3v and most of the OBD-II pins are not even connected!
OBD-II connections

Let’s compare  the connected pins to the pinout of the OBD-II connector in the image below


So the 12v VCC (pin 16 in red) is connected and the two ground pins (pin 4 & 5 in gray). How about the different OBD2 protocols? let’s see:

  • CAN  (ISO15765) used pin 6 & 14 (green color) and they are connected.
  • ISO9141/14230 uses pin 7 & 15 (yellow color) and they are connected.
  • J1850 PWM uses pin 2 & 10 (blue color) and they are NOT connected.
  • J1850 VPW uses only pin 2 (blue color) and it is NOT connected.

So it is clear that this will not support any of the J1850 protocols which are used by most old American car makers (Chrysler/Dodge/Jeep, Ford, GM), luckily I think all new cars (2008+) are using the CAN protocol which is the newest among the others.

Update: Another fake OBD2 reader

I bought another Bluetooth OBD-2 reader that is slightly larger than the one I got before hoping it would have the parts needed to support all protocols and since the seller also claim it does. (Spoiler: I got a full refund).


Guess what? It is exactly the same as the other one, it didn’t work on both of my cars so I opened it up and unsurprisingly it has the same guts (same chips) in slightly different arrangement.

obd2_02 obd2_03 obd2_04

I think having full support is a little too costly even for the Chinese manufacturer, also don’t be fooled by some sellers on Amazon who sell the same exact models for $15+, increasing the price won’t make it work. I also won’t recommend using these basic devices in your car since they don’t have Bluetooth authentication! and any nearby hacker can connect to them and have full access to your car CAN bus and do whatever your car manufacturer has allowed on that bus. You might have heard about the recent car hacks like disabling the breaks and such.

So if you are looking for something that works with all protocols and also safe to use I would go with trusted brands that have been tested by many users, e.g. “OBDLink LX Bluetooth” which looks like the perfect solution, good quality build, support for all ODB2 protocols, sleep mode and has a security button that need to be pressed to allow Bluetooth pairing I have not used it though since it is a little expensive.

Auto login to open Wifi

If you go to many places with open wireless access you might find it annoying that every time you have to open the browser to accept the same rules and conditions from that provider before you can have real internet access. It is even worse if you have tabs left open from your last session and they all now point to the same wifi login page!

However, if you are using Linux and you have NetworkManager set as the default network management tool then I have a solution for you, NetworkManager will run the scripts inside the folder “dispatcher.d” whenever the connection status changed for any of the network cards on the machine. Under Fedora the folder is located in “/etc/NetworkManager/dispatcher.d/” and I will assume other Linux distributions will be similar if not the same.

So all you have to do is create a script in that folder that will run whenever the wireless connection is up and the network name (SSID) matches the location that have the open wifi, then the script should automate the process of clicking on the accept button or whatever it takes to get internet access.

I have already made such a script that will allow me to login to Panera Bread and Baltimore County Public Library, but it can be expanded easily to include other locations. The first part of the script should be placed under the “dispatcher.d” folder and should be accessible by “root” only (This is a security feature, since NetworkManager will execute all scripts in that folder as root and anyone with access to these files can change their content to do other stuff that might harm your system, so make sure to set the permission to root only). That script will parse the iwconfig output to find the name of the wifi and call the script that matches the name if any.

Continue reading “Auto login to open Wifi”

Airline Manager Secrets and Cheats

NOTE: These cheats do not work anymore

I am going to list here few tricks and cheats that you can use while playing airline manager on facebook. But be careful as some might get you banned from the game. For all of these tricks all you need is Google Chrome browser or Firefox with the Firebug add-on.

1- The BIG Money maker

For this cheat to work you need to have cargo planes, so get your pax points up and buy the cargo feature. Once you buy your cargo plane (get one that can carry big load for short distance, it makes more money) start creating its route (again demand is important,  distance is not) but stop at the point where you need to sign a contract. As you can see most prices are about $1.0 to $2.5. So pick any of these contracts, lets say the first one, and right click on the “Sign” button, from the list you will see an item called “Inspect Element” click on that and the browser will open a small box at the bottom of the page showing you some HTML code of that page and the code for the button you right click on is highlighted. See the picture:

Continue reading “Airline Manager Secrets and Cheats”

Front Mic problem in Fedora 14

After upgrading to Fedora 14 I noticed that the built-in mic in my Dell D620 stopped working, after searching here and there I the problem is between ALSA and Pulseaudio, since alsa will show to capture devices “Mic” & “Front Mic” and Pulseaudio will use Mic as the default instead of Front Mic.

So I used “alsamixer” to set the correct capture source and that worked but after a reboot it was set back to Mic. Then I found about “alsactl” which should store the current setting by doing “alsactl store” but that did not work either since I think pulseaudio does not look into that.

Uninstalling pulseaudio as some people suggested solved the Mic problem but caused many other problems when playing many applications that want to play audio (like flash apps such as youtube and video apps…etc),  this is an ALSA problem that pulseaudio try to solve AFAIK.

The solution that I found was to use “amixer” which can be run from the command line with the parameters to set “Front Mic” as the capture source. Here is the full command for my device:

amixer -c 0 cset numid=6,iface=MIXER,name='Input Source' 1

Continue reading “Front Mic problem in Fedora 14”

RPM Fusion Smart channels for Fedora

If you are a Fedora user then you must be using RPM Fusion and if you are not then please do since it provides you with many cool packages that Fedora doesn’t come with (like ATI & nVidia drivers, video and audio codec…etc). After you install RPM Fusion repositories (through their provided rpm packages which you can find about under the ‘Configuration’ in their website) you will be able to use it right away from the command line by using ‘yum’ or if you like the GUI (like I do) then it is PackageKit. However, there is one thing that I don’t like about PackageKit which is dealing with dependencies.PackageKit will only resolve dependencies when you apply the changes not while you are making them (selecting to install or remove a package). I find that annoying since sometimes when I select to remove some packages that I think I don’t need and  when I click on apply it will show the list of dependencies of all the selected packages and will not tell you which one of the selected packages is needed by those other packages and the only way to find out  is by removing packages one by one. Same thing when installing.
However, there is a solution to this problem, it is called Smart, Smart is a package manager that can be used to manage ‘rpm’ packages (and also apt as well). You can install Smart and the GUI from Fedora repos with this command:

yum install smart smart-gui

The biggest advantage of using Smart over PackageKit is the way it resolves dependencies. Smart will do that instantly while you are clicking to install a new package or trying to remove one. So for example if you are using Fedora with KDE and wanted to remove all Gnome packages and you clicked for example on ‘gnome-vfs2’ Smart will immediately look for all other packages that depends on this one and if any it will show you a windows of the list of all other packages that will be removed as a result of removing this one, among that list you will find ‘Firefox’, ‘vlc’ and other packages that I actually need, so that means this one is important and i will just hit cancel to keep it. Same thing when for example you want to install and try some application but you find that it needs many other packages to be installed as well.

However, it seems that Fedora and RPMfusion are not giving much attention to Smart and the channels files (channel = repo) are not updated for Fedora 14 (was also the case for F13 when it was released) so I decided to update those packages myself and maybe find a way to send them to Fedora and RPMFusion so they will sign them and add them to their main repositories.

Download the appropriate files for your system or the source if you wanna compile the rpms and sign them yourself (you will need to rerun Smart so it detects the changes):

Update: Since not much attention from Fedora and RPMfusion is giving to Smart and it is not supported anymore I stopped making the rpms for it.

Why Apple did not know about the iPhone4 antenna problem

(IMO) That is easy to answer, because of Apple super secrecy they were testing the new design inside a case to make it look like the old iPhone. So the antenna was isolated from the user hand with enough distance to minimize the effect, and I am certain that it was also the case inside the company since they don’t want the other employee to know about it, but thanks to Gizmodo this thing was unveiled. In addition to that, they most probably have a big AT&T cell tower inside the company to make Steve happy.

Image from Gizmodo of the iPhone4 with the special case.
The camouflage case
The case it came inside was a fully developed plastic case to house this phone to disguise it like a 3GS. This wasn’t just a normal case; it had all the proper new holes cut out for the new switches and ports and camera holes and camera flash. But it looks like something from Belkin or Case-Mate. It’s a perfect disguise.

Source: Gizmodo

AirlineManager Ads Prices

While working on my script Autopilot to enable buying advertisement I started collecting information about the price changes over time, and found out that it is not actually random, but repeats every week. So here is a graph that shows the prices for 1 week and a table that shows the same thing and highlights the cheapest ones.

Sat Sun Mon Tue Wed Thu Fri
12 AM 49890 48089 32080 43022 47017 32213 40693
01 AM 48089 19004 32043 48612 37768 35792 49415
02 AM 23896 7435 32845 50324 32213 45439 49838
03 AM 7831 14021 34475 47017 33869 49890 39308
04 AM 8870 25482 36853 40843 40693 49838 14928
05 AM 21458 8658 39801 35177 47250 43232 7530
06 AM 22775 20310 43022 32213 49890 23896 8870
07 AM 7366 21438 46112 32555 50097 9763 19060
08 AM 20310 8083 48612 35792 48089 7435 25482
09 AM 23447 9777 50105 40693 39308 8870 14038
10 AM 10094 39347 50324 45439 23896 16499 8675
11 AM 7531 50168 49229 48567 11851 24883 22794
12 PM 19045 43179 47017 49890 7831 22775 23447
01 PM 46167 32218 44070 50168 7473 11015 11824
02 PM 50109 49244 40843 49838 8870 8675 7472
03 PM 43179 36829 37768 48089 14021 20310 9777
04 PM 31976 36545 35177 43232 21458 25582 29278
05 PM 44098 49611 33289 34525 25585 19037 48103
06 PM 43972 43972 43972 43972 43972 43972 43972
07 PM 32043 41531 38967 36524 34439 32909 32080
08 PM 48612 38967 34439 32080 32845 36853 43022
09 PM 37768 36524 32080 34475 43022 50105 47017
10 PM 35792 34439 32845 43022 50324 40843 32213
11 PM 49415 32909 36853 50105 40843 31977 40693

Note: the table and graph timings are based on the US-Eastern Time (-5) so adjust your times accordingly. Also the listed prices are for the most expensive type of advertisements (Billboards on 20 international airports).