Things used in this project

Hardware components:
Compare particleelectron
Particle Electron
×1
10167 01
DHT22 Temperature Sensor
×1
Software apps and online services:
Hackster
ThingSpeak API

Code

thermometer.inoArduino
// This #include statement was automatically added by the Particle IDE.
#include "ThingSpeak/ThingSpeak.h"

// This #include statement was automatically added by the Particle IDE.
#include "Adafruit_DHT/Adafruit_DHT.h"

// Sensor type
#define DHTTYPE DHT22    	// DHT 22 (AM2302)

// DHT22 sensor pinout:
// Pin 1 (on the left): +3.3V
// Pin 2: output
// Pin 4 (on the right): GROUND

#define DHT_5V_PIN D1
#define DHT_SENSOR_PIN D2
#define DHT_GROUND_PIN D4

DHT dht(DHT_SENSOR_PIN, DHTTYPE);

/* Thingspeak */
TCPClient client;
unsigned long myChannelNumber = 89137;
const char * myWriteAPIKey = "3D23PQHQIJ3OZXNF";

void setup() {
    // Connect to ThingSpeak
    ThingSpeak.begin(client);

    // Give power to the sensor
    pinMode(DHT_5V_PIN, OUTPUT);
    pinMode(DHT_GROUND_PIN, OUTPUT);
    digitalWrite(DHT_5V_PIN, HIGH);
    digitalWrite(DHT_GROUND_PIN, LOW);
    // Wait for the sensor to stabilize
    delay(1000);

    // Initialize sensor
    dht.begin();

    // Read Sensor
    double temperature = dht.getTempCelcius();
    double humidity = dht.getHumidity();

    // Update the 2 ThingSpeak fields with the new data
    ThingSpeak.setField(1, (float)temperature);
    ThingSpeak.setField(2, (float)humidity);
    
    // Write the fields that you've set all at once.
    ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
    
    // Give time for the message to reach ThingSpeak
    delay(5000);

    // Sleep for 15 minutes to save battery
    System.sleep(SLEEP_MODE_DEEP, 15 * 60);
}

void loop() {
    // This will run because the system is sleeping
}

Credits

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

MyHumidity controlled by BME280 and Photon
Easy
  • 58
  • 2

Full instructions

Checks if humidity threshold is reached and informs the user by using Blynk/IFTTT-services with softAP integration.

MyLight-Clock with NeoPixel Ring 12 Controlled by Photon
Easy
  • 237
  • 2

Full instructions

Read the time at night? Without glasses? Impossible? Focus on 2 light points, which will tell you the hour and the minute.

Map Your Particles!
Easy
  • 1,305
  • 20

Protip

Locate your Particle Photons, P1s and Electrons on a map without needing extra hardware. Use Ubidots or an offline map alternative

BME280 measures and displays on OLED controlled by Photon
Easy
  • 306
  • 2

Protip

I share my first steps with the sensor BME280 (temp / humi / pressure / altitude) and an OLED 128 * 64 px

MyDallas DS18B20 Controlled by Photon
Easy
  • 70
  • 0

Protip

A water-resistant temperature sensor is suitable to signal the reaching of the core temperature of the meat during the grilling time.

MyRemote Temperature MLX90614 Controlled by Photon
Easy
  • 49
  • 0

Protip

An infrared temperature sensor is suitable to signal the temperature without a touch/contact.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login