/* * - If the trigger pin (3) goes low, send the data. * - Get sensing datas by using analogread() * - Call postData * - Open socket as TCP Client * - Try to connet TCP server (data.sparkfun.com); if needs, do DNS clinet for getting IP address of server * - Make query string based on Phant frame * - Send query * - Check for a response from the server, and route it out the serial port. */ while(1) { if(triggerPin ==0) { sensor.readData(); c = sensor.ReadTemperature(CELCIUS); h = sensor.ReadHumidity(); printf("Temperature in Celcius: %4.2f", c); printf("Humidity is %4.2f\n", h, dp, dpf); sock.connect("data.sparkfun.com", 80); snprintf(http_cmd, http_cmd_sz, "GET /input/%s?private_key=%s&%s=%2.2f&%s=%3.3f HTTP/1.1\r\nHost: data.sparkfun.com\r\nConection: close\r\n\r\n", publicKey, privateKey, fieldNames1, h, fieldNames2, c); sock.send_all(http_cmd, http_cmd_sz-1); while ( (returnCode = sock.receive(buffer, buffer_sz-1)) > 0) { buffer[returnCode] = '\0'; printf("Received %d chars from server:\n\r%s\n", returnCode, buffer); } sock.close(); } wait(2); }