Advertisement
phillips321

Untitled

Sep 21st, 2011
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.30 KB | None | 0 0
  1. void loop()
  2. {
  3.   //--------------------------------------
  4.   // 1) Measurements and data preparation
  5.   //--------------------------------------
  6.   if ((millis()-lastupdate)>10000)
  7.   {
  8.     lastupdate = millis();
  9.     Serial.println("Powered up");
  10.     es.ES_enc28j60PowerUp();
  11.     delay(4000);
  12.     ethernet_setup_dhcp_dns(mac,PACHUBE_VHOST,80,8);
  13.     lastupdate = millis();
  14.      
  15.     float temperature = getVoltage(0);  //getting the voltage reading from the temperature sensor
  16.     temperature = (temperature - .5) * 100;          //converting from 10 mv per degree wit 500 mV offset
  17.    
  18.     // Convert int/double to string, add it to main string, add csv commas
  19.     // dtostrf - converts a double to a string!
  20.     // strcat  - adds a string to another string
  21.     // strcpy  - copies a string
  22.     strcpy(str,"TEMP,");
  23.     dtostrf(temperature,0,1,fstr); strcat(str,fstr);
  24.     dataReady = 1;
  25.   }
  26.  
  27.   //----------------------------------------
  28.   // 2) Send the data
  29.   //----------------------------------------
  30.   if (ethernet_ready_dhcp_dns() && dataReady==1)
  31.   {
  32.     ethernet_send_post(PSTR(PACHUBEAPIURL),PSTR(PACHUBE_VHOST),PSTR(PACHUBEAPIKEY), PSTR("PUT "),str);
  33.     Serial.println("sent"); dataReady = 0;
  34.     Serial.println("Powered down");
  35.     es.ES_enc28j60PowerDown();
  36.     delay(2000);
  37.   }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement