Programing

At the beginning I use Xiao RP2040 to control servo motor.

I document it on Interface and Programming. It use the to control servo motor.

But in the final, I try to use Xiao Esp32-C3, library is not work for it. For instead, PWM LEDC in ESP32 is very suitable for control the servo motor.

PWM(Pulse Width Modulation) LEDC (LED control) is orginal for control LED by pulse. By changing the pulse width, the rotation speed and direction can be controlled. Therefore, in the code, the motor is stopped by calculating the movement time (estimating the number of rotations).

Debug Record

There are too many problems, the circuit doesn't work at all when connected, so I need to debug it.

Let me break down the task. I separate it into four steps:

  • The LED lights up on the board.
  • The LED powered by VCC needs to light up.
  • The LED reacts to the PIR sensor.
  • The PIR sensor triggers the LED and the servo motor.

Let's start with the simplest display LED. Why isn't it lighting up?

  • after testing, I didn't solder the 3.3V pin well.

I switched to a 5V external power supply, but the XIAO ESP32-C3 wasn't receiving any power. Using a multimeter to test, I found the problem was the Schottky diode, it didn't achieve the desired effect and also blocked the current.

So I decided to remove it and create a jumper wire to directly connect the VCC 5V line.

It started working!!!!

However, this means I lose one layer of protection. I need to be careful not to use an external power source and the XIAO's USB at the same time, as this could damage the XIAO.

Why my The LED lights for lighting do not work

I connected to D10. Using a multimeter, I can see it generates regular LOW and HIGH signals, so the problem isn't the programming or the microcontroller. This time I used a MOSFET, so something might be wrong with it. My connections are correct, so the last possibility was the connection itself. Finally, the S pin to GND wasn't soldered well, so it wasn't connected.

Wow, it works!!!!

Then I changed to a smaller resistor, from 1kΩ to 50Ω, to make the LED brighter, which follows the datasheet from the supplier.

Why PIR motion sensor didn't work

I was connect on D4(GPIO6)

On the ESP32-C3, GPIO6 is a restricted pin. Connecting sensors and buttons and other external devices to it can easily cause problems.

Then I change to D2(GPIO4) it works!!.

Why Servo motor didn't work

I was using RP2040 to test, but XIAO ESP32-C3 can't use this library. Turn to use PWM LEDC.

Finally All DOWN, the The entire circuit succeed.

Some problem I need to refelect on schematic and update the PCB.

Files download