2012
07.31

I purchased a Schwinn Centennial bicycle from a professional picker one weekend for $25.  Its a late 70′s T-E-N speed… none of those extra gears, just ten speeds, 2 gears in front, 5 in back.  It has the classic swept under handlebars of the era, the painful seat, but it’s built to last because of Schwinn’s signature welds.  It only took a few sprays of chain lube, WD-40 on the cables and some dérailleur adjustment to get everything working again and it had it’s inaugural ride.  Now to build a bike computer for it, building upon some of the work already done by others.

A bike computer is an evolution, not an all or nothing project.  The beauty of microcontrollers is they can be added to, revised, features deleted, and can grow with the project as features are added.  I have a million ideas from trip computation, GPS tracking, workout logging, speed and odometer, heck I even thought of implementing a subset of OBD-II! But for now, we will suffice to do only a few things, speed, distance, lap and display the results in realtime, essentially a homebrew speedometer available at any bike shop for about $15.  But with the microcontroller architecture, feature addition will be easy.

So with that in mind, first we will need a display…. I am unsure which one exactly yet, but it must be graphical and LCD.  This line from Adafruit looks nice.  Also this old Nokia monochrome display looks nice, we don’t need color for this application.

Next we will need some sort of rotational sensor for the wheel, I have seen simple alarm contacts used, but I think I’ll go more elegant with a hall effect sensor and a magnet.

Next we need a platform, I am a fan and most familiar with the Arduino line, so we will use a classic Arduino (pro version 3.3V, no bells and whistles)  and build around that.  If we need more memory or power, we can always upgrade to the Arduino Mega.

And finally, for safety’s sake, we should add a flashy light on the back of the bike.  I had long wanted to do a Morse Code message in the flashing, to amuse those that can read it, and to provide an erratic flash to make it more attention grabbing.  So a few bright LEDs mounted under the seat will do the trick.

Oh, and we’ll need some form of rechargeable battery, Probably LiPo a charger and a battery gauge.

And there you have it, the initial design specifications for a bike computer.  Now its off to gather parts.

 

Share
2012
07.11

I had put the Arduino stuff on the back burner for awhile, concentrating on some web development work but I needed to track temperature at work and attempt to catch the air conditioning in the act of malfunctioning.  I decided to finish my porting the temperature controller I made in 2010 with the Arduino / Ethernet shield to the London HackspaceNanode-5, all with pretty good results.

Nanode Board Image

If you look closely you will see a TMP-421 temperature sensor board installed on the analog header, as outlined by Liquidware and ModernDevice, the vendor of this little breakout board.  It utilizes the I2C port which occupies two of the analog I/O and the other two are used as power and ground.  In this configuration it is possible to power down the chip for purposes of a reset or something, but this functionality is not used here.

The accompanying sketch and php scripts on github basically do the following.

  • Initialize the ethernet chip
  • Initialize the I2C bus and the TMP-421 chip
  • Read the temperature every 5 seconds
  • Push the temperature to a waiting mySQL database every 60 seconds
  • ???
  • PROFIT!

I want to add a rudimentary thermostat and relay driver, and a simple webpage to read the temperature on demand and set the thermostat setpoint.  So keep an eye on this blog and github for updates to the code.  The final feature list will be…

  • Temperature reporting and databasing (DONE)
  • Temperature graphing (DONE)
  • Simple hysteresis thermostat (IN PROGRESS)
  • Webserver to display current temp.
  • Webserver sets setpoint, persistantly through PROGMEM

Oh, I mentioned graphing….  as always click to display the latest graph…

Nanode Temperature Graph

I will release the graphing code later when I have added some functionality and cleaned it up a bit.  But if you want to play with graphing in your own, this is based on the Flot package.  It’s a little old now, but I am hesitant to change, it works!  But there is better out there and I’ll eventually get around to evaluating them.

And finally, to get this working on your server, first you will need a webhost with PHP and mySQL.  There are many packages out there, look around.  Then you will have to change the following lines of code,

In nanode_temperature.pde, between lines 45 to 60 change these parameters to match your setup

//**************************************
//**** BEGIN USER DEFINED VARIABLES ****
//**************************************
#define POST_RATE 60000 // rate to post to the db milliseconds (60 seconds)
#define UPDATE_RATE 5000 // rate to read the RSSI milliseconds (5 seconds)
#define TIME_OUT 30000 // time to wait for a response from internet (30 seconds)
float setpoint = 70.00; // default setpoint upon first use
float differential = 2.50; // differential
char HOSTNAME[] PROGMEM = “hostname.com”; // hostname of a shared hosting server here
static byte hisip[] = {***,***,***,***}; // ipaddress of the server here
#define HTTPPATH “/somewhere/nanode_temperature.php” // path to the PHP script
#define DATABASE “nanode_temperature” // database name
#define TABLE “node1″ // table name
//**********************************
//*** END USER DEFINED VARIABLES ***
//**********************************
Also between lines 77 to 80, change this to your network scheme…
#else
  static byte myip[] = {192,168,2,202}; // modify these addresses to match
  static byte gwip[] = {192,168,2,1}; // your local network scheme.
#endif
And finally in line 260, change the following line to reflect the path to your php script,
ether.browseUrl(PSTR("/path/nanode_temperature.php"), paramString, HOSTNAME, my_result_cb);

In php.db, you must put your database credentials in there, and the database name you chose above,

$host = localhost;
$user = username;
$password = password;
$database = databasename;
Thats it!  That should get you going with the functionality provided.  I’ll probably be adding more fields to the table, with on/off times, setpoints and the like, but I will write the php script such that it automatically adds them to your existing database, to make things simple.
Just to reiterate, the code can be found here.
Share