This instructable offers you to make your own ColorScanner. It's not a basic scanner, it scans the objects color, converts to RGB value and saves in a database. Each scanned object is shown in a table with the datetime and the colorvalue. On the webserver, which is written in php, there is a list with the Color name for each value as well. The scanner is connected on Arduino UNO through Raspberry PI.
How do we create this? I want to focus on 3 aspects. The housing of the scanner, Arduino/Pi and Php/Mysql.
I wish you good luck and have fun.
Step 1: Required Material
First of, the most important thing to create the ColorScanner is having the right material.
So what do we need?
* A wooden box/casket (Wine)
* Additional Wooden planks (34cm by 18cm)
* Steel nails
* Arduino UNO
* 4 Jump wires
* Raspberry PI 3
* Arduino USB cable
* Adafruit Tcs34725 Color Sensor
* Raspberry Adapter
Step 2: The Housing
The housing of our ColorScanner is quite simple.
First of all, you want to get yourself a wooden box with one side fully open.
My box was originally a wooden wine box, which i cleaned & scoured up. I cut out about 3/4 of one side. This allowed me to use the other 1/4 as space for my arduino components.
If you can't find your own box, feel free to make your own box with wooden planks. Ideal box measurements are height: 22cm, width: 17.5cm and length: 34cm.
It's much more convenient to actually you an existing wooden box than rather make it yourself, it will save you a lot of time.
To hide the arduino components, we will use an additional plank (18cm by 32cm) with a hole in the middle, which you can easily drill yourself (diameter: 3cm).
Additionally, based on preferrence you can decide how far you cut the wood out on the side. Since mine still had 8cm of wood, i used a wooden block/platform (6cm height) to place my arduino breadboard. To have a nice outcome with my plank.You can also use any other object, to give your breadboard the needed height.
At the left back of the box, i drilled another hole (diameter: 2cm). This was purely for my raspberry Pi adapter.
Step 3: The Arduino + Raspberry Pi
Arduino Wiring (Color Sensor):
Connect jumpers from:
5v -> VIN (red wire)
GND -> GND (black wire)
SDA -> SDA (orange wire)
SCL -> SCL (white wire)
Note: On older Arduinos such as the Duemilanove and pre R3 UNOs, SDA is on Analog 4 and SCL is on Analog 5.On pre-R2 Megas, SDA is on Digtital 20 and SCL is on digital 21.For the Leonardo, SDA is digital pin 2 and SCL is digital pin 3.
Raspberry Pi Wiring:
Connect Arduino Uno to Raspberry Pi 3.
Plug your Arduino USB cable onto your Pi device.
Step 4: Arduino Code
To let the TCS34725 work properly and let it RGB read values, we use the following Arduino Code.
Make sure to use this library: https://github.com/adafruit/Adafruit_TCS34725
Step 5: Setting Up Raspberry Pi
Install the OS Raspbian on your Raspberry Pi.
Now follow these steps to create an apache webserver with PhpMyAdmin.
After you've done these steps, it's time to connect Arduino.
First type in the Terminal: sudo apt-get install arduino
Then Plug your Arduino into your Raspberry Pi.
To test the port type: minicom -b 9600 -o -D /dev/ttyAMA0
Other than that, you should be good to continue.
Step 6: Database
Now it's time to create your Database. Since we have all different preferrences to name something, i won't share a file because it's quite easy to create your own.
First of all we want our RGB values in the Database. Therefore we create:
* A table called Color which contains 4 Columns (ColorID, R, G, B) --> Type: Integers (INT)
We also want to know when we scanned an object, therefore we create:
* A table called Time which contains 1 column (Time) --> Type: TIMESTAMP
Save everything and you are good to go.
Step 7: Raspberry Pi Code (Startup)
Whenever our Pi is booted up, we want it so it runs automatically a script for us. We can do this quite easily by:
* Typing sudo raspi-config in the console.
* Boot Options -> Desktop/CLI -> Console Autologin
* Adding our .Py script into the /home/pi/
* Typing sudo nano /etc/profile in the terminal.
* Adding the following line at the bottom sudo python /home/pi/colorscanner.py
* Reboot sudo reboot
Use the following Startup file.
Step 8: Php Template
Last but not least, we add our Php template (.rar file) to "/var/www/html" directory. Make sure you have full ownership and you should be good to go.
The markup is up to you. You can decide what your template needs to look like.
You can use my example .rar to show what it can look like.
We have a be nice policy.
Please be positive and constructive.