Arduino DUE + ESP-05 + Thingspeak

I’m currently experimenting with Arduino and Wifi modules like the ESP8266. Below you can find a working example where the Arduino DUE measures the temperature using a Dallas DS18B20 and uploads the temperature using a ESP-05 to my local Thingspeak server.

What do you need:

1x Arduino Due
1x Dallas 18B20
1x 4,7 kohm Resistor
1x ESP-05

You’re require an account on https://thingspeak.com/ or run your own thingspeak server locally.

Connections between Arduino Due and ESP-05

ESP Pin Arduino DUE Pin
RST
GND GND
URXD TX1
UTXD RX1
VCC3V3 3.3V
#include 
#include 

#define ONE_WIRE_BUS 7 
OneWire ourWire(ONE_WIRE_BUS); 
DallasTemperature sensors(&ourWire);

char serialbuffer[1000];

long interval = 120000;
long previousMillis = 0;

String domain = "ThingspeakIP";
String SSID = "SSID";
String Password = "PASSWORD";

void setup()
{
  sensors.begin();
  sensors.setResolution(TEMP_12_BIT); 
  Serial1.begin(9600);//connection to ESP8266
  Serial.begin(9600); //serial debug
  
  Serial1.println("AT+RST");
  delay(5000);
  Serial1.println("AT+CWMODE=1");
  delay(500);//delay after mode change
  
  //connect to wifi network
  String connectwifi = "AT+CWJAP=\"" + SSID + "\",\"" + Password + "\"";
  Serial.println(connectwifi);
  Serial1.println(connectwifi);
  delay(2000);
}

void loop() {
  while (Serial1.available() > 0) {
    Serial.write(Serial1.read());
  }
  unsigned long currentMillis = millis();
  if(currentMillis - previousMillis > interval) {
    previousMillis = currentMillis;   
    sensors.requestTemperatures();
    float temp = sensors.getTempCByIndex(0);
    String message = "/update?key=[THINGSPEAKKEY]&field1=";
    message += temp;
    Serial.println(message);
    WebRequest(message);
  } 
  
}

void WebRequest(String request){     
     String startcommand = "AT+CIPSTART=\"TCP\",\"" + domain + "\", 80"; 
     Serial1.println(startcommand);
     Serial.println(startcommand);  
     if(Serial1.find("Error")){
       Serial.println("error on start");
       return;
     }
     String sendcommand = "GET http://"+ domain + request + " HTTP/1.0\r\n\r\n\r\n";
     Serial.print(sendcommand);
     Serial1.print("AT+CIPSEND=");
     Serial1.println(sendcommand.length());
     Serial.print("AT+CIPSEND=");
     Serial.println(sendcommand.length());
     delay(2000);  
     Serial.println(sendcommand);
     Serial1.print(sendcommand); 
}