Showing posts with label Builds. Show all posts
Showing posts with label Builds. Show all posts

Friday, January 11, 2013

Parallelism in Hacking

I spent yesterday morning working on the datalogger, specifically making it WiFi capable.  This morning, I slept in, made my coffee and checked the news.  Over on Hackaday, Jose has created an Arduino/Pi/WiFi/X-Bee environmental monitor.  He's got his own webspace, uc4fun, where he's hosting the notes on his project.  A lot more professional looking than mine.

He's essentially doing my project (If he knows I exist, he's shaking his head saying "That guy's doing MY project").  However, he's doing it in a completely different fashion, which is awesome.  I think he's using a mix of I2C sensors (he's using the TMP102 and the BMP085) and a Sparkfun humidity sensor (Dude!  New Product Friday.... 'cuse me while I go browse...).

I think he went with the doubled up microprocessor approach because it allows him to use the ADC's on the Arduino.  So far, I've been severely limited in the sensors I can use on my build because I'm only using I2C and binary digital sensors.  His complexity gets him some serious advantages, but is also one of the main things I want to avoid (He's probably writing code for both the Arduino and the Pi.  That'll give me headaches).  I sent him a message on the Hackaday board asking why he made the choices he did.  Looking at his build and presentation, he's going to have some good answers.

I definitely wanted to avoid the multiple radio links.  Given my history with RF links, I'd like to keep that as simple as possible.


Sunday, December 16, 2012

Integrating the TMP102 sensor with the datalogger, and I2C bus lengths

The TMP102 is an I2C sensor available on a breakout board from Sparkfun TMP102.  It's pretty cheap, under $10.  It will actually allow you to have multiple sensors on the same I2C bus just by jumpering an address pin.

I'm working on creating a software module to decode the output from the sensor.  So far it isn't straight forward, at least for an amateur.  If I understand correctly, the sensor reports the readings in a backwards fashion.  I'm not sure I've decoded the output correctly, but I'm close.  Once I get that ironed out, I'll post the code up.

I started playing with I2C bus lengths.  I heard that the practical length was less than a meter.  I've got around a 2-3 meter CAT-5 cable set up running the TMP102.  It's dangling outside the window, inside a tupperware container, and appears to be working just fine.  I'm using Sparkfun RJ-45 Jacks and breakout boards.  It adds a couple of bucks to the cost of the project, but it makes for great modularity.  It's also going to let me do some cable run tests.  Eventually I'll post those up as well.

I modified the jacks and breakout boards slightly.  In place of a simple header, I used Arduino 8-pin stackable headers.  That way, I can easily add a second sensor (or more) at the cable end, while still being able to easily breadboard it.  So far it's working great.

The goal with this setup is to have two sets of environmental sensors.  One on the Raspberry Pi itself, and the other just slightly remote from the Raspberry Pi.  This sensor set could be outside a window, inside a terrarium/fish tank, inside a science project (fermenter? soil analyzer? hot water heater?), all kinds of possibilities.

If I can make the software scale-able, anyone could add all kinds of sensors to the system and have it easily recordable.  The only drawback would be writing new sensor drivers for each set of sensors.  That's where I'm having a fair amount of difficulty now.

It looks like I was wrong when I figured out the size of the data files.  Right now, the datafiles appear to be much smaller, despite my cramming more information into them (Temp1, Temp2, Pressure, Motion Sensor, Time, Log Level).  I think I want to change the logging system even further so that it creates a better record of values.  Right now I'm saving a string for each sensor cycle with just the sensor values.  The software is written so that it assumes a certain value is in a certain order in the string.  That's great, as long as no one else is adding sensors to the system, and you only look a certain way.

I'm wondering if I can create a log with each sensor cycle recording a dictionary.  Then I could easily write code to examine which sensors were polled for each sensor cycle.  I could easily pull all the sensor values, or some of the sensor values.  I could have some sensors polled more often than others.

I need to grab a second Raspberry Pi, and start thinking about how to pull all the sensors nodes together, into one easy to read display.


Monday, November 19, 2012

Raspberry Pi Home Datalogger

I've wanted to do something like this since I first started playing with microprocessors.  The idea of an inexpensive, distributed sensor network throughout the house is really cool.  In Hollywood we always see someone sitting at their computer console accessing their security system.  It's typically a wire-frame display with sensors all over the place.  They're getting all kinds of data, and even providing the occasional remote output (displays, lights or sirens, etc).

The $35 Raspberry Pi is almost the ideal basis for this kind of sensor network.  It runs a (relatively) well developed Linux distribution.  It has two USB ports, runs on 5v, sports an ethernet port, and will support almost any video display out there.  More importantly, it has several exposed general purpose I/O pins and supports I2C.

I'm using Lady Ada's Occidentalis distro.  So far it has been incredibly stable (though it swaps between video outputs if I cut power to the system).  I'm using this distro because there are examples using Python to access the various GPIO's and the I2C.

My previous post detailed some of my earlier experiments with the system.  Since then, I have worked on building a series of programs to access a BMP085 board attached to the I2C bus.  I haven't done much with Python in quite awhile, so I'm fairly rusty and lacking a definite style.

I finished a series of programs last night that check the sensor, log the sensor data to a logfile and update a webpage, and a simple program to automate the whole process.  Currently I've got the sensor being checked and logged every minute.  The logger program is using the Python Logging module.  I'm recording the event level (I'm generating a warning if the temperature reaches 30c), the epoch time (to facilitate graphing later), and the temperature and pressure (I don't care about the altitude).  Using epoch time versus Python's asctime also saves some memory.  The log files are between 1.8 and 18 megabytes per day (one measurement per minute).  This yields recordings between 50-500 days per gigabyte.  I'm not sure why there is such an insane difference between "Total Size of Files" and "Size on Disk".  Given that it's close to an order of magnitude, I need to address that at some point.

I'm looking to increase the number of sensors on the board.  I'm playing around with a GY-80 board that I got off of eBay some time ago.  It includes the BMP085 sensor, plus an IMU/Gyro component with a compass.  It was about $20.  I'm wondering if the resolution is tight enough to work as a seismograph, though I'll have to increase the polling rate to something much higher than once a minute.  Luckily, with the processing power of the Raspberry Pi, I could poll the sensor very quickly, analyze the data locally, and only report data that was relevant.  This idea is going to be an add on after some of the other to-do list is achieved.

A big thank you to the write of the Giuseppe Urso Blog.  He's found the datasheets for all of the components on this board (I think).  The ebay seller has not been able to provide good information for me.

Things to do:
I want to improve the webpage.  Right now it's a simple Apache text page that shows the temperature and pressure, along with the system time of the latest measurement (actual time, not epoch time).

I want more sensors.  I'd like a light and motion sensor (again, we're trying to get close to that Hollywood sensor system).  It would be great to incorporate a smoke/carbon monoxide/gas sensor into this build.  A networked, web-enabled hazard detector would be incredible.  I've already got a couple of sensors for this. To get them to work, I need to grab something that will let me add analog to digital feeds to the board (perhaps this?).

I really think I'd like to incorporate a second temperature sensor.  I'd like my first sensor node to be located just inside the front door.  Running a cable outside to a sensor (MPL115A2) would be pretty easy, and would give me the ability to log the weather outside compared to the environment inside.  The capability would also be nice if Angel decides to start working with herps again.  This would allow us to monitor the inside and outside of the tank.

The webpage needs serious work.  I'd like to be able to generate graphs of the data, on the fly (click on the parameter, and it brings up a graph of the last hour.  Click on that graph it shows the last 12 hours.  Click on that, it shows the last day.  Week, month, year, etc).  My skills with Python are not up to the task yet.  Hell, my skills with HTML are essentially non-existent (My webpages in the past have all used Dreamweaver).  I need to see if I can merge the two, and someone get the Python code to play nicely with a Dreamweaver generated page.

Automated alerts.  We'll go back to the Hollywood example for this one:  When the bad guys are breaking in, I need the network to tell my cellphone (or bring up an alert on my computer).  A more practical concept:  When the house gets too hot, I need to be told.  When the house is on fire, I need to be screamed at.

I want to keep the cost down.  The average cost, per node, should be less than $100.  At this price point, folks can afford to pick up a couple of nodes to watch their doors.  As they like it more, they could grab additional nodes for other rooms in the house (I want to be able to control my small home theater system using my cellphone and an IR equipped node).

Webcam support.  The Pi has two USB ports.  Once the node is developed, there is no reason to have the USB ports in use.  A web cam is a cheap (I saw a couple for under $10 the other day) way to gain tremendous amounts of information about a locale.  Even if the camera is only used to snap stills to send to a remote site (or just log locally) the idea has tremendous value.  As it stands, I haven't even tried hooking up a camera to the USB ports.

Free and open code.  An idea like this is only as usable as the guy making everything.  I'm not an engineer or computer scientist.  If I could get a couple of those guys interested in the project, they'd be able to do incredible things with it.  More to the point, they'd see ideas that I'd never even consider.  This project, as an open source project, has real potential.  I'm going to work on setting up a GitHub account, and making my code public (I'll warn you, it's ugly code).

I'll post up more as I get it.

Late edit:  I'm starting to look at Lady Ada's Raspberry Pi WebIDE.  I spent the afternoon/evening learning BitBucket, and now I've got a BitBucket account with the code on it (PiLog).  I may not be doing things correctly, so the repository may be a little bizarre over the next couple of days.  The code that was loaded tonight was tested to work, though your mileage may vary.




Tuesday, November 6, 2012

Overdue Updates

For my one reader (Thanks Mom!) I know the updates for the Ultrasound Phantoms are overdue. There is progress. Unfortunately, you don't get to read about it today.

 A couple of months ago I read about this cool new computer, the Raspberry Pi. As far as I know, they've only shipped the model B board, which is $35. That money gets you a Linux computer that is slightly bigger than a credit card. You need to supply a keyboard, SD card, and that's really it. If you want to run a Windows-like GUI, you'll want to have a mouse as well. It's got a couple of dozen general purpose I/O pins to let you build in your own gadgets and stuff (Read a pushbutton, blink an LED, etc).

 The board supports at least half a dozen types of Linux. I went with the Adafruit Occidentalis build. It's build off of Debian Linux, with some added extras, This incorporates libraries for SPI, I2C, One Wire, and WiFi built right into the distro. Couple this with the already included Python (Version 2.7 and Version 3.2) and you have a junior hacker's dream.

 I'll reiterate: $35. I had everything else lying around the house (SD card, spare keyboard and spare mouse). I have a computer that will hook up to pretty much any video display I'll run into. It supports HDMI 1080p right out of the box. It plays nice audio. It surfs the web (slowly, sometimes). For less than the price of a copy of Windows, a new video game, or a tank of gas (holy crap! Yeah, and I drive a Prius).

 It's Linux. For some people that will be a deal breaker (Again, less than the cost of...). I'm having to relearn a fair amount. I used Linux a couple of times, years ago. I had a Linux box once, to toy around with. I had a dual boot netbook where I utilized Ubuntu to run some network diagnostics.

This time around, I'm really focusing on the command line interactions. The little gizmo is decent with the GUI but it does slow down a fair amount at times. However, this thing screams from the command line.

 I'm re-discovering Python as well. I learned 2.7 during college (Thank you, Dan Fleck. You got me excited about programming, and changed my life). It looks like there is a serious attempt to use Python 3 in the Raspberry Pi world.

 I wrote a quick utility to poll the Adafruit Pi Cobbler pin-breakout board. Eventually I want to get the pin states over a network.
import RPi.GPIO as io 
io.setmode(io.BOARD) 
for i in range (26): 
     try: 
          io.setup(i,io.IN,pull_up_down=io.PUD_UP) 
     except: 
          continue 
     try:
                    print(io.input(i),i)
               except:
                   
                    print('invalid pin ')
                    print(i)
          print('Complete')

I'm running the program over SSH, so I guess, technically, I'm checking the pin state over the network.

It's important to note:
First, you have to run the program with superuser permissions (sudo).
Second, the program numbers the pins differently than the pins are numbered on the Adafruit breakout. Third, you probably need to be REALLY careful with this code. It attempts to mess with all of the pins, some of which aren't GPIO pins. So far, it doesn't seem to have bothered anything.

I'm waiting for some more parts so that I can start messing around with I2C sensors. Eventually I want to build an environmental monitoring system.

Tuesday, June 21, 2011

WiFi Sniper Rifle


I'm working an insane amount. Between the hospital and school, it doesn't leave much time. I stuff that time with the consulting work, and efforts on a new project to make a fair amount of money.

This post is about none of that.

One of my classes last semester was Wireless Network Security. It seemed to me that like many security problems, this was one of access. To top it off, because many people (and still some organizations) use shoddy security, if you can just get access, you are on the network. I've sat in a couple of dining rooms and offices showing clients how quickly their network can be compromised by not using their security tools correctly.

I'm also getting ready to go on vacation in the wilds of Canada. I'll be honest, I like my internet to be readily available, wherever I go. The last time I was there, we had some issues with signal and antenna aiming. I've been thinking about that problem ever since.

I had some parts lying around the house. Specifically for this project I used only a couple of real parts:
1x 802.11 2.4GHz "25dBi" antenna (Supposedly it works on 5GHz as well, I haven't tried)
1x 802.11n MIMO USB adapter, with two removable antennas
1x AR-15 Lower Receiver with handle (Airsoft Surplus, no modifications needed)
1x Removable stock
1x Cheap Bushnell Scope w/mounts
1x Short length of P-rail to mount the scope

I also used some PVC piping (1 inch, I think) to act as a pillar for the antenna, lower receiver and scope to attach to. I made a small acrylic block and secured it to the PVC pipe as a connection point between the PVC and the lower receiver. Various screws, nuts and some scrap wood were used (The scrap wood was planed to fit in the butt of the PVC, to further secure the PVC to the lower receiver. Another plug was fit to secure the pistol grip to the lower receiver).

I sent a picture to a friend of mine. I think I need to do this with all of my kit-bashes from now on. In the past he's typically been working next to me, when I do these things. He frequently says things like "Are you sure you want to....", or "Hey man, that's not real smart....", or "Is something burning?"
In short, he's the safety cut-out for many of my projects (Despite the fact that he literally has an entire self-inflicted injury category named after him).

His first reaction "Dude! (He's 37 or something) Dude! Is that a railgun?"

So I disappointed my best friend, but again, he probably saved me some grief by showing me a big problem.

This thing looks just like a firearm. More to the point, it's a scary firearm that will make everyone twitch if they see it. Not exactly the kind of thing you want to hang out with on a hill, and point at random dwellings to get an idea of its range.

Now, as an aiming device, this thing is going to be great. I'll be able to visualize my target antenna, and then slowly move the system around to get the best signal. However, I already recognize the difficulty of typing while shouldering the "rifle".

To combat that (and the scary pointing issue), I'm working on a tripod mount for the antenna and PVC assembly. Once the signal is established, I can disassemble the stock and lower receiver around the antenna/PVC assembly, which are secured using a stable tripod.

This is going to work really well in the Wilds of Canada (It sounds cooler when I capitalize it), and at home, I probably won't need the extreme range features of the whole build. I may look at a method of just securing a hand grip directly to the PVC. Then it's going to look like I'm aiming a giant linear antenna, instead of a railgun.

Thursday, October 16, 2008

Junk to Jewels



I'm a creative guy, but as an artist, I suck.  I truly do not have a good eye for aesthetics (my best friend does, and it drives me crazy).
So when I set out to make something, it has to work.  It may not look good, but it's going to work (and if it works, it typically works very well).

I build computers on the side.  Friends and family get it for free, others pay a small amount, typically less than what they would be paying for a retail computer.  Oh yeah, you don't have to wait an hour to get me on the tech support hot-line.  And yeah, I do make house calls.

I've got a fair amount of compu-junk lying around in boxes, or attached to old projects (My last big build was a dedicated computer built into my truck.  Full nav, MP3 player, position and speed tracker, on board diagnostics, a real nice system.  Too bad I had to yank it when I sold the truck and bought a Prius).  Much of it is older stuff that has been taken out of a computer or other project that is being upgraded.  Every once in awhile, I get a new piece thrown my way.

This build started off as a "perfect storm".  Everything came together rapidly.  First, my sister bought me "Ironman" on Blu-Ray (great movie).  Unfortunately, I don't have a Blu-Ray player or an HDTV.  I went and did a little research, and those things are expensive, particularly if you want a good player:
I specifically wanted one that could output to a variety of sources, and would connect to a home network (it turns out that this last option is kinda rare, and not cheap).  I was looking at hundreds of dollars, probably over $500.

As a lark, I researched Blu-Ray drives for PC's.  While searching, I took a look at Blu-Ray recorders, and found a unit from LG for $190, including free media:
A Blu-Ray burner, for under $200?   This project started to have a pulse.

A friend of mine had recently told me he was going to give me a motherboard that he had bought for his office computer.  He had purchased the wrong one, and in exchange, I would help him get the right one (turns out he was doing something similar, he wanted to use his PC on his big HDTV on the wall).  So, I was getting a buff new board, from my favorite MOBO company (ASUS).
Free

A friend had given me a shuttle PC case and power supply a couple of years before.  I'd never had a MOBO for it, but that was getting taken care of.  I went and grabbed it out of storage, and it looked perfect.  Unfortunately, it's a couple of years old, so I don't really have a weblink for it.

Memory was going to be salvaged, along with the processor (Intel Q6600) from an older motherboard.  As it turns out, the memory was not compatible with the new motherboard, so I had to get new sticks (thank god they're really cheap).
The price is off on the website, mine was $50 with another rebate on top of that.

The fan also had to be replaced.  The fan on the old motherboard was too tall for the shuttle PC case.  I splurged a little here, and got a Zalman fan with a 16dB sound rating, for $34 (Thermal paste another $7).  I was a little worried that it was going to be too broad for the motherboard, but it fit beautifully.  Even at it's highest setting I can't hear the fan noise over the background noise in my bedroom/office.  Certainly when the TV is on, I won't be able to hear it.

I salvaged another graphics board from an old PC.  This board (a Radeon x1600) had a VGA, DVI and S-Video output.  The S-Video is what I really needed (The MOBO has VGA, DVI, and HDMI outputs.  Unfortunately the DVI is not a full DVI output) to be able to get the computer to display on a standard TV.

So, the build was broken down like this:
ASUS P5Q-EM Motherboard Free
Intel Q6600 Processor Free
ATI Radeon x1600 Free
Zalman Fan and thermal paste ~$42
Corsair 4gb Memory ~$50 (minus a rebate)
LG Blu-Ray Recorder Drive $190
Windows Vista Ultimate Free from old computer

Total cost: $282 (I missed my original price point of $250 by 
$32)


I choose Vista because XP doesn't support Blu-Ray drives (or playback).  I also happened to have an extra license from an old computer that wasn't going to get ressurected (at least not right away).  I also have had pretty good experiences with Vista to date, and I'm not really sure what the griping is about (though I'll admit I would have like to see more of the promised features in the upgrades).

I'd like to thank the ASUS community forums real quick.  The memory incompatibilty issue really stumped me.  When I first started testing the board, it powered up, but nothing came on with the monitor.  This isn't my first build, so I spent quite awhile (hours) trying to figure out what was wrong.  Within hours of posting a plea to the forum community, I had a simple answer (that I probably should have come up with), and my fix was evident.  This is one reason why I keep going back to ASUS.

Once that was taken care of, installation was a snap.  I initially installed using a dedicated computer monitor.  I wanted to get the system up, drivers installed, and everything working before attempting to connect the computer to a TV set.

Once that was accomplished, I set the screen resolution down to 640x480.  I then shut the system down, and hooked the video and sound up to the TV.  Lo and behold, the Windows boot logo came up, and the desktop appeared.

I put in Ironman, which immediately booted through PowerDVD (bundled with the Blu-Ray drive).  Ironman immediately accessed the internet and pulled down additional content (pretty cool, but I have no idea what it actually pulled down).  I watched the first scene, and fell asleep, happy with my build.

I finished watching Ironman the next day.  While I'm really pleased with the build, I can't wait to see what this looks like on a true HDTV.  That's probably going to be a really long time in coming, as I had to reach deep just to finish this build (I'm actually a poor, not-quite-starving college student).

The interface is a little difficult.  I need to find a way to make my Harmony remote control the media functions of the PC.  I also need to find a decent wireless media keyboard for the system (my old Media Center Keyboard apparently has had a stroke or something).

I don't know that this is a viable option for the majority of the people out there.  Cost is close to a real unit:
Case ~$100
Processor ~$75
Memory ~$50
Motherboard ~$140
Operating System ~$150 (at least)
Blu-Ray Recorder ~$200

So around $700, call it $850-$900 with labor.  However, this system will RECORD to Blu-Ray disks (and CD's, DVD's, dual layer disks, and lightscribe).  It's incredibly hard to find Blu-Ray recorders for home theaters, and the ones I found ranged from $1000-$2,500.  Granted, that price is going to come down tremendously over the years.

However, this system will also do everything that a normal PC will do (email, internet, etc).  With the addition of a TV tuner board:
This thing will also be able to act as a TiVo/DVR (Approximately $150).  It won't be able to get premium channels (yet), because the consumer electronics industry hasn't jumped on the capabilities of the CableCard system yet (that's a rant for a later day).

I need to figure out how to get movies from this system to my iPod.  I've never watched a movie on my iPod (I don't really sit still long enough to do that), but I'd like to be able to do it.  Also, the Genius's at the Apple Store told me I couldn't.

Don't tell me "no".  It just eggs me on.



Be safe out there, and remember to vote.

Edit:  Quick update.  I under clocked the processor to run at 1.2Ghz (half the normal speed), which dropped the CPU temperature from 36-39 degrees centigrade, down to 26-29 degrees centigrade with the fan now running at the lowest setting.  Video playback seems to be unaffected, but the boot times seem to be slightly longer.