raphnet.net banner
Cette page est aussi disponible en français
USBTenki: USB Temperature sensors and more
Content: Project Overview | Pictures | Schematics | Supported sensors, wiring and firmwares | Host software | Virtual channels | Printed Circuit Board | References | Disclaimer
Project overview [hide]
What is it?
USBTenki is an electronic project to interface sensors to an USB port for collecting weather related data such as temperature. The firmware supports many different sensors and interfaces. It is up to you to decide what your USBTenki will support.

Hourly graphics generated from data collected using this project are available at http://meteo.raphnet.net

Project history and motivation:
This project - named USBTenki, from the japanese word 'tenki' 天気, which is pronounced ten-kee and means weather - was created because a friend needed an USB temperature sensor. A short time later, I got a requset for a temperature + humidity sensor, so I added support for such a sensor. Then, just for fun, I added an absolute pressure sensor which is able to report the atmospheric pressure. I plan to add support for more types of sensors, such light, lightning detection, wind speed and wind direction.

You can consult the list of supported sensors in the 'Supported sensors, wiring and firmwares' section below.

goto top Up


Pictures [hide]
Temperature + Relative humidity sensor using a Sensirion SHT75 sensor:


Temperature sensor using an MCP9803:


The prototype using an MCP9803 sensor:

Temperature sensor (prototype) based on the MCP9803 installed in the servers room's air conditionner:


Here are good examples of how to install a bypass capacitor near a sensor and protect the sensor using heat-shrink tubing:

Examples graphs (generated with munin plugin)
1: 2: 3: 4: 5: 6:
#ValuesSensor(s)PeriodIndoor/OutdoorLocation
1Temperature, Relative Humidity and Virtual channels. Sensirion SHT75 DayIndoor Saint-basile-le-grand, Qc, Canada
2Temperature, Relative Humidity and Virtual channels. Sensirion SHT75 WeekIndoor Saint-basile-le-grand, Qc, Canada
3Atmospheric pressure MPX4115AP Day Indoor Saint-basile-le-grand, Qc, Canada
4Atmospheric pressure MPX4115AP Week Indoor Saint-basile-le-grand, Qc, Canada
5Temperature MCP9803 Day Inside a standalone air conditioner, air output A server room in Montreal, Qc, Canada
6Temperature MCP9803 Day In front of an air duct (Building's air conditionner) A server room in Montreal, Qc, Canada
Hourly graphics available at http://meteo.raphnet.net

goto top Up


Schematics [hide]
Here are the schematics:

If you need a wiring diagram specific to your sensor, consult the corresponding diagram from the 'Supported sensors, wiring and firmwares' section below.
Design notes:
I started working on this project when a friend needed a simple, low-cost, computer-connected temperature sensor for monitoring a presumably unreliable air conditioning unit in a server room.

For simplicity, I decided to re-use the PCB I designed for my game controllers to USB projects. Therefore, the sensor connects to a PC using USB. For sensing the temperature, I decided to use (for the moment) digital sensors. Using digital sensors is easy, most sensors provide an acceptable precision, calibration is not required and I did not need to add additional components such as voltage references, precision resistors and operational amplifiers to my already existing board.

goto top Up


Supported sensors, wiring and firmwares [hide]
The atmega8 has to be programmed with a firmware that supports the sensor you are using. Unless otherwise noted, the fuse settings should be set to high_byte=0xC1 low_byte=0x1F.

I used Objective Development's software only USB implementation for Atmel's AVR microcontrollers, it was natural to use it again for this project. This means that again, the firmware is open-source and released under the Objective Development licence.

The source code for the firmware and host side client are distributed together. You can get both in the Host software section.


SHT75
Wiring diagram:
Type: Temperature and Relative HumidityInterface: Serial (similar to I2C, but not compatible)
Firmware: sensirion.hex Version: 1.1
Accuracy: ±0.3°C @ 25°C and ±1.8% RH
Comments:
This is a very precise two-in-one sensor manufactured by sensirion which outputs 14 bits of temperature data and 12 bits of relative humidity data. It is so sensitive that using the sensor more than 10% of the time will raise it's temperature by 0.1°C. Note that sensirion's temperature/humidity sensors all use the same protocol so this firmware can be used with other sensors such as the SHT11.

MCP9801/9803
Wiring diagram:
Type: TemperatureInterface: I2C
Firmware: mcp9800.hex Version: 1.1
Accuracy: ±0.5°C (typ.) at +25°C, ±1°C (max.) from -10°C to +85°C, ±2°C (max.) from -10°C to +125°C, ±3°C (max.) from -55°C to +125°C
Comments:
A good temperature sensor with 12 bit output. It's accuracy is much better than the LM75. In order to be detected by the firmware (without modifications), all 3 address pins must be connected to VCC. This allows for easier wiring. Installing a small capacitor near the sensor is a good idea.

LM75 (and compatibles)
Wiring diagram:
Type: TemperatureInterface: I2C
Firmware: lm75.hex Version: 1.1
Accuracy: ±2°C (max) from -25°C to +100°C, ±3°C (max) from -55°C to +125°C
Comments:
This is a standard and easy to find sensor. In fact, many sensors are compatible with the LM75 but support additional functionalities and/or resolution (for instance, the MCP980x sensors). The standard LM75 reports temperature using 9 bits. In order to be detected by the firmware (without modifications), all 3 address pins must be connected to VCC. This allows for easier wiring. Installing a small capacitor near the sensor is a good idea.

MPX4115AP
Wiring diagram:
Type: Absolute Pressure, 15 to 115 kPaInterface: Analogic
Firmware: Any, configure ADC channel Version: 1.2
Accuracy: ±1.5% error from 0° to 85°, Temperature compensated from -40°C to +125°C
Comments:
This sensor is for measuring the air pressure. Connect it to one of the ADC channels on the Atmel and configure the corresponding ADC channel with chip id 0x90. Because of the wide sensitivity range of the sensor and the Atmega8's analog to digital converter which cannot take samples using more than 10 bits, the accuracy is not so good and noise is visible on graphs. Nevertheless, it's sufficient to get a good idea of the current tendency. (Pressure rising or falling).

ADC inputs
No diagram. Type: 0 volts to VCC (approx 5 volts)Interface: Analogic
Firmware: adc.hex Version: 1.6
Accuracy: 10 bits
Comments:
Used to measure the voltage present on the Atmega8's ADC inputs (ADC0 to ADC5). For the moment, the reference is always VCC. It is thus important to take into account the fact that the voltage may not be exactly 5 volts. Also, care must be taken not to exceed VCC.

Configuring ADC channels: The firmware can expose ADC channels as specific chip IDs. By default all ADC channels are configured to CHIP_NONE (0xff). If you connect an analogic sensor to an ADC channel, configure the firmware (only needed once since the information is stored in eeprom). Here's a configuration example: (Sets ADC0 to 0x90 [MPX4115]).
# ./usbtenkisetup -s 'XXXXXX' setadcchip 0 0x90
For details about how to program an AVR, please visit my AVR programming page.

goto top Up


Host software [hide]
At the moment, the host side software is a command line tool that has only been tested under Linux. It uses libusb, so it should be easily ported to OSes supported by libusb.

FileDescription
usbtenki-1.6.tar.gz (303K) New features:
  • Firmware named 'ADC' for using only analogic inputs.
  • New channel types voltage and inverse voltage. New unit: 'Voltage'.
  • Option for retrying in case of a communication error or access conflict.
usbtenki-1.4.tar.gz (321K) Version 1.4 is the first public version. Tested on Linux and Mac OS X
usbtenki_munin.tar.gz munin plugin scripts.


Listing devices:
For printing a list of accessible USBTenki devices, use the '-l' switch:
# ./usbtenkiget -l
Found: 'USBTenki', Serial: 'B10004', Version 1.2, Channels: 11
    Channel 0: Sensirion SHT1x/7x Temperature [Temperature]
    Channel 1: Sensirion SHT1x/7x Relative Humidity [Relative Humidity]
    Channel 2: MPX4115 Absolute air pressure sensor [Pressure]
    Virtual Channel 256: Dew point [Dew point]
    Virtual Channel 257: Humidex [Humidex]
    Virtual Channel 258: Heat index [Heat index]
As you can see in the output above, there is a concept of channel and virtual channel. A channel reports real data from the physical sensor (or data computed by the firmware). Virtual channels are channels whose value is computed locally using the real channels. (More info about virtual channels)

Reading values:
Reading values from an USBTenki device is done by specifying a comma-separated list of the channels you want to the -i switch. If the value 'a' is passed, all channels are listed.
# ./usbtenkiget -i 0,1,256
22.46, 39.55, 8.02
The ouput above is easy to parse. But if you want a prettier output, use the -p switch:
# ./usbtenkiget -i a -p
Temperature: 22.26 °C
Relative Humidity: 40.03 %
Pressure: 102.89 kPa
Dew point: 8.02 °C
Humidex: 22.67 °C
Heat index: 24.98 °C
If the degree ° sign shows as garbage on your terminal, change your encoding to iso8859-1 or try the -7 switch to disable such fancy characters.

Converting values:
Celcius and Kilopascals are the default units. If you prefer other units, the -T and -P switches can be used to select different temperature and pressure units. Try -h for a list of supported units. Example:
# ./usbtenkiget -i 0,2 -p -T f -P hPa
Temperature: 70.61 °F
Pressure: 1022.45 hPa

goto top Up


Virtual Channels [hide]
Here is a list of the possible virtual channels, their dependencies and links to related documentation.
Channel # Name Dependencies Comments
256 Dew point Temperature and Relative Humidity "The "dew point" or "dewpoint" of a given parcel of air is the temperature to which the parcel must be cooled, at constant barometric pressure, for water vapor to condense into water, called dew." - source: Wikipedia. This value is calculated using a formula from a sensirion application note named Dewpoint Calculation Humidity Sensor
257 Humidex Dew point (virtual) and Temperature "The humidex is an index (a computed value as opposed to something measured) devised to describe how hot or humid weather feels to the average person." - Source: Meteorological Service of Canada FAQ. Visit their FAQ for information about how Humidex is calculated.
258 Heat index Temperature and Relative Humidity "The Heat index (HI) is an index that combines air temperature and relative humidity to determine an apparent temperature - how hot it actually feels." - Source: Wikipedia.

goto top Up


Printed Circuit Board [hide]
Top

Top

The PCB I use is the same as in the GC/N64 controller to usb project. This PCB has a footprint for a voltage regulator (not used this time) and reprogramming contacts on the bottom side. Here are composite images of the top and bottom layers:



No regulator is requied so the only components that must be installed on the back side are the two voltage selection resistors. Install them as they are on the picture on the right. If you dont have 0 ohm resistors, you may use small pieces of wire or do solder bridges.

Here is a wiring diagram for the board. With the schematic and sensor wiring diagrams, it should be easy to figure out how to connect your sensor.


And finally, here are the gerber files which you can use produce this PCB:
multiuse.zip

Due to the fact that this board is two-sided and has numerous vias, building it at home may be a little harder than the ususal. If you want, you can get professional PCBs from my online store.

goto top Up


References [hide]
The following wikipedia articles were useful:
Celcius
Fahrenheit
Heat index

The application notes on sensirion website. For calculating dewpoint from Temp + RH and for sensor documentation:
SHT75 datasheet and application notes

Information about humidex on the Meteorological Service of Canada (MSC) website:
http://www.weatheroffice.gc.ca/mainmenu/faq_e.html#weather4b

goto top Up


Disclaimer [hide]
I cannot be held responsible for any damages that could occur to you or your equipment while following the procedures present on this page. Also, I GIVE ABSOLUTELY NO WARRANTY on the correctness and usability of the informations on this page. Please note, however, that the procedures above have worked in my case without any damages or problems.

Now you cannot say that I did not warn you :)

goto top Up


Copyright © 2002-2009, Raphaël Assénat
Trademarks used in this site are the property of their respectives owners.
Website coded withWebsite coded with vimLast update: May 17, 2009