on Electronics, Jn5168, jn5169, Microcontrollers, zigbee

Create Cheap Philips Hue Compatible Devices

The Philips Hue range is a great way to add wirelessly controllable lighting to your home, but the protocol is proprietary which makes it difficult to add our own custom hardware. [Peter] found a way to create his own Hue compatible devices based on cheap JN5168 modules that are able to connect to the Hue bridge. This means you can roll out your own lamps using cheap RGB or White LEDs, a power supply and the JN5168 Zigbee Light Link module.

He started off by trying to clone a Zigbee Light Link device to a MeshBee — Seeed studio’s open source Zigbee Pro module based on the NXP JN5168. Even though the MeshBee used the same device as a Hue lamp, it would not connect to the Hue bridge. But another clone lamp called Innr that he purchased from the local hardware store did connect quite easily. Using NXP’s open source tools, he was able to download the flash and EEPROM contents from the Innr and copy them to the MeshBee which did the trick.

After the EEPROM transfer trick, he figured out how to modify the two keys used for the ZigBee protocol — one for Home Automation and the other for the Light Link. With this final discovery, he is able to take the ZigBee Light Link demo project, edit it using Beyond Studio, and then load the binaries on the MeshBee device so it can connect to the Hue bridge.

All of this work culminates in two custom firmware binaries; one for white dimmable lights and another for RGB dimmable ones. It even runs on these cheap JN5168 breakout kits he found for a few bucks. With all of the software taken care of, and having cheap ZigBee Light Link compatible modules on hand, building low-cost Hue compatible lights becomes pretty straight forward.

Thanks [wind-rider] for the tip.

View @hackaday.com


validate ip address using regex

The code snippet below will check if the passed string is a valid IP address or not .
An Internet Protocol address (IP address) is a numerical label assigned to each device participating in a computer network that uses the Internet Protocol for communication. Read more about IP address here. This snippet will validate IP version 4 addresses.

 * validate IP address
 * @param String IP address to verify
 * @return Boolean result
public static Boolean isIP(String input) {
    if (input!= null && !input.isEmpty()) {
        String regex = "^((25[0-5])|(2[0-4]\\d)|(1\\d\\d)|([1-9]\\d)|\\d)(\\.((25[0-5])|(2[0-4]\\d)|(1\\d\\d)|([1-9]\\d)|\\d)){3}$";
        //check if input matches the regex
        if (text.matches(regex)) {
            // valid ip
            return true;
        } else {
            // invalid ip
            return false;
    // invalid input
    return false;


SIMCOM SIM800H change in hardware. S2-105HG / S2-10651 , S2-1065N / S2-1065Q

SIMCOM has updated the hardware of SIM800H modules with hardware versions (S2-105HG / S2-10651) due to the fact that the power amplifier chip that these modules used (RF7176) is discontinued from production line. The Firmware also had to be changed due to modifications necessary for operation of the new power amplifier chips.

All the new modules ( with hardware versions(S2-1065N / S2-1065Q) ) will be having the new power amplifier chips namely RF7198. According to SIMCOM this change in hardware wont affect the properties and characteristics of the module.

Please note that:

  • firmware for the new hardware version of module differs from the old version of the firmware. Therefore, a new hardware version module can not be flashed with the firmware for the old hardware version module.
  • firmware image files for the old and new hardware versions will be with different names. Firmware for the old version is designated “1308B06SIM800H32_BT” while the firmware for the new version is designated “1309B06SIM800H32_BT”.


Firmware files for SIM800H

All the firmware files can be found at the firmware collection page of this blog. If you want to contribute the files you have you can do so by uploading your files to user uploads section or by emailing me the files you have.




isOnline() check if android device has internet connectivity

What do you want?

  • If you just want to check for a connection to any network – not caring if internet is available – then most of the answers here (including the accepted), implementing isConnectedOrConnecting() will work well.
  • If you want to know if you have an internet connection (as the question title indicates) please read on

Ping for the main name servers

public boolean isOnline() {
    Runtime runtime = Runtime.getRuntime();
    try {
       Process ipProcess = runtime.exec("/system/bin/ping -c 1");
        int     exitValue = ipProcess.waitFor();
        return (exitValue == 0);
    } catch (IOException e)          { e.printStackTrace(); } 
      catch (InterruptedException e) { e.printStackTrace(); }
    return false;

That’s it! Yes that short, yes it is fast, no it does not need to run in background, no you don’t need root privileges.

Possible Questions

  • Is this really fast enough?Yes, very fast!
  • Is there really no reliable way to check if internet is available, other than testing something on the internet?Not as far as I know, but let me know, and I will edit my answer.
  • Couldn’t I just ping my own page, which I want to request anyways?Sure! You could even check both, if you want to differentiate between “internet connection available” and your own servers beeing reachable
  • What if the DNS is down?Google DNS (e.g. is the largest public DNS service in the world. As of 2013 it serves 130 billion requests a day. Let ‘s just say, your app not responding would probably not be the talk of the day.
  • Which permissions are required?
    <uses-permission android:name="android.permission.INTERNET" />

    Just internet access – what surprise ^^ (BTW have you ever thought about, how some of the methods suggested here could even have a remote glue about the availability of internet, without this permission?)


USB OTG as an Extra USB Host in Allwinner A10, A20 etc

USB OTG port on Allwinner SoC based boards is a very useful tool. It can be used to flash an image to the flash memory or connect to a Host PC and making the board to act as a device.

Although there are many scenarios where USB OTG is useful, at times it is more useful to have an extra USB HOST on the board. All the settings of hardware configurations of allwinner SoCs are stored in a file named ` script.bin` that is compiled from a text file called fex file.We can learn more about the fex file from Sunxi Wiki in the Fex Guide.

A FEX file defines various aspects of how the SoC works. It configures the GPIO pins and sets up DRAM, Display, etc parameters.

Each line consists of a key = value pair combination under a [sectionheader]. All three, [sectionheader], key and value are case-sensitive. For comments a semi-colon (;) is used and everything following a semi-colon is ignored. The chip does not parse a textual version of a fex file, it gets cleaned and compiled by a fex-compiler. A reverse engineerd open source version exists in the sunxi-tools repository. Also a de-compiler which takes a binary script.bin and creates a textual script.fex. Usually, script.bin can be found on the nanda boot partition on A10 devices.

Changing script.bin file without removing the microSD card

The tools for script.bin changing are located in /opt/sunxi-tools directory:

  # cd /opt/sunxi-tools
  # ./chscr.sh

This will convert script.bin file from sdcard to script.fex file and the file will be opened using nano editor. Now you can change the board modules and parameters, save the changes (“CTRL”+”X”; confirm with “Y”) and exit (“CTRL”+”X” again) from nano editor.

  # ./wrscr.sh

this will convert script.fex to script.bin and the script.bin file will be written to sdcard.


Reboot the board and the new settings would be enabled.

Changing script.bin file by removing the microSD card

The biggest part of the board configuration might be edited, changed or improved in a file called script.bin

The script.bin file can usually be found in the main directory of a microSD card prepared with official Debian image. The folder containing the script can be inspected under both Windows, Linux or Mac.

You can’t directly edit binary file so you would need to convert it to text format (it is called fex in this case), then edit the parameters via a text editor and finally switch it back to binary format.


To convert back and forth the script.bin you might use different tools. You can find Windows tools here: SUNXI TOOLS FOR WINDOWS . For Linux convertors please check the sunxi tools here: SUNXI TOOLS

Editing Fex File for USB OTG

Now open the Fex file and locate the USB section.

;[usbc0]:  The configuration of controller 0 
;usb_used: Enable bit. If USB is enabled or not. 1: enable; 0: disable. 
;usb_port_type: Type of USB port. 0:device only;1:host only;2:OTG 
;usb_detect_type: Detect type. 0: Not detect; 1: detect vbus/id; 2: Detect id/dpdm

usb_used = 1 
usb_port_type = 0 
usb_detect_type = 0 
usb_id_gpio = port:PH04<0><1><default><default> 
usb_det_vbus_gpio = “axp_ctrl” 
usb_drv_vbus_gpio = port:PB09<1><0><default><0> 
;usb_restrict_gpio = port:PH00<1><0><default><0> 
usb_host_init_state = 0 
usb_restric_flag = 0 
usb_restric_voltage = 3550000 
usb_restric_capacity= 5

We just need to change usb_port_type from 0 to 1 to make it a USB host.

Converting fex to script.bin:

The following commands are executed at sunxi-tools directory:

$./fex2bin script.fex >script.bin
$sudo cp script.bin /boot/script.bin
$sudo umount /boot
Now restart the board and you can use USB OTG as USB host.

Eagle footprint library for Allwinner A10 SoC.

The Allwinner A10 is a family of single-core SoC devices designed by Allwinner Technology from Zhuhai, China. Currently the family consists of the A10, A13, A10s and A12. The SoCs incorporate the ARM Cortex-A8 as their main processor and the Mali 400 as the GPU.

The Allwinner A10 is known for its ability to boot Linux distributions such as Debian, Ubuntu, Fedora, and other ARM architecture-capable distributions from an SD card, in addition to the Android OS usually installed on the flash memory of the device.

Here I am sharing the footprint for Allwinner A10 Soc chip taken from Olimex design.