https://blakadder.com/tuya-covers/#determining-functions
Tuya blind
#include<stdlib.h>
#include <SoftwareSerial.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
#define SSID "SSID"
#define PASS "password"
#define IP "10.10.10.5" // website to talk to...
String GET = "GET /temps/update.php?key=ESP2&tempc=";
SoftwareSerial monitor(10, 11); // RX, TX
void setup()
{
monitor.begin(9600);
Serial.begin(9600);
//sendDebug("***");
//sendDebug(__FILE__);
//sendDebug("need a serial to usb attached to pins 10 and 11 to see output");
sensors.begin();
// monitor.println(__FILE__);
// sendDebug("AT+RST");
delay(2000);
sendDebug("AT");
delay(5000);
if(Serial.find("OK")){
monitor.println("RECEIVED: OK");
connectWiFi();
}else{
monitor.println("Didn't run connectWiFi, at least, didn't get back an OK");
}
}
void loop(){
sensors.requestTemperatures();
float tempC = sensors.getTempCByIndex(0);
//tempC = DallasTemperature::toFahrenheit(tempC);
char buffer[10];
String tempF = dtostrf(tempC, 5, 2, buffer);
updateTemp(tempF);
monitor.println(tempC);
delay(60000);
}
void updateTemp(String tenmpF){
String cmd = "AT+CIPSTART=\"TCP\",\"";
cmd += IP;
cmd += "\",80";
sendDebug(cmd);
delay(2000);
if(Serial.find("Error")){
monitor.print("RECEIVED: Error");
return;
}
cmd = GET;
cmd += tenmpF;
cmd += "\r\n";
Serial.print("AT+CIPSEND=");
Serial.println(cmd.length());
if(Serial.find(">")){
monitor.print(">");
monitor.print(cmd);
Serial.print(cmd);
}else{
sendDebug("AT+CIPCLOSE");
}
if(Serial.find("OK")){
monitor.println("RECEIVED: OK");
}else{
monitor.println("RECEIVED: Error");
}
}
void sendDebug(String cmd){
monitor.print("SEND: ");
monitor.println(cmd);
Serial.println(cmd);
}
boolean connectWiFi(){
Serial.println("AT+CWMODE=1");
delay(2000);
String cmd="AT+CWJAP=\"";
cmd+=SSID;
cmd+="\",\"";
cmd+=PASS;
cmd+="\"";
sendDebug(cmd);
delay(5000);
if(Serial.find("OK")){
monitor.println("Connect RECEIVED: OK");
return true;
}else{
monitor.println("Connect RECEIVED: Error");
return false;
}
}
<?php $ESP=$_GET["key"]; $temp=$_GET["tempc"]; $FILE='FILE'.$ESP.".txt"; file_put_contents($FILE,$temp); echo "<p>"; echo "$ESP | $temp"; echo "</p>"; ?>
tightvncserver