Bom dia galera, estou com dificuldades em postar no meu servidor phpmyadmin (não é local), estou usando o shield cc3000, não exibi no serial nenhuma mensagem de erro, diz como se postou normalmente, mas vendo no servidor nada, estou usando um arquivo arquivo.php para gravar no servidor, mas nada.

Alguem teria como me mostrar como poderia fazer?

segue codigo:

/***************************************************
This is a sketch to use the CC3000 WiFi chip & Dweet.io

Written by Marco Schwartz for Open Home Automation
****************************************************/

// Libraries
#include <Adafruit_CC3000.h>
//#include <ccspi.h>
#include <SPI.h>
#include <DS1307.h>
//#include "DHT.h"
//#include <avr/wdt.h>
//#include "utility/debug.h"
//#include "utility/socket.h"


// Define CC3000 chip pins
#define ADAFRUIT_CC3000_IRQ 3
#define ADAFRUIT_CC3000_VBAT 5
#define ADAFRUIT_CC3000_CS 10

// DHT sensor
//#define DHTPIN 7
//#define DHTTYPE DHT11

// Create CC3000 instances
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
SPI_CLOCK_DIV2); // you can change this clock speed

// DHT instance
//DHT dht(DHTPIN, DHTTYPE);

// WLAN parameters
#define WLAN_SSID "Rede Vale"
#define WLAN_PASS "valeinfo!11"
#define WLAN_SECURITY WLAN_SEC_WPA2

// Dweet parameters
#define thing_name "pedrofilipe_x9521ss5dsa9"

float vazao; //Variável para armazenar o valor em L/min
float soma=0; //Variável para tirar a média a cada 1 minuto
float media=0; //Variável para tirar a média a cada 1 minuto
int contaPulso; //Variável para a quantidade de pulsos
int i=0; //Variável para contagem
DS1307 rtc(A14, A15);
// Variables to be sent
//int temperature;
//int humidity;
//int light;
//int t=1200;

uint32_t ip;
void incpulso ()
{
contaPulso++; //Incrementa a variável de contagem dos pulsos
}
void setup(void)
{
//rtc.halt(false);

// rtc.setDOW(FRIDAY); //Define o dia da semana
// rtc.setTime(11, 49, 15); //Define o horario
// rtc.setDate(24, 4, 2015); //Define o dia, mes e ano

// rtc.setSQWRate(SQW_RATE_1);
// rtc.enableSQW(true);

// Initialize
Serial.begin(115200);
pinMode(2, INPUT);
attachInterrupt(0, incpulso, RISING);
Serial.println(F("\nInitializing..."));
if (!cc3000.begin())
{
Serial.println(F("Couldn't begin()! Check your wiring?"));
while(1);
}

/* Optional: Set a static IP address instead of using DHCP.
Note that the setStaticIPAddress function will save its state
in the CC3000's internal non-volatile memory and the details
will be used the next time the CC3000 connects to a network.
This means you only need to call the function once and the
CC3000 will remember the connection details. To switch back
to using DHCP, call the setDHCP() function (again only needs
to be called once).
*/

uint32_t ipAddress = cc3000.IP2U32(192, 168, 0, 11);
uint32_t netMask = cc3000.IP2U32(255, 255, 255, 0);
uint32_t defaultGateway = cc3000.IP2U32(192, 168, 0, 1);
uint32_t dns = cc3000.IP2U32(8, 8, 8, 8);
if (!cc3000.setStaticIPAddress(ipAddress, netMask, defaultGateway, dns)) {
Serial.println(F("Failed to set static IP!"));
while(1);
}

/* Optional: Revert back from static IP addres to use DHCP.
See note for setStaticIPAddress above, this only needs to be
called once and will be remembered afterwards by the CC3000.
*/
/*
if (!cc3000.setDHCP()) {
Serial.println(F("Failed to set DHCP!"));
while(1);
}
*/

/* Attempt to connect to an access point */
char *ssid = WLAN_SSID; /* Max 32 chars */
Serial.print(F("\nAttempting to connect to ")); Serial.println(ssid);

/* NOTE: Secure connections are not available in 'Tiny' mode!
By default connectToAP will retry indefinitely, however you can pass an
optional maximum number of retries (greater than zero) as the fourth parameter.

ALSO NOTE: By default connectToAP will retry forever until it can connect to
the access point. This means if the access point doesn't exist the call
will _never_ return! You can however put in an optional maximum retry count
by passing a 4th parameter to the connectToAP function below. This should
be a number of retries to make before giving up, for example 5 would retry
5 times and then fail if a connection couldn't be made.
*/
if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
Serial.println(F("Failed!"));
while(1);
}

Serial.println(F("Connected!"));

/* Wait for DHCP to complete */
Serial.println(F("Request DHCP"));
while (!cc3000.checkDHCP())
{
delay(100); // ToDo: Insert a DHCP timeout!
}

/* Display the IP address DNS, Gateway, etc. */
while (! displayConnectionDetails()) {
delay(1000);
}

/* Wait for DHCP to complete */
/* Serial.println(F("Request DHCP"));
while (!cc3000.checkDHCP())
{
delay(100);
} */
}

void loop(void)
{
contaPulso = 0; //Zera a variável para contar os giros por segundos
sei(); //Habilita interrupção
delay (1000); //Aguarda 1 segundo
cli(); //Desabilita interrupção

vazao = contaPulso / 5.5; //Converte para L/min
soma=soma+vazao; //Soma a vazão para o calculo da media
i++;

Serial.print(vazao); //Imprime na serial o valor da vazão
Serial.print(" L/min - "); //Imprime L/min
Serial.print(i);
Serial.print(" segundos - ");
// Measure from DHT
// float t = dht.readTemperature();
// float h = dht.readHumidity();
// temperature = (int)t;
// humidity = (int)h;
//t++;
//temperature = (int)t;
//humidity = (int)t;

// Measure light level
// float sensor_reading = analogRead(A0);
// light = (int)(sensor_reading/1024*100);
//light = 133;
Serial.println(F("Measurements done"));

// Start watchdog
// wdt_enable(WDTO_8S);
//54.236.224.164


media=soma;
Serial.print("\nMedia por minuto = "); //Imprime a frase Media por minuto =
Serial.print(media);

uint32_t ipdweet = cc3000.IP2U32(45, 55, 164, 40);

// Get IP
/* uint32_t ip = 0;
Serial.print(F("www.dweet.io -> "));
while (ip == 0) {
if (! cc3000.getHostByName("www.dweet.io", &ip)) {
Serial.println(F("Couldn't resolve!"));
}
delay(500);
}
cc3000.printIPdotsRev(ip);
Serial.println(F(""));
*/
// Reset watchdog
//wdt_reset();

// Check connection to WiFi
Serial.print(F("\nChecking WiFi connection ..."));
if(!cc3000.checkConnected()){while(1){}}
Serial.println(F("done."));
//wdt_reset();

// Send request
Adafruit_CC3000_Client client = cc3000.connectTCP(ipdweet, 80);
if (client.connected()) {
Serial.print("Sending request... ");

/*String dado;
dado += "GET /arduino/";
dado += "pedro.php?vazao=";
dado += media;
dado += " HTTP/1.1";*/


client.print("GET /arduino/pedro.php?vazao="+(String)media +" HTPP/1.1");
//client.fastrprint(F("GET /dweet/for/"));
//client.print(thing_name);
//client.print(media);


client.println("Host: 45.55.164.40");
client.println("Connection: close");
client.println("");

media=0;
i=0;
soma=0;

/////////////////////////////////////////////////////////

////////////////////////////////////////////////////////

Serial.println("OK.");
} else {
Serial.println("Connection failed");
return;
}

// Reset watchdog
// wdt_reset();

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

// Reset watchdog
// wdt_reset();

// Close connection and disconnect
client.close();

Serial.println("Closing connection");
Serial.println("");

// Reset watchdog & disable
// wdt_reset();
// wdt_disable();

// Wait 60 seconds until next update
//wait(1000);


Serial.println("\n\n Recomecar\n\n");

}

// Wait for a given time using the watchdog
/*void wait(int total_delay) {

int number_steps = (int)(total_delay/5000);
wdt_enable(WDTO_8S);
for (int i = 0; i < number_steps; i++){
//Serial.println(F("Waiting for 5 seconds ..."));
delay(5000);
wdt_reset();
}
wdt_disable();
}*/
bool displayConnectionDetails(void)
{
uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;

if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
{
Serial.println(F("Unable to retrieve the IP Address!\r\n"));
return false;
}
else
{
Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress);
Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask);
Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway);
Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);
Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv);
Serial.println();
return true;
}
}

Exibições: 220

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço