Motion Sensor Art Project: 1) Randomness and 2) Distance Detection?

Sounds like an interesting project!

  1. Randomness is pretty easy as long as you are using webcore. There are a number of different ways to do it, but it can definitely be done.

  2. Distance detection is not easy.

2a) There are some types of sensors, particularly radar-based ones, which can do that, but those are not the ones that you buy off-the-shelf to work with SmartThings. If you are a maker type and into robotics, you could probably build something that would do it (it’s the same kind of sensor that keeps a robot vacuum cleaner from running into walls), but it’s not simple.

Smart switch motion detector problem

There are other ways to do it but they all require lots and lots of devices. That can get expensive.

2b) The most certain way would probably be to set up a grid of interruptible IR beams, And then as the visitor enters different sections of the grid, trigger different light behavior. But that’s both complicated and expensive.

2c) If you’re willing to settle for just a couple of zones, maybe two or three, I think you could put a tube over a motion sensor lens to greatly narrow the detection field And then change the light settings as different sensors triggered. That would be easier and less expensive then the beam grid, but A lot more trial and error to set up. ( I thought about using a pressure Mat in some zones, but I think that spoils the effect as it would be obvious to the visitor what was triggering the change in the light)


2d) There may be some proximity lamps you can buy that do get brighter as you get closer, and then you would just control their power source. So it’s essentially the same kind of zones as 2c), but with a device that does it’s own dim Setting. You’d have a lot less control over that, though, and I don’t know if the timing would work. But I just mention it in case it’s something you want to look into. (These are typically sold for commercial use where retailers want to have a display light up as someone walks past. But there are also some sold for residential use, particularly in shop lighting.)

2e) If you’re willing to have the visitor wear a wristband, you could do this quite easily with Beacon technology, but the detection devices are phones, which can get expensive unless there are some you can borrow for the exhibit. I have mixed feelings about this one. I can pretty readily imagine how you would set it up, and I think it would be reliable and interesting, but there are also ways for the visitor to mess it up mid performance Which I don’t like.

Anyway, there are some possibilities for distance detection, but I don’t know how practical they will be for your project.


I should add that if you had asked about a project to track people in your own home, I would’ve gone a completely different route with this, microlocation probably based on one of the “wasp in a box“ models.

However, since you said this was an art project, I have made the perhaps incorrect assumption that you don’t own the space where the project will be presented and that it will be set up on a temporary basis. Also, I envisioned a kind of large gallery space rather than something with typical residential rooms and doors. And I assumed that you can’t count on each individual visitor having downloaded a particular app to a smart phone. That’s why I mostly just considered sensors that could be set up at the start of the day and easily taken down again.

If I’m wrong on all that, then definitely look at the various project reports on microlocation. You can find those by going to the quick browse lists in the community – created wiki, looking down near the end of the page for the project report section, and choosing the list on presence and micro location.


Also, I’m going to put this here for @ogiewon and other serious maker types: it’s a discussion by digikey of how you can wire proximity sensors. (This is one of those “simple design“ articles that only look “simple“ to people who already have certain level of knowledge. :wink: )


If you can find a workable Arduino-style solution to detect distance (like the inexpensive ultrasonic sensors), and you’re able to write some code, then a solution wouldn’t be too difficult to come up with. But, if you’re not a C/C++ programmer and into microcontrollers and electronics, this solution may not be quite right for you…:wink:

If you’re interested to learn more, let me know and I’ll try to point you in the right direction.


Thanks @JDRoberts and @ogiewon ! Your ideas push the boundaries on what I know how to do… so that means it’s perfect! Greatly appreciated. I’ll report back as I make progress.


@ogiewon this sounds perfect. I am huge into electronics, low level of familiarity with microcontrollers (little bit of Raspberry Pi exposure) and not one drop of C/C++ but I’m quick learner :wink: Any guidance you might have would be of huge help!

PostScript 1 hr later: been digesting my first chapters on Arduino over the past hour… I sense a new addiction coming on… LOL. Now shopping for starter kits, many of which have ultrasonic sensors in them. If you think its a good idea to obtain a different sensor (like those reviewed in the video that @JDRoberts posted, (likely due to lack of distance in the kit version) - I’d appreciate any counsel on that. Thanks again!

Well, here’s the place to start…

My thought is that you could use a sensor that can measure distance and feed this value to ST. One limiting factor is how quickly the data can fed to ST and then relayed to a light to adjust brightness, especially since all of this has to be processed in the ST Cloud via an internet connection.

Have you considered just using an Arduino or NodeMCU board to do everything? There are plenty of online resources that can help get you started with learning about Arduino programming, as well as the plethora of devices that can be connected to an inexpensive MCU board. The advantage of going this route is amazing performance. The challenge will be in the choice of lighting. Inexpensive LED strips may be your best option.

Here’s an example where someone used music to alter the lighting. Just an idea of what is possible…

Here’s another example showing distance based dimming.

1 Like

Yup love it - was already headed down the Arduino path! Great call. Unfortunately the distance/dimming video you posted was exactly what I need (and looks straightforward enough) but the poster didn’t leave any code behind to help newbies like me… dang. I’l keep looking. Totally loved the first video; very inspiring!

ThingShield looks quite awesome as well… any idea where to find it? Looks like it’s been discontinued, no?

  • LL

ThingShield was discontinued long ago. That is why I added support for LAN connected devices to ST_Anything, so that a shield is not needed.

Here’s some sample code. I have no idea if it works or not. Ultrasonic Fade LED - Arduino Projects Made Easy


Thanks Ogiewon! Here’s where I’m at so far

  1. my head is spinning wildly from the number of videos I’ve watched :grinning:
  2. I installed ST_Anything DHs in my IDE -woot!
  3. Arduino now shows up on my list of devices
    Current hangup: I cannot find the MAC address of my arduino. Tried resetting it to see if it would appear in the serial monitor, but no such luck… any ideas?
  4. I’ve connected the HC-SR04 and had success with a small code; I’ll definitely need a stronger sensor (this one’s only good for 40cm; the one in the video you sent me is good for 4m - that’ll do nicely)

(I know I don’t need to connect the light and the radio sensor to ST to work; I’m just kinda advancing both goals as learning processes.) Thanks for all the guidance, videos, and code! Hugely helpful. You’ made a new monster outta me… :slight_smile:


Good deal. I hope you used the GutHub integration to save a ton of time and effort.

Did you load one of the ST_Anything_Multiples_xxx.ino example sketches? What Arduino are you using? Did you set the Arduino IDE Serial Monitor windows baud rate to 115,200?

What light and radio sensor are you referring to?

LOL sorry Dan - “light and radio sensor” is referring back to my original project, in which I plan to use an Arduino and an HC-SR04 to control the brightness on a light fixture. I did use the GitHub integration - it was a breeze.

I’m using an Elegoo Arduino UNO R3. I realized (and am feeling stupid) my missing component is an ethernet shield - I thought the USB connection would serve as the connection but no dice.

I set the baud rate to 115,200 and hit reset to get the MAC address; no luck. I’m certain that will change once I get the ethernet shield! Off to Amazon I go (unless you suggest shopping elsewhere)…

Thanks a million Dan,

  • Mark

Any suggestions on the shield? I’d like to go wifi; looks like not all of them work with the UNO R3… thanks. M

So, I would recommend you NOT use an UNO due to the very restrictive 2KB of RAM on those boards. The UNO + W5100 Ethernet Shield (Cat5 cable) is a possible solution, but you’re very limited due to the memory constraints. The Arduino MEGA 2560 + W5100 is a much better solution, IMHO. I have not found any reliable WiFi solutions for the Arduino UNO/MEGA boards. ST_Anything supports two WiFi solutions, but neither of them have proven to be reliable in my testing. The hardware combinations are all detailed in the ReadMe.

The NodeMCU ESP8266 is definitely a lower cost, more powerful solution that has WiFi already built in. As long as you don’t need a ton of I/O, it is the way to go. This is a standalone board, no Arduino required.


The ESP8266 is now on its way! Thanks. You’ll recall my original post was about an art project; here’s what I’m trying to achieve. I would like to have a light bulb (probably 120VAC) that defaults to OFF and is connected to a sensor of some kind. When someone walks into the sensor’s field (sensor will be placed near the bulb), the bulb turns on, dimly. As the person closes the distance to the sensor, the bulb burns brighter, with 90-100% brightness at around 2 feet. As the person walks away from the bulb/sensor, the light dims, and ultimately returns to OFF.

In trying to take a barebones approach, I’m envisioning an Arduino with a sensor (probably ultrasonic, open to ideas) whose distance readings control a potentiometer that ultimately controls voltage to the dimming bulb. Issues I’ve been wrestling with:

  1. Is an ultrasonic sensor the best way to go? I’ve had success with an HC-SR04 but the detection distance is a max of 4m. I’d prefer 7 - 8m. I’ve been looking at some radar sensors (which I like a LOT since they have 360 degree detection) but to my understanding, they do not/cannot measure distance - I could be wrong on this. Totally open to other sensors I should be considering.

  2. One video @ogiewon shared (thanks!) was precisely what I’m trying to do - but instead of 120vAC, it had a basic LED plugged right into the Arduino with a 100ohm resistor, and the LED would get brighter as the distance to the object got shorter. Another video showed the sensor controlling a relay that controlled the AC circuit to a light bulb. This is great, but a relay (as I understand it) is a binary ON/OFF, and I want dimming capacity. Any ideas on what device I would use to get the ability to dim, based on the distance reading from the sensor?

  3. I’ve pulled the SmartThings component out of the equation for now, for simplicity’s sake - but I fully intend to bring it back into the equation once I get it working, so that I can control it from my home ST network.

My learning curve over the past 48 hours has been more of a vertical climb; with a couple of short drops here and there… LOL - many thanks for any insight you might offer!


I don’t have any real experience with distance sensors. Here’s a link to the Adafruit site which has many different sensors, but I don’t see a long-range one.

That a very good question. A quick Google search for Arduino Dimmer Bulb turned up this video (which includes a link for the dimmer module.) Again, I have ZERO experience with this product or how to use it. Looks like the code example and wiring diagram are included in the eBay listing.

Thanks for all your help, @Ogiewon. I’ll chase down those ideas you offered up; I’m now pursuing the ESP8266 project… I’ve DLed the Anything_Multiples_ESP8266wifi.ino for the ESP and when I Verify the code, I’m getting a lot of errors…

  • missing terminating " character
  • stray /342 in program
  • stray # in program

and several others; I cannot upload. I made sure to pulld own the ino file for this specific board. Thanks for any help pointers you can offer!


Did you pull down and install all of the libraries? Just download the zip file and copy the contents of the Arduino folder from the zip into your computer’s C:\users\yourUserName\Documents\Arduino folder.

Also, make sure you can build and run a simple example sketch for the ESP8266, like the blink sketch. This will help to make sure your Arduino IDE is properly set up for the ESP8266.

Final note, please use the v2.3 of the Arduino ESP8266 board manager to avoid a nasty memory leak issue.

Nailed it! I hadn’t copied the libraries. :smiley: Thanks for your patience on this, Dan. Now set up and humming. Really appreciated. Can I assume that this ESP8266 isn’t going to tolerate any other voltage? I’d like to place it elsewhere in the house and I’m now thinking about power supplies… thx - LL

The GPIO pins on the NodeMCU ESP8266 boards are rated for 0v to 3.3v. The NodeMCU Board is most easily powered via its microUSB connector. USB power comes in at 5vdc and is stepped down to 3.3vdc via an onboard voltage regulator chip.