Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify your code in the following ways: a. Change the temperature units to Fahrenheit. b. Add functionality to the code that stores the output in

Modify your code in the following ways:

a. Change the temperature units to Fahrenheit.

b. Add functionality to the code that stores the output in a JSON database file.

Code:

#!/usr/bin/env python

import grovepi import math # Connect the Grove Temperature & Humidity Sensor Pro to digital port D4 # This example uses the blue colored sensor. # SIG,NC,VCC,GND sensor = 4 # The Sensor goes on digital port 4.

# 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 = %.02f C humidity =%.02f%%\"%(temp, humidity))

except IOError: print (\"Error\")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Android 4 Application Development

Authors: Reto Meier

3rd Edition

1118223853, 9781118223857

More Books

Students also viewed these Programming questions