Difference between revisions of "Arduino: Simple LCD Thermometer with USB interface"
Lukas Dzunko (talk | contribs) (→Internal details) |
Lukas Dzunko (talk | contribs) (→Serial (USB) interface) |
||
Line 225: | Line 225: | ||
=== Physical connections === | === Physical connections === | ||
==== Serial (USB) interface ==== | ==== Serial (USB) interface ==== | ||
+ | Serial converter is connected to PD0 / PD1 (Digital 0/1) on micro-controller. Internal serial logic handle serial interface. | ||
+ | |||
==== Display ==== | ==== Display ==== | ||
==== Keyboard ==== | ==== Keyboard ==== |
Revision as of 13:08, 18 April 2014
Attention: this page is work in progress.
My motivation for "Simple LCD Thermometer with USB interface" is my server room. It is important to keep temperature and humidity in correct range. I am using automatic monitoring to be sure that everything is in "green" state. Previously I was using Conrad TFD 128 logger. It is good product but it have several design problems. To fulfill my needs I created my own device.
Contents
Technical specification
- Temperature and humidity collected in 10 second interval
- LCD interface with warnings (hot/cold, wet/dry)
- LCD interface with 5 tactile keys
- History and diagnostic information on LCD
- USB interface with simple text oriented protocol
- Historical data stored in RAM memory readable via LCD and USB interface
- Historical data with 5 minute interval (up to 60 minutes) and 1 hour interval (up to 72 hours)
- Minimum and Maximum values
- Temperature range: +1C - +50C, Resolution 0.1C
- Humidity range: 1% - 99%, Resolution: 1% (display), 0.1% (USB)
- Internal mCPU temperature monitoring
- Ranges indicating "normal" condition:
- temperature: 20 - 25C
- humidity: 40 - 70%
- dew point: 10 - 16C
LCD Interface
Temperature sensor need at least two seconds to settle down. This make space to display reboot source. If it is necessary to wait, then it is possible to use this time to show why device was rebooted.
Startup screen stay for approximately 3 seconds and then device move to "Normal screen". If there is no activity for 60 seconds then device automatically move back to "Normal screen".
Blinking text indicate out of range condition (hot/cold, wet/dry, reading out of range).
Note: all display examples use illustration values. For more details check ranges in technical specification.
Startup screen
Displayed up on device reboot. Indicate source of reboot.
+----------------+ +----------------+ +----------------+ +----------------+ |Please wait ... | |Please wait ... | |Please wait ... | |Please wait ... | |(Watchdog) WDRF| |(Brown-out) BORF| |(External) EXTRF| |(Power-on) PORF| +----------------+ +----------------+ +----------------+ +----------------+
Normal screen
Displayed during "normal" operation. First two characters on second line show device status:
- position 1: "heart" show sensor / device activity (♡ is altering with ♥ after each successful sensor read).
- position 2: "arrows" indicate USB activity (⇅ pop up if there is USB activity).
+----------------+ +----------------+ +----------------+ |T: 21.3C H: 50% | |T: 28.8C H: 90% | |T: 10.2C H: 10% | |♡⇅ NORM NORM| |♥⇅ HOT WET | |♡⇅ COLD DRY | +----------------+ +----------------+ +----------------+
Dew point (display)
+----------------+ +----------------+ +----------------+ |Dew point: 14.1C| |Dew point: 20.2C| |Dew point: 9.1C| | Comfortable| | Too high| | Too low| +----------------+ +----------------+ +----------------+
History + min/max
Minimum/Maximum and value from past (history) is indicated in left down corner of screen.
Temperature and humidity:
+----------------+ +----------------+ +----------------+ +----------------+ |T: 21.3C H: 50% | |T: 21.3C H: 50% | |T: 21.3C H: 50% | |T: 21.3C H: 50% | |-05m NORM NORM| |-55m NORM NORM| |-01h NORM NORM| |-72h NORM NORM| +----------------+ +----------------+ +----------------+ +----------------+ +----------------+ +----------------+ |T: 20.0C H: 30% | |T: 25.0C H: 30% | |MIN NORM NORM| |MAX NORM NORM| +----------------+ +----------------+
Dew point:
+----------------+ +----------------+ +----------------+ +----------------+ |Dew point: 14.1C| |Dew point: 14.1C| |Dew point: 14.1C| |Dew point: 14.1C| |-05m Comfortable| |-55m Comfortable| |-01h Comfortable| |-72h Comfortable| +----------------+ +----------------+ +----------------+ +----------------+ +----------------+ +----------------+ |Dew point: 12.1C| |Dew point: 16.1C| |MIN Comfortable| |MAX Comfortable| +----------------+ +----------------+
Diagnostic screen
System support following diagnostic screens:
+----------------+ +----------------+ +----------------+ +----------------+ +----------------+ |Diag: uptime | |Diag: history | |Diag: history | |Diag: CPU temp | |Diag: version | | 1234d 21h 45m| | m: 30 h: 20 | | m: ok h: ok | | | |Sys: AA Boot: AA| +----------------+ +----------------+ +----------------+ +----------------+ +----------------+
From left to right:
- device uptime
- position of first unknown history data (due to sensor problem or device reboot). "m" is for minute history and "h" for hour history.
- all history data valid
- internal CPU temperature (approximate)
- system and bootloader version
Screen position
Screen can be selected by tactile keyboard and position of screens are following:
+----------------+ +----------------+ |T: 25.0C H: 50% | |Dew point: 16.1C| |MAX NORM NORM| |MAX Comfortable| +----------------+ +----------------+ ↑ ↓ ↑ ↓ +----------------+ +----------------+ |T: 20.0C H: 30% | |Dew point: 12.1C| |MIN NORM NORM| |MIN Comfortable| Device boot-up +----------------+ +----------------+ ↓ ↓ ↑ ↓ ↑ ↓ +----------------+ +----------------+ +----------------+ +----------------+ |Please wait ... | → |T: 21.3C H: 50% | → |Dew point: 14.1C| → |Diag: uptime | → |(Power-on) PORF| → |♡⇅ NORM NORM| ← | Comfortable| ← | 123d 21h 45m| ← all other diag screens +----------------+ +----------------+ +----------------+ +----------------+ ↑ ↓ ↑ ↓ +----------------+ +----------------+ |T: 21.3C H: 50% | |Dew point: 14.1C| |-05m NORM NORM| |-05m Comfortable| +----------------+ +----------------+ ↑ ↓ ↑ ↓ history up to history up to 72 hours 72 hours for temperature for dew point and humidity
If there is no action for 60 seconds then screen move back to "Normal screen".
Serial (USB) interface
Device use virtual serial port over USB. Protocol is text oriented and request is made by sending upper case character. All undefinied characters are silently ignored. Additional requests are ignored while device is sending response. Configuration of serial port is 9600, 8-N-1, flow control: no
. Device send blank (space) character before responding to query.
Format of response
Example:
TEMP: 12.3C, HUM: 70.1%, 1 *CC
- all values are send in format: "
type: value unit
" - more values in one message are separated by coma (
,
) - last value is message sequential id. Number from 0 to 3.
- CRC is separated by asterisk (
*
) and is calculated as simple 8bit CRC
Message id start at 0. Increment sequentially to 3 and then wrap around to 0. This ensure that each message is unique even when temperature / humidity reading result in same number.
Commands / data query
Communication rules:
- Wait for "silence" before requesting data.
- Device respond immediately after request (interrupt driven logic).
- Additional response lines are requested by issuing requests once more. Issuing different command reset internal response line counter.
- Version command can be used as "ping" to check if device is alive.
Version
System and bootloader version:
V -> Sys: AA, Boot: AA, 0 *CC
Reboot
This command force device reboot by disabling interrupts and initiating endless loop. In such a condition device is automatically restarted by watchdog.
R -> (no response by device)
Note: there is no response to this command
Temperature / Humidity
Last temperature and humidity reading (up to 10 second old).
C -> Temp: 12.3 C, HUM 70%, 0 *CC
Temperature only
Last temperature reading (up to 10 second old, not suitable for dewpoint calculation).
T -> Temp: 12.3C, 0 *CC
Humidity only
Last humidity reading (up to 10 second old, not suitable for dewpoint calculation).
H -> Hum: 70%, 0 *CC
Dew point
Last dew point calculated from recent temperature and humidity (internally calculated by board).
D -> Dew: 12.3C, 0 *CC
Alarms
Current alarm condition.
S -> Temp: NORM, Hum: NORM, Dew: Comfortable, 0 *CC
History
History from 5 minutes to 72 hours in past (temperature, humidity, dewpoint). Repeat command to get more data.
H -> -05m, Temp: 12.3C, Hum: 70%, Dew: 10.0C, 0 *CC . . H -> -72h, Temp: 12.3C, Hum: 70%, Dew: 10.0C, 0 *CC
Note: dewpoint is not calculated. Number is for illustration only.
Minimum / Maximum + clear
Minimum and maximum values + command to clear data.
M -> Temp/Min: 12.3C, Hum/Min: 30%, Dew/Min: 10.0C, 0 *CC M -> Temp/Max: 23.1C, Hum/Max: 70%, Dew/Max: 21.3C, 1 *CC M -> Min/Max cleared ... , 2 *CC
Note: dewpoint is not calculated for particular Min/Max Temp/Hum combination. Value represent minimum or maximum for dewpoint itself.
Diag
Show diagnostic data in same format as on screen.
D -> UptimeD: 1234, UptimeH: 21, UptimeM: 45, 0 *CC D -> HistoryM: ok, HistoryH: ok, 1 *CC D -> CPUTemp: ...., 2 *CC
Internal details
I decided to use fixed connection layout to simplify code. System is internally "task" oriented.
Physical connections
Serial (USB) interface
Serial converter is connected to PD0 / PD1 (Digital 0/1) on micro-controller. Internal serial logic handle serial interface.