Friday, November 15, 2013

WIFI for Our Projects

I remember reading (many years ago); With the invent of the Internet, we would eventually have many in-home devices that would be addressable and controlled via an IP Address. The prediction suggested that even the common Light Bulb would someday be networked.

To date, there are many "computer devices" that are controlled via an IP Address, and many of them are connected via WIFI.

But so far, many Light Bulbs (or LED) still do not have IP Addresses.  The big reason for this is the expense of the compute power needed by each addressable device. A computer or controller is needed to perform the complex network functions, like; TCP/IP Stack, DHCP. Authentication, and General Data Transfer. For most hobby project developers, the complex networking software development is the most difficult impediment.

But, a relatively new device, the TI CC3000MOD (at $20.00) does all the network hard stuff at a relatively low cost. The CC3000 is programmed and data is sent to/from a project device via a simple two wire SPI interface. The actual chip is a little hard to work with, because of its physical small size, board layout, antenna requirements, and soldering methods.

But, Adafruit.com has a new product which uses the CC3000 to make it easy to include WIFI Networking in a controller project.  (Yes I know, my blog is starting to sound like a Adafruit commercial, but they are one of the leaders, and provide some great inexpensive project components. And, No, as stated in other blogs entries, I do NOT work for them. I just really like some of their products.)

Adafruit CC3000 Breakout Board, with Integrated WIFI Antenna *
The Adafruit.com CC3000 Breakout Board (at $35.00) is a small pre-assembled board that can be attached to any project with only a simple 9 pin header. Programming, control, and data transfer is via the 2 wire SPI interface. Complex TCIP/IP stack programming is NOT necessary, as all of the hard work is done by the chip and/or included libraries.

Note: other configurations are available which include external antenna connector and Protoboard space.

I plan to order a couple to experiment with for my future projects.


* As stated before, the photos has been taken from the Adafruit web site without their permission, hopefully they will not mind for this use and recommendation.


--

Sunday, November 3, 2013

Trinkets

OK, my parts were received from Adafruit.com, see previous post.

The USB Power Gauge works as expected, it is very handy to check the charge rate on my Cell Phone, and for checking power consumed by any USB device, including my Raspberry Pie and/or the BeagleBone computers. The USB Power Gauge provides information that is otherwise a little difficult to obtain.

I had also purchased three Adafruit Trinkets. I followed the recommended software (Ardunio IDE) install instruction, and modification needed for the Trinket. And then, I proceeded to "Brick" all three Trinkets (or at least that is what I thought). I have used the Ardunio Interactive Development Environment (IDE) many times in the past and was not expecting any problems.

Because the "Trinket" has only 512 Bytes EEPROM (boot loader ROM) part the loader (about 1.5K bytes) is placed in FLASH RAM, which leaves about 5.5K bytes for user programs.

While loading a user program into the remaining FLASH RAM, if something goes wrong, part of the boot loader can be overwritten, and therefore it is somewhat easy to "Brick" the Trinket.

Instructions are provide to "UnBrick" the Trinket, but that requires yet another Arduino and downloaded programs.

While reading many pages on the web trying to understand my problem, I discovered that for Linux machines may not support USB in the way that the Arduino IDE for the Trinket desires. The recommended method is to use a external USB Hub to connect the Trinket to a Linux computer.

It worked, . . . how or why, I do not know !!

The Trinkets were NOT actually Bricked, . . . they just looked and acted like it. While plugged into a Hub, they now respond as desired by the Arduino IDE.

My first task was, of course, to run "Blinky", the "Hello World" program.

Once that worked, I quickly put together the following CW sketch to send/blink "CQ" on the LED.


/*
  This Sketch Blinks CQ on the LED
*/
 
int led = 1; // blink 'digital' pin 1 - AKA the built in red LED

int WPM = 13; // Words Per Minute
int ditTime = 1200 / WPM;
int dahTime = ditTime * 3;

// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
  delay(2000);

}

// the loop routine runs over and over again forever:
void loop() {

    for(int j = 0; j < 3; j++) {
      dah(); // C
      dit();
      dah();
      dit();
      eoc();
      
      dah(); // Q
      dah();
      dit();
      dah();
      eoc();
    }
    eow();
    
    delay(10000);
}


void eoc() { // End of Charactor
    delay(ditTime * 3); // added to previous End-of-Char time
}

void eow() { // End of Word
    delay(ditTime * 7); // added to previous End-of-Char time
}

void dit() {
    cwpulse(ditTime);
}

void dah() {
    cwpulse(dahTime);
}

void cwpulse(int duration) {
    digitalWrite(led, HIGH); 
    delay(duration);
    digitalWrite(led, LOW);
    delay(ditTime);
}


// End   

A more complete and non-trivial CW sketch would be table driven, but this was quick-n-dirty just to just get something to work.

More complex and interesting programs will hopefully follow.

I think the Trinket will have a place in my bag of tricks, for small Ham Radio Projects. I am currently thinking of maybe a Beacon Trinket Shield, and/or a Tennis Ball Launcher Trigger Controller.

--