-->
Page 1 of 1

ESP8266 upload problem

PostPosted: Thu Jul 02, 2015 1:15 pm
by thivaakar
Greetings.

I'm having trouble trying to upload to ubidots but im'not sure where am i wrong.

on my serial monitor i can view my sensor readings but not online, although it seems esp8266 module is sending the data over.

Code: Select all#include <stdlib.h>
#include <SoftwareSerial.h>
#define SSID "boomgrow"
#define PASS "boom1grow"
#define IP "http://50.23.124.66"
//String GET = "GET /api/postvalue/?token=JTV7TqHW7GmDZuQOmb1KASZiYjel62a1PFz7w1rdW4sMjD8xwPY39h06zpmU&variable=5592c2877625426471f981a1&value=";
String GET = "GET /api/postvalue/?token=JTV7TqHW7GmDZuQOmb1KASZiYjel62a1PFz7w1rdW4sMjD8xwPY39h06zpmU&variable=556ec1737625425fb28692d5&value="; //dust variable ID = 556ec1737625425fb28692d5
//String voc1 = "55399a667625421a969d052d";


SoftwareSerial monitor(0, 1); // RX, TX

//*****DUST SENSOR SETUP
int measurePin = A5; //SIGNAL PIN(ANY ANALOG PIN)
int ledPower = 2; //ANY DIGITAL PIN
int samplingTime = 280;
int deltaTime = 40;
int sleepTime = 9680;
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;


void setup()
{

  pinMode(ledPower, OUTPUT);
  monitor.begin(9600);
  Serial.begin(9600);

  //**** TEST ESP8266 Module
  sendDebug("AT");
  delay(5000);
  if (Serial.find("OK")) {
    monitor.println("RECEIVED: OK");
    connectWiFi();
  }
}

void loop() {

  //**VOC loop
  int sensorValue = analogRead(A0);
  float Vol = sensorValue * 4.95 / 1023;
  Serial.print("Vol = ");
  Serial.println(Vol);
  delay(500);

  //**DUST loop
  digitalWrite(ledPower, LOW); // power on the LED
  delayMicroseconds(samplingTime);
  voMeasured = analogRead(measurePin); // read the dust value
  delayMicroseconds(deltaTime);
  digitalWrite(ledPower, HIGH); // turn the LED off
  delayMicroseconds(sleepTime);
  // 0 - 5.0V mapped to 0 - 1023 integer values
  calcVoltage = voMeasured * (5.0 / 1024);
  dustDensity = (0.17 * calcVoltage - 0.1) * 1000;
  Serial.print("Raw Signal Value (0-1023): ");
  Serial.print(voMeasured);
  Serial.print(" - Voltage: ");
  Serial.print(calcVoltage);
  Serial.print(" - Dust Density [ug/m3]: ");
  Serial.println(dustDensity);
 
  float Dust = dustDensity;
  delay(1000);


  save_value(String(Dust));
  delay(1000);
}

void save_value(String Dust) {
  //Set up TCP connection.
  String cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += IP;
  cmd += "\",80";
  Serial.println(cmd);
  //sendDebug(cmd);
  delay(2000);
  if (Serial.find("Error")) {
    monitor.print("RECEIVED: Error");
    return;
  }
 
  //Send DAta
  cmd = GET;
  cmd += Dust;
  cmd += "\r\n";
  Serial.print("AT+CIPSEND=");
  Serial.println(cmd.length());
  if (Serial.find(">")) {
    monitor.print(">");
    monitor.print(cmd);
    Serial.print(cmd);
  } else {
    sendDebug("AT+CIPCLOSE");
  }
  if (Serial.find("OK")) {
    monitor.println("RECEIVED: OK");
  } else {
    monitor.println("RECEIVED: Error");
  }
}
void sendDebug(String cmd) {
  monitor.print("SEND: ");
  monitor.println(cmd);
  Serial.println(cmd);
}

boolean connectWiFi() {
  Serial.println("AT+CWMODE=1");
  delay(2000);
  String cmd = "AT+CWJAP=\"";
  cmd += SSID;
  cmd += "\",\"";
  cmd += PASS;
  cmd += "\"";
 
  sendDebug(cmd);
  delay(5000);
  if (Serial.find("OK")) {
    monitor.println("RECEIVED: OK");
    return true;
  } else {
    monitor.println("RECEIVED: Error");
    return false;
  }
}


Image

Assistance would be appreciated to my graveyard and beyond :D been stuck on this for 3 days.

Re: ESP8266 upload problem

PostPosted: Fri Jul 03, 2015 11:02 am
by martinayotte
According to your code above, there HTTP requests are incomplete.
It should have "HTTP/1.1" and "Host : " along while double CRLF at the end.
This link can help : http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html