Created
June 8, 2017 20:46
-
-
Save giantmolecules/c03aeca6c4b70fc0c777054e92a2a473 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Timer tempTimer(2000, publishTemp); | |
int val = 0; | |
float voltage = 0.0; | |
float temperatureC = 0.0; | |
void setup() { | |
pinMode(A0, INPUT); | |
Serial.begin(115200); | |
} | |
void loop() { | |
val = analogRead(A0); | |
voltage = val*(3.3/4096.0); | |
Serial.print("Voltage = "); | |
Serial.print(voltage); | |
temperatureC = (voltage - 0.5) * 100; | |
Serial.print(" Temperature = "); | |
Serial.print(temperatureC); | |
Serial.println(" C"); | |
delay(100); | |
} | |
void publishTemp(){ | |
Particle.publish("TEMPC", String(temperatureC)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment