Stock Brokerage Charges : Fun(?) with numbers

I plotted the various charges that you would incur if you were to make equity transactions on Zerodha against the trade value. Below are the numbers and a graph.

Based on the data, I could see that Zerodha has pretty competitive rates for trade values exceeding 10k.

Ping me at if you see any issues with the data or the math !

I made some simplifying assumptions to fix an upper-bound to the charges. I am listing them below :

  • Transaction charges differ between NSE and BSE, I assumed 0.00325% (NSE charges) as they were the higher of the two
  • Stamp charges are calculated according to rates in Maharashtra
  • Since you need to add funds to your account to be able to buy equity on Zerodha, fund loading charges (Rs. 9 + taxes) have been added, assuming they will be incurred on every transaction.
  • DP charges are only applicable on selling as per the Zerodha website, but I have assumed they are applicable on both buying and selling
  • I have assumed that charges on buying and selling are equal. They are actually a little lower when you are buying.
  • I have assumed DP charges will be applicable on every transaction. They are actually levied once per scrip per day, regardless of how many transactions you do on that script

Making Devices : From Idea to Factory and beyond


I have had the benefit of getting help and advice from a lot of people and resources, as I went along the journey of converting an idea into a product, the PhonePe POS. I have put together a few things to be taken into consideration as you go from an idea to a prototype to engineering samples to your pre-production builds, and to finally receiving that first lot of mass manufactured products.

More and more startups everywhere are building innovative hardware, and while I have put together my experiences doing this in India, I hope this can be of use to startups outside India as well. The considerations mentioned here deal with sourcing, engineering, logistics, compliance and the interplay of these and other elements. 

The document presented here is not a HOW-TO guide, but more like a framework to help you find and weigh opportunities as you race to getting your product out the factory and to market.

Godspeed !

Making it in Shenzhen

Shenzhen is a great place to be if you are building electronic and related hardware. There are a lot of great videos and books about this, most notably by Bunnie Huang [ Book and Blog ] and this map by Seeed Studio.

I had a reasonable amount of time there to roam Huaqiang Bei ( abbreviated as HQB) (Huaqiang North), the electronics street and catalog the marketplace there. I am sharing a few pictures / observations / tips / comments based on my time there :

  • PCBA factories
    They are quite professional, have multiple assembly lines, and almost always do more than just PCBA. They can do sourcing, PCB fabrication, assembly and testing, including making the test jig according to your PCB. They may or may not charge you for making the test jig, and they may or may not make the jig in house. They usually have partners for making the rest of your product i.e. peripherals, connectors, housing. The bigger PCBA firms will charge you for testing based on how simple or complex and how slow or fast the testing is. These factories can churn out hundreds of thousands of assembled PCBs, a month.Pick and place machinePick and place and inspection machines for assembled PCBs are very common, and you shouldn’t really be going with EMS / CMs which don’t have that anymore.
  • Components
    You can generally just walk up to stores and buy component reels (thousands of them) at a time. Samples are a little costly (relative term, nowhere as expensive as buying them in retail in your home country). Like Alex puts it, “you don’t really pay for the samples, you pay for the service of cutting them”. These samples might not always be the brand you are looking for, so if your design cannot tolerate small variances, you will be better off buying branded components from verified distributors. For most prototypes and designs though, you should be just fine.Of course, not all components are stocked, but another tip I picked up, says that if you can’t find it anywhere, see if it is possible to redesign your device using alternatives that are heavily used and readily stocked. This will save you long lead times later.
    Another great idea when it comes to components (thanks again, Alex) is having a sample book, much like a photo album, where you label and stock strips of common components (resistors, capacitors, etc). That will save you a lot of grief if you prototype frequently, the time saved in not having to go to the market / wait for your order to arrive alone is worth it.
  • Makerspaces
    There are quite a few makerspaces, and they have a lot of great equipment. There’s Chaihuo (and x.factory ) run by Seeed Studio which is a bit away from the hustle and bustle of the market. TroubleMaker on the other hand is smack above the market, you can literally just walk down and buy all the tools and materials that you need. Special shout out to Henk from Troublemaker, they have a modest but very well equipped lab, and if you ever need anything done or made quickly, just head there. Alex hangs out there as well, and is super helpful with anything related to electronics.
  • Markets
    Certain buildings are great for buying specific things, obviously. Here are some I found below :

    • SEG Electronics Store : First three floors for components, tools, and hobby modules etc. Other floors above for consumer goods
    • SEGCOM : Everything related to mobile phones and accessories
    • Huaqiang building 1 : Components
    • Huaqiang building 2 : Components,tools, and consumer electronics
    • Duhui : Electronic Tools and measuring instrumentsView from the middle of HQB

    Of course, these markets are dynamic in nature and shops keep on moving around too, so your mileage may vary. HQB was also shut in part for a couple of years due to some construction work, and that has lead to reduced footfalls and shops closing down. Certain buildings have entire floors almost empty. Hopefully these buildings will see a rebound, it is an amazing one-stop-shop for everything electronic.
    Most things will be cheaper than ordering on websites, but if they are not, bargain 😉

  • Food
    You’re going to have a hard time if you are vegetarian, but you will survive. There are Indian restaurants, vegan restaurants, and Buddhist restaurants, and they understand the concept of vegetarian perfectly well, so you won’t starve. Hit me up for specific recommendations.
    The Iced Teas and fruit teas there are simply heavenly, have them every chance you get.
  • Shopping
    Dongmen is an area near HQB that is very popular for shopping, street or otherwise. They have great fashion, accessories and all other kinds of stores, and they are open until 11pm or so, so you can head there after HQB closes.
  • Travel
    There are bullet trains to Guangzhou that will take you there in 40-90 minutes, based on which of the two lines you take. The G line is faster, and goes straight to Guangzhou, whereas the C line makes a few stops in between. The trains go upto 307 kmph.Train
    There is amazing metro and bus connectivity, so you should be able to get to any part of the city fairly quickly and conveniently without spending too much. Cabs are easily available too though they are of course not as cost-effective. Road traffic is bad in working hours, and cars from other cities are not available on certain roads during this time.
    The three cities of Shenzhen, Dongguan and Guangzhou literally blend with each other, there are almost no perceivable city limits.
  • Language
    Talking to them is hard, very few people speak English. Download Baidu Translate, it works a lot better than Google Translate .Also Baidu Maps. And everybody uses WeChat to message, call, navigate, pay and more. You can thank me later.

If you are an Engineer, no matter which discipline, Shenzhen is your Mecca. Of course there’s a lot more to Shenzhen than this, and I’ll update this post if you hit me up and remind me what I missed, with your questions.

HT1621B Display controller Breakout Board

As a part of my work, I needed to drive an LCD segment display. Now, these displays are somewhat of a mixed breed between LCDs and 7 segment displays. They look sleek like LCDs, and are structured like 7 segment displays. However, they cannot be controlled just by toggling the segment pin of a particular segment high. They actually expect something of an “AC” signal to keep them on.

There are Arduino libraries that allow you to do this : You can find it here . However, if you are going to need 8-9 pins to control one character, you’ll find you will quickly run out of pins. Thankfully, these segments are very common, and so of course, there are controller ICs that will drive these displays, and let you offload the cumbersome task of generating the AC signals to drive those LCDs. The HT1621B is the perfect LCD segment controller IC for this job.

You just have to send messages serially to the HT1621B (in the right format of course), specify the necessary parameters, and the controller will take care of the rest. You can use the Arduino library for the HT1621B here.

HT1621B Breakout board

While working on this, I found it rather difficult to find an existing breakout board for the HT1621B, which is in the SOP48 package. I designed a board for it so that I could test it out. You can order the board with HT1621B controller ( if you are in India ) at the Amazon link here : .

If you want to get just the SOP48 breakout board, you can head over to OSHPark (link below).

Order from OSH Park

I hope this is useful !

Snooping on I2C – Making an OLED display work

As a part of one of my projects, I was trying to port the Arduino I2C OLED library to an ARM based platform. I had managed to figure out almost everything, the code seemed correct, the registers were all ported fine, timing wasn’t an issue, and yet there was only one problem : the display wasn’t actually showing anything.

To debug, I did the simplest thing first : tested the display with a standard Arduino Uno and the I2C OLED library. Worked like a charm. So the display was fine. Next up was testing the messages sent by the ARM chip and compare them against the messages sent by an Arduino. For this, I had the following setup.

First, I connected the display and the Arduino on the I2C SDA and SCL lines as usual via a breadboard.Further, I connected the I2C lines from another Arduino to the same SDA SCL lines from the breadboard, to snoop on the connections going on in the wire. I then wrote a small Arduino script to display the snooped messages.

The link to the script is here :I2C Snooping script for Arduino

When I repeated the exercise with the ARM chip, and compared the logs, I found that there were some flags that were being sent that were different. To reduce the chances of error, I dug through the code in the ARM causing the difference and fixed it. Now, the messages sent by both the Arduino and the ARM chip seemed exactly the same. Yet, the display was still just as dead. The issue was probably deeper than the byte level. The signal level then.

Luckily, my friend Mahesh at Electronut had a Saleae Logic Analyser that seemed to be the right tool for the job. I installed Logic from Saleae’s website  (install the standalone version on Windows, the installers often don’t work on x64 systems). I then used probes to record the signals from both the Arduino and the ARM chip. Below are images of the capture. I also used the internal functionality to analyse the signals by specifying that they were I2C signals. See the difference ?

Arduino (working)

Arduino signals

ARM chip (not working)

Repeated Start

Yep, there is a difference in the signals after two bytes are sent. A little bit of reading quickly revealed that the errant signal was a start bit (see footnote for explanation). I edited the code from the I2C application code in the ARM chip, and sure enough, the display started working.

Why couldn’t the Arduino catch this difference ?
I was using the Arduino I2C library for snooping. The Arduino I2C code I wrote probably ignored the start bit, thinking it was just another packet. Basically, my snooping code did not distinguish between a long packet of data or when it started or ended, because I broke them down too fine, at the byte level, not recording higher packet size level markers.

Moral of the story ?
1. Tools are great friends. Arduino, Logic analysers, even the humble ammeter sometimes. Take the time to learn how to use them. If you can afford them, buy them. They will save you hours, if not days, of wasted effort and time and frustration.
2. Dig deep. Then dig deeper.

I hope this is useful to somebody when debugging. Cheers !

Footnote :
The I2C OLED display requires instructions in a specific format. It is generally in the form of “Address, command” i.e. address of the setting to be changed, followed by the actual setting to be changed.

Now, I2C is a serial communication protocol and specifies how low lying signals are to be generated for reliable communication. The way to distinguish between two data frames is by letting the lines idle for a specified time, then pushing out a start bit. The ARM chip had a method to wait for pending transfers to complete. By calling that method, it assumed that this package transmission was complete, so the next time I called the method to send data, it emitted the Start bit again, as is polite between microcontrollers that are gentlemen and gentlewomen. Since the OLED actually expected a long packet, all I had to do was restructure my command to make sure it didn’t insert unnecessary breaks between packets.

Wireless Spectrum in India

I got curious about allocation of wireless spectrum in India, and I did a bit of digging to understand what bands were allocated for what purposes. My interest in this was partly to investigate what frequencies were license-free, so that they could be used for hobbyists, personal and civilian communication networks without applying for licensing.

I found this information in the National Frequency Allocation Plan (NFAP), which I have linked to below. Apparently, the NFAP is reviewed every 2 years, and the last document I found was the NFAP-2011. The Wireless Planning and Coordination Wing (WPC) of the Ministry of Communications and Information Technology puts out this information.

There is a graphic chart from 2002 (linked below), but it is not up-to-date, so use it with caution. For all intents and purposes, the NFAP-2011 is the most up-to-date information available (conditions apply).

The spectrum is allocated by means of gazetted notices and circulars, and as such there is no single Act or Law which deals with allocation of specific frequency bands. After perusing a few circulars which deal with allocating frequency bands for “unlicensed” usage, I find that the following bands are available for use without any licenses from the relevant authorities. Each of these come with maximum emitted power in specified bandwidths.

1. 50-200 KHz –  GSR90(E) dated 10.02.2009
Tyre pressure indicator systems for use by airlines during all phases of flight, vehicle security system and other low power devices are the intended use case.

Base unit: 1610, 1640, 1675, 1690 kHz, 43.720, 43.740, 43.820, 43.840, 43.920,
43.960, 44.120, 44.160, 44.180, 44.200, 44.320, 44.360, 44.400, 44.460, 44.480,
46.610, 46.630, 46.670, 46.675, 46.710, 46.725, 46.730, 46.770, 46.775, 46.825,
46.830, 46.870, 46.930 and 46.970 MHz.
Remote Unit: 26.375, 26.475, 26.575, 26.625, 48.760, 48.840, 48.860, 48.920, 49.020,
49.080, 49.100, 49.160, 49.200, 49.240, 49.280, 49.360, 49.400, 49.460, 49.500,
49.670, 49.770, 49.830, 49.845, 49.850, 49.860, 49.875, 49.890, 49.930, 49.970, 49.90,
150.350, 150.750, 150.850 and 150.950 MHz.

The above frequencies are earmarked for cordless Telephones, if you are developing such a system.

1820-1860 kHz
3500-3700 kHz
3890-3900 kHz
7000-7200 kHz
14000-14350 kHz
18068-18168 kHz
21000-21450 kHz
24890-24990 kHz
28000-29700 kHz
50-54 MHz
144-146 MHz
434-438 MHz

Amateur Service is permitted in the above bands.Amateur Service means “Amateur Radio” or Ham Radio, but you need to get a license from the WPC for using it (you have to pass an examination as well).

4. 3213, 5218, 13862.4 kHz, 73.675, 79.025, 159.55, 436.525 MHz
The above frequencies are earmarked for temporary demonstration of equipments and do not require licenses. These might be usable for experimental purposes, but too much information was not available about these bands.

5. 13.553 -13.567 MHz
The above band is available for unlicensed use for very low power radio devices. This band is used by the NFC standard (Near Field Communication) on contactless cards

6. 26.957-27.283 MHz
The above band is available for unlicensed use subject to a maximum radiated power of 5W.

7. 433-434 MHz
The above band is available for unlicensed use subject to a maximum radiated power of 10 mW with a channel bandwidth within 4Khz

8. 335.7125, 335.7375, 335.7625, 335.7875, 335.8125 and 335.8375 MHz,
The above band is available for unlicensed use for remote controlling cranes with a channel bandwidth of 10 KHz and maximum transmit power of 1 mW

9. 402-405 MHz
The above band is available for unlicensed use for very low power remote cardiac monitoring RF wireless medical devices,medical implant communication/ telemetry systems and other such medical RF wireless devices.

10. 926 – 926.5 MHz
“Certain spots” in this band are “open for consideration” for very low power cordless telephones.

11. 1427 – 1535 MHz
This band  may be “considered” for “experimental/ trial/ pilot-study purposes for indigenously developed technologies for point-to-point backhaul and point-to-multipoint access systems” based on request.

12. 2.4-2.4835 GHz
The above band is available for unlicensed use and is used for WiFi, Bluetooth, Zigbee, and many others.

13. 5.150-5.350 GHz , 5.725 – 5.875 GHz
The above band is available for unlicensed use and WiFi routers have started using this band. It may also be used for very low power radio gadgets, radio toys, Dedicated Short Range Communications (DSRC) for Intelligent Transport Networks etc.

14. 5.57 – 5.725 GHz
The above band can be made available on request.

15. 6.0-7.25 GHz
The above band can be used for Ultra Wide Band Equipment.

16. 865-867 MHz
The above band is available for unlicensed use for low power wireless equipment. Please note that 868MHz is not included in this unlicensed band, which is available in other regions for LoRa equipment.

1. Most allocations of frequency are done on a non-exclusive basis, which means they are to be shared.
2. The power levels of communications on the frequencies must be within specified limits to avoid interference. Your unlicensed communication, as a general principle, is not allowed to mess with somebody else’s licensed, or even unlicensed communication.
3. The spectrum allocations are non-permanent and can be changed.
4. Even though you do not need a license to use some of the bands above, you still need to apply for a license to make, sell or import the hardware that makes of these bands. This seems cumbersome, but I expect it is intended to ensure compliance to the regulations.

Links :

1. National Frequency Allocation Plan 2011
2. National Frequency Allocation Plan 2002 Chart

This note is very much a work in progress. I am compiling a much more detailed document for the technically/ business-oriented, please get in touch if you to know more specific information.

Also, I do not guarantee the completeness or acccuracy of this information, as this note is a compilation from available pieces of scattered information from hard-to-find government notifications.

( Not-so ) Cheap Electronics : The Real World

This post arose out of a lengthy Facebook discussion I had quite some time ago. I get this question a lot (and I have to get into this discussion fairly often), so here’s a blog post where I am putting down some perspective.

The original question that triggered the discussion was, that the Raspberry Pi Zero, priced at $5 is being looked at as the next unit of computing. The prices quoted by Indian retailers for this board is Rs. 1500 ( or about $22). The argument was that the boards costed less, were for education purposes (and should consequently enjoy discounted customs duty rates). Even assuming a profit of Rs. 200 (around $3), the boards should have been available for less than Rs. 1000 ($15). Then why was that not happening ?

Not So Cheap Electronics

I commented with a few points, and some others contributed some great points too, which I am summarising below.

1. Raspberry Pis (or other “low-cost” electronics) are “cheap” only for their shock value. Some of them (The Raspberry Pi for sure) have exclusive distributors and everybody must buy only from them. The cost at which a retailer gets his stock from Element14 is generally pretty high when buying in volumes of less than 100 and they are never able to buy at $5. In addition, some manufacturers (the Beaglebone, for example), will provide differential pricing slabs based on order size, and for orders less than 100/200, any retailer / distributor that wants to stock and offer these boards will be getting a higher buying price that is just a little less than announced retail.

2. Shipping charges (which are getting more expensive) and customs duties now get added to the goods (which already left almost no margin for the retailers to operate and profit) once they land in the destination country. Customs duties apply on the goods amount as well as on shipping (which increases the cost by 20% – 45% based on the nature of the goods). After that, based on your city, there are local entry taxes, known as octroi which are about 5% of (Original price + shipping) .

3. By this time, the goods already cost almost 1.4 times of the “low announced shock price” to the retailer/distributor.The retailer, if he/she is buying small or moderate volumes, has already gotten a heavy cost price which is nowhere close to the advertised “cost price” (and it is not their fault). When he/she sells to you, he/she also has to pay taxes on the selling price (not the cost price) and shipping costs within the country.

4. The retailer is taking a risk in stocking components, because he might or might not be able to sell all of them out. There are operating expenses as well, like rent, electricity, staff salaries, website costs etc. All of this is assuming the retailer sells directly on their website. If they put it on a marketplace, there are all kinds of fees : listing fees, commissions per sale, taxes, packaging material fees, etc. That makes it even more expensive on the marketplaces.

5. In addition, if bank deposit rates are around 8% (in India) , the retailer would expect to make more than that in order to justify doing business, otherwise they would be better off just depositing their working capital instead as a Fixed Deposit. A reasonable amount of profit is the only way a retailer can justify doing business AND keep on making things available. Adding middlemen no doubt pads up prices, but the middlemen (in a lot of cases) also make goods conveniently available that otherwise would require a lot of time, effort and money to source.

6. The amount of productivity lost in ordering a component internationally every single time (for prototyping, anyway) is very expensive in terms of cost (described above) and time (it generally takes 2-3 weeks to get there), both of which are sensitive for anybody working on electronics other than as a hobby.

7. There are a lot of big distributors of components, but almost everybody ships the goods to India from warehouses in Singapore. Local entry taxes and shipping are generally extra (unless order sizes cross a certain amount, which individual buyers generally do not cross).

8. Present conditions favour large distributors that are rather high in the distribution chain. For retailers / distributors who are near the bottom of the chain, there is a squeeze from both sides : high prices from above due to lack of “heavy” volume, and high expectations from the customers because of “promises” by manufacturers.

So, for customers (in India at least), you have capitalism in a free market affected by taxing government policies and logistics. You don’t have to like it, but you have to deal with it all the same.

P.S. I’d love to hear from you if there are factual errors or arguments I have missed, do DM me ! I’ll be happy to have this post evolve with more input.

Making a Hardware Product – Some notes

This is not a rant or definitive guide or advisory or anything else. These are just my observations and notes, noted as and when I come across something that is important. Hope it is useful to others, though it wasn’t written with any special care to help that.

– Keep track of the components used, especially critical ones. Long term support is absolutely essential for products that you expect to be making / using for the long term, and you’ll find yourself in a very bad place if the parts that you are using currently stop being manufactured a year down the line because of manufacturing / technological trends changing.

– As far as possible, try to maintain pin-to-pin compatibility between parts. Most reputable manufacturers will guarantee this, but if you have a choice between having this option and breaking compatibility, by all means keep the option open. It will save you a complete overhaul of your circuit design and a discard of your hardware that was on the assembly line waiting to be deployed.

Adding XPT2046 ( ADS7846 ) Touchscreen Support to Beaglebone Black

I have been playing around with the Beaglebone Black, mainly due to the fact that in addition to being powerful, the hardware designs for it are open source, unlike the Raspberry Pi, which means that if you need to design your own system using this as a platform, it is a lot easier to get hardware documentation and support to do so.

As a part of my experiments, I was trying to integrate a Waveshare 5 inch HDMI LCD with the BBB. The LCD itself looks good, and is packaged well but it was designed to work with a Raspberry Pi. The product is good, but the Waveshare folks are not very cooperative when it comes to sharing additional documentation or source code for the Linux drivers. As a result, the screen displayed stuff straight out of the box over HDMI (although Green shows up as blue, that remains an issue to be fixed), but the touch panel was another matter altogether.

Waveshare BeagleBone Black 5 inch HDMI LCD

The back of the screen says that the screen is based on the XPT2046 touch screen controller. A quick search reveals that the controller will work with the same drivers as the ADS7846 chip made by TI. That unfortunately was the only quick part. The controller worked over SPI, and we had decided to use SPI0 (since SPI1 on the BBB is shared with HDMI), but there were not too many useful (and relevant, not outdated) examples that showed how to enable SPI0 for use.

NOTE : This post assumes you are using Kernel version 4.1.0-rc5-bone3 , armhf architecture. If not, a lot of what I am talking about may not apply.

After three days of attacking the problem, I conceded that we needed help, and decided to reach out to Robert Nelson, who is quite an active maintainer of many BBB repositories. Turns out, we were messing around with the wrong Linux Kernel version. The “cape manager” which is the abstraction that lets you use the pins on the BBB, was stuck in “rewrite hell”, as RCN told me, and that pursuing anything between 3.8 and 4.1 was practically futile. I tried out 4.1.0-rc5-bone3 on his suggestion, and at least got the cape manager back. Following tutorials after that did not help much either, since a lot of things had changed.

Finally after one more day of battle, I was able to get the touch panel to work. Turns out, the 4.1.0 kernel already includes support for the ADS7846, which means you don’t have to compile the kernel module for it. The BBB uses something known as a Device Tree that lets it abstract away the physical hardware from the multiple functions it can perform, and lets you enable and disable it just using config files. The Device Tree Overlay is, as the name suggests, an overlay. It is not hardwired, but can easily by enabled or disabled at runtime based on your needs.

For the sake of simplicity, I have posted the code (or rather the device tree source or dts file) on Github here:

It has comments wherever I can explain what’s going on.

The file will need to compiled with the latest version of the device tree compiler, otherwise you’ll get an error later on when you are trying to load the overlay. You can follow the steps in the Readme here : BBB Overlays

The physical connections are below :

Screen <———> Beagle Bone Black
MOSI <———> SPI0_D0
MISO <———> SPI0_D1
CE1 <———> SPI0_CS0
P6 <———> Pin 23

HC 05 Master Slave Seamless Communication

I have been playing with the HC 05 Bluetooth module in the past week, and found some really good tutorials that teach you how to get started. Many of them cover how to use the HC05 as a slave, with a computer and a script at the other end.

That’s very useful, but there are many scenarios in which you might want two HC 05 modules to communicate with each other, unassisted. You can’t and don’t want to make the module search, pair and connect before you can actually start doing some meaningful communication.

Below, I will describe how to get one HC 05 module to act as a master and another one as a slave. The master will automatically look for, pair with, and establish a connection with the slave, and you can just get on with the communication right away.

Here are how the connections will work.


Notice that the connections are crossed on one end but not on the other.

P.S. I am assuming you already know how to use the Serial monitor with an Arduino or any other serial terminal with the CP2102 , so I am going to jump right in.

Here are the steps we will follow to accomplish what we need :

Master Configuration

1.Put the module in AT mode :

The HC 05 modules are generally in “transparent mode”, which means that they will take serial data on the Rx and Tx lines and pass them over the wired or wireless link directly, and will not treat anything as an
instruction”. To configure them, they must be put in Command mode. The “Key” pin on the HC 05 modules is not broken out, and needs to be “HIGH” when powered on to enter AT “command” mode.

HC 05 Key Pin

For that, you can either solder a wire and connect it to VCC when powering on the module, or you can simply touch a jumper wire between the Key pin and ground while powering it on. If the module has entered the AT mode, it will be a solid red with no blinking. If not, it will blink very fast, and you should retry. You can disconnect the wire once the module is in AT mode.

2. Make the configurations for pairing :

a. Clear all previously paired devices
On your serial terminal, enter the command : AT+RMAD

If the command was accepted, you will get an “OK” as a response.

b. Set PIN
Replace 1234 with your chosen 4 digit PIN.

c. Set role as “1”

This sets the module as master, which will actively seek for connections with paired devices.

d. Set connect mode as “1”

This sets the master to connect to any device with the pin. This is necessary for pairing the first device.

d. Reset

This resets the module and the master starts looking for modules to pair with.

Slave configuration

1.Put the module in AT mode :

Just like the step above for the master.

2. Make the configurations for pairing :

a. Clear all previously paired devices : AT+RMADD

b. Set PIN : AT+PSWD=1234

c. Set role as “0” : AT+ROLE=0

This sets the module as master, which will actively seek for connections with paired devices.

d. Set connect mode as “1” : AT+CMODE=1

d. Reset : AT+RESET

After this, if both modules are powered on, they will connect and transfer data to each other transparently i.e. It would be as if the Rx and Tx connections of the two microcontrollers were directly connected to each other and the modules themselves would invisibly do their job.

However, we must go one step further to add reliability. We will now change the CMODE setting to make sure the modules only connect to paired devices. Since we have paired with exactly one device, this ensures that in noisy environments with other devices around, nobody can hijack or block your connection.

Master & Slave

1. Put the device in AT mode as above.

2. Set connect mode as “0” : AT+CMODE=0

3. Reset : AT+RESET

1. Set the pin of the master and slave to the same PIN.
2. Set the Role of one module as Master and the other as slave
3. Set the Mode of the modules as “1” to connect with each


2. AT Command sheet

3. Alternate way of doing this using AT+BIND

4. Using the CP2102 with your Serial Terminal