Monday, October 29, 2012

Teensy 3.0 Arrives!

I just got my Teensy 3.0 today, and Im excited to work with it to get a feel for ARM M4 development. 

One of the most striking differences between this and the Teensy 2.0 is the board color and size. Its black and about a quarter of an inch longer than the former board. Also to note it obvious has the USB 2.0 Micro-B connector not the USB 2.0 Mini-B as the previous Teensy has.

Another immediate difference is the size of the chip. Its much larger and has twice as many pins. The board itself has many more pins packed in that tiny space than the Teensy 2.0.

Finally, the most promising, and most important feature, is the fact that this is an ARM Cortex-M4 with Arduino-style programming. You can see more on development using this powerful device on DangerousPrototypes, and the PJRC Forum.

The Kickstarter page is also available here if you want even more information.

Here are some of the specs of the Teensy 3.0:

Manufacturer: Freescale Semiconductor
Core: ARM Cortex M4
Processor Series: MK20DX128VLH5
Data Bus Width: 32 bit
Maximum Clock Frequency: 48 MHz 
(Up to 94 MHz Overclocked)
Program Memory Size: 128 KB
Data RAM Size: 16 KB
Digital Pins: 34  
PWM Pins: 10
Analog Pins: 14
DAC Pins: 0    
On-Chip ADC: Yes
On-Chip RTC: Yes
Operating Supply Voltage: 5V
USB Version: 2.0
USB Type: Micro-B

Photo Credit: John Beale

Friday, October 26, 2012

Beaglebone LCD3 Arrives!

Finally, after waiting for about 2 months, Ive gotten my LCD3 cape for my Beaglebone. Now I can start working with a screen. While it is the smaller of the two screens you can get, 7-inch for the larger, and 3.5-inch for the smaller, its still a useful screen to work with. 

After discovering today that Texas Instruments released an image of Android for the Beaglebone, Im strongly leaning towards writing that image to another SD card and trying my luck at getting Android working on the Beaglebone. The great part is the TI tutorial for their Matrix GUI takes place on the Android system, so I feel thats my best bet for getting the config I want actually working. Plus, Android has a MUCH more friendly GUI over Angstrom Linux. Even Angstrom with Gnome isnt all that great, from what I can tell visually.

As far as updates with the current Beaglebone build, Ive been unsuccessful as of late in getting my WiFi connecting - I think its a problem with my Xubuntu laptop. Ive setup the driver & the WiFi module lights up, but when I go to restart the WiFi config file, Angstrom & my XUbuntu terminal both hang. When I unplug the Beaglebone, the XUbuntu laptop crashes, and Im forced to reboot.

Either way, I will have to start from scratch with this WiFi issue on Android if I want to move in that direction. I'll post updates on this, as Im quite sure a lot of folks are interested about this topic. 

The build as it stands now:
~Beaglebone with Angstrom Linux and WiFi (no WiFi in the image below)

~An expansion cape with an XBee

    ~An LCD3 3.5" Touchscreen with Interface buttons

      Just have some Linux FYI:

      To shutdown, type:

      sudo halt
      sudo shutdown -h now

      To reboot, use:
      sudo reboot
      sudo shutdown -r now

      For more information on these commands, use:
      man reboot 
      man shutdown

      To see the current network connections, use:
      sudo ifconfig

      Wednesday, October 10, 2012

      Arduino Low Power Tutorial

      Ive been working with power save mode for the Arduino lately, and Ive found that while there are multitudes of examples out there, nobody specifically gives you a working example to run with. In this post, I'll walk you through my code, and at the end, I'll provide you with a great working example of using an interrupt button to bring the Arduino back out of a low power state for a few seconds and then back to sleep. This is great for applications that require the use of a battery for long periods of time and charging is scarce.

      You can follow the interrupted sleep tutorial by NoMi Design to learn just how to set things up.

      My code, however, is just like this example, provided on, except that Ive added some serial communications to see that its working visually and to re-enable the interrupt attach so that I can constantly bring the device out of sleep every time it goes to sleep.

      //remove the space between '<' and 'avr'.
      #include < avr/interrupt.h>
      #include < avr/power.h>
      #include < avr/sleep.h>
      #include < avr/io.h>
      void setup()
          DDRD &= B00000011;       // set Arduino pins 2 to 7 as inputs, leaves 0 & 1 (RX & TX) as is
          DDRB = B00000000;        // set pins 8 to 13 as inputs
          PORTD |= B11111100;      // enable pullups on pins 2 to 7
          PORTB |= B11111111;      // enable pullups on pins 8 to 13
          pinMode(13,OUTPUT);      // set pin 13 as an output so we can use LED to monitor
          digitalWrite(13,HIGH);   // turn pin 13 LED on
      void loop()
          // Stay awake for 1 second, then sleep.
          // LED turns off when sleeping, then back on upon wake.
          Serial.println("Entering Sleep Mode");
          Serial.println(" ");
          Serial.println("I am now Awake");
      void sleepNow()
          // Choose our preferred sleep mode:
          // Set pin 2 as interrupt and attach handler:
          attachInterrupt(0, pinInterrupt, HIGH);
          // Set sleep enable (SE) bit:
          // Put the device to sleep:
          digitalWrite(13,LOW);   // turn LED off to indicate sleep
          // Upon waking up, sketch continues from this point.
          digitalWrite(13,HIGH);   // turn LED on to indicate awake
      void pinInterrupt()
          attachInterrupt(0, pinInterrupt, HIGH);

      Dont mind any avr's at the end. Its a glitch the website keeps doing when I post #includes at the top of the code on the blog.

      Sleep Modes

      Finally, its important to discuss the types of Sleep Modes that you can choose from. There are 6 sleep modes available on the Arduino Uno (ATMEGA328):
      • SLEEP_MODE_IDLE                   – least power savings
      • SLEEP_MODE_PWR_DOWN    – most power savings
      SLEEP_MODE_IDLE provides the least power savings but also retains the most functionality.  SLEEP_MODE_PWR_DOWN uses the least power but turns almost everything off, so your options for wake interrupts and the like are limited.  Power reduction management methods are described in more detail on the avr-libc documentation page. For details on what features are available with each power saving mode for the Arduino Uno, please refer to the ATMEGA168/328p Datasheet (look out, its a 12mb file). For all other Arduino's refer to either the Arduino website, or the Atmel website.

      Ive decided to go with SLEEP_MODE_PWR_SAVE for this example, just because it gives me some flexibility with waking it, and because the power savings are a bit better than idle. Power down is overkill for my applications, and its comparative to actually turning off the device, which I don't need my hardware to do.

      You're welcome to ask questions, about this code if you arent sure whats going on. The bit of setting up the pins in the Arduino hardware is explained more on the Engblaze post.

      Saturday, October 6, 2012

      YAWS Assembly

      Most of the rest of my hardware arrived yesterday, so Ive begun to assemble things. During my Live Tests outdoors with the Weather Board, I came across a few things which I feel I should note.

      Ive revised the Sparkfun code to show the Wind Direction in Degrees (as in the code) and in Headings (N, S, E, W). This is a simple set of if-statements to display headings when the correct range is found.

      Ive also updated the code to remotely reboot the board on command, as Ive found that it has issues with starting a connection once its out in the field. The software has to be running first before the Weather board, thus a reboot is required. This is simply including setup(); in the reboot function.

      One of the things I wanted my Weather Station to do was display data via an LCD locally, so I can debug and view data in Real Time to make sure the station is functioning (and so I don't have to keep running back and forth to my computer). So I included a case in the code to display to the LCD screen and the serial port at the same time. I wont know for sure if this will work, but the code does compile. The way Im connecting the LCD screen to the Weather Board is via I2C using this tutorial. This requires a nifty little IC, the PCF8574P, an I2C 8-bit port extender and a 3.3V LCD screen. I'll post pics of it once its assembled and working.

      I guess now is as good a time as any to warn about the importance of a grounding kit on the weather station. You don't want lightning frying your expensive electronics, or burning down the shed (or your house), so you'll want to take good grounding measures. Do plenty of research to make sure you know what you are doing. I am not liable if you ignore this warning and lightning does hit your stuff (God forbid it of course).

      So that said, I used a 4-ft long piece of grounding rod (it comes in lengths of 8ft for about 10 bucks at Home Depot). Hammer it until about 1.5 ft of it is sticking out (the softer the ground, the shorter the rod should be; if the ground is hard, dry dirt, you might have to go to a 6ft rod or use the full 8 ft - this will change the amount of rod sticking out of the ground). You dont want to hammer it all the way in because the rocks in the ground will wear away the copper coating of the rod and that will accelerate decay of the steel rod. I also bought some #4 multi-stranded electrical cable, grounding clamps and a pencil-thin steel rod. All this stuff comes together as the grounding kit. A necessary expense to keep things safe.

      It looks like the weather station meters will just be attached to the steel pole of the mounting kit using stainless steel pipe clamps (the image below simply shows the mounting kit, now how Im going to mount it).

      Im still trying to work out all the minor things, like some extension cables for the sensors and the solar panel to reach where Im mounting the Weather Board.

      FYI, There will be a post soon about setting up the Beaglebone, as Ive gotten half of the stuff I need to start that side of my project. Configuring it is a pain, but it has to be done.