Things used in this project

Hardware components:
Cc3200 launchxl cc3200 launchxl no bg resize
TI LaunchPad CC3200-LAUNCHXL SimpleLink Wi-Fi LaunchPad
×1
110020004 20100
SeeedStudio Grove Starter Kit for LaunchPad
×1
Software apps and online services:
Energiabadgelogo2
TI LaunchPad Energia
Blynk logo avatars
Blynk
embedXcode

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

WIFI CONTROLLED ZUMO ROBOT
Intermediate
  • 24
  • 1

Protip

Design a robot that uses on-board IMU (Inertial Measurement Unit) sensors for autonomous motion control using Wi-Fi.

CC13xx + CC3100 WiFi IoT gateway
Intermediate
  • 11
  • 0

Protip

Learn how to use a 915MHz to Wi-Fi gateway in Energia

Upload code to TI TM4C123 using Linux, CMake and lm4tools
Intermediate
  • 120
  • 2

Protip

This is a step by step guide on how to get CMake and lm4tools setup in a Linux environment to upload code directly to your TM4C123 via usb.

Got Your Back
Intermediate
  • 2,113
  • 51

Full instructions

This ergonomic-sensitive chair add-on will help you chair-ish your health!

Got Your Back

#creaTIviteam

TiWo
Intermediate
  • 1,445
  • 35

Full instructions

TiWo, keepin' it cool

TiWo

Team ElectroVolts

Mounted Infrared LED Laser Tag System
Intermediate
  • 67
  • 3

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

Add projectSign up / Login