[{"element_type":"user_image","content":"https://cdn-learn.adafruit.com/user_assets/assets/000/000/717/original/time-and-temperature.png?1708883695","metadata":{"caption":""}},{"element_type":"text","content":"\n  \n        \u003cp\u003eLet's add temperature to the multifunction device using the ADT7410 on the Temperature and Motion Wing.\u003c/p\u003e\n\u003cp\u003eSee \u003ca title=\"Multifunction Device Part 1\" href=\"https://adafruit-playground.com/u/dexter_starboard/pages/desktop-multifunction-device-hardware\"\u003eMultifunction Device Part 1\u003c/a\u003e for a parts list and assembly instructions.\u003c/p\u003e\n      \n","metadata":{}},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n  \n  \n        \u003ch3\u003eReading the Sensor\u003c/h3\u003e\n\u003cp\u003eFirst we need to set up the sensor:\u003c/p\u003e\n      \n\n\n\n\n\n\n\n\n","metadata":{}},{"element_type":"code","content":"#Import the `adafruit_adt7410` library\n#get the I2C device\n#instantiate the sensor:\n\nimport board\nimport adafruit_adt7410\ni2c = board.I2C()\ntherm = adafruit_adt7410.ADT7410(i2c)\n\n#functions to read the sensor:\ndef get_temp_C():\n    \"Temperature Celsius\"\n    T = therm.temperature\n    return f\"{T:0.1f} C\"\n\ndef get_temp_F():\n    \"Temperature Fahrenheit\"\n    T = therm.temperature * 1.8 + 32\n    return f\"{T:0.1f} F\"","metadata":{"language":"python","linenums":false}},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n  \n        \u003cp\u003eWe need a Label to display the sensor readings. We'll add it to our 'splash' screen. Then we'll write a function to update the label.\u003c/p\u003e\n      \n\n\n\n\n\n\n\n","metadata":{}},{"element_type":"code","content":"import displayio\nfrom adafruit_bitmap_font.bitmap_font import load_font\nfrom adafruit_display_text.label import Label\n\nMETRIC = True\ndisplay = board.DISPLAY\nsplash = displayio.Group()\narial = load_font(\"/fonts/Arial-18.pcf\")\ntemperature = Label(\n\tarial,\n    text = \"10.0 K\",\n    color = 0x3333FF,\n    x = display.width * 3 // 8,\n    y = display.height * 3 // 8)\n\ndisplay.root_group = splash\n\ndef loop():\n    if METRIC:\n        temperature.text = get_temp_C()\n    else:\n        temperataure.text = get_temp_F()\n\nif __name__==\"__main__\":\n    while True:\n        loop()\n        time.sleep(0.1)","metadata":{"language":"auto","linenums":false}},{"element_type":"text","content":"\n  \n  \n        \u003cp\u003eYou can find \u003cspan\u003ethe Arial-18 font here:\u0026nbsp;\u003c/span\u003e\u003ca href=\"https://github.com/adafruit/Adafruit_Learning_System_Guides/tree/main/MagTag/MagTag_Google_Calendar/fonts\"\u003eMagTag Google Calendar\u003c/a\u003e. Make a '/fonts' folder on your CIRCUITPY drive and save the font there.\u003c/p\u003e\n\u003cp\u003eA complete sketch is available on Github: \u003ca title=\"code.py\" href=\"https://gist.github.com/rsbohn/9002ab69ea63cea77ab71f4a8f9f805b\"\u003ecode.py\u003c/a\u003e\u003c/p\u003e\n      \n\n","metadata":{}}]