Introduction: Particle Core - Temperature Sensor

Particle core is great for its IoT applications and one of such applications is to take common electronics to the internet, in this tutorial I'm going to show you how to connect a temperature sensor and read the values over the internet. You can read through my previous instructables before going through this one as there are a lot of simple projects to get started.

So lets get started...

Step 1: Tools and Components

Here is all that you need to get started -

  • Particle Core or Photon
  • Lm36
  • Breadboard
  • Jumper Wires

Step 2: Circuit

The circuit is really simple, it has a lm36 IC connected at analog pin 0 and the power supply for the sensor. The addition of the capacitor is optional and is only required to keep the senor stable and reduce the noise. An alternative IC would be Lm35 IC.

Step 3: Code

The code can be found below -

#include
#define PRINTF_BUFFER_SIZE 128 void Serial_printf(const char* fmt, ...) { char buff[PRINTF_BUFFER_SIZE]; va_list args; va_start(args, fmt); vsnprintf(buff, PRINTF_BUFFER_SIZE, fmt, args); va_end(args); Serial.println(buff); }

double temperature = 0.0;

void setup() { // Use serial port for debug print Serial.begin(9600);

// register API variable Spark.variable("temperature", &temperature, DOUBLE); pinMode(A7, INPUT); }

void loop() { int analogValue = analogRead(A7); double voltage = 3.3 * ((double)analogValue / 4095.0);

// http://www.analog.com/static/imported-files/data_sheets/TMP35_36_37.pdf temperature = (voltage - 0.5) * 100; Serial_printf("voltage=%g temperature=%g", voltage, temperature); delay(500); }