Smart Train
How to recycle a toy locomotive with a ESP8266?

 
 

        Thanks to the wide variety of shields offered by the ESP8266-based Wemos development board, we can recycle any toy that has a 5v DC motor and give it a new life! 

        In order to control our locomotive, we need to have knowledge about MQTT and know how to send commands to the Wemos with the EasyESP firmware (See section STEPS)

Materials:

M5Stack Core 2

More info

Wemos D1 Mini Lite

 More info

MOTOR_IMG

Wemos Motor Shield

 More info

BATTERY_IMG

Wemos Battery Shield

 More info

Buzzer activo - 12V, 12x9.5mm – Sumador

Buzzer

Buy Obstacle Avoidance IR Sensor Module at Low Price In India

IR Infrared Sensor

LED Amarillo Difuso 5mm - 10 pzas — 330ohms

LED 3.3v


Diagram:


Steps:

  1. Download EasyESP (Mega version for ESP8266) and flash our Wemos with the corresponding firmware.

  2. Configure a broker MQTT with controller type  "Home Assistant (openHAB) MQTT"

  3. Add devices :

    1. Motor shield: SDA: GPIO-4 (D2) SCL: GPIO-5 (D1)

    2. Sensor IR: GPIO-16 (D0)

  4.  Execute commands to check that sensor it's okey:

    1. Motor Shield:

      1. WemosMotorShieldCMD,0,Forward,30

      2. WemosMotorShieldCMD,0,Stop

    2. LED

      1. PWM,12,500

    3. Buzzer

      1. tone,14,1300,200

  5. Open UI M5Flow and upload the example code for M5Stack Core 2 Download NOTE: Change connection parameters for broker MQTT


3D Printing Farm - Part II
How automate your 3D store?