Things used in this project

Code

blynkweather.inoC/C++
Code for Energia
///
/// @mainpage	blynkWeather
///
/// @details	Blynk with Weather for CC3200
/// @n
/// @n
/// @n @a		Developed with [embedXcode+](http://embedXcode.weebly.com)
///
/// @author		Rei Vilo
/// @author		http://embeddedcomputing.weebly.com
/// @date		23/07/2015 13:58
/// @version	101
///
/// @copyright	(c) Rei Vilo, 2015
/// @copyright	CC = BY SA NC
///
/// @see		ReadMe.txt for references
///


///
/// @file		blynkWeather.ino
/// @brief		Main sketch
///
/// @details	Example sketch
/// @n @a		Developed with [embedXcode+](http://embedXcode.weebly.com)
///
/// @author		Rei Vilo
/// @author		http://embeddedcomputing.weebly.com
/// @date		23/07/2015 13:58
/// @version	101
///
/// @copyright	(c) Rei Vilo, 2015
/// @copyright	CC = BY SA NC
///
/// @see		ReadMe.txt for references
/// @n
///


// Core library for code-sense - IDE-based
#if defined(ENERGIA) // LaunchPad specific
#include "Energia.h"
#else // error
#error Platform not defined
#endif // end IDE

// Include application, user and local libraries
#include "Wire.h"
#include "Sensor_BMP180.h"
#include "Sensor_DHT.h"
#include "Sensor_PIR.h"

#ifndef __CC3200R1M1RGC__ // Do not include SPI for CC3200 LaunchPad
#include <SPI.h>
#endif
#include "WiFi.h"
#include <WiFiClient.h>
#include <BlynkSimpleCC3200.h>
#include "SimpleTimer.h"


// Prototypes


// Define variables and constants
Sensor_BMP180 myBMP180;
Sensor_DHT myDHT(24, DHT22);
Sensor_PIR myPIR(27);


#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space


// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "AuthToken";
SimpleTimer Timer;
const uint8_t myRelay = 23;

bool alarm = false;

void sendUptime()
{
    myPIR.get();
    alarm |= myPIR.status();
    BLYNK_LOG("myPIR    %8i %8i", myPIR.status(), alarm);
    digitalWrite(RED_LED, alarm);

    // You can send any value at any time.
    // Please don't send more that 10 values per second.
    Blynk.virtualWrite(4, alarm);
}

// Add setup code
void setup()
{
    Serial.begin(9600);

    Wire.begin(); // required by BMP180
    myBMP180.begin(3);
    myDHT.begin();
    myPIR.begin();
    
    pinMode(RED_LED, OUTPUT);
    digitalWrite(RED_LED, HIGH);
    delay(1000);
    digitalWrite(RED_LED, LOW);

    Blynk.begin(auth, "SSID", "password", 0); // WLAN_SEC_WPA2

    // Setup a function to be called every second
    Timer.setInterval(1000L, sendUptime);
}

// Add loop code
void loop()
{
    Blynk.run();
    Timer.run();
}

// This function tells Arduino what to do if there is a Widget
// which is requesting data for Virtual Pin (0)
BLYNK_READ(0)
{
    myBMP180.get();
    float t1 = myBMP180.temperature();
    float p  = myBMP180.pressure();
    // This command writes t1 to Virtual Pin (0)
    Blynk.virtualWrite(0, t1);
    // This command writes p to Virtual Pin (0)
    Blynk.virtualWrite(1, p);
    BLYNK_LOG("myBMP180 %8.1f %8.1f", t1, p);
}

// This function tells Arduino what to do if there is a Widget
// which is requesting data for Virtual Pin (2)
BLYNK_READ(2)
{
    myDHT.get();
    float t2 = myDHT.temperature();
    float rh = myDHT.humidity();
    // This command writes t2 to Virtual Pin (2)
    Blynk.virtualWrite(2, t2);
    // This command writes rh to Virtual Pin (3)
    Blynk.virtualWrite(3, rh);
    BLYNK_LOG("myDHT    %8.1f %8.1f", t2, rh);
}

// This function will be called every time
// when App writes value to Virtual Pin 5
BLYNK_WRITE(5)
{
    BLYNK_LOG("Reset alarm %s", param.asStr());
    // You can also use: asInt() and asDouble()
    if (param.asInt() > 0) alarm = false; // reset
}

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

Amazon Echo – Read Temperature and Humidity from Sensor
Intermediate
  • 293
  • 12

Full instructions

I am going to show how to use Amazon Echo to read temperature and humidity from sensor.

Smart Garden
Intermediate
  • 1,839
  • 17

Smart Garden is a plant environmental monitoring system.

FPGA Plant Model powerSUITE Buck/Boost Real Time
Intermediate
  • 51
  • 2

Protip

Allows quick evaluation of Power Supply Plant parameters for TI Buck_VMC_F2837xS project.

Pulsecounting and Deepsleep Based IoT Water Meter
Intermediate
  • 100
  • 2

This project creates a way to monitor water usage, to reduce water costs.

Blynk App with Linkit7688 Duo and Webcam
Intermediate
  • 309
  • 3

Full instructions

How to make a functional application with Blynk and the Linkit Smart 7688 Duo board, with utility for home automation.

Mounted Infrared LED Laser Tag System
Intermediate
  • 17
  • 1

A laser tag system that uses flex sensors to control an infrared LED transmitter.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Feedback