The NXP Rapid IoT is a compact device with multiple sensors, LCD display, BLE communication, and a LiPo battery. It seemed like the perfect device to implement a handheld home controller unit. A real plus is that the Atmosphere based Rapid IoT Studio IDE allows you to generate the embedded device code, the mobile application, and the cloud application all in the same framework.
My idea was to implement a controller that could be personalized to the user by reading a pre-programmed NFC tag. The controller would interact with the local environment to react to the user preferences. For example, the controller could measure the local temperature, compare it to the user's set (desired) temperature and send an increment or decrement command to a remote thermostat. The controller could control lighting based on the ambient light sensor value. And the controller could also send alerts and warnings based on high values from the air quality sensors. So, there's a huge range of control opportunities available with the Rapid IoT.
My goal for this contest is just to demonstrate a selection of these capabilities - as much as I can implement in the time allocated.
The first design issue that I encountered was that the Rapid IoT only has the ability to read and write its internal NFC tag. It cannot read or write external tags. I solved that problem by getting an NFC Click module and Hexiwear Battery Pack from Mikroelectronika. That also solved the other problem of short run time by adding 4 AA cells for power and an on/off switch. The internal battery has 240 mAh capacity which only provides about 2 hrs of run time with the OOB demo. 4 AA Duracell batteries have about 11400 mAh capacity. Power will still need to be managed, but it is much less of a problem.
The next set of issues slowed down my development progress and ultimately determined how much I was able to accomplish for the contest.
The Hexiwear Battery Pack has what I consider a major design feature omission. The USB interface on the Rapid IoT cannot be used when it is plugged into the Battery Pack. That means that I cannot program it or use the serial debug output when it is connected to the NFC Click module on the Battery Pack. As a result I have a limited NFC tag interface. I am basically only reading the User information from a single text record (the first one). I eventually want to use the Rapid IoT to read and write external tags using the NFC Click. I may end up getting a Docking Station to get the USB capability and also a hardware debugger. I might need to use MCUXpresso rather than the IoT Studio as I don't see write capability in the NFC Click Element (it exists for the internal NFC Element).
The software development environment caused me a number of problems. I used both Rapid IoT Studio and Atmosphere Studio. I also used MCUXpresso successfully but didn't develop any new code with it. The first problem was the learning curve which is normal when encountering a new design paradigm. I think the Studio concept is great and that simultaneous embedded, app, and cloud development will shorten implementation time. That being said, I think Studio is still early in its development relative to the Rapid IoT. It is reasonably straightforward to create new code using elements that are used in the provided examples. However, I found it difficult to use elements where sample code was not available. I had issues with determining the required syntax and also ran into issues with elements that did not work. The funniest one was a Text element that would cause a reboot if I put any text in it. To their credit, Atmosphere support is very responsive with help and fixes. I use both Rapid IoT Studio and Atmosphere Studio because Atmosphere Studio gets its updates quicker. One defect I complained about is that you can't tell which version you're using. When the bugs are worked out I think this environment will be awesome and I look forward to completing a full implementation of my controller with it.Design Features
- Thermostat with configurable set point
- Increment/decrement commands to cloud
- Cloud alerts
Sensors withon/off control
- Temperature and humidity
- Ambient light
- Air Pressure
- Air Quality
User configurationvia NFC tagPage Navigation and controls
Start Page: The home page is used to show controller status
- Line 1: Shows BLE when provisioned, blank if not
- Line 2: Battery charge (internal - always shows max on Battery Pack)
- Line 3: Time (00:00 when not provisioned)
- Line 4: Username ("User" if NFC tag has not been read)
Sensors: Up and to the right using touch pads, sensor reading and enable/disable using lower buttons
- Ambient Light
- Air Quality (TVOC and CO2)
- Thermostat - current temperature and user setting, increment and decrement user setting using right side buttons (initially 30 C)
- Buzzer - toggle on/off using lower left button
- Backlight - toggle on/off or set high, medium, low using side buttons
- Reset - reset device using lower left button
- Rapid IoT and NFC Click on Battery Pack with NFC tags
- Home screen before provisioning
- Home screen after provisioning before NFC tag read
- Home screen showing valid Username after NFC tag read
- Settings screen
- Thermostat screen
- Buzzer screen
- Backlight screen
- Reset screen
- Sensors screen
- Temperature/Humidity screen
- Ambient Light screen
- Pressure screen
- Air Quality screen
The mobile app displays the sensor values and allows setting the user temperature for thermostat control. I had quite a few issues with BLE, mostly with my Nexus 7 tablet but also with my iPad. Most of the issues were around being able to reliably provision the Rapid IoT device but I also had some bad data issues with the Nexus 7. I think the Nexus problems were because it is an older tablet and runs Android 6. The iPad is running iOS 12.
I used the NXP TagWriter app on my Nexus 7 tablet to write the text records onto the Ntag215 NFC tags. I only wrote 2 fields, the User and the Group. In my final application I'd like to add preference data that could be used to control temperature and lighting. I am currently only able to read the first field, so it's basically just a demo of being able to read from the NFC Click.
I ran into problems using the Web elements so again the alerts are just a proof of function rather than a full implementation. Atmosphere is working on fixes for the WebIO element that will be available next month and I'll update this part of the application (currently the POST function does not work).
I am using 2 web applications to implement the alerts, IFTTT's Maker Service and Pushbullet. The Maker Service has a feature called Webhooks which allows you to configure actions in response to a web request. You could send alert emails or text messages or in this instance I chose to push a note to my Pushbullet mobile app.