[SOLVED] Stuck at ip when trying to post value

Hi, I have a problem to post my value. When open serial it always stuck at ip address. My project is to measure the carbon monoxide concentration using MQ7 sensor. When I try to stream the data it always stuck at 50.23.124.66. Any guidance and help are much appreciated.

#include       <UbidotsCC3000.h>
#include       <Adafruit_CC3000.h>
#include       <ccspi.h>
#include       <string.h>
#include       <SPI.h>



#define WLAN_SSID       " "  // Your WiFi SSID, cannot be longer than 32 characters!
#define WLAN_PASS       " "  // Replace it with your WiFi pass

// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY   WLAN_SEC_WPA2

#define TOKEN " "  // Replace it with your Ubidots token
#define ID  " " // Replace it with your Ubidots' variable ID


Ubidots client(TOKEN);



float Ro_CO  = 2700.0;



int sensorPin_MQ7                              (0);  
int val_MQ7 = 0;        
float Vrl_MQ7 = 0.0;
float Rs_MQ7 = 0.0;
float ratio0 = 0.0;







void setup() 
{

Serial.begin(115200);
client.initialize();
client.wifiConnection(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);


}

// get CO ppm
float get_CO (float ratio0){
  float ppm = 0.00;
  ppm = 112.18* pow (ratio0, -1.456);
return ppm;}




void loop() 
 {
   Vrl_MQ7 = val_MQ7 * ( 5.00 / 1023.0  );      // V
   Rs_MQ7 = 10000 * ( 5.00 - Vrl_MQ7) / Vrl_MQ7 ;   // Ohm
   ratio0 =  Rs_MQ7/Ro_CO;   

  float value1 = (get_CO(ratio0), 3);
   client.add(ID,value1);

 }

You can post here you terminal data, and the size of the sketch please

I am using arduino mega 2560 compatible board with a CC3000 shield. I am using arduino ide 1.6.8. I have try the example given and it work flawlessly it can sent the analog value from one sensor, but when I tried to use my code it stuck at ubidots ip address. I have updated my ubidots library to the latest one.

Sketch uses 20,742 bytes (8%) of program storage space. Maximum is 253,952 bytes.
Global variables use 1,130 bytes (13%) of dynamic memory, leaving 7,062 bytes for local variables. Maximum is 8,192 bytes.

To tell you the truth i am planning to sent 5 data to your platform. The next 4 data will use the same code. But I am playing around with just one data at the moment.

The code with all the comments.

#include       <UbidotsCC3000.h>
#include       <Adafruit_CC3000.h>
#include       <ccspi.h>
#include       <string.h>
#include       <SPI.h>



#define WLAN_SSID       " "  // Your WiFi SSID, cannot be longer than 32 characters!
#define WLAN_PASS       " "  // Replace it with your WiFi pass

// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY   WLAN_SEC_WPA2

#define TOKEN " "  // Replace it with your Ubidots token
#define ID  " " // Replace it with your Ubidots' variable ID


Ubidots client(TOKEN);


//VARIABLES
float Ro_CO  = 2700.0; //From Calculation of Rs In a Clean
                       // Air with the Assumtptions that 
                       //in a clean air there is 0.2ppm Carbon
                       // monoxide concentrations we find
                       // the Ro of 0.2ppm carbon monoxide

int sensorPin_MQ7  (0);  
int val_MQ7 = 0;        // variable to store the value coming from the sensor
float Vrl_MQ7 = 0.0;
float Rs_MQ7 = 0.0;
float ratio0 = 0.0;


void setup() 
{

Serial.begin(115200);
client.initialize();
client.wifiConnection(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);


}

// get CO ppm
float get_CO (float ratio0){
  float ppm = 0.00;
  ppm = 112.18* pow (ratio0, -1.456); // From the graph of ppm vs Rs/Ro I plot 
                                      //(data provided by the manufacturer) 
                                      // we find the equation of 
                                     // ppm = A(Rs/Ro)^B
return ppm;}




void loop() 
 {
   val_MQ7 = analogRead(sensorPin_MQ7);     // read the analog value 
   Vrl_MQ7 = val_MQ7 * ( 5.00 / 1023.0);      // analog value convert to volt
   Rs_MQ7 = 10000 * ( 5.00 - Vrl_MQ7) / Vrl_MQ7 ;   // the voltage are
                                                   // then convert to Rs
   ratio0 =  Rs_MQ7/Ro_CO;     //The Rs of the sensor are then 
                               //devided with the Ro of the targeted gas

  float value1 = (get_CO(ratio0), 3); // The data obtain are given
                                      // in 3 decimal places
  client.add(ID,value1);

 }

I’m still a noob at programming.

one more thing please the exactly part when you code stuck (all serial terminal message please)

Its always stuck at the ip address. The serial is below

Initializing...

Attempting to connect to .......
Connected!
Request DHCP
Couldn't resolve!
50.23.124.66

Well this is a problem with cc3000 library of adafruit, mm maybe you forget to sold some pins of cc3000 board. Follow this guide and tell me if the problem presist https://learn.adafruit.com/adafruit-cc3000-wifi/cc3000-shield

This is the serial when I use the example UbidotsSaveValue Example. As you can see it can stream the value when using the example given.

Initializing...

Attempting to connect to  
Connected!
Request DHCP
50.23.124.66
CC3000/1.0|POST|cPNCuzrwzjcIskqHlJQuGC6HJU5zFn|CC3000=>571742e2762542027ef73fde:207.00|end
Client connected
envie
OK
CC3000/1.0|POST|cPNCuzrwzjcIskqHlJQuGC6HJU5zFn|CC3000=>571742e2762542027ef73fde:207.00|end
Client connected
envie
OK
CC3000/1.0|POST|cPNCuzrwzjcIskqHlJQuGC6HJU5zFn|CC3000=>571742e2762542027ef73fde:208.00|end
Client connected
envie
OK
CC3000/1.0|POST|cPNCuzrwzjcIskqHlJQuGC6HJU5zFn|CC3000=>571742e2762542027ef73fde:209.00|end
Client connected
envie
OK
CC3000/1.0|POST|cPNCuzrwzjcIskqHlJQuGC6HJU5zFn|CC3000=>571742e2762542027ef73fde:209.00|end
Client connected
envie
OK
CC3000/1.0|POST|cPNCuzrwzjcIskqHlJQuGC6HJU5zFn|CC3000=>571742e2762542027ef73fde:208.00|end
Client connected
envie
OK
CC3000/1.0|POST|cPNCuzrwzjcIskqHlJQuGC6HJU5zFn|CC3000=>571742e2762542027ef73fde:207.00|end

Below is the serial print when I use the Adafruit CC3000 Build test example. As you can see my firmware is the latest one.

Hello, CC3000!

RX Buffer : 131 bytes
TX Buffer : 131 bytes
Free RAM: 7331

Initialising the CC3000 ...
Firmware V. : 1.32
MAC Address :  
Networks found: 1
================================================
SSID Name    :  
RSSI         : 55
Security Mode: 3

================================================

Deleting old connection profiles

Attempting to connect to 
Connected!
Request DHCP

IP Addr: 192.168.0.101
Netmask: 255.255.255.0
Gateway: 192.168.0.1
DHCPsrv: 192.168.0.1
DNSserv: 192.168.0.1
www.adafruit.com -> 141.101.113.175

Pinging 141.101.113.175...4 replies
Ping successful!


Closing the connection

Then try to upgrade CC3000 firmware and use an example of adafruit cc3000 example please

Sorry for the confusing reply.

Then now is all good? or the problem persist when you add other library ?

Nope, still can’t use my code.

Initializing...

Attempting to connect to 
Connected!
Request DHCP
50.23.124.66

Still stuck at the ip address

well your problem is very strange, because it only happens when you put the code of the sensor. I can tell you something, it is stucking in the wifi connection, is very strange and i think that it is a conflict with your code and the adafruit_cc3000 library, because it stuck before the ubidots functions… mmm I recomended you ask in the adafruit forum, maybe they have the reason of that

I will try to do that.

this is the part where it is stucking my friend:

while (!cc3000.checkDHCP()){
        delay(100); // ToDo: Insert a DHCP timeout!
    }

An infinite loop, but is a normal function of cc3000, tell them about that

wait a second, you can try to change you void loop() for this void loop please and tell me it it works?

void loop() 
 {
   val_MQ7 = analogRead(sensorPin_MQ7);     // read the analog value 
   Vrl_MQ7 = val_MQ7 * ( 5.00 / 1023.0);      // analog value convert to volt
   Rs_MQ7 = 10000 * ( 5.00 - Vrl_MQ7) / Vrl_MQ7 ;   // the voltage are
                                                   // then convert to Rs
   ratio0 =  Rs_MQ7/Ro_CO;     //The Rs of the sensor are then 
                               //devided with the Ro of the targeted gas

  float value1 = (get_CO(ratio0), 3); // The data obtain are given
                                      // in 3 decimal places
  client.add(ID,value1);
  client.sendAll();

 }

It can stream data but the value is always 3.00. It post the wrong value.

yay! we forgot to put sendAll() :stuck_out_tongue: without this it only save the value in the mega but it doesn’t send it. MMM you can put an Serial.println(value1); before client.add to check the value?

It post different value. I tried my original code without any streaming the value i got is always around 0.1 not 3.00. I think aruino literally took the number 3 in (get_CO(ratio0), 3) as a value.

Yes is a posibility

Dave If you have another problem I’ll be here, thank you for the patience.