Backpack #1: OpenMV Camera

CEEOInnovations 'profile picture'
4.5K424

Intro: Backpack #1: OpenMV Camera

SPIKE Prime Backpacks are extensions for LEGO Education SPIKE Prime.

The Open MV camera is the brain for the Camera Backpack that allows you to integrate image processing and machine vision capabilities of the Open MV camera to LEGO SPIKE Prime.

We also have a Grove Sensor Backpack that allows you to connect cool sensors, a Pyboard Backpack that lets you connect to the WiFi, a Micro:bit Backpack that enables radio communication, and a Breadboard Backpack that you can use to prototype circuits.

STEP 1: Printing the Connector PCB

The Connector PCB will connect the OpenMV camera to the SPIKE Prime.


Go to the Google Drive folder and download "OpenMV v3 Manutacturing.fzz" file. There are many companies that can manufacture PCBs for you. Find the one that is nearby.

OR,

If you have access to a makerspace and you can use Desktop PCB Milling Machine by Bantam Tool download "OpenMV v2 Othermill.fzz" file and print them.

OR,

You can do it at your home. Follow the instructions here. https://www.instructables.com/id/DIY-PCB-Etching.... If you want to open the file go to and download/install Fritzing on your computer and open the design on your computer.

STEP 2: 3D Printing the Case

3D Print "backpack OpenMV lid v1.0.stl" and "backpack OpenMV v1.0.stl".

Our prints were made using Form 2 Printer. You may need to adjust the dimension based on your printer and you may need to sand down the sides to press fit.

STEP 3: Soldering Header Pins

Solder 2 - 1x8 Female header pins (long pins) to the OpenMV camera.

Also, solder 1x4 Female header pins and 1x8 Male 1.27 header pins to the Connector PCB.

STEP 4: Inserting Connector PCB Inside the Case

Secure the PCB inside the 3D printed case using M2 nuts and bolts.

STEP 5: Placing the OpenMV Inside the 3D Printed Case

Place the OpenMV camera over the connector PCB inside the case.

Close the 3D printed case with the 3D printed lid.

Note: Clip the long pins of the top four legs if they hit the bolt.

STEP 6: Connecting the Backpack to Distance Sensor Connector

Unscrew and take out the connector from the LEGO SPIKE Prime Distance Sensor and plug it to the backpack. The headers are small, so be careful while plugging it in.

STEP 7: Encasing the Backpack in Paper Cover

Download the paper cover design from our Google Drive Folder. Print it in color if have access to color printer. B/W printer will work as well.

If you have access to a laser cutter then use laser cutter to cut the design. If not, use scissors to cut them or use X-acto knives.


Fold them and wrap them around the 3D printed case. Use beams and pegs to secure the paper on the case.

19 Comments

It's amazing to me that even though the code was posted here over a year ago for using the OpenMV camera with LEGO Spike Prime, that only two people beside myself have left any comments or questions.
I just figured out how to increase the data transfer rate from the OpenMV to the Spike Prime. I deleted a couple of delays in the OpenMV and Spike code and now everything is working perfectly. I've been experimenting with using a camera on a LEGO robot for many years (mainly for homing in on colored balls) all the way back to the original CMUcam and later the Pixy camera, and had almost given up hope of getting the OpenMV to work. So glad it finally does!
Help! Same problem
where did you find the code?
thanks
silvia
Hi Silvia,
As I mentioned in one of my comments, I discovered that they had posted the code for communicating between an OpenMV camera and a Spike Prime Hub about nine months ago. Up until then I had an OpenMV that was just sitting on the shelf gathering dust. Scroll all the way down to the end of the comments and click on the words "3 answers" and there'll be a link to the code. Make sure you scroll down past the list of Python programs to where it says: "LEGO Spike Prime Backpack examples" and read the instructions for the OpenMV camera and Spike Prime..
The examples don't include color tracking, but I can send it to you if you need it. Good Luck,
Marc
Thanks for answering so quickly!
I hadn’t found this instructables, so I bought Anthony’s board, but I got the same problem for data transfer.
I found the code and will try it out. it would be great if you could send me the code for colour tracking.
thanks a lot, silvia
.
Are you referring to the board from Anton's Mindstorms Hacks that you plug into the OpenMV so you can use a cable to connect it to a port on the Spike Prime Hub? That's what I use and it makes connecting the two easy.

I can send the code in the next couple of days (OpenMV code for generating the tracking data & sending it the Spike Hub, Spike code to extract the data, & PID code to make use of the data to control the motors on the robot so it can track a colored object.

Exactly!
thanks !
looking forward to try it out
cheers
silvia
I've been experimenting with using cameras with LEGO Mindstorms going back to the NXT and EV3, but this is the first time I've been able to share what I've learned with someone else, so it's fun for me to help you get started. I suggest you test your setup with the OpenMV & Spike SendNumbers.py programs before attempting to do color tracking. In order to get the OpenMV flash drive to appear on your desktop, you'll need to click the connector icon (above the arrow) at the bottom left of the OpenMV IDE. Then copy the LPF2.py code into a new file, save it to the desktop and drag it onto the OpenMV flash drive. Also, I had to comment out line 15 (hub.port.B.device.mode(0) in the Spike code to avoid getting an error message. Hope this helps and let me know if you get stuck.
Marc


Hi Marc!
I'm trying to run the openMV_SendNumbers_SPIKEcode.py program but I can't run it. How do you program the Spike in micropython?
Thanks
Mirko
Hi Mirko,
When you say you can't run the program, do you mean you're getting an error message or that you're not able to do Python programming in the Spike Prime software? LEGO recently came out with a new version of the software (I believe it's version 3.0) which no longer includes the Python capability, so you'd have to go back to version 2.0 which I think is still available on the LEGO Spike website. On the other hand, if you're getting an error message, you'll need to delete line 15 of the Spike SendNumbers code: hub.port.B.device.mode(0). Hope this helps.
Marc

p.s. Just thought of something else.The software for LEGO Mindstorms Inventor (the retail version of Spike Prime) still has Python coding available. You should be able to find it online. It will work fine on your Spike Prime Hub. When you connect to your computer and launch the software, it will ask if you want to update the firmware. Click on ok and you should be good to go.
Thank you so much Marc! I was able to run the program on the robot using the LEGO Mindstorms Inventor software. Yesterday I tried to use the Spike 2.0 app but it didn't detect the OpenMV when I ran the code. Using Inventor instead it worked right away. Thanks so much for your help, I probably wouldn't have succeeded without your help. In the next few days I will try to use the OpenMV to detect colors.
Have a nice day!
Mirko
Glad to hear you got everything to work!. Let me know if you have any trouble getting color detection going. Marc
Just wondering if you were able to get the SendNumbers program working. I checked my notes, and there are several details you have to get right for everything to work if you're still interested. Marc
Hi unfortunately no time ! Tomorrow afternoon!!! I will let you know
Till soon
A few years ago I bought an OpenMV camera which I hoped to use for color tracking with a LEGO Spike Prime robot. Unfortunately, I could never figure out how to send the tracking data from the OpenMV to the Spike HUB. At that time, I posted a comment to that effect on this page and got a response saying they would eventually post the code that would allow me to do this. Fast forward to a few days ago, when almost by accident I returned to this page and discovered that the code I needed had been posted several months ago. I had a little trouble getting the code to work, but once I deleted this line in the Spike code: (I was getting an "object has no attribute 'mode'" error)...

hub.port.B.device.mode(0)

...it worked ok.

I noticed that on Anton's Mindstorms Hacks website, he used the same Spike code in a project of his and didn't include this line of code, so you may already be aware of this.

So now that I've gotten everything working, I was wondering if there is anyway to increase the data transfer rate from the OpenMV to the Spike Hub. WIth the current setup, I could only get about five 8 bit values per second into the Spike Hub.

Thanks for posting the code for this project and hope others are benefiting from it as well.

Marc Helfman
Kenwood, CA





It would be great to be able to use an OpenMV camera with Spike Prime.The Instructable does a good job of showing how to connect the camera to the distance sensor port, but how do you use the camera data in your Scratch program? Do you just read a value (x centroid?) as though you were getting a value from the distance sensor, or is there some additional software required?
A few years ago I bought an OpenMV camera which I hoped to use for color tracking with a LEGO Spike Prime robot. Unfortunately, I could never figure out how to send the tracking data from the OpenMV to the Spike HUB. At that time, I posted a comment to that effect on this page and got a response saying they would eventually post the code that would allow me to do this. Fast forward to a few days ago, when almost by accident I returned to this page and discovered that the code I needed had been posted several months ago. I had a little trouble getting the code to work, but once I deleted this line in the Spike code: (I was getting an "object has no attribute 'mode'" error)...

hub.port.B.device.mode(0)

...it worked ok.

I noticed that on Anton's Mindstorms Hacks website, he used the same Spike code in a project of his and didn't include this line of code, so you may already be aware of this.

So now that I've gotten everything working, I was wondering if there is anyway to increase the data transfer rate from the OpenMV to the Spike Hub. WIth the current setup, I could only get about five 8 bit values per second into the Spike Hub.

Thanks for posting the code for this project and hope others are benefiting from it as well.

Marc Helfman
Kenwood, CA








Thank you for your comment and for your great question. You will need to program the OpenMV camera such that the SPIKE Prime can read the camera data and it could be anything : color data, image detection data, etc. Connecting on the distance sensor port is just an easy way of connecting our backpack to the SPIKE Prime, it does not automatically detect the camera. We will let you know when it is possible to share the sample camera codes with you.