i2c smsbus

If you need technical help with anything you've bought from Dawn Robotics, please post here.

i2c smsbus

Postby beppeIT » Thu Jan 01, 2015 10:04 pm

I have noticed that the i2c-tools and smsbus (for python) are not present in the image sent with the PI camera Robot Kit.
I want to interface the light sensor I have already connected. I have created a python file, but smsbus module is not found.
Now, considering that the robot creates its own access point, before I damage something: is there a quick and safe way to connect the raspberry to internet (my home access point) so to install tools and module?

maybe connecting it to wired internet?

thx
beppeIT
 
Posts: 6
Joined: Thu Jan 01, 2015 9:58 pm

Re: i2c smsbus

Postby Alan » Fri Jan 02, 2015 8:09 pm

Hi there,

Welcome to the forums. :)

Not sure if you've tried this yet, but yes you're correct that you should just need to connect the Raspberry Pi to a router with an ethernet cable. Then the eth0 network interface should come up automatically and you should have internet access.

It is also possible to modify /etc/network/interfaces to connect to a WiFi network, but the access point setup may interfere a bit here, so probbly best to try a wired connection first if possible.

Regards

Alan
Alan
Site Admin
 
Posts: 311
Joined: Fri Jun 14, 2013 10:09 am

Re: i2c smsbus

Postby beppeIT » Sun Jan 04, 2015 1:37 pm

Hi to everybody,

i have been able to make it work, so i wold like to share with you all the process:
step 1 connect the robot to internet:
- take off the wifi dongle
- just connect to your router with a cable

step 2 install i2c tools and smbus
- to enable i2c follow this link: http://skpang.co.uk/blog/archives/575

step 3 check the i2c address of your device
- run sudo i2cdetect -y 1

I have the light sensor at address 0x28

then run a simple program, if you have the light sensor run mine below (just starting to program in python:
______________________________________
#!/usr/bin/python3

import time
import smbus

from smbus import SMBus

address = 0x29
control_on = 0x03
control_off = 0x00

TSL2561 = SMBus(1)

def enable ():
print "power ON"
TSL2561.write_byte(address, 0x80)
TSL2561.write_byte(address, control_on)
return

def disable():
print "power OFF"
TSL2561.write_byte(address, 0x80)
TSL2561.write_byte(address, control_off)
return

def Light():
var = [0,0,0,0]
var = TSL2561.read_i2c_block_data(0x29, 0x8C)
Channel0 = ((var[1]<<8) + var[0])
Channel1 = ((var[3]<<8) + var[2])
print "TOTAL LIGHT:%5d IR LIGHT:%5d" %(Channel0, Channel1)
return


def main():
enable()
while(True):
Light()
time.sleep(3)

if __name__=="__main__":
main()

_________________________________________
have fun... :D :D :D

big hugs from Italy


Beppe
beppeIT
 
Posts: 6
Joined: Thu Jan 01, 2015 9:58 pm


Return to Technical Support

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest