"Adafruit Motor Shield v2"

From Let's Control It
Jump to: navigation, search

Introduction

This Plugin in currently only available in the latest mega build github

This Plugin is for the Adafruit Motor Shield v2 which is controlled over the I2C protocol. To connect it to ESP8266 devices (e.g. Wemos D1 R2) you have to set it to 3.3 V, see adafruit documentation for that.

Hardware

This Plugin works with the v2 version of the Adafruit Motor Shield v2: Support the great developer of this board with buying it from them! (you will also find cheaper clones on Aliexpress, which also work with this plugin)

Adafruit motorshield v2.jpg

This Picture shows a clone board.

Software

The Plugin is heavily based on Adafruits own Library


ESP Easy

Use the device tab on the ESP Easy webinterface and create a new task by editing one of the available tasks. Select "Adafruit Motor Shield v2" from the dropdown box.

Enter the i2c address of you sensor, default value 0x60

Motor shield settings.jpg

Controlling the Motor Shield via HTTP commands

You can control the Motorshield by remote http commands send from your Home Automation Controller or any other device that can send http get requests.

Command format:

For DC Motors:

 http://<ESP IP address>/control?cmd=MotorShieldCMD,DCMotor,<Motornumber>,<Forward/Backward/Release>,<Speed>

For Steppers:

 http://<ESP IP address>/control?cmd=MotorShieldCMD,Stepper,<Motornumber>,<Forward/Backward/Release>,<Steps>,<SINGLE/DOUBLE/INTERLEAVE/MICROSTEP>

Examples: Turn on DC Motor, Direction: Forward. Speed is a value from 0-255

 http://<ESP IP address>/control?cmd=MotorShieldCMD,DCMotor,1,Forward,255

Stopping the DC Motor:

 http://<ESP IP address>/control?cmd=MotorShieldCMD,DCMotor,1,Release


control a Servo Motor

Support for Servo Motors is available via the buildtin functionality of ESPEasy (not part of this plugin) and can be done this way:

 http://<ESP IP address>/control?cmd=Servo,<servo nr>,<pin>,<position>

We currently support a maximum of two servo motors so you can build a pan & tilt device if you like.

Example to set servo 1 on gpio-0 to a 90 degree position and servo 2 on gpio-2 to a 45 degree position:

 http://<ESP IP address>/control?cmd=Servo,1,0,90
 http://<ESP IP address>/control?cmd=Servo,2,2,45