Simple and Cheap Temperature Logger v2.1: Source Code

Hello everyone. I know this blog has been dormant for “some” time. I should post some new projects soon. In the meantime, I uploaded the source code for the USB logger to my Github repository and changed the licence to GPL v3. Like always, it is provided “as is”. Actually, you should read the articles and write your own source code, it will be faster than trying to make work the code I wrote.

I can’t provide any help – this is not a project for beginners – especially if you try to make a commercial project with it.

 

Advertisements

Simple and cheap temperature logger: v2.1 [UPDATE: EEPROM in BOM corrected (SST25WF080) ] [UPDATE2: Link for the Github with source code]

Hi everyone!

It’s been too long since the last update. But it’s there! The last version of the temperature logger, the hardware and the source code.

USB-Temperature-Logger---Component-side

USB-Temperature-Logger---Battery-side

The changes since the last version:

Hardware

  • New footprint for the PIC18F26J50, easier to solder.
  • Only 0603 or bigger resistors/capacitors.
  • The serial EEPROM is now a SST25WF080, still 8Mb, but easier to source.
  • Some components price-optimized (USB connector, switch, 3.3V reg).

Software

  • Each logger can get a number, shown in the mass storage device drive name: simply add an asterisk (*) followed by the number you want to assign to the logger (between 0 and 65535) in the config.txt file (after the logging period), save the file and format the logger.
  • Bug fixes in the FAT12 functions, but the logging space is still limited to the half of the EEPROM.
  • Other bug fixes (month and year change, added robustness). The memory and the EEPROM are now scanned when you plug the logger back, to get the last data and reconstruct the filesystem in the case of a battery failure.

Temperature Logger 2.1: Schematics and basic BOM

The Altium files

The source code (based on Microchip Applications libraries -Device – Mass Storage – SD Card data logger- MPLABX)

The source code is now available from my GitHub: Temperature Logger v2.1 – Github

I also made a program/debug adapter (especially useful for debugging):

USB-Temperature-Logger-Programming-tool

USB-Temperature-Logger-Programming-tool1This is the “office” version of my previous peg-adapter 😉

A lot of people were asking me if I was selling these loggers. Unfortunately, no. The design and functionalities are sexy, but I don’t have the capacity to launch a production on my own. And if I had do make only a small batch, the price would be totally uncompetitive.

A big thanks for all the people who donated a little something to motivate me!! (or to help me be more ashamed of the lack of updates)

All the contents (except the parts of Microchip’s code in the source) are under the Creative commons license, Attribution – Share Alike – Non Commercial.

Creative Commons License
Simple temperature logger: v2.1 by Jean Wlodarski is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Simple and cheap temperature logger: New update coming

I’m working on a new revision of the temperature logger: new PCB and new firmware. It’s easier to solder, as the resistors/caps are now 0603 instead of 0402 and the PIC package is now a SSOP28 (instead of QFN).
The sleep current is smaller than 10uA and below 1mA when measuring the temperature (plus a few mA every 20-or-so logs, when writing to EEPROM).

The EEPROM is a SST25WF080 (still 1,8V 8Mb), as the previous Atmel memory is not available any more.

Some 3D renderings of the PCB:

Simple and cheap temperature logger 2.1

The USB connector is a Multicomp MC32604, cheaper than the previous MCKUSBX-SMT2AP1S-W30. (I couldn’t find a suitable 3D model for the PCB rendering)

The ISCP connector for programming the firmware  is SMT but fits the Microchip’s ICD header:

The new firmware has functions for the new EEPROM, a low battery indication, more robust logging and USB update capabilities. Plus a lot of bugfixes and optimizations.

Now, to complete the firmware, I have to build at least one logger, which means ordering the PCB and the components. That’s why I added a “donate” button to this blog (on the top right side of the page, just under the title), especially I don’t earn any money with this blog and content is free (and will stay free, of course).

If my work helped you, if you find it interesting, if you want more articles and more projects, dropping a few coins will motivate me and help me to materialize all the projects waiting in my head. 🙂

Stay tuned for more!

Jean.

Designing a simple and cheap temperature logger. Part 7: Schematics, PCB and source code.

I decided to publish all this project under Creative Commons license (Attribution, Derivatives, Non commercial, ShareAlike). The source code contains a FAT12 filesystem that can be reused to make custom flash drives for other projects.

USB Temperature Logger

(PCB version 1.2, hence the misaligned 3.3V regulator to include a diode. Corrected in the V2.0)

USB Temperature Logger 2

USB Temp Logger Schematics

You’ll find the schematics here: Simple USB temperature logger schematics

The Altium files (including a routed PCB) there: Simple USB temperature logger Altium files

The source code (based on Microchip Applications libraries -Device – Mass Storage – SD Card data logger- MPLABX): Simple USB temperature logger source code

The source code could be improved to increase the robustness of the logger (especially in the case of battery power failure while on logging mode). The PCB allows the monitoring of the battery voltage, it just needs to be implemented in the firmware.

I hope my work will be useful to someone!

Don’t hesitate to contact me (mail in the About section) for questions or comments!

Designing a simple and cheap temperature logger. Part 6: Video!!

I just finished developing my USB temperature logger and shot a video showing how it works. Here are the key figures:

  • Up to two months of logging with a single coin cell battery.
  • 30 000 timestamped temperature measurements.
  • Logging period from every 5 seconds to every 24 hours.
  • 0.5°C accuracy, 0.06°C resolution.
  • No driver, no software and no admin rights needed!
  • Compatible with any computer with USB port.
  • Automatic time synchronization with the computer.
  • Low cost design.

When plugged to a computer’s USB port, the logger appears as a normal USB drive. The temperature logging period is changed by editing a config.txt file. When this file is saved, the logger reads the periodicity (in seconds), synchronizes its clock to the computer’s date and time and starts to flash the LED to indicate it’s ready to log. Once removed from USB, the logging is started by pushing the button (the LED blinks three times). For every temperature measurement, the LED flashes.

Once plugged back to USB, the file DATA.CSV will contain all the temperature measurements and the corresponding date and time, TAB separated.

A future development could include a Li-Ion USB rechargeable battery, battery life monitoring, low power – long period logging mode.

If you’re interested by this project, don’t hesitate to contact me. Share if you like it!

Measuring small currents in battery-powered systems

This is a simple method for measuring small currents (μA/nA).

I wanted to see how much current my temperature logger is consuming while in various sleep modes for the various components on the board. I have a good multimeter but unfortunately, its smallest DC current range is 400mA. Even if the burden voltage isn’t that big, it’s impossible to measure anything below 10μA.

As I’m not lucky enough to own one of Dave Jones’ μCurrent I tried to find an other method. I inspired myself of a Microchip App note (AN1416).

The idea is to power a circuit with a charged capacitor and measure the discharge time, thus the current:

I = C*(Vd/t)

Where I is the current(A), C the capacity(F), Vd the voltage drop(V) and t, the time (s).

The method can be easily set up on a breadboard and it’s ideal for measuring small currents that don’t change over time (typically, microcontroller’s sleep modes):

 

Measuring small currentsIt’s better to use a nomally-opened switch, so a push on it will disconnect the power supply and allow the capacitor to discharge.

 

Measuring small currents breadboardIn my setup, I’m using a LM317 voltage regulator to have 3,00V (coin cell battery voltage) at the Vd point when my microcontroller is connected and the switch closed.

At the same time I open the circuit with the switch, I start a timer and usually stop it when the capacitor voltage dropped 0,2V  (2,8V at the capacitor)

For example, with a capacitor of 6600uF (measured), a Vd of 0,2 Volts and 50 seconds to reach it:

I=6600*(0,2/50) = 26,4μA

The value of the capacitor can be adjusted, so you don’t need to wait too long when dealing with nA currents. ex:

Vd=0,1V ; C=10uF ; t=30s : I=33nA

And so on..

To make sure the capacitor internal leakage is not affecting the measure too much, repeat it with no load connected to see how fast the current is dropping. It also allows you the see if the voltmeter impedance isn’t too high.

As soon as I get my temperature logger new PCB, I’ll measure the current in sleep / deep sleep mode for the PIC18F26J50, the EEPROM, the temperature sensor and I’ll post them here.

Designing a simple and cheap temperature logger. Part 5: New prototype PCB.

It has options to be powered by a Li-Ion battery (rechargeable via the USB port, with a MCP73831), as well as by a CR2032 coin cell. There’s an other option for the 1,8V EEPROM SDO line pull-up voltage adaptation.

All the options are selectable by fitting or not 0 Ohm resistors and adding the dedicated components.

In the Li-Ion version, it’s supposed to fit into a case like that (but with a hole for a button and a LED). It’s 19mm x 40mm.

The blue connector is the ICSP program port. I designed it to be “off-snappable”, as it’s connected only by three bits of PCB, where the signals pass.

USB Temperature Logger - Prototype 2 - Face

 

USB Temperature Logger - Prototype 2 - Back

NB: Some of my 3D models aren’t exact (like the battery socket, the 3D model is SMT instead of the through hole I have)

 

Here, an other PCB, Li-Ion only. Just for fun, I wanted to see how small the PCB (19mm x 38mm) can be routed with the components on the same face. On the bottom, there’s only a contact-style connector for ICSP:

Mini USB Temperature Logger - Prototype 3 - Face

 

Mini USB Temperature Logger - Prototype 3 - Back

The components names couldn’t fit on the top side, so I put them on the bottom.

The PCB could maybe get even smaller with a smaller 3,3V regulator, in a SOT23 package instead of the SOT223. The 32,768KHz crystal could also use a smaller package. But here, I hit the limits of the 2 layers, 6mil/6mil routing and I’m not sure some tracks won’t interfere each other.

The prototype on the first two images is the one I’ll be using to continue the software development.