Adafruit PyPortal Smart Thermometer User Manual

PyPortal Smart Thermometer with Analog Devices ADT7410, Adafruit
IO and CircuitPython
Created by Brent Rubell
Last updated on 2021-03-17 01:18:03 PM EDT
2 3
6 6 6
8
8 9
10
14 14 14 18
22 26
30 30
Guide Contents
Guide Contents Overview
CircuitPython Code Prerequisite Guides Parts
Install CircuitPython
Set up CircuitPython Quick Start! PyPortal Default Files
Adafruit IO Setup
Feed Setup Adafruit IO Trigger Setup Build an Adafruit IO Dashboard Obtain Adafruit IO Key
Internet Connect! What's a secrets file? Connect to WiFi Requests
HTTP GET with Requests HTTP POST with Requests Advanced Requests Usage
WiFi Manager Code PyPortal with CircuitPython
Secrets File Setup Add Libraries Add CircuitPython Code and Project Assets Code Usage Why is the backlight off by default? Adafruit IO Usage PyPortal Customization
Displaying temperature in Fahrenheit Changing fonts
Custom Wall Mount
© Adafruit Industries
https://learn.adafruit.com/pyportal-smart-thermometer-with-analog-devices-adt7410-
adafruit-io-and-circuitpython
Page 2 of 32
Overview
Connected your PyPortal to the internet and want to do more with data?
You'll be using the Analog Devices ADT7410 (https://adafru.it/EgN) built-into your PyPortal as a thermometer to measure the ambient temperature over I2C.
But what makes this thermometer particularly
smart?
You'll be sending temperature data to the internet - using
the best data service in the world
- Adafruit
IO (https://adafru.it/fH9) - for real-time data visualization and long-term data logging.
Want to give your PyPortal Thermometer
more intelligence
? set up a Trigger on Adafruit IO to email you if
the PyPortal Thermometer dips below (or goes above!) a certain temperature threshold value.
© Adafruit Industries
https://learn.adafruit.com/pyportal-smart-thermometer-with-analog-devices-adt7410-
adafruit-io-and-circuitpython
Page 3 of 32
We'll be using the Analog
Devices
ADT7410 (https://adafru.it/EaC)
built into the PyPortal to
measure the ambient
temperature over I2C
You'll also be using the
ambient light sensor, which
points through the front of the
PyPortal, to turn on the
PyPortal's display.
Wave at the PyPortal
to display the temperature
along with the current date
and time.
The date and time are
obtained from Adafruit IO and
are based on your PyPortal's IP
address - you don't need to
add
an RTC (https://adafru.it/sd6) or
fiddle with time zones!
© Adafruit Industries
https://learn.adafruit.com/pyportal-smart-thermometer-with-analog-devices-adt7410-
adafruit-io-and-circuitpython
Page 4 of 32
CircuitPython Code
CircuitPython is great for
building Internet-of-Things
projects. Using the Adafruit IO
CircuitPython
module (https://adafru.it/Ean),
you can easily send data to
Adafruit IO, receive data from
Adafruit IO, and easily
manipulate data with the
powerful Adafruit IO API.
You can rapidly update your
code without having to
compile and store WiFi and
API secret keys on the device.
This means that there's no
editing code and re-uploading
whenever you move the
PyPortal to another network -
just update a file and you're
set.
Prerequisite Guides
If you're new to Adafruit IO or CircuitPython, take a moment to walk through the following guides to get you started and up-to-speed:
Welcome to Adafruit IO (https://adafru.it/DZd) Welcome to CircuitPython (https://adafru.it/cpy-welcome)
Parts
You only need a PyPortal for this guide - you'll be using the temperature and light sensors included with the PyPortal. No other sensors or external circuitry required!
© Adafruit Industries
https://learn.adafruit.com/pyportal-smart-thermometer-with-analog-devices-adt7410-
adafruit-io-and-circuitpython
Page 5 of 32
Adafruit PyPortal - CircuitPython Powered Internet Display
PyPortal, our easy-to-use IoT device that allows you to create all the things for the “Internet of Things” in minutes. Make custom touch screen interface... Out of Stock
1 x USB Cable USB cable - USB A to Micro-B - 3 ft
Out of
Stock
Add to Cart
© Adafruit Industries
https://learn.adafruit.com/pyportal-smart-thermometer-with-analog-devices-adt7410-
adafruit-io-and-circuitpython
Page 6 of 32
Install CircuitPython
CircuitPython (https://adafru.it/tB7) is a derivative of MicroPython (https://adafru.it/BeZ) designed to simplify
experimentation and education on low-cost microcontrollers. It makes it easier than ever to get prototyping by requiring no upfront desktop software downloads. Simply copy and edit files on the CIRCUITPY "flash" drive to iterate.
The following instructions will show you how to install CircuitPython. If you've already installed CircuitPython but are looking to update it or reinstall it, the same steps work for that as well!
Set up CircuitPython Quick Start!
Follow this quick step-by-step for super-fast Python power :)
https://adafru.it/Egk
https://adafru.it/HFd
Click the link above to download the latest version of
CircuitPython for the PyPortal.
Download and save it to your desktop (or wherever is handy).
Plug your PyPortal into your computer using a known-good USB
cable.
A lot of people end up using charge-only USB cables and it is
very frustrating! So make sure you have a USB cable you know
is good for data sync.
Double-click the Reset button on the top in the middle (magenta
arrow) on your board, and you will see the NeoPixel RGB LED
(green arrow) turn green. If it turns red, check the USB cable, try
another USB port, etc. Note: The little red LED next to the USB
connector will pulse red. That's ok!
If double-clicking doesn't work the first time, try again.
Sometimes it can take a few tries to get the rhythm right!
https://adafru.it/Egk
https://adafru.it/HFd
© Adafruit Industries
https://learn.adafruit.com/pyportal-smart-thermometer-with-analog-devices-adt7410-
adafruit-io-and-circuitpython
Page 7 of 32
You will see a new disk drive appear called PORTALBOOT.
Drag the adafruit-circuitpython-pyportal-<whatever>.uf2 file to
PORTALBOOT.
The LED will flash. Then, the PORTALBOOT drive will disappear
and a new disk drive called CIRCUITPY will appear.
If you haven't added any code to your board, the only file that
will be present is boot_out.txt. This is absolutely normal! It's time
for you to add your code.py and get started!
That's it, you're done! :)
PyPortal Default Files
Click below to download a zip of the files that shipped on the PyPortal or PyPortal Pynt.
https://adafru.it/Env
https://adafru.it/HFf
https://adafru.it/Env
https://adafru.it/HFf
© Adafruit Industries
https://learn.adafruit.com/pyportal-smart-thermometer-with-analog-devices-adt7410-
adafruit-io-and-circuitpython
Page 8 of 32
Adafruit IO Setup
Feed Setup
If you do not already have an Adafruit IO account set up, head over to io.adafruit.com (https://adafru.it/fH9) to link your Adafruit.com account to Adafruit IO.
The first step is to create a new Adafruit IO feed to hold the data from the PyPortal's temperature sensor. Navigate to the feeds page (https://adafru.it/mxC) on Adafruit IO. Then click Actions -> Create New Feed , and name this feed temperature.
If you do not already know how to create a feed, head over to Adafruit IO Basics:
Feeds (https://adafru.it/ioA).
Adafruit IO Trigger Setup
This optional step requires an active Adafruit IO Plus (IO+) account.
While you can remotely monitor your PyPortal thermometer using an Adafruit IO Dashboard, if you want to be alerted of a specific high temperature reading when you're away from your keyboard. You can set up Adafruit IO Triggers to monitor a feed for predefined conditions.
© Adafruit Industries
https://learn.adafruit.com/pyportal-smart-thermometer-with-analog-devices-adt7410-
adafruit-io-and-circuitpython
Page 9 of 32
Adafruit IO Email Triggers are a feature of Adafruit IO Plus, and
require an active Adafruit IO Plus subscription.
To check if you have an Adafruit IO Plus subscription: Navigate
to your Adafruit IO Profile page (https://adafru.it/BmD) and check
your
Current Plan
.
Interested in upgrading to IO Plus? Learn more about
the upgraded, all systems go version of the Adafruit IO
service here... (https://adafru.it/Eg3)
Navigate to the Adafruit IO trigger page (https://adafru.it/Em3). From the Actions dropdown, click Create a New Trigger.
To set up the trigger, you'll need to define a condition and an action to perform when the condition occurs.
Set the feed to
temperature
Define the trigger to fire only when the feed value is
greater
than 85
.
Set the trigger action to
email me
Next, you'll set up a
second
trigger to email you if the temperature feed dips below freezing (in degrees
Fahrenheit).
Set the feed to
temperature
Define the trigger to fire only when the feed value is
less than or
equal to 32
.
Set the trigger action to
email me
Note that 85 is a
value
on the feed and does not include the unit - it can be 85 degrees Celsius, Fahrenheit
or even Kelvin. The code in this project supports converting the raw value before sending it to Adafruit IO.
© Adafruit Industries
https://learn.adafruit.com/pyportal-smart-thermometer-with-analog-devices-adt7410-
adafruit-io-and-circuitpython
Page 10 of 32
Loading...
+ 22 hidden pages