Introduction: 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.
Supplies
OpenMV camera (link)
OpenMV connector PCB (link)
Headers
2 - 1x8 Female header pins (long pins) (link)
2 - 1x4 Female header pins (comes in the same box as above)
1 - 1x8 Male 1.27 header pins (from Mouser) (link)
Lego pieces
4 - 1x3 beams
1 - 1x7 beam
10 - pegs
1- Distance Sensor connector
Case design (link)
Paper case design (link)
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
7 months ago
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.
1 year ago
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!
Reply 7 months ago
Help! Same problem
where did you find the code?
thanks
silvia
Reply 7 months ago
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
Reply 7 months ago
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
.
Reply 7 months ago
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.
Reply 7 months ago
Exactly!
thanks !
looking forward to try it out
cheers
silvia
Reply 7 months ago
Marc
Reply 7 months ago
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
Reply 7 months ago
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.
Reply 7 months ago
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
Reply 7 months ago
Glad to hear you got everything to work!. Let me know if you have any trouble getting color detection going. Marc
Reply 7 months ago
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
Reply 7 months ago
Hi unfortunately no time ! Tomorrow afternoon!!! I will let you know
Till soon
1 year ago
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
Question 3 years ago on Step 2
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?
Answer 1 year ago
Here are the codes,
https://github.com/ceeoinnovations/SPIKEPrimeBackp...
Regards,
Reply 1 year ago
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
Answer 3 years ago
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.