Chapter 6. What Else Can We Do?

As you can imagine by now, there are myriad ways we can grow our voice-enabled product. We can add more inputs (e.g., sensors) and add more outputs (e.g., a digital display or different types of LEDs). Alternatively, we can also create variations of our product or expand the product line, as Amazon has done with Echo and Alexa. Initially, there was just Echo and Alexa, then Alexa appeared in Fire TV, then Echo Dot, Echo Tap, Echo Look, Dash Wand, Echo Show, and a number of other Amazon products, not to mention all the third-party Alexa-enabled devices.

We do this by first understanding how the product will be used and how to elevate that experience. For instance, does adding a motion sensor help the user experience or make it worse? Does adding a screen or extra buttons improve the overall experience and if so how would they be used? The best way to answer all these questions is to create variations of your product and get beta testers involved. Invite your friends and family over to play with the device to gather feedback. That feedback loop is critical to the success of your device. Even if you will be the only user of the device you’re building, it’s helpful to have other people test it—they can provide you with insight you wouldn’t have otherwise thought of on your own.

There are a number of IoT sensors out there that you can use. Here’s a short list of sensors you might want to consider playing with—do some research and experiment with how these sensors can be integrated into a voice interface such as Alexa:

Name Purpose
PIR motion sensor Senses infrared radiation to detect motion
Moisture sensor Detects moisture levels
Gyroscope Detects direction
Photocells Senses light
Sonar Detects objects by bouncing ultrasonic waves
Accelerometer Measures motion and tilt
Force sensitive resistor Senses pressure and force
Temperature sensor Measures temperature
Piezo Generally used as a buzzer but also used as a knock sensor
Ball tilt sensor Senses orientation

If you are interested in learning more about sensors, Wikipedia keeps a great list at https://en.wikipedia.org/wiki/List_of_sensors. There you will find a list of over 300 sensors that you can read up on and consider incorporating in your experiments and ultimately your product. While there are multiple paths we can take from here, in this final chapter we will include one last example that entails adding a motion sensor as an input. We will then cover some of the key considerations you will need to think about if you want to move forward with taking your great invention to production.

Adding More Inputs

Now that we have our own voice-enabled device with a custom skill, let’s see how we can integrate additional inputs such as a motion sensor. In this example, by adding a simple motion sensor, we can detect when people walk by and trigger an event like having Alexa say “Hello” or simply turning on an LED light. To follow along, you will need a passive infrared (PIR) sensor, sometimes referred to as pyroelectric infrared, or simply PIR (Figure 6-1). These are typically found in home security motion sensors but can also be ordered online for less than $10.

At a high level, PIR works by detecting infrared radiation levels above absolute zero; because humans and other animals typically radiate infrared wave lengths at around 10–12 μm (microns), this is a great technology for sensing people as well as creatures and other objects that radiate a decent amount of infrared light. We’re not going to dive too deep into the science of a PIR sensor, so if you want to learn more, check out Adafruit’s “How PIRs Work”. While you’re there, feel free to order a few of the PIR (motion) sensors to play with.

Figure 6-1. PIR Sensor - Photo Creative Commons, Adafruit Learning Systems

Generally PIR sensors will have three pins: one for ground, one for power, and one for the signal. Power is generally 3V to 5V, but can be as a high as 12V in some cases. As for the particular model shown here, you can feed it anywhere between 5V and 12V. The signal output is 3.3V, and can detect from up to 20 feet away at a 120 degree cone. The sensitivity and signal firing can be adjusted to your liking; for example, in some cases you might want to adjust the sensitivity to “min” and time to “max” (around 4 seconds) to detect when a person is standing in front of your device for a set period of time instead of just walking by.

Alternatively, you can use a sonar sensor, which uses ultrasonic waves to detect objects, or if you need something more precise for your particular application, you can look into using ToF Distance Sensor. The Adafruit VL53LOX is an amazing little sensor smaller than a US quarter dollar coin; the VL53LOX can detect objects by sensing the reflection of a very narrow field of light, unlike PIR and Sonar that detect within a wide cone or Field of View (FoV). With the wide range of motion sensors available, it’s a good idea to test as many as possible in order to determine which ones work best with your device.

As we mentioned earlier, this example will use a PIR sensor, so let’s get to it. First thing we’ll want to do is take a look at the diagram in Figure 6-2, so we know how to wire up our motion sensor.

Figure 6-2. Raspberry Pi with PIR sensor wiring digram

As you can see in Figure 6-2, we have the ground (black wire) connected to the Pi’s ground and the power (red wire) connected to the Pi’s 5V power output. As for our PIR signal (yellow wire), we connected it to GPIO 23 but you can wire it up to another GPIO pin if 23 is taken. Once we have all our connections in place, next thing we will want to do is modify the AlexaPi code to listen for the PIR events. For this we will need to open the rpilikeplatform.py file we talked about earlier in “Working with a Button and LEDs”.

Additionally you can add a new key value to the configuration file; for instance, under the raspberrypi section, add the first line as follows:

raspberrypi:
  motion: 23
  button: 18
  plb_light: 24
  rec_light: 25

Next open up the rpilikeplatform.py file in the src/alexapi/device_platforms directory. Once the file is open, look for the definition function called setup. There, we will set up our GPIO pin to listen to inputs from the PIR motion sensor; for instance, in the following code, simply add the first line (bolded for clarity) under setup:

def setup(self):
  GPIO.setup(self._pconfig['motion'], GPIO.IN)
  GPIO.setup(self._pconfig['button'], GPIO.IN, pull_up_down=GPIO.PUD_UP) 
  GPIO.setup(self._pconfig['rec_light'], GPIO.OUT)
  GPIO.setup(self._pconfig['plb_light'], GPIO.OUT)
  GPIO.output(self._pconfig['rec_light'], GPIO.LOW)
  GPIO.output(self._pconfig['plb_light'], GPIO.LOW)

Now let’s look for the after_setup definition function. There, we’re going to add GPIO event detection so when the motion is sensed from the PIR sensor, a function is called. In the after_setup function, we add a new line to the bottom of the function that listens for a HIGH event on the motion pin specified in the config file:

def after_setup(self, trigger_callback=None):
  self._trigger_callback = trigger_callback
  if self._trigger_callback:
  # threaded detection of button press
  GPIO.add_event_detect(self._pconfig['button'], GPIO.FALLING,
                        callback=self.detect_button, bouncetime=100)
  GPIO.add_event_detect(self._pconfig['motion'], GPIO.HIGH,
                        callback=self.detect_motion, bouncetime=100)

Note that in the preceding code we set the callback to self.detect_motion, which doesn’t currently exist. No worries, we are going to add a new function that will handle what we want to handle, when motion is detected. To test, we’ll start with something easy like turning on and off one of the LED lights. Add the following code right before the detect_button function like so:

def detect_motion(self, channel=None):
  logger.debug("Motion detected!")
  GPIO.output(self._pconfig['plb_light'], GPIO.HIGH)
  time.sleep(5)
  GPIO.output(self._pconfig['plb_light'], GPIO.LOW)

def detect_button(self, channel=None):
  self._trigger_callback(self.force_recording)
  logger.debug("Button pressed!")
  time.sleep(.5)  # time for the button input to settle down
  while GPIO.input(self._pconfig['button']) == 0:
    time.sleep(.1)
  logger.debug("Button released.")
  self.button_pressed = False
  time.sleep(.5)  # more time for the button to settle down

One last piece of code we need to update is in the cleanup function. Here we will remove the GPIO event detection to free up those resources when we’re not using them. In cleanup we will add the first line specified here, where we’re simply passing in the pin specified in the config file to the GPIO.remove_event_detect function:

def cleanup(self):
  GPIO.remove_event_detect(self._pconfig['motion'])
  GPIO.remove_event_detect(self._pconfig['button'])
  GPIO.output(self._pconfig['rec_light'], GPIO.LOW)
  GPIO.output(self._pconfig['plb_light'], GPIO.LOW)

Now we test. Go ahead and reboot the Pi. When the Pi comes back online, you will be able to pass your hand in front of the motion sensor or walk past it and it will light up the LED. Once we know this works for certain and as expected, we can start to think about other events we can activate inside of the detect_motion function, such as play a sound or brighten a display in much the same way the Nest thermostat does when you walk past it.

Going to Production

We’ve gotten our feet wet with some fun prototypes, but if you’re looking to create a product to sell to the public, there’s a much longer road ahead that includes strategic planning around security, testing, assembly, procurement, logistics, support, and much more. Successful product development is a complex process that has to be carefully executed, or else the potential for failure is too high, no matter how “cool” your product is. When prototyping, we can plug in some jumpers, write some code, and it works great, but as soon as that gets into the hands of customers it will easily break.

The first step in going to production is trashing your current prototype! You want to make sure you have iterated enough times that you are satisfied with the minimal viable product (MVP) and it serves its purpose. This can’t be done on the first iteration; you’ll need to take some time with it, but it shouldn’t be a long, drawn-out process—it’s all about finding the right balance. Tony Fadell, who designed and helped launch popular products such as the iPod and Nest, was well known for saying, “Don’t take longer than a year to ship a product.” Whether you take six months or a year is up to you; just draw the line in the sand and stick to it. Basically, once those MVP requirements are met, it’s time to launch!

A good, value-driven MVP project plan is a great way to establish when it’s time to go to production, and it’s important to consider the overall production lifecycle as you draw up the project outline. By now you should have an MVP in mind, based on our design thinking discussion in Chapter 1. Once you have a solid prototype ready, taking your MVP prototype to production requires some additions to that MVP requirements list. Some key considerations include:

  • Security
  • Quality management
  • Manufacturing
  • Support
  • Regulations

Additionally there’s logistics around warehousing and shipping, which really depends on where you are manufacturing your product. You could partner with a factory that can handle most of the product lifecycle for you or simply one aspect of it. In the beginning, however, your best option is to find a factory that can help with both PCB design, enclosure design, even specification and documentation all the way through possibly drop-shipping. The cost per unit might be much higher in the beginning, but overall costs could potentially be lower, thus reducing your risk level.

Security Concerns

For most tinkerers and makers, security is an afterthought. Security needs to be baked into your MVP way before going to production. It doesn’t necessarily need to be in the first or second prototype iteration (unless, of course, you are working on a product that requires it, such as a home security system or an ATM), but it should be considered early for all product development. The last thing you want is to unwittingly deploy a thousand vulnerable units and have your product fall victim to a distributed denial-of-service (DDoS) attack—that’s not the kind of press you’re looking for as you head to market.

So how do you create a secure product? First, create a checklist that covers all components of your product and services. For example, database security requirements, web API security requirements, edge security requirements, and so on. The following are some key considerations to help you get started. As you iterate, you might consider adding new components and new security requirements.

Authentication

As we’ve seen with Alexa, we use OAuth for authentication security. This has become the standard for authenticating users. For device-level authentication, however, make sure to create a strong password for your Raspberry Pi at minimum. If you are not using AVS and are going straight to your own APIs, make sure to incorporate some kind of X.509 certificate handling to ensure the requests to your API are coming from approved and authenticated devices.

Additionally, add a threshold to login attempts. If a login counter set in your authentication method reaches this threshold (e.g., say ten login attempts in under a minute), it’s highly likely that there’s an automated password generator attempting to hack in and it’s a good idea to lock that account.

Cryptography

This applies to both transport and storage of data. Ideally, any sensitive data such as passwords, PINs, birth dates, and other personally identifiable information (PII) are encrypted and stored in the secure database online. Then, depending on your transport protocol, say HTTPS, you use SSL/TLS to encrypt the transport of the data.

Data validation

In your web API, once you’ve validated the request and user (if any) make sure you validate all input data. For example, if the input includes a string and two integer parameters, make sure to check for null values, validate the value types, measure the length of the strings for an expected range, then ensure the integers fall within an expected range as well. Same goes for dates, times, decimals, and any other primitive and complex data types.

Error handling

Whether you are displaying an error message in a monitor or API response, it’s important to omit any system-identifying information such as OS type, source code references, and file paths, as this information can be used by attackers. It’s always best to log those details in a secure system logfile, then simply return an error code and user-friendly error message. If you are storing crash logs or debugging data, make sure it cannot be downloaded by an unauthorized user. You’d be surprised how many of us simply dump this data into a root file or directory.

While this is in no way meant to be a comprehensive security checklist, it does shine a light on the multiple aspects of security you need to consider for your voice-enabled IoT device. Make sure to do the proper research, planning, and implementation of each of the components of your specific product.

Quality Management

Quality, like security, is another one of those “I’ll deal with it later” subjects when it comes to prototyping, and understandably so: the prototype simply needs to work, not necessarily work all the time or even look good—it just needs to function enough to prove that it works. That’s the nature of prototyping. But when it comes time to go live, you want to make sure you have a solid quality management process in place.

This encompasses two key areas: quality assurance (QA) and testing and quality control (QC). Let’s take a closer look at each.

Quality assurance

QA is the process to which one assures quality. It’s your proactive plan to prevent defects and bugs in your hardware and software. Your QA plan is where you outline all the testing techniques, both automated and manual. This should be a well-written document that can be handed off to others in the event they need to implement the testing criteria so that all expectations and requirements are met.

Testing and quality control

QC is the actual implementation of testing controls that capture any defects and bugs. This can be broken down into dozens of sections once you take into account all the different types of testing you might need to run on your products and services. On the software side, there’s unit testing, automated functional testing, as well as security and penetration testing. On the hardware side, you have in-circuit testing, design verification testing, optical testing, and other testing techniques designed to ensure the PCB and overall hardware was produced to spec. Then, on the usability side, you have user acceptance testing, smoke tests, A/B testing, and so on.

Support

Know your limitations! As one person, you can only handle so much, especially when it comes to supporting your users. The last thing you want is to be fielding tech support calls all day long. Sure, you think you’ve put in some solid quality controls and all tests passed but as soon as that product hits the hands of customers, it’s 100% guaranteed you will receive support inquiries.

One thing you can do to provide support and capture feedback is to build it into your voice experience. Take Alexa, for example—people can say, “Alexa, I need help.” This can also be done with more custom solutions, as with the API.AI demonstration we looked at earlier. Here, we can add a response for “I need help” such as “Please visit www.mydomain.com/support to learn more” or potentially follow up with a question like, “What do you need help with?” and keep the conversation going from there to provide a robust chatbot-style support system.

Here are some additional things to consider when thinking about your support plan:

  • Documentation
  • Automated support
  • Escalated support
  • Returns
  • Handling complaints

Documentation

As the saying goes, “Communication is key.” The best way to communicate with users is through your documentation. Whether you are targeting developers or end users, the clarity and completeness of your documentation will help reduce tech support inquiries by at least 50% as the majority tech support issues out in the wild are related to user error. You can publish documentation online in a Help section of your website with an easily accessible keyword search system. A Frequently Asked Questions (FAQs) section is another great way to synthesize all those support inquiries and make it easily accessible for others to learn from.

When shipping products that require installation, including an iconography-rich installation guide works wonders, as in the case with IKEA and Apple products. Make sure to include in the printed materials any short URLs to extended online support libraries or Help sections so your users can easily navigate to it online without having to type in long, complex URLs.

Automated support

Another great way to provide help is via chatbots. Using API.AI or Microsoft’s Qnamaker.ai, you can easily load up your FAQs and make them available in bots for Slack, Facebook Messenger, and other channels your users can engage in. You can even get real fancy with it by asking users key questions to rule out common issues (e.g., “Is it plugged in?”; “Is the green light on or is it red?”; etc.). Just make sure not to close users off here. You will definitely need a way to escalate the user’s issue if it cannot be resolved by the chatbot. This can be done by either creating an automated support ticket or redirecting the user to chat with an actual person.

Escalated support

This is where support begins to get expensive. If a user has exhausted all other means of support and his only option is to talk to an actual person, then either online chat or phone support comes into play. In the beginning, it will most likely be you providing support. This is another great reason to move only a small amount of units at a time. For each batch you produce and ship, analyze the number of support inquiries you receive. Use this feedback loop to not only help your users but gather important ideas on how to improve your automated support as well as the quality of your product on future batches.

Returns

Strange things happen all the time. Packages might be missing parts or arrive damaged, or a customer may want to return the product because it’s the wrong color and doesn’t fit the feng shui of her home. Whatever the reason, you’ll need to handle those returns efficiently. Set aside a dedicated space to store returned devices until they can be tested, refurbished, and resold. Refurbished devices can be sold at a marginal discount to attract entry-level customers or those on a budget who wouldn’t have normally purchased your product, and at the same time, you’re covered on the per unit cost.

Handling complaints

“Your product sucks!” “It doesn’t work!” “Your product is garbage!” Are you offended yet? If so, don’t go live with your product. Ever! You need to have thick skin when dealing with the public. Even the best of the best—yes, even Steve Jobs himself heard these same words about Apple products. Seriously, how many times have you wanted to throw your iPhone out the window? It happens. People complain, that’s what we do. Don’t take offense. Simply try to identify if there’s anything constructive in the complaint; for example, if it’s an irrational user blasting about how the color of the LED should be fuchsia instead of purple, then respond with something like “Great suggestion!” and move on. But if a user has a logical explanation about adjusting the positioning of the LED, then just cut out all the noise and add that suggestion to your backlog.

Some things may sound irrational to you but to others it makes perfect sense. Sometimes you’ll hear the same complaints over and over from multiple users. This should be a red flag. Consider the fuchsia color example, for instance. Why is the user so obsessed with that color? Why are multiple people asking for that color? There must be something there, right? Maybe, maybe not, but you decide to make it fuchsia and all of a sudden, you have more people asking for the purple back! Insanity can easily set in. Just remember, you cannot satisfy all people, all the time. This is why we build multiple editions, versions, variations, and additional offerings of a product. Additionally, A/B testing can be implemented to help you identify which group of people prefer certain features over other features and so on.

Overall, always remember why you built that first prototype to begin with. Was it to have fun? Build something cool? Make some serious cash? Whatever it was, always remember that purpose when things get insane.

What’s Next?

So there you have it. You’ve successfully learned to rapidly prototype a voice-enabled device. Now what? Now you keep iterating and improving. To help you along your journey in getting you through to the next steps, the following are some additional resources you can reference:

Books

  • Prototype to Product by Alan Cohen

  • Designing Voice User Interfaces by Cathy Pearl

  • Designing Connected Products by Claire Rowland, Elizabeth Goodman, Martin Charlier, Ann Light, and Alfred Lui

  • Collaborative Product Design by Austin Govella

  • Product Roadmapping by Michael Connors, C. Todd Lombardo, Evan Ryan, and Bruce McCarthy

Online Courses and Videos

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset