Log ambient temperature readings in degrees Celsius and Fahrenheit.
Motivation: The ideal temperature while sleeping is between 60 and 67 degrees Fahrenheit. I am using this application to experimentally tune my heating systems (heater or thermostat settings) to the sweet spot. Of course, this application can be used for many other use cases where temperature logging is desired.
# in the project root folder
cd temperature_logger_umbrella/
# start elixir application
iex -S mix
# In another terminal start a tcp client
telnet 127.0.0.1 4040
# display available ports
> enumerate
# start logging with default period and file path
> start
# stop logging
> stop
# start logging every 60 seconds to the default file
> start 60
> stop
# start logging every 20 seconds to the file `~/logs/temperature.log`
> start 20 ~/logs/temperature.log
enumerate
Prints out the available ports.
start <period> <path>
Starts logging temperature data.
Option | Description | Default |
---|---|---|
period |
How often a sample should be recorded, in seconds (minimum is 1) | 1 |
log_path |
The path to the file that is written to | /temperature_logger_umbrella/log/temperature_logger.log |
stop
Stops logging temperature data.
git clone git@github.com:johnc219/temperature-logger.git
Required parts:
TI MSP430G2553
microcontroller with LaunchpadTMP36
temperature sensor.1uF
capacitor (seeTMP36
datasheet Basic Temperature Sensor Connections)
Note the 0.1 μF bypass capacitor on the input. This capacitor should be a ceramic type, have very short leads (surface-mount is preferable), and be located as close as possible in physical proximity to the temperature sensor supply pin. Because these temperature sensors operate on very little supply current and may be exposed to very hostile electrical environments, it is important to minimize the effects of radio frequency interference (RFI) on these devices.
- Install Energia
- Ensure the
MSP430G2
drivers are installed - Open
temperature_sensor.ino
- Connect the Launchpad via USB
- Select
MSP430g2553
underTools > Board
, and select the correct serial port underTools > Serial Port
. If you don’t see a selectable serial port, you likely have a driver issue. - Upload
temperature_sensor.ino
to theMSP430G2553
- Ensure
elixir
is installed - Ensure C compiler dependencies are satisfied
- Navigate to
temperature_logger_umbrella/
- Run
mix deps.get
- Run
mix compile
If you are using a board other than the MSP430, you can implement your own microcontroller code. The Elixir app expects to receive UART messages every second. The message is expected to be a JSON string with a \n
at the end in the following format:
{ "celsius": <Number>, "fahrenheit": <Number> }
The code must adhere to the following rules:
- Baudrate of 9600 b/s
- Must start sending data when an "O" is received
- Must stop sending data when an "F" is received
- When sending, data must be sent at a period of 1 sec
- The data must be sent in format described above
Caveat
There is no current option to specify the port in the TCP client API. You must invoke
TemperatureLogger.start_logging(TemperatureLogger, [port: <String>])
directly in iex
.
Why not just buy a thermometer?
This application is to automate logging temperatures in addition to reading them.