Monthly Archives: June 2020

Summer Camp – SparkFun Style

via SparkFun: Commerce Blog

We know a lot of summer camps, trips and activities are up in the air, if not downright canceled this year. Not to worry - we’ve got some of your typical summer camp activities covered, with an electronics twist. Check out this summer’s activity schedule, and let’s have some fun!

Wooden trail sign with SparkFun Summer Camp and deal dates

Our summer camp schedule includes:

  • E-textiles: Kick your arts and crafts game up a notch by adding lights and sound to your projects - we see that rad patch you’re working on! (If you end up making a sweet summer camp patch, we’d love to see it! Share on social media and tag @sparkfun.)
  • GPS: Hiking and exploring nature can be tricky if you’re somewhere unfamiliar. Learn more about GPS and try making your own system.
  • Robotics: You could play a classic summertime sport or game – or you could build a robot and teach it to play with you (very slow, two-player tag, anyone?)!
  • Machine Learning: Ever tried to memorize the plants, bugs and animals you might meet in your local great outdoors? Maybe it’s time to have machine learning lend you a hand, so you don't learn the difference between poison ivy and Boston ivy the hard way.

Camp will kick off Thursday evening, July 2nd, and end on Friday, July 31, at 11:59 p.m. MDT. Our special summer camp page will be live on Thursday evening, and each week will have activities, projects and information to get you started on the different topics. While we’re at it, each theme will feature some sort of surprise, because who doesn’t love a sale? Check Thursday evenings for the latest surprise! Please note that we will be closed in observance of the July 4th holiday on Friday, July 3rd.

We’d love to see the projects that you create this summer! Please share with us on social media by tagging us on your post.

comments | comment feed

Nathan Seidle on IoT Radar

via SparkFun: Commerce Blog

We're popping in today to bring your attention to our LinkedIn page, where you can see Nathan talk about machine learning, artificial intelligence, tinyML, data logging with the Artemis OpenLog, and the origins of SparkFun with Wisse Hettinga at the IoT Radar.

Nate & Wisse

It's a fun interview, and you'll get a glimpse of some projects Nathan is working on at home! The interview is only up until July 3rd, so there are only a few days left to watch it.

comments | comment feed

Photodetector Gadget

via SparkFun: Commerce Blog

Hello and happy summer, everyone. This week we are pleased to release the new MAX30101 Qwiic Photodetector Breakout. This tiny board is a perfect addition to our line of Qwiic sensors and will surely find a place in your next project. Also this week we have the new Logitech K400 Wireless Keyboard for your computing and desktop applications, as well as two new sets of 2x20 headers for Raspberry Pi, Nvidia Jetson, and Google Coral boards. Let's jump in and take a closer look!

Go Gadget, Go!

SparkFun Photodetector Breakout - MAX30101 (Qwiic)

SparkFun Photodetector Breakout - MAX30101 (Qwiic)

SEN-16474
$19.95

The SparkFun Photodetector Breakout is an updated version of the SparkFun Particle Sensor Breakout and includes the MAX30101, a highly sensitive optical sensor and successor to the MAX30105 and MAX30102. The MAX30101 Breakout utilizes a photon detector to measure the amount of returning light reflected back from the LEDs. This is useful for various applications like particle (i.e. smoke) detection, proximity measurements and even photoplethysmography.


Logitech K400 Plus Wireless Touch Keyboard

Logitech K400 Plus Wireless Touch Keyboard

WIG-16300
$39.95

The Logitech K400 Plus Wireless Touch Keyboard is a compact keyboard with an integrated touchpad that puts all your controls in a single device. Comfortable, quiet keys and a large (3.5-inch) touchpad make navigation effortless. A wireless range of 10m (33') enables a responsive, uninterrupted connection in even the largest rooms. Watch video, stream music, connect with friends, browse web pages and more without annoying delays or dropouts.


Qwiic Power Switch

Qwiic Power Switch

SPX-16740
$6.95
Qwiic PT100 - ADS122C04

Qwiic PT100 - ADS122C04

SPX-16770
$29.95

Two new SparkX boards also released this week: the Qwiic Power Switch and the Qwiic PT100. The Qwiic Power Switch (QPS) will help you control some of the high-power Qwiic boards in the world, while the Qwiic PT100 will allow you to measure temperature with a 100 Ohm Platinum Resistance Thermometer (PRT).

Make sure to check them out and the rest of our SparkX rapid production products!


Extended GPIO Female Header - 2x20 Pin (13.5mm/9.80mm)

Extended GPIO Female Header - 2x20 Pin (13.5mm/9.80mm)

PRT-16764
$1.95
Extended GPIO Female Header - 2x20 Pin (16mm/7.30mm)

Extended GPIO Female Header - 2x20 Pin (16mm/7.30mm)

PRT-16763
$1.95

These 2x20 pin female headers (in 13.5mm/9.8mm and 16mm/7.3mm sizes) allow you to extend the reach of any board with the standard 2x20 GPIO pin footprint, like the Raspberry Pi, Google Coral, and NVIDIA Jetson. You can also solder it to Pi HATs that do not have headers on the board (assuming that the board is only populated on the top, or the height of the components do not get in the way if it is a two-layer board).


That's it for this week! As always, we can't wait to see what you make! Shoot us a tweet @sparkfun, or let us know on Instagram or Facebook. We’d love to see what projects you’ve made!

Never miss a new product!

comments | comment feed

Reflow Toaster Oven – a Qwiic Hack!

via SparkFun: Commerce Blog

While working from home during the past few months, I have greatly missed being able to throw some prototypes through the super nice SparkFun production reflow oven.

zoom in of solder paste reflowing in a toaster oven

Ahhh, so glad I didn't have to hand solder each of those blobs.

I really wanted a reflow oven in my garage, so after doing some research online, I decided to buy a cheap toaster oven and give this hack a try. Ultimately, I decided to use a standard hobby servo to automate the movement of the temperature knob like so:

alt text

Just like a push-pull linkage in a model airplane!

Although slightly less elegant than some of the other methods out there, this servo control method works quite well. Additionally, it didn't require any modifications to the wiring of my toaster oven and was pretty darn cheap and simple to setup.

Research

I came across many blogs, websites and products dedicated to hacking toaster ovens into reflow ovens:

The most important things I learned were the following:

  1. Get a toaster oven with these features (I purchased the Black & Decker TO3000G, which was $59 new):

    • Analog dial control style
    • Quartz elements (two above and two below if you can)
    • A convection fan
    • Small or medium-sized
  2. A single thermocouple "floating" in the air near the PCB works fine. Note, a lot of the pro-end models have multiple temp sensors (at multiple points in the chamber and one touching the PCB), but I haven't found the need yet. The SparkFun Qwiic Thermocouple and braided thermocouple work great!

  3. Opening the door seems to be the only way to get a good and fast cool down. Even the ~$4,000 pro machines have the drawer open automatically to achieve good "free air" cooling. I have yet to automate this step, but so far I love watching the solder flow. When I see my reflow time is up, I have been manually opening the door. If I find the need to automate this in the future, I'll most likely get another servo or stepper motor involved.

  4. Most toaster ovens can't achieve an ideal ramp up rate of 1.5C/second, but that's okay. You can add a slower ramp up during your soak phase - a slow ramp up from 150-180. More on this later as we discuss the profile, the code and show some results.

Parts List

Manual testing

Before rigging up a servo to move the control knob, I first gathered parts and got my thermocouple readings working. Then the plan was to simply move the control knob manually (with my hand), and see if I could get a decent profile while watching the data plotter.

alt text

My very first attempt manually adjusting the knob by hand.

Following the profile suggestions in the CompuPhase article and reading what Wikipedea had, I decided to try for a profile represented by the blue line in the graphic above. The red represents the live readings from the thermocouple. Note: in all of my serial plotter graphics, the blue line is being plotted as a reference, and my controller is not analyzing the blue line in any way.

And so I tried again:

alt text

Second attempt adjusting temp knob by hand.

As you can see, I started taking notes to keep track of what was working and what was not. For my second attempt, I actually set the oven to "warm" for ten seconds before starting my plotter. The adjustments noted in the graphic were done by me physically moving the dial with my hand.

By my fourth manual test, I was pretty pleased with the results - not perfect by any means, but starting to look a bit like an actual profile:

alt text

Fourth attempt by hand, starting to look decent.

Servo Hack

Now that I knew a decent profile could be achieved by simply moving the temp dial, it was time to slap a servo on this thing and automate the movements!

First things first, I ripped off that control knob. A flat head screw driver helped greatly to get it started. Next, I mounted the servo horn to the knob with a servo mount screw in the center hole of the servo horn.

Temp knob removed. Mount with center point screw first.

Then, I drilled out two more holes for a good secure mount. Note: I'd make sure to align the positioning mark (that little silver thing) directly down. This will ensure that the servo linkage and rotation can achieve the full 180 degrees of motion.

Mounted servo horn with center screw. Horn mounting complete.

Next was actually mounting the servo to the oven. I had a scrap piece of wood that fit the job exactly, but anything that can extend the servo out past the face of the oven should work. I opted to use dual-lock hook and loop, but servo tape or double-sided foam tape would have worked too. Make sure to align properly both along the center point of the servo horns and the depth away from the oven.

Center point alignment. Depth alignement.

Finally, the last step was to link the two control horns. There are many ways to do this with various linkage hardware, but the simplest is to use bare control rods and add "Z-bends" at specific points. I first tried this with a single control rod, but it was much smoother with two!

Z-bend Dual control rod hooked up

The Code

The source code for the project can be downloaded from the GitHub repository here:

Using Example 1 from the Qwiic Thermocouple Arduino Library and a basic servo control example, I was able to piece together a sketch that accomplishes a pretty nice reflow profile.

Before diving into the code, I'd like to highlight the fact that this project does not use PID control to try and follow a set profile. I first proved out that manually moving the temp knob by hand could create a decent reflow profile. By watching the temperature and keeping track of time, my Arduino can determine the zone (preheat, soak, ramp up, reflow, cooldown). Once you know the zone, you can simply set servo to predetermined positions (or toggle on/off as in soak) to hold a close enough temperature or ramp up.

My plan was:

  1. Set full power
  2. Wait to see 140C, kill power, enter soak zone
  3. During soak, toggle power on/off to climb from 150C to 180C
  4. Once soak time is complete, turn on full power (enter ramp-up zone)
  5. During ramp-up, wait to see reflow temp (220C) (enter reflow zone)
  6. During reflow, toggle servo on/off to hold temp
  7. Once reflow time is complete, turn servo to "off," indicating user should open door

My main loop simply uses a "for loop" to get through the zones, then when it's done it stops with a "while(1)". It is updateServoPos() that actually determines the zone and updates a global variable.

void loop() {

for (int i = 0 ; i <= 4 ; i++) // cycle through all zones - 0 through 4.
{
    int tempDelta = abs(profileTemp[i + 1] - profileTemp[i]);
    int timeDelta = abs(profileTimeStamp[i + 1] - profileTimeStamp[i]);
    float rampIncrementVal = float(tempDelta) / float(timeDelta);
    currentTargetTemp = profileTemp[i];

    // Print data to serial for good plotter view in real time.
    // Print target (for visual reference only), currentTemp, ovenSetting (aka servo pos), zone
    for (int j = 0 ; j < (timeDelta - 1); j++)
    {
    currentTargetTemp += rampIncrementVal;
    Serial.print(currentTargetTemp, 2);
    Serial.print(",");

    if (tempSensor.available())
    {
        currentTemp = tempSensor.getThermocoupleTemp();
    }
    else {
        currentTemp = 0; // error
    }

    Serial.print(currentTemp);
    Serial.print(",");

    updateServoPos(); // Note, this will increment the zone when specific times or temps are reached.

    Serial.print(ovenSetting);
    Serial.print(",");

    Serial.println(zone * 20);
    delay(1000);
    totalTime++;
    }
}

// monitor actual temps during cooldown
for (int i = 0 ; i < COOL_DOWN_SECONDS ; i++)
{
    currentTargetTemp = 0;
    Serial.print(currentTargetTemp, 2);
    Serial.print(",");
    if (tempSensor.available())
    {
    currentTemp = tempSensor.getThermocoupleTemp();
    }
    else {
    currentTemp = 0; // error
    }
    Serial.print(currentTemp);
    Serial.print(",");
    updateServoPos();
    Serial.print(ovenSetting);
    Serial.print(",");
    Serial.println(zone * 20);
    delay(1000);
}
while (1); // end
}

The following function, updateServoPos(), is where the temperature and totalTime is checked to determine the zone we are currently in, and ultimately what servo positions are desired.

void updateServoPos()
{
    if ((zone == ZONE_preheat) && (currentTemp > 140)) // done with preheat, move onto soak
    {
        zone = ZONE_soak;
    }
    else if ((zone == ZONE_soak) && (soakSeconds > SOAK_TIME)) // done with soak, move onto ramp
    {
        zone = ZONE_ramp;
    }
    else if ((zone == ZONE_ramp) && (currentTemp > 215)) // done with ramp move onto reflow
    {
        zone = ZONE_reflow;
    }
    else if ((zone == ZONE_reflow) && (reflowSeconds > 30))
    {
        zone = ZONE_cool;
    }

switch (zone) {
    case ZONE_preheat:
        setServo(41);
        break;
    case ZONE_soak:
        soakSeconds++;
        if ((soakSeconds % 15) == 0) // every 15 seconds toggle
        {
            soakState = !soakState;
        }
        if (soakState)
        {
            setServo(100);
        }
        else {
            setServo(0);
        }
        break;
    case ZONE_ramp:
        setServo(100);
        break;
    case ZONE_reflow:
        reflowSeconds++;
        if ((reflowSeconds > 5) && (reflowSeconds < 10)) // from 5-10 seconds drop to off
        {
            setServo(0);
        }
        else {
            setServo(100);
        }
        break;
    case ZONE_cool:
        setServo(0);
        break;
    }
}

Some of these settings would surely need to be tweaked when using a different oven, thermocouple and servo setup. Slight variations in the servo hardware hookups will most likely require different servo positions settings to get the desired position on the temp knob.

Also, the position of the thermocouple can affect its readings, so each setup will most likely require different temperature trigger values (i.e. in the servoUpdatePos() function, you may need to adjust the if statements that determine the zone).

Last, paste and component size must be considered. After reflowing a few panels, I saw that the SAC305 paste I was using actually started reflowing closer to 220C, so I made that my target max reflow temp. And if I had huge components, these can act as heatsinks and may require a longer soak and/or higher peak reflow temp.

Results

alt text

My last profile cooking actual panels and looking good!

The above screenshot is from my latest achieved profile using servo control. The different colored lines represent the following:

  • Blue: Generic reference profile
  • Red: Temp readings showing actual profile in the oven
  • Yellow: Zones, stepping up through preheat, soak, ramp-up, reflow, cooldown
  • Green: Servo position, represented by 0-100 percent power

Although this last profile screenshot is the result of almost 20 test runs and 10 actual board panels reflowing, I would like to mention that even with some slight variation between profiles, all of my panels came out beautifully. A good paste job and proper placement of parts can greatly help your initial yield, but I even had a few sloppy paste jobs and they came out fine!

Conclusion

My complete setup in the garage. Panel in the oven.

If you're interested in reflowing some electronics using a toaster oven, it can be done using a simple Arduino, servo and thermocouple. It does take a little time to do some test runs and make slight adjustments to the provided Arduino sketch, but the results are pretty great! I currently have to watch the oven to manually open the door when it's done, but this could be automated. Plus, while one panel was in the oven, I simply started hand placing parts on the next panel and so no time was really lost.

If you would like to give this a try and have any questions, please reach out in the comment below or at the GitHub project repository.

Also, if you have any experience with solder reflow profiles, I'd love to hear your thoughts in the comments below.

Thanks for reading and cheers to some good DIY electronics SMD assembly!

Resources

comments | comment feed

Machine vision with low cost camera modules

via Arduino Blog

If you’re interested in embedded machine learning (TinyML) on the Arduino Nano 33 BLE Sense, you’ll have found a ton of on-board sensors — digital microphone, accelerometer, gyro, magnetometer, light, proximity, temperature, humidity and color — but realized that for vision you need to attach an external camera.

In this article, we will show you how to get image data from a low-cost VGA camera module. We’ll be using the Arduino_OVD767x library to make the software side of things simpler.

Hardware setup

To get started, you will need:

You can of course get a board without headers and solder instead, if that’s your preference.

The one downside to this setup is that (in module form) there are a lot of jumpers to connect. It’s not hard but you need to take care to connect the right cables at either end. You can use tape to secure the wires once things are done, lest one comes loose.

You need to connect the wires as follows:

Software setup

First, install the Arduino IDE or register for Arduino Create tools. Once you install and open your environment, the camera library is available in the library manager.

  • Install the Arduino IDE or register for Arduino Create
  • Tools > Manage Libraries and search for the OV767 library
  • Press the Install button

Now, we will use the example sketch to test the cables are connected correctly:

  • Examples > Arduino_OV767X > CameraCaptureRawBytes
  • Uncomment (remove the //) from line 48 to display a test pattern
Camera.testPattern();
  • Compile and upload to your board

Your Arduino is now outputting raw image binary over serial. To view this as an image we’ve included a special application to view the image output from the camera using Processing.

Processing is a simple programming environment that was created by graduate students at MIT Media Lab to make it easier to develop visually oriented applications with an emphasis on animation and providing users with instant feedback through interaction.

  • Install and open Processing 
  • Paste the CameraVisualizerRawBytes code into a Processing sketch
  • Edit line 31-37 to match the machine and serial port your Arduino is connected to
  • Hit the play button in Processing and you should see a test pattern (image update takes a couple of seconds):

If all goes well, you should see the striped test pattern above!

Next we will go back to the Arduino IDE and edit the sketch so the Arduino sends a live image from the camera in the Processing viewer: 

  • Return to the Arduino IDE
  • Comment out line 48 of the Arduino sketch
// We've disabled the test pattern and will display a live image
// Camera.testPattern();
  • Compile and upload to the board
  • Once the sketch is uploaded hit the play button in Processing again
  • After a few seconds you should now have a live image:

Considerations for TinyML

The full VGA (640×480 resolution) output from our little camera is way too big for current TinyML applications. uTensor runs handwriting detection with MNIST that uses 28×28 images. The person detection example in the TensorFlow Lite for Microcontrollers example uses 96×96 which is more than enough. Even state-of-the-art ‘Big ML’ applications often only use 320×320 images (see the TinyML book). Also consider an 8-bit grayscale VGA image occupies 300KB uncompressed and the Nano 33 BLE Sense has 256KB of RAM. We have to do something to reduce the image size! 

Camera format options

The OV7670 module supports lower resolutions through configuration options. The options modify the image data before it reaches the Arduino. The configurations currently available via the library today are:

  • VGA – 640 x 480
  • CIF – 352 x 240
  • QVGA – 320 x 240
  • QCIF – 176 x 144

This is a good start as it reduces the amount of time it takes to send an image from the camera to the Arduino. It reduces the size of the image data array required in your Arduino sketch as well. You select the resolution by changing the value in Camera.begin. Don’t forget to change the size of your array too.

Camera.begin(QVGA, RGB565, 1)

The camera library also offers different color formats: YUV422, RGB444 and RGB565. These define how the color values are encoded and all occupy 2 bytes per pixel in our image data. We’re using the RGB565 format which has 5 bits for red, 6 bits for green, and 5 bits for blue:

Converting the 2-byte RGB565 pixel to individual red, green, and blue values in your sketch can be accomplished as follows:

    // Convert from RGB565 to 24-bit RGB

    uint16_t pixel = (high << 8) | low;

    int red   = ((pixel >> 11) & 0x1f) << 3;
    int green = ((pixel >> 5) & 0x3f) << 2;
    int blue  = ((pixel >> 0) & 0x1f) << 3;

Resizing the image on the Arduino

Once we get our image data onto the Arduino, we can then reduce the size of the image further. Just removing pixels will give us a jagged (aliased) image. To do this more smoothly, we need a downsampling algorithm that can interpolate pixel values and use them to create a smaller image.

The techniques used to resample images is an interesting topic in itself. We found the simple downsampling example from Eloquent Arduino works with fine the Arduino_OV767X camera library output (see animated GIF above).

Applications like the TensorFlow Lite Micro Person Detection example that use CNN based models on Arduino for machine vision may not need any further preprocessing of the image — other than averaging the RGB values in order to remove color for 8-bit grayscale data per pixel.

However, if you do want to perform normalization, iterating across pixels using the Arduino max and min functions is a convenient way to obtain the upper and lower bounds of input pixel values. You can then use map to scale the output pixel values to a 0-255 range.

byte pixelOut = map(input[y][x][c], lower, upper, 0, 255); 

Conclusion

This was an introduction to how to connect an OV7670 camera module to the Arduino Nano 33 BLE Sense and some considerations for obtaining data from the camera for TinyML applications. There’s a lot more to explore on the topic of machine vision on Arduino — this is just a start!

Deploying Projects in the Field: Off-the-Shelf Enclosures

via SparkFun: Commerce Blog

With the weather getting better I find myself deploying more projects outside, which means more projects that need to be enclosed and protected from the elements. There are a number of DIY options these days when it comes to project enclosures: 3D printing, laser-cut acrylic, etc. I have access to most of those options, but I am also someone who doesn’t want to reinvent the wheel.

I decided to explore what my not-so-local big box hardware store had available. With an open mind and a few sensors and different boards for rough size and test fit, I found a couple of options, but one I really like and stood out to me: external weatherproof electrical junction boxes. I know, not super creative, but here are a few reasons that I went this direction.

Form Factor Options

I picked up a number of different sizes and shapes and found that each one seemed to fit different form factors nicely.

alt text

From the Raspberry Pi and Arduino Uno form factor, to our Thing+ and even the micro:bit with a carrier board, it seemed like most factors found a cozy home with enough space to add a peripheral boards like shields, PHATs, or access to a Qwiic connector to leverage the Qwiic System.

alt text

One issue I did find with the snug fit of these enclosures was access to USB for power and/or programming once the project was put together. I solved this by reversing my thinking about mounting the boards in the enclosure. Instead of the project facing “out” from the box, I mounted the development boards to the enclosure lid. This had a number of benefits.

alt text

Attaching the majority of my project to the lid makes it removable from the project for reworking/reprogramming at my desk, while the enclosure can stay attached to wherever I mounted it.

alt text

You can buy the lids for most brands of external enclosures separately from the enclosure housing itself. This means I can mount different projects or versions of the same project to different lids and swap them in and out as I see fit. The benefit of the different lid system also means that it becomes an area that I am comfortable with modifying, cutting, sanding, etc., because it is easily replaceable if I mess up.

Industry Standard External Connections

The wonderful thing about using off-the-shelf enclosures is that they meet industry standards, so different boxes can connect to one another, with wiring passing from one to the other, in an easy to assemble way that is still dry and weather-proof.

alt text

Trying to figure out how to drill holes, seal them up again for passing sensor wires through the enclosure wall, and then figure out an elegant way to seal things up again is always a challenge. With external enclosures, penetration points are already molded in and you can connect things via weatherproof wiring or even a fully enclosed conduit system to keep things dry.

alt text

In a project I just completed, I needed to connect to an external sensor as well as power. With the project being in my shop, it didn't need to be weatherproof, but I did find a connector that clamped the wires for strain relief, which is always a plus in my book. You can find so many options to benefit your project here!

As a hard-learned side note... electronics tend to get warm in enclosed spaces, so I moved my temperature sensors into a short piece of conduit with small holes drilled into it.

Durability

I think this can be read between the lines in this post, but the thing that stands out with using these boxes as enclosures for projects is the durability they offer your project at relatively low cost. These boxes are designed to be outside, to be rained on, to be in the sun, to be hit with an errant baseball, etc. This durability comes from the expectations that come with these being external use, and because of that I use them in many indoor projects where the project may get bumped, dusty or dropped. It takes a lot to crack or break these things!

Range of Price and Quality

Now, I know that these enclosure options come with a price tag. No doubt I could have 3D printed a relatively weatherproof enclosure or even made one with basic shop tools, but I went this route because they were readily available and will stand up to the elements, let alone saving me the time it takes to design and build an enclosure.

That being said, what you are protecting your project from and how long it will be exposed, as well as the permanence of your project, will dictate the level of investment for you. Many times my projects fall into the tupperware-and-tape category for enclosures, but the projects I have been doing recently have been more permanent, and so I went for higher quality. It’s all up to you, but I have found using these off-the-shelf boxes as enclosures are a huge savings in time and effort to get a project deployed.

So far things have worked out well for me using this method, and I keep finding ways to build out DIY systems around my home and yard, from data collection in my garden to a control system for my air compressor. The next time you are in the hardware store, take a moment to stroll down the aisles and see what you can find.

How about you? Have you gone this route with enclosing projects? What other off-the-shelf parts and bits have you used from the hardware store for your projects around your home or office?

comments | comment feed