This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require('http'); | |
const express = require('express'); | |
const { ApolloServer } = require('apollo-server-express'); | |
// GraphQL Schema and Resolvers | |
const { typeDefs } = require('./graphql/schema'); | |
const { resolvers } = require('./graphql/resolvers'); | |
const server = new ApolloServer({ typeDefs, resolvers }); | |
const app = express(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { MQTTPubSub } = require('graphql-mqtt-subscriptions'); | |
const { connect } = require('mqtt'); | |
const client = connect('mqtt://mqtt.eclipse.org', { | |
reconnectPeriod: 1000 | |
}); | |
const pubsub = new MQTTPubSub({ | |
client | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { gql } = require('apollo-server-express'); | |
const typeDefs = gql` | |
type SensorData { | |
temp: Float! | |
humid: Float! | |
time: String! | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<Wire.h> | |
#include<PubSubClient.h> | |
#include<WiFi.h> | |
#include<Adafruit_BME280.h> | |
#include <ArduinoJson.h> | |
/* | |
* WLAN Configuration | |
*/ | |
const char* ssid = "YOUR_SSID"; // FILL THIS ACCORDINGLY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def upload_data(batch_data): | |
if connected_to_cloud(): | |
try: | |
if CLOUD_DB.write_points(batch_data, time_precision='ms'): | |
logger.info('Write Successful to Cloud') | |
logger.info('Updating local database with status=1 field') | |
# for each point add `status=1` field | |
for point in batch_data: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_points(conf): | |
# We use the configuration in the TOML file | |
# to get the data points using `influxdb-python` | |
# Refer to Repository for complete code | |
# create the query string | |
dict_str = ''.join('"{}"=\'{}\''.format(key,value) for key, value in conf['tags'].items()) | |
QUERY = 'SELECT "{}" FROM "{}" WHERE "status"=0 AND {} LIMIT {}'.format( | |
'","'.join(conf['fields']), | |
conf['measurement'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[local] | |
# Local Instance of InfluxDB | |
host = 'localhost' | |
port = 8086 | |
database = 'CISS' | |
[cloud] | |
# Cloud Instance of InfluxDB | |
# NOTE: doesn't have to InfluxDB it could be | |
# any technology stack that you wish to upload |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ciss: | |
"""CISS Class""" | |
# parsing methods | |
# other necessary codes | |
def parse_payload(self, accepted_data): | |
data_type = {'measurement': 'ciss', | |
'fields': | |
{ | |
'accX': 0.0, | |
'accY': 0.0, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"categories": [ | |
{ | |
"name": "Goals", | |
"labels": [ | |
{ | |
"id": 1, | |
"name": "I want to track other’s products.", | |
"checked": false | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"text": "Platform information quality", | |
"checked": false, | |
"value": { | |
"description": null | |
}, | |
"children": [{ | |
"text": "Collection quality", | |
"checked": false, | |
"value": { |