Friday, February 23, 2018

5mm LED Holders

One of the things I find myself making often, is plastic (plexiglass) control panels. I still have not made my desktop cnc yet, but when I do, I can stop drilling these panels by hand. Mounting LED's is always a task, and I started using these very nice chrome LED holders. They come with a plastic plug for the 2 LED leads to stick through, and hold the LED securely. For my 4 lead RGB LED's, I just use a spot of hot glue to hold the LED, and heat shrink tubing to insulate the leads. Use a silicone coated wire for flexibility and stress relief.

Tuesday, February 20, 2018

FreePBX - Open Source PBX Phone System

I just installed FreePBX, a linux based open source phone system at work (12 SIP trunks, 40 extensions), and thought, why not a home / small office unit based on a Raspberry Pi? The Raspberry Pi can easily handle multiple SIP trunks, and enough IP phones for the whole family / small business to have a extension or even a private DID. The FreePBX software is free, the Raspberry Pi is inexpensive (about $80 for a complete kit) and PolyCom IP Phones are readily available for around $80 each. Now you can have individual voicemail (email integrated), auto attendant, intercom, paging / bells, and music on hold just like the big boys. The phones and paging adapter can be powered by a inexpensive POE network switch, as can the Raspberry Pi with a POE Hat.

Arduino integration? Yes your Arduino can make outbound calls with prerecorded alerts!

Thursday, January 11, 2018

ATX Bench Power Supply

As a Ham Radio operator and a electronics / programming fanatic, I'm always on the lookout to improve my bench equipment. This weeks upgrade is a multi voltage bench power supply. For those that have been looking, bench power supplies can be very pricey, but many people overlook the ubiquitous computer power supply. It has +12v, -12v, 5v, and 3.3v taps, but not in a easy to use form. That changes with a ATX power adapter. Now you can easily add a variety of voltages to your projects, in some hefty current ratings, up to 36 amps or more.

The next stage is to add a Arduino voltage and current display for each output, and maybe some MOSFET's for adjustable output for testing motor speed.

ATX Power Supply $22

ATX Power Distribution Board $30
includes solderless breadboard and breadboard power supply adapter. 

See for notes on cooling, regulation, and other voltage combinations.

Friday, December 29, 2017

Raspberry Pi and a UPS (Battery Backup)

Regular workstations (PC's) and servers are often plugged into a UPS (Uninterruptible Power Supply, or Battery Backup) with a USB cable so that the UPS can tell the computer when battery voltage is low, and to perform a clean shutdown.

A Raspberry Pi does not come with a power switch. If you were to cut power without running a proper shutdown command, you can easily corrupt the SD Card.

We can do the same with a Raspberry Pi. The following site outlines the procedure for setting up the monitoring software so that your Raspberry Pi will properly shutdown when the backup battery gets low. If you have several Raspberry Pi's, they all can get the shutdown command from the same UPS.

We use the CyberPower 750 shown. A Raspberry Pi can run for weeks before the battery runs low.

No more corrupted SD Cards, and no more worries!

Tuesday, December 26, 2017

Harbor Freight / Pittsburgh Caliper Arduino Connection

Another HF Caliper project. Here is the HF Caliper connected to our digital interface for Arduino, Raspberry Pi, and more. Just above the battery door is a small access panel that covers a 4 pin edge connector. Carefully solder 3 wires to those pads, which, from left to right are GND, Data, Clock, and +1.5v (we aren't using that one). You no longer need to solder on to those delicate pads, as we have a cable that plugs right in!

The interface is simple. two transistors (we used 2N2222A) and four 10k Ohm resistors 1/4w.

You can order a finished board for only $20, a HF cable (no soldering) for $25, and a Arduino Nano w/ integrated Screw Shield for $15

Screenshot, schematic, and code are posted below. Thanks to the following sites for ideas and resources:

Cable to fit caliper, eliminates need to solder -

Just cut off the RJ-11 plug, strip 1" of the black outer jacket, strip 1/2" of insulation on each wire, fold back in half, solder, and insert into screw terminals (the wires are too fine to hold in the screw terminals otherwise). Connect as follows:

Gnd - yellow
Data - blue
Clock - red
1.5v (not used) - white

Next version of the board will have a RJ-11 jack on board, no stripping wires.

Arduino code is below:

//Digital caliper code to read the value off of a cheap set of digital calipers
//By Making Stuff Youtube channel
//This code is open source and in the public domain.

const byte clockPin = 2;  //attach to clock pin on calipers
const byte dataPin = 3; //attach to data pin on calipers

//Milliseconds to wait until starting a new value
//This can be a different value depending on which flavor caliper you are using.
const int cycleTime = 32; 

unsigned volatile int clockFlag = 0; 

long now = 0;
long lastInterrupt = 0;
long value = 0;

float finalValue = 0;
float previousValue = 0;

int newValue = 0;
int sign = 1;
int currentBit = 1;

void setup() {

  pinMode(clockPin, INPUT);  
  pinMode(dataPin, INPUT); 
  //We have to take the value on the RISING edge instead of FALLING
  //because it is possible that the first bit will be missed and this
  //causes the value to be off by .01mm.
  attachInterrupt(digitalPinToInterrupt(clockPin), clockISR, RISING);

void loop() {  
   if(finalValue != previousValue) {
     previousValue = finalValue;
   newValue = 0;
 //The ISR Can't handle the arduino command millis()
 //because it uses interrupts to count. The ISR will 
 //set the clockFlag and the clockFlag will trigger 
 //a call the decode routine outside of an ISR.
 if(clockFlag == 1)
  clockFlag = 0;

void decode(){
   unsigned char dataIn;
   dataIn = digitalRead(dataPin); 
   now = millis();
   if((now - lastInterrupt) > cycleTime)
     finalValue = (value * sign) / 100.00;
     currentBit = 0;
     value = 0;
     sign = 1;
     newValue = 1;      
   else if (currentBit < 16 )
     if (dataIn == 0)
       if (currentBit < 16) {
          value |= 1 << currentBit;
       else if (currentBit == 20) {
          sign = -1;
   lastInterrupt = now;

void clockISR(){
 clockFlag = 1; 

Thursday, December 14, 2017

What is my Ultimate Raspberry Pi Station?

As I'm working on several Raspberry Pi hosted web/database/IOT projects this Christmas Season, I wanted to share my ultimate workstation.

First of all you need a Raspberry Pi. Now that version 3 is out, I got rid of all my older units and replaced them with this little wonder computer. The integrated WiFi and Bluetooth, plus the faster speed makes a useful computer into a absolute necessity!

I start with this Raspberry Pi Starter Kit which includes the Raspberry Pi 3, a 32gb SD Card, Power supply, and a HDMI cable.

Now, the case that comes in the kit is a fine case, but I wanted to mount mine on the back of my TV to keep it and the wiring out of the way. This VESA case can also mount on a wall or under a shelf.

Again, with the minimal wiring goal, I use a Logitech wireless keyboard / mouse combo.

And did I mention I use a TV? Yes! A inexpensive HD LCD with a HDMI input for the Pi, and I can still catch a game or movie when I need a break from programming!

Last, but not least, you may need a VESA hardware kit to fit your tv. This kit covers most TV models and will make it easy to mount your Pi on the rear of the TV.

So that's my setup, What is your preferred setup?

Tuesday, November 21, 2017

Arduino and Raspberry Pi Holder

When you are building circuits and programming your microcontroller, you probably have it sitting on a table, wires going everywhere, and possibly shorting the bottom pins on clipped wire pieces, tools, and other obstructions. It can be a challenge to keep everything tidy and organized, which can cause trouble shooting issues. I'm looking forward to my new organizer coming this week, and I will post video of it in use. It allows me to keep a Raspberry Pi, Arduino, and a breadboard stable and secure. Projects have a higher possibility of working the first time, as I can see better if wires are going where they are supposed to, and have not pulled loose!

Arduino / Pi / Breadboard Base

Here I have my Raspberry Pi 3, a Sainsmart Arduino UNO, and a Arduino WiFi / SD Card Shield mounted with a breadboard and a RPi I/O breakout adapter. A great setup for Linux, Apache, mySQL and PHP (LAMP) database storage and web presentation of Arduino connected sensors. I combined this with a CanaKit Raspberry Pi Starter Kit.

Wednesday, November 15, 2017

Model Railroad DCC Control - JMRI / Raspberry PI

For those who want to control their DCC Model Railroad with their cell phones or tablets (pretty much any Android (Engine Driver) or IOS (WiThrottle) device), There is a Raspberry Pi image already built. Copy it to a sdcard, insert into your Raspberry Pi, and you are pretty much set to go!

Once you've assembled the hardware and installed the image, connect your RPi to your layout via PR3, LocoBuffer-USB, NCE Serial, NCE USB, SPROG or DCC++, and plug in the RPi's power adapter.  You should see some LEDs on the RPi begin to blink, and shortly, using your wifi-capable phone, you'll see a WiFi network named "RPi-JMRI".  Select it and enter "rpI-jmri" when prompted for the key (note that 3rd character is a capital "eye").  Open EngineDriver on your phone, and you should have an available connection under Discovered Servers called "RPi-JMRI".  (Similar with WiThrottle on iPhone).  Enter loco address and run trains!

Tuesday, November 14, 2017

Breadboard Friendly ESP8266-01 / nRF24L01+

The cheapest WiFi modules on the market (around $3 each) are the ESP8266-01 boards, which are WiFi enabled microcontrollers in their own right (with limited I/O), or they can be used with an Arduino as the WiFi interface. However, they have a funky 2x4 header that is not breadboard friendly.

Here is one possible solution. A inexpensive 2x4 to breadboard converter with a 2x4 socket on top and headers on bottom that match up nicely with a breadboard. It not only works with the ESP8266-01, but also works with the nRF24L01+ RF modules as well.

Now it's very easy to experiment with these handy modules. If you need a 5v to 3.3v regulator and level shifting for your ESP8266-01, check out these converters!

More ESP8266 Fun!

We have shown how to use the ESP8266 to collect sensor data, and send it to a database (client mode), but you can also use the ESP8266 as a webserver, displaying a web page and showing status or accepting input (server mode). In fact, it can be a server and a client at the same time. The following code runs a webserver on the esp8266, providing input fields to instruct the esp8266 to perform an action, and then POSTs that set of actions to the database. You could also read a sensor to verify that the actions were actually performed.



Tuesday, September 26, 2017

Calculate Daylight Savings Time Date

The web based apps I write often have informative messages for the users, and one request was a reminder to change the clocks for Daylight Savings Time. Since it's not the same date each year, but is always the Second Sunday of March and the First Sunday of November, I needed to be able to get a date for those days. It's fairly easy in PHP, as you can see below.

$year = date('Y');
$spring = date('m-d-Y 02:00:00 A', 
strtotime('Second Sunday Of March '.$year)); $fall = date('m-d-Y 02:00:00 A',
strtotime('First Sunday Of November '.$year)); echo 'Spring: ' . $spring; echo 'Fall: ' . $fall;
Here is the quiz of the day:

How would you accomplish this on the Arduino?


Arduino Time Libraries

Arduino DST Solution

Friday, August 25, 2017

Arduino / Relay Interference


You have a relay connected to your Arduino, and after a while your Arduino stops running. That's not supposed to happen, these things loop forever, right?

It's a common issue when running inductive loads from a Arduino controlled relay. Many folks think it's a voltage problem and try throwing capacitors on the relay supply, or using a opto isolated relay (separate power and ground). These solutions may work, but more often than not, they don't.


So what is causing the problem? It's EMI!
The back EMF from an inductive load causes the relay contacts to act like a spark gap transmitter, scrambling the processor. The Atmel chips are very susceptible to RF.

Not to worry, it's not permanent, it clears when you cycle power.

How did we discover this and how do you keep it from happening?

We have a project where a Nano and a common relay board are installed in a small case. When all the parts are assembled on the bench, it works fine. When crammed together in the box, it works for a while, then freezes. But only with a inductive load attached to the relay. With no load, or a resistive load, it runs forever (well, 3 days or more, forever was too long a test period). We have tested this six ways to sunday with a variety of Arduino and Arduino clones.


Installing snubbing diodes on relay coils and motors (the common solution) can be difficult (they don't work on ac devices) or void a warranty on many household appliances.

I series connected a resistor and a capacitor together, and connected those across the Arduino relay contacts (as close to the relay contacts as you can get). This quenches the back EMF, and prevents the Arduino from locking up. There you go, a $0.30 solution to a nagging problem.

Make sure your capacitor is rated for the voltage you expect to see. I used a .1 uF 50v Tantalum, and a 100 Ohm 1/4w resistor on a 26v circuit. My load was another relay. In another application, the load was a 120v motor, so the cap was 150v.

Tuesday, August 22, 2017

2 Channel IR Interface

Recently we produced a 6 Channel IR interface for IR transceivers like the TCRT5000 pairs. Lots of Model Railroading and other object detection applications. Now we have the less expensive 2 channel version available. Same code, same components, just less of them! - $30 + S&H

Harbor Freight Caliper Interface

Did you know the inexpensive Pittsburgh / Chicago Tool / Harbor Freight Calipers (4 pin dataport under battery cover) have a digital interface? We can read that interface with an Arduino, just like we do with the Mitutoyo / Igaging calipers and micrometers. The electrical interface is different, as is the data stream. Now, thanks to the hard work and experimentation of the folks at Arduinotronics, you can integrate measurement into your projects.

You can display the results on a LCD screen, save to a SDcard, or log the data to a Raspberry Pi based database.

 I'll be posting video, code and schematic shortly, but get your board order in now so you can get started! $20 + S&H


Friday, August 11, 2017

Setting up a Mosquitto MQTT IOT Broker

Ever want to view / control devices at home while on the road?

As part of our IoT initiative, I have set up a broker based on Mosquitto. Mosquitto uses MQTT, a publish and subscribe mechanism that avoids the necessity of special router configuration on your home network. A sensor node (arduino with ethernet or wifi, esp8266, etc.) publishes data to the public broker, and a client (cell phone, another arduino, etc.) subscribes to that topic to display information or receive instructions. Since the device that subscribes, or publishes to the broker initiates the conversation, your home router does not need network address translation or ports opened up. To secure the data transmission, usernames, passwords, client id's and SSL are used.

Our first step was to install Mosquitto on the server. We used the excellent tutorial at to get the broker up and running, and tested. Since we used a windows 10 machine as the server, we had to enclose the message "Hello World" in double quotes instead of single quotes as stated in the tutorial.

There are two dependencies listed during the installation, so also download those, and copy the resulting dll's to the mosquitto directory.

Since I use MySQL and PHP to collect data from our sensors and log to the database, I created a php page that acts as a publisher to the broker. The sensor could just as easily publish to the broker directly, but I needed the database and visual graphing capability of PHP, CSS3, HTML5 and Javascript. I can also easily email alerts.

I may set up php as a subscriber, and have the sensors publish to the broker.

To use MQTT with PHP you need a MQTT Library for PHP.

Stay tuned for more articles using ESP8266's, relays and other sensors, with MQTT transport. I'll have a Mosquitto sandbox for readers to play with so you can publish and subscribe your sensors.

PHP Example Code:

Android viewing and control:

There is an very good Android dashboard for publishing and subscribing to the broker. You can see your sensor values, and send commands to your devices from anywhere in the world.

IoT MQTT Dashboard
Related Posts Plugin for WordPress, Blogger...