Dimmable Switch Tutorial using YYAC-3S for ESP32
In this section we’ll walk through creating a Dimmable Switch using ESP32 and then control the light brightness via Amazon Alexa, GoogleHome or SmartThings.
Prerequisites :
- ESP32.
- YYAC-3S.
- Dimmable Light Bulb.
- Jumper Wires.
Not all the light bulbs are dimmable. Please check the manufacturer’s label to see if the bulb is dimmable.
Quick introduction to YYAC-3S
YYAC-3S module can used to control the supply of AC electricity using PWM from an Arduino, ESP8266, ESP32 or Pico W. It can be used to control the speed of AC motors and the brightness of dimmable light bulbs. The circuit consists of an SCR and an optocoupler on the input side. This prevents current from flowing back to the MCU and also separates it from ground, making it safe to use. The module supports a PWM input of 0-255 and can control AC voltage up to 220V with a maximum current of 3A.
Wiring
Connect the YYAC-3S module to the microcontroller as follows:
- VCC pin to the microcontroller’s 5V pin (3.3V does not seems to work).
- GND pin to the ESP32’s GND pin.
- PWM pin to a digital pin 16 on the microcontroller.
MCU | YYAC-3S PWM Pin |
---|---|
ESP32 | 16 |
Let’s verify that YYAC-3S module is wired correctly and working.
Arduino IDE Serial Monitor will show light bulb dimming like this:
Step 1 : Create a new device in Sinric Pro
- Login to your Sinric Pro account, go to Devices menu on your left and click Add Device button (On top left).
- Enter the device name Dimmer, description Dimmer and select the device type as Switch With Dimming.
-
Click Others tab and Click Save
-
Next screen will show the credentials required to connect the device you just created.
- Copy the Device Id, App Key and App Secret Keep these values secure. DO NOT SHARE THEM ON PUBLIC FORUMS !
Step 2 : Connect to Sinric Pro
Step 2.1 Install Sinric Pro Library
2.2 Complete Code
Now you should be able to control the the brightness level via Alexa, Google Home and SmartThings apps
Troubleshooting
- Does not dim ? Please check the manufacturer’s label to see if the light bulb is dimmable.
- PWM not working ?
Above LED lights up when the module recevice the PWM signal from MCU.
- Please refer to our Troubleshooting page for more details.
This document is open source. See a typo? Please create an issue