Zoran Roncevic
Published © LGPL

Particle Photon & Thingspeak

Sending data to Thingspeak using Photon library without Webhook.

BeginnerProtip30 minutes4,755
Particle Photon & Thingspeak

Things used in this project

Hardware components

Photon
Particle Photon
×1
DHT22 Temperature Sensor
DHT22 Temperature Sensor
×1

Software apps and online services

ThingSpeak API
ThingSpeak API

Story

Read more

Schematics

Photon & DHT22

Code

DHT22-TS.ino

C/C++
#include "ThingSpeak/ThingSpeak.h"
#include "Adafruit_DHT/Adafruit_DHT.h"

#define DHTPIN 2     // what pin we're connected to
#define DHTTYPE DHT22	

DHT dht(DHTPIN, DHTTYPE);
TCPClient client;

int sendDelay = 60000;

unsigned int myChannelNumber = [Your-Channel-ID];
const char * myWriteAPIKey = "[Your-ReadApi-Key]";

void setup() {
	dht.begin();
	ThingSpeak.begin(client);
	Particle.publish("PowerON","dht22-ts",60,PRIVATE);
}

void loop() {

	float h = dht.getHumidity();
	float t = dht.getTempCelcius();

  ThingSpeak.setField(1,t);
  ThingSpeak.setField(2,h);

  // Write the fields that you've set all at once.
  ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);  
  delay(sendDelay);	
}

Credits

Zoran Roncevic

Zoran Roncevic

19 projects • 121 followers
Hackster Live ambassador in Serbia. Organizer of Maker NS community.

Comments

Add projectSign up / Login