Guillermo Perez Guillen
Published © Apache-2.0

Weather Notifier With Blues

Two versions of personal weather station with Blues that send notificaciones disabled people on their waterproof smartwatch while swimming

AdvancedFull instructions provided12 hours103
Weather Notifier With Blues

Things used in this project

Hardware components

Blues Notecard (Cellular)
Blues Notecard (Cellular)
×1
Blues Notecarrier-A
Blues Notecarrier-A
×1
Blues Swan
Blues Swan
×1
Grove - Temperature&Humidity Sensor (DHT20)
×1
SparkFun Environmental Combo Breakout - CCS811/BME280 (Qwiic)
SparkFun Environmental Combo Breakout - CCS811/BME280 (Qwiic)
×1
Rechargeable Battery, 4.8 V
Rechargeable Battery, 4.8 V
×1

Software apps and online services

Visual Studio 2015
Microsoft Visual Studio 2015
PlatformIO IDE
PlatformIO IDE
Blues Notehub.io
Blues Notehub.io
ThingSpeak API
ThingSpeak API
MATLAB
MATLAB

Hand tools and fabrication machines

fitbit inspire 2 - smartwatch
Smartphone
Box, General Purpose
Box, General Purpose

Story

Read more

Schematics

Weather Notifier With Blues - Version 1

Schematic

Weather Notifier With Blues - Version 2

Schematic

Code

platformio.ini

Arduino
Code to be uploaded to the Blues Swan board
; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:bw_swan_r5]
platform = ststm32
board = bw_swan_r5
upload_protocol = dfu
framework = arduino
build_flags = -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
monitor_speed = 115200
lib_deps = 
	Wire
	blues/Blues Wireless Notecard@^1.4.5
	blues/Blues Wireless Notecard Pseudo Sensor@^1.1.0
	robtillaart/DHT20@^0.2.3

main.cpp

Arduino
Code to be uploaded to the Blues Swan board
#include <Arduino.h>
#include <Notecard.h>
#include <NotecardPseudoSensor.h>
#include "DHT20.h" //DHT20

DHT20 DHT; //DHT20

using namespace blues;

#define usbSerial Serial
#define productUID "com.blues.tvantoll.your_project" // paste here your UID project

Notecard notecard;
NotecardPseudoSensor sensor(notecard);

void setup() {
  // put your setup code here, to run once:
DHT.begin();    //DHT20  
delay(2500);
usbSerial.begin(115200);

notecard.begin();
notecard.setDebugOutputStream(usbSerial);

J *req = notecard.newRequest("hub.set");
JAddStringToObject(req, "product", productUID);
JAddStringToObject(req, "mode", "continuous");
notecard.sendRequest(req);
}

void loop() {
  // put your main code here, to run repeatedly: UPDATE
int status = DHT.read(); //DHT20
float temperature = DHT.getTemperature(); //DHT20
float humidity = DHT.getHumidity(); //DHT20

usbSerial.print("Temperature = ");
usbSerial.print(temperature);
usbSerial.println(" *C");
usbSerial.print("Humidity = ");
usbSerial.print(humidity);
usbSerial.println(" %");

switch (status)
    {
      case DHT20_OK:
        usbSerial.print("OK");
        break;
      case DHT20_ERROR_CHECKSUM:
        usbSerial.print("Checksum error");
        break;
      case DHT20_ERROR_CONNECT:
        usbSerial.print("Connect error");
        break;
      case DHT20_MISSING_BYTES:
        usbSerial.print("Missing bytes");
        break;
      case DHT20_ERROR_BYTES_ALL_ZERO:
        usbSerial.print("All bytes read zero");
        break;
      case DHT20_ERROR_READ_TIMEOUT:
        usbSerial.print("Read time out");
        break;
      case DHT20_ERROR_LASTREAD:
        usbSerial.print("Error read too fast");
        break;
      default:
        usbSerial.print("Unknown error");
        break;
    }
    usbSerial.print("\n");

  J *req = notecard.newRequest("note.add");
  if (req != NULL)
  {
    JAddStringToObject(req, "file", "sensors.qo");
    JAddBoolToObject(req, "sync", true);
    J *body = JAddObjectToObject(req, "body");
    if (body)
    {
      JAddNumberToObject(body, "temp", temperature);
      JAddNumberToObject(body, "humidity", humidity);
    }
    notecard.sendRequest(req);
  }

delay(15000);
}

Notecard Blues Weather Notification

MATLAB
Code of MATLAB Analysis
% Enter your MATLAB Code below

channelID = 2295928;
%alert_body = 'Successful email with ThingSpeak';
alert_subject = 'What is the weather like today?';
alert_api_key = 'TAKasSlj8EwIBptu8PQ'; % insert your Alert API Key here 
alert_url = "https://api.thingspeak.com/alerts/send";

% Read the recent data.
temperatureData = thingSpeakRead(channelID,'NumDays',1,'Fields',1);
humidityData = thingSpeakRead(channelID,'NumDays',1,'Fields',2);

% Check to make sure the data was read correctly from the channel.
if (temperatureData > 27) & (humidityData < 70);
    alertBody = "It's gonna be a sunny day!";    
elseif (temperatureData < 27 & (humidityData > 70));
    alertBody = "It's gonna be a rainy day!";  
else 
    alertBody = "It's gonna be a unstable weather day!";      
end

jsonmessage = sprintf(['{"subject": "%s", "body": "%s"}'], alert_subject, alertBody);
options = weboptions("HeaderFields", {'Thingspeak-Alerts-API-Key', alert_api_key; 'Content-Type','application/json'});
result = webwrite(alert_url, jsonmessage, options); 

JSONata Expression

JSON
Code to be uploaded to the Notehub project
{
    "api_key":"GMAC2OH1T6JW5UGJ",
    "field1": body.temp,
    "field2": body.humidity,
    "field3": tower_location & ', ' & tower_country,
    "field4": when
}

weather-notifier-with-blues-version1

Repository

weather-notifier-with-blues-version2

Repository

Credits

Guillermo Perez Guillen

Guillermo Perez Guillen

54 projects • 63 followers
Electronics and Communications Engineer (ECE): 12 prizes in Hackster / Hackaday Prize Finalist 2021-22-23 / 3 prizes in element14

Comments