Introduction: Photon:Displaying Values of DHT11 Using Blynk

Picture of Photon:Displaying Values of DHT11 Using Blynk

I like to experiment new things, Blynk is an android app where most of them use it for NodeMCU, I tried to interface it to an emerging IoT platform Photon.Fortunately, i was successful in interfacing it.

To begin with my introduction, I'm Sridhar Janardhan popularly known as Appytechie.In This Ibles, i am going to show how to interface a humidity sensor DHT11 to a Photon and display the value using a Blynk app.

start to sound amazing??Read on.

Have a glance on the components required for this project.

Step 1: Components Required:

Picture of Components Required:

Things used in this project are:

  • Photon
  • DHT11
  • Breadboard
  • Jumper wires
  • Android mobile
  • Type A to To C USB cable

Let's now connect the Photon to the Wifi using an Android.

Step 2: Wifi Linkage to the Photon

Picture of Wifi Linkage to the Photon

To turn on the Photon use the USB cable and connect.

After you turn on the Photon put the device into listening mode just by pressing the setup button for few seconds.

If your device is blinking in a different color please check out the docs presented by the Particle here.

Connecting the Photon to Wifi:

  • Download the official particle app here.
  • After downloading, Log in with your Particle account credentials, If you are a new user sign up here.
  • After signing up, Press the '+' button in the bottom right and choose Photon.
  • Now complete the process as per the screen instruction.
  • At last stage name your device and then you can see the breathing Cyan indicating that the Photon is connected successfully to wifi.

let's now interface the DHT11 sensor.

Step 3: Connect DHT11 Sensor

Picture of Connect DHT11 Sensor

DTH-11 is a humidity sensor that measures the humidity content.This sensor throws a data at a regular interval.This data we are going to show in Blynk app.

The connection of the DHT11 sensor are as follows:

  • The VCC pin of the sensor is given to the On board 3.3 volts.
  • The GND pin is connected to the GND pin of Photon.
  • The Signal pin is connected to the Digital pin 2 of the Photon.

Step 4: Blynk App Interfacing

Picture of Blynk App Interfacing

  • login with your credentials
  • Choose new project
  • In choose device choose particle photon
  • in connection type choose WiFi
  • Choose the gauge and value as the displaying parameter and Set gauge virtual pin as v2 and display virtual pin as v1.
  • Add the auth code in the code below.

Step 5: Coding

#include "blynk/blynk.h"

#include "PietteTech_DHT.h"

// system defines #define DHTTYPE DHT22 // Sensor type DHT11/21/22/AM2301/AM2302 #define DHTPIN 4 // Digital pin for communications #define DHT_SAMPLE_INTERVAL 60000 // Sample every minute

//declaration void dht_wrapper(); // must be declared before the lib initialization

// Lib instantiate PietteTech_DHT DHT(DHTPIN, DHTTYPE, dht_wrapper);

// globals unsigned int DHTnextSampleTime; // Next time we want to start sample bool bDHTstarted; // flag to indicate we started acquisition int n; // counter

//this is coming from https://www.instructables.com/id/Datalogging-with-Spark-Core-Google-Drive/?ALLSTEPS char resultstr[64]; //String to store the sensor data

//DANGER - DO NOT SHARE!!!! char auth[] = "01234567890123456789"; // Put your blynk token here //DANGER - DO NOT SHARE!!!!

char VERSION[64] = "0.04";

#define READ_INTERVAL 60000

void setup() {

Blynk.begin(auth); DHTnextSampleTime = 0; // Start the first sample immediately Particle.variable("result", resultstr, STRING);

Particle.publish("DHT22 - firmware version", VERSION, 60, PRIVATE); }

// This wrapper is in charge of calling // must be defined like this for the lib work void dht_wrapper() { DHT.isrCallback(); }

void loop() {

Blynk.run(); // all the Blynk magic happens here

// Check if we need to start the next sample if (millis() > DHTnextSampleTime) { if (!bDHTstarted) { // start the sample DHT.acquire(); bDHTstarted = true; }

if (!DHT.acquiring()) { // has sample completed?

float temp = (float)DHT.getCelsius(); int temp1 = (temp - (int)temp) * 100;

char tempInChar[32]; sprintf(tempInChar,"%0d.%d", (int)temp, temp1); Particle.publish("The temperature from the dht22 is:", tempInChar, 60, PRIVATE);

//virtual pin 1 will be the temperature Blynk.virtualWrite(V1, tempInChar); //google docs can get this variable sprintf(resultstr, "{\"t\":%s}", tempInChar);

float humid = (float)DHT.getHumidity(); int humid1 = (humid - (int)humid) * 100;

sprintf(tempInChar,"%0d.%d", (int)humid, humid1); Particle.publish("The humidity from the dht22 is:", tempInChar, 60, PRIVATE);

//virtual pin 2 will be the humidity Blynk.virtualWrite(V2, tempInChar);

n++; // increment counter bDHTstarted = false; // reset the sample flag so we can take another DHTnextSampleTime = millis() + DHT_SAMPLE_INTERVAL; // set the time for next sample } }

}

Comments

About This Instructable

706views

11favorites

License:

Bio: I am an electronic hobbyist on Arduino, Photon, Raspberry Pi and common electronics.A passionate cook.Any assistance in electronics and web development feel free ... More »
More by callmeappytechie:PIR Controlled Buzzer Using ArduinoDIY LampshadeTasty Egg Bonda
Add instructable to: