I have wanted to create a platform that simplifies datalogging since I began coding. This project provides an Arduino-compatible system that is driven by Amazon AWS and controlled through user input to Alexa.
The users prompts the Alexa Skill to log certain sensors and can control actuators. Data can be captured between a start and end time and date. Additional sensors can be enabled even while a datalog is ongoing.
This is the all-in-on smart home device. You can be in charge of setting up your lights, temperature, and other sensors and have them trigger events. The LDR can trigger lights to come on and actuator a motor to move your shades up or down. If we had a sound sensor, it could e-mail you when your dog was barking outside.
The objective was to create a skill that enabled a user to prompt Alexa to record data from a given sensor that was attached to the Arduino. There would be an option to enable an actuator if a certain trigger value was met. The program would datalog and send an email.
I chose to do a custom Alexa Skill. This skill triggers events in an AWS Lambda function.
Users initiate dialog by saying "Alexa, open SciJoy Logger." This starts the launch intent in the Lambda function, which asks the user to specify what sensor they would like to use. The Lambda function delegates dialog. This means it takes over control and makes sure all the required data slots are filled. It fills the sensor type, the duration to log the sensor, the sample rate, the threshold value, whether the threshold is a min or a max, and if the use wants to trigger an actuator with this sensor.
If the user wants to trigger an actuator, they are prompted to name an actuator. They then fill in all the slots for the actuator.
In the Lambda function, I use the id values for many of the slots. This lets me set sensor and actuator types to integer values and makes sure that the data is normalized and not using any synonyms. I also translate the duration values to milliseconds so the Arduino can use them.
The sensor and actuator intents send updates to the AWS IoT Thing Shadow.
This shadow logs updated user values from the Lambda function. We have a Raspberry Pi 3 subscribed to this shadow. It looks for delta values between the desired and reported states. The Pi takes the delta values, parses out the JSON parts of the shadow. The is reconstructed into a string, which is sent over serial to the Yun. The Pi reports back the status of the shadow.
The Yun read the shadow values sent by the Pi. The Yun's sketch takes monitors the sample rate and records analog values from the sensors. These values are logged into a Google Spreadsheet using Temboo. If a sensor values crosses a threshold, the person is e-mailed an alert. If a trigger values is crossed for an actuator, the actuator is started.
I plan to continue to refine this project. The Lambda should be a state machine with more error checking. The state machine will allow users to have more decisions. There will be more sensors added. The sensors could be connected to the Yun via WiFi or radio to enable longer distance use.
I am also a firm believer in accessible technology and I want to explore the voice-enabled features for future projects.