So I came into the office at the weekend to do some tidying up before going away to Wales for my wife's birthday surprise. I didn't expect it to snow, and where we're going to stay is in a red Snow Warning area. Great!
I took the opportunity to start sorting out the multitude of sensors I've been ferrying back and forth between the office and the Curtis family home each day. My rucksack is usually stuffed with bits and pieces that I convince myself I might need at home for the night's coding, but in reality I only ever break out a couple of items and concentrate on them.
So today I mounted a SparkFun BMA180 breakout on a SExI prototyping board, wire-wrapped the connections, and tested that I could address the accelerometer. Sure, yes, that worked, so I'll write a driver for it one evening as all the Bosch Sensortec acceleration sensors have the same type of memory map and set of capabilities.
But I also constructed a shield to take the DIL modules that ST provide for evaluation of their sensors. I happen to have an LPS331AP DIL module, so I plugged it in and labeled the shield so I know what it's for.
The easiest way to test the sensor out is a few lines of CoreBASIC. Telnet into the interpreter and type away! I know my device has address 0xBA and the LPS331AP has a "Who Am I" register at address 0x0F that should read back 0xBB. Will it?
>i2c 0xba write 0x0f read 1 to x
>print hex expand x
["BB"]
>
Excellent! It does! I can address the sensor and away we go! After a bit of reading and coding, I constructed the C and CoreBASIC drivers for it:
>install "lps331ap" as lps331
>print lps331.temp
26.3229
>print lps331.pressure
99078.1
>
OK. Brilliant. That driver will make the next release of CoreBASIC!
Just time to finish up, tidy up, wrap up, and go home.
No comments:
Post a Comment