ESP8285 制作物联网灯座
·
本文旨在用ESP8285 制作物联网灯座
交流VX:you-yu
EDA使用立创
ESP8266_RTOS-SDK
使用微信小程序控制
微信小程序部份代码
var new_clientid = Math.random().toString(36).substr(2)
this.setData({
btn_loading: true
});
if (app.globalData.siginout == false){
var client = new MQTT.Client("wss://" + this.data.server_addr + "/mqtt/", "clientId_" + new_clientid);
var that = this;
//connect to MQTT broker
console.log('clientid', "clientId_" + new_clientid)
灯座部份代码
char *Read_nvs_time(char* get_names)
{
nvs_handle handle;
static const char *NVS_CUSTOMER = "config";
nvs_open(NVS_CUSTOMER, NVS_READWRITE, &handle);
size_t lens = 50;
static char time_str[50];
//memcpy(time_str,"None",8);
esp_err_t err = nvs_get_str(handle, get_names, &time_str, &lens);
nvs_close(handle);
//printf("read : %s , data: %s ,error : %d\r\n",get_names,time_str,(int)err);
if(err != ESP_OK){
memcpy(time_str,"None",8);
return time_str;
}else{
return time_str;
}
PCB 预览图:

成品 预览图:

更多推荐

所有评论(0)