May 242013
 

So after destroying one Pi, I still managed to salvage the evening. What I wanted to do was read from the UART Serial pins on the Raspberry Pi directly on the Arduino without any magic. Just RX/TX to TX/RX. But in order to avoid frying another Pi I used an Adafruit voltage stepper. The Pi speaks serial at 3.3v and the Arduino likes to chat at 5v. The Raspberry Pi GPIO pins are sensitive to the extra voltage.

The Raspberry Pi automatically spits out data over the serial pins by default. For later use, I will want to comment that out so I can use that serial session for sending command data and receiving sensor data from the Arduino. But for now, I just want to get it working and see some BBS looking scrolling going across my terminal.

Step One, if you are using the default Raspbian distro, you need to slow down the baud rate. The Arduino using the Software Serial class cannot keep up and you will just get gibberish.

The easiest fix is to turn on your Pi and ssh into it and make two changes. First in the /boot/cmdline.txt file, change the two instances of 115200 to 9600. (Sure it might work a little higher but I was too lazy to test at multiple speeds). Then, edit /etc/inittab file. Cruise to what should be the last line, and change the 115200 to 9600.

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
Becomes:
T0:23:respawn:/sbin/getty -L ttyAMA0 9600 vt100

Now you can shutoff your Pi.

Lets prep the Arduino now – you can use this simple sketch (https://gist.github.com/tagroup/5641521) to echo all received serial data to the Arduino serial console. Once you upload the sketch to your Arduino, you can unplug that and start hooking the two up.

First on your Pi, Pin 8 is the Tx and Pin 10 is the Rx . You will also need to connect the ground Pin 6 to your voltage stepper board. The overall goal is your Tx -> RX and the Rx -> Tx . So on the other side of your stepper (the 5v side) connect the pins you defined in the sketch above across from the opposite transmission type coming out of the Pi. The ground should also be attached to the Pi ground and the 5v should go to the appropriate location on your stepper board.

Now you are ready to fire it up. Start the Arduino first and open the serial monitor, under tools. If you are set to the right baud rate, 9600, you should see the “Ready to receive Data” message. Now turn on your Raspberry Pi and watch the magic. You should see all of the loading processes and eventually you can log in to your Pi directly through your Arduino.

If you still see gibberish log into your Raspberry Pi via SSH and check that everything is set correctly by typing ‘sudo stty –F /dev/ttyAMA0 –a’. You should see 9600 as the baud rate. If you see something else you can set it by typing ‘sudo stty –F /dev/ttyAMA0 9600’.

May 242013
 

How I Fried my Raspberry Pi

Arduino Motor Shield Rev3TL;DR: 12v Battery + Arduino Motor Shield + Arduino + Raspberry Pi =Bad Time for the PI.

Symptoms: No lights regardless of which power adapter I use and how it is connected. Oh and the instant temperature change when you plug it in. The micro-usb immediately heats up enough to cause burns.

Solution: I have no idea. Definitely past my skill set. If I don’t find anything online by the end of the weekend, I plan on putting it in a glass baking plan and leaving it plugged in until it melts or has glorious flames.

How it happened: My own stupidity and lack of patience. I write these blogs so I remember what to do in the future. The purpose of this blog is to serve as a reminder of what not to do.

The Story: I made a late trip to RadioShack one night over the weekend for some connects for a solar panel Ali is building (DIY solar panels are ridiculously hard for someone like me but that is another story). During the trip I saw an Arduino Motor Shield on sale for $10 bucks and figured why not, I like motors and know nothing about controlling them. Like everything you purchase from stores like RadioShack or ToysRus, the packaging looked like it had been gnawed and the instructions were missing. I should note that I don’t blame lacking instructions for the fried Raspberry Pi because I would have foolishly skipped over them anyway as I did with the product sheet I found online.  (Here is some example code)

Fast forward to last night, I have two Roomba motors and a couple old UPC 12v batteries which I have been charging with Alison’s homemade solar panels. I attached the two motors (really wheel sets) to an old internal hard drive cage and decided it was time to make them go fast. I remembered reading that the board could handle something like 20vdc so I am money. My 12v battery charged to 13ish volts should be perfect. I plug in the motors and the battery to the motor shield. It doesn’t make much of a difference but I was using one of the AdaFruit voltage regulators. It is nice to put in-line to control the voltage. In this test, I was just using it for the on / off switch. I noticed that the Arduino lights came on and I didn’t think much of it.

Roomba Wheels Arduino Motor ShieldWhen working with the motor shield, you have to initialize the direction, brake, and power so I put together a quick sketch that did exactly that and pushed it to the Arduino. All was well – wheels were spinning – I was feeling like a genius ready to go on to the next step. I want my buggy to be controlled by a serial connection from a Raspberry Pi, that I can control via wireless from a desktop or tablet (I don’t have a wireless shield, Bluetooth, or Zigbee). I put a little bit of code together for the Arduino to check the serial connection and perform an action based on the result. Worked perfectly from the serial console within Arduino. It was now time to plug it in to the Pi. Grabbed the Pi and plugged the usb from the Arduino hooked to the motor shield with the 12v battery still on from my last test and it was officially cooking Pi time. My first though was that the micro usb connection had the problem but immediately after burning my figure touching the housing I knew it was good game. I still didn’t know why. I try another plug, nothing. Was this just coincidence or did it have to do with the Arduino Motor Shield and my need to start testing with the highest voltage possible? I decided to shove probes to read the voltage from the usb plugged into the Arduino board. It was fluctuating all over the place… Damn it was my fault. After doing the research I should have done before starting, I learned that while you can power your Arduino from the Motor Shield Rev 3, it is not recommended to do so with more than 9 volts. Oops. I also learned that there is a disconnect on the back of the shield exactly to prevent the situation I had experienced. All you have to do is physically separate (scratch off) the two pads of solder.

For the benefit of anyone else that might stumble onto this blog and is only reading the bold text: IF YOU OWN THE ARDUINO MOTOR SHIELD REV3 AND YOU WANT TO POWER +9v – SEPARATE THE POWER DISCONNECT ON THE BACK OF THE ARDUINO MOTOR SHIELD REV3.

From the official documentation that I read too late:
To avoid possible damage to the Arduino board on which the shield is mounted, we reccomend using an external power supply that provides a voltage between 7 and 12V. If your motor require more than 9V we recommend that you separate the power lines of the shield and the Arduino board on which the shield is mounted. This is possible by cutting the “Vin Connect” jumper placed on the back side of the shield. The absolute limit for the Vin at the screw terminals is 18V.

I cannot get too upset because I could have easily fried the laptop I was using too.

Please enjoy the further failings when testing the buggy later.

May 092013
 

Running OpenZwave on Your Cubieboard

Before running off to play in the unknown (to me) land of the Cubie, I figured it would be a good idea to try out OpenZwave, my Aeon Lab Z-stick and the OpenZwave Socket servers.  So far the Cubieboard is running well with the last compiled version of OpenZwave with Conrad’s Lights Control, OpenZwave Control Panel and my Basic Zwave web interface.  All of the applications run at about the same speed as they do on the Raspberry Pis.

My CubieBoard Setup:

  • Cubieboard 1gb RAM version 2012-09-09
  • This Debian Wheezy image with the device specific bootloader.  (This is a very clean minimal install that is headless only.  You MUST ssh into the Cubieboard.)
  • A 8gb microSD card that came out of a HTC Evo Phone.  The card is slow.
  • Aeon Labs Z-stick 2

OpenZwave Info and Starting the Socket Server

The image below contains exactly the same version of the OpenZwave library, clients and servers as the last Raspberry Pi image.  The host name has changed to cubie-openzwave (cubie-openzwave.local on bonjour).  DHCP is enabled by default and the host name is set to broadcast and announce services on Avahi.  The image contains three applications for playing with Zwave: OpenZwave Control Panel, Lights Control and Basic.  Lights Control and Basic run with nginx with PHP, curl, APC, and sqlite. The OpenZwave Control Panel uses libmicrohttpd and magic.  Start up instructions will come up as the ‘message/motto of the day’ when you ssh into your Cubieboard.  You can also see the instructions on this Rasberry Pi OpenZwave post.  Only one OpenZwave application can run at one time – so make sure to run killOZW before switching between Basic and Lights Control.  I tested with a multilevel switch, binary switch and a thermostat.

The username is ‘root’ and the password is ‘password’.  Type ‘passwd’ to change it.

Download: cubie-openzwave-2013-05-09-4gb.img.7z (240ish mb)

Notes: I used 7zip on Mint and had some issues writing the image on Windows.  The image worked correctly on Debian and Mint.  Please let me know if you have any issues.

If moving the files to your own Linux image – I had problems with the ‘basic-server’ not finding the dynamically linked libraries.  It would give me an error saying that no file or directory existed by the name basic-server (file was there with correct permissions).  The command ‘ldd’ would spit out an error that it was “not a dynamic executable”.  To fix the problem, I had to copy ld-linux.so.3 to its old location of ‘/lib/’ (yeah, I guess I could have  recompiled – always a time crunch) from its new location ‘/lib/arm-linux-gnueabihf/’.  The command is ‘cp /lib/arm-linux-gnueabihf/ld-linux.so.3 /lib’.  From the information I gathered in a couple of minutes of research, this runtime linker location was a big deal last August and probably impacts a lot of other programs running on Debian and Ubuntu.

May 052013
 

CubieBoard vs RaspberryPiThis week has been full of unexpected surprises.  I finally received the Cubieboard I had order several weeks ago.  I think I paid $59 + shipping for the kit which came with a case, cords and a cardboard box similar to the original boxes that Raspberry Pi’s were shipped in.  I didn’t have high expectations for the device to be honest because my only exposure to them has been people having problems compiling openzwave on the Raspbian that was mangled to work on the Cubieboard.

Another area of concern, the documentation online for the Cubieboard is horrible compared to the documentation and community available to Raspberry Pi owners.  The strangest thing for me is I don’t know which is the official forum.  There are two links to two different forums on the main Cubieboard site and most of those posts link to another AllWinner board.

Back to the packaging, it was actually really nice.  It had inner boxes with more inner boxes and nicely custom cut foam.  The only thing it was missing was the “designed in Cupertino” on the side of the box.

When I pulled it out and went searching on the web for the amps needed for the supplied usb power cord, I learned that this bad boy has 4G of NAND memory with Android already loaded on it (yeah, I am an idiot for not knowing that ahead of time).

I know I should have removed the paper.

I know I should have removed the paper.

I was shocked.  In a good way.  I thought I would have to spend a couple hours fighting to get the perfect image on a micro sd card to even get to see the thing in action (something I knew I didn’t have time for today).  Instead all I had to do was plug in power, hdmi, and a hub for the mouse, keyboard, and wireless (super cheap dongle worked immediately).  Best of all, once I had it plugged in it looked like Christmas with bright green and red leds.  Wonderful.

Then surprise two: it didn’t dawn on me that this is just a giant tablet.  It runs almost all tablet apps from the Play store including the most bullshit Comcast app.  The Comcast app does not let you use airplay to extend your content onto a larger screen due to ridiculous DRM standards (and even though the dialog box on Apple even says ‘stream anything you can see on your iPad to your Apple TV’).  It was so glorious to defeat Comcast and watch the shows on the big screen, I left it streaming anything and everything the rest of the day.  Tomorrow, I plan on having Entourage going in the background while I get some work done.

Now I haven’t gotten to the real use of this toy yet.  The evaluation is completely premature but after day one, I have to say this is better and easier  to use than the Raspberry Pi.  People can ease in to making disk images but still have something to play with while they are learning.

Another nice thing is the fact that the case and cords are included.  Then when you look at speed, RAM, SATA connections 4g NAND,  and the fact that your ethernet that does not compete with your usb devices….. I am really starting to like this.  Let’s see how day two goes.

Forgot to mention – plugged in my cheap wifi dongle and it just worked.  Way to go Android.

Day 2 Update

Still impressed.  I followed a nice tutorial to get a minimal Debian Wheezy install up and running from a micro SD card.  The process is very similar to the Raspberry Pi experience but their are a few extra steps because so many devices share the same distro.  After writing the distro to your SD card, you have to write the device-specific bootloader.  In my case, the /dev/sdX was /dev/mmcblk0.  When you write your images you will see two partitions – just like the Raspberry Pi.  For a quick test, I ran ‘sysbench –test=cpu –cpu-max-prime=20000 run’ on the new install and got an average total time of 656.2975 seconds to complete the test.  I am not sure how that number compares to other Cubieboards / Cubieboard distros.  A lot of forums talk about the need to tweak the cpu to run more like a server and less like a tablet but I have not ventured down that road yet.  As a quick comparison, my GitPi did the same sysbench test in 1320.0708 seconds and 1081.8397 seconds on an OpenZ-wave test Pi.

If you want to install sysbench, you can get it from the repo with ‘sudo apt-get install sysbench’.