Arduino 120V AC Relay Example

I got tired of poking around with LCD drivers with my Arduino. Time for a quick project to mix it up…staring at a surge protector always puts 120V on my mind. As it turns out, I tore apart an old humidifier a while ago on my ‘workbench.’ Monday night is Katie’s reality TV night…time for something sweet.

Investigating duty cycles on this plastic fan:

fan hack

fan hack

I figured that I could horse around with my PowerSwitch Tail, and make it somewhat mimic a PWM 5V setup. I was curious how long I would have to ‘pulse’ the switch with juice to keep the fan constantly rolling. I started with it fully on, and kicked my ‘active’ duty cycles lower until I reached a nearly-continual state of motion. Pause for Arduino code snippet:

/*
PowerSwitch Tail Template
-
120V AC Driver w/ LED indicator
-
Joseph Swanson
2011 | http://swantron.com
*/

void setup() {
// declare pins (13, 7) for writing
pinMode(13, OUTPUT);
pinMode(7, OUTPUT);
}

void loop() {
// Fire relay / LED
digitalWrite(13, HIGH);
digitalWrite(7, HIGH);

// Configure for “on” time
delay (50);

// Kill relay / LED
digitalWrite(13, LOW);
digitalWrite(7, LOW);

// Configure for “off” time
delay (950);
}

Pause for a small small-video break:

As that code and vid indicate, 1/20th of a second is all it took to keep the fan rolling, with 19/20th of a second idle. Not bad. Not sure what the takeaway is, but that is something to mention.

Put that knowledge somewhere safe, provided the question of humidifier fan duty cycles should spring up.

WordPress 3.2 Custom Layout

After the whole fiasco that came with my upgrade to WordPress 3.2, I
decided to shell my old layout and go with a new free website
builder
. Not only was it too bloated with jqueries, but the whole
thing was sort of outdated. Time for some new blood, to go with my new
(faster?) server.

Introducing: Swiz3

wordpress 3.2 free layout

swiz 3.1

Way quicker than the Swiz2* series. It turns out that WP has introduced a bunch of the custom menu junk that I formerly have fought with into their release, so out with the old.

Consider this a working beta, and pay no attention to anything wonky on IE…haven’t even looked at this site on that. Cheers.

Evolution of a Project

I have two speeds when it comes to projects: percolate and bazooka. Whereas my swantron comment / to / LCD project was bazooka, this Twitter deal has been percolate. Haven’t been able to jump in completely, rather, I have been poking this one with a stick.

Still poking…

arduino controlling blue lcd

dual terminals and a terminal

Making progress…snagging my Twitter page via Python, and dumping it to LCD:

body and html closing tags on my lcd

+1 closing tags

I just need to hammer out some parsing, and I will be good to go. I really need to figure out some sweet regex and drop this whole ‘import (some junk)’ stuff. Who knows…at this rate, I just may.

Twitter CLI Teaser

I sort of forget what my original project entailed…something about tweeting via the command line, for Arduino purposes. You can pretty much just toss a bunch of words in a hat, and add ‘Arduino’ and ‘Command Line’ to them, and there you have one of my typical projects.

Anyhow, here we find ourselves. I am missing some dependencies with OAuth, but have managed to get twitter working from an interactive python shell:

cli twitter

command line-y

This section is as much for my reference as it is for public knowledge…I snagged the commands that I ran to snag my comments. It first prints swantr0n (my dev account) and then my primary Twitter feed, @swantron

swantron@mini9:~$ python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
[GCC 4.5.2] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import twitter
>>> api = twitter.Api()
>>> feedSwantron = api.GetUserTimeline(‘swantron’)
>>> feedSwantr0n = api.GetUserTimeline(‘swantr0n’)
>>> print [ x.text for x in feedSwantr0n]
['development account for @swantron | tune into http://t.co/SpDFBkK for projects', 'hello world']
>>> print [ x.text for x in feedSwantron]
['@vftb ...you better believe it', 'Twitter Project Teaser : http://t.co/7ZrOLUn | one step closer to tweeting from the #CLI ... might take a run at make it tweet', 'Might need to implement some sleeves into my wardrobe... @adafruit just flipped the script with open source cuff links', 'unsafe at any speed... updating #ubuntu on the road http://t.co/Q8gfc56', 'Upgrading Mini 9 to #Ubuntu Natty http://t.co/7yT9w81 | posting to kill time... review here ( http://t.co/RM675lX ) lunch-aft on the morrow', 'http://swantron.com/basic-mower-cord-repair/ #DIY lawn mower repair from a #math major. spoiler: it works', "#arduino no you didn't http://swantron.com/html-to-python-to-arduino-to-lcd/ #LCD project, stepped up a bit", 'working on a python script to dump info from web to LCD http://swantron.com/python-teaser/ #arduino', 'http://youtu.be/MpomhE6dgww video of #boc unboxing (for the win)', '#woot bag-o-crap unboxing @ http://swantron.com/woot-boc-unboxing/ not too shabby', 'http://swantron.com/compiz-error-in-ubuntu-natty/ still finding some compiz issues in #ubuntu 11.04', '#Arduino project @ http://swantron.com/command-line-lcd-arduino-interface/ | driving LCD screen via command line', '@RobotGrrl... what version are you running? I had no problems with IOIO / Droid 2 (froyo 2.2)', 'Easy LCD #Arduino Display | http://swantron.com/easy-lcd-arduino-display/ | feels good to have a warm soldering iron and functional hardware']
>>>

I will keep plugging away until I get this thing hammered out. If not, I can print this suff to my LCD for a real-time Twitter display. Could be cool either way.

Ubuntu Natty Netbook Review

I have had Natty on my Mini 9 for a few days. It runs like a top.

natty narwhal on a dell mini 9 netbook

mini

Solid state HD equates to a sub double digit boot time…be sure to configure compiz via:

sudo apt-get install compizconfig-settings-manager

That is about it. Plus 1. I would rattle on about 11.04, but I already have a few posts back. Besides, I have bigger fish to fry. Namely, Gannon…

ocarina of time gannon

bring it, gannon

I’m in my 30s, and just now getting around to beating Ocarina of Time. Katie and Man-Dawg are watching the Bachelor (or Bachelorette; no effing idea) downstairs…here goes nothing

Makeshift Linux Heads-Up Display

Per my last post, I began upgrading my Dell Mini 9 last night…from Ubuntu 10.10 to 11.04. Well, at some point, it tossed a fit about not being able to snag a package, and hung on a dialogue box all night. No worries…I’ll finish this install on the way to work.

ubuntu linux netbook on my silverado dashboard

check the speedometer...

Who said netbooks are passe? Looks like that guy was designed to ride on the dash of a Silverado if you ask me.

For the record, I was not doing 110 MPH by the MSU campus. I have an issue with my speedometer. I was doing 90 MPH, tops.

My install was a success for the record. I will see if all functions are fully functional soon, and put together a post.

HTML to Python to Arduino to LCD

Last week found me standing tall upon my shell script soapbox, shouting command line praises to all who would listen.

Thou ought direct thine output aftways, to-wards thine USB port of thee. And that is well and righteous.

Well, that still is the case. My latest project has made it glaringly obvious that sometimes a little Python script will render a whole bunch of shell scripting moot. Namely, parsing HTML. Let’s see a picture…

outdoor hacking

bad lab mobile

Lunch hour project: parse the comments from swantron.com; feed said comments to an LCD screen.

I was horsing around with wget from a CLI a few days ago. I found myself trying to smash through the resultant file via pure regular expressions…which is incredibly clumsy. Well, as luck would have it, my go-to after my main go-to is Python, and this type of thing has been issue enough to warrant a library. BeautifulSoup. It acts to parse the HTML info into items, that can be smashed around as I see(med) fit.

My setup was simple: py script to snag my comments and write serial, Arduino sketch to drive a LCD and read/write serial. And a source of shade. And a WiFi signal to snag.

mobile mobile

bad lab mobile-mobile

Check, check, check, etc. Video time:

Pretty slick…hit the fold for the code, as promised, and a summary.
Continue reading

Python Teaser

After a deal of success with the command line interface-to-Arduino project, I am in the middle of stepping it up a notch. I ended up on a few blogs due to that last effort, which indicates that I am doing something worthy of note. Hats off to me, perhaps. Well, my tool belt is what it is…if I can’t do it via shell scripting, I reach next for Python. In an attempt to parse stuff that I have been ‘getting’ via wget, I found myself trying to do some clunky regex from the command line. Guess what…I can do that without as much heartache via Python via BeautifulSoup…

beautiful soup

so...beautiful


Thus far, I have python doing the website getting and Beautiful Soup doing the parsing of my site…basically just grabbing some info at this point that I can modify. I have my LCD driven via my trusty Arduino, and that is that. Instead of redirecting standard out to serial, I am writing to serial via python. Easy breezy.

I have some sloppy sloppy code at this point, and need to add some hardware and stuffs to my prototype. Stay tuned…this could be a good one.

Woot BOC Unboxing

It showed up…

woot b o c

finally

I got excited and made an un-boxing vid. Apparently, I get twitchy when I am excited. Probably why I interview like shit. Anyhow…

So, my three dollar (eight with shipping) bag of crap yielded:

* Passive laptop cooling pad
* Refurbished DSL router
* Strawberry that unfolds into a bag?
* Remote controlled Batman helicopter
* Three dog brushes

Not bad at all; I’m chalking this up as a win.

Command Line LCD Arduino Interface

Liquid crystal displays are pretty awesome. Command line interfaces are very awesome. Hmm…

I started daydreaming at work about how to go about making hardware interface with an RSS feed. I have seen some projects that use Arduinos with ethernet shields to check Twitter, for example, but they seem unnecessarily bulky. Or clumsy. I spend a lot of time working on the command line, and love to put together dirty little scripts to solve problems. It sort of goes along the lines of ‘when you have a hammer, everything looks like a nail’…I figured that the same thing could be implemented with a little shell scripting and my trusty Arduino, sans anything complicated.

So far, so good.

bad lab mobile

bad lab mobile

I put together a sketch (after the bump) to drive my LCD, writing serial output to the screen. After verifying that the sketch worked via the Arduino IDE’s serial monitor, I popped open a CLI and got to work. FWIW, I am using Ubuntu 11.04 still…ctrl-alt-t pops open a terminal window…unity has me all over shortcuts these days. Anyhow, I was able to verify that I could echo text and direct it to the USB port that the Arduino was mounted to. No sweat.

As a proof of concept, I decided to display the number of times that I had the word “awesome” on swantron.com. Once the LCD was shown to work, the sky is the limit…see some regex, pipes, wget, and so forth in action:

CLI

CLI FTW

Survey says:

+1 awesome

+11 awesome

Eleven “awesome”s. Awesome.
(Hit the bump for some code, an oddity, and more fun…)
Continue reading