Sunday, December 27, 2009

Order Arrived

My LCD screen arrived! Along with the switching regulators.

Turns out the switching regulators were the wrong ones. They do perfectly fine on 3v, but not at all on 1.2v. Thankfully, futurlec sells another one by maxim which is designed for 1-cell operation. I'll include it in my next order. The alternative is to wire two solar garden lights together, and have a two cell system.

I also need to figure out the windmill, the voltage varies a huge amount, and I was thing that charging a 3v battery pack might be the go. My only concern is voltage, as the windmill can get pretty fast! Maybe I should keep an eye out for a dedicated two cell charging chip - accepting a wide range of voltages.

On the web interface, I am rather stuck. I need to make it so that I can edit configuration files from the internet. PHP doesn't have any major line editing functions, but I have figured out a few work arounds. Next time I work on it, I might get somewhere!

Wednesday, December 16, 2009

What's been happening?

Where have I been!?

I've started working on all sorts of projects lately. Largely due to the long lead times on low priority shipping from Taiwan. I've ordered a new LCD - this one is a graphics LCD! - and some switching regulators - to power these devices from 2 AA batteries.

I need to get my entire sensor net up and running. I'm considering building a USB powered device. It's easy, and has no major power design issues - unlike the solar powered version I haven't managed to get working! I'm ordering two switching regulator sets, so when those arrive I should be sorted. One is going in the garage with a 3v battery pack, and one is going to be wired to the solar garden light. This one will be fed on a 1.2v NiMh AAA battery charged by the solar panel.

On the software side. I have a fully functional, but not yet fully featured python script that runs on boot. The trick was to put the start-up scripts in the original root, not the pivot root! A hurdle I am currently experiencing is time. I need to synchronise the router with a NTP server - a server designed to update system clocks. This will give my router the correct time as it has no backup battery / capacitor. That is the easy part... That hard part is making the router use the correct timezone. I could call it a feature that it uses UTC (Universal Coordinated Time - not an acronym mistake!), but I would really prefer it used the local time. Hopefully I can change this in the python program rather than the router itself...

I have successfully made an LED that will turn on and off via an SMS sent to twitter. The direct message is read by the router, and this triggers the LED. I plan to use this for a fan I have - the type used in summer for keeping cool!

No photos as of yet. The whole device is still in the early days.

Saturday, November 21, 2009

Scripts, and more scripts...


My router runs three different scripting languages now. Built in bash, lua, and python.

A person suggested lua as an easy scripting language already supported in OpenWRT. The problem was that I couldn't get processes to start on boot. So I set up a simple lua script to try do the job.

The problem wasn't to do with init.d however. The problem was I used pivot_root - a tool to create a new '/'. This meant I could move the old root to /mnt, and use my USB stick as /. Anyway... To get things to start on boot, I had to copy my init.d to the old root and make the symlink to rc.d.

The lua script is now redundant, so I might get rid of it. It does however make it easy to add new stuff without having to copy the script and symlink - not that that is hard...


My router now starts a *working* pythong script, a server for hosting my website (lighttpd), and a server for uploading files to my website (vsftpd). Everything it needs to do it now does!

Finally I can stop repeating myself on the router, and start getting a functional system online! The only major router stuff to do is:
  • get python to read twitter names from a text file
  • get the website's members area to edit the above file
  • get ntpclient to run on startup, and edit the timezone to NZDT
I figure I will get the *.CSV files to be created fresh daily. So at 0000 to 2359 is will have one file, and the next day there will be a new file. This will make it a little easier to see what happens day to day.

I think I will get python to create a 'comments' log file. It will be more user readable than the *.CSV files, and will include things like boot, message file edited, and any other useful stuff I can think of.

I've built the simple indoor temperature sensor into a warehouse box I found (don't worry mum, it was from an old project!). All I need now is a power supply. The HopeRF units need a steady 5v. This makes powersupplies hard to design, as I want them to be efficient, and low power. I'm hoping for atleast a one year battery life. Did somebody say switching regulator?

Friday, November 20, 2009

Long Day

Been a long day today... I've managed to svn checkout the latest trunk, configure the image for flashing, compile the binaries, flash the new firmware via TFTP, configure the basic network options, set up a pivot_root so I can have more space (uses 32MB flash drive), re-configured network stuff, installed lighttpd, vsftpd, python, python-twitter.

The damn init scripts wont work! For some reason the /etc/init.d/lifghttpd and /etc/init.d/vsftpd scripts will not activate on boot. They have been enabled and made executable.

The only work around I have left is to lower the serial port baud rate, and use a microcontroller to start them. A higher power type deal. The micro waits for a particular string (I'm thinking a long pause might be easier...) and then sends a linefeed. This will acitvate the console over the serial port. The microcontroller will have to send a few commands to the router. Then there will be a python program running in the FOREGROUND. Instead of using pyserial, I will just have the python wait at a raw_input() command. The microconroller will talk directly to the python program.

I don't like this solution. It seems like a stupid idea to have a microcontroller take the place of a person when it shouldn't need to. The router should be able to run the processes on its own.

Wednesday, November 18, 2009

It works!

Took this video a while ago, but I'm showing you now =)



At the moment I have flashing new router firmware. A few things were going wrong with the last lot... I'm hoping to have that done before I go to bed. No school tomorrow, so I'll be able to get lots done! I might even make a blog post about it!

Monday, November 16, 2009

New Plan

AVRs are hard. Coming from a PICAXE background they are hard. Development time with a PICAXE was a few minutes to a few days. I still have only managed basic tasks with AVRs that took minutes on a PICAXE.

So, I have decided to build the system with PICAXE, and replace them with AVRs. What this will mean is I have a working system online, can easily add features, and not spend all my time learning. AFTER I have a working system, I will then try copy it with a bunch of ATmega48s. After replicating the circuit on a breadboard, I will order a collection of SMD parts, etch a board, then solder together a nice small finished product.

Basically, I will get a system online, and then take my time with the AVRs. Each unit will be done as standalone - I will replace individual components, and keep communications protocols the same. Once I have a fully operational AVR system, adding new features (software I might add) shouldn't be too much of a task.

I spend a bunch of time working on an AVR project, and don't get very far. It took me a weekend (on and off) to get a HopeRF -> AVR -> 16x2 Character LCD. This in PICAXE would have been a simple excercize, but for AVR it meant learning how to interface the LCD and the USART. Both very simple on the PICAXE.

I have big plans for microLOG =)

Saturday, November 14, 2009

History

This project is not new. I have been working on it since about January 2009.

WHAT IS IT?:
Put simply, microLOG is a data logger. This means it measures a sensor in relation to time. Presently I have only used a room temperature sensor, and the data logger would log the temperature every 20 minutes or so. It stored the data as a *.csv file, and this could be imported into excel for graphing.

ORIGINAL IDEA:
A system to log data, and transfer it to a Casio fx-9750G PLUS - a graphical calculator used in New Zealand schools.

CURRENT IDEA:
A system to log data via wireless nodes, create a *.csv file, and upload to twitter. The system can be configured by a web interface.

WHY THE CHANGE?:
The communication protocol for the Casio calculator was too much for my PICAXE, and too much for the mighty Basic Stamp 2. The Casio expects a verification header, followed by a data packet, and then an end header. These data packets all had checksums which luckily were just sums. The checksum had to be generated, the data sent, and only then would the calculator accept the data. I never managed to get this to work...

SOLUTION:
I ended up with a VDRIVE2 - A USB flash drive to SPI / serial 'converter'. I was able to get a PICAXE to append data to a *.csv file on the flash drive.

I saw mightyohm's tutorial on how to hack a wireless router into a WiFi Radio. I also saw Andrew's photoset on using an OpenMESH router as a way of uploading data from a PICAXE to the internet. So I combined the two and ended up with a router running OpenWRT, running a python script, running an http server, and reading data coming off the HopeRF.

HOW MUCH TIME WAS SPENT?:
This is the major project of mine, so it takes up the majority of my free time. I spend a good few hours a week on it, and it has been over half a year SO: 4 hours a week * 40 weeks = 160 hours!

HOW MUCH MONEY WAS SPENT?:
Tough one, as I don't write it all down... I would say about $50 worth of PICAXE gear. A $12 LCD screen, $150 worth of wireless units, $60 for the router, $40 for the VDRIVE, and maybe $20 worth of misc stuff. That lots totals $332. In the competitions I have entered, I have won $485. So I have made $153. It's awesome to think that I have made money on a project I built in my spare time. There are more competitions to enter it into, and this could win more cash!

As a side note, I do this for the project, not for the money. Much of the money ends up invested into the project, or into the hobby. The major purchases with the prize money are a $220 Digital Camera, $75 worth of more HopeRF units, $60 for the wireless router...

WHAT AM I WORKING ON NOW?:
  • I'm still building the web interface.
  • I am upgrading from PICAXE to AVR - bloody ATtiny series doesn't have USART (only in ATtiny2313 which doesn't have ADC). Lucky for me, the ATmega48 costs a mere $2AUD and comes in a TQFN package. I can develop on a breadboard with my PDIP ATmega48, and then etch a board, and solder on the TQFN. SMD soldering is actually pretty easy!
  • I'm working on adding more sensors. I have a windmill, so I will measure RPM, voltage, and current (shunt resistor and ADC I guess..). I can also wire some push buttons to the garage, and log the opening and closing of the garage doors.
  • 'Reverse Tweeting'. You can txt a direct message to microLOG, and it will perform a task (maybe I'll log the messages too!)

APPLICATIONS:
I tell lots of people about his invention, and many say "It can be used for security". PIR sensors can be wired in, and a tweet can be send when one of these sensors measure activity.

Personally I think it can be used in schools. Students will be able to do science homework (Aren't I nice!?) during the holidays by following the humidity and temperature of their plant. A sensor node will cost about $43 (ATmega48 $2.50, HopeRF $35, PCB $2, Temperature Bead $0.50, Misc Parts $3). Each node would be able to monitor multiple sensors (8 ADC channels). If a student were to monitor humidity and temperature, then 4 students could share a node.

$43 may sound like a lot, but I talked to my science teacher, and our school spent a good few $1000 on their data logger. It is single channel only. My system has the benefit of 8 analogue channels per node, and (in theory) and infinite number of nodes. I say in theory, as wireless means I can have as many nodes as I want. I think I would have a problem with 'collisions'. More than one node talking at a time. There could easily be a work around... Disable the wireless unit of the nodes when there is data being received.



More posts to come.