[SOLVED] ESP-01 CIPMODE error. need help with solving it

i am trying to send information to ubidots but i get a CIPMODE error. i am using the ESP-01 and arduino uno.

@xmex Could you post here your code?

#include “hx711.h”
#include “SoftwareSerial.h”
#include “UbidotsESP8266.h”
#define echoPin 6 // Echo Pin of ultrasoni sensor
#define trigPin 7 // Trigger Pin of ultrasonic sensor
#define buzzerPin 10 // buzzer input pin
#define SSID “caps”
#define PASS “lbp 6000b”
#define TOKEN “00uX11UEfc0l8qNwsD4uUg7dbwzMNg”
#define ID “576fbfb47625425249e235cb” // Your Ubidots’ variable ID
#define ID2 “576fbfbb76254252e5274df5”
#define DOUTPin A0
#define SCKPin A1
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Hx711 scale(A0, A1);// Hx711.DOUT - pin #A0
                    // Hx711.SCK - pin #A1
int maximumRange = 20; // Maximum range needed
int minimumRange = 0; // Minimum range needed
long duration, depth; // Duration used to calculate depth
float leveldifference, levelinpercentage;

Ubidots client(TOKEN);

void setup() {
 client.wifiConnection(SSID,PASS);
 Serial.begin(9600);
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
 pinMode(10, OUTPUT);// declare pin 10 to be an output of buzzer
 lcd.begin(16, 2);
 
 }

void loop() 
{
 Serial.print(scale.getGram(), 1);
 if(scale.getGram()>=200)
 {
  digitalWrite(buzzerPin, HIGH); 
  }
 Serial.println(" g");
 delay(100);
 lcd.setCursor(8, 0);
 lcd.print (scale.getGram(), 1);
 lcd.setCursor(14,0);
 lcd.print ("g");
 lcd.setCursor(0,0);
 lcd.print("WEIGHT:");
 /* The following trigPin/echoPin cycle is used to determine the
 depth of the bin using the nearest objects by bouncing soundwaves off of them. */ 
 digitalWrite(trigPin,LOW); 
 delayMicroseconds(5); 
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10); 
 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);
 depth = duration/58.2;//Calculate the depth (in cm) based on the speed of sound.
 leveldifference =(20-depth);
 levelinpercentage =(leveldifference/20)*100; //percentage used up in %
 lcd.setCursor(8, 1);
 lcd.print (levelinpercentage);
 lcd.setCursor(14,1);
 lcd.print ("%");
 lcd.setCursor(0,1);
 lcd.print("level :");
 
  if (depth >= maximumRange || depth <= minimumRange){
 /* Turn buzzer on to indicate "out of range" */
 Serial.println("out of range");
 digitalWrite(buzzerPin, HIGH);
 delay(100); 
 }
 else {
 Serial.print(levelinpercentage);
 Serial.println("%");
 digitalWrite(buzzerPin, LOW); 
 }
 /* Send the depth level and weight to the cloud and display on lcd, then
 turn buzzer OFF to indicate successful reading. */
 float value = scale.getGram();
  float value2 = levelinpercentage;
  client.add(ID,value);
  client.add(ID2,value2);
  client.sendAll();
  delay(1000);  //Delay 10ms before next reading.
}

just posted the code and here is the error.
out of ò
0.0 g
out of range
=>576fbfb47625425249e235cb:0.00,576fbfbb76254252e5274df5:100.00,
Response of ESP8266:

Response of ESP8266:

Response of ESP8266:

Error at CIPMODE
0.0 g
out of range
=>576fbfb47625425249e235cb:0.00,576fbfbb76254252e5274df5:100.00,576fbfb47625425249e235cb:0.00,576fbfbb76254252e5274df5:100.00,
Response of ESP8266:

@xmex how are you connecting the ESP to arduino?

i used this .cpp.

#include "UbidotsESP8266.h"
    #include <SoftwareSerial.h>

/**
 * Constructor.
 */
Ubidots::Ubidots(char* token) {
    _token = token;
    _client.begin(9600);
    currentValue = 0;
    _dsName = "ESP8266";
    _dsLabel = "esp-8266-identifier";
    val = (Value *)malloc(MAX_VALUES*sizeof(Value));
}

char* Ubidots::readData(uint16_t timeout) {
    uint16_t replyidx = 0;
    char replybuffer[550];
    while (timeout--) {
        if (replyidx >= 549) {
            break;
        }
        while (_client.available()) {
            char c =  _client.read();
            if (c == '\r') continue;
            if (c == 0xA) {
                if (replyidx == 0)   // the first 0x0A is ignored
                    continue;
            }
            replybuffer[replyidx] = c;
            replyidx++;
            if (replyidx >= 549) {
                break;
            }
        }
        if (timeout == 0) {
            break;
        }
        delay(1);
    }
    replybuffer[replyidx] = '\0';  // null term
#ifdef DEBUG_UBIDOTS
    Serial.println("Response of ESP8266:");
    Serial.println(replybuffer);
#endif
    while (_client.available()) {
        _client.read();
    }
    return replybuffer;
}
/** 
 * This function is to set the WiFi connection
 * @arg ssid of the WiFi
 * @arg pass of the WiFi
 * @return true upon success
 */
bool Ubidots::wifiConnection(char* ssid, char* pass) {
    _client.println(F("AT"));
    if((strstr(readData(2000),"OK")==NULL)){
#ifdef DEBUG_UBIDOTS
        Serial.println(F("clearin data"));
#endif
    }
    _client.println(F("AT+RST"));
    if((strstr(readData(2000),"OK")==NULL)){
#ifdef DEBUG_UBIDOTS
        Serial.println(F("Reset of ESP8266"));
#endif
    }
    _client.println(F("AT+GMR"));
    if((strstr(readData(2000),"OK")==NULL)){
#ifdef DEBUG_UBIDOTS
        Serial.println(F("Error at GMR"));
#endif
    }
    _client.println(F("AT+CWMODE=3"));
    if((strstr(readData(2000),"ERROR")!=NULL)){
#ifdef DEBUG_UBIDOTS
        Serial.println(F("Error with AT+CWMODE"));
#endif
        return false;
    }
    _client.print(F("AT+CWJAP=\""));
    _client.print(ssid);
    _client.print(F("\",\""));
    _client.print(pass);
    _client.println(F("\""));            
    if(strstr(readData(15000),"ERROR")!=NULL){
#ifdef DEBUG_UBIDOTS
        Serial.println(F("Error with AT+CWJAP"));
#endif
        return false;
    }
    _client.println(F("AT+CIFSR"));
    if((strstr(readData(2000),"ERROR")!=NULL)){
    
#ifdef DEBUG_UBIDOTS
        Serial.println(F("Error with AT+CIFSR"));
#endif
        return false;
    }
}
/** 
 * This function is to get value from the Ubidots API
 * @arg id the id where you will get the data
 * @return num the data that you get from the Ubidots API
 */
float Ubidots::getValue(char* id) {
    float num;
    String raw;
    uint8_t bodyPosinit;
    uint8_t bodyPosend;
    _client.println(F("AT"));
    if((strstr(readData(2000),"OK")==NULL)){
#ifdef DEBUG_UBIDOTS
        Serial.println(F("clearin data"));
#endif
    }
    _client.println(F("AT+CIPMUX=0"));
    if(strstr(readData(3000),"ERROR")!=NULL){
        Serial.println(F("Error at CIPMUX"));        
        return false;
    }
    _client.println(F("AT+CIPSTART=\"TCP\",\"things.ubidots.com\",80"));
    if(strstr(readData(10000),"Ok Linked")!=NULL){
        Serial.println(F("Error at CIPSTART"));
        return false;
    }
    _client.println(F("AT+CIPMODE=1"));
    if(strstr(readData(1000),"OK")==NULL){
        Serial.println(F("Error at CIPMODE"));        
        return false;
    }
    _client.println(F("AT+CIPSEND"));
    if(strstr(readData(1000),">")==NULL){
        Serial.println(F("Error at CIPSEND"));        
        return false;
    }
    _client.print(F("GET /api/v1.6/variables/"));
    _client.print(id);
    _client.println(F("/values?page_size=1 HTTP/1.1"));
    _client.println(F("Host: things.ubidots.com"));
    _client.println(F("User-Agent: Arduino-ESP8266/1.0"));
    _client.print(F("X-Auth-Token: "));
    _client.println(_token);
    _client.println(F("Connection: close"));
    _client.println();
    _client.println(F("+++"));
    char* reply = readData(5000);
    char* pch = strstr(reply,"\"value\":");
    raw = String(pch);
    bodyPosinit =9+ raw.indexOf("\"value\":");
    bodyPosend = raw.indexOf(", \"timestamp\"");
    raw.substring(bodyPosinit,bodyPosend).toCharArray(reply, 10);
    num = atof(reply);      
    return num;
}

void Ubidots::add(char *variable_id, float value, char *context1) {
    (val+currentValue)->id = variable_id;
    (val+currentValue)->value_id = value;
    (val+currentValue)->context_1 = context1;
    currentValue++;
    if (currentValue > MAX_VALUES) {
        currentValue = MAX_VALUES;
    }
}

bool Ubidots::sendAll() {
    uint8_t i;
    String str;
    char data[256];
    sprintf(data, "=>");
    for (i = 0; i < currentValue; i++) {
        str = String(((val+i)->value_id), 2);
        sprintf(data, "%s%s:%s", data, (val+i)->id, str.c_str());
        if ((val+currentValue)->context_1) {
            sprintf(data, "%s$%s", data, (val+i)->context_1);
        }
        sprintf(data, "%s,", data);
    }
    Serial.println(data);
    // Next for is to calculate the lenght of the data that you will send
    _client.println(F("AT+CIPMUX=0"));
    if(strstr(readData(3000),"ERROR")!=NULL){
        Serial.println(F("Error at CIPMUX"));        
        return false;
    }
    _client.print(F("AT+CIPSTART=\"TCP\",\""));
    _client.print(SERVER);
    _client.print(F("\","));
    _client.println(PORT);
    if(strstr(readData(10000),"Ok Linked")!=NULL){
        Serial.println(F("Error at CIPSTART"));        
        return false;
    }
    _client.println(F("AT+CIPMODE=1"));
    if(strstr(readData(1000),"OK")==NULL){
        Serial.println(F("Error at CIPMODE"));        
        return false;
    }
    _client.println(F("AT+CIPSEND"));
    if(strstr(readData(1000),">")==NULL){
        Serial.println(F("Error CIPSEND"));        
        return false;
    }
    _client.print(USER_AGENT);
    _client.print(F("/"));
    _client.print(VERSION);
    _client.print(F("|POST|"));
    _client.print(_token);
    _client.print(F("|"));
    _client.print(_dsLabel);
    _client.print(F(":"));
    _client.print(_dsName);
    _client.print(data);
    _client.println(F("|end"));
    _client.println(F("+++"));
    if(strstr(readData(5000),">") != NULL) {
        Serial.println(F("Error"));
        return false;
    }
    // Next for is to send all data from the struct   
    currentValue = 0;
    return true;
}`indent preformatted text by 4 spaces`

on pins TX and RX

ON pins TX and RX and powering it through a 3.3v regulator from 5v arduino supply

@xmex I think that you aren’t connecting it in the right form.
please follow the steps in this guide: http://ubidots.com/docs/devices/ESP8266-arduino.html

Best regards,
Metavix

done that thrice but still i get the same error

done that thrice but still its not working

@xmex Same erro? Could you post here a photo of your esp connected to Arduino, i need to check the leds on ESP

Best regards,
Metavix

@xmex sorry i made a mistake, the right connection is this:
Arduino —— ESP8266

D2 ——–> RXD
D3 ——–> TXD
3.3V ——–> VCC
3.3V ——–> CH_PD
GND ——–> GND

now i get an error CIPSEND.

now i get an error cipsend. initially i was stuck with cipmode error then edited the .cpp at AT+CIPMODE FROM “OK” to “ERROR”) !=NULL
NOW THE CIPSEND is a problem

@xmex great We have an advance, i will search why you have a cipsend error
Best regards,
Metavix

@xmex i was trying to get the same error that you have, I found a possible explanation for that and it is the small timeout for CIPSEND, i gave just 1 second and it need wait more time to get a response. I will fix it and upload a new version.

Best regards,
Metavix

Metavix,

Have you corrected the cipsend error issue?. Can I know the changes?