// Reads temperature from TMP36 sensor (from SparkFun electronics) on Arduino Pro Mini 3.3V 8MHz // Reports the readings to serial port // Plug Vcc of sensor to digital 12 // Plug Gnd of sensor to gnd of the board // Plug Vout of sensor to analog 0 // Monitoring diode (digital 13) blinks while sensor is being read const int power = 12; const int monitor = 13; const int analog = A0; const int serialRate = 9600 * 4; void setup() { // Beware: This is for Arduino Pro Mini 8MHz // most boards do not need this division Serial.begin(serialRate / 2); pinMode(power, OUTPUT); } void loop() { // Power up the thermo sensor digitalWrite(power, HIGH); // Power up monitor led digitalWrite(monitor, HIGH); // Wait for consistent ADC reading delay(150); // Read sensor value int value = analogRead(analog); digitalWrite(power, LOW); digitalWrite(monitor, LOW); // Print values to serial // Formula is 10mV per degree celsius for this sensor // Arduino reference is 3.3 on this board // ADC range is 0 to 1023 (10 bits) Serial.println(100 * value * (3.3 / 1023)); // Flush serial to get more consistent decoding at the other end of serial link Serial.flush(); // Wait for next loop delay(2000); }