我想创建一个智能开关。 我用这个esp8266模型和thinger.io开源物联网平台。 我想在没有RTC的情况下在ESP8266上插入时间。
这是我的代码
#include <ESP8266WiFi.h>
#include <ThingerESP8266.h>
#define DEBUG true
#define USERNAME "....."
#define DEVICE_ID "....."
#define DEVICE_CREDENTIAL "....."
#define SSID "...."
#define SSID_PASSWORD "........"
ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);
void setup() {
Serial.begin(115200);
pinMode(00, OUTPUT);
pinMode(02, OUTPUT);
pinMode(04, OUTPUT);
pinMode(05, OUTPUT);
pinMode(13, OUTPUT);
int a=0;
thing.add_wifi(SSID, SSID_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
digitalWrite(13, HIGH);
delay(50);
digitalWrite(13, LOW);
delay(50);
}
digitalWrite(13, HIGH);
Serial.println();
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println();
Serial.println("WiFi connected");
Serial.println("IP address: "); Serial.println(WiFi.localIP());
thing["Light One"] << [](pson& in){
digitalWrite(00, in ? LOW:HIGH);
int n1=in?1:0;
Serial.println(n1);
Serial.println("one");
pson tweet_content;
if(n1==1){
tweet_content["value2"] ="ON";
}else{
tweet_content["value2"] ="OFF";
}
tweet_content["value1"] = "One";
thing.call_endpoint("lightup", tweet_content);
};
thing["Light Two"] << [](pson& in){
digitalWrite(02, in ? LOW:HIGH);
int n2=in?1:0;
Serial.println(n2);
Serial.println("Two");
pson tweet_content;
if(n2==1){
tweet_content["value2"] ="ON";
}else{
tweet_content["value2"] ="OFF";
}
tweet_content["value1"] = "Two";
thing.call_endpoint("lightup", tweet_content);
};
thing["Light Three"] << [](pson& in){
digitalWrite(04,in ? LOW:HIGH);
int n3=in?1:0;
Serial.println(n3);
Serial.println("Three");
pson tweet_content;
if(n3==1){
tweet_content["value2"] ="ON";
}else{
tweet_content["value2"] ="OFF";
}
tweet_content["value1"] = "Three";
thing.call_endpoint("lightup", tweet_content);
};
thing["Light Four"] << [](pson& in){
digitalWrite(05, in ? LOW:HIGH);
int n4=in?1:0;
Serial.println(n4);
Serial.println("Four");
pson tweet_content;
if(n4==1){
tweet_content["value2"] ="ON";
}else{
tweet_content["value2"] ="OFF";
}
tweet_content["value1"] = "Four";
thing.call_endpoint("lightup", tweet_content);
};
thing["millis"] >> outputValue(millis());
}
void loop() {
thing.handle();
}
我想在该代码中插入时间码。
请问这怎么办?