---
title: "Connecting to the Web server"
url: "https://maker.wiznet.io/forum/11208"
markdown_url: "https://maker.wiznet.io/forum/11208/md"
type: "Forum topic"
category: "Wireless"
author: "lhakim"
created: "2015-07-31T02:39:41+09:00"
last_activity: "2017-05-04T08:36:32+09:00"
language: "en"
views: 1207
replies: 2
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# Connecting to the Web server

## Question

Asked by lhakim on 2015-07-31 in Wireless.

Hai,
My project is to update data to thinkspeak using arduino uno and wizfi210 (DFRobot wifi shield v2.2), and i found similar topic here

[\[From QnA\]Connecting to the Google Web server](https://forum.wiznet.io/t/from-qna-connecting-to-the-google-web-server/158/1) [WizFi210/220](https://maker.wiznet.io/c/wifi-module/wizfi210-220/37)

> How can I connect to the google HTTP serer(Port 80) using &lt;AT+NCTCP> command?

I try the step using Arduino IDE serial monitor, and below the result

```
ATI2
WizFi210
1.1.1.0(W)
[OK]

AT+WA=INSTIL_RESEARCH_LAB
    IP              SubNet         Gateway   
 10.8.132.250: 255.255.254.0: 10.8.132.254
[OK]

AT+SETTIME=31/07/2013,10:21:11  
[OK]

AT+NCTCP=184.106.153.149,80   ///THINKSPEAK ip AND PORT
[OK]

{1B}S0GET / HTTP/1.1{0x0d}{0xa}{0x0d}{0xa}{1B}E
[ERROR: INVALID INPUT]
```

My question is:
1.How to use ESC sequence in arduino IDE as i already try “{1B}”,“(1B)”,“{27}”,“(27)”, still fail
2.How to post data to server (like thinkspeak)?
Below my code in arduino

```
 int esc=27;
  Serial.print(esc);
  Serial.print("s0");
  delay(1000);
  Serial.print("GET https://api.thingspeak.com/update?key=F2J4TD75PYVIWMQ1&field1=200 HTTP1.1\r\n");
  Serial.print("Host: api.thingspeak.com\r\n\r\n");
  Serial.print(esc);
  Serial.print("e");
```

Thanks

## Replies

### Reply 1 by wizdaniel, 2015-08-02

Hi lhakim.

1. You have to modify {xx} command to HEXA code.
   For example {1B} command means a hexa code of the ESC key function.
   {0x0d}{0x0a} means carriage return and line feeds as known as ENTER key function.(\r\n)
   So you can get the response from cloud server after typing ESC, carriage return, line feeds instead of {xx}.

2. You have written incorrect GET method.(GET [api.thingspeak.com/update?key=F … field1=200](https://api.thingspeak.com/update?key=F2J4TD75PYVIWMQ1&field1=200) HTTP1.1\r\n)
   If you want to connect and send queries to [thingspeak.com](http://thingspeak.com), you can prefer the api note of [thingspeak.com](http://thingspeak.com) like the link below.

- [thingspeak.com/docs/thingtweet/](https://thingspeak.com/docs/thingtweet/)

- [thingspeak.com/docs/thinghttp/](https://thingspeak.com/docs/thinghttp/)

[Thingspeak.com](http://Thingspeak.com) needs the string of information(POST ~~, api_key ~~, message ~~)

AND it have to be just sent as below rules.
client.print(“POST /update HTTP/1.1\n”);
client.print(“Host: [api.thingspeak.com](http://api.thingspeak.com)\n”);
client.print(“Connection: close\n”);
client.print(“X-THINGSPEAKAPIKEY: “+writeAPIKey+”\n”);
client.print(“Content-Type: application/x-www-form-urlencoded\n”);
client.print(“Content-Length: “);
client.print(tsData.length());
client.print(”\n\n”);

That source was included in the link below
[url][http://community.thingspeak.com/arduino/ThingSpeakClient.pde\[/url\]](http://community.thingspeak.com/arduino/ThingSpeakClient.pde%5B/url%5D)

Thanks.

### Reply 2 by lhakim, 2015-08-03

Hai wizdniel,
Thanks for the reply

I already manage to update the data to thinkspeak.

What I do is use serial.write in arduino to send hexa code to serial.Below is my test code

```
Serial.print("AT+NCTCP=184.106.153.149,80\n\r");  //Attempt TCP client connection to Destination   
  delay(1000);
  if(Serial.find("OK"))                       // if success, connect to network
     {
      Serial.println("TCP connection success");
      digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(1000);
      Serial.write(0x1b);
      Serial.print("S0");  
  Serial.print("GET /update?key=F2J4TD75PYVIWMQ1&field1=");
  Serial.print(data);
  Serial.print("HTTP/1.1\r\n");
  Serial.print("Host: api.thingspeak.com\r\n\r\n");
  Serial.write(0x1b);
  Serial.print("E");
  delay(1000);
   }
```

---

Source: https://maker.wiznet.io/forum/11208
