DIY Image Sensor and Digital Camera

29,366

101

16

Introduction: DIY Image Sensor and Digital Camera

About: I'm a content creator. I make open source projects and videos for said projects. My goal is to create free and open knowledge for everyone.

There are many tutorials online about building your own film camera, but I don't think there are any about building your own image sensor! Off the shelf image sensors are available from a lot of companies online, and using them would make designing your own digital camera not super difficult(but still very hard!). I wanted to take it to the next level and use only simple components, break it down to the most basic parts, so that you're controlling every aspect of the design and programming.

I'm calling the project the "DigiObscura".

If you watch the video below you will see that the original plan was to use a pin hole. However that idea is shelved for now, due to the nature of these sensors. I'm sure there is a way to make it work, but I'm extremely happy with the solution I came up with.

Check it out!

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Watch the Video!

I explain a majority of the project in detail in the video, it should set you in the right direction.

Step 2: Gather the Parts!

This project isn't really cheap, or easy. But if you're looking for a challenge and a way to learn about how digital cameras work, this is definitely for you!

You will need to be able to 3D print parts, solder circuit boards, program Arduinos, and have a basic understanding of how cameras work.

If you order the parts through the PCBWay link I get a percentage of the sale!

Parts

  • Microcontroller Circuit Board (PCBWay (Affiliate Link) or GitHub)
  • Image Sensor Circuit Board (PCBWay or GitHub) - Don't forget to order a stencil!
  • BOM for Micrcocontroller PCB and Image Sensor (FindChips)
  • Heat Set Threaded Inserts M3 (McMaster-Carr)
  • Button
  • M3 Screws
  • Magnifying Glass
  • OLED Screen (Optional)
  • SD Card
  • 18650 Battery (Optional)

Step 3: Start the 3D Prints

If you have the boards and parts already, its time to start the 3D prints. Head on over to thingiverse and download the files. If you need to modify them you can get the Fusion 360 files from the GitHub.

Thingiverse Files: https://www.thingiverse.com/thing:4070769

The prints will take a while. You can print at 0.2mm layer height and 5% infill as these parts don't need a lot of strength.

My lens mount will only work if you use the old Canon 35-105 as I mentioned in the video. You can find them pretty cheap used or even broken, since you're only using the outer glass.

Step 4: Populate the Image Sensor

I like to do the hardest things first, and this is definitely the most challenging part of the build. The image sensor has 1024 light sensors. If you don't own your own pick and place machine, you're going to be doing this for awhile. I think it took me about 2.5hrs non-stop to place all of the components and I considering myself pretty good at it(done a lot of assembly). So if you're new, definitely practice a lot before trying this. My neck was hurting pretty bad after. You can also order them pre-assembled from a lot of PCB fab houses now. I haven't done it for this board, but it should be easy if you have done it before. If you make a mistake on this board, debugging could be challenging, make sure you at least place all of the components in the same direction.

Spread out the solder paste and get populating...

Step 5: Populate the Microcontroller Board

The microcontroller board is a lot simpler compared to the image sensor. If you completed the image sensor without fail, this should be a breeze. There aren't a lot of components so just follow the schematic and board files on KiCad and it shouldn't take long.

Once you solder on the surface mount components, do the through hole components. The headers for the image sensor will go on the back of the board(opposite to the surface mount components).

Step 6: Program the Bootloader

The Microcontroller will now need the bootloader. You can choose either the "Feather M0" in the Adafruit collection of boards, or the "SAMD Dev Breakout" by Sparkfun. Either will work, and I suggest you use what is more familiar to you.

I have done other videos that show this process, and will not describe it in detail in this instructable, there is already a lot going on in this one.

Step 7: Put in Threaded Inserts

Hopefully your prints have finished by this point.

The 3D prints are designed to accept heated brass threaded inserts. Take your time to install them all straight. There are 4 for the image sensor, 4 for the arduino board, 4 for the lens mount, and 3 for the tripod mount.

You could probably get away with 2 instead of 4 for each of the PCB mounts, there isn't a lot of stress on any of these parts. Your call.

Step 8: Assemble the Camera Body

There are not a lot of parts. Follow the assembly in the image above. Use M3 screws where needed.

The button will be installed in the upper hole in the camera body, and attached to the arduino PCB via the JST connector.

Step 9: Finding a Lens

I originally planned on making this a pinhole camera, but that didn't really work out. In my case I decided to take apart an old broken Canon 35-105 lens and use the front glass. The front glass is basically a magnifying glass but produces less distortion on the image. If you can't find a broken lens to use, a regular magnifying glass would work fine. Try to find something with only a 2x or 3x magnification otherwise the distance to the image sensor will be too big. You will likely need to modify the lens mount 3D print file to suit your needs. When making a new file you will need to find the focal plane distance, which is the distance from the lens to the image sensor where things are in focus. I explain this in better detail in the video.

Step 10: Programming and Testing the Arduino

I have included two different programs in the GitHub. Both are equally useful but the "Webcam" firmware is better for debugging, so I recommend starting with that.

Upload the firmware to the Arduino.

Now its time to see if everything is soldered properly. If you don't have it already, get the "Processing" program. There are two parts to the Webcam firmware. One runs on the camera, the other runs on your computer in Processing.

When you have the firmware uploaded to the camera, open processing and run the program. Make sure you choose the correct COM port. If you're going to test it out make sure you point it at something with a lot of contrast and a lot of light. It helps if you know what the camera is looking at!

If all it working you should have an image being generated from the camera! Try not to move the camera as it is constantly generating a new image.

Step 11: Add the Camera Firmware

If everything checks out in Processing, the remaining firmware will turn your 3D printed box of electronics into a full blown digital camera(the lowest resolution camera ever).

Upload the digital camera firmware.

Install an SD card and battery. The camera won't let you take pictures unless there is an SD card present and it will say so on the OLED display if you have one connected.

Your camera is ready to take some pictures!

Step 12: Setting Up Photos

I think we all know by now that this is an experiment in making your own digital camera, and you're not going to be able to get amazing images out of it. Quite frankly getting any image out of your own DIY digital camera is a feat in itself, but I was blown away by the amount of details that are visible.

Its not going to do well in just general photography. You will need high contrast and large objects to see anything really.

Taking a picture of my face worked best when the background was dark and my face was well lit.

Play around with it and learn, and please, try messing with the Arduino Firmware and try and make it better.

Step 13: You're a Pro!

If you finished this project and its working, seriously impressive.

Tweet at me with your images, I want to see what you come up with.

Step 14: Support Future Projects!

All of these projects are free open source, and I try to make them as accessible as possible. If you are a fan of my work, and you can afford it, consider supporting me by becoming a patron on Patreon. My patrons are what make these projects possible.

https://www.patreon.com/seanhodgins

If you enjoy the videos head over to my YouTube and hit that subscribe button! (or just click the link below)

SeanHodgins on Youtube

Thanks for all of your support!

Feel free to share this project on Reddit, Twitter, Instagram, and anywhere else you want. On twitter and Instagram be sure to tag me @idlehandsdev so I can thank you!

STEM Contest

This is an entry in the
STEM Contest

Be the First to Share

    Recommendations

    • Magnets Challenge

      Magnets Challenge
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest

    16 Discussions

    0
    ProfHankD
    ProfHankD

    21 days ago

    Pitty you didn't use LEDs for your sensor. There's a lovely little trick where you can use a LED alternatively as a light emitter and detector -- so you could have your camera collect an image of the scene and then project an aligned image on the scene. My brother, Paul Dietz, has done a lot with LEDs and I've played with it many times too, including having students do projects with LED arrays for image capture/projection, but never with anywhere near 1024 LEDs. Paul's got sample code posted at https://github.com/paulhdietz/LEDSensors2019/blob/master/LEDs%20as%20Sensors%20SIGGRAPH%202019%20Code/_03_SenseAndLight/_03_SenseAndLight.ino

    0
    needfulthing
    needfulthing

    Reply 10 days ago

    I tried using LEDs as light sensors in a voltage divider setup, but never got reliable results that came close to what a photo resistor delivers. Some people suggested IR LEDs because of their higher sensitivity as a sensor, but it was still not worth the effort looking at the results apart from the rare case you can not get your hands on a photo resistor. But maybe I was doing something wrong?

    0
    ProfHankD
    ProfHankD

    Reply 9 days ago

    My brother's original paper on the bidirectional LED use is http://www.merl.com/publications/docs/TR2003-35.pdf -- he basically reverse biases the LED diode to charge a capacitance and then times discharging to a digital input threshold. ADC is by measuring the time taken to discharge. LEDs aren't very sensitive as detectors, but can be sampled in under 100us in normal room lighting. Some LEDs are more sensitive than others, but LEDs generally are sensitive only to a relatively narrow wavelength range near what they emit; bad news is they don't sense all light, good news is that you can make a color sensor. BTW, I've had two separate undergrad student project teams manage to not get this to work right... so, you're ahead of the game already. ;-)

    1
    rakrupski
    rakrupski

    17 days ago

    Had an idea... be even more awesome!

    Get an appropriate diameter WS2812 RGB LED ring, put it around your lens like one of those "shadowless" lights, then write a bit of code to do "all red, expose, all green, expose, all blue, expose" then Photoshop the 3 images together with the appropriate color layers.

    Now your camera shoots in FULL COLOR!

    0
    PyaeP1
    PyaeP1

    Reply 16 days ago

    educated guess :D

    0
    rakrupski
    rakrupski

    17 days ago

    That was one of the coolest projects I've seen in a long time! Awesome!

    Long time ago in the late 1980's I used to burn 2764 EPROMS for use in Radio Shack Color Computer projects. One day I noticed that the COCO would crash if I had a windowed EPROM (uncovered) and shined a bright light on it. With the light removed, the EPROM worked again, so I knew that it was merely affected by the light, not permanently erased like a UV lamp would do.

    So I wired one up in free address space on the COCO and wrote a small Basic program to "scan" an EPROM that was fully programmed (all bits/bytes 0). By shining a light on it, I got an "image" - blobs of area that were either all white or black (on or off - no grayscale in between).

    Next I tried a lens (an eye loupe) and could make out a correspondence between the blobs and the scene. I discovered that the memory cells in the EPROM were not laid out in a nice linear X-Y fashion, but in two halves, one the mirror image of the other!

    That is, IF it could actually make a decent image, one half would be normal and the other half backwards.

    With your camera, have you tried taking several shots in a row then averaging them to get better results?

    Anyway, once again awesome project you made. Love it!

    0
    The Electrobot
    The Electrobot

    20 days ago

    Good and very well executed ible. Soldering 1024 SMD would have been quite a challenge though.

    If I might suggest 3 variations.
    1. Shifting the image sensor in x and Y direction to get more effective pixels. It would require a mechanical arrangement and stable subjects. The software could be used to stitch multiple images taken with different sensor positions together to get a higher combined pixel count.
    2. Using three or four rows of staggered LED rows and mechanically scan for the column. This will result in lesser LEDs. This will be similar to how scanners work...
    3. Using 3mm transparent dome LEDs as sensors. The dome will act as a lens and focus the light on the LED chip and will result in increased light sensitivity.



    0
    jessyratfink
    jessyratfink

    Reply 21 days ago

    Yay!! Congrats Sean :D

    0
    Ferferite
    Ferferite

    22 days ago

    This is really cool and I would even build one buuut the cost is pretty high(at least for me since i am 13). I might try to save up and make a bigger sensor. I jsut love cameras and diy cameras!

    2
    hdreiling
    hdreiling

    24 days ago

    WoW... this is really cool, remembers me of the 1980ies when my first image sensor was made out of a windowed DRAM.

    1
    RomasP
    RomasP

    24 days ago

    Great project! I would suggest making one with deep IR sensor diodes, lens from laser cutter. There would be real IR camera
    I would suggest to add calibration data for every pixel. Calculated from total dark ant fully white images

    1
    Alex in NZ
    Alex in NZ

    25 days ago

    Respect! That is an impressive dedication to place your pixels. When I saw the title I thought that you might have been going to create a sensor from a (possibly old) RAM chip, but soldering up your own array is impressive indeed. Thank you for sharing your work :-)

    1
    audreyobscura
    audreyobscura

    25 days ago

    This is brilliant! Thank you so much for sharing this. I'm shook that you hand set all of those light sensors 0_0 impressive!