Advanced search FAQ Register Login

It is currently Tue Jan 23, 2018 4:32 pm

 

Postby Coen » Thu Nov 05, 2015 11:00 am

I'm currently working on a school project with some friends. We want to make a Raspberry Pi robot which will follow a line taped on the ground. We came up with the idea to use a colour sensor. If it sees a specific colour,the robot will go forward and left and right etc. We already have a simple robot which can go forward, backward, left and right.
The only colour sensor we found was on this website. Link: http://www.modmypi.com/raspberry-pi/breakout-boards/adafruit/adafruit-rgb-colour-sensor-with-ir-filter.
On this page there is also a tutorial link, but it leads to a tutorial for the Arduino. My friends and I are not very familiar with mini computers like the Raspberry Pi and Arduino. We're confused since the product page says it's a sensor for the Rapsberry Pi but the tutorial uses an Arduino. We are wondering whether the sensor is made for the Rapsberry Pi or the Arduino, and if it's made for the Arduino we'd like to know if it's also compatible with the Raspberry Pi somehow.

If the colour sensor is compatible with the Raspberry Pi could you please give us a brief tutorial on how to assemble the colour sensor on the Rapsberry Pi.

Sorry if we made any grammar mistakes, English is not our native language.

Thanks in advance.

Coen
n00b

Posts: 7

Joined: Wed Nov 04, 2015 7:31 pm

Location: Netherlands

Postby BMS Doug » Thu Nov 05, 2015 2:53 pm

Adafruit have some sample code for the Raspberry Pi on their Github.

You would connect:
3V3 to 3V3 (GPIO pin 1)
GND to GND (GPIO pin 6)
SCL to I2C SCL (GPIO pin 5)
SDA to I2C SDA (GPIO pin 3)
INT to a GPIO pin setup as an Input (optional: interrupt Pin, tells the Pi that the board has an output to be read)
LED to a GPIO pin setup as an output (optional: pull low to turn off LED).

BMS Doug
31337

Posts: 273

Joined: Tue Sep 08, 2015 3:55 pm

Location: London

Doug.

Volunteer Moderator.

Postby Coen » Thu Nov 05, 2015 10:40 pm

Thanks for your reply. I have a few questions.

Does the sensor goes directly into the Pi? Don't we need something like a breadboard?

In the tutorial where they use the Arduino they use: VIN, GND, SDA and SCL. And you use the 3V3 instead of the VIN. Is this special for the Raspberry?

And as last. I've looked on the GitHub code, but I can't make anything out of that. As I said we're all not very familair with the Raspberry. The only thing we need is the sensor to scan an object and prints the color of the object. Could you help us with that?

Thanks for helping!

Coen
n00b

Posts: 7

Joined: Wed Nov 04, 2015 7:31 pm

Location: Netherlands

Postby BMS Doug » Fri Nov 06, 2015 9:37 am

Coen wrote:Thanks for your reply. I have a few questions.

You are welcome, I'll give you my best answers.

Coen wrote:Does the sensor goes directly into the Pi? Don't we need something like a breadboard?

you can use a breadboard if you like, but it will end up with the connections made to the same places. breadboards are most useful when you need to add other components inline, in this case it would just be an unnecessary joining place between the Pi and the end component (but use one if you want to).

Coen wrote:In the tutorial where they use the Arduino they use: VIN, GND, SDA and SCL. And you use the 3V3 instead of the VIN. Is this special for the Raspberry?

Yes, the Arduino runs natively at 5V, the Pi runs at 3V3. if you connect the Pi's 5V to the colour sensor it will output 5V logic, you don't want to put 5V onto the Pi GPIO pins so you use the 3V3 input instead and the colour sensor then outputs 3V3 logic.

Coen wrote:And as last. I've looked on the GitHub code, but I can't make anything out of that. As I said we're all not very familair with the Raspberry. The only thing we need is the sensor to scan an object and prints the color of the object. Could you help us with that?


Copy the three files from the Adafruit github onto your Pi in a directory you want to use for the project (make one for the purpose).
then Run the example code Adafruit_TCS34725_Example.py and it will give you one of two responses:
either: 'Too dark to determine color temperature!'
or: "Color Temperature: %d K" (where %d is the colorTemp)

Coen wrote:Thanks for helping!


you are welcome.

Please note that I haven't tried any of this out, I don't have the sensor to play with.

BMS Doug
31337

Posts: 273

Joined: Tue Sep 08, 2015 3:55 pm

Location: London

Doug.

Volunteer Moderator.

Postby Coen » Sat Nov 07, 2015 7:25 pm

Thanks!

I think we know enough for now. I'm going to order the sensor but because we live in the Netherlands it will take 1/3 weeks till we have it. So when we have it and we need any help, I will let you know :D

Thanks for everything!

Coen
n00b

Posts: 7

Joined: Wed Nov 04, 2015 7:31 pm

Location: Netherlands

Postby Coen » Mon Jan 11, 2016 9:51 am

Hello again,

It's been a while. We've tried a lot of things with the sensor, but we can't get it working.
We can't figure out with the tutorials how to get the RGB values. Al those tutorials are working with an Arduino and they say nothing about the pi. And as I said, we are beginners with the raspberry so I don't think we can't handle this on our own.
Could someone please help us with this?

Coen
n00b

Posts: 7

Joined: Wed Nov 04, 2015 7:31 pm

Location: Netherlands

Postby BMS Doug » Mon Jan 11, 2016 10:02 am

Could you post a picture of your connections?

Have you copied the three python files from this Adafruit Github repository?

Have you enabled i2c on your raspberry pi? (from the raspi-config).

BMS Doug
31337

Posts: 273

Joined: Tue Sep 08, 2015 3:55 pm

Location: London

Doug.

Volunteer Moderator.

Postby Coen » Mon Jan 11, 2016 10:57 pm

BMS Doug wrote:Could you post a picture of your connections?

Image

Image

The ground(black wire) is connected to another ground from the motors but those aren't connected on the picture. The white, gray and purple wires are from the sensor.

BMS Doug wrote:Have you copied the three python files from this Adafruit Github repository?

We found in the tutorial something about Arduino IDE. So we installed that on our pi but we don't know how to use it and if we really need to use it. Because those files are just python files, can't you just run them through the terminal with: sudo python Adafruit_I2C.py ?

BMS Doug wrote:Have you enabled i2c on your raspberry pi? (from the raspi-config).

No we didn't even know about that :D So we'll enable that.

Coen
n00b

Posts: 7

Joined: Wed Nov 04, 2015 7:31 pm

Location: Netherlands

Postby BMS Doug » Tue Jan 12, 2016 9:20 am

Coen wrote:
BMS Doug wrote:Could you post a picture of your connections?


The ground(black wire) is connected to another ground from the motors but those aren't connected on the picture. The white, gray and purple wires are from the sensor.

BMS Doug wrote:Have you copied the three python files from this Adafruit Github repository?

We found in the tutorial something about Arduino IDE. So we installed that on our pi but we don't know how to use it and if we really need to use it. Because those files are just python files, can't you just run them through the terminal with: sudo python Adafruit_I2C.py ?

BMS Doug wrote:Have you enabled i2c on your raspberry pi? (from the raspi-config).

No we didn't even know about that :D So we'll enable that.


Great pictures, the connections are correct.
you need to copy the files onto the pi and run them on the Pi, specifically you want to run Adafruit_TCS34725_Example.py

Code: Select all

sudo python Adafruit_TCS34725_Example.py

but you need all three python files to be present in the same directory in the Pi as the example python program imports code from the other two programs.

If you follow these instructions from adafruit it will download all of the adafruit sample code for the raspberry pi, then you just need to change your working directory so that you are in the TCS34725 sub directory and run the code as described above.

Code: Select all

cd /Adafruit-Raspberry-Pi-Python-Code/Adafruit_TCS34725

Code: Select all

sudo python Adafruit_TCS34725_Example.py


I hope this helps.

BMS Doug
31337

Posts: 273

Joined: Tue Sep 08, 2015 3:55 pm

Location: London

Doug.

Volunteer Moderator.

Postby BMS Doug » Tue Jan 12, 2016 6:09 pm

Coen wrote:We found in the tutorial something about Arduino IDE. So we installed that on our pi but we don't know how to use it and if we really need to use it. Because those files are just python files, can't you just run them through the terminal with: sudo python Adafruit_I2C.py ?


An arduino IDE is a Development Environment for the Arduino (not very useful if you don't have an arduino).
Adafruit have a WEBIDE which installs a Webbased IDE on the Pi, you can navigate to it from a PC web browser and control what is happening on your Pi from your PC (as long as it is on the same network). This isn't all that useful if you have the Pi setup with a keyboard, mouse and monitor.

BMS Doug
31337

Posts: 273

Joined: Tue Sep 08, 2015 3:55 pm

Location: London

Doug.

Volunteer Moderator.
Next

Who is online

Users browsing this forum: No registered users and 1 guest

Board index

The teamDelete all board cookies • All times are UTC [ DST ]