Print in console - Tinkercad simulator

0

I'm using this tinkercad simulator and would like to consume a web service (it can be anyone, in the code I put one that I found from the example clock)

ESP8266 Arduino

link

#include <SoftwareSerial.h>

const byte rxPin = 2;
const byte txPin = 3;

String ssid     = "Simulator Wifi";
String password = "";

String host     = "nist.time.gov";
const int httpPort   = 80;
String uri       = "/actualtime.cgi?lzbc=siqm9b";

SoftwareSerial ESP8266 (rxPin, txPin);

unsigned long lastTimeMillis = 0;

void setup() {
  Serial.begin(9600);   
  ESP8266.begin(9600);
  delay(2000);

  ESP8266.println("AT+CWJAP=\"" + ssid + "\",\"" + password + "\"");

}

void printResponse() {
  while (ESP8266.available()) {
    Serial.println(ESP8266.readStringUntil('\n')); 
  }
}

void loop() {

  if (millis() - lastTimeMillis > 30000) {
    lastTimeMillis = millis();

    ESP8266.println("AT+CIPMUX=1");
    delay(1000);
    printResponse();

    ESP8266.println("AT+CIPSTART=\"TCP\",\"" + host + "\"," + httpPort);
    delay(1000);
    printResponse();

    String cmd = "GET " + uri + " HTTP/1.1\r\nHost: " + host + "\r\n\r\n";
    ESP8266.println("AT+CIPSEND=4," + String(cmd.length() + 4));
    delay(1000);

    ESP8266.println(cmd);
    delay(1000);
    ESP8266.println(""); 
  }

  if (ESP8266.available()) {
    Serial.write(ESP8266.read());
  }

}

The problem is that the console does not display anything

    
asked by anonymous 13.04.2018 / 12:46

0 answers