esp01s改造老旧吸尘器连入天猫精灵语音控制(blinker + 阿里云)

esp01s改造老旧吸尘器连入天猫精灵语音控制

esp01s改造老旧吸尘器连入天猫精灵语音控制
利用esp01s加红外遥控二极管,实现天猫精灵语音控制扫地机(科沃斯CEN540)启动、回充

1、用到的元器件

  1. esp01s模块
  2. 红外led灯
  3. NPN三极管s8050,1个
  4. 限流电阻200——500Ω均可,2个

2、电路

s8050发射极接esp01s的GND,基极接限流电阻后接esp01s的3脚(RXD),集电极接限流电阻,再接led负极回到esp01s的VCC,esp01s模块从扫地机内esp_wroom模块取电。

3、代码

#define BLINKER_WIFI
#define BLINKER_ALIGENIE_OUTLET
#define BLINKER_WIFI_MULTI
#include <Arduino.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>
#include <Blinker.h>

char auth[] = "xxx";
char ssid[] = "TP-LINK_46AB";
char pswd[] = "xxx..";


char ssid1[] = "TP_LINK_820F";
char pswd1[] = "xxx";

char ssid2[] = "sxbctvnet-ehh24";
char pswd2[] = "xxx";



const uint16_t kIrLed = 3;  // RXD.

IRsend irsend(kIrLed);  // Set the GPIO to be used to sending the message.

//红外遥控指令
//上
uint16_t upData[67] = {9014, 4538,  634, 498,  554, 572,  554, 596,  534, 596,  534, 576,  552, 596,  534, 1708,  550, 596,  532, 1750,  508, 598,  530, 1726,  532, 598,  530, 1728,  542, 586,  542, 1738,  526, 602,  528, 576,  554, 1730,  532, 574,  556, 1728,  534, 594,  534, 1724,  534, 594,  534, 1724,  538, 1722,  532, 596,  532, 1752,  508, 596,  532, 1726,  532, 598,  530, 1750,  506, 598,  550};  // NEC 2AA55AA
//下
uint16_t downData[67] = {9010, 4526,  572, 556,  572, 578,  550, 578,  550, 558,  572, 558,  570, 558,  570, 1708,  550, 562,  568, 1736,  524, 606,  524, 1734,  522, 582,  548, 1734,  526, 580,  550, 1734,  498, 630,  500, 628,  502, 1758,  546, 1688,  574, 556,  574, 578,  550, 1708,  550, 1710,  550, 580,  550, 1692,  568, 562,  568, 580,  548, 1736,  524, 1736,  524, 606,  524, 606,  522, 1712,  524};  // NEC 2AA6699
//左
uint16_t leftData[67] = {9018, 4542,  556, 594,  534, 596,  534, 594,  534, 594,  534, 594,  534, 576,  554, 1726,  532, 596,  534, 1750,  506, 622,  508, 1728,  530, 620,  506, 1728,  530, 598,  546, 1714,  550, 576,  554, 600,  528, 576,  554, 1708,  554, 1704,  556, 574,  556, 572,  556, 1724,  534, 1704,  554, 1724,  534, 1750,  506, 622,  506, 622,  508, 1726,  532, 1728,  530, 598,  530, 622,  524};  // NEC 2AA33CC
//右
uint16_t rightData[67] = {9016, 4564,  532, 574,  554, 574,  554, 596,  532, 576,  552, 578,  552, 596,  534, 1726,  532, 596,  532, 1750,  506, 598,  530, 1752,  506, 622,  506, 1728,  524, 604,  524, 1756,  526, 578,  550, 578,  552, 1706,  556, 574,  554, 574,  556, 572,  558, 1702,  558, 596,  532, 572,  556, 1726,  530, 578,  552, 1726,  532, 1752,  506, 1726,  530, 600,  530, 1730,  528, 1748,  524};  // NEC 2AA44BB
//CLEAN
uint16_t clearData[67] = {8990, 4538,  558, 596,  534, 594,  534, 576,  554, 596,  534, 576,  554, 596,  534, 1726,  534, 596,  534, 1750,  508, 598,  530, 1752,  508, 598,  532, 1750,  500, 628,  520, 1738,  526, 578,  552, 600,  528, 576,  554, 1706,  554, 596,  534, 572,  558, 594,  534, 1724,  534, 596,  532, 1704,  554, 1706,  550, 596,  534, 1726,  530, 1750,  508, 1726,  530, 622,  508, 1750,  524};  // NEC 2AA22DD
//PLAN
//uint16_t rawData[99] = {9020, 4566,  532, 596,  534, 596,  534, 596,  534, 576,  552, 576,  556, 594,  534, 1726,  534, 580,  550, 596,  534, 1730,  530, 622,  508, 1728,  532, 622,  508, 1728,  546, 584,  546, 1736,  528, 578,  554, 600,  530, 600,  530, 600,  532, 574,  556, 574,  556, 572,  558, 570,  558, 1726,  534, 1728,  534, 1726,  534, 1726,  532, 1752,  508, 1730,  530, 1754,  506, 1726,  544, 1740,  526, 578,  552, 602,  528, 576,  552, 600,  530, 576,  554, 576,  554, 574,  556, 1704,  556, 1726,  534, 596,  534, 1706,  556, 576,  552, 1728,  532, 1752,  508, 1730,  530};  // UNKNOWN 9AF51A45
//延边
uint16_t roundData[67] = {8996, 4568,  534, 576,  552, 578,  554, 598,  530, 598,  530, 578,  552, 598,  532, 1728,  532, 598,  530, 1734,  528, 600,  530, 1756,  506, 602,  528, 1732,  526, 604,  526, 1734,  548, 606,  526, 582,  548, 1710,  554, 1708,  552, 1706,  554, 578,  552, 1710,  550, 1730,  530, 1732,  530, 1754,  504, 600,  532, 600,  528, 600,  528, 1730,  528, 600,  530, 602,  526, 604,  524};  // NEC 2AA7788
//回充
uint16_t gohomeData[67] = {9020, 4544,  554, 576,  554, 596,  532, 576,  554, 578,  552, 598,  532, 596,  532, 1728,  532, 598,  532, 1726,  532, 622,  506, 1728,  530, 624,  508, 1750,  500, 628,  500, 1734,  548, 582,  548, 1734,  532, 574,  554, 598,  530, 598,  532, 1728,  532, 596,  532, 596,  532, 598,  532, 596,  536, 1722,  532, 1726,  532, 1728,  530, 622,  506, 1732,  528, 1754,  506, 1732,  548};  // NEC 2AA8877
//定点
uint16_t rawData[67] = {9018, 4566,  530, 576,  554, 578,  552, 598,  532, 576,  554, 598,  532, 598,  532, 1710,  548, 598,  532, 1732,  526, 624,  506, 1754,  504, 626,  504, 1754,  504, 602,  524, 1756,  526, 602,  526, 1708,  550, 580,  552, 576,  554, 1706,  554, 1728,  532, 598,  532, 598,  532, 1706,  554, 596,  532, 1728,  532, 1730,  530, 600,  530, 602,  528, 1732,  528, 1754,  504, 626,  502};  // NEC 2AA9966


BlinkerButton ButtonUp("btn-up");
BlinkerButton ButtonDown("btn-down");
BlinkerButton ButtonLeft("btn-left");
BlinkerButton ButtonRight("btn-right");
BlinkerButton ButtonClear("btn-clear");
BlinkerButton ButtonRound("btn-round");
BlinkerButton ButtonGohome("btn-gohome");
BlinkerButton ButtonRaw("btn-raw");
BlinkerNumber Number1("num-abc");

int counter = 0;

void buttonup_callback(const String & state)
{
  irsend.sendRaw(upData, 67, 38);
  BLINKER_LOG("up");
}
void buttondown_callback(const String & state)
{
  irsend.sendRaw(downData, 67, 38);
  BLINKER_LOG("down");
}
void buttonleft_callback(const String & state)
{
  irsend.sendRaw(leftData, 67, 38);
  BLINKER_LOG("left");
}
void buttonright_callback(const String & state)
{
  irsend.sendRaw(rightData, 67, 38);
  BLINKER_LOG("right");
}
void buttonclear_callback(const String & state)
{
  irsend.sendRaw(clearData, 67, 38);
  BLINKER_LOG("clear");
}
void buttonround_callback(const String & state)
{
  irsend.sendRaw(roundData, 67, 38);
  BLINKER_LOG("round");
}
void buttongohome_callback(const String & state)
{
  irsend.sendRaw(gohomeData, 67, 38);
  BLINKER_LOG("gohome");
}
void buttonraw_callback(const String & state)
{
  irsend.sendRaw(rawData, 67, 38);
  BLINKER_LOG("raw");
}

void dataRead(const String & data)
{
    BLINKER_LOG("Blinker readString: ", data);
    counter++;
    Number1.print(counter);
}

void aligeniePowerState(const String & state)
{
    BLINKER_LOG("need set power state: ", state);

    if (state == BLINKER_CMD_ON) {
        irsend.sendRaw(clearData, 67, 38);//发送启动指令
        BLINKER_LOG("on");
        BlinkerAliGenie.powerState("on");
        BlinkerAliGenie.print();
        delay(10000);
        irsend.sendRaw(downData, 67, 38);//开启强力模式
        BLINKER_LOG("max");
    }
    else if (state == BLINKER_CMD_OFF) {
        irsend.sendRaw(gohomeData, 67, 38);//发送回充指令
        BlinkerAliGenie.powerState("off");
        BlinkerAliGenie.print();
        BLINKER_LOG("off");
    }
}

void heartbeat()
{
  BLINKER_LOG("heartbeat!");
}

void setup(){
  
  Serial.begin(115200);
  BLINKER_DEBUG.stream(Serial);
  BLINKER_DEBUG.debugAll();
  irsend.begin(); 
  
  digitalWrite(2,HIGH);//关闭板载LED
  Blinker.addAP(ssid2, pswd2);
  Blinker.addAP(ssid1, pswd1);
  Blinker.begin(auth, ssid, pswd);
  Blinker.attachData(dataRead);

  ButtonUp.attach(buttonup_callback);
  ButtonDown.attach(buttondown_callback);
  ButtonLeft.attach(buttonleft_callback);
  ButtonRight.attach(buttonright_callback);
  ButtonClear.attach(buttonclear_callback);
  ButtonRound.attach(buttonround_callback);
  ButtonGohome.attach(buttongohome_callback);
  ButtonRaw.attach(buttonraw_callback);
  Blinker.attachHeartbeat(heartbeat);
  BlinkerAliGenie.attachPowerState(aligeniePowerState);
}

void loop(){
  Blinker.run();
}

Blinker端

在这里插入图片描述

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值