spoiler : A LED control project
This project is similarly with my old project. BUT this time doesn't need Wi-Fi and cloud to set the room. If hotel room has Ethernet port it can be used directly. Without add independent power port for Wi-Fi device.
start with WIZ750SRIf you don't know how to use WIZ750SR you can read this project and follow it to start.
Hardware prepareconnect WIZ750SR like this : can be power from DC jack or USB.
connect KL27 mini board like this : it is hard to buy this board I choose it just because it has the RS232 port. See the schematics at the end attachment.
connect LED like this
PC
wizconfig : setting WIZ750SR to server mode.
sscom : use it TCP client to connect WIZ750SR.
KL27 mini board
Full code see the attachment at the end. Key point is to receive data and identity it. Here I define data format " XX RR GG BB 0x55 0xAA " . First byte XX is don't care since while I connect with RS232 this byte always receives not current. 2nd to 4th byte are RGB color duty setting. 5th and 6th byte is identity data to make sure data is sending from me. Below is while loop code show UART TX RX.
while (1)
{
/* If RX is idle and g_rxBuffer is empty, start to read data to g_rxBuffer. */
if (!rxOnGoing)
{
if((g_rxBuffer[5]==0xaa) && (g_rxBuffer[4]==0x55))
{
//data formate " XX RR GG BB 0x55 0xAA " , XX don't care , RR hex Red duty max 100, GG green , BB blue , 0x55 0xAA for identity data
LEDdutyR = g_rxBuffer[1];
LEDdutyG = g_rxBuffer[2];
LEDdutyB = g_rxBuffer[3];
if( LEDdutyR > 100) LEDdutyR = 100;
if( LEDdutyG > 100) LEDdutyG = 100;
if( LEDdutyB > 100) LEDdutyB = 100;
TPM_1_pwmSignalParamsUser[1].dutyCyclePercent = LEDdutyR;
TPM_1_pwmSignalParamsUser[2].dutyCyclePercent = LEDdutyG;
TPM_1_pwmSignalParamsUser[3].dutyCyclePercent = LEDdutyB;
TPM_SetupPwm(TPM_1_PERIPHERAL, TPM_1_pwmSignalParamsUser, sizeof(TPM_1_pwmSignalParamsUser) / sizeof(tpm_chnl_pwm_signal_param_t), kTPM_EdgeAlignedPwm, 1000U, TPM_1_CLOCK_SOURCE);
}
receiveXfer.data = g_rxBuffer;
receiveXfer.dataSize = 6;
LPUART_TransferReceiveNonBlocking(LPUART_0_PERIPHERAL, &g_lpuartHandle, &receiveXfer, NULL);
rxOnGoing = true;
}
if((true==pitch1IsrFlag) &&((!txOnGoing)))
{
// keep sending power on time each 1 sec
pitch1IsrFlag = 0;
sprintf(g_txBuffer,"time = %u\r\n", runtime);
sendXfer.data = g_txBuffer;
sendXfer.dataSize = strlen(g_txBuffer);
LPUART_TransferSendNonBlocking(LPUART_0_PERIPHERAL, &g_lpuartHandle, &sendXfer);
txOnGoing = true;
runtime++;
}
}
Model housesetting Red LED
setting Green LED
setting Blue LED
White ( send "aa 64 64 64 55 aa" )
close room light
with room light
ConclusionWhen I control LED, I can control anything.
benefit when use wiz750sr
1. Doesn't need cloud server.
2. Easy setting through RS232/RS485/TTL.
3. Use Ethernet port stable signal and high speed.
Comments