Saturday, December 20, 2014

pcDuino3 Nano - Kernel Upgrade

This is the first of a series documenting my setup of a new home server with the Linksprite pcDuino3 Nano.  A listing for the entire series can be found here.  More information on the pcDuino3 Nano can be found at Linksprite’s website and the pcDuino website.

When I booted the fresh out of the box pcDuino3 Nano the kernel it booted from NAND was built on 10-15-2014. A check of the pcDuino3 Nano download page on the LinkSprite website showed that there was a more current version built on 12-5-2014.

I checked the version of the kernel running as shown below:

root@ubuntu:~# uname -a
Linux ubuntu 3.4.79+ #5 SMP PREEMPT Wed Oct 15 14:06:46 CST 2014 armv7l armv7l armv7l GNU/Linux
root@ubuntu:~#

The new kernel resolved the Aurduino-ish IDE corruption issue due to a serial port bug.  I figured before I got started with anything I would upgrade to the latest kernel.

On the pcDuino family of systems there are two methods for upgrading the software running from NAND.

  1. You can use the LiveSuit utility which loads software from a windows computer over usb.
  2. You can use the PhoenixCard utility which writes a specially formatted sd card.  This card is inserted in the system and when it is powered up it loads the new kernel.

I chose to use PhoenixCard. 

Note: I have a USB TTL cable connected to the console pins or the pcDuino3 Nano.  While this isn’t a requirement to complete this process it helps to be able to see the messages as the print.

image

1) The first step was to download the kernel image and the Ubuntu image which is done from the pcDuino3 Nano download page.  You also need to download a copy of PhoenixCard.

The version of PhoenixCard, Phoenix_V309, that is on the pcDuino3 Nano download page was flagged by Norton Internet security as a problem.  As a result I ended up using PhoenixCard_v310_20130618 which I found via Google here: https://drive.google.com/file/d/0B38hUt6ypQXDVTB6cWJXZ3ZGNkE/edit?usp=sharing

Save the files on your system.

image

2) Extract PhoenixCard and run PhoenixCard.exe.

image

3) You will get prompted to allow the program from an unknown publisher to make changes to your system.  You will need to say yes nd you will end up in PhoenixCard 3.10. PhoenixCard does an update check which starts out in Chinese but ends with a window in English.

image

4) Click on the “Img File” button and select “cduino3_nano_a20_kernel_livesuit_20141205.img”. 

image

5) Check to make sure the disk in the disk window is correct and select “Burn”.  After the burn completes you will see the following messages in the Option window. 

  • There is a note on the pcDuino3 Nano download page that says with some internal readers you may be a “Card Preprocess Failed !1012” due to the fact that they cannot write a partition table.
  • I ran into an interesting problem when my sd card’s lock tab ended up in the locked position.  PhoenixCard would say it could format the card but the burn would fail.  If the burn fails check your lock tab.

image

6) Power off your pcDuino3 Nano and take the sd card out of your computer and put it into the pcDuino3 Nano’s sd slot.  Apply power to the pcDuino3 Nano. 

While the kernel is loading LED 4 will flash.  Once the load is complete it will turn off.  When it does turn off the pcDuino3 Nano and remove the sd card.

7) Next you need to extract the Ubuntu files from the archive and write them to an sd card. 

If you use the same sd card you used for the kernel load make sure you reformat the card before you write the ubuntu files to it

You can do this with the PhoenixCard utility or another sd card formatting utility.

image

8) Once the files have been written to the sd card take it out of your system and put it in the sd card slot in the pcDuino3 Nano and power up the system.  While the Ubuntu files are loading LED 3 will be on and LED 4 will flash.  When the load is finished both LED 3 and LED 4 will blink in unison.

9) Turn off the pcDuino3 Nano, remove the sd card and turn it back on.  It should boot into the updated kernel.

root@ubuntu:~# uname -a
Linux ubuntu 3.4.79+ #2 SMP PREEMPT Fri Dec 5 17:23:11 CST 2014 armv7l armv7l armv7l GNU/Linux
root@ubuntu:~#

Friday, December 19, 2014

pcDuino3 Nano

Thanks to the folks at LinkSprite a pcDuino3 Nano recently arrived in my mailbox.  The pcDuino3 is a later generation of the pcDuino which I got in March 2013.  I really enjoyed working with the original pcDuino.  I used it on in a number of projects which are documented in this blog

I found the pcDuino to be a usable computer with easy access to the basic hardware level.  Unlike some other similar systems you can  boot into a windowed environment and get very reasonable performance.

My positive experiences with the first pcDuino led me back to LinkSprite when I started looking for a  a new system to host my home network attach storage system.  The specifications for the pcDuino3 Nano sold me on it and I couldn’t wait to get my hands on one.

What I liked about the pcDuino3 Nano was that it has a decent amount of processing power, a SATA port, GB ethernet and at $39.99 a very attractive price.  Over the next week or so I plan to document my experiences putting this system through its paces and then setting up the NAS system.

pcDuino3Nanov2

The picture above is where I was about 10 minutes after unboxing the pcDuino3 Nano.  I had it plugged into my network and into a monitor with a keyboard, a mouse and a console cable.  I applied power and it booted me into Lubuntu 12.04.

I plan to post updates and tutorials on this project over the next several months.

More to follow…

Sunday, November 30, 2014

RFduino Bluetooth Low Energy Bicycle Speed Sensor

During October and November I worked on a project to build a Bluetooth low energy bicycle speed sensor and interface it with my Android tablet.  The project used a hall effect sensor and magnet to count the rotation of the wheel.  The hall effect sensor was fed into the RFduino which computed the time for a complete rotation of the wheel and then using a BLE notify fed the data to the tablet.

BLESpeedometer

In the picture below the RFduino is at the top of the picture.  The RFduino is covered by a blue and red led.  The blue led is to provide visible status when a device is connected to the speed sensor and the red led cycles on and off as the hall effect sensor is read.  Below the RFduino is an Adafruit CR2032 holder.  To the left of the CR2032 is the connector that the hall effect sensor plugs into and to the right is the on / off switch.

BLESpeedometerClose

On the tablet I developed an app that builds on the Interactive Bicycle Trainer that I developed last winter.  The tablet is fastened on the handle bars and the bike is put on the trainer with the front wheel raised so that the handle bars are able to be turned.  Using the speed sensor a virtual rider on the tablet moves along a roadway at a speed that depends on how fast you pedal.  Leveraging the rotational senor capabilities of the table turning the handle bars allows you to steer the virtual bike to avoid oil slicks that are on the road.

device-2014-12-19-215943

The RFduino sketch and the Android App are on GitHub in the digitalhack/dhRFduino repository.

Saturday, October 11, 2014

RFduino / BLED112 / DS18B20 Temperature Demo

This is another simple temperature monitor.  It uses a DS18B20 sensor which is connected to the RFduino over a 1-Wire bus.  It also adds red and blue LEDs that supply status. 

The red LED blinks unless an error is detected at which time it turns on solid.  The blue LED turns on when a connection is made to the temperature monitor and blinks 5 times if a new temperature is detected.

Below is a mock up of the breadboard temperature monitor and a circuit diagram produced using the fritzing package.

TemperatureDS18B20Project_bb

TemperatureDS18B20Project_schem

If you don’t already have the OneWire library information on it can be found here on the Arduino site which directs you to Paul Stofffregen’s site.  To install download the zip file and then copy to your RFduino libraries directory.  On my system this directory is located at C:\Program Files (x86)\arduino-1.5.7\hardware\arduino\RFduino\libraries.  On your system this will be dependent on where your Arduino IDE with RFduino support is located.

The files for the DS18B20 demo are located here.  This demo uses the same windows program as the TMP007 demo which can be found here in the dhRFduino repository on GitHub.

The LEDs are controlled by setting that are located in the RFduinoBLE_onConnect and RFduinoBLE_onDisconnect routines.  These routines are called when a connection is established to the RFduino and when that connection is terminated.

RFduino / BLED112 / TMP007 Temperature Demo

I decided to build on the temperature example by adding an external sensor to the RFduino.  In keeping with the temperature theme I used a TMP007 temperature sensor from Adafruit.

To read the temperature from the TMP007 I used the TMP007 library from Adafruit. 

Remember when installing libraries to use with the RFduino you need to get them put in the right place in the Arduino tree.  On my system this directory is located at C:\Program Files (x86)\arduino-1.5.7\hardware\arduino\RFduino\libraries.  On your system this will be dependent on where your Arduino IDE with RFduino support is located.

The files for the TMP007 demo are here on GitHub in the dhRFduino repository.

The hardware setup for this demo is very simple.  The TMP007 and the RFduino are connected to power and ground and the SCL and SDA lines on the TMP007 are connected to SCL labeled GPIO5 and SDA labeled GPIO6 on the RFduino.

If this demo is run in DEBUG mode and the serial console is attached to the RFduino status messages will be logged when a connection is made to the RFduino, when the connection is disconnected, the temperature each time the sensor is red and when a new temperature value is detected.

Sunday, September 7, 2014

Accessing an RFduino using BLE GUI

I was asked how you would access the RFduino using the BLE GUI.  Below are step by step instructions that worked for me.

RFduino Setup

Open the Temperature example sketch in the Arduino IDE and compile and load the sketch.

Reading a Value from the RFduino

Run the BLE GUI software.  This can be done via the icon on the desktop or through the program menu.

When the software runs it will display a windows as shown below.

image

The software should have the COM port that was installed listed as shown in the first red circle.  As long as the right COM port is showing the next step is to select the Attach button as shown in the second red circle.  I was able to use the default baud rate.

When you are successfully connected the Attach button should change to a Detach button and next to the button should be a green Connected as shown below.

image

After you successfully connect to the BLED112 you should select the Start button to start scanning.  The GUI should update and list your RFduino device as shown below.  I only have one BLE device so I am not sure how it would look if you had multiple devices that were all broadcasting.

image

The log window will also show results of the scan.

image

Next you should select the Connect button to connect to the RFduino.

image

Once you are connected the Connect button will change to Disconnect and you should select the GATT button.

image

When the GATT button is selected it will update the GUI including additional commands and a window where the results will be shared.  You should select the Descriptors Discover.

image

The GUI will update and show all the descriptors it found on the RFduino.

image

You can scroll down and select Handle 14.  By selecting the Read button you will read data from the RFduino.  In this case it will be the core temperature.

image

The GUI will update with the Raw value stored at Handle 14 and will also print the result in the log window.

image

You have now successfully read the RFduino via your BLED112.

You will want to select the Disconnect button to disconnect from the RFduino and the Detach button to disconnect the GUI from the BLED112.

Thanks to Bluegiga and RFduino for their products and documentation.  If you find something that doesn’t work for you or you have questions please post them as comments and I will get back to you as soon as I can.

Saturday, September 6, 2014

My Take on the RFduino Temperature Example for Windows 7

One of the examples that comes with the RFduino is an example which reads the RFduino’s core temperature via BLE.  This is my take on that example running under Windows 7 using the BLED112 and BGLib.  The output is just text and not the nice graphics of the IOS RFduino example but it should get the idea across.

One change I made to the sketch running on the RFduino is to only update the temperature if it changes.  This allows the program running on the Windows PC to set the notify attribute and have the RFduino send a notification with the new temperature when it changes.

I found this program not a really good example of using notify because the core temperature doesn’t appear to change too often.  However, it shows all the steps necessary to utilize the notify BLE feature with the RFduino and BLED112.

The code for this example can be found on GitHub in the dhRFduino repository under digitalhack.

For a step by step example of getting this to run under windows see the post on RFduino and BLED112, Putting It All Together but substitute the TemperatureExample sketch and windows program for the ReadValueExample sketch and windows program.

This example uses a soft reset for the BLED112 and has timeouts implemented in a slightly different way than the ReadValueExample.

As always I hope you find this helpful and thanks to Bluegiga and RFduino because without their products none of this would be possible.

If you find something that doesn’t work for you or you have questions please post them as comments and I will get back to you as soon as I can.