Grove - I2C Motor Driver - information and source code

It worked fine at first, all connection are ok. I am using a shield with an arduino and the i2c Motor Driver. I tried the code of the link but it does not work, Motor Driver keep all the LEDs on.
I would like to send something to the Motor Driver and this reply through i2c but i am not sure if it is possible.


Did you use jumper wires for this connection? How long?

I used grove universal 20cm cable with a shield connected to arduino


I’m trying to flash the frimware of my I2C motor driver but I’m struggling with the AVR programmer. I bought the AVRISP programmer from seeedstudio.
Please see enclosed a picture which shows how I connect to the board.

A had the similar problem. It was wrong pinout written at the board. But my board looks quite different (may be I have an old version of it).
Try to look at atmega8 datasheet, and check wheather the MISO, MOSI and SCK pins of controller connected to the proper pins of the socket.

Which flashing-program do you use?

So is the actual SOURCE CODE of the firmware somewhere online? The wiki link File:Grove-I2C Motor Driver seems to only have a file with hex values in it, no source code.

I want to know if I can extend the firmware so it can work with dc motors with encoders.

Do you want to connect encoders to this board? How?

I have written an alternative firmware for this board. I can share the source code if it really helps you.

Yes, that would be helpful. I’m interested in using this with the DFRobot Baron-4WD Mobile Platform which has optical encoders or possibly with the Trosson Budget Bot Chassis whose motors use Hall Effect Quadrature Encoders

Here is alternative firmware for the motor driver. I would be grateful to receive any report from you.

But how do you want to connect encoders? There are only 3 inputs available: MOSI, MISO, SCL. But 2 encoders require 4 inputs.

First: Thanks for responding

Second: I wish this forum would show hyperlinks better. I didn’t see that you had one in your response and was going to ask where the firmware was!

On how to connect encoders: I hadn’t realized there weren’t enough inputs available. So that would be a real problem!

Hi all,

I’m also having trouble getting this board up and running. When I connect power all 4 direction and the power led go on. Doesn’t matter whether I2C is connected or not. Any ideas? How to check whether it’s a DOA?

Also, my board has v1.0 printed on the back. Does that mean it’s an outdated version?

And lastly, anyone got stepper motor code for it? That’s what I bought it for but the sample code is only for DC motors.

I’m trying to operate it from an Arduino Uno with several other devices on the I2C bus.

Thanks for any help, Dieter

Ok scrap the all-leds on issue… I was being stupid mixing up 5 and 3.3V VCC…

All help on the other questions still very welcome though!

Looks like an outdated board indeed, it doesn’t have the address dipswitch… Any know if other things have changed as well?

Apart from that, I was able to run the DC motor sample code successfully. I’m now trying to integrate it with my main application which involves other devices on the bus (ADXL345, MPR121). Now all power and direction led’s light again and the board doesn’t respond. Is this a signal for a certain error state that can help me debugging?

Still would like stepper motor action instead of DC, too.

I’ll just keep logging my progress here. Perhaps it’ll help someone at some point…

Turns out my older version board has address 0x28 instead of the current one’s 0x0f.

Looks like my board is the same as the one in the link posted earlier in this thread: (forum doesn’t let me post links)

I found a basic stepper library for the Grove/Twig I2C driver here:
Mind you, serial addresses are set for the older version boards. Change them for newer versions.
The code is also pre-arduino-1.0. I’ve patched 2 files in the repository for 1.0+ compatibility.

Actually the stepper mode is really not complicated, just badly documented in the wiki. What you need to do is set the ‘channel set’ / ‘direction set’ registry alternatingly for your motor’s 2/4/6/8 steps.

When I got TwigMotor working I started merging its I2C functionality with the AccelStepper library: … index.html
It’s a great arduino stepper library with non-blocking code, acceleration/deceleration, etc.
I now have an alpha version of AccelStepper with an additional mode for I2C control of the Grove board (and potentially other I2C stepper drivers). I’ll publish it once it’s cleaned and tested.

  1. Maybe (this picture) will help you
  2. Usually stepper motor is driven by constant current, not voltage. But this board doesn’t allow you to measure the current.
  3. I think it would be better to implement all logic inside the board. I have posted the message about alternative open-source firmware. Please, consider implementing stepper-motor mode in this firmware.

Thanks for chiming in!

I’m not sure what the implications of #2 are. Can you elaborate? Is there going to be issues because of it?
The TwigStepper library sets PWM to 255 before doing the channel switching. Is that related?

As for #3, I don’t have a programmer to upload firmware to my board…

I have some experience in making driver for 12W stepper motors for CNC router.
The classical scheme is the following:

L298 is used with L297, which implements all logic, and controls the current. To control the drive current It compares voltage at SEN1/SEN2 with voltage at VREF.

My stepper motor works at 1.5A. It have resistance about 2 Ohms. So, if you want to run it at constant voltage, maximum voltage is 3V. It is unreal!
If you control the current, you can run it at any input voltage.

I don’t know anything about small stepper motors, maybe there are motors, which can be run at constant voltage 5V or 12V.

L298 have inputs to connect current-sense resistors, but I have never seen an I2C board with this resistors.

I have this motor:

I’ve ran it for a couple of hours and it seemed fine, though it got quite hot. I’m not sure if that’s ok as it’s my first time working with steppers.

Yes, I think you can run this motor without any current-sense.