A program for monitoring the temperature in your medication cabinet and warning you via Telegram when it's too hot or cold - complete with setup instructions
If you've ever lived in a one-room-appartment, you know how difficult it can be to keep your medication at a medication-friendly temperature and humidity. There's steam from the kitchen, humidity from the shower, coldness from opening the windows at night and heat from closing them in winter.
MediTemp is a solution -admittedly for linux powerusers mainly- that allows you to monitor the temperature in your medication cabinet using a Linux machine and a small temper usb thermometer connected with an usb cable. It plots the temperature and humidity, one data point every 10 minutes, and stores it in a csv file, and it sends you a notification (e.g. on your phone) via Telegram whenever temperature or humidity fall into bad ranges. There are even instructions on how to get a ringtone from your phone whenever ths occurs (on android)!
It's just a small python script that you will have to start (with sudo) everytime your machine starts. This README contains detailed information on how to set up the thermometer and the USB connection to it, how to get these components, how to set up the connection via Telegram, and potentially the ringtone notification if you want to get one everytime the temperature goes out of bounds.
Whenever the temperature is lower than 15°C or higher than 25°C, or when the humidity is higher than 60%.
You can change these values by editing the meditemp.py
file.
You can also change the interval in which the temperature is changed in the file (defaults to 10 minutes, checking the temperature more often can cause the temperature device to heat up its surroundings or itself).
You'll need a TEMPer device, which looks like a USB stick, but contains a thermometer and, in some cases, a humidity sensor that can be accessed by a connected machine. The one I used (for which this program is tested) is the classic TEMPer device which is also pretty affordable (around 15USD), but doesn't offer humidity support; alternatives and how to identify them are listed here.
You will also need a USB-A plug to USB-A socket cable to connect the TEMPer device to your machine on which you run meditemp; the one I used is this one. You could, theoretically, do without this if you store your machine in your medicine cabinet, but I wouldn't recommend this since your machine will emit heat into the medicine cabinet and also heat up the temperature sensor itself.
It should be mentioned that all of the TEMPer devices measure their internal temperature, so the temperature reported may be higher than the one of their surroundings.
If you want to minimize temperature changes for the emds, you could put them and the thermometer into a thermos bag. This might cause them to get warmer due to the heat generated by the thermometer, though, which might be a problem if your room is already on the warmer side (but might be a positive side effect if it isn't). You should also make sure to only open the bag under good temperature conditions if you do this, since otherwise you'll end up keeping your meds at suboptimal temperatures longer than needed with this bag.
# Clone the repo
git clone git@github.com:phseiff/MediTemp.git
cd MediTemp
# or like this:
# git clone https://github.com/phseiff/MediTemp.git
# make sure gnuplot is installed
# if you don't want your temperature plotted you can skip this
sudo apt-get install -y gnuplot
# install telegram-send and set it up
# if you don't want warning notifications you can skip this
sudo pip3 install telegram-send
telegram-send --configure
# you will now have to go to https://telegram.me/BotFather to
# create a bot, and paste the bot token; just follow the
# instructions telegram-send gives you on this.
sudo python3 meditemp.py \
--no-gnuplot `# <- only if skipped the gnuplot step above` \
--no-notif `# <- only if you skipped the telegram-send step` \
#--no-log `# <- disables error log - not recommended!!!` \
-
You should get a temperature log printed in the console, one line every 10 minutes, like this:
12/28/2021, 01:43; 24.56
-
A file called
med_temp.csv
will be created, in which the temperature is logged, each line being in a"time[%m/%d/%Y, %H:%M]; temp[°C]; humidity[%]
format. -
A file called
meditemp-log.txt
will be created, in which, if--no-log
isn't set, errors and the time they occurred will be logged. None of these errors will ever crash the program. -
If
--no-gnuplot
isn't set, a file calledmed_temp.html
should be created, which you can open in your browser to see how the temperature changed over time. You can changemeditemp.gnuplot
to midufy how the plot looks like. -
If
--no-notifs
isn't set and the temperature or humidity falls out of bounds, you should receive a telegram notification from the bot you created that goes likeTemperature alert: 25.18°
or likeHumidity alert: 61%
.
All of the files created by meditemp are persistent throughout all runs (restarting doesn't overwrite their content, instead adding to it), and updated everytime temperature and humidity are measured, not just when the program is exited. The program runs with sudo (otherwise connecting to the thermometer won't work for some reason), but all files are saved and created with the local user as their owner.
If you are on android and want to get a ringtone whenever you get a notification, you can either set custom notifications for the bot (this should work in iOS too) by going into your chat with the bot, clicking the bot's name, clicking on "Notifications" and choosing "Customize", then customizing, or you can use an app called Message Alarm which allows you to set specific notifications (as in, ringtones) for specific telegram contacts (such as your bot). You have to add Telegram to the applications tracked by the app to achieve this, and then add the username (not the handle!) of your bot to the tracked users.
run
sudo nano /bin/rc.local
(you might have to enter your root password) and then add
sudo python3 [absolute path to meditemp]/meditemp.py [optional arguments] &
before the exit 0
and after the shebang and anything else in the file (the ampersand is important).
Then press Ctrl+X and press y and Enter.
If you encounter a bug please report it with the entire relevant parts of meditemp-log.txt
, as well as the command you used.
If you encounter an error with --no-logfile
and do not have the error message from your console, please try to replicate the error without --no-logfile
before reporting the issue so you can share the log.
Humidity detection is untested and I am not really able to debug anything specific to it due to me not owning the relevant hardware; if you encounter or see an issue related to it feel free to help by creating a pull request that fixes the issue.
The program is tested in Ubuntu 18.04, in case that's relevant for you.
Issues are welcome, pull requests for bugfixes are also welcome, starring this repo to show your appreciation is especially welcome! ⭐
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
SIMILARLY, ANY HARDWARE RECOMMENDATION OR SUGGESTION IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT, OF BOTH THE HARDWARE AND THE SUGGESTED USE FOR THE HARDWARE. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS OF THIS DOCUMENT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE HARDWARE MENTIONED AND THE HARDWARE MENTIONS IN THIS DOCUMENT.