Pages

Sunday, June 16, 2013

Arduino, xBee and PWM lighting with XTension

Back on Halloween Ben and I built him a gigantic lightup inflatable pumpkin costume that was a great deal of fun. In addition to the el wire face on it we also built him an electric t-shirt with LED strips attached to an arduino, some buttons for lighting effects and a little 12v battery pack to power them.

You can see them there under his costume, at night they put on a great show, flickering and fading in and out and flashing brightly when he pushed the button that let them accentuate his awesomeness while trick-or-treating.  We used these cool white LED strips from adafruit.com. After halloween I removed them from the t-shirt and saved them for future projects. A future project revealed itself shortly thereafter in the form of aquarium lighting for his new fish tank. We didn't do any fancy remote control or PWM on them for version 1. We just taped 2 of the 4 little strips to some shelf support material I had and powered them from a generic 12v wall wort.

They worked great for a while, but the constant splashing of water on them and the metal bars soon took it's toll. I think that the power supply may have been a bit high too for they rather quickly started to degrade and individual LED's started to go dim. Even so they lasted several months, but finally died and it was time to rebuild. We had 2 more strips left over from the costume and this time we decided to do it right. PWM to control the levels so it could be dimmed, an xBee radio so that it could be wired into the Home Automation System and some buttons so he could set the level there. I had just finished an arduino interface for XTension and so decided that this should be a demo project on how to bring some of these things together. 

Here you can see how far the old LED strips degraded. The metal shelf support is rusty, the LED strips have gone opaque and you can see where some coper was exposed and turned bright green.


Yuck... This time I would build something with proper heat sinking and proper protection from the elements. I used a  piece of aluminum extrusion U channel as the base for them. It's available at HD and others as a shelf support. It's meant to go over the long edge of a plywood or particle board shelf to keep it from bowing in the middle. It wasn't quite the perfect size for 2 LED strips, they were a tight fit, but I added some extra adhesive behind them as well. 


Also you can see one of the bezel pieces. I printed those on the MakerBot out of translucent PLA. They are actually less translucent that I had though and I might replace them with just cut pieces of plastic soon, but they work for now to protect the lights from the water.

For the Arduino I went with a Fio. I'm not using the lipoly battery charging ability of it, just the fact that it's an arduino with an xBee socket built in. Both running at 3.3v so no other circuitry is required. Or so it seemed... The LED strips need to run at 12v, the Fio is rated at 12v input and initially booted and started up OK, when I had it wired in circuit and applied 12v the regulator on the board burst into bright flame or arcing or something. I removed the power with some alacrity thinking I had cooked the arduino and probably the xBee as well. Testing from USB power though showed them both to be just fine. Now thats impressive, a piece of gear that can actually catch fire and not break down! So instead of relying on the on board regulator I added a beefier external 3.3v regulator. That also released it's magic smoke upon startup. So at this point I took a step back and reviewed the rest of my wiring. Had I wired the mosfet backwards and was putting 12v into one of the input pins or something? Nope, everything looked good. So I broke out an anyvolt micro adjustable regulator and hooked that up instead. Adjusted it's output down to 3.3v and all was well. I guess 3.3v linear regulators just dont like an input as high as 12v. There are many dc/dc converters on the market now, and anyvolt also make a 3.3v version, but the adjustable was what I had on hand. Connecting that to the 3.3v input and bypassing the internal regulator completely brought it all happily back to life.



The mosfet in the picture makes PWM'ing high loads so very easy, no external parts required, not even a resister. This particular model is an N-channel power mosfet and I wired it according to adafruits excellent examples that are linked to from that store entry. Thats actually the same one that powered ben's halloween costume so it's still got some lumps of hot glue attached.  A $1.25 saved is a $1.25 earned ;) You can also see the LED strips powered up and running behind their makerbotted water protection. The plastic strips are just hot glued gently on top of the aluminum channel. I want to be able to replace them when they get a scuzzy from being in the water.


I mounted all three devices into a tiny plastic parts case with a hole drilled through the top/bottom for the xBee antenna. If you were using a lower output one with a chip antenna then even that wouldn't be necessary. 


The buttons in their final install position on the fish tank. Not very pretty, this end of the project will likely get a reworking.

The arduino interface for XTEnsion just provides a simple text based interface for sending values back and forth. basically just address=value with a return at the end. It can be extended of course ;) but for this that wasn't necessary. I opted to make the buttons and the light totally separate in the device itself, requiring the intervention of the computer in order to send back the light level in response to a button push. This means that you can't control the light if the computer if offline, but if the computer is offline I've got bigger problems than the fish tank lights. So in this code the buttons just send an ON when they are pushed (and no off, though I could do that easily enough if it's useful) and then the computer responds by sending a level for the lamp. There is a heartbeat delay between pushing a button and the response coming back, but this way I can set the levels in the computer without having to recompile the arduino code, or without having to write a lot of code to save the levels into the eeprom. So there are other solutions if you like that. You could also build this without any remote computer in the mix at all by just setting the lamp PWM value in the processButtons() handler. But this is an example of how to write arduino code that talks to XTension.


This is how the units are setup in XTension. The buttons receive the commands send from the arduino like:
  Serial.println( "button1=on");

and if you change the aquarium light units level it ends up sending a command like "LAMP=160"

XTension will also convert the address to be all caps, so keep that in mind in your arduino when comparing strings. In the code you'll see some commented out map commands as I was going to map the standard dim level in XTension, 0%=100% onto the range of PWM outputs available on the arduino, 0-255, but decided not to, just let us control it from here. In experimenting with it we discovered that 160 was plenty bright for the fish and the plants and struck a nice comprimise between light and heat output. Any more than that and the light bar started to border on hot rather than just warm. I want to keep these LED's for a long time so we are not going to let them overheat. And a value of just 4 is bright enough on the dim setting for Ben to use as a nightlight. It really does look like moonlight at that level and is quite pretty.

The computer control is important separate from the button control so that the lights can be turned on remotely when we are on vacation, or if he fails to turn them on in the morning. Since feeding the fish and turning on the light is part of his morning ritual he rarely forgets. But now I know when he last turned the lights on, and if it doesn't happen I can turn the lights on automatically and send me an alert so that I can feed the fish if he forgets. He's 8 and is really very good at taking care of them, but it does happen. 

Since the arduino has plenty of inputs and outputs available we have plenty of room available for future expansion. I think a water temperature sensor is in the near future, that will be easy. Perhaps some UV or deep blue LED's to make his fluorescent fish light up at night too. We're also starting to think about an automatic feeder that we would design and print on the makerbot and control from this same arduino.

Setting up xBee radios to work with XTension needs an entry of it's own as well. That will come shortly. Here is the source code free and open use it as you wish. download the arduino project

/*

  Ben's aquarium light 
  
  using an xBee to talk to XTension

  June 10 2013  james@sentman.com
  
  In this example, the 3 buttons send their ON to XTension when they are pushed, and XTension replies
  with the proper change to the light level. They do not directly control the level of the lamp.
  the lamp is only controlled from XTension by way of scripting from the button units.

*/


//input and output pin definitions
const int lampPin = 3;
const int upButton = 8;
const int midButton = 7;
const int downButton = 12;
const int ledPin = 13;

//these globals are used by the serial interface for talking to and getting commands
//from XTension via the Arduino interface. All commands are sent as NAME=value pairs with a 
//carriage return at the end. Set your buffer sizes to be at least as big as the longest command
//you expect to receive. These are oversized as only a single value is sent.

const int commandBufferSize = 19;
const int valueBufferSize = 22;
char commandBuffer[ commandBufferSize + 1];
int commandBufferIndex = 0;
char valueBuffer[ valueBufferSize + 1];
int valueBufferIndex = 0;
boolean gotCommand = false;


//debounce necessities
unsigned long lastButtonMillis = 0;
unsigned long currentMillis = 0;
int currentButtonPushed = -1;




void setup(){
  
 //make sure xBee is set to same serial speed. Could use faster of course 
 Serial.begin( 9600);

 //set the pinmodes for in or out as appropriate
 pinMode( lampPin, OUTPUT);
 pinMode( upButton, INPUT);
 pinMode( midButton, INPUT);
 pinMode( downButton, INPUT);
 pinMode( ledPin, OUTPUT); 
 //turnon the pullup resisters
 //to simplify the wiring I'm using internal pullup resisters for the buttons
 //that way I only have to connect them to ground.
 digitalWrite( upButton, HIGH);
 digitalWrite( midButton, HIGH);
 digitalWrite( downButton, HIGH);
 //make sure we startup off 
 analogWrite( lampPin, 0);
 //could always save the current value of the light to the eeprom 
 //and retrieve it at startup so that a power outage for a few seconds 
 //wouldn't result in the light being off.
 //give the led a flash
 digitalWrite( ledPin, HIGH);
 delay( 500);
 digitalWrite( ledPin, LOW);
 //write to XTension that the system is ready.
 Serial.println( "log=Aquarium Ready");

 //and update it's unit so that it knows that it's not on
 Serial.println( "LAMP=0");
  
  
  
}


void loop(){
  
   //currentMillis is used in the button processing in several places
   //so instead of constantly calling to millis() just do it once and put it
   //in this variable.
   currentMillis = millis();
   //check the serial buffer for any waiting command data and process it
   //if there is any
   processSerialCommands();
  
   //check for any button state changes
   processButtons(); 

  
  
}

/*
  this is part of the Arduino interface to XTension
  it can easily be reused in future projects.
  this just manages the command and value buffers and reading of data
  from the port. Any actual received commands will be passed to the next
  processCommand() method. Add any other incoming value handlers or special
  commands there. This handler shoulnd't need to be changed for most things
*/

void processSerialCommands(){
   int workByte;
  
    //if no data available then just return, nothing to do this cycle through loop
    if (Serial.available() == 0){
     return;
    }
   //read a byte
   workByte = Serial.read();

   //since all data is sent and received as name=value pairs
   //initial data is added to the command buffer. When a 61 or "=" is recieved
   //we finalize the end of the commandBuffer with a nul and start adding future characters
   //to the value buffer.
   if (workByte == 61){
      commandBuffer[ commandBufferIndex] = 0;
      commandBufferIndex = 0;
      gotCommand = true;
      return;
   }
   
   
   //this is looking for the carriage return at the end of the command line
   //if it finds the return then it finalizes the value buffer with a nul and 
   //resets the buffer indexes to get them all ready for the next command
   // and finally passes the most recently received command=value pair to the process command
   if (workByte == 13){
     valueBuffer[ valueBufferIndex]=0;
     valueBufferIndex = 0;
     commandBufferIndex = 0;
     gotCommand = false;
     processCommand();
     return;
   }
   
   
   //if we haven't finalized the command yet (or address as it's now called in XTension)
   //then we add the byte to the commandBuffer and increment the index to wait for the next one
  if (!gotCommand){
    commandBuffer[ commandBufferIndex] = workByte;
    commandBufferIndex++;
    
    //make sure that we dont overrun the buffer though and reset it if we're receiving garbage
    if (commandBufferIndex > commandBufferSize + 1){
      commandBufferIndex = 0;
      return;
    }
    
  } else {
    
    //we've already got the command because gotCommand has been set to true by the
    //check above for a 61 value or "="
    //so now add instead to the value buffer, increment it's counter and continue
    valueBuffer[ valueBufferIndex] = workByte;
    valueBufferIndex++;
    
    //make sure that the value buffer doesn't overflow and if so then
    //reset both the command and value buffer due to garbage on the line.
    if (valueBufferIndex > valueBufferSize + 1){
      commandBufferIndex = 0;
      valueBufferIndex = 0;
      return;
    }
  }
  
}

//XTENSION here is where you will receive incoming commands use the string objects to manage your response
//  add as many addresses as you need.

void processCommand(){
  String theCommand = String( commandBuffer);
  String theValue = String( valueBuffer);
  
  if (theCommand == "LAMP"){
    
    if (theValue == "on"){
      setLampLevel( 100);
    } else if (theValue == "off"){
      setLampLevel( 0);
    } else {
      setLampLevel( theValue.toInt());
    }
    
    return;
  }
  
  //add as many more comparisons for theCommmand as you need to for your application
  //XTension will always send address=value pairs if it's a change to a unit, though
  //any data may be sent with the "send data" verb including commands that have no value
  //though in that case you should still send the = and then immediately the return. like
  //reboot=/13 do not omit the equal sign.
}


void setLampLevel( int newLevel){
 //int adjustedLevel;
 //level from XTension is 0 to 100, map it so that we never go to all on 
 //adjustedLevel = map(newLevel, 0, 100, 0, 210); //keep it from going all on as that burns out the LED's
 //Serial.print( "log=level is ");
 //Serial.println( adjustedLevel);
 analogWrite( lampPin, newLevel);
  
  
}


void processButtons(){
  boolean debounceTimeout;
  
  if ((currentMillis - lastButtonMillis) > 100){
    debounceTimeout = true;
  } else {
    debounceTimeout = false;
  }
  
  
  if (digitalRead( upButton) == LOW){
    //upbutton is pushed
    if ((debounceTimeout) && (currentButtonPushed != upButton)){
      currentButtonPushed = upButton;
      lastButtonMillis = currentMillis;
      Serial.println( "button1=on");
      return;
    }
  } else if (currentButtonPushed == upButton){
      //the button is up but the last button pushed was ours so we can reset it
      if (debounceTimeout){
        lastButtonMillis = currentMillis;
        currentButtonPushed = -1;
      }
  }

    
 if (digitalRead( midButton) == LOW){
    //midButton is pushed
    if ((debounceTimeout) && (currentButtonPushed != midButton)){
      currentButtonPushed = midButton;
      lastButtonMillis = currentMillis;
      Serial.println( "button2=on");
      return;
    }
  } else if (currentButtonPushed == midButton){
      //the button is up but the last button pushed was ours so we can reset it
      if (debounceTimeout){
        lastButtonMillis = currentMillis;
        currentButtonPushed = -1;
      }
    }
    
  if (digitalRead( downButton) == LOW){
    //upbutton is pushed
    if ((debounceTimeout) && (currentButtonPushed != downButton)){
      currentButtonPushed = downButton;
      lastButtonMillis = currentMillis;
      Serial.println( "button3=on");
      return;
    }
  } else if (currentButtonPushed == downButton){
      //the button is up but the last button pushed was ours so we can reset it
      if (debounceTimeout){
        lastButtonMillis = currentMillis;
        currentButtonPushed = -1;
      }
  }
}

Tuesday, June 4, 2013

iPhone restore problems

I replaced the battery in my iPhone 4 the other day. It seemed to work fine till it ran all the down yesterday. Upon plugging the phone back in it got itself stuck in an infinite loop of rebooting.

I placed the phone into restore mode and plugged it into the computer, but it wouldn't get past the extracting and preparing software phase with a "2001" error. Which Apple says is something to do with USB. Much trying with new cables and restarting resulted in nothing.

After switching back to the old battery though I was able to restore the phone (and I wonder if I had though to do that initially if I could have kept the things that hadn't been backed up that day, alas) but I still wasn't able to reload it from the last backup because it refused to show up in iTunes.

Finally i noticed that it was showing up as an empty iPhone in Aperture which was running in the background. After quitting that and restarting iTunes I was able to make it show up and am running the restore now.

A tower of unrelated problems is so much fun to tease out.

So... Bad batteries can cause the phone to refuse to connect properly even when connected to power. And Aperture (and probably iPhoto) running at the same time can keep an iPhone from showing up in iTunes if it's been just recently restored.

Putting that information out there for any others that might find themselves in a similar situation.

Update:
I've heard back from ifixit.com from where I got the original battery, and I'll give them a plug for the best support ever, just shipping me a replacement and no hassle. I've used these guys many times in the past for parts and tools and never had an issue and the one time I did they really came through. I know you can find the batteries a little cheaper if you're willing to order direct from china or go on ebay, but their wonderful takeapart videos and their wonderful support are more than worth the extra few bucks. Support a company that will support you back!

Wednesday, May 22, 2013

xBee Motion Sensor testing

I've been meaning to do some battery tests with these things for a long time. An xBee can sleep at nearly no power use until it gets a wakeup signal. I'm not sure what the power usage of the PIR sensor is, but we'll find out.

In full on mode it works fine, but that will run the battery down fairly quickly. I'd like to set a periodic wakeup once an hour or so to just report in battery voltage or at least to give a ping that it's still there and of course it needs to wakeup whenever the PIR fires.

So now off to study the sleep settings.


Tuesday, May 21, 2013

Thermostat Prototype Stage

This is a continuation of work started in part one

I've finished a usable version of the firmware and have gone ahead and installed the prototype thermostat. It's ugly as sin with all it's interconnects and it's enormous makerbotted case, but it's working. It has a much longer cycle time than the old thermostat which was really short cycling. I'm not sure if I like it better like this or the old way. I think that to be completely accurate it's going to need to anticipate the temperature drop or rise and actually cut out before it reaches the goal temperature. I think the array that I use to average several temp readings over time will need to be adjustable in size too.



There you can see the various parts, the LCD display in back with it's IC2 backpack both from adafruit.com, the diavolino board from evilmadscience.com is my favorite arduino platform for such things, and you can't beat the price either if you're willing to do a little soldering. To the right are the xBee for comm and below that the temp/humidity sensor. That one is the parallax board purchased from adafruit and I'm not wedded to that form factor though I suppose the pins on it would make it easier to include it on a custom board. the analog board below is working great.

I need to add some fail safe logic in the arduino code that make sure that multiple relays aren't on at the same time, it shouldn't happen, but it will be easy to verify.

All the wiring is such a mess, it needs to be all on one board and this will be my excuse to really learn to use some of the open source schematic and board layout tools. I'm not looking forward to that actually as they all look like a nightmare, though some folks seem to do very good work with them. The diavolino was designed with them so I should be able to learn to use them too. 



There it is installed, looking like a total hack on the wall, but it's a prototype and I've done far worse to the house in the name of science ;) The oregon sensor is for temperature verification. I graph the 2 of them together in the computer to make sure that I'm actually measuring the temperature.

The connection software so that it can get it's info from and send data to XTension is all done. It's a very simple human readable protocol. The thermostat doesn't try to do any scheduling or setback by itself, that will all be handled by scripts in the computer so it's own software isn't concerned with such things as what time it is. The clock display is updated from the computer with a regular update that is only for display. If you dont send a clock update for 2 minutes that display changes to tell you there has been a loss of communications to let you know something is up. So far that hasn't happened, the xBee is working perfectly.

The bottom line in the display there showing the outside temp is just a text line message that can display anything. The computer can send any kind of alert to display there. At the moment I'm only sending the outside temp, but it could show anything useful there. 



The web interface through XTension is working great too. I now have 5 thermostats connected to the computer in 2 separate physical locations. The "Beach" one is at Nana's place near the beach and is connected over the internet. I have 2 wifi thermostats from radiothermostat.com, an omnistat, an aprilair communicating thermostat and until the last lightening storm an RCS RS485 model that I loved sadly it died and is now replaced with a home made one. XTension supports all these kinds now and if anyone wants to use another kind let me know, as long as it has a documented protocol. The latest honeywell wifi thermostats that home depot is carrying now are locked down and they seem to have no interest in interacting with any other systems at all, so dont buy those.


The backlight level is not automatic yet, I just control it from a unit in XTension. So when I go to bed it dims it down and when we get up in the morning it turns it up for easier viewing. I'm also tracking free memory in the arduino and sending that as a unit update. In the above example it's 0 because it's never actually sent a change since the first few minutes. There are a lot of variables and the array of floats to average for temperature so I was concerned that it would stop working after time if I had bugs in the code. With each loop through the main code it checks it's available memory and if it changes it will report it up to XTension. So far doing it's thing for several days now the available memory hasn't changed at all which is a good thing.

So whats next? I dont really like the display, I think that version 2 might have a graphical display for fancier display. I used an expensive temp/humidity module that is very accurate, but I had to make an offset parameter anyway so whats the point, there are much cheaper modules that are easier to use that I will investigate too. 

Since it's going to be an xBee socket the final product will be able to use any of the xBee's out there so you should be able to connect through a zigbee network the way I do or with a "bluetooth bee" directly as a serial port to the computer or via wifi with the wifi bees that can be placed in the same sockets. Though the setup for those will be more complicated.

Tuesday, April 9, 2013

Modern method of remote controlling a family members Mac for familiar computer support

Through the years I have helped my friends and family sort out their Macs whenever problems arose. Honestly it hasn't been often. I always tell people, if you get a Mac I'll help you with whatever problems you encounter but if you buy a windows machine you're on your own. A tribute to how easy they are to get to do what you want that I'm rarely forced to make good on the promise ;) Recently I've been helping my sister rebuild a corrupted iPhoto library and try to figure out whats wrong with all that. Doing it via "type this, click that and read me message" sort of phone support would have been impossible and caused probably a family schism due to yelling, screen sharing is the best option. But she's in another state.

In an ancient world so old as to be mostly myth and legend there was "timbuktu" which I used a lot in those heady days alas it is no longer around.

In the only slightly less distant past there was "share my desktop" a great little VNC server that you could run as a regular app, double click and it was on and I could connect and help quit the app and it was off and no danger of leaving a service running in the background on their machines open to the internet.

Eventually Apple added VNC support directly to the system. But this doesn't really solve the problem because I'd have had to walk her through configuring her router to pass through the ports for it and setup NAT to the proper mac which would have a dynamic address so it would eventually stop working and so I've have to setup either a DHCP reservation or a static IP for that machine and then run a dyndns or no-ip.com client so as to be able to find her IP or teach her how to read it off the router config page or something. Far too much work.

iChat still supports screen sharing, but only through AIM accounts, not through iMessage accounts. Which seems a terrible step backwards. I still can't quite believe there isn't a way to make this work, but I couldn't figure it out.

But now we have Back To My Mac, which isn't really all that hyped by Apple. It provides an IPv6 tunnel into our machines that we can access via our iCloud ID's. But it's not really setup to connect to other peoples machines at all, only to your own. Having had so much trouble with calendars and such and iCloud in the beginning the very last thing I was going to do was sign my computer out of my own iCloud account and into hers, I am a little shaky even thinking about what that would do to our photo streams and iTunes ID's and email and calendaring... yikes.

Luckily, you can just create another user temporarily to play with! I walked her through turning on and sining into iCloud on her machine. Then in the sharing panel you have to turn on both screen sharing AND file sharing even if you're not going to share files because that is the finder interface to screen sharing. (yes, you can probably use the command line to get the IPv6 dns name of the machine and use that directly into the VNC connection dialog, but you try walking a non-computer oriented family member through the command line commands to do this, no thank you ;)

I then created a temporary user on my own mac, signed into iCloud with her ID and there, right in my sidebar was her shared drive. Click it and "share screen" was available right there in the finder and I was able to sort it out.

Not exactly seamless for helping your family and friends as they still need to share more of their passwords with you than you should need to, but no software installs necessary, no external sites, no configuring the router for NAT over the phone. All in all back to my mac is a win, they need more features but it's really an awesome hidden selling point for your Mac. If you're not using it you should be!

Wednesday, March 20, 2013

Arduino Thermostat part 1

We took a very close lightning hit here a month ago. I didn't lose anything plugged into the wall, I have good surge protection on each electric panel, but I lost several things connected to long serial cables including my very fancy RS485 serial thermostat from HAI. I've replaced the other components and added surge protection to their long serial lines to prevent future problems from induced current but I've decided to roll my own thermostat.

I've been supporting communicating thermostats in XTension for some years now. There are 4 models that I've implemented the protocols to and there are more lined up should they ever choose to document what those protocols are. (and if you have one, or have a favorite you think should be supported please let me know) so it's not like I have a lack of good thermostats laying around here that I could install. But I'm drawn to dangerous DIY like this.

I've decided that it should not do very much in the thermostat at all. Since it's going to be connected to XTension through an xBee radio link I really have no need of schedules or setbacks or anything, I can do that all in the logic of the computer. Since I've basically disabled that functionality of every thermostat I've ever installed and just run it from the computer anyway it seems like a lot of added complexity in them that I never use. I've been using those xBee radios for some time in lots of projects around the house and they are just awesome. XTension lets you control their pins, or read their analog inputs or use their remote serial ports for just about anything.

This device I"m making wont be a one size fits all for everyone, but then anybody considering doing this should have some info on what they are doing since getting this wrong could potentially ruin your house in the form of frozen pipes or destroy thousands of dollars worth of compressors in your AC or worse. So I'm not going to sell a kit or anything, but it's been interesting me for some time.

Here's the power board completed. It has the connections for the thermostat wiring, 3 solid state relays and the half wave bridge rectifier and smoothing capacitor to make the DC prior to feeding it into the arduino power supply. Since the furnace here is simple, only single stage only 3 are necessary. The fan relay, call for heat and call for cooling.




I debated how to switch the lines to the furnace. I could have used cheap relays, but they use not insignificant power that can cause heating inside the case and false readings (but you can get around this like more commercial thermostats do by putting the relays at the top of the case and the sensor at the bottom and using the heat to create a chimney effect of room air past the sensor making it read actually better) but it can also cause problems with voltage fluctuations causing false readings from analog temp sensors and other things. (this wont be a problem since I've decided to go with a digital temp sensor) Plus you can hear them click and that is just so last decade... The problem is that you're switching AC power, so just a single mosfet isn't going to work. You can use 2 wired in opposite directions to do it or an SCR or any number of other ways, but these SSR's are not expensive (I think I paid around $5 each for them from allelectronics.com) and I had them around. Additionally they provide complete isolation between the logic and the current being switched.

The capacitor is overkill by 3 or 4 times, but it's what I had around and it mostly fit on the board there. There are 2 diodes on the board wired in series. I used what I had, those are fancy fast acting low voltage drop schottky diodes which are totally overkill for this power supply too, but I had a bunch of them left over from switching LED power supply experiments. They are rated for an amp of power which is good, but only for 20 volts, so 2 in series are necessary to safely rectify the 24v from the furnace. I used a simple half wave bridge here because the output from a full wave bridge would have been more DC voltage than the switching regulator I've ordered for the arduino side is rated for on input.

Apart from just following good coding practices when I start writing the code, and making it as simple as possible I will be implementing a ping and response system between this and XTension so I can tell if it goes away or gets hung up. I've done a lot of smaller projects with Arduinos and I know they can run for extended periods without problems. Even so, this being a one off project I need a way to reset the thing automatically if it goes down. My first thought was to use one of the many unused pins on the xBee connected through a transistor to the arduinos reset pin. Then I can reset it from the XTension computer if I lose the ping. Though I am beginning to think a local circuit with some timer or capacitor that needs to be regularly restarted by a pulse from the arduino and will cause a reset if it doesn't get that pulse might be good too. A kind of local watchdog timer too. We shall see what happens.

Shortly I'll be connecting this board to the power from the furnace and measuring the output and making sure that all works even though there is no control logic yet.

Today I'll be putting together the arduino and hopefully the fancy temp/humidity sensor I ordered will arrive and I can begin that side of the project.


Sunday, February 10, 2013

WD My Passport 2TB drive


I purchased a very reasonably priced Western Digital My Passport 2TB drive the other day. I thought I'd be terribly clever and extract the drive and implant it into my laptop. WD outsmarted me though and have the USB3 interface on the drives interface card. It's not just an SATA drive with an adaptor. So back into it's case it went and I just relocated portions of my iTunes library to it rather than increasing my laptops size.

The case came apart easily enough though. Yielded without incident or any tab breakage to my selection of spudgers. It snapped back together just like new after sharing it's interface secrets.

Even though I wasn't able to get it into my laptop I am still happy with this. The fact that there is no extra card in there for the interface means that the case is as tiny as possible. The speed of the disk is also impressive for an external, even compared to the other USB3 drive I've got which is a seagate free agent goflex. Which I also like since the sata interface is a separate dongle and you can pop it onto any sata desktop drive. (though there are no provisions for external power so you can't connect it to a full sized drive.)