Advertisement
phillips321

ENC28J60 to sleep

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