# TCP/IP stack for wifi module

I keep reading about TCP/IP stack for wifi module. I am having bit difficulty to understand that.

I am working on hobby project in IoT and need to choose wifi module for Atmega328P. I heard about CC3000 module which is very costly. So I thought I should buy raw wifi chip and use that with Atmega328P and use MQTT to communicate with it. This is just a theory. But this stack thing came in between and I don't know what it is?

What is TCP/IP stack for wifi module? I am new to this area. So, it would be great if you can elaborate the answer.

First and foremost: Do not use the CC3000 module. I tried it, and failed miserably after many hours of work involved. The driver which comes with the module is unusable. You might want to browse the related TI forum and read through all the various people having problems, especially with hanging communication. Go for one of the successors (CC31xx/CC32xx) instead.

Regarding the TCP/IP stack. Look at the OSI model. It defines several layers, starting from the physical layer (which is how bits are transferred over a connection) up to the application layer (which is what the data actually means). Each layer builds upon each other. Now, various parts will abstract the complexities of each layer up to a certain layer. If you simply have a PHY chip, you will need to implement all Layers starting from layer 2 (the data link layer). You will probably run into timing issues. This can be resolved by using a controller which already implements Layer 1 + 2 + 3, or even up to layer 4. This is basically what many microcontrollers use. You will be able to prepare a TCP or UDP packet in software, then pass all the rest of the work to the module. Far less work for you.

If you really want to go with "raw data" (still, you will be praparing data for one layer or the other) I would account for (far) increased development time. There are also several TCP/IP stacks available (both for free and commercially available) but you will still need time to implement this into your remaining application.

• I understand. I also heard about ESP8266 and will give it a try. – Jaynti Kanani Apr 5 '15 at 6:47
• A full TCP/IP stack in controller software is a resource hog, especially FLASH and RAM memory. That is another reason to use a ready made module. (cc: @JayntiKanani) – jippie Apr 5 '15 at 7:30

As an addition to Tom's post: I've used the CC3000 but I'm driving it myself. It's a little complex and real power hungry (spikes of +300mA) but I've been made use it rather than my chosen chip, the CC1110. Groan...

However, Adafruit have a lovely little CC3000 based module and they have code for the Arduino (and thus ATMega) that worked very nicely when I tried it last year. I had no issues whatsoever but then I was using Adafruit's work to help me. Use them, they're great.

I've used raw WiFi chipsets (LSR TiWi). These are chipsets that require a Linux or Windows machine behind them (I was using an ARM Cortex A8 embedded system) to provide the communications (TCP/IP and all the rest Tom describes) stacks. The LSR connects via 25MHz 4 bit SDIO so a bit of a journey from an ATMega.

I hear lots about the ESP8266. It's terrifyingly cheap and thus worth a shot regardless of how well it works for you. At that price point, all sorts of hobbyists and professionals are leaping on and producing lots of examples and docs. Adafruit sell them now. Note that its a 3.3V module, not 5V. The ESP8266 uses an "AT command" style of serial interface. So you can do something like this:

AT+CWJAP="WiFiAccessPoint","MyPassword"


to join an access point. And

AT+CIPSTART=4,"TCP","google.com",80


to create a TCP connection to google on port 80 using channel #4. It's all pretty cool actually!

• Yeah, I find it very easy to use in many tutorials. There is also Broadcom WICED module available. Have you used it? How it is? – Jaynti Kanani Apr 6 '15 at 3:55
• Sorry, haven't used that one. – carveone Apr 6 '15 at 9:33