Simplest Datalogger

chipwich

Member
As is typical for me, I've taken a project which could be created by any of the regulars here in less than 20 minutes, and turned it in to a week's worth of effort in a demonstration that anything (especially software) can be over-engineered... But I do hope the result is worthwhile and useful.

This is a really simple but very flexible way to log data using a PICAXE microcontroller. Minimal parts, flexible data samplng, great battery life, and simplicity of data export to a PC were the important design considerations. I initially hacked this together quickly to monitor the charge state of a battery hooked up to a solar panel. Then I used it to monitor the temperature change in a room from the furnace, and then looked at changes in ambient light levels due room lights and daily sunlight. I kept adding features to this project (hence the week of effort) to make it completely standalone and configurable over the serial line. It now includes battery level indication, extremely efficient power use including a low power mode, and a range of input configurations.

This logger can read a voltage, a resistance, the internal temperature sensor, an external DS18B20 temperature sensor, or even monitor its own power supply. It is entirely controlled via the same serial cable that is used to program the PICAXE. The only parts are the PICAXE circuit, an LED to indicate that the logger is functioning, and a connection to the device being monitored (unless you use the internal temp sensor).

picaxe_datalogger_1_800.jpgdatalog_heatervent_1.png

Full project details available at http://www.corticalcafe.com/picaxe_simplest_datalogger.html
 
Last edited:

westaust55

Moderator
Well done Chipwich.

The code is well documented and well formatted for ease of anyone reading and looking at the program flow at a later date.

For those you may not always have access to all websites at school or work I have attached a PICAXE program code here.
I would still recommend that you visit Chipwich's website (given the opportunity) to see additional informaiton and images.
 

Attachments

techElder

Well-known member
Chipwich, I didn't immediately see how you standardized or calibrated to your range of sensors. Pardon me if that is built into your code, since I haven't had the chance to go through that yet.
 

chipwich

Member
Chipwich, I didn't immediately see how you standardized or calibrated to your range of sensors.
An excellent question. I suppose not everyone wants their data calibrated in arbitrary units! To address your question, I added a "calib" reading to the data [D]ump routine (latest code on the project page) and also an explanation of how calibration works. Here's a summary:


Temperature:
The internal temperature measurement is highly dependant on the power supply (Vcc), and probably not worth too spending too much time on, since you can use a DS18B20 for accurate temperature measurements. This sensor automatically reads in degrees Celsius.


Voltage:
ADC readings are dependant on knowing the supply voltage, Vcc. The "calib" command allows you to calculate Vcc: VccCalc = 261/calib.

Once you know Vcc, it's easy to convert ADC readings into voltage, Vin, since a full scale ADC reading of 255 equates to Vcc: VinCalc=readADC*VccCalc/255

For example, my VMM says I am using a 3.88v supply for Vcc. The calib=66. This means VccCalc=261/66=3.96v. VccCalc is pretty close to VccMeasured.

So applying a 2.41v reference as Vin, the readADC=158. This means VinCalc=158*3.96/255=2.45v. Again, VinCalc is reasonably close to VinMeasured, at least within the accuracy of my $5 VMM.


Resistance:
The ADC measurement reflects the voltage across an unknown resistor, Rin, which is the lower half of a voltage divider circuit. The upper resistor is the internal pullup resistor in the PICAXE, as enabled via a "pullup" command. I'll have to read up on the values/tolerances, and work through the math to explain how to calibrate resistance.

But perhaps someone has anyone has already worked through this. Can anyone recall a similar resistance calibration issue? Thanks in advance...
 
Last edited:
Top