db_and_interfacia.pde (9448Bytes)
bt_test2.bas (2627Bytes)
bt_test2_18x_module.bas (1513Bytes)
My something else.
Logging of data from a bluetooth connected device to a database. The idea of this device is to allow the user to record up to X (currently 4)channels of data to internal/external memory or stream the data to a computer connected to this device. When using the internal/external memory, you can start, stop, dump and clear the stored data. The other option is to stream the data at intervals ranging from 1 second to 65 seconds(currently).
One of the constraints on this device was to make it as small as possible with the current tech that I can work with which are of the pdip level. If I get into smt level, this can be made even smaller. The container that I decided to use as it was easy to get was a mint container that had a width, height and length that should work. One of the concerns of this setup currently is the battery lifetime for the streaming mode and connection availability of the bt device in the storage mode.
A couple of ideas is as follows:
- Streaming mode is active during the day with night time intervals being set to one update an hour.
- Using a solar panel to keep the battery usage to a minimum during the day. This works for sunny days, but winter would require a larger battery that would most likely need to be able to run for many days on end. This would change the size of the overal dimensions of the device.
- In data storage mode the BT device is kept off and is only turned on at a certain time of day for a window of 15 minutes. This could be done by using a rtc addition to keep that window accurate.
- Use something other than BT or use an extremely low power BT device.
- Allow a limited set of times for streaming like 15,30, 45, and 60 minutes.
Frontend functionality
Allow the user to control the local memory storage and configure streaming mode. Connect and disconnect from both BT device and the DB.
Current funcitonality
- Start - Start local logging of data onto memory chip(s)
- Stop - Stop logging od local or streaming data.
- Clear mem - Clear all data on local memory chip(s)
- Dump Mem - Dump memory from all memory chip(s) to DB
- Continuous mode - Stream data to db at set intervals.
Functionality I'd like to add.
- A config for the db so that the user can add a db, port, user name and pw.
- A config for multiple BT devices.
- Alerts for the memory storage on the device.
- Real time graphing of streaming data.
- graphing of datasets per day, hour, month
- Data stats for the above as well.
The libraries in processing that I'm using are:
- BluetoothDesktop - bluetooth lib for connecting to other devices.
- SQLibrary - sql library to connect to mysql
- Interfascia - buttons and such
Original image
Next steps
- Working on implementing inserts into the db.--COMPLETED
- Start and stop request of data to the bt connected device. --COMPLETED
- Logging of streaming data. --COMPLETED
- Logging of data from memory. --In Progress
Enable features on 18x.
- Start --In Progress
- Stop --COMPLETED (cont mode only)
- Clear mem --In Progress
- Dump mem --In Progress
- Continuous mode --COMPLETED
Further steps.
Use the knowledge gained in bt com to implement a control and logging app for a mobile phone(android)
Update 2/1/10
Added and tested ability to insert data. Works perfectly, now need to write a test app on the uproc to send some adc data
Created simple db table for recording multiple data channels.
Need to test sending and validating data send to pc.
The current parts that I'm looking to use. The eclipse tin will hold the components.
The battery is one concern as it's a bit too big to fit, but I'm looking at using a 100-200mah lipo.
Edit 2/08/10
figured out most of the pin assignment for the 18x and 08m. worked on the command codes to start, stop, run in continuious mode and possibly a sleep mode.
Flowchart for the 08m was created. Need to go over it again to make sure it makes sense, but overall it looks good. 2 considerations I've been making, first is setting it up so that I can control the bt power via the 18x/transistor as a on/off switch...but not sure that'll make sense(should that go on the 08m?)...and the second is I need to consider if I want to control the power through a transistor for the 08m in case I need to do a restart of that micro. Overall I've made good progress in this project. I'll add the contents of my whiteboard later and eventually the board layout. so far I have not added the i2c memory chip and am working on just using the 256 bytes of space that the 18x can use. If I need more, I'll consider the mem chip.
currently I'll be tracking current temp, adc of an ldr and adc voltage for a solar panel. This is just a small test setup so nothing too special.
Edit 2/09/10
Finally completed my SF order and decided to grab a 3.7v 100mah and 800mah lipo cell as well as charger and jst connectors for this project....should have those parts by this weekend and should have it all breadboarded by then as well. next is to make sure it all works well. hmmm....also need to remmeber to disable the bod on the picaxes...
Edit 2/13/10
Got the parts and putting things together today. Fiinally updated the interface image with what I'm currently working with.
currently the top three buttons have functions, the other 4 are not connected at the moment but do activate the function call with test text.
Edit 2/15/10
Added 2 new buttons, Clear memory and dump mem.
clear_mem function will clear all allocated memory blocks that are currently being used.
dump_mem function will transimit all memory currently held in the allocated memory blocks then clear them.
Worked on Continuous mode code for both 18x and app
Removed debug statements and test code that were slowing things down
Resolved an issue with the 18x not getting data time interval data and cleaned up code.
Reworked logic in the computer app that deals with the data being sent though I can see that there could be issues with it.
Started sending data to DB for a test. will add pic of current breadboarded circuit later.
Edit 2/16/10
This is the current test rig. No, it's not pretty, yes it works. currently I'm tracking light level with an ldr and the current temp with a DS18B20 sensor. will hook up the solar panel sometime this week.
Ran into some issues last night with the bt connection. I may have to figure out how to reconnect on a connection failure, not sure how that will work. Second issue is if the data gets out of sync though I think I can correct that.
Been testing this rig this morning, about 6ish set it to run when it was still pretty dark and cool. Almost 2 hous later, data coming in looks good(graph time!). I need to add a date/time column though as I have no ref time. I should also add a data key to track which set of data I'm looking at. I'm considering using a seperate adc chip to collect the data and save the other inputs on the 18x for other data though I've read that you can reconfig(peek/poke mem on) the 18x to use the output pins to inputs. I'll have to research this as this would be great for this project and save board space(no seperate adc channel).
- Cleaned up this page a bit to make the project a bit more understandable.