Saturday, December 5, 2015

HOW TO: View Arduino Serial Data from Command Line

In the past I have always viewed the information I printed to the serial port within the Arduino IDE by opening the Serial Monitor.  However, you can view the same information from the command line.  To do so simply follow these steps.

Put this in an Arduino sketch:

void setup() {
Serial.begin(9600);
}

void loop() {
Serial.println("ImagineN4tion, right MEOW!");
delay(500);
}



Upload it to whatever development board you are working with.

Then, on Mac, open Terminal and execute the following command:

ls /dev/tty.*



This will list all the serial connections.  Identify which serial port you would like to listen to.  Then execute the following command to listen to that port:

screen /dev/tty.[yourSerialPortName] [yourBaudRate]

You will enter your specific information to replace what is between the [ ] in this command.  Thus, for me it becomes:

screen /dev/tty.SLAB_USBtoUART 9600




A screen window will be opened within your terminal and you will be able to see whatever your development board is printing to the serial port, yahoo!  The sketch I provided above simply prints "ImagineN4tion, right MEOW!" repeatedly.







HOW TO: Up and running with Adafruit HUZZAH Feather ESP8266

INTRO:

Hello weary cyber-ether traveler!  The following is a quick HOW TO that describes how to connect a device to the internet that you can use to control things in the physical world.  We will be using a wifi enabled device called the "Adafruit HUZZAH Feather ESP8266" to connect to the internets.  Don't you worry if none of that makes sense to you or you are unfamiliar with some of the lingo and materials.  We play nicely with people whom are still learning and in pursuit of knowledge :).  


Hardware used:


  1. MAC Comp-ooter
  2. Adafruit HUZZAH Feather esp8266 (we will refer to as Huzzah from here on out) - https://www.adafruit.com/product/2821
  3. USB A/micro cable - https://www.adafruit.com/products/898


Software used:

Important:  Make sure to use an Arduino IDE version other than 1.6.6 as that version seems to not function well with the Huzzah ESP8266 boards.


  1. Arduino IDE version 1.6.5 - https://www.arduino.cc/en/Main/OldSoftwareReleases#00xx
  2. Silicon Labs VCP Driver Install Disk - https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx



Initial Setup:

Download and install the software components listed above.

Then, open the Arduino IDE and click Arduino->Preferences and enter the below URL into the "Additional Boards Manager URLs" field in the pop-up box (See images 1-3).  

URL to copy paste into the Additional Boards Manager URLs field:
http://arduino.esp8266.com/stable/package_esp8266com_index.json


Image 1: Open Preferences

Image 2: Preferences Pop-up

Image 3: Adding the URL into the "Additional Boards Manager URLs" field.


Next click Tools->Boards->Boards Manager... and find "esp8266" in the boards manager.  Then click install.  (See images 4-5)

Image 4: Navigate to the Boards Manager...

Image 5: Find "esp8266" and install.



Now close down your Arduino IDE and restart.  Once you have done this, click Tools->Board->Adafruit Huzzah esp8266 (See image 6).



Image 6:  Choose the Adafruit HUZZAH ESP8266




Next, click Tools->CPU Frequency and choose 80mhz (See image 4).

Image 4: Selecting the CPU Frequency



Then, click Tools->Upload Speed and choose 115200 (See image 5).

Image 5: Selecting the Upload Speed



Connect the HUZZAH Feather to your computer with the USB A/micro (See image 6).

Image 6:  Connect your Huzzah to your computer



Then, click Tools->Port and choose the port your Feather is connected to.  It will likely say something like "USBtoUART" at the end (See image 10).  If not, there's always trial and error with a limited amount of ports.  Note, we had to deselect and reselect the port a couple of times when trying to successfully upload the sketch to our Huzzah.

Image 10:  Choose the port your Huzzah is connected to.


The Fun Stuff!

Now that we have properly set everything up let's try and get some code on our Huzzah.  Within the Arduino IDE, copy paste the following sketch, courtesy of the nice folks over at Adafruit (See image 11).


void setup() {
  pinMode(0, OUTPUT);
}

void loop() {
  digitalWrite(0, HIGH);
  delay(500);
  digitalWrite(0, LOW);
  delay(500);
}




Image 11: Copy code into the Arduino IDE


Then, in the upper left hand corner of the Arduino IDE, click "Verify" (See image 12) wait for the process to complete and then click "Upload" (See iamge 13) and the code will Upload to your Huzzah.  If everything goes off without a hitch, a red LED on your Huzzah will blink on and off.  Initially we received errors but after deselecting and then reselecting the Port (See image 8), it worked.  Note that some users have reported needing to connect pin 0 to ground to successfully upload the code.  Give this a shot if you are having issues.

Image 12: The Verify button in the Arduino IDE


Image 13: The Upload button in the Arduino IDE



Movie 1: Hello world, blinky time!

Next Steps

Go mobile with a lipo battery pack and make your Huzzah do something cool.  Use your ImagineN4tion...