Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By martinayotte
#31795 The problem is maybe in the request itself. Why do you have "HEAD" in it ?
BTW, "time.is" seems to check UserAgent signature, so we need one.
Also, the request should end with double \r\n.

Code: Select allGET HEAD / HTTP /1.1\r\nHost: time.is


It should something like :
Code: Select allGET / HTTP /1.1\r\nHost: time.is\r\nUser_Agent: MyESPClient\r\n\r\n
User avatar
By sushma
#31801 I interfaced with Raspberry Pi and sending AT commands using minicom. I sent the data as
GET / HTTP /1.1\r\nHost: time.is\r\nUser_Agent: MyESPClient\r\n\r\n
I got" ERROR" message. Why is it so? I am trying to read current time from internet and I used all the possible AT commands but no result. When I reset ESP8266 it displays:
ets Jan 8 2013, rst cause:4, boot mode:(3,6)
wdt reset
load 0x40100000, len 816, room 16
tail 0
chksum 0x8d
load 0x3ffe8000, len 788, room 8
tail 12
chksum 0xcf
ho 0 tail 12 room 4
load 0x3ffe8314, len 288, room 12
tail 4
chksum 0xcf
csum 0xcf

2nd boot version : 1.2
SPI Speed : 40MHz
SPI Mode : QIO
SPI Flash Size : 4Mbit
jump to run user1
&*(&^^%%$%
Ai-Thinker Technology Co. Ltd.
invalid

Instead of "Ready" message after resetting I am getting "invalid" message, why is it so? Is there any problem with module or with firmware or anything else? I am unable to flash the latest firmware also? It is displaying as "failed to connect" when I tried to download bin file using flasher, even I tried with NodeMCU flasher. Nothing is working. What is the problem? Since a week I am working on it and unable to resolve. Can anyone suggest me a process to make it work properly?
User avatar
By martinayotte
#31848 I've put back my old ai-thinker-0.23-sdk1.01-full-0x00000.bin firmware and I used my old python test script as follow :

Code: Select all#!/usr/bin/python

import time
import serial
import binascii

port = serial.Serial('/dev/ttyUSB2', 115200, timeout=1)

def waitFor(str):
    timeout = 0
    serial_rxbuf = ""
    while True:
        while port.inWaiting() > 0:
            c = port.read()
            serial_rxbuf += c
            if serial_rxbuf.endswith(str):
                return True
        time.sleep(0.01)
        timeout += 1
        if timeout > 100:
            print "waitFor Timeout !"
            return False

def getRxLine():
    timeout = 0
    serial_rxbuf = ""
    while True:
        while port.inWaiting() > 0:
            c = port.read()
            serial_rxbuf += c
            if c == '\n':
                return serial_rxbuf.strip()
        time.sleep(0.01)
        timeout += 1
        if timeout > 100:
            print "Timeout !"
            return serial_rxbuf

port.write("AT+CIPSTART=\"TCP\",\"www.timeapi.org\",80\r\n")
waitFor("CONNECT")
waitFor("OK")
get_str = "GET /utc/now?format=%25a%20%25b%20%25d%20%25I:%25M:%25S%20%25Z%20%25Y HTTP/1.1\r\nHost: www.timeapi.org\r\nUser_Agent: MyESPClient\r\n\r\n"
print get_str
print "sending AT+CIPSEND=%d\r\n" % len(get_str)
port.write("AT+CIPSEND=%d\r\n" % len(get_str))
time.sleep(0.3)
waitFor(">")
port.write(get_str)
for i in range(0,20):
      str = getRxLine()
      print "Echo: %s" % str


I've got the following answer from "www.timeapi.org" :

Code: Select allGET /utc/now?format=%25a%20%25b%20%25d%20%25I:%25M:%25S%20%25Z%20%25Y HTTP/1.1
Host: www.timeapi.org
User_Agent: MyESPClient


sending AT+CIPSEND=130

User_Agent: MyESPClientat=%25a%20%25b%20%25d%20%25I:%25M:%25S%20%25Z%20%25Y HTTP/1.1
Echo: Recv 130 bytes
Echo:
Echo: SEND OK
Echo:
Echo: +IPD,283:HTTP/1.1 200 OK
Echo: Date: Tue, 20 Oct 2015 17:36:56 GMT
Echo: Connection: keep-alive
Echo: X-Frame-Options: sameorigin
Echo: X-Xss-Protection: 1; mode=block
Echo: Content-Type: text/html;charset=utf-8
Echo: Content-Length: 31
Echo: Server: thin 1.5.0 codename Knife
Echo: Via: 1.1 vegur
Echo:
Timeout !
Echo: Tue Oct 20 05:36:56 +00:00 2015


For the "time.is", I've got a huge HTML page, like the one that can be seen in a browser, but too much javascripts to analyse to get straight to the JSON time value request. If someone know more their API, maybe we can make it work.