Page 1 of 1

[SOLVED] Motor shield for NodeMCU

Posted: Thu Oct 26, 2017 9:46 pm
by maple
I am trying to run motor shield with NodeMCU (ESP8266 12N), motor shield doc: https://smartarduino.gitbooks.io/user-m ... index.html. As I am a newbie, there is maybe some big misunderstanding, which I cannot see after three days working on it.

NodeMCU is flashed with latest Micropython 1.9.2, powering the motor shield from 2×18650 lion batteries (approx 7.5 volts), using a shortcut between VIN and VM, so only one power for controller and motor. The code is after many hours of looking for the problem very simple:

Code: Select all

import micropython
import machine
a1 = machine.Pin(5, machine.Pin.OUT)
a2 = machine.Pin(0, machine.Pin.OUT)
b1 = machine.Pin(4, machine.Pin.OUT)
b2 = machine.Pin(2, machine.Pin.OUT)
a1.value(1)
a2.value(1)
b1.value(1)
b2.value(1)
No PWM, just put HIGH on those pins and look what I can see on motor shield output A+/A-/B+/B-. Controller looks good, I can measure 3.3V on those pins (D1-D3), but nothing on shield output. Between A+ and A- I found 0.2V, between B+ and B- there is about 0.5V.

I bought several pieces of those motor shields and all of them are the same. No output voltage on motor pins.

Photo of my super simple setup
Image
(on photo the power LED is off, but of course, I know about that power switch :-) ).

Does anybody have any idea? I tried also program the pins using Arduino IDE (reflashed the NodeMCU), but no luck too.

Re: Motor shield for NodeMCU

Posted: Fri Oct 27, 2017 6:04 am
by pythoncoder
The data on that shield is rather limited (in particular no schematic) so it's hard to comment. My first port of call with questionable hardware is to test it, running it as the manufacturer intended. But you've done that, with no joy. If it doesn't work with NodeMCU firmware and the Arduino IDE then you might get better support from the manufacturer.

Re: Motor shield for NodeMCU

Posted: Fri Oct 27, 2017 6:21 am
by maple
Thanks a lot. I found some post on instructables here: https://www.instructables.com/id/Motori ... h-ESP8266/ with the same motor shield. Author writes about very bad documentation and some commenters are discussing removing 2 resistors from that shield (?)

I will try to concact manufacturer. After all (before trashing those shields) I will try to remove those resistors :-)

Re: Motor shield for NodeMCU

Posted: Fri Oct 27, 2017 3:39 pm
by benalb
maple wrote:
Thu Oct 26, 2017 9:46 pm
I am trying to run motor shield with NodeMCU (ESP8266 12N), motor shield doc: https://smartarduino.gitbooks.io/user-m ... index.html.
(...)
I've got the same shield, and it works, with this code you can get the idea:

Code: Select all

from machine import Pin, PWM

""" nodemcu pins from the motor shield """
pin1 = Pin(5, Pin.OUT)  # D1
pin2 = Pin(4, Pin.OUT)  # D2
pin3 = Pin(0, Pin.OUT)  # D3
pin4 = Pin(2, Pin.OUT)  # D4

""" named after the L9110 h-bridge pins """
BIN1 = PWM(pin1, freq=750)
BIN2 = PWM(pin3, freq=750)
AIN1 = PWM(pin2, freq=750)
AIN2 = PWM(pin4, freq=750)

""" TODO: variable speed """
speed = 950 

def stop_all():
    for each in (BIN1, BIN2, AIN1, AIN2):
        each.duty(0)

def backward():
    BIN1.duty(0)
    BIN2.duty(speed)
    AIN1.duty(0)
    AIN2.duty(speed)

def forward():
    BIN1.duty(speed)
    BIN2.duty(0)
    AIN1.duty(speed)
    AIN2.duty(0)

def left():
    BIN1.duty(speed)
    BIN2.duty(0)
    AIN1.duty(0)
    AIN2.duty(speed)

def right():
    BIN1.duty(0)
    BIN2.duty(speed)
    AIN1.duty(speed)
    AIN2.duty(0)
Image
https://imgur.com/a/3HRY4

Re: Motor shield for NodeMCU

Posted: Fri Oct 27, 2017 6:52 pm
by maple
Thanks a lot for your advice and code. But according to this https://www.instructables.com/id/Motori ... h-ESP8266/ ant mainly the first comment, there is some version of this motor shield, which cannot run until you remove those two 100 ohm resistors. My items are have the same problem :-(

I measured precisely all those resistors and there are 1K on input to L293DD, but they have 100 ohm pull down to GND. Which means, the input signal from NodeMCU controller cannot reach the L293DD. I do not really know, why they are there - L293DD can handle up to 7V on its input and NodeMCU produce 3.3V output.

I have removed those two 100 ohm resistors (first and third from left, when antenna is on the right side) and the shield is working now.

Image

Hope, this discussion can help somebody else to fix same problem with the shield.

Re: Motor shield for NodeMCU

Posted: Sun Dec 16, 2018 8:41 pm
by mrogojanu
[quote=maple post_id=22787 time=1509130322 user_id=3339]
Thanks a lot for your advice and code. But according to this https://www.instructables.com/id/Motori ... h-ESP8266/ ant mainly the first comment, there is some version of this motor shield, which cannot run until you remove those two 100 ohm resistors. My items are have the same problem :-(

I measured precisely all those resistors and there are 1K on input to L293DD, but they have 100 ohm pull down to GND. Which means, the input signal from NodeMCU controller cannot reach the L293DD. I do not really know, why they are there - L293DD can handle up to 7V on its input and NodeMCU produce 3.3V output.

I have removed those two 100 ohm resistors (first and third from left, when antenna is on the right side) and the shield is working now.

[img]https://i.imgur.com/n2O26OLl.jpg[/img]

Hope, this discussion can help somebody else to fix same problem with the shield.
[/quote]

Thank you! I tried everything and nothing was working. Removing the 2 resistors as shown above resolved my problem.

Re: [SOLVED] Motor shield for NodeMCU

Posted: Sat Nov 09, 2019 8:10 pm
by mart
Hi,

Thanks for the nice example code!

I have tried getting this to work for quite some time, with no luck at all.

What I've done is to copy paste the code and called each of the functions in the example above with the NodeMCU connected to the motor shield and a usb in the Node MCU from the PC. I see no errors in the Terminal and the motor works if I wire it directly to the battery.

It's a 12 volt motor from an electric screwdriver and the battery from the same screwdriver. I've tried it with two different motor shields of the same model to rule out a hardware malfunction.

I've measured the voltage across the outputs of the MotorShield, and it does not seem to open up.

Any ideas what might be the issue here?

Re: [SOLVED] Motor shield for NodeMCU

Posted: Tue Dec 03, 2019 2:46 am
by zhou-star
Hello!
Through your feedback, I tested your problem by myself, but I did not encounter your problem. The motor can be well controlled. The code used is the code provided by the company to the customer, you can try again
Looking forward to your feedback!

Re: [SOLVED] Motor shield for NodeMCU

Posted: Sat May 02, 2020 12:24 pm
by jack222
Hello all !
Maybe you will be able to help me !

I removed as suggested the two resistors as mentionned above. I can now pilot the motor but I can not change the rotation. When I change the GPIO to 0 it stops the motor, when put it to 1, it starts the motor.
Unfortunattely I can not reverse the motor... Any clue ?

Image

Thank you all !