Nov 15, 2011

2.4GHz (WiFi) Arduino Spectrum Analyzer - Part 3, CYWM6935 Wireless Radio Module


CYWM6935 Wireless Module

This module is the heart of the Spectrum Analyzer.  Since I "borrowed" the code from  Richi's Blog, I can't really explain how the code is working. But, it does work! Richi's code examples are available on github.

I fork from Richi's "Fritzing" picture example in my final prototype (no wiring picture available for that, see video below) in that I don't make any attempt at level shifting, I run my Atmega chip at 3.3V directly from a battery.

The tricky thing with the CYWM6935 is the spacing on the already-soldered pins - they're too narrow for standard 0.1" female jumpers that you may get from sparkfun or Pololu. For prototyping, I used some very narrow female-to-male jumpers from SchmartBoard, these worked great. In the finished product, I used narrow-spaced IDC 10-pin female header cable, similar to this one at sparkfun,  to connect up the CYM6935.
IDC 2x5 Pin Female Cable


Here's a video showing the transition from prototype to (more-or-less) finished product:







2.4GHz (WiFi) Arduino Spectrum Analyzer - Part 2, Display

As a practical approach to this project, I could have started with getting the CYWM6935 module working or testing out the graphical LCD. If I could not get either one working, I would have just stopped. There was code for both of these, but the Nokia LCDs had more examples and a simpler datasheet(!). I figured if I could get the LCD working and fail on the wireless module, I was still ahead. Graphical LCDs can be used in lots of projects.

My first step was to get a Nokia 3310 to play with. These are readily available on ebay and elsewhere for around $10. What you get is a faceplate, LCD on glass, and fine-pitched connections. The pads on the LCD normally are connected with Elastomeric (Zebra brand) connectors.


Click on picture to enlarge
Although I've soldered a fair number of kits and boards, I found it very difficult to wire connections to the 1.15mm pitch of the pads, but others have found workable solutions. I tried Starlino's approach of salvaging ribbon cable from an old DVD drive, but couldn't find cable that matched the pitch, it was off just a bit. Others have made breakout boards by etching purpose-built PCB's that change the pitch from 1.15mm to 2.54mm (0.1").

So it was off to ebay to see if I could find any clones of the Nokia 3310 LCD. The first one I found was this nice one from MDFly which came with a 10 pin 2mm pitch IDC connector for around $10.
The IDC ribbon connector was female on both ends, making it easier to use the 2mm pitch of the header: push one female end onto the keyed box header on the LCD's base, push thin male jumpers into the other end. After that, I could use the male jumpers to attach to a standard 0.1"/2.54mm spaced breadboard. OK! Progress.

However, this wasn't going to work well for me in my desired case. I wanted the smallest possible enclosure for the WiFi Analyzer, and the 10 pin IDC cable, folded over or turned into origami, would take up too much space. So it was back to ebay to see what else was available.
Found this Nokia 5110 clone from MIB Instruments, also available for about $10, free shipping from Hong Kong. The MIB Instruments N5110LCD has the same specs as the original Nokia 3310 and the MDFly versions: 84x48 pixels; uses Philips PCD8544 LCD controller; operates on 2.7V to 3.3V. What's nice for me is that the N5110LCD has 8 solder holes at the base of the unit, with standard 0.1"/2.54mm pitch. I could solder header pins onto the LCD. Those headers would fit into matching female headers soldered directly onto a PCB. That would save a lot of space from not having to route wires around.

Note: I used female headers to connect the LCD on my final hand-soldered board. I could have soldered the LCD headers straight onto the board and saved some vertical space. But I usually build my projects with reuse in mind. If the LCD is attached via female headers, I can easily remove it and use it somewhere else.


Another good source of Nokia 5110 LCD clones is adafruit.com. Included for the current $10 price is a level shifter. LadyAda has also written a nice, easy-to-use graphics library for these devices. Highly recommended!


2.4GHz (WiFi) Arduino Spectrum Analyzer - Part 1, Getting Started

Parts List:
Arduino seeedstudio clone
              OR
Parts for a minimal arduino:
  • A breadboard
  • 22 AWG wire
  • 7805 Voltage regulator
  • 2 LEDs
  • 2 220 Ohm resistors
  • 1 10k Ohm resistor
  • 2 10 uF capacitors
  • 16 MHz clock crystal
  • 2 22 pF capacitors
  • small momentary normally open ("off") button, i.e. Omron type B3F  
  • FTDI USB connector (for programming the Atmega micro)
  • 74HC4050 TTL Level Shifter
Plus: 
 




Minimal Arduino


If you'd like to get this working on a breadboard as a prototype, there's a good introduction to a minimal Arduino platform in an ITP Tutorial. One drawback of this approach is the need for some kind of programmer for the Atmega168/328 microcontroller, a tool to get code into the micro. This would be a one-time purchase that's reusable for other projects, but depending on your tool choice, would be around $20 USD. I mention the Arduino Breadboard because the ITP Tutorial has a good description of the layout of parts for a minimal Arduino. It's what I used as a basis for the layout of my own hand-soldered board. I then just added two other critical components, the graphical LCD and the Cypress Semiconductor CYWM6935 Wireless Radio Module, tied to the appropriate pins on the Atmega chip.

One advantage of the breadboard approach is that it's reusable for other projects. Also, unlike the approach shown below, you can swap in/out the Atmega chip in the circuit. That way, you could take another Atmega chip, load it up with a program on the breadboard, pop the newly-programmed chip out and put it into a separate, more permanent purpose-built circuit.

Getting to 3.3V
Electronic parts expect one of two different voltages to represent a digital 1 (on, or high): either 3.3v or 5V; digital 0 (off, or low) is represented by a voltage at or near zero. For this project, the LCD and CYWM6935 expect 3.3V logic as input but the board will be running at 5V, so we have to adjust the 5V down somehow. For this task, one integrated circuit you can use is a 74HC4050 Hex High-to-low level shifter ( I used an NTE4050B, available at my local Fry's). There are other approaches to this problem, but this is conceptually very simple: high voltage logic in one side, low voltage logic out the other.

For a digital logic signal from the 3.3V components, the Atmega168/328 is tolerant of 3.3V as a digital 1, so no special handling needed there.

At this point, you're looking at $10-15 for component parts; $5-8 for a breadboard; and maybe $20 for a programmer. And that's before you get to the key components, the LCD and CYWM6935, which are about $10 each.

Seeedstudio to the Rescue
Another option to drive the prototype is to use a seeedstudio Arduino clone, available for about $22.50 before S/H. The "seeeduino" clone has a switch to adjust the logic output to 3.3V or 5V and has worked fine for my prototyping. Expect about 14 business days after shipping to reach the U.S. A bonus for the seeeduino is that, in addition to female headers connected to the digital pins of the Atmega chip, as on the Arduino, there are through-hole solder points for each of the pins. That's useful in this project, because the LCD and CYWM6935 share some of the same connections, so you could have one component wired to the female headers and the other soldered to the through-holes. Or, solder additional female headers on the through-holes. You could build the entire project on the seeeduino, save some costs, and the basic parts costs would be about $45, including the LCD and CYWM6935.
Seeedstudio Seeeduino V2.2

Note that the seeeduino uses surface-mount versions of the Atmega chip. That means, unlike on an Arduino or your breadboard version, you can't pop out the Atmega chip (after loading your program code) and reuse it in a soldered, purpose-built version of your circuit.


2.4GHz Arduino Spectrum Analyzer - Overview

A while back, this work of Miguel Vallejo was featured on hackaday and other blogs. This was a Spectrum Analyzer for the ISM Band crammed into a repurposed Nokia 3410 cellphone. This intrigued me, I wanted to make one for myself.

The Journey is the Reward
I took this project on as a learning experience. I had never done anything this ambitious before, although I had soldered several kits from adafruit.com and had played with quite a few sketches on the arduino platform. Since electronics is a hobby for me, I choose what projects I'll undertake by at least three criteria, in descending order:
  1. how much I can learn from the effort?
  2. can the things I learn be extended to other projects?
  3. is the end product useful, novel or amusing in some way?
That last criteria, is the product useful, sometimes is not very important to me. I've often built things just to see that I can, or just to see what the gizmo does. For example, I love building computers. But when you're done, all you have is a computer ;-) !

What is important is the experience of building something, of facing challenges and answering them in a satisfying way. The main beginning goals of this project were to get some exposure to graphical LCDs and the wireless module, CYWM6935 from Cypress Semiconductor. A LOT of learning happened along the way and choices had to be made.

For the impatient, here's a video that shows the Spectrum Analyzer progressing from raw prototype to "Version 0.99 Beta", or close to "first engineering prototype". Video is about 2:07 in length:




Basic Parts Costs
Depending on how you choose to implement this project, your component and raw materials costs could be as little as about $30 USD, or over $50. That doesn't include additional tools like a breadboard or a microcontroller programmer, if you don't already have them.