SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
#198730
Hello. I am trying to connect my Thing Dev controller to a PWM Servo driver(https://www.adafruit.com/product/815). Considering these topics:
1. https://learn.sparkfun.com/tutorials/es ... e-overview
2. https://learn.adafruit.com/16-channel-p ... king-it-up

I've connected:
Thing -> PWM driver
3v3 -> VCC
GND -> GND
Pin2 -> SDA
Pin14 -> SCL

I am using the Arduino IDE and libraries to program the Thing Dev(ESP8266). Do I have to do some code preparation to get the SDA/SCL I2C interface connection going? I've read the https://learn.sparkfun.com/tutorials/es ... up-arduino but I'm not sure after all. I can't get my project going with the Thing Dev, while using Arduino everything is fine. I use the same setup + the same code for both. The code is a simple loop which fades an LED strip through a MOSFET by PWM-ing. Also noticed here https://learn.sparkfun.com/tutorials/es ... in-arduino that I have to yield() periodically, but this didn't solve my problem, so I suppose I am not doing something properly with the I2C interface because I can't even lit the strip(yes, I am using external power supply).
#198737
Code: Select all
#include <Adafruit_PWMServoDriver.h>
Adafruit_PWMServoDriver pwm;

void setup() {
  pwm = Adafruit_PWMServoDriver(0x40);
  pwm.begin();
  pwm.setPWMFreq(1600);
}

void loop() {
  for(int i = 0; i <= 4095; i++) {
    pwm.setPWM(15, 0, i);
    //yield();
  }

  for(int i = 4095; i >= 0; i--) {
    pwm.setPWM(15, 0, i);
    //yield();
  }
}
Most of it is from the library of the PWM Servo. Example: https://github.com/adafruit/Adafruit-PW ... wmtest.ino

Tried with both - with yield and without it.
#198738
Have you tried with just a single led (with current limiting resistor) on the PWM output to test if there is a changing voltage at all? Try to reduce complexity by testing if indivudual parts work as they should. So first without mosfet and ledstring.
#198741
Valen wrote: Fri Mar 23, 2018 8:49 am Have you tried with just a single led (with current limiting resistor) on the PWM output to test if there is a changing voltage at all? Try to reduce complexity by testing if indivudual parts work as they should. So first without mosfet and ledstring.
So, started from the simplest thing possible. Thing only - 3v3 => Blue LED => GND - works.
Trying to do it through the PWM Servo driver(connected to the Thing) doesn't work, though. Can't even lit a single LED no matter if it is PWM or simple V+.
#198742
The ESP8266 Hookup guide says:
Wire – The ESP8266 should work with any I2C sensor you can throw at it – just use the same Wire API calls you’re used to. There are a few differences: ◦Pin definition: The ESP2866 doesn’t actually have any hardware I2C pins – those labeled on the Thing are the default, but you can actually use any two pins as SDA and SCL. Calling Wire.begin() will assume pins 2 and 14 are SDA and SCL, but you can manually set them to any other pin by calling Wire.begin([SDA], [SCL]).
I personally do not have this device so YMMV.
#198743
I don't have the ESP8266 Thing dev board either. By the looks of the schematic pin GPIO14 does not have a pull up resistor. But on the PWM driver there is, 10k Ohm. So that is good. How long are the wires between the Thing board and the PWM driver?
#198744
What color leds did you try? The 3.3 volt supply of the Thing is not sufficiently high to make blue or white leds light up. Better use red, green or yellow leds. Don't forget that LEDs have a polarity. If it doesn't light up, rotate the led. You might have connected it in reverse the first time.
#198745
Okay, I knew I was screwing something simple. So, basically, after trying everything hardware related, I started looking what am I missing code-wise. I included the Wire.h library and did the default mapping(for the Thing Dev) of the SDA/SCL pins and it finally worked. No idea why I had to do this explicitly but it solved the problem.
Basically, the solution was:
Code: Select all
Wire.pins(2, 14);
Thank you both for the input. : )