I rebuilt an existing interface module — to be a stand-alone temperature and light sensor, with serial RS-232 interface and some signal LEDs. 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 light sensor.
It has two internal sensors, LM35 and TSL 252R, 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.
Four external analog inputs are available through the D-sub connector, and can be used for auxiliary sensors.
In addition to sensor inputs — the module also has three LEDs and a buzzer for alerts and signalling. The LEDs are driven by PWM outputs, meaning their brightness can be controlled. Slowly fading LEDs in and out is softer and more aesthetically pleasing than regular flashing — at least to me 🙂
I/O
Inputs
- PC0 Temperature sensor (analog)
- PC1 Light sensor (analog)
- PC2 Analog input 3
- PC3 Analog input 4
- PC4 Analog input 5
- PC5 Analog input 6
Calculations
Temperature
ADC × 5
------- ≈ °C ± 0.5
10
Light intensity
ADC × 5 µW
------- ≈ --- ± 0.532
9.4 cm²
Outputs
- PB0 Buzzer
- PB1 Green LED (PWM)
- PB2 Yellow LED (PWM)
- PB3 Red LED (PWM)
- PD3 Life signal
- PD4 Link activity
Serial communication
- PD0 Rx
- PD1 Tx
D-sub 25-pin
- 13.8V
- 0V
- 5V out (from internal voltage regulator)
- 0V out
- Analog input 3
- Analog input 4
- Analog input 5
- Analog input 6
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-light-sensor-LED-signals-RS232
Photos
Schematic drawing
Parts used
- 1 × AVR ATmega8-16PU, DIL-28, 16 MHz, 23 I/Os
- 1 × Buzzer, electromagnetic PCB, 12V, 35mA, Ø16mm, int. oscillator
- 5 × Capacitor, aluminium electrolytic, 1 µF, 50V
- 2 × Capacitor, aluminium electrolytic, 10 µF, 25V
- 3 × 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, 25 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), 150x80x50mm, flange
- 1 × Fuse 5x20 mm, 800 mA, fast-acting
- 1 × Fuse holder, panel, 5x20mm, PTF30
- 1 × Heatsink, 27.3K/W, 19mm, attachable, TO220
- 1 × LED 5mm clear, Green, 2.1V, 20mA, 385mcd, 6°
- 1 × LED 5mm clear, Green, 3.4V, 20mA, 10.000mcd, 25°
- 1 × LED 5mm clear, Red, 2.1V, 20mA, 7.000mcd, 20°
- 1 × LED 5mm clear, Yellow, 2.0V, 20mA, 250mcd, 6°
- 1 × LED 5mm clear, Yellow, 2.1V, 20mA, 10.000mcd, 20°
- 1 × LED lens 5mm, CLB 300 low, Green
- 1 × LED lens 5mm, CLB 300 low, Yellow
- 1 × LED lens 5mm, CLF 280, Green
- 1 × LED lens 5mm, CLF 280, Red
- 1 × LED lens 5mm, CLF 280, Yellow
- 1 × Light-to-voltage sensor, TSL 252R, 9.4mV / (μW/cm2)
- 64 cm2 PCB, stripboard, 100x160mm, 160cm2
- 1 × Power jack, panel, 2.1mm, plastic housing
- 1 × Resistor, carbon film, 0.25W, 100 Ω, 5%
- 2 × Resistor, carbon film, 0.25W, 150 Ω, 5%
- 2 × Resistor, carbon film, 0.25W, 330 Ω, 5%
- 2 × Resistor, carbon film, 0.25W, 4.7 kΩ, 5%
- 1 × RS232 interface, MAX232CPE, dual
- 1 × Spacer, round unthreaded, 3mm, Ø6mm, Delrin
- 35 × Straight pin header, female, Single row, 2.54mm
- 2 × Straight pin header, male, Dual row, 2.54mm
- 40 × 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-11-11, with message: Add lots of tags to posts.