Adafruit Mini IoT Home and Atmosphere IoT Studio

By Don Johanneck

Editor’s Note: This article is based on the Mini Smart Home tutorial from the Adafruit learning tutorial by Brent Rubell. Photos by Adafruit and Digi-Key staff.

Learn about scalable home automation projects using a miniature paper Mache house that demonstrates real-world scenarios. Wiring, user interaction, and firmware deployment are covered in detail and, when the steps outlined below are executed properly, results in a sensor monitoring and device control interface on a favorite Bluetooth capable mobile device. This project is expandable and can be repurposed for a multitude of custom IoT projects.

Atmosphere IoT Studio

Atmosphere IoT Studio is a codeless, drag-and-drop integrated development environment (IDE), that allows the user to create IoT solutions remotely using an internet browser. Build projects from anywhere there is internet access. The only local download is Atmosphere IoT Agent which runs in the computer’s system tray and acts as a bridge between Atmosphere IoT Studio and the hardware being developed.

Atmosphere IoT Studio Mobile App

Atmosphere IoT Studio includes mobile app development capability for remote interaction with a project over Bluetooth Low Energy or Wi-Fi transports. After installing the Atmosphere IoT Studio mobile app on a device such as a smart phone or tablet, users can log in and connect to projects using easily customizable interfaces developed in Atmosphere IoT Studio. The mobile app may also act as a bridge to send data to the cloud for long term storage.

Mini IoT Home Platform

This project is assembled using the Adafruit Quad 2x2 FeatherWing Kit as a base to mount the Huzzah32 ESP32 Feather Board, ADXL343+ADT7410 Sensor FeatherWing, BME680 development board, and the Adafruit Mini Relay FeatherWing. All of this and more is contained in the Adafruit Feather HUZZAH32 IoT Kit Feather Arduino IDE Starter Kit.

Kit_1

Getting started:

Connecting the components

When making connections to specific GPIO pins on the Quad 2x2 FeatherWing, use the labels found on the Huzzah32 PCB to determine pin header locations.

Quad 2x2 FeatherWing

The largest soldering task involves the Quad 2x2 FeatherWing headers. Insert the supplied headers into the top side of the Quad 2x2 FeatherWing header locations and apply solder to the pins and pads on the back side being careful to avoid bridging solder onto adjacent pins. Digi-Key has published some useful soldering resources and tutorials.

The Quad 2x2 FeatherWing has areas with a multitude of open pads for prototyping and also pad buses for power connections. Pad buses such as the 3V bus and GND bus are interconnected for easy distribution of power where the prototyping pads are not interconnected. When using wire in the prototyping pad area, allow enough additional bare wire on the back side to bridge the pads leading to the desired connection point. See Figure 1.

point_1

Figure 1. Bridging connections in prototyping area.

BME680 Wiring

Solder the supplied header in the prototyping area on the lower right quadrant of the Quad 2x2 FeatherWing as in Figure 2. Using prototyping wire and Figure 3 as a reference, connect the BME680 VIN pin location to the FeatherWing 3V power bus (red wire), the GND pin to the GND bus (black wire), SCK pin to the SCL header location (blue wire) and the SDA pin to the SDI header location (orange wire).

Figure_2

Install the Buzzer

The buzzer installs with its negative lead (short lead) inserted into a pad on the GND bus of the lower left quadrant of the Quad 2x2 FeatherWing. Insert the positive lead into any open pad in the prototyping area. Turn the Quad 2x2 FeatherWing over and solder the leads to the pads. Using prototyping wire, insert, and solder a wire between the positive lead and GPIO pin 12 at the header location and solder as before. See Figure 4.

buzzer_3

Figure 4. Chime module location and wiring.

Mini Relay FeatherWing Wiring

Insert and solder the 3-Pin terminal block to the Mini Relay FeatherWing PCB; then using prototyping wire, solder a wire between the signal pad and GPIO pin 33 at the auxiliary header pad location as shown in Figure 5. Solder a red wire to the 3V pad and connect it to the COM terminal of the terminal block.

FeatherWing_4

Figure 5. Relay FeatherWing Signal and relay terminal wiring.

Attaching JST wire leads to the Quad 2x2 FeatherWing

Prepare the three JST connector cables by cutting them into two equal parts; then strip 5 mm of insulation from each cut end (12 ends). It is beneficial during installation to “tin” the bare wires with solder after stripping the insulation. Separate the wires into male and female connector groups.

In the top right quadrant of the Quad 2x2 FeatherWing and Figure 6 as a reference, insert the black lead of a female connector wire into the GND auxiliary header pad and solder on the back side. Insert the red lead into the GPIO pin 14 auxiliary header pad and solder on the back side. Using a small piece of tape near the connector end, label the wire as “Lights” or “L” and “14” to denote the GPIO used to control the lights.

lighting_5

Figure 6. Lighting cable pin location and labeling.

In the top left quadrant of the Quad 2x2 FeatherWing, insert the black lead of a female connector wire into the GND auxiliary header pad and solder on the back side. For now, the red lead will remain unattached. Label the wire as “Fan” and “33” to denote the GPIO used to control the relay that controls the fan.

In the lower left quadrant of the Quad 2x2 FeatherWing, insert the black lead of a female connector wire into the GND auxiliary header pad and solder on the back side. Insert the red lead into the GPIO pin 15 auxiliary header pad and solder on the back side. Label the wire as “Door” and “15”.

Install the boards

Insert the Mini Relay FeatherWing into the top left quadrant of the Quad 2x2 FeatherWing headers; then connect the red lead of the wire labeled “Fan” into the NO terminal of the Mini Relay FeatherWing terminal block.

Route all the JST wires through the gaps between the headers upward and out of the top of the Quad 2x2 FeatherWing as shown in Figure 7; then insert the ADXL343+ADT7410 Sensor FeatherWing into the top right quadrant of the Quad 2x2 FeatherWing headers.

quad_6

Figure 7. Quad 2x2 FeatherWing JST wire routing.

Insert the BME680 development board into the BME680 header in the lower right quadrant of the Quad 2x2 FeatherWing. Finally, insert the Huzzah32 into the lower left quadrant of the Quad 2x2 FeatherWing headers. See Figure 8.

boards_7

Figure 8. Quad 2x2 FeatherWing with all development boards installed.

Mini IoT Home Assembly

A home needs a front door

A magnetic reed switch is used as a sensor that detects whether the front door is open or closed. These sensors operate on the principle that when a magnet is less than ~0.5" away, the reed switch contacts close. The change in sensor state is fed into the HUZZAH32 which in turn sends the door's status to the Atmosphere IoT Studio mobile app via a Bluetooth connection. These switches aren't just for a cardboard home, they've been used in real-world projects such as the Adafruit IO Door Detector project.

Using glue or double-sided tape, attach the reed switch to the left side of the door-frame. Ensure the switch is firmly in place and does not move around easily. Next, grab the closest empty Adafruit, Digi-Key or other cardboard or pasteboard box. Using a ruler, sketch a door on the box; then cut out the door using a pair of scissors or a sharp knife as shown in Figure 9. Using hot glue or double-sided tape, affix the magnet to the door. Using piece of single-sided tape to create the door hinge, place a little less than half of the tape on the long side of the door opposite the magnet. See Figure 10.

door_8

Figure 9. Cutting a door from scrap cardboard.     Figure 10. Door with magnet attached and tape for a hinge.

Align the door with the door opening inside the house making sure the magnet and sensor are also aligned. Firmly press the exposed tape onto the wall of the house; then test to ensure the door swings freely open and closed.

Strip 3 mm of the rubber coating from the door sensor leads. Slide a 14 mm length of small diameter heat shrink tube onto each lead. Slide a longer, single piece of larger diameter heat shrink tube over both leads.

Align one lead from a male JST connector wire parallel to either lead of the door sensor; then solder the leads together. A pair of helping hands will aid in wire to wire assembly. Allow the solder to cool; then slide the small diameter heat shrink tube over the solder joint and apply heat to shrink the tube and seal the joint. Repeat this step for the remaining sensor and connector lead; then seal both smaller shrink tubes with the larger shrink tube. See Digi-Key’s Another Teaching Moment on How to Splice and Tap Wires for tips on completing this step.

A fan keeps the home cool

To attach the fan inside the roof of the home, a section of the supplied popsicle stick must be cut to size. Using a wire cutter or scissors, square off one end of the stick. See Figure 11. To avoid splitting the wood, take small "snips" instead of one large cut. Sandpaper may be used to true up and smooth the cut end.

trim_9

Figure 11. Trimming the popsicle stick.

Insert the cut end of the stick into the inside corner of the roof as shown in Figure 12. Using a pencil, mark the stick where it meets the other side of the roof wall. Trim off the excess material and sand as needed.

length_10

Figure 12. Determining the right length for the stick.

Add a dab of glue to each end on one side of the stick. Insert the stick into the roof and press down in place until the glue sets. See Figure 13.

stick_11

Figure 13. Fastening the stick to the roof.

Modify the fan blades by cutting approximately 0.4 mm off each blade tip with a pair of scissors or wire cutters as shown in Figure 14. Press-fit the propeller onto the DC Spindle Motor. There may be a need to press hard, it's a tight fit. See Figure 15.

blades_12

Figure 14. Trimming the fan blades.        Figure 15. Pressing the fan onto the motor shaft.

Strip 3 mm of the rubber coating from the motor leads. Slide a 14 mm length of small diameter shrink tube onto each lead. Slide a longer, single piece of larger diameter shrink tube over both leads.

Align the red lead from a male JST connector cable with the red lead of the motor; then solder the leads together. Allow the solder to cool; then slide the small diameter shrink tube over the solder joint and apply heat to seal the joint. Repeat this step for the remaining motor and connector leads; then seal both smaller shrink tubes with the larger heat shrink tube.

Using Figure 16 as a reference, apply a small dab of glue to the back of the fan motor. Avoid covering any of the vent holes. Center the motor above the popsicle stick ensuring the blade tips clear all nearby surfaces. Press the motor in place and allow the glue to set.

glue_13

Figure 16. Keep glue away from motor vents.

Homes need lighting systems

Five Adafruit LED Sequins (in Digi-Key red) are provided to add some light to the home. These small LEDs only show a single color and don't have internal digital control, making them simple to add to the mini home.

Using the remaining male JST cable, strip off an additional 20 mm or more of the insulation on each wire. Twist each wire to wind the strands; then apply solder to the entire length of each wire to “tin” the leads.

Align the red lead with the positive (+) pad of a sequin; then solder the wire to the pad. Repeat this step for the black lead and the negative (-) pad of the sequin. Attach additional sequins to the wire leads as desired. See Figure 17.

sequins_14

Figure 17. LED sequins soldered to wire leads.

Apply glue to the JST cable and sequins using care not to cover the LED lenses; then attach the lights to the inside of the roof. Route the lighting and fan cables along an inside corner and toward the bottom of the roof and secure in place with glue. See Figure 18.

secured_15

Figure 18. LED sequins secured in place.

Cut an access hole for the programming cable

When the populated Quad 2x2 FeatherWing is installed in the Mini IoT Home, the USB programming port is obstructed so a new hole in the structure is required. Paper Mache is best cut using a sharp X-Acto type knife or the layers of paper may separate or become fuzzy.

On the bottom rear corner of the left sidewall of the home, measure, mark and cut a 20.8 mm H x 17.4 mm W hole in the paper Mache. See Figures 19 and 20. Slide the Smart Home Hub into the smart home. Connect all the JST connectors according to the labels, route the wires neatly into the enclosure and install the roof section on the Mini IoT Home as shown in Figure 21.

enclosure_16

Figure 19. Measuring the port location.

enclosure_17

Figure 20. Finished hole cut.

enclosure_18

Figure 21. Installing the roof section.

The Atmosphere IoT Development Platform

Atmosphere IoT Studio

Microcontroller and mobile application functionality are developed in Atmosphere IoT Studio which is a browser-based program that works with any computer with internet access. It is freely downloaded from the Atmosphere website. Simply create an account to access Atmosphere IoT Studio online. The Atmosphere website also lists devices that are currently compatible as well as project examples.

Install Atmosphere IoT Agent

On the Atmosphere website, locate and download Atmosphere IoT Agent on each computer used to develop Atmosphere IoT Studio projects. IoT Agent runs in the computer’s system tray and acts as a bridge between Atmosphere IoT Studio and the microcontroller platform attached to the computer’s USB port.

Note: If using the Mozilla Firefox browser, a few extra steps are required to allow the use of Atmosphere IoT Agent with Atmosphere IoT Studio. Use the link below and follow the steps to enable Atmosphere Iot Agent.

https://docs.atmosphereiot.com/documents/downloads/atmosphereiotagent.html

Install Atmosphere IoT Mobile App

The Atmosphere IoT Mobile App allows developers to deploy custom applications on mobile devices such as smart-phones and interact with remote microcontroller devices. Download and install the app on mobile devices from an app store. Log into the app using your Atmosphere IoT Studio login information; then add a project to start interacting remotely with the developed hardware.

Creating an Atmosphere IoT Studio Project

Atmosphere IoT Studio opens in the “Projects” pane. See Figure 22. Select the “New Project” icon; then select the development board type with the correct chipset. For this project, select the Huzzah32 type with the ESP32 chipset by Adafruit. See Figure 23. Under “Project Details”, give the project a name such as “Mini IoT Home” and select “CREATE” to move on to the Embedded Workspace.

create_17

Figure 22. Atmosphere New Project Pane.       Figure 23. Selecting the project hardware

The Embedded Workspace is where the development of device firmware and the mobile app is accomplished using Drag-and-Drop functionality. Configurable project elements are dragged into the workspace and linked together using configurable events.

Turning on the Lights (LED Sequins)

From the element toolbox, select the GPIO Pin element; then select the BLE GATT Characteristic element. The two elements will appear in the Adafruit Huzzah32 workspace. Because the BLE element will be used to trigger the GPIO element, position it to the left of the GPIO element as shown in Figure 24.

lighting_18

Figure 24. Adding lighting elements to the Huzzah32 workspace.

Select the GPIOPin icon in the workspace to reveal the GPIO Pin element properties bar to the right of the workspace. Give the element a descriptive name such as “GPIOPinLights” and set the GPIO PIN number to “IO14”. The default GPIO MODE and INITIAL STATE values are correct for lighting control. See Figure 25.

configure_19

Figure 25. Configuring the GPIOPin element as a push-pull output.

Select the BLECharacteristicCustom icon in the workspace to reveal its properties in the sidebar. Give the element a descriptive name such as “BLECharLights”. Since GPIO pins accept only Boolean values (either 1 for HIGH or 0 for LOW) set the READ, WRITE and NOTIFY data types to “Boolean”. See Figure 26.

element_20

Figure 26. Configuring the BLECharLights element for logic transport.

It is time to link the elements together with an event. With the BLECharLights element still selected, scroll down the properties bar and select Add Event; then select the GPIOPinLights element to reveal the event link in the workspace between the two elements. See Figure 27. An event configuration box also appears above the Add Event icon. Change the ABILITY to “Set State”. When the BLECharLights element receives a 1 or 0 from the mobile device, it passes that value through the event which sets the state of GPIO pin 14 accordingly.

event_21

Figure 27. Adding and configuring the GPIOPinLights event.

This simple, two-element firmware is sufficient to move on to the Application workspace where the mobile app is developed. Select the Application tab to reveal the App builder and programming workspace. The BLECharLights element from firmware development is automatically loaded into the workspace as shown in Figure 28.

workspace_22

Figure 28. BLEGatt elements automatically load into the Application workspace.

Building a mobile app is an opportunity to be creative with graphics and app functionality. For this project, an example background is provided as a downloadable image: https://github.com/adafruit/Adafruit_Learning_System_Guides/raw/master/DigiKey_IoT_Home/iot-home-background.png.

Change the app resolution to match the personal mobile device intended for use by selecting the device image with the “+” sign and toggling the Enable button that corresponds with the device or resolution desired; then select the SAVE button. See Figure 29.

save_23

Figure 29. Changing the mobile app screen resolution.

To bring in the background image, select the Image element from the Element Toolbox. In the properties sidebar, select the BROWSE button and locate the example background image downloaded earlier. The image can be moved and resized as needed using click and drag or by changing the origin and location values in the X:, Y:, W: and H: blanks. In this case, X=0, Y=0, W=360 and H=740 will fill the screen entirely with the background image.

Note: If the image background or any other image appears to be cut off or does not fill the entire area, the problem may be your choice of internet browser. Open Atmosphere IoT Studio using the latest version of Mozilla Firefox to resolve this issue.

Add a toggle switch to the Application workspace by selecting the device in the element toolbox. Using the “Bring to Front” icon in the layer and grid toolbar, move the toggle switch to the top layer; then drag the switch to a position under the lightbulb icon of the background image.

Add an event between the Toggle Switch element and the BLECharLights element. Set its ABILITY to “Write” and the VALUE to “value” as shown in Figure 30. When the switch is toggled on the mobile device, the value of the switch is written to the BLECharLights element and subsequently, the value is used to set the logic state of pin IO14 of the microcontroller through the GPIOPinLights element.

value_24

Figure 30. Completing the light toggling function using an event.

It is time to compile this first bit of programming and test its functionality. Select the COMPILE icon (Hammer). The project is saved, compiled and made ready for the firmware to be downloaded to the Huzzah32. Navigate to the Adafruit Huzzah32 workspace and select the Firmware Download icon (arrow over IC chip).

If the program is uploaded successfully, use the Atmosphere IoT App on the selected mobile device to interact with the Mini IoT Home's lights.

If there is a compilation error, a window with a descriptive compiler error will appear over the workspace.

There may be a need to check the port configuration using the computer’s Device Manager. Under Ports (COM & LPT), examine the Silicon Labs CP210x USB to UART Bridge and assure the device COM port matches the COM port listed in Atmosphere IoT Studio when selecting the Firmware Download icon. Also note the serial speed. If a mismatch exists, double click on the device in the Device Manager, then set the COM port to the same value as the Firmware Downloader and select a Bits per Second speed that is at least one setting higher than the serial speed listed in the Atmosphere IoT Studio compiler.

Atmosphere IoT Mobile App

The mobile Atmosphere IoT app works in conjunction with a wireless mobile device and the Atmosphere IoT Platform (cloud service) to monitor the custom-built connected things. The Atmosphere IoT App is a pared down version of the web-based Atmosphere IoT Studio. The project can't be edited or modified, but the devices can be connected, and their status viewed.

Download the Atmosphere IoT app onto a mobile device and use the Atmosphere IoT Studio login information to access projects. The app opens in dashboard mode. Select the Devices icon (box), then select the SCAN icon (small box with “plus” symbol in the upper right corner of the screen).

If the firmware downloaded correctly and the microcontroller is functioning, the project name appears in the Devices In Range list. Select the device to begin provisioning the Bluetooth connection. The app will also try to provision a Wi-Fi connection which is not a part of this project. When an error message appears asking for an SSID and password, either enter the data and SAVE or select CANCEL.

The app developed in Atmosphere IoT Studio now appears. Toggle the switch to see the lights in the Mini IoT Home respond.

Monitor the Mini IoT Home

To take advantage of the sensors on the BME680 and the ADT7410FEATHERWING, libraries must be added to the Element Toolbox and the firmware expanded in Atmosphere IoT Studio.

Select Add Element (+) at the bottom of the Element Toolbox. Search for the BME680; then enable the library using the toggle. Select the SAVE button to return to the workspace. See Figure 31. Repeat this step for the ADT7410FEATHERWING. Elements for these devices are now included in the Imported section of the Element Toolbox.

toolbox_25

Figure 31. Adding libraries to the element toolbox.

Sensors are read on regular intervals with the data being displayed on the mobile app. Add sensor functionality in the Adafruit Huzzah32 workspace of Atmosphere IoT Studio by selecting an Interval element; then select the ADT7410Featherwing element to add it to the workspace. Connect the Interval to the ADT7410 by adding an event. Set the ABILITY of the event to “Read Temperature (°C)”. The interval triggers the ADT7410 element to read the temperature sensor. Set the interval’s TIME to one second (1000 milliseconds) as shown in Figure 32.

time_26

Figure 32. Adding and connecting the AD7410 element to the workspace.

With the data collected, it is conditioned before transport over another Bluetooth GATT characteristic. From the Element Toolbox, add a Type Conversion Element, three Mathematical Operation Elements and a BLE GATT characteristic element to the workspace. Rename the elements to describe their temperature related function. See Figure 33.

Note: Although arithmetic operations may be implemented inside each of the BLE GATT characteristic elements by appending the readData, this method also consumes valuable transport time. Too many operations can cause the entire BLE transport to operate unpredictably or not at all.

function_27

Figure 33. Adding data conditioning elements prior to transport via BLE.

Select the DataTypeConvTemp Element and set its OUTPUT TYPE to “Integer”. This step converts the sensor output to a whole number for display in the mobile app (no decimal points) and prepares the data to be converted to a Fahrenheit value using the Mathematical Operation Elements. Add an event between the ADT7410Featherwing element and the DataTypeConvTemp Element.

Mathematical Operation Elements support one operation at a time. The formula for Celsius to Fahrenheit conversion is: F = (C*9/5)+32 which yields three operations. It is tempting to reduce 9/5 to its decimal equivalent of 1.8 to eliminate one operation but because the sensor output is converted to an integer, all other values in the operation are viewed as integers so 1.8 becomes 1 resulting in output errors.

Select the OperationT1 Element. Set its OPERATION value to “*” for multiply and the OPERAND to “9”.

Select the OperationT2 Element. Set its OPERATION value to “/” for divide and the OPERAND to “5”.

Select the OperationT3 Element. Set its OPERATION value to “+” for addition and the OPERAND to “32”. Add an event between the ADT7410Featherwing element and OperationT1; then add events between the Mathematical Operation Elements in sequence. Finally, add an event between the OperationT3 Element and the BLECharTemp Element. See Figure 34.

operation_28

Figure 34. Setting the conditions and connecting the elements using events.

Before adding more sensors, select the Application workspace to develop the ADT7410 sensor data output to the mobile device. As before, the BLE GATT Characteristic for temperature data is already populated. Add an Interval element; then connect the Interval to the BLECharTemp element with a new event. Next add a Label element and connect it to the BLECharTemp with an event. Set the event TEXT property to readData+” °F”. Using Figure 35 as a reference, give the label a name and set the label TEXT to “Temp” and ALIGNMENT to “Center”. Don’t forget to bring it to the front in the layout and position it under the thermometer symbol.

app_29

Figure 35. Completing AD7410 functionality on the mobile app.

Test this new functionality. Select the COMPILE (Hammer) icon. The project is saved, compiled and ready for the firmware to be downloaded to the Huzzah32. Navigate to the Adafruit Huzzah32 workspace and select the Firmware Download icon (arrow over IC chip).

On the mobile device, delete the previous version of this project; then load the current project as before and test the toggle switch. Data from the ADT7410 temp sensor is now visible under the thermometer icon followed by the °F text added earlier. See Figure 36.

device_30

Figure 36. Visualizing AD7410 data on a mobile device.

More Sensors

Add BME680 sensor capability to this project in the Adafruit Huzzah32 workspace by selecting the BME680 Environmental element from the Element Toolbox as well as two Type Conversion Element elements and two BLE GATT Characteristic elements. Rename the elements for humidity and gas sensing. Set the OUTPUT TYPE of both Type Conversion Elements to “Integer”. Select the Interval element; then add an event that connects it to the BME680 element. Set the ABILITY of the event to “Read Humidity (%Rh)”. Add another event that connects the Interval element to the BME680 element. Set the ABILITY of the event to “Read Gas Resistance (Ohm)” as shown in Figure 37.

data_31

Figure 37. Adding additional sensor functionality and data conditioning.

Sensing Humidity

Select the BME680 element. Change the I2C ADDRESS to ”0x77” and the Triggers to “Humidity Read”; then add an event between the BME680 element and the DataTypeConvHumidity Element. Add an event between the DataTypeConvHumidity Element and the BLECharHumidity Element. Assure the event’s ABILITY is set to “Set Value”.

Sensing Gases

The gas sensor takes readings in ohms which will be converted to kiloohms for reporting the data. Select the IntervalSens element again; then add another event that connects it to the BME680 element to trigger a gas resistance read. Set the ABILITY of the event to “Read Gas Resistance (Ohm)”. Add a Mathematical Operation Element. Set the OPERATION to “/” and the OPERAND to “1000”. Select the BME680 element. Change the Triggers to “Gas Resistance Read”; then add an event between the BME680 element and the Type Conversion Element. Add an event between the Type Conversion Element and the Mathematical Operation Element and another between the Mathematical Operation Element and the BLECharGas Element making sure the event’s ABILITY is set to “Set Value”. Figure 38 shows all of the element connections.

gasses_32

Figure 38. Connecting the BME680 conditioning and transport elements for gas readings.

To update the Mobile App for the Added Functionality, select the Application workspace to develop the BME680 sensor data output to the mobile device. As before, the BLE GATT Characteristic Elements for humidity and gas data are already populated. Connect the Interval element to the BLECharHumidity and BLECharGas elements with new events.

Add a Label element and connect it to the BLECharHumidity with an event. Set the event TEXT property to readData+” %RH”. Give the label a name, set the label TEXT to “Humidity” and ALIGNMENT to “Center”. In the app design pane, bring the label to the front layer and position it under the “%” icon of the background image. See Figure 39.

humidity_33

Figure 39. Updating the application workspace and mobile app labels for humidity data.

Add a Label element and connect it to the BLECharGas with an event. Set the event TEXT property to readData+” Kohms”. Give the label a name, set the label TEXT to “Gas” and ALIGNMENT to “Center”. In the app layout, bring the label to the front layer and position it under the “meter” icon of the background image; then change the W: value to 120 to prevent a line return when displaying the value. See Figure 40.

gasdata_34

Figure 40. Updating the application workspace and mobile app labels for gas data.

Test this new functionality. Select the COMPILE (Hammer) icon; then navigate to the Adafruit Huzzah32 workspace and select the Firmware Download icon (arrow over IC chip).

On the mobile device, delete the previous version of this project; then load the current project as before. Data from the BME680 humidity and gas sensors is now visible under the percent and meter icons respectively followed by the literal text added earlier. See Figure 41.

Displaying Humidity and Gas data on a mobile device

Figure 41. Displaying Humidity and Gas data on a mobile device.

Keeping track of the data

While the data is neatly displayed by the mobile app on a remote device, the data is not saved or stored in any way. IoT Data storage is accomplished by adding Cloud elements to the Application workspace.

Add three Device Events to the Application workspace as shown in Figure 42. Rename the Device Events corresponding to the sensor they represent. Link a Device Event to each sensor BLECharacteristic element by adding Events.

storage_36

Figure 42. Adding and connecting data storage events.

The Cloud workspace provides Wi-Fi connectivity with cloud services like Atmosphere IoT Cloud or Amazon Web Services. Select the Cloud workspace. Cloud elements in the Application workspace automatically appear in the Cloud workspace.

For this project, the data is sent to a Cloud Storage element. Add and rename a Cloud Storage element to the Cloud workspace; then add events to link the CloudEvents to the CloudStorage element. Format the VALUE field name of each event such as {Temp:value}, {Humidity:value} and {Gas:value}. See Figure 43.

cloud_37

Figure 43. Configuring cloud data storage in the Cloud workspace.

Test this new functionality. Select the COMPILE (Hammer) icon; then navigate to the Adafruit Huzzah32 workspace and select the Firmware Download icon (arrow over IC chip).

On the mobile device, delete the previous version of this project; then load the current project. After loading the Mini IoT Home app, select the cloud data icon and observe how many kilobytes of data have been stored so far. See Figure 44.From this pane, storage data can also be cleared. To slow the accumulation of data, the Interval element in the Application workspace can be modified to trigger less frequently.

access_38

Figure 44. Accessing the cloud storage pane.

Keeping Things Cool

An automated home responds to changing conditions. If the interior temperature is too high, a fan may kick-in to counter the problem. For this project, temperature data is used to trigger a relay which in turn activates the ceiling fan. In the Adafruit Huzzah32 workspace, add a Comparison element and a GPIOPin element as shown in Figure 45.

fan_39

Figure 45. Adding fan control capability to the hardware profile.

Add an event between the OperationT3 element and the EmbeddedComparison element. Select the EmbeddedComparison element. Set the CONDITION to “Greater Than”; then set the TARGET VALUE to a temperature value above which the fan should turn on. With the Triggers property set to “Condition True”, add an event between the EmbeddedComparison element and the GPIOPinFan element. Change the ABILITY of the event to “Set Pin High”. See Figure 46.

control_40

Figure 46. Adding events to connect the fan control elements.

With the Triggers property set to “Condition False”, add an event between the EmbeddedComparison element and the GPIOPinFan element. Change the ABILITY of the event to “Set Pin Low”.

Finally, select the GPIO Pin element. Rename the element to fit its fan function; then set the GPIO PIN value to “IO33” which is the IO pin that activates the relay.

Test this new functionality. Select the COMPILE (Hammer) icon; then navigate to the Adafruit Huzzah32 workspace and select the Firmware Download icon (arrow over IC chip). On the mobile device, delete the previous version of this project; then load the current project.

After loading the Mini IoT Home app, place a finger on the temperature sensor of the ADT7410FeatherWing or aim a hairdryer at the Mini Iot Home and observe the temperature rising on the mobile device. The fan starts running when the temperature exceeds the target value.

A Home is a Secure Place

The final hardware-based part of this project involves the door sensor and door alarm function to provide visual feedback on a mobile device and auditory feedback from the home itself. Both the firmware and application workspaces require new Interval elements to periodically monitor GPIO pins and initiate events.

In the Adafruit Huzzah32 workspace and using Figure 47 as a reference, select a new Interval from the element toolbox. Rename the element and set the TIME to 300 milliseconds. Add a new GPIOPin element to the workspace. Rename the element, set its GPIO PIN to “IO15”, GPIO MODE to “Input Pull Up” and the Triggers to “Read”. Connect the Interval element to the GPIOPin element with an event. Set the event’s ABILITY to “Read”.

sensor_41

Figure 47. Adding door sensor read capability to the hardware profile.

From the element toolbox, add a BLE GATT characteristic element to the workspace. Rename the element. GPIO pins output Boolean values (either 1 for HIGH or 0 for LOW) set the READ, WRITE and NOTIFY data types to “Boolean”. Connect the GPIOPin element to the BLE GATT characteristic element with an event. See Figure 48.

transport_42

Figure 48. Configuring the BLE for door sensor data transport.

From the element toolbox, add and rename an EmbeddedComparison element to the workspace. Change the TARGET VALUE to “1”. Connect the GPIOPinDoor element to the EmbedCompDoor element with an event. Assure the event’s Triggers is set to “Read” and ABILITY is set to “Evaluate”. From the element toolbox, add another GPIOPin element; then rename the element and set the GPIO PIN to “IO12” which is connected to the chime.

Select the EmbedCompDoor element; assure the Triggers property is set to “Condition True”. Add an event between the EmbedCompDoor and GPIOPinChime element. Set the event’s ABILITY to “Set Pin High”. Select the EmbedCompDoor element again; assure the Triggers property is set to “Condition False”. Add an event between the EmbedCompDoor and GPIOPinChime elements. Set the event’s ABILITY to “Set Pin Low” as shown in Figure 49.

GPIO_43

Figure 49. Adding data comparison and GPIO output to activate the chime hardware.

Switch to the Application workspace. Add an Interval Element to the workspace. Rename the element and set the TIME to 300 milliseconds. Place an event between the new Interval and the BLECharDoor elements. To evaluate if the door is open or closed, add a Condition element from the toolbox. See Figure 50. For the mobile app, images are used to indicate the current door status. Download the sample images from the links below.

visual_44

Figure 50. Adding visual door indication to the application workspace.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/master/DigiKey_IoT_Home/door-closed.png

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/master/DigiKey_IoT_Home/door-open.png

Add two Image elements to the Application workspace. Rename the elements to indicate door status.

Select ImageDoorOpen element; then select the BROWSE button to locate and import the door open image downloaded earlier. Using the “Bring to Front” icon in the Layer and Grid toolbar, move the door open image to the top layer; then drag the image into position in the empty gray box under the humidity box. Repeat this step for the ImageDoorClosed element. See Figure 51. Comparing the X: and Y: values in the application design toolbar helps during image alignment.

openclosed_45

Figure 51. Adding the door open and door closed images to the application workspace.

Select the ConditionDoor element. Assure the Triggers property is set to “Condition True”. Add an event between the ConditionDoor element and the ImageDoorOpen element; set the ABILITY property to “Show”. Add another event between the ConditionDoor element and the ImageDoorClosed element; set the ABILITY property to “Hide”. See Figure 52.

Change the ConditionDoor element’s Triggers property to “Condition False”. Add an event between the ConditionDoor element and the ImageDoorOpen element; set the ABILITY property to “Hide”. Add another event between the ConditionDoor element and the ImageDoorClosed element; set the ABILITY property to “Show”.

hideshow_46

Figure 52. Configuring the image hide and show capability based on comparison conditions.

Test this new functionality by compiling and downloading the new firmware. Physically open and close the front door of the Mini IoT Home and observe the door status images toggling on the mobile app and the chime sounding when the door is open.

This concludes the programming needed to monitor and control the Adafruit Mini IoT Home. This is also the time to perform a save-as function to create a copy and start experimenting with graphics and functionality. The way has been paved for alternate ways to view the cloud storage data using custom dashboards. This topic is not covered here but is available at this link (https://docs.atmosphereiot.com/documents/viewingdevicedata/configuringthedashboard.html) or by selecting DOCs under the Help icon found in the lower left corner of Atmosphere IoT Studio. 

Key Parts and Components

Add all Digi-Key Parts to Cart
  • 1528-4253-ND
  • 1528-2515-ND
  • 1528-2880-ND
  • 1528-1658-ND
  • 1528-4450-ND
  • 1528-2444-ND