Digital sound sensor and the Raspberry Pico

There are a couple of different options to do sound detection. One provides a simple digital signal when the sound passes a threshold. The other provides a threshold digital signal as well as an analog amplitude signal.

Digital Sound Detection Option

You can pick these sensors up for about $1 apiece on Amazon.

The sound detection sensor detects whether sound has exceeded a threshold value. Sound is detected via microphone and fed into an LM393 op amp. The sound level set point is adjusted via an on board potentiometer. When the sound level exceeds the set point, an LED on the module is illuminated and the output is set low.

Specifications of sound detection sensor module:

  • Working voltage: DC 3.3-5V
  • Adjustable Sensitivity
  • Dimensions: 32 x 17 mm
  • Signal output indication LED
  • Single channel output in the form of digital switching outputs (0 and 1 high and low)
  • Outputs low level and the signal light when there is sound

Schematic Diagram

The circuit

The program

The Pico MicroPython program to access the signal via any GPIO port. In this case we will use GPIO 16.

from machine import Pin
import utime
di=Pin(16,Pin.IN)
def sound_handler(pin):
    utime.sleep_ms(100)
    if pin.value()==False:
        print("ALARM! Sound detected!")
di.irq(trigger=machine.Pin.IRQ_RISING,handler=sound_handler)

This is a simple program that prints “Alarm! Sound detected” when the interrupt is triggered. You could do the sensing in a main loop as well. You will want to adjust the pot on the sound sensor board to get the desired level of sensitivity. I looked at using the one that also had analog output, but it output an analog audio signal that is more difficult to sense effectively and those boards cost slightly more as well.

Adding more complex triggers with IFTTT to control your home IoT

IoT HomeI have been using IFTTT for quite a while with my various IoT devices, doing simple things like turning on lights when my garage door opens or when there is motion near my home. One of the great things about IFTTT is its simplicity. If ‘this’ triggering event happens, do ‘that’. This simplicity is also one of the frustrating limitations of doing more complex tasks.

If I want to only turn on the porch lights when it is dark out, but keep them off when it is light, there is no way to do that natively within the system. They have thought about expansion capabilities through the ability to send and receive information from websites that can provide stateful information – IFTTT supports both trigger and response through a capability called webhooks. There are some free services to support this capability that you can experiment, if you don’t want to bring up your own website.

The one I looked at is: apilio.io and there is a good explanation of it on Medium. It is still in beta though.

Apilio has three building blocks:

  • Variables – to contain state information
  • Conditions – to evaluate variables
  • Logicblocks – to determine the actions from a Boolean analysis of the conditions

As an example, I decided to use Apilio with IFFF to turn my lights on when there was motion in front of my house but only when it is dark out. To accomplish this, I had to perform the following steps:

  1. Configure your IFTTT webhook connection on your webhooks settings/documentation page in IFTTT and enter that key into your Apilio profile. This key enables a secure connection between the website and IFTTT.
  2. Next define the variables in Apilio where you would like to store state information. In my case, I created a Boolean variable darkOutside. Note that there are URLs that when accessed will set the variable to True or False. You’ll need these URLs in the next step.
  3. Define two IFTTT rule Applets that set the variable to True at sunset and False at sunrise, using the capabilities of the Weather Underground trigger supported by IFTTT.
  4. Define a condition in Apilio that if darkOutside is True then it returns true, otherwise False. I named it DarkOutsideCondition
  5. Next, I made an Apilio logicblock that performs a simple logical AND operation that if it is triggered and the DarkOutsideCondition is True, it triggers applets back in IFTTT. I called the logicblock lights_on_when_dark. It has a URL to force its evaluation (from the logicblock show command) and a place to store a IFTTT trigger event name, if it is evaluated. One for True (called LightsOn) and another for when it is evaluated False (called LightsOff).
  6. Since I have a Ring doorbell with motion sensing that interfaces with IFTTT, I made an IFTTT Applet for when motion is sensed to initiate the evaluation trigger of the logicblock lights_on_when_dark.
  7. Now I just needed to create 2 more Applets, one to turn on the lights if it gets a webhook event called LightsOn and another if IFTTT gets the webhook event LightsOff that turn the lights on accordingly.

This may seem a complex but really only consists of:

  • a variable, a condition and a logicblock in Apillio
  • five applets in IFTTT:
    • set the darkOutside variable to true at sunset
    • set the darkOutside variable to false at sunset
    • receive a LightsOff trigger and turn the lights off
    • receive a LightsOn trigger and turn the lights on
    • catch the Ring motion sensor trigger and force and evaluation of the lights_on_when_dark logic block.

This is a fairly simple example. There are also some additional examples on the Apilio site, but hopefully this walkthrough will help you get started with enough context to overcome some of the areas that confused me.

I also have a IFTTT applet to turn the lights off at sunrise, just so there is another way to turn the lights off. I should have the ability to add some delay sensing so that I can turn the lights off after they have been on for a defined period (say a half hour), to keep my energy costs down.

Six thoughts on mobility trends for 2018

mobility walkLet’s face it, some aspects of mobility are getting long in the tooth. The demand for more capabilities is insatiable. Here are a few areas where I think 2018 will see some exciting capabilities develop. Many of these are not new, but their interactions and intersection should provide some interesting results and thoughts to include during your planning.

1. Further blurring and integration of IoT and mobile

We’re likely to see more situations where mobile recognizes the IoT devices around them to enhance contextual understanding for the user. We’ve seen some use of NFC and Bluetooth to share information, but approaches to embrace the environment and act upon the information available is still in its infancy. This year should provide some significant use cases and maturity.

2. Cloud Integration

By now most businesses have done much more than just stick their toe in the cloud Everything as a Service (XaaS) pool. As the number of potential devices in the mobility and IoT space expand, the flexibility and time to action that cloud solutions facilitate needs to be understood and put into practice. It is also time to take all the data coming in from these and transform that flow into true contextual understanding and action, also requiring a dynamic computing environment.

3. Augmented reality

With augmented reality predicted to expend to a market somewhere between $120 and $221 billion in revenues by 2021, we’re likely to see quite a bit of innovation in this space. The wide range of potential demonstrates the lack of a real understanding. 2018 should be a year where AR gets real.

4. Security

All discussions of mobility need to include security. Heck, the first month of 2018 has should have nailed the importance of security into the minds of anyone in the IT space. There were more patches (and patches of patches) on a greater range of systems than many would have believed possible just a short time ago. Recently, every mobile store (Apple, Android…) was found to have nefarious software that had to be exercised. Mobile developers need to be ever more vigilant, not just about the code they write but the libraries they use.

5. Predictive Analytics

Context is king and the use of analytics to increase the understanding of the situation and possible responses is going to continue to expand. As capabilities advance, only our imagination will hold this area back from increasing where and when mobile devices become useful. Unfortunately, the same can be said about the security issues that are based on using predictive analytics.

6. Changing business models

Peer to peer solutions continue to be the rage but with the capabilities listed above, whole new approaches to value generation are possible. There will always be early adopters who are willing to play with these and with the deeper understanding possibilities today new approaches to crossing the chasm will be demonstrated.

It should be an interesting year…

Another step toward gesture based computing

You may have seen some on the analysis that is taking place related to Google Soli, which is being viewed with a great deal of excitement (even though it will not be out until next year).

There has been significant work in this space over the years with Leap Motion (focused on hand based gestures) and Microsoft Kinect (addressing whole body or room scale sensing) with numerous examples of special application interfaces.

The first time I recall writing about gesture-based interfaces was back in 2007, although the Wii came out in 2006 (hard to believe that was almost a decade ago). The excitement about Soli did surprise me since the Leap Motion technology is available today (version 2.2.6 was released this week) and can do many of the same levels of gesture sensing (although it doesn’t have the same range as Soli).

In any case, I think we’ll see a whole new level of experimentation in how computers and humans can interface in a more intuitive fashion – and that’s a great thing.

New approach to power #IoT

plug in economyOne of the great things about Moore’s law that is sometimes overlooked is that even though computing capabilities have expanded at a tremendous rate, the power consumption for those same transistors that are being packed together have gone down at an even faster rate.

This announcement from the University of Illinois at Urbana-Champaign of the demonstration of a high-performance 3D micro-battery suitable for large-scale, on-chip integration may have long-lasting impact to the Internet of Things.

“Due to the complexity of 3D electrodes, it is generally difficult to realize such batteries, let alone the possibility of on-chip integration and scaling. In this project, we developed an effective method to make high-performance 3D lithium-ion microbatteries using processes that are highly compatible with the fabrication of microelectronics,” – Hailong Ning, a MatSE graduate student

If this technology can be produced reliably, I’d expect it to show up in many ways quickly, since access to a power source is critical to any sensing or distributed computing approach, allowing for greater flexibility in where to place ‘things’. Having the manufacturing process compatible with the chip making process should make for rapid adoption.

Expect more from IoT

planningRecently there was a post in Forbes titled In Search of the True Value in The Internet of Things. This post narrowed down the value statement to:

The real value lies in being able to capture and analyze the data that comes from the sensors at the endpoints of IoT — and that needs to be the few nuggets of data that are of material value to the business.

It does make me wonder if the author overlooked the new business model possibilities. It is not just about capturing and analyzing, it also include the action taken by which actors for the company and its entire ecosystem. As everything ‘gets smarter’ there should be more options available and more time to execute those options. At the same time we see larger and more powerful arrays of processors, we also see them moving into more places and processes.

One of the great questions that remains is what should ‘we’ be doing differently now that computing’s impact moves both deeper and broader into the business?

The arrogance of success is to think that what you did yesterday will be sufficient for tomorrow. -William Pollard

And not Or

and not or (logic)I was in an exchange the other day with some folks talking about their perspective that all companies need to be using cloud computing. I agree, but my view is slightly different. My perspective is that depending on the company’s size, needs and applications they will likely continue to have in house systems. It’s not a choice between things, but a choice among things and an acceptance of the way things are and one answer doesn’t meet everyone’s needs. You can’t look at it as: clouds the answer, now what’s the question?

Mobile computing is similar. It is the future interface of the enterprise, not really something special anymore. Embracing mobile devices and cloud computing will have a game changing effect, but it is not about the infrastructure but what we do with them and people want to do those things everywhere.

There are a number of other trends taking place like the IoT that are also shifting how organizations think about computing. It is interesting how this term is changing and how various organizations are trying to name it. It used to be ubiquitous computing, some call it ambient computing, but most still use the Internet of Things.

In any case the aggregation of sensors, devices, intelligence, and agents will shift how organizations generate value and shift IT to focus on systems of action.

Internet of Things Units Installed Base by Category (in Millions)

 Category 2013 2014 2015 2020
Automotive 96.0 189.6 372.3 3,511.1
Consumer 1,842.1 2,244.5 2.874.9 13,172.5
Generic Business 395.2 479.4 623.9 5,158.6
Vertical Business 698.7 836.5 1,009.4 3,164.4
Grand Total 3,032.0 3,750.0 4,880.6 25,006.6

Source: Gartner (November 2014)

Many still look at these opportunities primarily from an infrastructure perspective, but I definitely do not. It is about the business and the hardware side is a small (but necessary) part. Organizations that will compete effectively in the coming years are going to shift their thinking to “and” and not “or” foundation. It is not all about IT, but IT has a role in enabling this flexibility.

By the way the output of the And not Or logic circuit illustration is always a one –> true.