Difference between revisions of "WemosMotorshield"

From Let's Control It
Jump to navigation Jump to search
(Created page with "TUNGSTEN")
 
(initial draft version)
Line 1: Line 1:
TUNGSTEN
+
Draft version!!!
 +
 
 +
 
 +
= Introduction =
 +
 
 +
Plugin 079: Wemos Motorshield
 +
 
 +
'''This Plugin in currently only available in the latest mega build [https://github.com/letscontrolit/ESPEasy/tree/mega github]'''
 +
 
 +
It is labeled for Testing.
 +
 
 +
This Plugin is for the [https://wiki.wemos.cc/products:d1_mini_shields:motor_shield] which is controlled over the I2C protocol.
 +
 
 +
 
 +
 
 +
== Hardware ==
 +
This Plugin works with the Wemos Motorshield.
 +
 
 +
 
 +
= Installation =
 +
 
 +
@Piotr Bugalski has recently re-written the firmware for this motorshield, and published it at https://github.com/pbugalski/wemos_motor_shield.
 +
From what I can tell, the new firmware is compatible with the old one, minus the hanging and crashing, so it should be perfect for a drop-in replacement.
 +
 
 +
Here is how you can flash it to your shield:
 +
 
 +
Preparations:
 +
 
 +
Short the RTS and the 3V pins on the shield together, like this: Bild!!!
 +
 
 +
And the connect the main pins of the shield to your USB2TTL as follows:
 +
GND ↔ GND
 +
3V3 ↔ 3V3 (or VCC or whatever it is called on your USB2TTL)
 +
D2 ↔ TX
 +
D1 ↔ RX
 +
and connect it to your computer.
 +
 
 +
 
 +
Download the motor_shield.bin:
 +
https://cdn.hackaday.io/files/18439788894176/motor_shield.bin
 +
or
 +
https://github.com/pbugalski/wemos_motor_shield
 +
 
 +
 
 +
Download STM32Flash from here https://sourceforge.net/projects/stm32flash/files/
 +
Extract and put the above files into a directory
 +
Plug in your USB serial device and make a note of the COM port it uses
 +
 
 +
Those of you who want to do this using Window's 8/10:
 +
Window Command Prompt  cd to the directory
 +
1) stm32flash.exe COM8 "replace with your port number"
 +
2) stm32flash.exe -k COM8    This will unlock your shield
 +
3) stm32flash.exe -f -v -w motor_shield.bin COM8  this will flash the bin and re-lock the shield.
 +
 
 +
Then disconnect all the wires (including the RTS pin), connect the shield to your WeMos D1 Mini, and it should work.
 +
 
 +
 
 +
 
 +
see also: https://hackaday.io/project/18439-motor-shield-reprogramming
 +
 
 +
 
 +
= Software =
 +
 
 +
The Plugin is based on based on this library: https://github.com/wemos/WEMOS_Motor_Shield_Arduino_Library
 +
 
 +
 
 +
== ESP Easy ==
 +
Flash Testing version of ESPeasy in order to used the plugin.
 +
Use the device tab on the ESP Easy webinterface and create a new task by editing one of the available tasks.
 +
Select "Motor - Wemos Motorshield" from the dropdown box.
 +
Enter device name.
 +
Enter the i2c address of you sensor, default value 0x30
 +
 
 +
 
 +
 
 +
== Controlling the Motor Shield via HTTP commands ==
 +
 
 +
Currently only 2 DC motors are supported. Steppers need to be implemented in future.
 +
 
 +
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.
 +
 
 +
Available commands:
 +
Forward/Backward/Stop
 +
 
 +
Events Examples:
 +
DoorOpen
 +
DoorClose
 +
DoorStop
 +
 
 +
 
 +
 
 +
Command format:
 +
 
 +
For DC Motors:
 +
 
 +
  http://<ESP IP address>/control?cmd=MotorShieldCMD,DCMotor,<Motornumber>,<Forward/Backward/Release>,<Speed>
 +
 
 +
 
 +
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
 +
 
 +
 
 +
 
 +
 
 +
=== Rules Example ===
 +
 
 +
// Timer for all day open door at time if not open
 +
 
 +
On Clock#Time=All,07:00 do
 +
If [Reed1-open#Switch]!=1
 +
Event,DoorOpen
 +
Else
 +
Event,DoorStop
 +
endif
 +
endon
 +
 
 +
// Timer for all day close door at time if not closed
 +
 
 +
On Clock#Time=All,22:00 do
 +
If [Reed2-close#Switch]!=1
 +
Event,DoorClose
 +
Else
 +
Event,DoorStop
 +
endif
 +
endon

Revision as of 15:51, 28 August 2018

Draft version!!!


Introduction

Plugin 079: Wemos Motorshield

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

It is labeled for Testing.

This Plugin is for the [1] which is controlled over the I2C protocol.


Hardware

This Plugin works with the Wemos Motorshield.


Installation

@Piotr Bugalski has recently re-written the firmware for this motorshield, and published it at https://github.com/pbugalski/wemos_motor_shield. From what I can tell, the new firmware is compatible with the old one, minus the hanging and crashing, so it should be perfect for a drop-in replacement.

Here is how you can flash it to your shield:

Preparations:

Short the RTS and the 3V pins on the shield together, like this: Bild!!!

And the connect the main pins of the shield to your USB2TTL as follows: GND ↔ GND 3V3 ↔ 3V3 (or VCC or whatever it is called on your USB2TTL) D2 ↔ TX D1 ↔ RX and connect it to your computer.


Download the motor_shield.bin: https://cdn.hackaday.io/files/18439788894176/motor_shield.bin or https://github.com/pbugalski/wemos_motor_shield


Download STM32Flash from here https://sourceforge.net/projects/stm32flash/files/ Extract and put the above files into a directory Plug in your USB serial device and make a note of the COM port it uses

Those of you who want to do this using Window's 8/10: Window Command Prompt cd to the directory 1) stm32flash.exe COM8 "replace with your port number" 2) stm32flash.exe -k COM8 This will unlock your shield 3) stm32flash.exe -f -v -w motor_shield.bin COM8 this will flash the bin and re-lock the shield.

Then disconnect all the wires (including the RTS pin), connect the shield to your WeMos D1 Mini, and it should work.


see also: https://hackaday.io/project/18439-motor-shield-reprogramming


Software

The Plugin is based on based on this library: https://github.com/wemos/WEMOS_Motor_Shield_Arduino_Library


ESP Easy

Flash Testing version of ESPeasy in order to used the plugin. Use the device tab on the ESP Easy webinterface and create a new task by editing one of the available tasks. Select "Motor - Wemos Motorshield" from the dropdown box. Enter device name. Enter the i2c address of you sensor, default value 0x30


Controlling the Motor Shield via HTTP commands

Currently only 2 DC motors are supported. Steppers need to be implemented in future.

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.

Available commands: Forward/Backward/Stop

Events Examples: DoorOpen DoorClose DoorStop


Command format:

For DC Motors:

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


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



Rules Example

// Timer for all day open door at time if not open

On Clock#Time=All,07:00 do If [Reed1-open#Switch]!=1 Event,DoorOpen Else Event,DoorStop endif endon

// Timer for all day close door at time if not closed

On Clock#Time=All,22:00 do If [Reed2-close#Switch]!=1 Event,DoorClose Else Event,DoorStop endif endon