Category Archives: Arduino

New Beginnings

Hello everyone!


I originally started this blog as a part of a project for my EMBA.  At the time I was living in Indiana.  Since then, I have changed jobs twice, and moved to two different locations – its been a hectic last couple of years.  Due to my career and life changes, I abandoned my blogging.  However, I have noticed a decent amount of activity and interest, so I am picking it back up with some current projects.


My next project will be a water box for a portable AC.  I recently moved to the Portland, Oregon area, and found very few houses and even apartments have AC systems installed – due to the weather they aren’t needed as much as other areas.  However, in a 3 story place, the 3rd story gets very hot.  So, I decided to go with a portable AC unit for now.


For those of you who have never used a portable AC unit, the problem is that when you cool air it causes condensation, and water builds up.  The AC units have tanks in them, and when they fill up they shut down.  Then you have to roll it over to the bathroom, or someplace, pick it up and drain it out.  So, instead of that, I am building a water box that the AC unit will drain into, and when the water level gets to a couple inches, I’ll have it pumped out the window.


Currently, I have the system functioning, but it is not complete.  I have created my wooden water box – the wood inside has been stained with a polyurethane stain (PolyShades), and all corners/cracks have been sealed with a standard silicone.  I have not finished the outside of the box yet (I am waiting to get my controls system finalized before I finish it).  I am using a 12 VDC pump I picked up on Amazon ( ), a 5/16 hose from HomeDepot, an old 12 VDC adapter I had laying around, an Arduino Mega (an overkill, but I didn’t have any of the smaller boards on hand), and a 4 channel relay shield I picked up from RadioShack (You really only need 1 channel for this project, but the shield was just more convenient as it mounts directly on the Arduino – you can find some 1 channels cheap on Amazon ).


I am running into issues with direct contact sensors – sensors that are sitting in the water.  My first sensor I made from various parts, corroded very quickly.  I am now using a water sensor I picked up on amazon ( ).  The sensor worked well, but it is picking up some corrosion/scaling, which is causing indication issues.  I’m not sure whats causing the issue, as I figured the condensation would be fairly pure water, but I am assuming it is coming from either the polyurethane, the silicone sealant, a combination of the both, or even maybe a reaction of the urethane and the silicone.


Due to the direct-contact sensor issue, I am going to switch to a non-contact method, using an ultrasonic sensor, which you can also find online at Amazon, such as these .  I am  busy working, but I should be able to complete this modification next week, and will have more to post with some better pictures, code, and directions.


Picture of the AC unit on top of the water box:

Water-box - 1.jpeg


A picture inside of the water-box.  Don’t mind the messy wires – that was caused from changing sensors out, and some uncertainty of success.  You can see the pump, and the sensor (red circuit board towards the bottom).  You should be able to see the corrosion/buildup on the lower portion of the sensor:

Water-box - Inside 1

My Arduino Air Compressor Controller Project – Beginning of Coding!

Thanks for joining me again!

I have good news – the Arduino controller is almost all put together! All that is left for hooking it up is to hook up the 3 wires for the sensor, which won’t take very long, and screw the front cover in. It’s not perfect (I wish I would’ve got a slightly larger box), but it will work:

Air Compressor Controller - 1

For this blog, I would like to start getting into the programming code for this project. First, as I mentioned in my first blog post about Arduinos, you must download the Arduino IDE. The Arduino IDE (Integrated Development Environment) provides a simple platform for writing your code, even provides us with many different examples, and it is used to load the program onto the Arduino through USB. The program code is written in C, which I can provide more information about in the future. Arduino calls the program code a sketch.

There are other options for writing the programs, such as using Microsoft’s Visual Studio with the Visual Micro add-in (which is my personal favorite). Using Visual Studio is a quite a bit more complex to initially get setup and get projects started, so for this blog series I’m just sticking with the Arduino IDE.

The following is a screenshot of the Arduino IDE, with the Blink example, which is installed as the default sketch on all Arduino microcontrollers:

Arduino Blink Sketch

A couple of things to notice with this sketch:

  • We can include comments in our code to help with documentation and for instructional purposes. The compiler will ignore the comments as if they weren’t there, but they are still displayed in the IDE.
    • One line comment “//” – this can be used anywhere in the code, including after a statement, as shown towards the bottom of the sketch. Everything after the // will be ignored by the complier.
    • A multi-line comment begins with “/*” and ends with “*/” – everything in between the start/end designators will be ignored.
  • The Arduino has 2 key functions that it runs:
    • Setup – the Arduino runs this code when it is first turned on. It is used for setting various parameters to prepare the board for the main program
    • Loop – This is the main part of the program for the Arduino – it runs through this function in a continuous loop.

To start out our sketch, I am going to begin with a separate function to calculate the pressure – If you remember, on my post about the hardware I am using a 200 psi linear pressure transducer, which varies the output from 0.5 volts at 0 psi, to 4.5 volts at 200 psi. So, we just need to setup a simple calculation to make it easy to determine what the actual pressure is, based on the output voltage of the pressure transducer. However, to make it a little more complicated, the Arduino doesn’t give us the voltage, it gives us a numerical value from 0 at 0 volts, to 1023 at 5 volts.

So the first thing this code is going to need to do is convert the 0-1023 Arduino value to a voltage. This is pretty simple. For 5 volts, there is a range of 1024 values (Note: 0 is a value here, so it’s 1024, not 1023). Therefore, for each 1 value step of the Arduino’s analog value is equal to 5/1024 = 0.004883 volts. So 205 = 1 volt, 410 = 2 volts…

Next, we want to check for errors in our pressure reading – If something happened to our pressure transducer, and we aren’t getting a good reading we don’t want to keep the compressor running. This pressure transducer outputs a minimum of 0.5 – so if the voltage is less than 0.5 it is more than likely shorted out. On the high side, 5 volts are being applied to it, and its max output is 4.5 – so if it is reading above 4.5 it also means something is wrong and giving us a bad reading.

Lastly, is the voltage to pressure conversion: 4/200 = 50psi/volt (the voltage range is from 0.5 to 4.5 volts, which is only a range of 4). Therefore, for each 1 volt outputted from the pressure transducer above 0.5, is 50 pounds.

There are many different ways you could perform this conversion, but I have included the conversion part of my code for this project at the end of this blog post – please look at it, and provide comments and feedback. If you would like the actual sketch files, please reach out to me through one of the social media links.

Thanks for joining me again! Hopefully we will have my air compressor running again by next week! I’ll be working on the full code, and will be posting it later this week – Please check back in!

double psiconvt(double psi)


                bool olderror = psisenserror;

                double c1;

                double c2;

                double val = 0;

                c1 = psi * 0.004883;


                                The psi sensor starts at 0.5V – anything less is an error with the sensor

                                The psi sensor ends at 4.5V – anything more is an error with the sensor

                                Therefore, if it is outside of those parameters, throw an error


                if(c1 < 0.46)


                                psisenserror = true;


                else if(c1 > 4.54)


                                psisenserror = true;




                                psisenserror = false;


                c2 = c1 – 0.5;

                val = c2 * 50;

                return val;


My Arduino Air Compressor Controller Project – Tools

Welcome back to my Arduino Air Compressor Controller Project!

I know last week I stated that we were going to begin moving to code this week, but I have some bad news… My project box cracked down the front, and it’s not safe continuing with the box – it is housing 240 volts, and it is going on a piece of equipment with a lot of vibration.


So, I have a new aluminum box, that is much sturdier, and I am working on getting all the parts switched over and mounted on it, as well as doing some upgrades (a larger display 20 character by 4 line display, instead of the 16 character by 2 line display).

New aluminum box

Since we’re not ready to move on to code yet, I figured it would be a good time to take a step back look at the tools I used to create the prototype board and assemble the controller. So, for this project the necessary electrical tools include:

  • Mini nipps – tremendously helpful when soldering new components on boards – they make it really easy to cut off the excess wire protruding from the bottom of the board
  • Multimeter – not entirely required, but highly recommended – it will help troubleshoot problems
  • Pencil tip Soldering iron – for finer electronics, I recommend using a low wattage, pencil tip soldering iron – the pencil tip makes it easier to work with the smaller boards, and the lower wattage prevents it from getting too hot and damaging delicate components
  • Wire stripper/combo tool – there are nicer, separate wire cutters and wire strippers you can purchase, but these type are cheap, and they work

You really don’t have to have anything special or expensive. Most people swear by more expensive multi meters, like the Fluke brand (which are very nice), but for most hobbyist, a cheap Wal-Mart multi meter will do – at this level you really don’t need to worry about being precise.  You can pick all of these up for under $50, and you can find everything but the mini nippers at Wal-Mart or a hardware store.

Also, you need a few more basic tools:

  • Screwdriver (both phillips and slotted) – this will depend on the hardware (nuts and bolts) you choose
  • Mini pliers – This set includes mini nippers
  • Dremel – or a cheaper clone will suffice
  • Drill with drill bits – any drill will do, but make sure that you have or get bits specifically for the nuts and bolts you will be using.

If you really get into electronics as a hobby, you may look into getting a desoldering iron (very handy for fixing soldering mistakes or repurposing boards), and a hot re-work station. The hot re-work station is really for SMD’s (surface mounted devices), which I find the occasional need for, but I also use it for heat shrink and other things, and most of them come with a temperature controlled soldering iron (another must for the hobbyist).

Again, I apologize for not getting into some code yet, but I promise we will get into some code in my next blog in this series. Thanks for joining me, and please check back later for more.

My Arduino Air Compressor Controller Project – Assembly of Control Board

Well, I’ve made some progress on our Arduino project!

I have my control board 100% assembled and functionally tested (without the Arduino). All that is left for the hardware is attaching the push button switches, the pressure sensor, mounting my project box to the compressor, and wiring up the power line to my terminal strip. Then we will begin working on the programming for the Arduino!

Compressor Project Box - 1

The following is a rough sketch of the circuitry so you can visualize it a little better. Note: I created this with fritzing, which has a limited amount of pre-built components – so, the components shown are just for illustration, not all of them are identical to the components I am using.

Compressor Controller - Breadboard Sketch

At the top left, you will see my connector for the 12 volt power supply, which will ultimately supply power for the entire device. The controller fan, and the air compressor relay will be powered from the 12V bus through the transistors.

Right next to the 12V power supply is a voltage regulator – it takes an input from 5-60 volts and regulates it to a stable 5 volts. The regulator’s 5 volt output will supply power to everything else – I chose to power the devices (pressure switch and LCD) directly from the regulator output instead of from the Arduino because of the Arduino’s limited max output of 500 ma – The Arduino is fully capable of powering all these devices from its power source. I just chose to avoid it as a fault in one of the devices could exceed the power output of the Arduino, potentially damaging the Arduino.

Just below the voltage regulator are two transistors. I am using these transistors as switches – to turn them on all you have to do is supply a small voltage/current to the base of the transistor. This will allow current to flow through the transistor, completing the circuit path for the device (the relay and fan). To turn it off, you apply 0 volts, or ground to the base of these transistors and it will shut them off. This can be easily performed by the Arduino’s digital outputs, which can turn off and on (0 volts and 5 volts).

Below the transistors are my three push button switches. These switches will be used as a menu, up, and down buttons to allow me to change my setpoints, and look at different things; temperature & humidity inside the box, status of the fan & relay, current tank pressure, the amount of time the compressor has ran, and the current setpoints. They are connected to the 5 volt bus, so when they are pressed they send a 5 volt signal to the digital pins on the Arduino, which we will program it to monitor and respond accordingly. There is a resistor on the output of the switch to drive it to 0 volts – sometimes these switches float, and have non-zero values when not pressed. I can provide more information about transistors later – they are really cool, and are capable of doing many different things for us.

Underneath the three pushbuttons, is our temperature and humidity sensor. This sensor is powered by the 5 volt bus, and uses a single buss data communication to relay the information. Luckily there is a program library for this, and we don’t have to create any special codes for this communication – one of the great things about Arduinos. Since it is a digital communication, it is hooked up to one of the digital pins.

At the bottom right of the breadboard, you will see a pressure sensor (this is not the same as my 3 wire sensor, but it was all fritzing had in its parts list). The pressure sensor is powered by 5 volts (mine has a +5 volt wire, a ground, and a sensor output). The pressure sensor sends a linear output from 0.5 volts at 0 psi, to 4.5 volts at its max rating (200 psi in our case). The reason it is 0.5 – 4.5 instead of 0-5 is to allow us to detect shorts and opens, which could either give a 0 or 5 volt out. Since this sensor gives a differing voltage output, analog, it is attached to one of the Arduino’s analog input pins.

Now, to the right of the breadboard, at the top, I have the fan and relay. Both of which are being controlled by their own transistors, which will be controlled through the Arduino.

Below the relay is the Arduino, our microcontroller.

To the far right is our 16 X 2 LCD (16 characters by 2 line liquid crystal display). This will be powered from the output of the voltage regulator. Its backlight is the largest load on our 5 volt bus. The LCD will be used to display the information I mentioned earlier about the buttons.

Thanks for joining me again! Next week I will have it completely assembled, and we will begin playing with some code!!! Please follow me and join me next week for more!

My Arduino Air Compressor Controller Project – My Parts & Components

Hello everyone! Thanks for coming back for more about my Arduino Air Compressor Controller project!

Before we start building, it is extremely important to come up with a plan! So, I’ve specked out my air compressor system in my previous post, My Arduino Air Compressor Controller Project – Part – 1. It is a 240 Volt motor, rated at 15 running amps, with a tank & compressor rating of 150 psi, but I didn’t mention that it is plugged into a 30 Amp circuit. The circuit breaker is important because it is an important safety feature – the motor runs at 15 amps, but according to the name plate can draw up to 93 amps if it locks up. Therefore, we want to make sure that all the components that we use for the motor will handle at least 30 amps, which is allowed because the breaker trips at 30 amps, protecting everything else in the line.

So, I’ve specked out the components I will be using for this project, in accordance with the ratings I am working with:

  • 12 VDC mini/micro fan – This is not necessary, but I thought it would be neat to add it to this project, to show how you can monitor temperature and control it with a fan or other device
  • 16 X 2 LCD – You can use different displays, even a touch screen if you wish, but this is a simple display that will work fine to display information, such as the current pressure, and use for operations to change the pressure set points
  • Arduino Mega – This is the microcontroller I chose to use – there are others, such as the Arduino Uno, which is cheaper, but I have a couple of these on my work bench, and I just chose to use what I have
  • Arduino Mega Shield – This as a great development tool, that allows you to put some small components on a breadboard that fit right into the Arduino headers. There are different variations, some for cheaper, but I like this one because it has the power headers and other benefits
  • Nuts/bolts/screws/spacers – This will all depend on the specific configuration of devices you use. I waited until I received all my components, and went to the hardware store with them to get the right size bolts and spacers – The air compressor vibrates a lot while running – everything in the controller box must be secured well!!!
  • Power Supply – I chose to use an old 12 vdc 1 amp power supply I had laying around – When picking the power supply, it is advisable to pick one that will supply the highest voltage needed (and of course the necessary amperage), in this case the 12 vdc relay and fan – It is easier to drop the voltage down that raise it up…
  • Pressure relief – This is necessary to prevent the air tank from over pressurizing and rupturing, I got a 150 psi relief because it is what my tank is rated for – some tanks are rated for less, such as 120 or 135 psi – make sure to check the rating of your tank before changing out any pressure relief valves
  • Pressure Transducer – This is the electrical component that will sense the pressure in the tank for us, and send a signal back to our Arduino microcontroller
  • Project Box – There are numerous types, shapes, and sizes of boxes you can order. I just ordered a standard shaped box that will fit in the location I want it to go, and is large enough to fit all the electrical components inside
  • Push Buttons – These buttons will be used to enter a menu and change the pressure set points – again, there are numerous types, but for this project I am using normally open momentary push button switches
  • Relay – This will actually be the switch for the motor, so the one I chose is rated for 240 VAC and 30 Amps – which is the voltage the motor will be running at, and the amp rating of the circuit breaker it will be connected to. This relay also operates (switches) on a 12 VDC signal, which will work great with our 12 VDC power supply
  • Resistors – For this project, we will need some various resistors.
  • Temperature/humidity monitor – This component is not necessary, but I thought it would be neat to show a method we can monitor the temperature inside of the box, using the indication to cycle the cooling fan when needed
  • Terminal Strip – This will be a handy strip to secure our power leads to
  • Transistors – The Arduino Mega we are using is only capable of outputting a max of 500 ma at 5 VDC, which will not power the relay or the fan. Therefore, we will be using transistors as switches for the relay and fan, which will be controlled by the Arduino. These transistors I selected are rated for up to 60V and 5 amps – more than enough for the relay and fan
  • Voltage Regulator – The Arduino Mega has a voltage regulator built into it, and we can power it directly from our 12 VDC power supply, but I chose to have a voltage regulator anyways – if needed it will supply more 5 VDC power than the Arduino is capable of outputting

Note: I have no affiliation to any of the links I have provided in this post. Most of the components I have for this project, I have acquired over time, through eBay, Amazon, RadioShack, and other sources. I have just provided these links for your benefit, but you may be able to find better deals by Googling or using other search engines and sites.

Here’s what my box is beginning to look like after starting to securely bolt the components in place:

Air Compressor Controller Box - 1

Air Compressor Controller Box - 2

Thanks for joining me again! Next week I will post some more progress with the basic design of the controller – Please follow me or check back again soon!

My Arduino Air Compressor Controller Project – Part 1

Last week, I introduced Arduinos, and mentioned that I would be discussing my air compressor controller project using an Arduino. I will try to complete this series in 5-6 posts with this introduction, details about the hardware, and details about the programming.

Disclaimer: I am providing this information for educational and informational purposes only. Although this looks simple, working with 120V and 240V components and manipulating them with projects like this can be very dangerous, potentially resulting in severe injury, death, damaged equipment, fire, and will definitely void any warranty you may have on the item(s). If you wish to perform a project like this, seek assistance from an experienced electrician first.

So why am I doing this project, when you can just pick up a new stock controller (pressure switch) for $50 – $60? The standard pressure switch for my air compressor typically starts the air compressor when the air pressure drops below 90 psi, and stops when it reaches around 135 psi. It becomes somewhat problematic when trying to run air tools in the 110-120 psi range – when it drops below 100 psi, the air tool just doesn’t get the power it needs, requiring constant adjustment. Yes, you can manually set these pressure switches to cycle on sooner, but leaving it like that will drastically increase the start/stop cycles on the compressor, causing it to ware out much quicker.


My compressor and compressor motor

So, for this project my goal is to create a microcontroller for my compressor that allows me to change the start/stop points of my compressor, safely. The first step in a project like this is to figure out how it works, so you can figure out what you need in order to control it. Normal household compressors are relatively simple – they use a 120 or 240 volt AC induction motor which are controlled by a mechanical pressure switch. The mechanical pressure switch is what I am replacing, so I won’t get into the other aspects of the compressor.

The motor on my compressor is a 240V motor, so it has 2 terminal leads and a ground. The ground is always connected, but the two leads are what the pressure switch controls – it is what my new controller has to do, switch those two terminal leads on/off to start/stop the compressor (it is possible to control it by switching just one terminal lead, but it is just not a good idea as one motor lead will always be ‘hot’).

Now that we know the basics for how to control the start/stop of this compressor, I’ll move on to safety. Most people should already be aware of the hazards of electricity, but this introduces another hazard – over pressurization of the pressure vessel (air compressor tank). I wish it weren’t so, but mechanical and electrical components fail – there is a possibility that the device we use as a switch could fail, leaving the compressor running, over pressurizing the tank, causing it to rupture.

The main key in preventing these bad things from happening, is by getting the properly rated equipment/material. In the image below, you will see my compressor motor is rated for 240V at 15 amps – The switch I use must meet or exceed this rating, failure to do so will definitely result in the switch failing. It is also important to use the proper internal wiring and any other parts/components that will support the voltage and current (amp) that will be flowing through it.

My compressor motor name plate

My compressor motor name plate

Preventing the over pressurization can be done with a pressure release – a valve held shut by mechanical means, such as a spring, that will open at a certain pressure set point to reduce the pressure. The safety relief must be rated for the proper pressure, and flow – it will do no good if the air compressor can supply more air than the relief can release. Most air compressors only output a small volume of air, so most pressure reliefs you find will suffice, just make sure. You can see in the picture below, that my air compressor is rated to output a volume of 10.3 SCFM at 90 psi (at a higher pressure, like 130 psi, it will output a lower volume). Also, it is important to note that the sticker on my compressor states 135 max psi, I looked up the details which state it is capable of 150 psi, and the tank is also rated for 150 psi. So, I need to get a pressure relief for 150 psi or less, that is capable of relieving 10.3 SCFM or more.


My compressor main label

Pressure vessel name plate

Pressure vessel name plate

Next week I will continue posting about this project, moving into discussing the hardware I’ve chosen for my controller. Thanks for reading and following my blog! Please leave comments, and check back next week for more!

Arduino – Inspiring creativity and innovation of technology through learning

This blog, I would like to talk about one of my hobbies – microcontrollers, specifically, Arduinos.


Arduino Mega 2560

So just what exactly is an Arduino you ask – they are an open-source microcontroller that offers a relatively inexpensive way to learn about microcontrollers and build your own automation systems. There are many other development boards, just to name a few raspberry pi, Intel’s Galileo, even Samsung is getting ready to launch their ARTIK. While these are all great options, I prefer Arduino because there is a lot more documentation and examples available for them, they are easier to setup, and they are an actual microcontroller not a microcomputer (I will discuss the difference later).

What can you do with an Arduino? An Arduino is essentially an I/O (input/output) hardware device that has its own microcontroller. There are numerous different versions of Arduinos, but they range from having 14 digital and 6 analog pins, up to 54 digital and 16 input pins. The digital pins can be used as inputs or outputs, while the analog pins are only for input (except on their Due model, which has a couple of analog outputs). Basically, you use these analog and digital pins on the Arduino to read devices (temperatures, pressures, distance sensors, etc…), then have the microcontroller control a device (servos, motors, switches, send a signal, etc…). Most Arduinos also come with USB connectivity, and have the ability for serial, IC2, and other types of electrical communications – meaning that you can link multiple Arduinos together and to other devices, including computers. Some of the things Arduinos have been used for include:

You can find many, many other projects people have completed with Arduinos, and listed for everyone to see with instructions (

How do you get started, what does it take, how much does it cost? In order to program an Arduino, you need to have a computer with USB – Arduino has their programming software available for Windows, Mac OS X, and Linux. You must download the Arduino IDE (free), from Arduino’s website. Depending on your electrical engineering desire, you can actually get started learning about Arduinos with starter kits that typically start out around $50 (which you can find on Amazon and EBay). Starter kits typically contain one of the Arduino boards (usually the UNO), some electrical components (LEDs, resistors, switches), electromechanical devices (motors, servos), and an instruction manual (could be printed or some are available online). The official Arduino Starter Kit, which is currently unavailable (I believe they are upgrading it), is $89.90. If you’re ambitious, and want to start off on your own, without a starter kit, you can pick up the Arduino official Arduino boards, such as the UNO (one of their most popular boards) for around $25. Arduinos are an open-source hardware/software device, so you can also find a lot of knockoffs for cheaper on EBay, Amazon, and other places. However, I recommend purchasing from Arduino if possible, as they are the inventors and leaders of this project, providing us with continuous hardware and software improvements.

Seeing how quickly our technology is changing, I highly recommend looking into Arduino’s, as it will give you a deeper understanding of how technology is controlling devices – it will give you a new perspective of your electronics. I would also highly recommend them for families – teaching children these things at a fairly young age could be invaluable in their development and potential career paths.

Thanks for reading my blog post! If you are interested in Arduinos, join me next week, I will discuss one of my Arduino projects – a motor controller for my 220V air compressor.