Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void loop()
- {
- //--------------------------------------
- // 1) Measurements and data preparation
- //--------------------------------------
- if ((millis()-lastupdate)>10000)
- {
- Serial.println("Powered up");
- es.ES_enc28j60PowerUp();
- ethernet_setup_dhcp_dns(mac,PACHUBE_VHOST,80,8);
- delay(4000);
- lastupdate = millis();
- float temperature = getVoltage(0); //getting the voltage reading from the temperature sensor
- temperature = (temperature - .5) * 100; //converting from 10 mv per degree wit 500 mV offset
- // Convert int/double to string, add it to main string, add csv commas
- // dtostrf - converts a double to a string!
- // strcat - adds a string to another string
- // strcpy - copies a string
- strcpy(str,"TEMP,");
- dtostrf(temperature,0,1,fstr); strcat(str,fstr);
- dataReady = 1;
- }
- //----------------------------------------
- // 2) Send the data
- //----------------------------------------
- if (ethernet_ready_dhcp_dns() && dataReady==1)
- {
- ethernet_send_post(PSTR(PACHUBEAPIURL),PSTR(PACHUBE_VHOST),PSTR(PACHUBEAPIKEY), PSTR("PUT "),str);
- Serial.println("sent"); dataReady = 0;
- }
- Serial.println("Powered down");
- es.ES_enc28j60PowerDown();
- delay(2000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement