I love IoT, but I really hate talks in which all the great concepts are explained and finally when you get the chance to actually see something, all you get is some LEDs that light up and change their color. If you attend your first talk on this topic, you’re probably happy, but when you sit in your third or fourth talk, it really starts to get boring. After all it’s IoT not IoL (Internet of Lights).
I wanted to prepare a talk on using Flex as a frontend for an IoT system, so after complaining about blinking lights, I thought: what’s cooler than blinking lights? Well just about anything is cooler, but my own Cyborg – that’s almost as cool as it can get.
So I started to look for some driving, walking, whatsoever robot kits and stumbled over Rapiro . At first glance he’s definitely cute. At second glance I think he’s even cooler as he’s a good platform to play with and demonstrate a lot of different things. He’s big enough to be visible at a conference presentation. Small enough to take with you, even on a plane and with a big hollow head in which you can store all sorts of electronics. When I found out it is possible to extend the relatively primitive Arduino that comes with Rapiro with an Intel Edison by using a carrier board especially designed for Rapiro , it was sold.
Ordering my Rapiro from Germany was pretty easy and extremely fast. I wouldn’t manage to get to Japan in the time Rapiro managed to come to Germany. Anyway, the hardest thing was explaining the customs guys what’s in the box. In Germany you need a classification for EVERYTHING. For $500 (Rapiro + Edison carrier + a little spare parts) they decided it’s not a toy – so what is it? It’s not an industrial robot and it can’t really transport things. There is no “Walking and dancing robot” category in German tax classifications. So it took them about 30 minutes to figure out what he was. In the end they settled with “0000” which seems to be “We don’t know what it is, just apply the maximum tax on it”. In the end I payed my taxes and Raprio and I were good to go.
Note: I recommend ordering directly form Switch-Science , as I have read about some problems with other suppliers that didn’t fill out all of the papers correctly or didn’t add the CE certificates for the electronics. Yet another suggestion would be to order one or two spare servos of both sizes.
Note: If you are planning to include the IR Sensor, I would recommend soldering the pins to the Arduino and do the cabling before assembling Rapiro or you will have to disassemble most of him again.
Building Rapiro is extremely straight forward. The documentation is great and it should almost assemble itself automatically.
One thing I did notice, though, was that even if I did follow the instructions (i.e. I connected the servos and made them initialize before assembling Rapiro and took care not to change their position during assembly), Rapiro did some crazy moves when I switched him on for the first time. The reason was that some servos now initialized to different positions. So I had to disassemble parts, adjust the servos and re-assemble them. But now he’s standing tall awaiting my commands.
Connecting to Rapiro’s Arduino
Note: I would recommend NOT connecting the cable from Rapiro’s Arduino to the Edison for now as it seems there are problems using the Arduino directly if this cable is connected. I guess it’s as if you connected two devices to the same COM port. I had a lot of trouble with this prior to noticing this.
The micro USB port on Rapiro’s right hand side is the serial terminal to Rapiro’s Arduino. Now it was possible to attach Rapiro to a computer and immediately start talking to him. I am using a Mac, so I needed to install the driver for the virtual COM port first. After installing the driver and Arduino IDE I was able to upload my first sketch. The first tasks are to iteratively adjust the trimming values for the servos in the Arduino sketch so the little guy isn’t shivering because the servos are in some half ideal position.
One thing I noticed was that after uploading a sketch I sometimes had to disconnect the USB connection prior to uploading a new version (I had to do this quite often during the initial calibration). Without doing this, all I got was some nasty looking errors when trying to upload for the second time.
So after all servos were correctly calibrated, it was time to have the little guy do his first steps. For this I simply opened a “Serial Monitor” in the Arduino IDE. Inside this I then sent the initial
#M1 which makes Rapiro walk forward and what should I say? He started walking. So I played around a little with the other “movement” presets, and was happy.
Here is a list of all commands of the initial sketch: https://wiki.rapiro.com/page/serial-command/
Setting up the Edison
After the Arduino had been correctly configured and Rapiro was able to do his basic things, my next step was to setup and configure Rapiro’s brain. First I connected my computers USB cable to Edison’s micro USB (the one on the left hand side if you face Rapiro – as seen on above image) and had the Intel Phone Flash Tool Light install an image of the latest firmware . After the Edison had the latest firmware running, I needed to connect the micro USB cable to the other micro USB port of the Edison (the one on the right hand side if you face Rapiro). This is also a serial terminal port. To connect to the Edison, simply use this command:
screen /dev/xx.usbserial-XXXXXXXX 115200 –L
If the screen is simply clear, be sure to press “Enter” once or twice as the “screen-saver” might be on. In it’s initial state you can simply logon with the
After doing this my first thing to do was to configure the WiFi connection
and to enable the WiFi SSL access by setting a password
Now I was able to disconnect the USB cable and log in to the Edison using a normal SSH client. That was easy!
Setting up the Edison to communicate with Rapiro’s Arduino
The Edison comes with four COM ports enabled:
/dev/ttyGS0: Mini-USB Port at the back with which you can directly log in to Rapiro from PC/Mac using a virtual serial connection
/dev/ttyMFD0: BlueTooth serial connection
/dev/ttyMFD1: Serial UART connection using the on-board Pins (the one needed to communicate with Rapiro’s Arduino)
/dev/ttyMFD1: Linux Kernel Debug (no idea what this is)
In order to send commands from the Edison from the command-line, you need to install some sort of terminal. Later on I’ll send the commands from Java directly where I don’t need a terminal, but for testing it’s always good to have one. Edison’s default Linux uses OPKG to install packages. But in order to find packages we first need to add a package repository:
- Log in to your Edison
/etc/opkg/base-feeds.confon the Edison
- Add the following lines to the (usually empty) file:
src/gz all http://repo.opkg.net/edison/repo/all src/gz edison http://repo.opkg.net/edison/repo/edison src/gz core2-32 http://repo.opkg.net/edison/repo/core2-32
opkg updateto fetch the list of available packages. (You should resist the temptation to run “opkg upgrade” as I have read that this will break things)
opkg install screenyou install the terminal program “screen”
So after installing the terminal program we can start sending commands to the Arduino:
screen /dev/ttyMFD1 57600 -L
you open a terminal connection to Rapiro’s Arduino (no worries if the screen is empty … that’s the way it should be … and be sure to use the 57600 baud rate as the Arduino sketch configures the COM port to use that rate)
- Now try typing
#M1and your Rapiro should start walking forward
#M0it should stop.
I did notice that as soon as you type
# Rapiro looks like he’s frozen or having mechanical problems. So in this case, don’t worry, it’s just the software not being implemented too well. I am certain that I’ll write a new sketch for the Arduino that is more optimized for sending commands from Edison over time.
Description of Edison’s COM ports: https://communities.intel.com/thread/54236?tstart=0
Where I got a hint on what “ttyMFD0” actually is: https://android.googlesource.com/platform/hardware/bsp/intel/+/b4e503caf3329e5230441ff6c2a2849a0fa4932f%5E!/
How to seup the OPKG Edison repo: http://alextgalileo.altervista.org/edison-package-repo-configuration-instructions.html
As I want do to some quite sophisticated stuff with my Rapiro and the Edison carrier board comes with a microSD slot, I got my hands on a really fast 64 GB microSD card. This should be enough for playing around. After all I don’t want a walking Hadoop/Cassandra cluster following me everywhere – even if that might sound cool.
Since the Edison’s Linux distribution doesn’t directly support FAT32, I decided to re-format the SD card with EXT4. But if you are used to formatting stuff with FAT16/32 or NTFS, formatting a 64GB SD card with EXT4 does take a minute or two … or several hundred. The first time I tried, my little friend ran out of energy before finishing the job so the second time I connected the Edison’s terminal port to an USB port for energy and restarted the formatting process. In this way, the little guy doesn’t wear out his servos, as he tended to get nervous tremors in some of his servos every now and then. Doing some math I guess spending the extra bucks on the super-duper SD card was a waste of money as the Edison and/or carrier board might not provide the speed to utilize this. In the end I think formatting my 64 GB took about 3-4 hours.
First I needed to find out under what name my SD card is available:
This prints out a long list:
Disk /dev/mmcblk0: 3909 MB, 3909091328 bytes
1 heads, 16 sectors/track, 477184 cylinders
Units = cylinders of 16 * 512 = 8192 bytes
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 1 477185 3817472 ee EFI GPT
Partition 1 does not end on cylinder boundary
Disk /dev/mmcblk0boot1: 4 MB, 4194304 bytes
4 heads, 16 sectors/track, 128 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Disk /dev/mmcblk0boot1 doesn't contain a valid partition table
Disk /dev/mmcblk0boot0: 4 MB, 4194304 bytes
4 heads, 16 sectors/track, 128 cylinders
Units = cylinders of 64 * 512 = 32768 bytes
Disk /dev/mmcblk0boot0 doesn't contain a valid partition table
Disk /dev/mmcblk1: 63.8 GB, 63864569856 bytes
255 heads, 63 sectors/track, 7764 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/mmcblk1p1 3 7765 62351360 83 Linux
mmcblk1 seems to the the name of the SD device when using it on the Edison carrier board. At least judging from the 63.8GB of space.
Next I needed to switch the FAT32 partition on the SD card to an EXT4 one:
Here you need to hit “t” to “change a partition’s system id” and then use the id “83” to switch the partition type to “Linux”. To save the changes, hit “w” (write) at the end.
After that I started the formatting process:
mkfs.ext4 -m 0 -L memories /dev/mmcblk1p1
and then mounted it with:
mkdir -p /mnt/memories
mount -rw -t ext4 /dev/mmcblk1p1 /mnt/memories/
OK … this way you still need to mount it every time you start, so add this to your
/dev/mmcblk1p1 /mnt/memories ext4 defaults 0 0
This way you can use
mount /mnt/memories and the system will know what to do, but it doesn’t quite do it yet. In order to have the partition auto-mounted at startup you finally need to create a script that is executed while starting up. I couldn’t find one in the typical places, and it seems you have to manually do this:
mkdir -p /etc/init.d
chmod +x rc.local
It doesn’t actually have to be called that way, but this way it’s at least a little aligned with established defaults and it has to be executable.
Inside rc.local all we need is one line:
To tell Edison’s OS about the script we finally registered it to be called at startup:
update-rc.d rc.local defaults
Done … next time you reboot, the SD card should be automatically mounted.
At this point we have a working Rapiro with an embedded Intel Edison running on the Edison carrier board, we extended the available disk space by utilizing a microSD card inserted into the SD card reader of the carrier board and this is automatically mounted when the system starts. Edison is accessible using SSH via WiFi and we can log on to it remotely and send commands to Rapiro’s Arduino and thereby remote-control him … I think that’s quite nice for a start, but it’s only the start.
To be continued …
I’ll continue this little series with probably a little more demanding tasks, but my toys have to be delivered first. In part 2 I’ll cover:
- Connecting the Rapiro IR proximity sensor to his Arduino
- Adding sound I/O to Edison using a WM8731 circuit board
- Adding vision including object detection to Edison using an insanely cool Pixy CMUcam5
So get your soldering irons and 3d printers ready.
In part 3 I’m going to deal with software running on the Edison and probably my optimized Arduino sketch.
Your job at codecentric?
More articles in this subject area
Discover exciting further topics and let the codecentric world inspire you.