About the usage of Rev2 esp8266 at command


#1

I recently got into this field of arduino , and I bought the espduino to send some messages up to the thingspeak . I download the smaple code on github from https://github.com/AprilBrother/espduino .
And I try to use the thingspeak sample . But I didn’t got a dht . So I just type the numbers on and try to modify it . But It just didn’t send it up . Here is my code .

#include <espduino.h>
#include <rest.h>

#define PIN_ENABLE_ESP 13
#define SSID  "dlink3f"
#define PASS  "fang752612345"

ESP esp(&Serial1, &Serial, PIN_ENABLE_ESP);

REST rest(&esp);

boolean wifiConnected = false;

void wifiCb(void* response)
{
  uint32_t status;
  RESPONSE res(response);

  if(res.getArgc() == 1) {
    res.popArgs((uint8_t*)&status, 4);
    if(status == STATION_GOT_IP) {
      Serial.println("WIFI CONNECTED");
     
      wifiConnected = true;
    } else {
      wifiConnected = false;
    }
    
  }
}

void setup() {
  Serial1.begin(19200);
  Serial.begin(19200);
  esp.enable();
  delay(500);
  esp.reset();
  delay(500);
  while(!esp.ready());

  Serial.println("123");
  if(!rest.begin("api.thingspeak.com")) {
    Serial.println("ARDUINO: failed to setup rest client");
    while(1);
  }

  /*setup wifi*/
  Serial.println("ARDUINO: setup wifi");
  esp.wifiCb.attach(&wifiCb);

  esp.wifiConnect(SSID, PASS);
  Serial.println("ARDUINO: system started");
}

void loop() {
  char response[266];
  esp.process();
  if(wifiConnected) {
      char buff[64];
      sprintf(buff, "/update?api_key=Y9RPPYEVNVDJGN8R&field1=%s&field2=%s", 2, 3);
      Serial.println(buff);
      rest.get((const char*)buff);
      Serial.println("ARDUINO: send get");

      if(rest.getResponse(response, 266) == HTTP_STATUS_OK){
        Serial.println("ARDUINO: GET successful");
        Serial.println(response);
      }
      delay(30000);
      
    } else {
      Serial.print("error,\r\n"); 
    }
    
    
  }

and the result can i got some help?


#2

Please change the baud rate at serial monitor to 19200 first.


#3

i changed but nothing have shown
like this


#4

This is the latest result

could anyone help me out with this
P.S my board is Cactus Micro Rev2 Arduino compatible plus esp8266


#5

Hi,

Did you re-flash the firmware for esp8266 module? Please check the topic “about cactus micro r2 recently

Please make sure which firmware you choose. The sketch you post can only work with the firmware espduino. It can’t work with AT firmware.


#6

I’m sorry I’m not sure how to upload the sketch . Infact , I only want to upload to thingspeak . Is there any way I can upload to thingspeak with the board Cactus Micro Rev2 Arduino compatible plus esp8266 . Is there any easy explanation ?


#7

The default firmware for esp8266 module is espduino. If you haven’t re-flashed the esp8266 module, the firmware should be espduino.

I’ve tested the sketch you posted here. It works. Have you made any other change to the board?


#8

I didn’t made any change to the board . Is it the same sketch ? I don’t know , the board just don’t reply to me .


#9

Is it the same board ?
The Micro Rev2 one .


#10

Could you please take a photo for the board?


#11


#12

And I came to the site on the box to look for help .


#13

with this sketch . I can connect to my wifi .

 * @example ConnectWiFi.ino
 * @brief The ConnectWiFi demo of library WeeESP8266. 
 * @author Wu Pengfei<pengfei.wu@itead.cc> 
 * @date 2015.03
 * 
 * @par Copyright:
 * Copyright (c) 2015 ITEAD Intelligent Systems Co., Ltd. \n\n
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version. \n\n
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
#include "ESP8266.h"

#define SSID        "dlink3f"
#define PASSWORD    "fang752612345"

ESP8266 wifi(Serial1);

void setup(void)
{
    pinMode(13, OUTPUT);
     digitalWrite(13, HIGH); 
    Serial.begin(9600);
    Serial.print("setup begin\r\n");

    Serial.print("FW Version: ");
    Serial.println(wifi.getVersion().c_str());
    
    
    if (wifi.setOprToStation()) {
        Serial.print("to station ok\r\n");
    } else {
        Serial.print("to station err\r\n");
    }

    if (wifi.joinAP(SSID, PASSWORD)) {
        Serial.print("Join AP success\r\n");
        Serial.print("IP: ");       
        Serial.println(wifi.getLocalIP().c_str());
    } else {
        Serial.print("Join AP failure\r\n");
    }
    
    Serial.print("setup end\r\n");
}

void loop(void)
{
}


#14

Hi,

The sketch from itead work with at command firmware. Please check the section “For esp8266 AT firmware” for more examples.


#15

HI ,
Now I can run with these examples https://github.com/AprilBrother/cactus-micro-r2/tree/master/libraries/CactusMicro/examples , so how should I do to make it send on to the thingspeak .

Thanks for your help


#16

You need re-flash the firmware to espduino.

Please check our wiki Cactus Micro R2 Tutorial. There’s a link for How to made Cactus Micro R2 as ESP8266 programmer.

Here’s the espduino firmware.


#17

HI ,
I follow the instruction and done .
but I still can’t get the code I type on top run .
What should I do next.


#18

Please also take a screenshot for “Config” and “Advanced” page.


#19

here it is


#20

Please change these:

  • Flash size - 1MByte or 512KByte
  • SPI Mode - QIO