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!

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

Give feedback

Comments

Similar projects you might like

Convo-Care: Alexa-Controlled E-Health App
Intermediate
  • 257
  • 8

Protip

Convo-Care provides a better e-health experience through a conversational UI.

Rocky Rover: Robotic Vision System PixyCam & Arduino 101
Intermediate
  • 4,522
  • 48

Full instructions

Using PixyCam and Intel Arduino 101 to drive this rover. Easy Robotic Vision system using PixyCam, rover reacts to the ball using Pan/Tilt.

Family, friend or foe - PIR arm/disarm using BLE
Intermediate
  • 98
  • 2

Full instructions

It's a BLE-enabled, cloud-connected smartphone app used to control & monitor who/when PIR is armed/disarmed. Uses Slack for notifications.

Smart and Safe Cabinets
Intermediate
  • 440
  • 8

Full instructions

With 41% of poisonings happening to children under 4, more needs to be done. We use Amazon Alexa and Intel IoT to lock and unlock cabinets.

Smart and Safe Cabinets

Magic Smoke Replacement Team

Mobile Life IoT
Intermediate
  • 135
  • 3

Work in progress

A mobile network connected security and monitoring system suited to today's RV-er concerned about protecting their investment.

Sigfox - Callback Configuration Example
Intermediate
  • 277
  • 5

Protip

Configure a callback in Sigfox backend and send data to Taurus Platform.

ProjectsCommunitiesContestsLiveJobsFree StoreBlogAdd projectSign up / Login
Respect project