Blues Wireless & Qubitro-Based IoT Weather Data Logger

Tools

Blues Wireless Notecard (Cellular)
Blues Wireless Notecarrier-A
Arduino Nano 33 BLE Sense
Seeed Studio Grove – Light Sensor
Seeed Studio Grove – Air quality sensor v1.3
DHT11 Temperature & Humidity Sensor (3 pins)

ONLINE SERVICES AND APPLICATIONS

  • Blues Wireless Notehub.io
  • Qubitro
  • Arduino IDE

A PROJECT SUMMARY

Monitoring environmental conditions is more crucial than ever as global temperatures increase.

There are several techniques to track environmental data. To do this operation, you can use corded devices, controllers with SD cards for manually recording and transmitting back data, or Wi-Fi or BLE communication-based controllers.

How will you manage to keep track of your weather information if you don’t have the time to manually collect data from an SD card or if your devices aren’t within Wi-Fi or Bluetooth connection range?

Hardware:

LTE-M Notecard Global
Notecarrier A with LiPo, Solar, and Qwiic Connectors
Arduino Nano 33 BLE Sense
DHT11 Temperature Sensor
Rain Sensor
Seeed Air Quality Sensor
Seeed Light Sensor

Software:

Arduino IDE
Blues Notehub
Qubitro

Outline of the structure:

Hardware setup is step one.

We will utilise a DHT11, a rain sensor, an air quality sensor, and a light sensor to gather environmental data in the first stage. All of the sensors are linked to an Arduino Nano 33 BLE Sense, which will serve as a controller for processing the data.

Notehub setup in step two

Using a Blues Notecard and Blues Notecarrier, sensor data will be sent to the Blues Notehub cloud.

Qubitro setup in step three.

We’ll utilise Qubitro to display and interpret our sensor data as soon as it enters the cloud.

Setup of Hardware:

Except for the DHT11, all sensors are analogue. Connect A0 to A2 of the Arduino Nano 33 analogue pins directly and DHT11 to D13 of the Arduino Nano 33 BLE Sense.

Let’s go to the programming portion now that all of your sensors are linked. Open the Arduino IDE and build the following code to accomplish this. The serial monitor will receive all sensor data that has been collected by the device.

#include "Air_Quality_Sensor.h"
#include <DHT.h>

String Stage;

AirQualitySensor sensor(A1);       //Analog pin A1 for Air Quality sensor
#define DHTPIN 13                  //Digital pin 13 for DHT11 sensor
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

void setup(void) {

  dht.begin();                        // Init DHT11
  Serial.println("Waiting sensor to init...");
  delay(10000);

}
void loop(void) {

  int quality = sensor.slope();

  Serial.print("AQ Sensor value    : ");
  Serial.println(sensor.getValue());
  Serial.print("Pollution Level    : ");

  if (quality == AirQualitySensor::FORCE_SIGNAL) {
    String Stage = "ERROR!";
    Serial.println(Stage);
  }
  else if (quality == AirQualitySensor::HIGH_POLLUTION) {
    String Stage = "High pollution!";
    Serial.println(Stage);
  }
  else if (quality == AirQualitySensor::LOW_POLLUTION) {
    String Stage = "Low pollution!";
    Serial.println(Stage);
  }
  else if (quality == AirQualitySensor::FRESH_AIR) {
    String Stage = "Fresh air!";
    Serial.println(Stage);
  }

  float h = dht.readHumidity();
  Serial.print("Humidity Level     : ");
  Serial.print(h);
  Serial.println(" %");

  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  Serial.print("Temperature Level  : ");
  Serial.print(t);
  Serial.println(" C");

  int value = analogRead(A2);       //Analog pin A2 for Light sensor
  float valuel = map(value, 0, 800, 0, 100);
  Serial.print("Light Sensor Level : ");
  Serial.print(valuel);
  Serial.println(" %");

  int rainSensor = analogRead(A3);  //Analog pin A3 for Rain sensor
  float rainSensor1 = map(rainSensor, 0, 1024, 0, 100);
  Serial.print("Rain Sensor Level  : ");
  Serial.println(rainSensor);
  Serial.print("Dry level          : ");
  Serial.print(rainSensor1);
  Serial.println(" %");
  Serial.println("------------------------------------------------");
  delay(10000);

}

Setting up your Blues Notecarrier is the next stage. I’ll demonstrate how to accomplish this as I’m using an external sim card. Attach the Notecard to the Notecarrier. Utilize a micro USB connection to link the Notecarrier to your computer.

We’ll now put the Blues Notecarrier to the test. I’m sending some fictitious data to Notehub using Python.

import json
import notecard
import serial
import time

productUID = "com.gmail.pradeeplogu26:env_data_logger" #Change this with yours

# Select Serial
use_uart = True
card = None
# Configure the serial connection to the Notecard
serial = serial.Serial('COM7', 9600)                  #Change this with your COM port

card = notecard.OpenSerial(serial, debug=True)
req = {"req": "hub.set"}
req["product"] = productUID
req["mode"] = "continuous"
card.Transaction(req)

while True:
    temp = 10
    humidity = 20
    print('Temperature: {} degrees C'.format(temp))
    print('Humidity: {}%'.format(humidity))
    req = {"req": "note.add"}
    req["file"] = "sensors.qo"
    req["start"] = True
    req["body"] = {"temp": temp, "humidity": humidity}
    card.Transaction(req)
    time.sleep(15)

Simply change the project UID and Com port to your own names, then press Run. The terminal displays the fake data.

The response listed above will be returned by this script. Open the Notehub dashboard after that, then select the “Events” option to view the information.

When you’re through with this step, use the UART port on the Arduino Nano 33 BLE Sense to connect the Blues Notecard and Notecarrier. You can view the data that the Python script sends in Notehub.

Simply compile the following Arduino code in the Arduino IDE when the connections are complete to transmit the sensor data to Notehub.

#include <Notecard.h>
#include "Air_Quality_Sensor.h"
#include <DHT.h>

AirQualitySensor sensor(A1);         //Analog pin A1 for Air Quality sensor
#define DHTPIN 13                    //Digital pin 13 for DHT11 sensor

#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

#define txRxPinsSerial Serial1
#define productUID "xxxxxxxxxxxxxxxxxxxx"
Notecard notecard;

String Stage;

void setup(void) {

  notecard.begin(txRxPinsSerial, 9600);

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

  delay(1000);

  dht.begin(); // Init DHT11
  Serial.println("Waiting sensor to init...");
  delay(10000);

}

void loop(void) {

  int quality = sensor.slope();
  Serial.print("AQ Sensor value    : ");
  Serial.println(sensor.getValue());

  Serial.print("Pollution Level    : ");
  if (quality == AirQualitySensor::FORCE_SIGNAL) {
    String Stage = "ERROR!";
    Serial.println(Stage);
  }
  else if (quality == AirQualitySensor::HIGH_POLLUTION) {
    String Stage = "High pollution!";
    Serial.println(Stage);
  }
  else if (quality == AirQualitySensor::LOW_POLLUTION) {
    String Stage = "Low pollution!";
    Serial.println(Stage);
  }
  else if (quality == AirQualitySensor::FRESH_AIR) {
    String Stage = "Fresh air!";
    Serial.println(Stage);
  }

  float h = dht.readHumidity();
  Serial.print("Humidity Level     : ");
  Serial.print(h);
  Serial.println(" %");

  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  Serial.print("Temperature Level  : ");
  Serial.print(t);
  Serial.println(" C");

  int value = analogRead(A2);
  float valuel = map(value, 0, 800, 0, 100);
  Serial.print("Light Sensor Level : ");
  Serial.print(valuel);
  Serial.println(" %");

  int rainSensor = analogRead(A3);
  float rainSensor1 = map(rainSensor, 0, 1024, 0, 100);
  Serial.print("Rain Sensor Level  : ");

  Serial.println(rainSensor);
  Serial.print("Dry level          : ");
  Serial.print(rainSensor1);
  Serial.println(" %");

  J *req = notecard.newRequest("note.add");
  if (req != NULL) {
    JAddStringToObject(req, "file", "sensors.qo");
    JAddBoolToObject(req, "sync", true);

    J *body = JCreateObject();
    if (body != NULL) {
      JAddNumberToObject(body, "temperature", t);
      JAddNumberToObject(body, "humidity", h);
      JAddNumberToObject(body, "air quality value", sensor.getValue());
      JAddNumberToObject(body, "light intencity", valuel);
      JAddNumberToObject(body, "rain sensor", rainSensor);
      JAddNumberToObject(body, "dry level", rainSensor1);
      JAddItemToObject(req, "body", body);
    }
    notecard.sendRequest(req);
  }
  Serial.println("------------------------------------------------");
  delay(10000);

}

Simply launch the serial monitor and examine the data produced. Next, navigate to the Notehub dashboard’s “Events” tab.

You may view the sensor data there.

You are finished with the hardware portion at this time. By clicking on the JSON data, you may examine all of the information that was transmitted by our Blues gear.

Setup of Notehub:

We uploaded our data to Notehub, so now we must display it graphically using graphs and tables. Let’s see how to accomplish this using Qubitro cloud.

Create a new route first by opening Notehub and selecting the “Routes” option.

Then choose HTTP/HTTPS as the integration type.

The information concerning our “Qubitro Route” must now be entered.

Setup for Qubitro:

We’re going to set up the project in Qubitro in this stage. Launch the https://portal.qubitro.com/ website, log in using your credentials, and then start a new project. No further hardware is required.
Go to the project settings next and then copy the “Project ID.”

Copy the “Webhook sign-in key” after going to the credentials tab in the Qubitro portal. Take them and re-enter them in the route header of the Blues Notehub.

When everything is set up, click “Create new route” to add the new route to your Notehub.
Your Blues gadget is now visible on the Qubitro site.

To view the incoming data, simply open the device. The data is automatically extracted from Blues by Qubitro. You may examine the hardware’s current position, voltage, and orientation in the overview page.

Open the Data tab next so you can see the data from your sensors.

We’re going to perform some visualisation right now, so click the Monitoring tab and add some widgets to get started.

Similarly, give all the data widgets. I’ve included my model dashboard.

Finally, graphs and charts allowed us to see the sensor data.

We are now in the most crucial stage of developing our IoT-based Weather Data Logger. How about user-to-user data sharing in a web or mobile application? With Qubitro, APIs may communicate cloud data across several platforms and languages.

Open the Credentials tab in the Qubitro portal and copy the API key to test it out.

Then visit https://qubitro-api.readme.io/reference/getdevice, where you will be prompted to enter some information.

Enter the Device ID and Project you used while setting up the Qubitro Project, along with the API key in the “Bearer-API Key” format, and then click the “Try It” button. Your Blues hardware allows you to view all of your data.

Create a straightforward Python script to retrieve the API response. Change the keys in the Python script below, then execute it.

import requests
import time
from colorama import Fore, Back, Style

while (True):
    url = "https://api.qubitro.com/v1/projects/e675f223-ff1e-4bab-85e1-37de1e944f6d/devices/dev%3A867730051771776-e675f223-ff1e-4bab-85e1-37de1e944f6d"
    headers = {
    "Accept": "application/json",
    "Authorization": "Bearer-xxxxxxxxxxxxxxxxxxxxxxxx"
    }
    response = requests.get(url, headers=headers)
    print(response.text)
    time.sleep(10)

The data from the device will be returned.

Schematics

There is difference between trained and educated people

KP

“Down-to-earth person will never get offended” – KP

World is a better place, Just make it right

KP

Helping Hands.

About the author

pondabrothers

You can download our apps and books for free..
Search - Incognito Inventions

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *