Giter Site home page Giter Site logo

esp8266_mqtt_dc1's Introduction

ESP8266_MQTT_DC1

将斐讯DC1排插接入MQTT服务器

斐讯DC1智能排插,由于某些原因斐讯公司的服务器已经关闭,官方app已经无法再使用。排插失去远程控制的功能,所以价格也沦为普通排插的价格。但是可以通过自主搭建MQTT服务器实现远程控制。

  1. 低成本(40RMB)
  2. 可添加定时任务
  3. 可在线升级(OTA)
  4. 可查看电压、电流、功率
  5. 改造现成插座,简单,美观
  6. 间接有了智能台灯、智能风扇......

APP

DC1 Assistant

  1. 支持ESPTOUCH配网
  2. 一键添加
  3. 仅支持DC1设备

DC1 Assistant

  1. 不支持ESPTOUCH配网
  2. 手动一个一个添加
  3. 支持所有MQTT设备

使用方法

  1. 搭建MQTT服务器
  2. clone 项目
  3. 修改 mqtt_config.h文件
    • MQTT_HOSTMQTT服务器域名或IP
    • MQTT_PORTMQTT服务器端口号
    • MQTT_USERMQTT用户名
    • MQTT_PASSMQTT密码
  4. 修改 Makefile 文件
    • 芯片型号带B为8Mbit SPI_SIZE_MAP?=2
    • 芯片型号不带B为16Mbit SPI_SIZE_MAP?=5
  5. 拆解DC1排插取出控制板
  6. 编译下载
    • 使用USB转TTL下载
    • 下载前请先拉低IO0(按下白色按键)
  7. 重新上电LED慢闪即固件刷入成功
  8. 将控制板安装回插排中(请将后盖盖好再插上电源)
  9. 长按总开关WIFI信号灯快闪进入配网模式
  10. 进行配网(ESPTouch、Airkiss)

使用说明

  1. 任意开关打开都会触发总开关
  2. USB的开关随总开关的状态
  3. LOGO灯即是总开关和USB的状态
  4. WIFI信号灯慢闪即正在连接WIFI
  5. WIFI信号灯快闪即进入配网模式
  6. WIFI信号灯常亮即成功连接WIFI
  7. 长按总开关进入配网模式,用于重新配网
  8. 每次配网自动保存,可共存两个WIFI信息
  9. 长按开关1,进入Webserver配置模式
  10. 定时任务使用MQTT消息添加

话题说明

  1. 定义文件mqtt_config.h
  2. {mac}即芯片的MAC
  3. 状态话题:/dc1/{mac}/status{0-3}
  4. 控制话题:/dc1/{mac}/control{0-3}
  5. 功率信息话题:/dc1/{mac}/power
  6. 电压信息话题:/dc1/{mac}/voltage
  7. 电流信息话题:/dc1/{mac}/current
  8. 遗嘱话题:/dc1/lwt/{mac}
  9. 出生话题:/dc1/birth/{mac}
  10. ota升级话题:/dc1/ota/{mac}
  11. 定时任务配置话题:/dc1/{mac}/timer/config
  12. 定时任务配置输出信息话题:/dc1/{mac}/timer/info

定时任务配置

  1. 添加定时任务
    //时间:17:45, 重复周期: 周一到周六, 关闭开关1  
    {
        "addTimer": {
            "time": "17:45",
            "week": "1111110",
            "switchNum": 1,
            "value": 0
        }
    }
    
    //时间:12:45, 重复周期: 今天, 打开开关1  
    {
        "addTimer": {
            "time": "12:45",
            "week": "today",
            "switchNum": 1,
            "value": 1
        }
    }
    
  2. 获取定时任务信息
    {
        "getTimer": 0
    }
    
    //返回(定时任务配置输出信息话题)
    //taskId为操作 202 为关闭开关1
    {
        "timerNum": 2,
        "timerInfo": [
            {
                "id": 1000,
                "status": 1,
                "time": "17:45:00",
                "week": "1111110",
                "taskId": 202
            },
            {
                "id": 1001,
                "status": 1,
                "time": "12:45:00",
                "week": "today",
                "taskId": 203
            }
        ]
    }
    
  3. 删除定时任务(id)
    {
        "delTimer": 1001
    }
    

OAT升级说明

  • 使用ota升级话题发送升级文件获取地址
  • 消息格式{"url":"http://yourdomain.com:9001/ota/"}

Webserver说明

  1. 长按开关1按键进入Webserver配置模式,wifi灯闪动
  2. 使用手机或电脑连接名称为 Webserver 的热点
  3. 访问192.168.4.1
  • 主界面

  • WIFI配置界面
    *

  • OTA升级界面

其他平台

esp8266_mqtt_dc1's People

Contributors

hogc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

esp8266_mqtt_dc1's Issues

编译错误

请问你使用的是什么编译环境?
我用安信可IDE1.5编译报错,用VBOX也错误.

xtensa-lx106-elf-gcc -Os -g -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -fno-builtin-printf -g -Wpointer-arith -Wundef -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -ffunction-sections -fdata-sections -fno-builtin-printf -fno-guess-branch-probability -freorder-blocks-and-partition -fno-cse-follow-jumps -DICACHE_FLASH -DSPI_FLASH_SIZE_MAP=6 -I include -I ./ -I ../../include/ets -I ../include -I ../include/mqtt -I ../../include -I ../../include/eagle -I ../../driver_lib/include -I ../../../include -I ../../../include/eagle -I ../../../driver_lib/include -o .output/eagle/debug/obj/user_main.o -c user_main.c
user_main.c: In function 'mqttConnectedCb':
user_main.c:202:13: error: implicit declaration of function 'dc1_read_gpio' [-Werror=implicit-function-declaration]
gpio_ret = dc1_read_gpio();
^
user_main.c: In function 'mqttDataCb':
user_main.c:407:5: error: implicit declaration of function 'clock_get_timer_task_info_json' [-Werror=implicit-function-declaration]
clock_get_timer_task_info_json(info_str);
^
user_main.c: In function 'user_init':
user_main.c:626:2: error: implicit declaration of function 'set_uart_cb' [-Werror=implicit-function-declaration]
set_uart_cb(dc1_uart_data_handler);
^
cc1.exe: all warnings being treated as errors
make[2]: *** [../../../Makefile:348: .output/eagle/debug/obj/user_main.o] Error 1
make[2]: Leaving directory '/f/esp8266/NonSdk/ESP8266_NONOS_SDK/ESP8266_MQTT_DC1/app/user'
make[1]: *** [../../Makefile:333: .subdirs] Error 2
make[1]: Leaving directory '/f/esp8266/NonSdk/ESP8266_NONOS_SDK/ESP8266_MQTT_DC1/app'
make: *** [../Makefile:333: .subdirs] Error 2

关于OTA

image

请问你ota的文件怎样生成的?我ota时模块会挂掉的?

BOOT?=new
APP?=1 //此刻生成的是 user1.bin文件
SPI_SPEED?=40
SPI_MODE?=QIO
SPI_SIZE_MAP?=

BOOT?=new
APP?=2 //此刻生成的是 user2.bin文件
SPI_SPEED?=40
SPI_MODE?=QIO
SPI_SIZE_MAP?=

我这边这样生成出来ota就挂掉了不成功。

是不是还有什么其它操作?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.