Introduction: Use UVC to Send Image

In this Instruactables, we'll show you how to use an Arduino compatible board to capture a picture through an USB Video Class (UVC) equipment and send it out using TCP protocol to the designated receiver. The receiver must use TCP to receive the JPEG image file. In this example, we'll use Linux netcat (nc) utility to receive the image. Netcat is often referred to as a Swiss army knife of networking tools, this versatile command can assist you in monitoring, testing, and sending data across network connections (Please Google 'netcat' for detail usage).

Step 1: Equipments

We'll need the following devices for this project:

  • Ameba Arduino board - The main reason to use this Arduino compatible board for this project because of its built-in wireless so we don't need an extra wifi shield. You can search eBay using "Ameba Arduino" about it.
  • Logitech C170 Webcam - A simple UVC which you can get it at eBay, Amazon online store, or your local electronic store should have carrying it.
  • Micro USB OTG adapter - Ameba USB host interface is micro USB while the UVC we use have USB type A connector, we therefore need this adapter to connect the webcam to Ameba. If you can get an UVC that have micro USB interface, then you don't need this adapter.

Step 2: Wiring

There are 3 micro USB host on Ameba, the one at the back supports OTG UVC, by which the USB camera can transmit video data to Ameba, and Ameba sends it to the network through wifi. Detailed wiring is as above. Connect Micro USB OTG to Ameba, then connect the Webcam type A connector to the adapter. Note that in the above wiring diagram, the webcam uses Ameba as power source. If the power supply of Ameba is not sufficient, this would cause the camera unable to work. That is, you have to make sure the power source provides sufficient power to Ameba, or you have to choose the USB OTG which can be connected to external power source.

Step 3: Code Reference

In this example, we set the camera to Motion JPEG mode, and use TCP to transmit image to receiver. In the attached Arduino sketch, We need to modify the sample code for the following information:

  • The SSID/password for the AP connection.
  • The IP address of the receiver.

After the above modification, compile and upload the sample to Ameba and press reset button to start the code.

Step 4: The Result

After the connection is established (as indicated in the terminal output "You're connected to the network"). At this time, you can type in the Linux computer: "nc -l 5001 > myjpg.jpg". This command will wait until socket close or some problem occurs. If you type the nc command again, you will receive the file again, since Ameba tried to send the image every second. This Linux machine needs to be connected to the same AP that Ameba is connected to either through wire or wireless, just make sure the all IPs are in the same subnet.

After Ameba sends an image to receiver. The “Fail to connect” message appears, this means the example ends successfully. You can also see the connection messages in the terminal out. The picture attached in this step is captured using the Webcam in this example. The laptop on the left is the host that connects with Ameba which is also connected with the Webcam (the same laptop shown in the introduction section). The laptop on the right hand side is the Linux machine that running netcat to get the picture.