Portable temperature, humidity and light ambient datalogger

Portable temperature, humidity and light ambient datalogger

UPDATE: Here’ the BOM file, I forget upload it: BOM_PIC_DATALOG_V1.0_WEB

UPDATE: Also in Adafruit’s blog. Thanks!

Hi all! I’m continuing here with the last board I design and now I’m continuing testing. It’s a battery-powered small datalogger based on a PIC18F2620 microcontroller. The idea comes a few months ago, talking with a friend. He needs something to  monitoring temperature and humidity inside a sea container, for a three weeks travel from Spain to China. Low consumption is important, in order to have maximum autonomy with a small battery. I use a HDC1050 temperature and humidity sensor, and a TEMT6000X01 ambient light sensor. The collected data is stored on a micro SD card. Also the board has a RTC for timestamp, a Li-Ion battery charger, user pushbuttons and leds, and a MCP2221 USB bridge to communicate with the board and configure some parameters through software. Let’s see the board in detail!

  • HARDWARE

First of all, here’s a view of the board with the main components. After I’ll talk about the case 😉

Portable temperature, humidity and light ambient dataloggerThe schematic of the board is available here: EEL_PIC_DATALOG_V1.0. It’s  divided in the following parts:

  1. Main diagram: Includes the mini-B USB connector, TVS diode for protecting the USB line and the rest of the connections.
  2. Power supply stage: The board can be powered using a 3.7V Li-Ion battery or through USB port. I use a 3.7V/1100mAh battery for this first prototype (LP603450). USB port is also used to charge the battery. I use the MCP73832-2ACI/OT regulator from Microchip with a Rset of 4K7 (not 10K as appear in the schematic). This allows a current charge of around 220mA/h. D4 (red) and D5 (green) leds indicate the status of the charge. Also, D1 (green) lights when USB power is present:Portable temperature, humidity and light ambient dataloggerPortable temperature, humidity and light ambient datalogger

    The hot point is the battery manager, when charging the battery. Although is a high temperature, is not critic and with this setup, the battery is fully charged in around 5 hours.

    System voltage is 3.0V, so I use a TPS76930DBVR LDO regulator. with a maximum output current of 100mA and a typical dropout voltage of 115mV at 100mA output. Also, there’s another LDO regulator, U10. This one is used to power the USB – serial converter. The input of this regulator comes from the USB port, so when there’s no connection with the USB, the regulator and also the USB converter are not powered, increasing the battery life.

    Battery voltage is measured with the RA3 analog input of the microcontroller. I just set a voltage divider to adjust the maximum battery value (4.2V at the end of the charge) to the 3.0V maximum voltage on the PIC pins.

    At this time, duration of the battery is around 10 days. With the actual software, there isn’t any low power implemented yet. The consumption is around 5-6 mA, including the DS18B20 sensor that I don’t use. I think that unassembly this sensor and forces SW to low power consumption, the goal of three weeks of autonomy is easy to reach.

  3. PIC18F2620 microcontroller: The brain of the board!. 64KB Flash, 3968 RAM bytes, 1KB EEPROM, 25I/O, I2C, UART,…all condensed on a 28-pin soic package. Enough for this project! Of course, the board has the ICSP connector and also J4 and J5 connectors with accesible VCC, GND and three not used pins. I also let in the board the footprint for a DS18B20 temperature sensor. Originally, it’s on the board because I’m not sure if I’ll be able to solder the HDC1050 sensor, so if I can’t, at least I can obtain the temperature from this sensor.
  4. I2C bus: On the 3.0V I2C bus are the HDC1050 temperature and humidity sensor and also the M41T00SM6 RTC. The RTC has a CR1220 battery for backup date and time. Also there’s a connector available with these signals for future uses. The I2C bus is implemented by software, because the I2C lines are shared with the SPI port, and I need it for the micro-SD card.
  5. Micro-SD Socket: I use this one from Molex because is easy to solder by hand. Not much to say here, just and SD card connected to the SPI port. You can check here the SD card specs.
  6.  User interface: Two pushbuttons (active low) and two led’s (D2 Green / D3 Red) for what user wants!.
  7. LDR: A TEMT6000X01 ambient light sensor. It reads with the analog RA0 input. Because the internal ADC of the PIC has 10-bit resolution, maximum value will be 1023 that corresponds with maximum level of illumination.
  8. USB-Serial bridge: Based on the MCP2221 chip that I use before.

I design the board with components only on top layer, it’s easy to assemble. I use the DP5050 sick of beige PCB format from DangerousPrototypes. The gerber files of the board can downloaded here: GBR_PIC_DATALOG_V1.0. And here’re a couple of 3D-previews images from Altium:

Portable temperature, humidity and light ambient datalogger Portable temperature, humidity and light ambient datalogger

I order the boards to DirtyPCB company, and like always, the quality is excelent for the price. The one con I notice this time is that yellow board with white silkscreen is not easy to read, but I never make a yellow board ;-):

  • CASE

For first time, I make a 3D case for the board. To make this job, one of my best friend helps me in this design. He has his own company and has a lot of experience designing cases for electronic equipments. I send him the step model of the board and he designs the case, to fit the board and also the battery. This was the first attemp:

Portable temperature, humidity and light ambient dataloggerPortable temperature, humidity and light ambient datalogger

The board fits perfect, but you can show the battery. Also, I need a small space to take out the wires from battery, and also add a method to fix the datalogger. We implement all this changes on the second version:

Portable temperature, humidity and light ambient datalogger

Yes! I use two Neodymium Magnets to fix the board to any metallic surface. It’s a transparent method of fixing and the final result looks great. Now I can put it in my fridge door:

Portable temperature, humidity and light ambient datalogger

Now the electronics fits better and you can’t show the battery, so the datalogger seems a bit more professional:

Portable temperature, humidity and light ambient datalogger

Portable temperature, humidity and light ambient datalogger

The .stl file of this last case is available here: BOX_DATALOGGER_V02

  • SOFTWARE

The software (*) for the datalogger is here: PIC_DATALOG_V00d. I use Mikroc Pro PIC compiler, the libraries of this compiler are great! Especially the FAT32 library, it allows to manage the micro SD card on a very easy way. Current version is 00D, and I’m still working on it. I know there’re many things that I can optimize, process that could be simpler…..but the board is still on debug!

There’re many considerations on this SW, I’ll try to explain some important points, but if you have any doubt with something, please comment it and I’ll try to answer!

  • At power-up, system configures and check all the peripherals: configure GPIO’s, UART, I2C, SPI, RTC status and set the time for the files on the SD card. Also reads the device ID, a parameter that identifies the datalogger (value stored in microcontroller EEPROM).

Portable temperature, humidity and light ambient datalogger

  • Files on the SD has the following name format: yyyymmdd.ext . That is, year, month and day. The extension file is initially ‘000’. Every new day, system creates a new file with the same format, so every 24 hours, you’ll have a new file.
  • System has defined a time to update all the parameters and store it on the SD. This time is configurable by user, and can go between 1s and 999s. When a update event occurs, the system reads all the sensors and parameters and store data on the SD.
  • With the P1 pushbutton, you can put a mark on the file. That means that in this moment, you force a update event, so sensors are read and store on the SD card. With the P2 pushbutton, you can make a new file. Filename will be the same but extension changes to 001, 002….and so on. Every push on P2 makes a new file.

Portable temperature, humidity and light ambient datalogger Portable temperature, humidity and light ambient datalogger

  • Data fomat: on the SD card files. you’ll find a new file for every day. This files has plain-text format and separated by ‘;’, for an easy import with excel or similar software:

Portable temperature, humidity and light ambient dataloggerFile has the following fields:

.Software name and version

.Device ID

.Time (s) when system updated the data and store it

.Date

.Time

.Event (Power Up, Mark, Update)

.Battery voltage

.LDR value

.DS18B20 temperature (now it’s fixed because I don’t read it)

.HDC1050 temperature (in ºC)

.HDC1050 humidity (%)

.Rest of bytes are reserved for future uses.

Portable temperature, humidity and light ambient dataloggerJust a fast graphic of the battery level across 4 days.

  • Every days a new file is created. To merge all the files in only one to easy import into excel and make graphics, you can use the following command:

type *.* >> out_file.txt

  • As you can see, I implement a command-line commands to have info or set parameters of the datalogger. To connect with the board, just plug the USB cable and install the virtual COM port driver of the MCP2221. I use Tera term software for this. Baud rate is 9600 bps, 8, N,1. Important! Set ‘Local Echo’ to see the commands you send to the board. The command list I implement on the board is the following one:

– reset -> Perform a software reset of the datalogger

– set time -> Update time of the board (hour and minutes, seconds set to 0).

– set date -> Update date of the board (year, month, day and day of week).

– set update -> Set the time to update the system (from 1s to 999s)

– set id-> Set the datalogger ID (from 000 to 999)

– temp-> Perform a HDC1050 temperature measure

– hr-> Perform a HDC1050 humidity measure

– ldr-> Perform a LDR measure (mean of 10 samples)

– batt-> Perform a battery voltage measure (mean of 10 samples)

– date-> Shows the datalogger date

– time-> Shows the datalogger time

– id-> Shows the datalogger identification

– upd-> Shows the datalogger update time (in s)

(*) THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

  • Twitter
  • del.icio.us
  • Digg
  • Facebook
  • Technorati
  • Reddit
  • Yahoo Buzz
  • StumbleUpon

This post is also available in: Spanish

13 thoughts on “Portable temperature, humidity and light ambient datalogger

  1. Pingback: Portable temperature, humidity and ambient light datalogger - Electronics-Lab

  2. ich

    Very cool Project. But were are the BOM? Can you generate a BOM-File with the size of the uses parts?

    Reply
    1. jechavarria Post author

      Hi ich! I forget upload it, you can find it on the post, at the top. I hope it serves you and if you have any other question, please tell me!
      Best regards, Jesus

      Reply
    1. jechavarria Post author

      Thanks for your comment, Vasile! I’m happy yo like it

      Best regards, Jesus

      Reply
  3. Pingback: A full-featured, portable weather data recorder - Electronics-Lab

  4. Bob Kondner

    Hi,
    Wonderful job. Very professional.

    The standby current seems kind of high. I use a PIC18F26K20 in a product where I have battery control in low level assembly with a C App running in foreground. With a short C app waking from sleep at 8Hz the entire process consumes about 100ua. A 2000mahr AA cell based battery (3 in series) would give you 2 years of operation.

    I put my RTC in code using the 32Khz low power oscillator and I use that to bring my processors out of sleep every 125ms. There are details on my site.

    Again I think you have one of the better projects on this forum.

    Bob K

    Reply
  5. Pingback: Portable Datalogger for Temperature, Humidity & Ambient Light | Electronics Infoline

  6. Lenouvel Jean-Luc

    Hello,

    t’s a very cool solution. but how much it costs ?

    Best regards

    Jean-Luc Lenouvel

    Reply
    1. jechavarria Post author

      Hi Jean-Luc:
      Actually, I can give you the unitary cost for the two prototypes I assemble by hand:
      – Components: 45eur (Mouser)
      – PCB: 3eur (DirtyPCB)
      – Li-Ion Battery: 5eur (Spanish distributor)
      It’s around 55 eur, the cost of the case is not included and also the assemby cost (I do it by hand)
      I know is a high price but this always happens with prototypes.
      If you want more info or have more questions, just tell me!

      Best regards, Jesus

      Reply
  7. Pingback: Registrador de temperatura ambiente com SD card - FritzenLab

Leave a Reply

Your email address will not be published. Required fields are marked *