Mark Angelo Nambatac
Published © CC BY

NXP Weather Data Monitoring with IFTTT Notifications

Creating a weather station with the integration of IFTTT in which you can control your smart home devices and many more!

IntermediateFull instructions provided10 hours1,799
NXP Weather Data Monitoring with IFTTT Notifications

Things used in this project

Hardware components

Rapid IoT Prototyping Kit
NXP Rapid IoT Prototyping Kit
×1
Raspberry Pi 3 Model B+
Raspberry Pi 3 Model B+
It should be noted that you can use other devices as long as it supports BLE (Bluetooth Low Energy). With that in mind, we chose the 3B+ model due to its built-in Bluetooth module, which is needed for connecting to the Rapid IOT Device
×1

Software apps and online services

NXP Rapid IOT Online Studio
Adafruit IO
Maker service
IFTTT Maker service
Download the Mobile app in your smartphone for easy configuration

Story

Read more

Code

NXP Rapid IOT Online IDE Project Structure

Plain text
This is the file that you will be importing to the NXP Rapid IOT Online IDE
No preview (download only).

NXP Rapid IOT Device Firmware

Plain text
Upload this firmware to your device using the instructions above
No preview (download only).

Python Code

Python
This is the code that you will run in your raspberry pi
import unicodedata
import time

import pygatt
import Adafruit_IO

adapter = pygatt.GATTToolBackend()

#NXP Mac Address which is located at the back of the device
BLE_ADDRESS = '00:60:37:0A:B1:4B'

#NXP Rapid IOT Characteristic UUIDS
SENSOR_UUIDS = {
    "temperature": "09c0c6b0-f14c-4e4f-b94a-d3aefbfd4668",
    "humidity" :"09c0c6b0-f14c-4e4f-b94a-d3aefbfd4669",
    "air_quality_tvoc":"09c0c6b0-f14c-4e4f-b94a-d3aefbfd466a",
    "air_quality_co2": "09c0c6b0-f14c-4e4f-b94a-d3aefbfd466b",
    "pressure": "09c0c6b0-f14c-4e4f-b94a-d3aefbfd466c",
    "ambient-light": "09c0c6b0-f14c-4e4f-b94a-d3aefbfd466d"  ,
    "battery-level": "09c0c6b0-f14c-4e4f-b94a-d3aefbfd4666",
    "charging-status": "09c0c6b0-f14c-4e4f-b94a-d3aefbfd4667"
}

#Adafruit IO Configuration
ADAFRUIT_IO_USERNAME = "***************************"
ADAFRUIT_IO_KEY = "********************************"

aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)

#Feeds in Adafruit IO
temp = aio.feeds('temperature')
humid = aio.feeds('humidity')
pressure = aio.feeds('pressure')
bat_status = aio.feeds('charging-status')
bat_level = aio.feeds('battery-level')
light = aio.feeds('ambient-light')
tvoc = aio.feeds('tvoc')
co2 = aio.feeds('co2')

sensor_values = {}
try: 
    adapter.start()
    device = adapter.connect(BLE_ADDRESS)
    while True:
        
        #Reading all the sensor values from the device
        for sensor, uuid in SENSOR_UUIDS.items():
            initial = device.char_read(uuid)
            #Converting ByteArray to String
            value = initial.decode('utf-8').rstrip('\x00')
            #Convert the string from value to float
            sensor_values[sensor] = float(value) 
        
        #Converting pressure value to get only the first 3 digits (kPa)
        pressure_converted = int(str(sensor_values['pressure'])[:3])

        #Sending all the values to the corresponding fields
        aio.send_data(temp.key, sensor_values['temperature'])
        aio.send_data(humid.key, sensor_values['humidity'])
        aio.send_data(pressure.key, pressure_converted)
        aio.send_data(bat_status.key, sensor_values['charging-status'])
        aio.send_data(bat_level.key, sensor_values['battery-level'])
        aio.send_data(light.key, sensor_values['ambient-light'])
        aio.send_data(tvoc.key, sensor_values['air_quality_tvoc'])
        aio.send_data(co2.key, sensor_values['air_quality_co2'])

        time.sleep(10)
    
finally:
    adapter.stop()

Credits

Mark Angelo Nambatac
4 projects • 9 followers
Aspiring Software Engineer | Loves Tinkering | Hates Soldering SMD Components

Comments