Shreyas KishoreAditya SenguptaPranshu MalikTanmay BansalDanish Bansal
Published

Traffic and Emission Control System

Different emission-gauges share the details of their respective vehicles’ emissions, with the server, where the data is consolidated & used.

AdvancedShowcase (no instructions)3,436
Traffic and Emission Control System

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
MQ135 Gas Sensor
×1

Software apps and online services

ARTIK Cloud for IoT
Samsung ARTIK Cloud for IoT

Hand tools and fabrication machines

Laser cutter (generic)
Laser cutter (generic)

Story

Read more

Schematics

Laser cutting template

Schematic

Code

Sending MQ135 Data

Python
import artikcloud
from artikcloud.rest import ApiException
import sys, getopt
import time, random, json
from pprint import pprint
import Serial

def main(argv):

	DEFAULT_CONFIG_PATH = 'config.json'
  poll = Serial.readline()
	with open(DEFAULT_CONFIG_PATH, 'r') as config_file:
		config = json.load(config_file)['TECUnitConfig']
	print(config)
	
	artikcloud.configuration = artikcloud.Configuration();
	artikcloud.configuration.access_token = config['deviceToken']
	
	api_instance = artikcloud.MessagesApi()

	device_message = {}

	device_message['pollution'] = poll

	device_sdid = config['deviceId']

	ts = time.time()

	data = artikcloud.Message(device_message, device_sdid, ts)

	try:
	    pprint(artikcloud.configuration.auth_settings())

	    api_response = api_instance.send_message(data)
	    pprint(api_response)
	except ApiException as e:
	    print "Exception when calling MessagesApi->send_message: %s\n" % e


if __name__ == "__main__":
   main(sys.argv[1:])

Reading pollution data from ARTIK Cloud

Python
import artikcloud
from artikcloud.rest import ApiException
import sys, getopt
import time, random, json
from pprint import pprint

def main(argv):

	DEFAULT_CONFIG_PATH = 'config.json'

	with open(DEFAULT_CONFIG_PATH, 'r') as config_file:
		config = json.load(config_file)['TECUnitConfig']
	print(config)

	artikcloud.configuration = artikcloud.Configuration();
	artikcloud.configuration.access_token = config['deviceToken']

	api_instance = artikcloud.MessagesApi()

	sdids = config['pollution'] 
	try:
	    pprint(artikcloud.configuration.auth_settings())
	    api_response = api_instance.get_last_normalized_messages(sdids=sdids)
	    pprint(api_response)
	except ApiException as e:
	    print "Exception when calling MessagesApi->get_last_normalized_messages: %s\n" % e


if __name__ == "__main__":
   main(sys.argv[1:])
Contact GitHub API Training Shop Blog About
© 2016 GitHub, Inc. Terms Privacy Security Status Help

Credits

Shreyas Kishore

Shreyas Kishore

2 projects • 4 followers
Aditya Sengupta

Aditya Sengupta

1 project • 2 followers
Pranshu Malik

Pranshu Malik

1 project • 1 follower
Tanmay Bansal

Tanmay Bansal

1 project • 1 follower
Danish Bansal

Danish Bansal

1 project • 1 follower

Comments