Light intensity and temperature sensors; with white, green, yellow, red and blue signal LEDs and a buzzer. RS-232 communication. Uses an AVR ATmega8 microcontroller.

Table of contents

Details

This serial port module has two analog sensors: temperature (LM35) and light intensity (TSL252R), five colored LEDs, and a buzzer.

I originally built it for my old apartment, where it measured the temperature and illuminance in my living room. The LEDs were used to give a visual indication of notices and alarms from the rack box project.

The firmware has been revised several times since it was built. The LEDs and switch makes it an ideal module for testing purposes.

Munin graph of temperature, over 24 hours
Munin graph of illuminance, over 24 hours

Commands

Inputs

  • Digital
    1. Switch up
    2. Switch down
  • Analog
    1. Temperature sensor
    2. Light sensor

Outputs

  • Digital
    1. Green LED
    2. Yellow LED
    3. Red LED
    4. Blue LED
    5. Buzzer
  • Analog
    1. White LED (PWM)

Video demonstration

I/O

Inputs

  1. PC0 Temperature
  2. PC1 Light intensity
  3. PC2 Switch 1
  4. PC3 Switch 2

Calculations

Temperature

ADC × 5
------- ≈ °C ± 0.5
  10

Light intensity

ADC × 5   µW
------- ≈ --- ± 0.532
  9.4     cm²

Outputs

  1. PB0 LED white
  2. PB1 LED green
  3. PB2 LED yellow
  4. PB3 LED red
  5. PB4 LED blue
  6. PB5 Buzzer
  7. PD5 Link act.
  8. PD6 Status LED red
  9. PD7 Status LED green

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

Photos

Cutouts in plastic enclosure
Buzzer mounted in enclosure
Voltage regulator with heat-sink
LEDs and switch, with wires
Circuit board, AVR microcontroller not installed
Sensors mounted
Sensors mounted
Lenses for LEDs installed
Inside module during assembly
Inside module during assembly
Inside module during assembly
All LEDs and switch mounted
Installing circuit board
Installing circuit board
Module completed, testing
Sensors poking out of enclosure
Module mounted on cabinet
Module mounted on cabinet
Inside module
AVR microcontroller and serial interface IC

Schematic drawing

Schematics for serial interface module

Parts list

  • 1 × AVR ATmega8-16PU, DIL-28, 16 MHz, 23 I/Os
  • 1 × Buzzer, 95 dB, panel, 24x18 mm, 10–26 V
  • 5 × Capacitor, aluminium electrolytic, 1 µF, 50V
  • 1 × Capacitor, aluminium electrolytic, 10 µF, 25V
  • 2 × Capacitor, aluminium electrolytic, 47 µF, 25V
  • 2 × Capacitor, ceramic, 1 nF, 100V
  • 2 × Capacitor, metallized polyester foil, 10 nF, (0.01 µF)
  • 1 × D-sub soldering cups, 9 pin female
  • 1 × DIL socket, 16-pin, 7.62mm
  • 1 × DIL socket, 28-pin, 7.62mm
  • 1 × Diode, rectifier, 1 A, 400V, 1N4004
  • 1 × Enclosure, plastic (1591 FL), 150x80x50mm, flange
  • 1 × Fuse 5x20 mm, 500 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 × LED 5mm clear, Blue, 3.4V, 20mA, 7.200mcd, 20°
  • 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, White, 2.95V, 20mA, 12.000mcd, 20°
  • 1 × LED 5mm clear, Yellow, 2.1V, 20mA, 10.000mcd, 20°
  • 1 × LED 5mm, Red/Green, 2.0 2.1V, 10mA, 100 63mcd, 30°
  • 1 × LED 5mm, Yellow, 2.0V, 25mA
  • 2 × LED holder 5mm, Black plastic
  • 1 × LED lens 5mm, CLF 280, Blue
  • 1 × LED lens 5mm, CLF 280, Clear
  • 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)
  • 32 cm2 PCB, stripboard, 100x160mm, 160cm2
  • 1 × Power jack, panel, 2.1mm, plastic housing
  • 2 × Resistor, carbon film, 0.25W, 100 Ω, 5%
  • 1 × Resistor, carbon film, 0.25W, 120 Ω, 5%
  • 2 × Resistor, carbon film, 0.25W, 150 Ω, 5%
  • 2 × Resistor, carbon film, 0.25W, 330 Ω, 5%
  • 3 × Resistor, carbon film, 0.25W, 470 Ω, 5%
  • 2 × Resistor, carbon film, 0.25W, 4.7 kΩ, 5%
  • 2 × Resistor, carbon film, 0.25W, 10 kΩ, 5%
  • 1 × RS232 interface, MAX232CPE, dual
  • 1 × Rubber boot for toggle switch, O-ring sealing
  • 4 × Spacer, round unthreaded, 3mm, Ø6mm, Delrin
  • 33 × Straight pin header, female, Single row, 2.54mm
  • 33 × Straight pin header, male, Single row, 2.54mm
  • 1 × Switch, toggle, 1-pole, micro, (on)-off-(on)
  • 1 × Temperature sensor LM35DZ, 0 to +100 °C, +-0,6 °C
  • 1 × Transistor, NPN, 800 mA, 45V, 0.625W, BC337-25
  • 1 × Voltage regulator +5V, 2 A, L78S05CV

Last commit 2024-11-11, with message: Add lots of tags to posts.