Author Archives: Rob Reynolds

We <3 a DIY Valentine

via SparkFun: Commerce Blog

LEDs are great, and can make almost any project better. Well, unless you’re building discreet spy equipment, in which case you probably shouldn’t put a 3 mm PTH red or green LED on it (I’m looking at you, Hollywood!). And the more LEDs you can put on a project, the better, right? But did you know that you can create the illusion of way more LEDs than you actually have? Of course you know that, because you’re reading SparkFun’s blog post, which means you are no doubt fully aware of infinity mirrors. From @the_gella’s Infinity Mirror Heart Heels here at SparkFun to Yayoi Kusama’s Infinity Mirror Rooms at London’s Tate Modern (opening at the end of March and remaining there for a full year!), infinity mirrors are mesmerising, because they create the illusion of space beyond where it exists.

Yayoi Kumasa Room

One of Yayoi Kumasa's infinity mirror rooms. I'm going to start a bit smaller than that.

So I decided it was time for me to create one of my own. But I had other things I wanted to do as well. I like controlling things remotely, so I thought I should have some type of wireless control for the project. I also wanted to get familiar with MIT’s App Inventor. And of course, I’m always down to design and 3D print something new. Given all the things on this wish list, I decided to go with an infinity mirror with a microcontroller and either WiFi or Bluetooth (or both?), controlled via a simple and fairly uninteresting phone app that I would create, in a frame that was more than just a plain rectangular mirror. With Valentine’s Day just around the corner, I knew just what to do. I would create something that allowed me to send little visual messages up to my wife to let her know I’m thinking of her. Allow me to share with you the “I Heart You Infinity”!

alt text

My "I Heart You Infinity" build. See, because it's a heart, with infinity mirrors, and, well, you get it.

INFINITY... AND EVEN MORE INFINITY!

A two-plane infinity mirror like this is about as simple as infinity mirrors can get. A quick internet search will show a myriad of infinity pyramids, infinity cubes - even infinity dodecahedrons. But no matter how many sides or edges, they all do the same thing, They create the illusion of many rows of lights from just a single row. For most makers, this means a strip of addressable LEDs. This allows for more than just a simple “lights on/lights off” display. A strip of RGB LEDs allows for a quarter of a million colors, along with movement effects like theatre chases and rainbow fades. Since I’m trying to keep my build fairly compact, I decided to use our Skinny RGB 144 LED strip.

Many of my builds are predicated on what board is the closest. For this build, I had a SparkFun ESP32 Thing well within arm’s reach, so that’s what I used...and that's the entire parts list. A Thing Plus and a strip of addressable RGB LEDs. I’m also using a 2 Ah Lithium Ion Battery, but this could just as easily be powered by a wall wart.

THE CODE

There is nothing spectacular or earth-shattering about the code. Create a Bluetooth instance, connect, then wait for incoming signals. When a signal is received, do what it says. Since I didn’t know what effects I wanted when I started coding this project, I simply set it to receive numbers in the if statements, figuring I could just name the functions as I created them. If you want to take a closer look at the code, it's in my GitHub repo, linked at the end of this post.

THE APP

While I’ve done some app work the old fashioned way, I'd been hearing more about the MIT App Inventor and wanted to give it a shot. Turns out it’s an incredibly fast and simple way to develop apps, from initial layout all the way through to publishing. The interface is intuitive and user friendly, with two primary screens with which you’ll interact.

The first is the Designer screen, where you’ll insert all of your components, both visible (such as images, buttons, etc.), and non-visible (like lists and sensors ), and create the layout that you want. From there, it’s over to the Blocks screen, where you’ll do all of the programming for your components. Even though you’re using the fairly simple style of block-based coding, the App Inventor allows for quite complex functions. Aside from the standard built-in functions, each component type has its own list of functions that you can use.

My app build was super simple, as I wasn’t sure how long it was going to take me to implement. I drew up a quick logo of a heart with the infinity symbol inside it just to give the app some imagery (I also used it for the app icon), then added five buttons - one that’s a simple on/off toggle button, and four others that each trigger a different function for the LEDs. Next to the on/off button, I added a small light bulb icon that is bright yellow when the LEDs are on, and black when they are turned off.

Since this is my first build with App Inventor, it’s extremely primitive. However, I can see potential for some pretty advanced apps using this tool. One thing to note is that, sadly, at this point projects built in the App Inventor cannot be ported to iPhones, although that is something that they’re continuing to pursue.

alt text

The coding screen of MIT's App Inventor, with a screenshot of the app on my phone.

THE BUILD

The build of any simple infinity mirror is quite straightforward. At the back, I have 6-millimeter mirror acrylic; at the front, 3-millimeter clear acrylic with one-way mirror film. Sandwiched in between are my RGB LEDs. With no light on the inside, the mirror film acts just like a mirror to anyone looking at it. However, once the LEDs are illuminated, they become visible through the mirror film. Their image bounces back and forth between the two mirrors for infinity, or at least for a couple dozen or so times, depending on their brightness. For the enclosure, I drew up a quick two-part heart, with a solid back and an open front, and printed that out. Then I realized the the enclosure should probably be able to house the battery and the ESP32 Thing as well, so rather than redesign and reprint it, I simply designed a base that could hold everything. I gave it a couple of little hearts and an infinity symbol to keep with the theme, and printed it in two colors, just because I can.

3D parts on printer bed

The printed parts sitting proudly on the bed of their printer. Dual extruders allow for two-color printing.

PUTTING IT TOGETHER

The final result came out pretty well. The heart is cute, infinity mirrors are always amazing, and I can now send my wife a quick light-up message letting her know I’m thinking of her, and will love her for infinity.

If you want a closer look at all of the parts and pieces, I’ve put them into a GitHub repo. Use them, change them around, have fun with them, and let someone know you love them in an exceptionally nerdy way, using the magic of Bluetooth and addressable LEDs!

Infinity Heart Chasing

The "I Heart U Infinity" in action. And yes, I do have a singerie in my home. The question is why don't you?

comments | comment feed

Can I Give You a Lift?

via SparkFun: Commerce Blog

When you reach a certain age, you begin to notice that friends of yours are starting to have kids. You might even notice that you’re having kids yourself. With a little luck (and perhaps a bit of nudging), hopefully your kids will get interested in science or engineering at an early age.

It’s extra sweet when your friend’s kids get interested in engineering, and they come to you. Such was the case recently with a very dear friend of mine. It turns out that his three-year-old son is completely obsessed with elevators. Their local mall has glass enclosed elevators, and this eager young learner can watch them go up and down for hours. However, since hanging around the mall for hours on end isn’t really an option right now, my friend asked for advice. He wanted a toy elevator for his boy, but couldn’t find anything commercially available that really fit what he wanted. So he asked if I knew anyone who might be able to come up with a design closer to what he thought his son would like. After listening to his description, and not knowing any makers in his area, I told him that I would be happy to make an elevator for his son.

Elevator
The elevator, almost complete. Clear acrylic on the sides and back allow him to watch the mechanics of it.

The design I came up with...well, actually the design I came up with was way over-designed and far too complicated to pull off in the amount of time I had, especially for someone that young. So the design I settled on was a two-story elevator, using MicroRax for the framing, a combination of laser cut acrylic and 3D-printed parts for the wall enclosures, using a small stepper motor and belt that I had harvested from an old printer, plus a couple of continuous rotation servos and controlled with a slightly older SparkFun RedBoard that I had on hand, and a SparkFun EasyDriver Stepper Motor Driver. Some illuminated buttons and LEDs rounded out the parts list.

Elevator Parts

A small stepper motor with gears and a steel slide harvested from an old printer, with a 3D-printed motor mount and counterweights.

I used the longest of the MicroRax lengths for the height, which in hindsight might not have been the best idea. Creating the enclosure before I figured out how and where I was going to put all of the internal components was just poor practice. Oh well, another lesson learned...again. Components first; enclosure second. Once I assembled the framing, I took measurements then set to cutting the acrylic. Then it was a matter of putting everything inside. Once I began that process, it became clear that I had not left myself enough room to fully open the elevator doors. My options were to either make the enclosure larger and re-cut all of the acrylic, which probably wasn’t possible since my acrylic pile is now mostly small scraps, or just make the elevator doors a little narrower. Since I still had just barely enough acrylic to re-cut the front panel, that’s what I did.

Car and Door

I cut the car out of clear blue acrylic, and the door and mechanism were acrylic and 3D-printed parts.

I printed a counterweight for the elevator car, adjusting the fill percentage so that it was almost the same weight as the elevator car. Since I was already using harvested printer parts, I grabbed three rails as well - one for the counterweight and two for the car. I cut them to length and created sliders to attach to the car. I found some rack-and-pinion files online, but none that really suited my needs. I did a little design work, and after a few iterations, had just what I needed. It might not have been the most elegant solution, but often, especially when time is of the essence, I have to remind myself that “perfect is the enemy of done."

As far as the control motors go, I generally trust servos to be “eh, close enough" and steppers to be “yeah, that’s definitely precise enough." However, since this will be out of my hands, in the hands of a young boy, and too far away for me to readily fix, I don’t know that even steppers can be considered fail-safe. So I tapped back into my theatre days, where everyone knew that if you want something to stop at the same place, at the same time, every time, you put limit switches at each end of its travel. So in an effort to make the elevator as child-proof kid friendly as possible, I added six limit switches - two for the elevator car and two for each elevator door. This way, if the belt slips, or a door gets jammed, the travel distance isn’t relying on precoded math, it’s hitting a physical limit switch every time it travels, and that brings me a little peace of mind.

The coding is straightforward and simple. Since we’re using continuous rotation servos, all we do is set the speed and have them run until they hit the limit switch. The same goes for the stepper motor operating the elevator car - run CW or CCW until you hit a switch. I’m still finalizing the LEDs. I know that the blue LED over each door illuminates when the car is on that floor, but we’ll see how I light up the buttons. So many possibilities.

Zane's Elevator

Lest there be any confusion, this is Zane's Elevator!

I always enjoy sparking interest or excitement in a child when it comes to engineering - almost as much as I love the chance to help out an old friend. Did you create any cool builds this year for your kids, or even someone else’s? Was it due to an interest they showed in something, or an interest you were trying to pique in them? We always love to hear what our products are being used for out in the wild, so drop us a note in the comments and let up know what you've made that sparked wonder in the eyes of a child! Happy Hacking!

comments | comment feed

Halloween One-Day Build

via SparkFun: Commerce Blog

Years ago while still living in NYC, I worked on several in-house videos for a large company. The director was a great guy who loved Halloween - so much so that every year he used all of his vacation time in October to create the greatest Halloween home imaginable. He started planning in February, meeting with scenic designers and landscapers (yeah, that’s the level of commitment we’re talking about here), so every year when October rolls around and I haven’t even thought about building props or wearables for Halloween, I feel like I'm shirking my maker responsibilities.

This year, however, promises to be different. Because I’m more prepared? No, of course not! But because creating scary scenes has gotten easier, thanks to some recent additions to SparkFun’s Qwiic line of products. While our products have always been great for small scary builds and wearables, recent upgrades and additions to our line of Qwiic relay boards now make it simple to control larger components like strobe lights, fog machines, projectors, and a myriad of other AC-powered devices.

alt text
A ghoul and a few tombstones, then a smoke machine, strobe light, string lights, and you're all set!

Since the idea was to demonstrate how fast and easy a Halloween build could be, I simply used a few parts that I had on hand. Luckily we just released the Qwiic Dual Solid State Relay, and I had a Qwiic Quad Solid State Relay from its recent release. A couple of sensors and one of my perennial favorites, the Qwiic MP3 Player, and I was set.

Since, as I’ve pointed out on several occasions, working with the AC side of a relay can be dangerous, I set out to create a safer way to connect high side components. Having done electrical work, my first thought was just to pick up a junction box from Lowe’s and throw something functional together. But then I thought, why not add a little form to the function? Planning to use both a Qwiic Quad and Qwiic Dual Relay, I knew I might want up to six controllable AC outlets, so I picked up an appropriately-sized power strip.

Unaltered Power Strip
When opening up a power strip you may find security screws. The right tool kit should get you in.

Opening it up and looking at the internals, it almost appeared as if the rails were designed to be modular. At each of the six outlets, there was a hole in the rail as if it were designed to accept an incoming soldered line. There were also vertical indents between each outlet, indicating to me that the rails were meant to be cut to varying lengths, so that’s what I did. By isolating each outlet on the hot rail, and leaving the other two intact, I can now safely control each outlet individually with the Qwiic Relays.

Hacked Power Strip
You're playing with high power here, so proceed with caution.

In the end, I went with four relays controlling AC outlets, and the other two relays controlling low voltage DC lines. If you’re planning on doing something like this and wind up not using all of the outlets on your power strip, I definitely recommend throwing a wire nut on the ends of the wires not running to a relay. While the lines are in fact isolated, it’s just not good form to leave wire ends exposed, hot or not.

HalloweenComponents
The components for the Halloween build, Qwiic and simple!

The code is very straightforward. The PIR starts the MP3 Trigger and turns on the walkway lights (Relay 1 on the Qwiic Quad Relay). Following that, the proximity sensor triggers the remaining five relays as the victim - I mean, the happy Halloweener - gets closer. The cross-light on the tombstones, the fog machine, the strobe light, the up light on the ghoul, along with his green eyes all fire at predefined distances. I tested the system using very short distances that I could trigger at my workbench using my hand, then increased those values for the final build. Additionally, since each relay has a status light, I was able to test the entire setup with nothing on the high side.

/*
 * Qwiic & Easy Haunted House
 * By: Rob Reynolds
 * SparkFun Electronics
 * September 2020
 * 
 * This build utilizes the SparkFun Qwiic Solid State Relay Kit
 * along with the Qwiic Distance Sensor (VL53L1X).
 * SparkFun labored with love to create this code. Feel like supporting open source hardware?
 * Buy a board or two from SparkFun!
 * SparkFun Qwiic Solid State Relay Kit - https://www.sparkfun.com/products/16833
 * SparkFun Distance Sensor (VL53L1X) - https://www.sparkfun.com/products/14722
 * SparkFun Qwiic MP3 Trigger - http://librarymanager/All#SparkFun_MP3_Trigger
 * 
 * License: This code is public domain but you buy me a beer if you use 
 * this and we meet someday (Beerware license).
 */

#include <ComponentObject.h>
#include <RangeSensor.h>
#include <SparkFun_VL53L1X.h>
#include <vl53l1x_class.h>
#include <vl53l1_error_codes.h>
#include <Wire.h>
#include "SparkFun_Qwiic_Relay.h"

#define RELAY_ADDR 0x08 // Alternate address 0x6C
#define DUAL_RELAY_ADDR 0x0A //Alternate address 0x0B
Qwiic_Relay quadRelay(RELAY_ADDR); 
Qwiic_Relay dualRelay(DUAL_RELAY_ADDR);

#include "SparkFun_Qwiic_MP3_Trigger_Arduino_Library.h" //http://librarymanager/All#SparkFun_MP3_Trigger
MP3TRIGGER mp3;

#include "SparkFun_VL53L1X.h" //Click here to get the library: http://librarymanager/All#SparkFun_VL53L1X

//Optional interrupt and shutdown pins.
//#define SHUTDOWN_PIN 2
//#define INTERRUPT_PIN 3

SFEVL53L1X distanceSensor;
//Uncomment the following line to use the optional shutdown and interrupt pins.
//SFEVL53L1X distanceSensor(Wire, SHUTDOWN_PIN, INTERRUPT_PIN);

const int motionPin = 2; // Pin connected to motion detector
int proximity = 0;

void setup(void)
{
  Wire.begin();

  Serial.begin(115200);
  Serial.println("Halloween Build 2020");

  if (distanceSensor.begin() != 0) //Begin returns 0 on a good init
  {
    Serial.println("Sensor failed to begin. Please check wiring. Freezing...");
    while (1)
      ;
  }
  Serial.println("Sensor online!");

  // Let's make sure the relay hardware is set up correctly.
  if(!quadRelay.begin())
    Serial.println("Check connections to Qwiic Relay.");
  else
    Serial.println("Qwiic Quad Relay checks out!");

  if(!dualRelay.begin())
    Serial.println("Check connections to Qwiic Relay.");
  else
    Serial.println("Let's haunt this house!");    

   //Check to see if Qwiic MP3 is present on the bus
  if (mp3.begin() == false)
  {
    Serial.println("Qwiic MP3 failed to respond. Please check wiring and possibly the I2C address. Freezing...");
    while (1);
  }

  mp3.setVolume(25); //Volume can be 0 (off) to 31 (max)

  pinMode(motionPin, INPUT);
  pinMode(LED_BUILTIN, OUTPUT);

  delay(6000); //Give the PIR a chance to get settled 
}

void loop(void)
{
  proximity = digitalRead(motionPin);
  distanceSensor.startRanging(); //Write configuration bytes to initiate measurement
  while (!distanceSensor.checkForDataReady())
  {
    delay(1);
  }
  float distance = distanceSensor.getDistance(); //Get the result of the measurement from the sensor
  distanceSensor.clearInterrupt();
  distanceSensor.stopRanging();

  Serial.print("Distance(cm): ");
  Serial.println(distance);

  if (proximity == HIGH) // If the sensor's output goes high, motion is detected
  {
    mp3.playTrack(1);
    digitalWrite(LED_BUILTIN, HIGH);  // turn LED ON for testing purposes
    quadRelay.turnRelayOn(1);         // Turn on runway lights
    Serial.println("Relay 1 is hot.");
    pinMode(motionPin, OUTPUT);
    delay(50); 
  } 

  //NOTE: If the following values are not bracketed to a apecific range
  // and you're using < x, your "else if" statements need to be in
  //ascending numeric order

  if (distance < 1000){
    quadRelay.turnRelayOn(4); //Ghoul uplight
    dualRelay.turnRelayOn(2); //Ghoul Eyes
    Serial.println("Relay Q4 and Relay D2 are hot.");
    delay(50);
  }

  else if (distance < 2500){

    quadRelay.turnRelayOn(3);       // Turn lightning on
    Serial.println("Relay 2 is hot.");
    delay(750);
    quadRelay.turnRelayOff(3);      //Turn lightning off
    delay(250);
  }

  else if (distance < 3000){
    dualRelay.turnRelayOn(1); //Turn on hacked Fog Machine trigger
    Serial.println("Relay D1 is hot.");
    delay(3000);
    dualRelay.turnRelayOff(1);  // Turn off hacked Fog Machine trigger
    delay(50);
  }

  else if (distance < 3500){
    quadRelay.turnRelayOn(2); //Tombstone sidelights
    Serial.println("Relay Q2 is on.");
    delay(50);
  }

  if (mp3.isPlaying() == true){
    Serial.println("Your song is currently playing.");
    Serial.println();
    digitalWrite(LED_BUILTIN, HIGH);
    pinMode(motionPin, OUTPUT);     
  }

  else if (mp3.isPlaying() == false && distance < 4000){
    Serial.println("Your song is no longer playing");
    Serial.println("but the room is still occupied.");
    Serial.println();
    digitalWrite(LED_BUILTIN, LOW);
  }

  else if (mp3.isPlaying() == false && distance > 4000) {
    Serial.println("Your song is not playing.");
    Serial.println("The room is empty.");
    Serial.println();
    digitalWrite(LED_BUILTIN, LOW);
    pinMode(motionPin, INPUT);
    quadRelay.turnAllRelaysOff();
  }


  delay(500);
}

Once I had it loosely working, I set it up at full scale and filmed it...and found some issues (really, one issue in particular). The readings from the VL53L1X Distance Sensor seemed to be hopping around quite a bit, setting off relays at unexpected times. But overall, for a single day build of an initial layout, I think it’s a pretty solid proof of concept.

If I were to continue with this project and set it up outside my house for trick-or-treaters, there are definitely some changes I would make. The VL53L1X Distance sensor is only good for about 4 meters, so I would probably change that out and use a longer range sensor, probably something like the LIDAR-Lite v3HP. Additionally, I would probably figure a different playback method for the music. I would like to have music start when it senses a presence, then have thunder to accompany the lightning, as well as some howls or screams as the subject wanders through the room or gets closer to my front door. Since the Qwiic MP3 Trigger isn’t polyphonic, I would either need two MP3 Triggers (using a Qwiic MUX), or perhaps I could add an external audio player to the first relay. There are options.

Of course, since this Halloween will look nothing like any Halloween any of us has ever seen, and trick-or-treating has already been cancelled in municipalities across the country, perhaps my next four weeks would be better spent building a mechanism that launched candy bars from my front porch out to the street, basing the force of the throwing arm on information garnered from the proximity sensor. And if that goes well, who knows, maybe next year I can bring in the landscape architects.

comments | comment feed

Touchless light show with the Qwiic Dual Solid State Relay

via SparkFun: Commerce Blog

Last week we released the SparkFun Qwiic Dual Solid State Relay, and as is usually the case, I was tasked with learning about it, then scripting and filming a video to tell all of you about it. This happens pretty much every week, and while the varying technologies of each new product come with their own learning curves, recent wrinkles like supply chain issues and the limited time I can spend at SparkFun (for employee safety) have added new wrinkles into the timeline of releasing a new product.

SparkFun Qwiic Dual Solid State Relay

SparkFun Qwiic Dual Solid State Relay

COM-16810
$149.95

Naturally we keep a schedule of what products we’re expecting to release in the coming weeks. I pore over datasheets, read through the libraries our engineers are building, and try to come up with ideas that might make for an interesting demo build. Of course, working from home is not the same as heading into SFHQ every day. The ideas that race through my mind haven’t changed, but the inventory on hand certainly has. There have been times over the past six months when I have come up with a build idea, only to have my dreams dashed when I dig through my parts drawer and find that I don’t possess the component around which I was planning my build. This week was a good example of that. I knew that I had multiple VL53L1X Distance Sensors on hand, but knowing that they have a hardware defined I2C address, I knew that I would need a Qwiic MUX Breakout to use more than one of these sensors. And it turned out that I didn't have a MUX on hand. So I pulled the Qwiic VCNL4040 Proximity Sensor off of a previous project, and proceeded forward.

Proximity sensors
VL53L1X Proximity sensors aplenty, but without a MUX, I'm limited to using only one

Sometimes this theoretical portion of my work week ("this should work...theoretically") leads me right up the moment when I have to start filming the new video. Such was the case this week. I didn’t get my hands on the Qwiic Dual SSR until I arrived at SFHQ to do the filming. Luckily I had completed the outline for the video, as well as the sketch for the demo build, so I figured it would be as simple as connecting the relay board via its Qwiic connector, wiring the load side and watching it work.

That’s not exactly how it happened.

alt text
Even though the ranges of the two sensors differ, for this build they were both perfectly suited

I connected everything together and powered it up, and nothing happened. Since I had written and tested the sketch on a different Qwiic relay board, I figured that since our Qwiic Relay Library for Arduino is universal across all of our Qwiic Relay boards, all I’d need to do would be to change the I2C address, and everything would work perfectly – but it didn’t. I checked all of the connections, examined my sketch, looked at the library to make sure I was using the correct I2C address for the new Dual Solid State Relay board, and all of it checked out.

I ran an I2C sniffer, and voila! Even though the board powered up, and I got the status light, I was not receiving an I2C address from the board. With the timeline we impose on ourselves for many of our boards, there will be times when a board will come up to the Marketing department hot off the reflow oven so that our (amazing) photographer Juan can get images of the component and get them to the folks who are putting together the product web page. Sometimes in the process, the components accidentally bypass the firmware flash stage. I simply took the board down to production, they flashed it, I plugged it back into my setup, and everything was Jake!

The code for the project was just a very basic amalgamation of the first examples of each of the VL53L1X distance sensor, the VCNL4040 Proximity Sensor, and the Qwiic Dual Solid State Relay. I added a delay in the void loop so I could watch the proximity digits for each sensor, then used those to set the limits to trigger each of the two relays.

/*
 * Dual Solid State Relay Demo
 * Rob Reynolds, SparkFun Electronics, September 2020
 * Using two separate sensors, this demo
 * toggles the two relays of the SparkFun Qwiic
 * Dual Solid State Relay on and off as you
 * hold your hands over the sensors.
 * 
 * SparkFun labored with love to create this code. Feel like supporting open source hardware?
 * Buy a board or two from SparkFun!
 * SparkFun Qwiic Dual Solid State Relay - (https://www.sparkfun.com/products/16810)
 * SparkFun Distance Sensor Breakout VL53L1X - (https://www.sparkfun.com/products/14722)
 * SparkFun Proximity Sensor Breakout VCNL4040 - (https://www.sparkfun.com/products/15177)
 * 
 * License: This code is public domain but you buy me a beer if you use 
 * this and we meet someday (Beerware license).
 */

#include <Wire.h>

//**********VCNL4040 Setup here***************
//Click here to get the library: http://librarymanager/All#SparkFun_VCNL4040
#include "SparkFun_VCNL4040_Arduino_Library.h"
VCNL4040 proximitySensor;

//*********VL53L1X Setup here***************
#include <ComponentObject.h>
#include <RangeSensor.h>
#include <SparkFun_VL53L1X.h>
#include <vl53l1x_class.h>
#include <vl53l1_error_codes.h>
#include "SparkFun_VL53L1X.h" //Click here to get the library: http://librarymanager/All#SparkFun_VL53L1X

SFEVL53L1X distanceSensor;

//************Here's the Dual SSR section***********
#include "SparkFun_Qwiic_Relay.h"
#define RELAY_ADDR 0x0A // Alternate address 0x6C
Qwiic_Relay dualRelay(RELAY_ADDR); 

void setup()
{
  Serial.begin(115200);
  Serial.println("SparkFun VCNL4040 Example");

  Wire.begin(); //Join i2c bus

  if (proximitySensor.begin() == false)
  {
    Serial.println("Device not found. Please check wiring.");
    while (1); //Freeze!
  }

  if(!dualRelay.begin())
    Serial.println("Check connections to Qwiic Relay.");
  else
    Serial.println("Dual Relay Light Show!!");

  Serial.println("VL53L1X Qwiic Test");

  if (distanceSensor.begin() != 0) //Begin returns 0 on a good init
  {
    Serial.println("Sensor failed to begin. Please check wiring. Freezing...");
    while (1)
      ;
  }
  Serial.println("Sensor online!");

  dualRelay.turnAllRelaysOff();

  delay(1000);
}

void loop()
{
  //Get proximity value. The value ranges from 0 to 65535
  //so we need an unsigned integer or a long.
  unsigned int proxValue = proximitySensor.getProximity(); 

  Serial.print("Proximity Value: ");
  Serial.print(proxValue);
  Serial.println();

  delay(10);

  if (proxValue > 12){
    dualRelay.turnRelayOn(1);
    delay(50);
  }

  else if (proxValue < 12){
    dualRelay.turnRelayOff(1);
    delay(50);
}

  //********VL53L1X section*************
  distanceSensor.startRanging(); //Write configuration bytes to initiate measurement
  while (!distanceSensor.checkForDataReady())
  {
    delay(1);
  }

  int distance = distanceSensor.getDistance(); //Get the result of the measurement from the sensor
  distanceSensor.clearInterrupt();
  distanceSensor.stopRanging();

  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println();

  if (distance < 400){
    dualRelay.turnRelayOn(2);
    Serial.println("Relay 4 is hot.");
    delay(50);
  }

  else if (distance > 400){
    dualRelay.turnRelayOff(2);
    delay(50);
  }

  //delay(500); //uncomment this delay for testing
}

Again, when working on the high voltage side, make sure that you are knowledgeable and comfortable with that level of potentially lethal voltage. Even though we have built safety measures into this board, like ground isolation between the relay and control circuitry and a milled out area isolating each side of the AC, without proper attention to detail this can be a dangerous product. If you're not quite ready to wire up your own AC lines, the IoT Power Relay is a good solution while you increase your knowledge of high voltage circuits.

If you are planning on creating your own light show, or any other relay-driven project, don't forget that you're not limited to a pair of relays on a single board. Since the ATTiny84A on the Dual Solid State Relay is software configurable, and communicates over I2C, you can daisy-chain over one hundred boards together, allowing you to create an entire light wall that you control by waving your arms around. Yeah, now who's DJ GOAT?!

Evil genius at work

Choosing the proper music is paramount to feeling like you might actually be able to take over the world

comments | comment feed

Solar Cooking with Maximum Efficiency

via SparkFun: Commerce Blog

Twice every year, in February and September, the world’s top fashion designers, as well as younger up and coming designers, descend upon NYC to show off their designs for New York Fashion Week. Designers will easily spend six figures to get the set and venue to look exactly the way they want to best showcase their collection, in a show that usually lasts for no more than 20 minutes. After that, much of the materials are reused or recycled, but some of it deemed not reusable simply gets thrown out. This can be a maker’s dream.

I spent seven years working with one of the top companies in NYC responsible for designing, building and installing everything in those fashions shows that wasn’t clothing - the backdrops, the prostheniums, the runways, the lighting. We used every conceivable material, so I had access to lots of those materials, saving them from the dumpster and giving them new life in a string of hare-brained projects.

This is where I built my first solar hot dog cooker. To say it was primitive in its construction would be overselling it. Some scraps of wood, a scrap of mirror acrylic, and for the skewer a steel rod that I wiped off with a paper towel, and that was it. To pan the unit, I just dragged it slightly to the west. And to tilt, I had a piece of wood that I just screwed into the side of it, and adjusted by screwing it in at different heights. Now, years later, I decided it was time for an upgrade.

alt text
Me, upside down and somewhat distorted, in the reflection of the SparBcue solar cooker

Luckily, with the release of our new SparkFun ProDriver, controlling the movement with a pair of 125 oz.in stepper motors was incredibly simple. Four photocells measure the light discrepancies across both the X and Y axes, and that information is used to keep the unit pointed directly at the sun.

As for actually cooking the hot dogs (or whatever you decide to throw on the skewer) we rely on the beauty of the parabola. The sides are ¼” plywood with minimal 1”x2” framing, and ⅛” mirror acrylic bent into a parabolic arc, with the skewer at the focal point. I laid out the points on one of the sheets of plywood, then clamped the two sheets together and drilled small holes along the arc, with another set of holes slightly inside the first. Through these holes I put small finishing nails to hold the bent acrylic sheet in place.

Parabola Layout
My original layout sketch for the parabolic arc for my Solar Hot Dog Cooker v.1.

A basic lazy Susan swivel plate is used to pan the device from east to west, belt driven from one of the stepper motors. For tilt, a threaded rod on the second stepper motor changes the angle. This is perhaps more precise than this build requires, but seemed the simplest way to achieve the necessary movement on this axis. A single hinge point at the front and dual hinge points at the rear allow for proper tilt, with the dual rear hinge points guaranteeing that the threaded rod remains in alignment throughout the entire range of the SparBcue.

alt text

Hinging the motor mount as well as the threaded T-nut receiver maintains alignment of the threaded rod.

To track the sun, I’m using four photocells, one on each corner of the cooker, in 3D-printed enclosures. The application is quite simple - take measurements from all four sensors, then do some averaging. If the top is darker than the bottom, tilt up until they’re once again evenly illuminated. Then do the same thing for left and right. I had tried a build like this several years ago using a pair of servo motors, but this was the first time I had tried it on this scale, and with stepper motors. It actually works quite nicely.

/*
  SparBcue by Rob Reynolds @ SparkFun 2020
  A Sun Tracking Solar Hot Dog Cooker

  This board uses two SparkFun ProDrivers and two stepper motors
  Feel like supporting open source hardware?
  Buy a board from SparkFun! https://www.sparkfun.com/products/16836

  This code is free to use, alter,and distribute, but if you find it useful
  and we meet some day at the local, you buy me a beer. (Beerware License)

  Hardware Connections:

  ARDUINO --> PRODRIVERs
  D8 --> STBY   PRODRIVER1 and PRODRIVER2
  D7 --> EN     PRODRIVER1 and PRODRIVER2
  D6 --> MODE0  PRODRIVER1 and PRODRIVER2
  D5 --> MODE1  ***PRODRIVER1 only***       (LATCH PIN 1)
  D4 --> MODE2  PRODRIVER1 and PRODRIVER2
  D3 --> MODE3  PRODRIVER1 and PRODRIVER2
  D2 --> ERR    PRODRIVER1 and PRODRIVER2

  ARDUINO --> PRODRIVER2
  D9 --> MODE1  ***PRODRIVER2 only***       (LATCH PIN 2)

*/

    #include <Servo.h>  //Library to manage Servo

#include "SparkFun_ProDriver_TC78H670FTG_Arduino_Library.h" //Click here to get the     library: http://librarymanager/All#SparkFun_ProDriver
PRODRIVER myProDriverVert; //Create instance of the vertical stepper motor
PRODRIVER myProDriverHor; //Create an instance of the horizontal stepper motor

#define myProDriverHorLatchPin 9; //The latchpin for the 2nd driver must be defined.     (The first driver latchpin is predefined.)

//Assigning photocells
int pctopl = A2; //top left LDR green
int pctopr = A1; //top right LDR yellow
int pcbotl = A3; // bottom left LDR blue
int pcbotr = A0; // bottom right LDR orange

int tol = 50; //Set tolerance so that minor light difference don't trigger movement.     Adjust as needed.

Servo skewerServo; // A continuous rotation servo spins the skewer

int pos = 90; //This sets speed of continuous rotation servo to 0

void setup() {
  Serial.begin(115200);
  Serial.println("SparkFun ProDriver TC78H670FTG Sun Tracking Solar Cooker");

  skewerServo.attach(10); //Attach the servo to pin 10

  // myProDriver2
  // Note, this must be setup first because of shared lines.
  myProDriverHor.settings.controlMode = PRODRIVER_MODE_SERIAL;
  myProDriverHor.settings.mode1Pin = myProDriverHorLatchPin; // latch pin
  myProDriverHor.begin(); // calling this first ensure latch pin 2 will be low     during other future .begin()s

  // myProDriver1
  // default latch pin is D5, so no need to change here
  myProDriverVert.settings.controlMode = PRODRIVER_MODE_SERIAL;
  myProDriverVert.begin();

}

void loop() {

  skewerServo.write(75); //spin the skewer forever

   //capturing analog values of each photocell
  int topl = analogRead(pctopl); //Read top left photodiode
  int topr = analogRead(pctopr); //Read top right photodiode
  int botl = analogRead(pcbotl); //Read bottom left photodiode
  int botr = analogRead(pcbotr); //read bottom right photodiode
  // calculating average
  int avTop = (topl + topr) / 2; //average of top photocells
  int avBot = (botl + botr) / 2; //average of bottom photocells
  int avLeft = (topl + botl) / 2; //average of left photocells
  int avRight = (topr + botr) / 2; //average of right photocells

  // Print values for testing
  Serial.print("Average Left: ");
  Serial.println(avLeft);
  Serial.print("Average Right: ");
  Serial.println(avRight);
  Serial.println("Average Bottom: " + String(avBot));
  Serial.println("Average Top: " + String(avTop));
  Serial.println();

  if ((avTop + tol) < avBot){

    myProDriverVert.step(50,0); //Turn CW
    delay(10);
    Serial.println("Move Up");
  }

  else if ((avTop - tol) > avBot) {

    myProDriverVert.step(50,1); //Turn CCW
    delay(10);
    Serial.println("Move Down");
  } 

  if ((avLeft + tol) < avRight) {

    myProDriverHor.step(50,0); //Turn CW
    delay(10);
    Serial.println("Move Left");
  }

  else if ((avLeft - tol) > avRight){

    myProDriverHor.step(50,1); //Turn CCW
    delay(10);
    Serial.println("Move Right");
  }
  Serial.println();

  delay(5000); //Give it a little time between readings.

}

alt text
When aligned to the sun, you can see beams of light, as well as shadows from the nails, all converging on the focal point.

ISSUES AND UPDATES

During the construction, I learned that one of the two 125 oz.in stepper motors was faulty. As I knew I wouldn’t be able to get another before the build had to be completed (unless I wanted to shoot the video with the device untested), I went with a slightly smaller stepper motor with less torque. While it did work, it made a pretty terrible sound that indicated that it probably wouldn’t be a very good long term solution. As soon as I get another 125 oz.in stepper motor, I’ll swap that back in.

The SparBcue is currently powered by a 5V lithium ion battery pack for the RedBoard and continuous rotation servo, and a 12V battery to power the two stepper motors. The steppers need a lot of torque, and therefore a lot of power, so I don’t know that I’ll be able to change out this power source. However, to run the board, I’m planning on swapping out the battery pack with a solar panel. I also need to do a little work on the gear on the skewer. While the gears themselves are fine, their attachment to the skewer is questionable at best. I'm also considering adding a potentiometer to allow for adjustment of the tolerance on the fly. An additional pair of potentiometers might be useful for getting a rough focus towards the sun before engaging its tracking. Hey, if something's worth engineering, it's worth overengineering, right?

Happy cooking, and Happy Hacking!

alt text

The perfect time of day - SparBcue in the sun, chair in the shade, and cold drink in the hand (you'll have to take my word on that last one).

comments | comment feed

So you want to talk about RFID

via SparkFun: Commerce Blog

Radio Frequency Identification, or RFID, has been around in some form since the mid 1940s. Léon Theramin’s listening device for the Soviet Union and Sir Robert Alexander Watson-Watt’s Identify Friend or Foe (IFF) system were both developed and used during WWII as early examples of using radio frequency to identify objects.

Today, we use RFID technology for everything from office security and access control, to high speed roadway toll payments, to hospital infant tracking, to race timing. The list of applications is extremely long, but they all come down to the same three things - an RFID tag, an RFID reader and a computer or microcontroller to control what happens with the information.

With Automatic Identification and Data Capture (AIDC) devices and technology racing forward, now is a great time to start working with RFID devices. Can you imagine going to the supermarket, filling your cart, and then just walking out as an RFID reader captures the information from the tags on every one of your items? It may sound a bit futuristic, but right now our Simultaneous RFID Reader is capable of reading up to 150 tags per second. Pair that with the proper antenna, and you’ll get a reading range of almost five meters! Not only does that make it seem like checkoutless shopping might not be too futuristic, but it sounds like you might even be able to create that type of system yourself!

Getting started with RFID is as easy as taking candy from a... candy vending machine.

If you’re new to RFID, this video will give you a brief overview, plus show you a recent RFID project I put together with just a few Qwiic boards, a servo, and a quarter-dozen LEDs. Then head over to our RFID page for more ideas and inspiration! And if you have an amazing RFID project, or even an amazing idea for one, we want to hear about it in the comments!

Happy Hacking!

 

comments | comment feed