Award
Congratulations Jeremie, for answering the question and has received an EZ-Credit award! Share what you have learned and create a tutorial to help others by clicking here.

I2c Information Update?

Assistance Requested

Help OldBotBuilder with their question and receive $10 of EZ-Credit to get more robots and parts from our store. The following information was provided about their previous efforts searching tutorials for a resolution.

OldBotBuilder claims to have checked these sources:
 
#1

DJ, Anybody,

Is there new information about I2C? The last reference I can find is:
http://www.ez-robot.com/Community/Forum/posts.aspx?threadId=322

I am trying to write a script that will have the EZ-B v4 respond as an I2C slave to a master I2C device. To do this, the master device sends the EZ-B data, the EZ-b is then able to respond by sending data to the master.

The script fails and the WiFi connection is broken.
I have to power down, then reconnect the EZ-B.

Here is a script snippet:
(The address of the master is 0x4)
>> The master is in a loop I2C writing a '1', then I2C reading <<
:loop
$V1 = I2CRead(0,0x4,1)
Print ("V1 = "+$V1)
I2CWrite(0,0x4,40) #decimal 40 is the value I want written
sleep(1000)
goto(loop)

Thank you.

I have found a few conversations, tutorials and activities that may help with your question. Take a look at these links. I've sorted them by what I believe to be most relevant but that is not always the case as I'm still learning.


Also, consider reviewing the Learn section for informative lessons and activities. Check it out!


#2

You are unable to "read" unless there is a request sent.

Attempting to read i2c will pause forever (as you are experiencing) without knowing there is data. Do something like this...


1) Send a request for data

2) Read the known data size that has been requested

#3

For more information, look at the i2c BlinkM example...

Code:


# Shift the bits over
# Set the LSB (first bit) to a 1
# When first bit is a 1 on i2c, that means
# it is a Read Address
$i2cAddress = 0x09

Print("BlinkM Address: " + $i2cAddress)

# Tell BlinkM we want the RGB Values
i2cWrite(0, $i2cAddress, 0x67)

# Receive the RGB Values
$raw = i2cRead(0, AUTO, $i2cAddress , 3)

# Print the number of bytes
Print("Received: " + Length($Raw) + " Bytes"Winky

# Print the hex value of each byte
PrintHex($Raw)

# Split the array of bytes and assign to each variable
$Red = GetByte($Raw[0])
$Green = GetByte($Raw[1])
$Blue = GetByte($Raw[2])

#4

DJ,

Thanks for the quick reply.

Your script is setting the EZ-b as the master and the BlinkM as the slave.
I need the EZ-b to be the slave.

#5

The EZ-B is unable to be a slave - it's configured as a master by factory.

#6

I am trying to use the EZ-b as a 'capability enhancer' for robots built with the Lego EV3. To do this the EV3 uses a Dexter Industries I2C sensor block. This block sets the EV3 as the I2C master.

I have connected the EV3 via an arduino and got it to work with the information in http://www.dexterindustries.com/howto/connecting-ev3-arduino/

Near the end is a section headed "EV3 as the Master".

BTW-
http://www.ez-robot.com/Community/Forum/Thread?threadId=6532 shows the robot that I wish to 'enhance' with all the super EZ-B capabilities.
A video is at: https://www.youtube.com/watch?v=DiGyeV759JE

Again, thanks.

#7

Hi @OldbotBuilder,

You could essentially run your robot with 2 masters. The ez-bv4 can communicate serially to the Arduino. You could write a program on the Arduino that could translate your serial data from the ez-b and create I2C commands to send to the EV3 controller, probably wouldn't be that efficient but it's an idea.

Otherwise, I would suggest to try interfacing the motors and sensors from the EV3 directly to the ez-b. I believe LEGO peripherals also communicate as I2C slaves, but I don't have enough info on these new LEGO kits to confirm that.

#8

From what I read, it looks like the EV3 can only be a Master (no slave option) and the EZB as DJ said likewise is designed to only be a Master.

My thoughts are you would either need to use an Arduino in between the two. Or it might be possible to communicate with the LEGO EV3 over wifi using TCP/IP.
This might work.

#9

Jeremie and JustinRatliff,

Good ideas and I will look into both suggestions.
Thanks to you both.

Now - how does the 'resolved by' credit get assigned?