I rebuilt an existing interface module — to be a stand-alone temperature and humidity sensor, with serial RS-232 interface. Uses an AVR ATmega8 microcontroller.
Table of contents
About
This module was originally installed in the rack box, as an I/O module. When the rack box project was terminated, I instead repurposed the unit to become a stand-alone temperature and humidity sensor.
It has two sensors, LM35 and HIH 4000, connected to ADC inputs on the AVR microcontroller. When requested; the device returns the ADC value. This must be converted into a proper unit by the receiver.
I/O
Inputs
- PC0 Temperature sensor (analog)
- PC1 Humidity sensor (analog)
Calculations
Temperature
ADC × 5
------- ≈ °C ± 0.5
10
Humidity
ADC × 5 - 826
------------- ≈ %RH ± 3.5
31.5
Outputs
- PB0 Life signal
- PB1 Link activity
Serial communication
- PD0 Rx
- PD1 Tx
D-sub 15-pin
- 13.8V
- 0V
Communication
Interfacing is done with RS-232, using MAX232 or MAX202 and the SIOS protocol.
Serial settings
- Baud: 38400
- Data bits: 8
- Parity: None
- Stop bits: 1
Source code
- Bascom-AVR source is available in a git repository:
- https://github.com/thomasjsn/AVR-Temp-humidity-sensor-RS232
Photos
![](https://blog.cavelab.dev/2011/12/avr-temp-humidity-serial-sensor/temp_humid_sensor-20150919_234729_hu337a7655f9bb9806e0dcfd64669b7899_514647_800x0_resize_q80_lanczos.jpg)
![](https://blog.cavelab.dev/2011/12/avr-temp-humidity-serial-sensor/temp_humid_sensor-20150919_234831_hu3e66212137baa903ab9e841cfbc73c88_646528_800x0_resize_q80_lanczos.jpg)
![](https://blog.cavelab.dev/2011/12/avr-temp-humidity-serial-sensor/temp_humid_sensor-20150919_234901_hud38d082affdd546b2e5c7844f11cd3d9_665324_800x0_resize_q80_lanczos.jpg)
![](https://blog.cavelab.dev/2011/12/avr-temp-humidity-serial-sensor/temp_humid_sensor-20150919_234910_hue192a8d94342c061380440e32c90633e_635270_800x0_resize_q80_lanczos.jpg)
![](https://blog.cavelab.dev/2011/12/avr-temp-humidity-serial-sensor/temp_humid_sensor-20150919_234936_hu1a93e212b6c8841f2fa2dcee6180ae04_674536_800x0_resize_q80_lanczos.jpg)
![](https://blog.cavelab.dev/2011/12/avr-temp-humidity-serial-sensor/temp_humid_sensor-20150919_234957_hua373fa40db850511bb43f0745bc4fb44_736608_800x0_resize_q80_lanczos.jpg)
![](https://blog.cavelab.dev/2011/12/avr-temp-humidity-serial-sensor/temp_humid_sensor-20150919_235005_hu8ecc4e73d56c6ff4553f360fd1ffdada_726661_800x0_resize_q80_lanczos.jpg)
![](https://blog.cavelab.dev/2011/12/avr-temp-humidity-serial-sensor/cover_hubb86f9892bd2a6646e52eefed03c269e_574923_800x0_resize_q80_lanczos.jpg)
Schematic diagram
![](https://blog.cavelab.dev/2011/12/avr-temp-humidity-serial-sensor/avr_temperature_humidity_sensor_circuit.png)
Parts used
- 1 × AVR ATmega8-16PU, DIL-28, 16 MHz, 23 I/Os
- 5 × Capacitor, aluminium electrolytic, 1 µF, 50V
- 1 × Capacitor, aluminium electrolytic, 10 µF, 25V
- 2 × Capacitor, aluminium electrolytic, 47 µF, 25V
- 1 × Capacitor, ceramic, 1 nF, 100V
- 3 × Capacitor, metallized polyester foil, 10 nF, (0.01 µF)
- 1 × D-sub soldering cups, 15 pin male
- 1 × D-sub soldering cups, 9 pin female
- 1 × DIL socket, 16-pin, 7.62mm
- 1 × DIL socket, 28-pin, 7.62mm
- 1 × Enclosure, plastic (1591 FL), 120x65x40mm, flange
- 1 × Fuse 5x20 mm, 200 mA, fast-acting
- 1 × Fuse holder, open, PCB, 5x20mm
- 1 × Fuse holder, open, PCB, Protective cover
- 1 × Heatsink, 27.3K/W, 19mm, attachable, TO220
- 1 × Humidity sensor, HIH 4000, 0 - 100 %, +4 to +5.8 V
- 1 × LED 5mm clear, Yellow, 2.0V, 20mA, 250mcd, 6°
- 1 × LED 5mm coloured clear, Green, 2.1V, 20mA, 30mcd, 10°
- 2 × LED holder 5mm, RTC51, black plastic
- 64 cm2 PCB, stripboard, 100x160mm, 160cm2
- 1 × Power jack, panel, 2.1mm, plastic housing
- 2 × Resistor, carbon film, 0.25W, 330 Ω, 5%
- 2 × Resistor, carbon film, 0.25W, 4.7 kΩ, 5%
- 1 × RS232 interface, MAX232CPE, dual
- 25 × Straight pin header, female, Single row, 2.54mm
- 25 × Straight pin header, male, Single row, 2.54mm
- 1 × Temperature sensor LM35DZ, 0 to +100 °C, +-0,6 °C
- 1 × Transistor, NPN, 100 mA, 45V, 0.5W, BC547B
- 1 × Voltage regulator +5V, 2 A, L78S05CV
Last commit 2024-04-05, with message: Tag cleanup.