ERROR UPLOAD DATA

Everything pertaining to the data.sparkfun.com service, the phant project which powers it, and user projects which talk to the service.

Moderators: phalanx, toddtreece, Brennen@SparkFun

Post Reply
dfacsdfasc
Posts: 1
Joined: Thu Apr 13, 2017 9:22 am

ERROR UPLOAD DATA

Post by dfacsdfasc » Thu Apr 13, 2017 9:53 am

hi everyone.I have arduino uno and SparkFun WiFi Shield - CC3000 and the monitor serial repeat :
Posting !
Error 1
the problem i think is that if (!client.connect(server,80))
also i can't make ping with data.sparkfun :
---------------------------
SparkFun CC3000 - Ping Test
---------------------------
CC3000 initialization complete
Connecting to: Thomson226466
Connected!
IP Address: 192.168.10.1
Looking up IP address of: data.sparkfun.com
IP address found: 54.86.132.254
Pinging 54.86.132.254 3 times...
Pong!

Packets sent: 6
Packets received: 0
Min round time (ms): 4294967295
Max round time (ms): 0
Avg round time (ms): 0

Disconnected
Finished ping test




!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!PING WITH GOOGLE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
---------------------------
SparkFun CC3000 - Ping Test
---------------------------
CC3000 initialization complete
Connecting to: Thomson226466
Connected!
IP Address: 192.168.10.1
Looking up IP address of: www.google.com
IP address found: 216.58.209.164
Pinging 216.58.209.164 3 times...
Pong!

Packets sent: 6
Packets received: 3
Min round time (ms): 78
Max round time (ms): 239
Avg round time (ms): 133

Disconnected
Finished ping test

!!!!!!!!!!!!!!!!!!!!!!!!!ARDUINO CODE!!!!!!!!!!!!!!!!!!!!!!!

#include <SPI.h>
#include <SFE_CC3000.h>
#include <SFE_CC3000_Client.h>
#include "DHT.h"
#define DHTPIN 3
#define DHTTYPE DHT22
#define pirPin 4
#define CC3000_INT 2 // Needs to be an interrupt pin (D2/D3)
#define CC3000_EN 7 // Can be any digital pin
#define CC3000_CS 10 // Preferred is pin 10 on Uno

// IP address assignment method
#define USE_DHCP 0 // 0 = static IP, 1 = DHCP

// Connection info data lengths
#define IP_ADDR_LEN 4 // Length of IP address in bytes
#define MAC_ADDR_LEN 6 // Length of MAC address in bytes

byte mac[]={0xC4,0xB3,0x01,0xBE,0x0C,0xC5};
char ap_ssid[] = "Thomson226466"; // SSID of network
char ap_password[] = "a18111811"; // Password of network
unsigned int ap_security = WLAN_SEC_WPA2; // Security of network
unsigned int timeout = 30000; // Milliseconds
//const char static_ip_addr[] = "0.0.0.0";
//IPAddress ip (192,168,10,1);
char server[]="data.sparkfun.com";
DHT dht(DHTPIN,DHTTYPE);

// Global Variables
SFE_CC3000 wifi = SFE_CC3000(CC3000_INT, CC3000_EN, CC3000_CS);
SFE_CC3000_Client client = SFE_CC3000_Client(wifi);

const String publicKey = "lz6LQqgnDbH9rlR5YJN3";
const String privateKey = "Elp4keKm1rIJ6Ya2r0B7";
const byte NUM_FIELDS = 3;
const String fieldNames[NUM_FIELDS] = {"Humidity","temp","MOTION"};
String fieldData[NUM_FIELDS];

void setup() {
Serial.begin(115200);
//pinMode (DHTpin,INPUT_PULLUP);
dht.begin();
pinMode(pirPin,INPUT);



setupWiFi();
Serial.println(F("=============Ready to Stream======="));
}

void loop(){
delay(2000);
fieldData[0]=dht.readHumidity();
fieldData[1]=dht.readTemperature();
fieldData[2]=digitalRead(pirPin);
if(fieldData[2]==HIGH){
fieldData[2]=("Sameone is there");
}else{
fieldData[2]=("No Motion");
}
Serial.println("Posting!");
postData();
delay(2000);


}

void setupWiFi(){
ConnectionInfo connection_info;
int i;
if (wifi.init())
{
Serial.println(F("CC3000 Ready"));

}else{
Serial.println(F("Error:0"));
}
}

void postData()
{
if (!client.connect(server,80))
{
Serial.println(F("Error:1"));
}
client.print("Get/input/");
client.print(publicKey);
client.print("?private_key=");
client.print(privateKey);
client.print("HUMIDITY");
client.println("");
client.print("TEMPERATURE");
client.print("");
client.print("MOTION/n");

for (int i=1; i<NUM_FIELDS; i++)
{
client.print(fieldNames);
client.print(fieldData);
client.print("");
}
client.print("/n");
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(server);
client.println("Connection: close");
client.println();

while (client.connected())
{
if ( client.available() )
{
char c = client.read();
Serial.print(c);
}
}
Serial.println();
}

Post Reply