hex705

the first creature to discover water was likely not a fish

Web cam on a YUN

leave a comment

I have a YUN and I want to take a picture with it.  I have a book called: Internet of Things with the Arduino Yun by Marco Schwartz.  Like a lot of these book it take a few leaps of faith — but overall I am happy.

 

I wanted to test the web cam feature —  cause someone told me that “the world is like all about image man”.  And i plan to prove them wrong.

I needed a webcam (and it had to be UVC compatible).  Went to a big box ignored the stares from the staff when asked them about UVC driver compatibility.  They suggested I needed a new computer cause they never heard of a Yun (nor arduino) — I let that one slide.  Fortunately know some model numbers from here and bought a cheap one.

Purchased logitech c270

Using my newly formatted sd card — I was away to the races.

You need to ssh into the Yun linux processor to install necessary software onto the Yun.  From the terminal in your laptop —

ssh root@ IP_OF_YOUR_YUN
password: YOUR_PASSWORD

You should now be at command line prompt in your Yun.   You will be logged in as root so will have a ‘~’ prompt.

You can <code>cd / and ls -al </code> to see the usual linux file structure.

As per above book installed several packages:

opkg update
opkg install kmod-video-uvc
opkg install fswebcam

Packages installed, sd card inserted, camera plugged to Yun usb (check ,check, check) — take a picture.

at command line type

fswebcam test.png

Fail. Got this:

--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
No input was specified, using the first.
Adjusting resolution from 384x288 to 352x288.
--- Capturing frame...
VIDIOC_DQBUF: No such device
No frames captured.

At this point I look for the trouble shooting section of the book. Nothing. I like this book, I do, really, but a couple of crumbs regarding what can go wrong wouldn’t hurt.

Some google advice from the raspberry pi community suggests that this is not uncommon. But they suggest is has to do with power — which may be, but I am attached to a wall outlet so I really hope not.

At command line try the picture with a little more feedback ( add a -v :: for verbose):


fswebcam test.png -v

now I get error above plus:

src_v4l2_set_pix_format,554: 0: [0x56595559] 'YUYV' (YUV 4:2:2 (YUYV))
src_v4l2_set_pix_format,554: 1: [0x47504A4D] 'MJPG' (MJPEG)

 

the camera seems to only produce these formats. Man page time — the pallet switch helped me out:


fswebcam --help

    -p, --palette 
              Try  to use the specified image format when capturing the image.

              Default is to select one automatically.

              Supported formats:

              PNG
              JPEG
              MJPEG
              RGB32
              RGB24
              BGR32
              BGR24
              YUYV
              UYVY
              YUV420P
              BAYER
              RGB565
              RGB555
              GREY

I try
fswebcam -p YUYV test.png -v

And I get a picture. Cool.

Some messing around suggests I only need the -p YUYV switch the first time after re-boot. I can leave out after that — YMMV.

So now the second ( and subsequent) pictures can be captured like this:


fswebcam test.png

Note:: that the image is stored in what ever directory your using when you type above command. So I suggest you nav over to your sd card before taking any more pics (and maybe delete those first few unless they are keepers). Assuming your card is in the default location.


cd /mnt/sda1

now type to snap a shot. it will be on your card!

Excellent. The book suggests you unmount the card and put in your laptop and look at your pic — and this works to be sure — (NOTE that unmount command skips the first ‘n’ — umount — so you will get a command not found error if you type it human style).

nav away from the card — you will get a resource busy otherwise.

cd ~
umount /dev/sda1


sd card is unmounted -- safe to pull it out.

stick card in laptop nifty you have a camera (sort of).

But this whole mount / unmount — move card thing gets old the second time. But fortunately really smart people exist and they knew about setting up the /arduino/www directory.  Check it out.

Follow the instructions at above and now you can command line click in your Yun and web browser view your pics from your laptop — no card swap needed.

That’s cool.

 

A couple of other things I learned along the way ….

dmesg
To see kernel messages — these should include a block about your camera and a block about your sd card.

you can also try:

lsusb

To see the USB devices connected (including your camera and card reader).

lsmod
To list modules including the libraries installed above.

 

RESOURCES:

this forum post also came in handy 

Written by hex705

June 30th, 2014 at 12:04 am

Posted in Uncategorized

Arduino SD — FAT16 — OSX

leave a comment

I have a micro SD card.  I want to use it with an Arduino Yun (or xBee shield).

It needs to be formatted FAT16.  (NOT FAT32 — FAT32 will not mount).

This is a two PART process.  The first part results in a fat32 format using disk utility.  PART two converts to FAT16 via command line (terminal).

PART 1:

Connect card to OSX machine.

Open disk utility.

Click on SD card when it mounts — it will show up in left panel.

Select ERASE from the top RIGHT panel options.

FORMAT: choose MS-DOS (FAT).

NAME:  myDISK (optional — but for clarity use a name).

Click erase (bottom right).

When done, click on the partition you just named.  At bottom of disk utility it will tell you the mount point and ofrmat — it will tell you FAT32.

 

PART one is complete.

 

PART TWO:

 

Open terminal window

at prompt, list file system by typing  :

df -h

You should see a table with  disk and their mount points.  BE CAREFUL one of the disks is your hard drive.  IT IS VERY IMPORTANT THAT YOU DO NOT OVERWRITE YOUR HARD DRIVE.  The next step will reformat the selected disk in an instant!

in the right column you should see a disk with the name you created in PART 1 above (eg. myDISK).  the left most column for this volume is the info we need.

mine say that myDISK can be found at :

/dev/disk1s1

(the numbers after the word disk will likely be different — that’s ok.  It is worth noting that my hard drive is at /dev/disk0s2  <– I do not want to write to this in next step!)

You want to format the disk at /dev/disk1s1 ms_dos fat16.

You need to unmount this disk to format it. (unmount is not the same as eject.)  easiest way — jump back to disk utility, select the disk name you are about to format (ie myDISK) and then click unmount icon at top.

now back to terminal…

at command line, type:

newfs_msdos -F 16 /dev/disk1s1

ie:

newfs_msdos -F 16 /YOUR/MOUNT/POINT

when you click enter it will be done.

Go back to disk utility, mount the disk and look at bottom — it will now tell you that you have a fat16 disk!

 

just like we need for the YUn… and now it mounts!

RESOURCES:

ada fruit support

arduino site

arduino yun forum

 

 

 

Written by hex705

June 29th, 2014 at 1:52 am

xCode Blues

leave a comment

xCode crashes ” internal error” at start up.  What now?

These are some fast scratched notes on how I am trying to solve this.

fix disk permissions – no luck

cleaned caches – no fix

cleaned prefs – no fix

used Lion cache cleaner — no luck

 

clean install of dev tools (i deleted dev tools manually and tried reinstall — but that didn;t fix it — makes sense — so my bad).

1) REMOVE.  in Terminal:

/Library/Developer/4.2.1/uninstall-devtools --mode=all

you need to be admin and may need to prefix with sudo:

sudo /Library/Developer/4.2.1/uninstall-devtools --mode=all

check your version.

(see: http://stackoverflow.com/questions/7873991/how-to-remove-xcode-4-2-and-install-4-1-to-develop-ruby-rails-on-osx-lion)

2) app store and get it again — app store download an installer — not the app.  SO, if app store says you have xCode — find the install xCode file lurking on your drive (likely in downloads) — delete it.  App store will tell you you don;t have it anymore and get you a new installer.

all else fails — as of Nov. 17, 2011 4.1 avaialble here:

 

https://daw.apple.com/cgi-bin/WebObjects/DSAuthWeb.woa/747/wo/w0bCT1D8XzaH2gYfb6Gjg0/3.3.3.1.1.2.1.1.3.1.1

need dev ID, its not linked publically, but seems to work.

 

 

 

Written by hex705

November 18th, 2011 at 9:17 am

Posted in Uncategorized

Logging Serial Communication to a Text File (Arduino and OSX)

leave a comment

This is a quick tutorial on how to log messages coming from your Arduino into your OSX box and save them in a file.  I found this while debugging an Arduino//Ethernet project that had verbose server response that I needed to save.  I passed Serial.print() and Serial.println() messages from Arduino into a terminal screen and recorded them into a text file with script.  (The sequence for exiting script and leaving you with a readable file is important so read to bottom).
Read the rest of this entry »

Written by hex705

October 12th, 2011 at 9:50 am

Processing – MIDI — GarageBand

leave a comment

Processing can be used as a MIDI controller with Garage Band — this brief tutorial will get you started. There are limitations to this system — but it is enough to do some simple sound experiments. This is a basic introduction only.
Read the rest of this entry »

Written by hex705

February 6th, 2011 at 12:28 pm

Posted in Sounds

Tagged with , , , ,

OSX Command Line with Processing

leave a comment

It is possible to access Unix Terminal commands (command line) on a Mac (OSX) through Processing.  This example uses the say command and then open to open two applications.  Note that parameters are in a String array (String[]) can can be changed with standard array calls.
Read the rest of this entry »

Written by hex705

February 1st, 2011 at 11:35 am

Posted in bridges

Arduino to Processing — Multiple Data Points

leave a comment

Sending a single data point from the physical world into media systems is reasonably straight forward. Sending multiple data points can be much more complex.   This post outlines a simple strategy for sending multiple data points from Arduino to Processing. 
Read the rest of this entry »

Written by hex705

October 20th, 2010 at 10:14 pm

Posted in Uncategorized

Mac OSX, CCV and playstation Eye

leave a comment

Some quick notes on setting up a playstation eye web-cam on OSX.

I have been testing external web cameras for use in interactive installations and multitouch contexts.  I have an external i-sight– which is great but has been dropped enough times to be a little sketchy.  I recently acquired a playstation eye.  The former is firewire,  the latter is USB2.  i-sight is plug and play in OSX — but to get the playstation camera running you will need to download a driver — I am using macam — the standard for OSX USB camera support.

Macam is a free USB driver for OSX — latest version supports playstation eye.  Macam has a standalone app that will let you see the image, record stills and video.

If you wish to use the camera with CCV (community core vision — AKA t-beta) then you may need to manually add the macam component to your library.  IT must go in root —  /Library/quicktime/  .  Delete old versions of the component if you are upgrading.  Restart CCV and the image from the camera should appear in the CCV preview windows.

Written by hex705

October 16th, 2010 at 1:49 pm

How to control a light bulb in Paris

leave a comment

Please download code for today’s class:

tele_example code  ( no longer available ).

full_tele_example code

These code samples will enable you to quickly set up real-time physical data-sharing links between a server, client and  Arduino micro-controllers.

Four files are included: sensorRead_n, teleServer_n, teleClient_n, sensorActuate_n.  Sensor files are Arduino code, Server and Client files are Processing.

Written by hex705

January 25th, 2010 at 8:47 am

Posted in bridges,networks

Tagged with

Servo Control with an Arduino

leave a comment

Servos are a class of actuator that have built-in positioning feedback. They are composed of a motor and a circuit with a potentiometer (variable resister) and time decoders that are used for feedback and positioning. They are controlled with time-based commands known as pulse-width-control. Pulse-width-control is a cousin of PWM (pulse width modulation).
Read the rest of this entry »

Written by hex705

November 2nd, 2009 at 5:38 pm