Bluetooth Low Energy : Communicating as a Central and Peripheral Device


In the world of connected devices, we often encounter a Bluetooth Low Energy (BLE) device communicating with the Smart Phone. May be the BLE device is sending the temperature sensor data to the iPhone and you can view the current temperature in an app. In this case, the BLE device is acting as a peripheral and the iPhone (which also has a BLE wireless network inside) is acting as a central device.

But what if you want to send the temperature sensor data from the BLE device to another BLE device which is not an iPhone? How do you do that? We are going to find it out in this post.

Although the core Bluetooth spec. supports that a BLE device can either be a peripheral (sends data) or central (receives data), most BLE chips available are peripheral only. Those chip manufacturers have specifically disabled the BLE chip from acting as a central device. And for a developer, there is no way to change that!

Thankfully, TI CC2540 is one of the rare BLE chips that supports both the central and peripheral property. As a result, whoever is using CC2540 as a chip and making their own module or board has that capability. For example, Bluegiga BLE modules are based on CC2540. Therefore, if you buy Bluegiga BLE boards, you will have the liberty to make it either a central or a peripheral device.

What do we need:

  1. A pair of Bluegiga BLE113 based breakout boards
  2. TI CC debugger to flash the code
  3. An Arduino (explained later)
  4. Wires

Why do we need an Arduino?

Suppose we have two Bluegiga BLE devices. One is sending and the other is receiving the data. Using an app like Punchthrough or something similar, we can easily verify if the sender BLE is sending the data or not. But how do I verify that the receiver BLE is receiving the data? In the case of Bluegiga BLE, those received data are available in its UART pins. If we connect the Bluegiga UART pins to the Arduino UART pins, we can read those received data with a simple Arduino program.

Steps to follow:

  • Get the Bluegiga SDK installed in a Windows PC. In Mac, you need a windows virtual machine.
  • Once the SDK is installed, you will have “BLE SW Update Tool” in your desktop. Use it to flash code through TI CC debugger. There are other ways to flash the code but this one seems the simplest to me.
  • Download the BLE_Central repository and flash the project113.bgproj file to one of the Bluegiga BLE113 device. Mark it somehow to note that this one is the central device.
  • Similarly, download the BLE_Peripheral repository and flash project-ble113.bgproj file to the other Bluegiga device.
  • Now we want to verify that the central-peripheral BLE communication is really working.

BLE113 Pinout-500x500                            Courtesy: Hardware Breakout

  • Power the BLE boards with 3.3V to VCC and GND to GND pin
  • Connect the P0_5 of the central device to Arduino TX and P0_4 to Arduino RX
  • Now power up the Arduino, upload the simple UART reading code and you should see the output in the Arduino serial monitor.

Startup Grind 2015

Startup Grind 2015

Startup Grind 2015 was in Redwood City this February. This is my first Startup Grind. Thanks to the organizers for the scholarship. I attended the event without paying a penny!

The two day event had 1:1 sessions, panels and workshop with an incredible line of speakers.

My background is hardware so I was specifically interested in Matt Rogers and Eric Migicovosky. Matt shared his experience at Apple and how it shaped some of the decisions at Nest, how his role is evolving from the early days of Nest to a grown up Nest. Eric’s session was more into Pebble’s take on Apple watch. I loved it how cool he was in answering those questions.

I also attended the sessions with Matt Miller of Sequoia Capital, Paul from Alta Venture, Manu Kumar from K9 venture, AngelList syndicate session, Health session with Halle Taco, Jeff of Priceline, Google Venture, Mike from Instagram and Biz Stone from Twitter.

My top 3 lessons from the Startup Grind 2015.

  1. Hardware products take 2X more money and 3X more time than you think you need – Matt Rogers, Nest.
  2. Nail it before you scale it – Matt Miller of Sequoia Capital on scaling your startup.
  3. Always value people not organization – Biz Stone, Twitter co-founder.

Zuckenberg’s Year of Books: Recap of ‘The Better Angels of Our Nature’

Originally published at my medium blog.

Okay, so I just finished reading ‘The Better Angels of our Nature’ by Steven Pinker; the 2nd book of Zuckenberg’s ‘A Year of Book’ club. And here is a quick recap. If you haven’t seen my notes on the 1st book, you can check it out here.

In this book, Steven argues that violence has decreased over time. The writer discusses how violence was exercised in different times of the civilization. He argues that violence has reduced and explains why. The book starts with a vivid depiction of atrocities described in the Hebrew Bible, so detailed that I felt like ‘okay I understand, what’s next?’ But as I kept going, it became more and more appealing; opening new doors of historical, sociological and political paradigm in front of me.

Without further ado, here is my quick summary

  1. The religious brutality described in the Hebrew and Christian Bible, though fictitious, represents the thought process of the people of that time. But sensibilities toward violence have changed so much that religious people have compartmentalize their religious ideology. Their school of belief have rarely changed but their action is thoroughly tolerant and nonviolent. The writer calls it ‘a benevolent hypocrisy’.
  2. How did we get the name of our favorite drink ‘Bloody Mary’? The writer says that the name originated as the Queen Mary I of England burned 300 religious dissenters.
  3. Honor exist because everyone thinks that everyone else thinks it exists. [1]
  4. U.S. had higher homicide rate than other similar countries. Although U.S. can’t be thought of one single country, rather a collection of countries as the societal and cultural norm varies. The northern U.S. states has lower homicide rate than the southern U.S. states.
  5. War follows the power law distribution. That means it has a non-negligible probability of extreme outcome.
  6. But why war follows power law distribution? Because leaders keep increasing the atrocities of the war as time pass. As they have already spent much resource in the war, they want to avoid any chance of losing by increasing atrocity. This eventually causes wars to follow the power law distribution. [2]
  7. Many small wars cause more deaths than one fatal war.
  8. Probability of death from Boston to LA flight is same as 12 mile drive. [3]
  9. Predatory violence happens when suffering of the victim is very insignificant compared to the joy of the killer
  10. Institutional violence happens because of the societal and political rule.
  11. Will more women in power reduce violence? Yes.
  12. Women are the less violent sex of human species. Although, in any society, thought process of women are strongly correlated to their male counterparts.
  13. So what can we do to reduce violence? Increase ‘empathy’. Empathy has been a recent buzz but the writer believes that empathy alone is not a significant component for violence reduction. Empathy can hinder fairness and that in turn can cause violence.
  14. Self-control, promoting intelligence (as intelligent people believe in positive sum game), better government, people familiar with each other and women empowerment are some of the critical components towards a less violent world.
  15. Yamaguchi, the only survivor of the world’s two nuclear attack said that “The only people who should be allowed to govern countries with nuclear weapons are mothers, those who are still breast-feeding their babies”.

[1] Next time you wonder ‘what people will think’, remember this line.
[2] The same reason why we finish watching a bad movie if we have already paid for the ticket.
[3] After 9–11, an increasing number of people started travelling by road instead of air causing more travel related death than before.


Zuckenberg’s Year of Books : Reviewing ‘The End of Power’

Originally published at my Medium blog.

As part of Mark Zuckenberg’s 2015 challenge — reading a book in every two weeks, I just finished reading the 1st book — The End of Power by Moisés Naím. With numerous examples from history, politics, religion, culture and technology; the book discusses how power is decaying over time. It was a great read adding to my political & cultural knowledge base.

So I decided to note down my thoughts and some of the interesting points from the book. Without further ado, here is a quick review.

  • Powerful people are feeling more and more powerless.
  • Power itself is decreasing for various reasons — increase in the World’s population, access to education and resources are to name a few.
  • As we lack power to solve bigger problems, we focus on short term achievements. [1]
  • Power is expressed through the 4 channels — muscle, code (religious or societal norm), pitch and reward.
  • According to William Domhoff, American life was controlled by the owners and top managers of large corporations.
  • Number of autocratic countries are decreasing, even autocrats are not that much autocratic these days.
  • In the election process, one party getting absolute majority is becoming rarer.
  • Power in corporations is also reducing. In the United States, CEO turnover was higher in the 1990s than in the two previous decades. For example, Paolo Scaroni, the CEO of the Italian oil giant ENI said “When I look back at how the leaders of the main oil companies of the 1960s, 1970s or 1980s used to make decisions and run their businesses, I am amazed at the freedom and autonomy they enjoyed. From where I sit, it’s obvious that nowadays any oil company CEO has far less power than those who came before us.”
  • The term ‘dark pools’ is quite interesting. It refers to a group of institutions that seek to trade anonymously to avoid revealing their strategies. The Securities and Exchange Commission estimated that the number of active dark pools in the US market shot up from ten in 2002 to more than thirty in 2012.

My Thoughts:

The book’s message — power is decaying over time is pretty intuitive in the era of Apps and Kickstarter. In fact I personally know someone who was expressing the same opinion without even knowing about this book!

Take for example crowdfunding. I know at least 4 writers who got funded by Kickstarter and were able to publish the books. Without crowdfunding, they wouldn’t have seen the light of the day.

In my opinion, power hasn’t really gone, but the means of power is probably a more complex mix of muscle, code, pitch and reward than before.

[1] This is the most astounding thought from the book that I will remember forever. And yes, it is so true. Why you think everyone is building an App when we spend 10 hours in weekly commute to work? Why can’t people solve real problems? Because solving real problems takes longer time, more resources and a huge number of people to trust and follow your leadership. You don’t have time because you want to be a billionaire by 30. You don’t have enough resources because resources are distributed among many people. And you don’t have a huge trusted follower base as everyone is building their own app!


Hand Assembling SMD Circuit Boards

At litehouse.io, we recently got our 1st prototype board. We decided to do hand assembly of the SMD circuit board instead of sending it to the fab!

This is my 1st circuit board assembly. Soldering the SMD components can be really daunting. But if you have proper tools and resources in hand, it is not all that bad.

Here is how our soldering area looks like


Soldering in progress …


Without further ado, lets list down the necessary tools and resources used to complete the hand assembly of the SMD circuit board.

X-Tronic Hot Air Rework & Soldering Station: This (or any other brand you like) is a keeper. The kit is a collection of a bunch of necessary tools that you will need. So instead of ordering them separately, you can save $$$ on this package.

Solder tip cleaner: More useful than the traditional spongy cleaner that comes with the soldering station.

Vacuum Pickup Station: Extremely useful for pick&place of the tiny resistors, capacitors etc. Although my 0603 size resistors were too small for the smallest vacuum suction tip that this kit has. It sucked up 3 of the resistor and I still can’t find them! So I ended up using the tweezer for the resistors (painful). I need to find smaller tip for vacuum suction.

Flux Paste: This is your best friend!

Wipers: Needed to cleanup after soldering.

Flux Brushes: Needed to cleanup after soldering.

How to SMD Soldering
Soldering QFN Components
How to use Vacuum Pickup Tool

My begineer soldering kits
Soldering Station
Helping Hand
Desoldering pump


Open Hardware Summit 2014

I attended Open Hardware Summit this September in Rome, Italy. It was a two day conference with great speakers – Adrian Bowyer, Eric Pan, Becky Stern, Jason Kridner, Micah ScottMadeline Gannon, Zack Jacobson-Weaver, JeromeAmmar Halabi, Yasmin Elayat, Liat Brix, Hagit Keysar, Allison Burtch, Jason Kridner  and more.

Addie starts the Day1 of the Summit

Madeline Gannon and Zack Jacobson-Weaver on open source industrial robots

Eric on Design from Manufacture

On day 2, Benjamin had the workshop on open hardware business model.
Eric had another interesting workshop  on design from manufacture.

I got the opportunity to co-chair the Summit along with Addie, Simone, Zach and Gabriella.


Mathilde from Making Society has published a great recap on the summit.
And checkout the Flickr photo stream of Open Hardware Summit 2014.


RaspberryPi: Reading I2C Inputs using C

Accessing Raspberry Pi GPIO pins with Python libraries is popular among hackers & makers. How about programming languages like C? C gives you flexibility to port code in embedded firmware/driver layer if necessary. That is why I was looking for a C library that exposes Raspberry Pi GPIO pins for application layer. I was specially interested in exploring the I2C pins and found the excellent wiringPi library.

In this post, I will show step by step on how I use wiringPi library to read from the I2C interface of a 3-axis Accelerometer+Gyroscope module. The module I used is GY521 (InvenSense MPU6050).

Hardware setup:

I have a Raspberry Pi Model B (Rev-1), GY521 (InvenSense MPU6050), breadboard & some male-female wire.

*Connect Raspberry Pi 3V3 to GY521 VCC
*Connect Raspberry Pi GND to GY521 GND
*Connect Raspberry Pi SCL to GY521 SCL
*Connect Raspberry Pi SDA to GY521 SDA

To find the Raspberry Pi GPIO pin maps, follow this guide


*Install I2C dev library. Under Raspbian, use

sudo apt-get install libi2c-dev

*Configure I2C pins using adafruit guide

*Install wiringPi using this link

*Make sure your Raspberry Pi can detect the device attached to the I2C interface. If detected, then you will see an address with below command. In my case, the address is 0x68 which is then used in the code.

i2cdetect -y 0 # Rev 1
i2cdetect -y 1 # Rev 2

*Use this sample code from my github

*Use the Makefile and type

$make i2ctest
$sudo ./i2ctest

You should now see the sensor data value in the screen.