Add to code below so specifications are met:
Frequency of Data: Readings must be taken once every 30 minutes, and the readings must be incrementally stored in a JSON file. To clarify, each reading must be added to a single JSON file so that a flat file of readings is stored over time.
Output Visual Using LEDs:
*Green LED lights up when the last conditions are: temperature > 60 and < 85, and humidity is < 80%
*Blue LED lights upwhen the last conditions are: temperature > 85 and < 95, and humidity is < 80%
*Red LED lights up when the last conditions are: temperature > 95
*Green and Blue LED light up when the last conditions are: humidity >80%
Code
from grovepi import *
from grove_rgb_lcd import *
import math
import json
dht_sensor_port = 7 # connect the DHt sensor to port 7
dht_sensor_type = 0 # use 0 for the blue-colored sensor and 1 for the white-colored sensor
# set green as backlight color
# we need to do it just once
# setting the backlight color once reduces the amount of data transfer over the I2C line
setRGB(0,255,0)
# temp_humidity_sensor_type
# Grove Base Kit comes with the blue sensor.
blue = 0 # The Blue colored sensor.
white = 1 # The White colored sensor.
while True:
try:
# This example uses the blue colored sensor.
# The first parameter is the port, the second parameter is the type of sensor.
[temp,humidity] = grovepi.dht(sensor,blue)
if math.isnan(temp) == False and math.isnan(humidity) == False:
print(“temp = %.356f F humidity =%.356f%%”%(temp, humidity))
except IOError:
print (“Error”)
tempHumid={ #Making json array here
‘Temp’ :tempF
‘Humidity’: humidity
}
with open(‘temperature_humidity.json’, ‘w’) as json_tempHumid_file: #writing to json file
json.dump(tempHumid, json_tempHumid_file)
Specifically, the following critical elements must be addressed. Most of the critical elements align with a particular course outcome (shown in brackets).
I. Weather Station: In this part of your project, you will be assessed on how well you enhanced the weather station prototype.
A. Embedded Systems Code (State Architecture, Functions, Imports, and Variables)
i. Interrupts are functional and aligned with product specifications. [CS-350-01]
ii. Frequency of data gathering has been implemented, is functional, and is aligned with product specifications. [CS-350-01]
iii. Embedded systems code runs without errors, is logically organized, and is properly commented. [CS-350-01]
B. Dashboard Controls, Functionality, and Reporting Feature: In this part of your project, your instructor will examine your code to determine
how well you set up and enhanced the weather station prototype so that people can easily see the information that is being gathered by the
sensors.
i. Writes code that displays data to the dashboard. [CS-350-02]
ii. Includes screenshot or picture of the weather station data displaying on the dashboard. [CS-350-02]
iii. Dashboard code runs without errors, is logically organized, and is properly commented. [CS-350-02]


0 comments