Wemos D1 Mini I2C Dual Motor Driver Shield Documentation
The Wemos D1 Mini I2C Dual Motor Driver Shield is a compact and versatile motor control solution designed specifically for the Wemos D1 Mini development board. This shield allows users to control two DC motors simultaneously, making it an ideal choice for robotics, automation, and IoT projects. The shield utilizes the I2C communication protocol, ensuring efficient and reliable motor control.
Dual DC motor control: Supports two DC motors with a maximum current of 1.5A each
I2C communication protocol: Simplifies motor control and reduces wiring complexity
Compatible with Wemos D1 Mini development board
Compact design: Easy to integrate into robotic and automation projects
5V operating voltage: Compatible with most motor applications
The Wemos D1 Mini I2C Dual Motor Driver Shield has the following pinout:
VCC: 5V power input
GND: Ground
SCL: I2C clock signal
SDA: I2C data signal
M1A, M1B: Motor 1 output terminals
M2A, M2B: Motor 2 output terminals
### Example 1: Basic Motor Control using Arduino
This example demonstrates how to control a single motor using the Wemos D1 Mini I2C Dual Motor Driver Shield. The motor will rotate in both clockwise and counterclockwise directions.
```c++
#include <Wire.h> // Include I2C library
#define MOTOR_DRIVER_ADDRESS 0x60 // I2C address of the motor driver shield
void setup() {
Wire.begin(); // Initialize I2C
}
void loop() {
// Set motor 1 to rotate clockwise
Wire.beginTransmission(MOTOR_DRIVER_ADDRESS);
Wire.write(0x00); // Command to set motor 1 direction
Wire.write(0x01); // Set motor 1 to rotate clockwise
Wire.endTransmission();
delay(1000); // Wait 1 second
// Set motor 1 to rotate counterclockwise
Wire.beginTransmission(MOTOR_DRIVER_ADDRESS);
Wire.write(0x00); // Command to set motor 1 direction
Wire.write(0x02); // Set motor 1 to rotate counterclockwise
Wire.endTransmission();
delay(1000); // Wait 1 second
}
```
### Example 2: Controlling Two Motors using Python (MicroPython)
This example demonstrates how to control two motors simultaneously using the Wemos D1 Mini I2C Dual Motor Driver Shield and MicroPython.
```python
import machine
import utime
# Initialize I2C
i2c = machine.I2C(scl=machine.Pin(5), sda=machine.Pin(4))
# I2C address of the motor driver shield
motor_driver_address = 0x60
def set_motor(motor, direction):
# Set motor direction (1 for clockwise, 2 for counterclockwise)
i2c.writeto(motor_driver_address, bytearray([0x00, direction]))
while True:
# Set motor 1 to rotate clockwise
set_motor(1, 1)
# Set motor 2 to rotate counterclockwise
set_motor(2, 2)
utime.sleep(1) # Wait 1 second
# Set motor 1 to rotate counterclockwise
set_motor(1, 2)
# Set motor 2 to rotate clockwise
set_motor(2, 1)
utime.sleep(1) # Wait 1 second
```
### Example 3: Motor Speed Control using Lua (NodeMCU)
This example demonstrates how to control the speed of a single motor using the Wemos D1 Mini I2C Dual Motor Driver Shield and NodeMCU Lua.
```lua
i2c.setup(0, 5, 4) -- Initialize I2C on pins 5 and 4
local motor_driver_address = 0x60
function set_motor_speed(motor, speed)
-- Set motor speed (0-255)
i2c.start(0)
i2c.address(motor_driver_address, i2c.TRANSMITTER)
i2c.write(string.char(0x01, speed)) -- Command to set motor speed
i2c.stop()
end
while true do
-- Set motor 1 speed to 128 (half speed)
set_motor_speed(1, 128)
tmr.delay(1000000) -- Wait 1 second
-- Set motor 1 speed to 255 (full speed)
set_motor_speed(1, 255)
tmr.delay(1000000) -- Wait 1 second
end
```
In the above examples, the I2C address of the motor driver shield is assumed to be 0x60. Please check the specific address of your shield and update the code accordingly.
The motor driver shield uses a 5V operating voltage, so ensure that your power supply matches this requirement.
When using the motor driver shield, ensure that the motor connections are secure and properly insulated to prevent electrical shock or short circuits.