Skip to content

Instantly share code, notes, and snippets.

@deviceplususer
Created February 5, 2020 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deviceplususer/d53e626d26ae0d976bd05557e96d2277 to your computer and use it in GitHub Desktop.
Save deviceplususer/d53e626d26ae0d976bd05557e96d2277 to your computer and use it in GitHub Desktop.
#coding: utf-8
from smbus2 import SMBus
import time
import RPi.GPIO as GPIO
interrupted = False
GPIO.setwarnings(False)
import time
import board
import neopixel
pixel_pin = board.D18
num_pixels = 16
ORDER = neopixel.GRB
pixels = neopixel.NeoPixel(pixel_pin, num_pixels, brightness=0.2, auto_write=False,
pixel_order=ORDER)
bus_number = 1
i2c_address = 0x76
setup()
get_calib_param()
if __name__ == '__main__':
try:
temp, press, hum = readData()
except KeyboardInterrupt:
pass
if temp:
msg = "今の室温は、" + str(round(temp,1)) + "度、湿度は、" + str(round(hum,1)) + "パーセントです!"
if temp > 25:
msg += "暑くないですか?"
pixels.fill((255, 0, 0))
elif temp < 15:
msg += "寒いですね!"
pixels.fill((0, 0, 255))
elif hum > 70:
msg += "蒸し蒸ししますね"
pixels.fill((255, 0, 0))
else:
msg += "快適です!"
pixels.fill((0, 255, 0))
pixels.show()
print (msg)
time.sleep(3)
pixels.fill((0, 0, 0))
pixels.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment