Search This Blog

Wednesday, August 8, 2012

Plex Media Server crash

A quick note to the Linux media sharing community...

If Plex crashes upon upstart, try the following:

sudo mkdir /var/lib/plexmediaserver
sudo chown -R plex.nogroup /var/lib/plexmediaserver

This was happening to me after a fresh wipe and install of Plex.  When running tail /var/log/kern.log, I get several  "init: plexmediaserver main process (5424) terminated with status 134", with various PIDs, but always status 134, and then finally "init: plexmediaserver respawning too fast, stopped".

The above fix is for an older version of Plex, but seemed to work in my case.  My setup is Ubuntu 12.04 LTS, x64, Plex ver 0.9.6.3.143 from the repositories.  It seems the Ubuntu packager, Tobias Hieta, has made this mistake in the past because I found this in the Plex forums for Ubuntu 11.10.

Thursday, August 2, 2012

Automatic garden watering system using Arduino

As promised, I am posting details of my first real Arduino project - you know, after the "hello world" blinky lights and such. Although this does not stray much from blinking lights, except I will be "blinking" a solenoid valve every few hours to turn on the water.

 First, the hardware:
600 mA solenoid valve
Garden hose thread on one side and 1/2" barb on the other
See technical specifications at the bottom
I got this one off eBay, but this link will not work forever
1/4" barb <-> female NPT

male NPT <-> 3/8" barb

90 degree drip irrigation elbow 
drip irrigation tubing hold down clamps

drip irrigation tubing

garden hose female to 3/4" hose threads
for connecting hose to valve

misc. hose clamps (at least 3)

drip irrigation stake sprayers

"t" drip irrigation adapters

3/8" ID braided hose (non-braided will kink in the sun)
this connects to the outlet of the solenoid


Solenoid valve specifications:
ModelEHCOTECH  GCC-CS-12VDC
Voltage12-Volt DC
Current600 mA
Operation ModeNormally Closed (valve opens when energized)
Valve TypeDiaphragm Valve (Servo Operated)
INLET PORT3/4" Garden Hose Thread (US Standard)
OUTLET PORTBarbed fitting for 3/8" ID hose 
Pressure Rating3-120 psi
Flow Rate4.4 GPM at 60 psi
 Suitable MediaWater, Very Low Viscosity Fluids
Temperature LimitationsMaximum Fluid Temperature 195° F
Filter ScreenRemovable Filter Screen Included
Materials
Valve Body / Guide TubeNylon
 SpringStainless Steel
 PlungerStainless Steel
 Plunger TipNitrile Butadiene Rubber (NBR)
 DiaphragmNitrile Butadiene Rubber (NBR)
 Diaphragm PlatePolyoxymethylene (POM)
Mounting ScrewsN/A
Mounting PositionAny
Estimated Valve LifeMore than 250,000 Cycles


And now for the electronics:
(partially borrowed from this guy)

  • Arduino board
  • USB cable for programming the Arduino
  • Breadboard 
  • Some jumper cables
  • 1K resistor
  • TIP120 transistor (TIP102 will also work fine)
  • 1N4004 diode (1N4001 also works)
  • 12VDC power transformer
  • LEDs for indication lights
Now we will wire it up:

Some things of note about the breadboard diagram:
  1. The 9V is there simply because the Fritzing program does not yet have an AC -> DC power transformer.  The wiring, however, is the same.  For this project, I purchased the transformer from Radio Shack and the pigtail adapter.  Using a Fluke, I determined which wire was (-) and which was (+), and then connected those into the breadboard power module.
  2. The power supply provides a source of power for both the solenoid and the Arduino board, so that I do not have to worry about a 9V battery going dead while I am not around to check on the garden.
  3. The green and red LEDs are mounted to the plastic enclosure (along with a power switch). The green is used to indicate if the solenoid is energized.  The red is used to indicate if the Arduino is energized.  It actually only indicates if power is applied to the breadboard, but unless a wire becomes loose inside the enclosure, one could assume the Arduino is powered.
  4. The transistor is a Darlington NPN type.  While looking at it, with the metal heat sink on the back side, the legs are (from left to right) B, C, E: Base, Collector, Emitter.  So, from our Arduino, pin 13, there is a 1K Ohm resistor that connects to the Base leg.  This provides the low power signal to "switch on" the transistor.  The power now flows from the collector side to the emitter side.  For details on understanding the workings of a transistor, check out this video:



The wiring schematic is a little bit easier to read.  For the transistor on this one, the legs are BCE from top to bottom.


Once you have it all wired up, it's time to write the sketch:


There ya' have it!  If there are any issues / problems / suggestions, please leave a comment below.

Here are some pictures of my completed project:

Soldering the leads to the power plug for the Arduino
As you can see, the inner post (shorter one) is positive (red wire)
Please note the threads!  I almost ruined my connector by trying to pull off the plastic with pliers. 
Finished product, fully heat shrunk

Ensure the silver strip of the diode is opposite of the transistor
Purpose of the diode is to prevent buck voltage from going back through the transistor to the Arduino when the solenoid is deenergized.  A good explanation of this phenomenon can be found here. Basically, when the current is flowing through the coils of the solenoid and then the power is removed, the current still wants to flow but has nowhere to go other than back through the transistor.


Left to right: solenoid ground, transformer ground, solenoid positive, transformer positive, Arduino positive (the Arduino negative is not shown here, but is common to the other negatives here)

Arduino ground going to negative strip on breadboard



Enclosure (Radio Shack). 
Holes were drilled out for power cable, 2 LEDs, and switch.
The switch is not shown in the schematic because it was an afterthought. Just run the positive wire from the power in to a leg of the switch, and another wire from the other leg to the breadboard positive.

Yes, I know, these parts don't match those from the top of the post. I found out after assembling the female/female adapter that those threads were too deep to allow a seal because of the threads on the solenoid valve were slightly different. My solution was to use my garden hose female end (which has short threads) and put the female/female on the other end of the water hose, which then connects to the faucet.

Tygon (plastic tubing) hose to drip irrigation interface

90 degree, 3 ft. spray nozzle
The stake is zip-tied to my re-purposed pallet.

There are 3 sprayers, in 3 corners
For details on how to construct an elevated garden box (common for urban gardening), please visit my friend's wife's blog over at The Green Box Garden

Wednesday, August 1, 2012

Arduino based Nikon DSLR IR Trigger for Lightning

UPDATE: Due to the overwhelming influx from Google searches, it seems this may be a popular topic.  If you are interested in a finished package that will mount to your camera, e-mail me at (thisdomainname)@gmail.com.  I have already ordered the circuit boards and components and they should be arriving within the next few weeks.
---break---

My latest hobby projects have been using an Arduino microcontroller board:

So far I have built an automatic garden watering setup using a 12VDC solenoid valve connected to my garden hose.  (I'll hopefully get the details on this posted later)  And this, an automatic camera trigger for capturing shots of lightning bolts.

An example of it working in my hotel room:
Once I get out in the field to capture actual lightning, I will come back to edit this post.

The idea came to me while I was out taking pictures in the Florida wetlands and a massive storm system started rolling in.  As I was walking back to the car - which at this point was about 1.5 miles away - I started to see a pretty amazing lightning show on the horizon.  I could not, however, make my trigger finger react in time after seeing a lightning bolt in order to capture a shot of it. After doing some quick research, I came up with this Arduino project.  Here is the rundown... Materials required:
  • Arduino Uno (Radio Shack or here)
  • 220 Ohm Resistor (Radio Shack #271-1313)
  • Light Dependent Resistor aka photoresistor (Radio Shack #276-1657)
  • Breadboard (Radio Shack #276-002 or smaller)
  • Infrared (IR) Transmitter (Radio Shack #276-0142)
    • This will come with a transmitter and receiver. The transmitter is the darker of the two.
Setup:
Wire up the LDR (photoresistor) with one leg connected to the 5V and the other to the 220 Ohm reistor and A0 (Analog Input, pin 0).  The other side of the resistor connects to ground.  The IR transmitter is connected to D13 (Digital Out, pin 13) and ground.  It acts like an LED, so the long leg (positive side) must be connected to pin 13.  A short side note: this reminds of me of a few years ago, hacking the original Xbox to put in a modchip.  I had a bright blue LED that I wanted to solder on the board for power indication, but the clearance to where I wanted to mount it was not enough, so I clipped the legs shorter.  This is when I learned that polarity in LEDs matters, and if you clip the legs, make sure you clip the ground side shorter, or in some other way mark it so you remember.  LEDs will not function if wired backwards.
Back to the setup... if you wire it as shown in this breadboard picture:
Or this schematic:
... all you will have left is building the "sketch" - what the Arduino community calls the software / program.  I will assume you already have a working knowledge of sketches and setting up the software on your computer and will not go into those details.  If this is your first project, I highly recommend picking up the book Getting Started With Arduino by Massimo Banzi (co-founder of Arduino) from Radio Shack or any book store.  It goes well with the Arduino Uno starter kit. 
A couple things to note:
  1. This currently is being powered from my USB port.  Arduinos are designed such that once the sketch is compiled and uploaded, it is stored in the EEPROM, which has a sort of (very) miniature flash drive inside to store the machine code.  Therefore, in order for this to be of any use, I would need to wire in a battery pack to power the board out in the field.  Once the batteries are switched on, the Arduino runs the loop() part of the code continuously until power is removed.
  2. Once the prototyping is complete and I have verified it works properly, getting a printed circuit board (PCB) manufactured to reduce the footprint might be something to look in to.  The software I used to draw the above schematic and breadboard layouts is called Fritzing.  Oddly enough, it works on Linux (as well as Windows and Mac), and is a very well put together program - something I would even be willing to pay money for.  Once you have drawn up the circuit within Fritzing, you can order a PCB from within the software and Fritzing Fab will manufacture it and send it to you for $0.92/sq cm.  IE, something like this would cost me less than $10 for a professionally manufactured circuit board: