D1 Mini Shield – AT8870 Motor

Last Updated on 15. October 2026 by SuffocationLink status: OK

Motorplatine zur Ansteuerung von zwei Motoren (6,6 V – 38 V) über den I²C-Bus

For the D1 mini ESP8266 and ESP32, go here:

Facts

  • Versorgungsspannung 6,6V – 38 V
  • Maximaler Dauerstrom 2A (kurzzeitig bis zu 3,6A)
  • Steuerung Vorwärts/Rückwärts (Geschwindigkeit), Stopp/Bremsen
DescriptionNamePin
I²C ClockSCL5 (D1)
I²C DataSeventh-day Adventist4 (D2)
Motor A Anschluss 11A
Motor A Anschluss 22A
Motor B Anschluss 11B
Motor B Anschluss 22B
Externe SpannungVM(6,5 -38V)VM
Externe Spannung GNDGroundGround
Default I²C Adresse 0x30
D1 Mini Shield – AT8870 Motor –

SchematicLink status: OK

Compatibility

D1 TypeCompatibleBegründung, wenn nicht
D1 miniYes
D1 mini ProYesUntested
D1 mini LiteYesUntested
D1 32Yes


S2 mini
YesUntested
C3YesUntested
Kompatibilität zu den D1 Boards

Areas of application

  • Ferngesteuerte Autos
  • Selbstfahrende Roboter
  • Arme mit zwei Freiheitsgraden
  • Betreiben eines Schrittmotors

Views

D1 Mini Shield – AT8870 Motor – Verbunden

Programming

Libraries

Arduino ESP32 Bibliothek V2.0.3-RC1

Arduino ESP8266 Bibliothek V3.0.2

https://github.com/wemos/LOLIN_I2C_MOTOR_LibraryLink status: OK

Test programme

Source code MotorTest.ino (GitHubLink status: OK)

/* Testprogramm for D1 motor shields
   Step 1: Motor A Forward -> increase Speed -> decrease speed
   Step 2: Motor B Forward -> increase Speed -> decrease speed
   Step 3: Motor A&B Forward -> increase Speed -> decrease speed

   Lib:
   https://github.com/wemos/LOLIN_I2C_MOTOR_Library

   Inspired by the examples of the library
   Created by S. Fambach
   Visit http://www.fambach.net if you want
*/

#include <Wire.h>

// get the motor lib and get an object

#include "LOLIN_I2C_MOTOR.h"
LOLIN_I2C_MOTOR motor; //I2C address 0x30


void setup()
{

  Wire.begin();
  Serial.begin(115200);
  Serial.println(F("Init Motor Shield..."));

  while (motor.PRODUCT_ID != PRODUCT_ID_I2C_MOTOR) //wait motor shield ready.
  {
    motor.getInfo();
  }
  Serial.println(F("... Success"));

}

void loop()
{

  // M1 forward test ********************************************************
  Serial.print(F("MA forward Test .."));
  motor.changeStatus(MOTOR_CH_A, MOTOR_STATUS_CW);
  motor.changeFreq(MOTOR_CH_A, 20000);
  motor.changeStatus(MOTOR_CH_B, MOTOR_STATUS_STOP);

  Serial.print(F(".. increase speed .."));
  for (int i = 0; i < 100; i++) {
    motor.changeDuty(MOTOR_CH_A, i);
    if ( (i % 10) == 0 ) {
      Serial.print(".");
    }
    delay(200);
  }

  Serial.print(F(".. decrease speed .."));
  for (int i = 100; i > 0; i--) {
    motor.changeDuty(MOTOR_CH_A, i);
    if ( (i % 10) == 0 ) {
      Serial.print(".");
    }
    delay(200);
  }
  motor.changeDuty(MOTOR_CH_A, 0);
  Serial.println(F(".. Finished"));

  // motor.changeStatus(MOTOR_CH_A,MOTOR_STATUS_STOP);


  // M1 backward test ********************************************************
  Serial.print(F("MA Backward Test .."));
  motor.changeStatus(MOTOR_CH_A, MOTOR_STATUS_CCW);
  motor.changeFreq(MOTOR_CH_A, 20000);
  motor.changeStatus(MOTOR_CH_B, MOTOR_STATUS_STOP);

  Serial.print(F(".. increase speed .."));
  for (int i = 0; i < 100; i++) {
    motor.changeDuty(MOTOR_CH_A, i);
    if ( (i % 10) == 0 ) {
      Serial.print(".");
    }
    delay(200);
  }

  Serial.print(F(".. decrease speed .."));
  for (int i = 100; i > 0; i--) {
    motor.changeDuty(MOTOR_CH_A, i);
    if ( (i % 10) == 0 ) {
      Serial.print(".");
    }
    delay(200);
  }
  motor.changeDuty(MOTOR_CH_A, 0);
  Serial.println(F(".. Finished"));
  motor.changeStatus(MOTOR_CH_A, MOTOR_STATUS_STOP);

  
  // M2 forward test ********************************************************
  Serial.print(F("MB forward Test .."));
  motor.changeStatus(MOTOR_CH_B, MOTOR_STATUS_CW);
  motor.changeFreq(MOTOR_CH_B, 20000);
  motor.changeStatus(MOTOR_CH_A, MOTOR_STATUS_STOP);

  Serial.print(F(".. increase speed .."));
  for (int i = 0; i < 100; i++) {
    motor.changeDuty(MOTOR_CH_B, i);
    if ( (i % 10) == 0 ) {
      Serial.print(".");
    }
    delay(200);
  }

  Serial.print(F(".. decrease speed .."));
  for (int i = 100; i > 0; i--) {
    motor.changeDuty(MOTOR_CH_B, i);
    if ( (i % 10) == 0 ) {
      Serial.print(".");
    }
    delay(200);
  }
  motor.changeDuty(MOTOR_CH_B, 0);
  Serial.println(F(".. Finished"));

  // M2 Backward test ********************************************************
  Serial.print(F("MB backward Test .."));
  motor.changeStatus(MOTOR_CH_B, MOTOR_STATUS_CCW);
  motor.changeFreq(MOTOR_CH_B, 20000);
  motor.changeStatus(MOTOR_CH_A, MOTOR_STATUS_STOP);

  Serial.print(F(".. increase speed .."));
  for (int i = 0; i < 100; i++) {
    motor.changeDuty(MOTOR_CH_B, i);
    if ( (i % 10) == 0 ) {
      Serial.print(".");
    }
    delay(200);
  }

  Serial.print(F(".. decrease speed .."));
  for (int i = 100; i > 0; i--) {
    motor.changeDuty(MOTOR_CH_B, i);
    if ( (i % 10) == 0 ) {
      Serial.print(".");
    }
    delay(200);
  }
  motor.changeDuty(MOTOR_CH_B, 0);
  Serial.println(F(".. Finished"));

  // test both motors ********************************************************
  // forward test
  Serial.print(F("Both forward Test .."));
  motor.changeStatus(MOTOR_CH_BOTH, MOTOR_STATUS_CW);
  motor.changeFreq(MOTOR_CH_BOTH, 20000);
  //

  Serial.print(F(".. increase speed .."));
  for (int i = 0; i < 100; i++) {
    motor.changeDuty(MOTOR_CH_BOTH, i);
    if ( (i % 10) == 0 ) {
      Serial.print(".");
    }
    delay(200);
  }

  Serial.print(F(".. decrease speed .."));
  for (int i = 100; i > 0; i--) {
    motor.changeDuty(MOTOR_CH_BOTH, i);
    if ( (i % 10) == 0 ) {
      Serial.print(".");
    }
    delay(200);
  }
  motor.changeDuty(MOTOR_CH_BOTH, 0);
  Serial.println(F(".. Finished"));

  // Backward test ********************************************************
  Serial.print(F("Both backward Test .."));
  motor.changeStatus(MOTOR_CH_BOTH, MOTOR_STATUS_CCW);
  motor.changeFreq(MOTOR_CH_BOTH, 20000);


  Serial.print(F(".. increase speed .."));
  for (int i = 0; i < 100; i++) {
    motor.changeDuty(MOTOR_CH_BOTH, i);
    if ( (i % 10) == 0 ) {
      Serial.print(".");
    }
    delay(200);
  }

  Serial.print(F(".. decrease speed .."));
  for (int i = 100; i > 0; i--) {
    motor.changeDuty(MOTOR_CH_BOTH, i);
    if ( (i % 10) == 0 ) {
      Serial.print(".");
    }
    delay(200);
  }
  motor.changeDuty(MOTOR_CH_BOTH, 0);
  Serial.println(F(".. Finished"));

  /********************************************************/

  motor.changeStatus(MOTOR_CH_BOTH, MOTOR_STATUS_STOP);
  delay(2000);
  // stop

}

So siehts auf der Konsole aus:

Problems

—

Conclusion

Kann zwei Motoren über den I²C-Bus bedienen, was will man mehr?

More posts

Other Shields

More ESPs

Sources

Sources for the Shield

HLink status: UnknownerstellerseiteLink status: Unknown

Sources for the boards

Manufacturer's websiteLink status: OK

SchematicLink status: OK

CH340 USB DriverLink status: OK

https://arduino-projekte.info/wemos-d1-mini/Link status: Unknown

https://www.exp-tech.de/plattformen/esp8266/entwicklungsboards/8898/wemos-d1-miniLink status: Unknown

DateChangeAuthor
15.10.2026Beispielcode als Code-Block eingefügt (Einbettung über gist-it.appspot.com funktionierte nicht mehr)Suffocation
08.10.2026Überschriften-Hierarchie korrigiert (H1→H2, Unterebenen eine Stufe tiefer)Suffocation
04.10.2026Rechtschreibung korrigiert: Tippfehler, Groß-/Kleinschreibung, KommasSuffocation
03.10.2026Log-Liste eingefügtSuffocation
15.04.2022Post createdSuffocation
Changelog

1 thought on “D1 Mini Shield – AT8870 Motor”

  1. Haben Sie ein Codebeispiel zum Antreiben eines Schrittmotors mit AT8870?
    Ich kann es mit LOLIN_I2C_MOTOR nicht zum Laufen bringen.

Leave a Reply

Your email address will not be published. Required fields are marked *