{"id":338595,"date":"2022-09-21T21:00:09","date_gmt":"2022-09-21T21:00:09","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=338595"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=338595","title":{"rendered":"<span>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0432 R \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 Rapsberry PI Zero W<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0414\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 <a href=\"https:\/\/teletype.in\/@weekly_charts\/YodM2Y8SNmM\" rel=\"noopener noreferrer nofollow\">\u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0433\u043e\u0434\u044b \u0432 \u0440\u0435\u0433\u0438\u043e\u043d\u0430\u0445 \u0420\u0424<\/a> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 R, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044e (\u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e \u043a\u0430\u0436\u0434\u044b\u0435 \u0442\u0440\u0438 \u0447\u0430\u0441\u0430) \u043d\u0430 \u043c\u043e\u0451\u043c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u043c \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435 \u2014 Raspberry PI Zero W.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/661\/641\/94f\/66164194f4cf4a532a74b544e8b7b330.jpeg\" alt=\"\u041c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0434\u043e\u043c\u0430\u0448\u043d\u0438\u0439 \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 24\/7\" title=\"\u041c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0434\u043e\u043c\u0430\u0448\u043d\u0438\u0439 \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 24\/7\" width=\"958\" height=\"626\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/661\/641\/94f\/66164194f4cf4a532a74b544e8b7b330.jpeg\" data-blurred=\"true\"\/><figcaption>\u041c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0434\u043e\u043c\u0430\u0448\u043d\u0438\u0439 \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 24\/7<\/figcaption><\/figure>\n<p><strong>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435: <\/strong><a href=\"https:\/\/disk.yandex.ru\/d\/b6Qu6RSAUGXqLg\" rel=\"noopener noreferrer nofollow\">cpu_temp.log<\/a><\/p>\n<p>\u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043c\u0438\u043d\u0443\u0442\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 Raspberry PI, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u043b\u043e\u0433-\u0444\u0430\u0439\u043b\u0435 c \u043f\u043e\u043c\u043e\u0449\u044c\u044e bash-\u0441\u043a\u0440\u0438\u043f\u0442\u0430:<\/p>\n<pre><code class=\"bash\">#!\/bin\/bash date +\"%d.%m.%Y %T\" | tr '\\n' '\\t' >> \/home\/pi\/cpu_temp.log ; vcgencmd measure_temp| tr -d \"temp=\" | tr -d \"'C\" >> \/home\/pi\/cpu_temp.log<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 bash-\u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043f\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0447\u0435\u0440\u0435\u0437 cron \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c (\u043a\u0430\u0436\u0434\u0443\u044e \u043c\u0438\u043d\u0443\u0442\u0443):<\/p>\n<p><code>*\/1 * * * * ~\/cpu_temp.sh<\/code><\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043b\u043e\u0433:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7ed\/4ef\/c63\/7ed4efc6351682acde7f00668439a1fb.png\" width=\"1065\" height=\"743\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7ed\/4ef\/c63\/7ed4efc6351682acde7f00668439a1fb.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u042d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e R (<a href=\"https:\/\/disk.yandex.ru\/d\/NgkCtteoZ-fPag\" rel=\"noopener noreferrer nofollow\">cpu_temp.R<\/a>), \u0430 \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a \u0432\u0441\u0442\u0430\u0432\u0438\u043c \u043b\u043e\u0433\u043e Raspberry PI:  <a href=\"https:\/\/disk.yandex.ru\/d\/dP16Vwq9sH6RNQ\" rel=\"noopener noreferrer nofollow\">https:\/\/disk.yandex.ru\/d\/dP16Vwq9sH6RNQ<\/a>  <\/p>\n<pre><code class=\"r\">library(tidyverse) library(readr) library(geomtextpath) library(glue) library(here)  # \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043b\u043e\u0433\u043e\u0442\u0438\u043f Raspberry Pi png &lt;- magick::image_read(\"raspberrypi-logo.png\") img &lt;- grid::rasterGrob(png, interpolate = TRUE)  # \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 (\u043b\u043e\u0433 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b) cpu_temp &lt;- read_delim(     \"cpu_temp.log\",     delim = \"\\t\",     col_names = c(\"datetime\", \"cpu_temp\"),     trim_ws = TRUE) %>%   mutate(datetime = lubridate::as_datetime(datetime,                                            \"%d.%m.%Y %H:%M:%S\",                                            tz = \"Asia\/Yekaterinburg\"))  # \u0412\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0434\u043b\u044f \u0433\u0440\u0430\u0444\u0438\u043a\u0430 -- \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 3 \u0447\u0430\u0441\u0430 \u0438\u0437 \u043b\u043e\u0433\u0430 last_datetime &lt;- cpu_temp$datetime[length(cpu_temp$datetime)] first_datetime &lt;- last_datetime - lubridate::hours(3)  # \u041e\u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u043b\u044f \u0433\u0440\u0430\u0444\u0438\u043a\u0430 (\u043c\u0438\u043d, \u043c\u0430\u043a\u0441, \u0441\u0440\u0435\u0434\u043d\u0435\u0435) maxTempCPU &lt;- max(cpu_temp$cpu_temp[between(cpu_temp$datetime,                                             first_datetime, last_datetime)]) minTempCPU &lt;- min(cpu_temp$cpu_temp[between(cpu_temp$datetime,                                             first_datetime, last_datetime)]) meanTempCPU_period &lt;-   round(mean(cpu_temp$cpu_temp[between(cpu_temp$datetime,                                        first_datetime, last_datetime)]), 1)  # \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u043b\u043e\u0433\u043e mt &lt;- ceiling(max(cpu_temp$cpu_temp)) mt_min &lt;- floor(min(cpu_temp$cpu_temp)) x_max &lt;- last_datetime + lubridate::minutes(25) x_min &lt;- last_datetime + lubridate::minutes(10)  cpu_temp %>%   filter(between(datetime, first_datetime, last_datetime)) %>%   ggplot(aes(datetime, cpu_temp)) +   annotation_custom(     img,     ymin = mt ,     ymax = mt + 8.25,     xmin = x_min,     xmax = x_max   ) +   geom_texthline(     yintercept = mean(cpu_temp$cpu_temp),     size = 3.75,     linetype = \"dashed\",     linewidth = 0.25,     label = glue(\"\u0421\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u0430 \u0432\u0441\u0451 \u0432\u0440\u0435\u043c\u044f: &lt;b>{round(mean(cpu_temp$cpu_temp),1)}&lt;\/b>\u00b0C\"),     hjust = 0.985,     vjust = -0.2,     color = \"gray70\",     rich = TRUE   ) +   geom_texthline(     yintercept = meanTempCPU_period,     size = 3.75,     linewidth = 0.25,     label = glue(\"\u0421\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u0430 3 \u0447\u0430\u0441\u0430: &lt;b>{meanTempCPU_period}&lt;\/b>\u00b0C\"),     hjust = 0.985,     vjust = -0.2,     color = \"gray70\",     rich = TRUE   ) +   geom_step(color = \"gray10\") +   scale_y_continuous(     breaks = seq(mt_min, mt + 1, 2),     limits = c(mt_min, mt + 1),     labels = c(as.character(seq(mt_min, mt - 1, 2)),                glue::glue(\"{mt + 1}\u00b0C\"))   ) +   scale_x_datetime(     \"\u0412\u0440\u0435\u043c\u044f\",     date_breaks = \"30 min\",     date_labels = \"%H:%M\",     expand = c(0.15, 0)   ) +   labs(     title = \"\u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 Raspberry Pi Zero W\",     subtitle = glue(       \"\u041f\u043e\u043c\u0438\u043d\u0443\u0442\u043d\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 3 \u0447\u0430\u0441\u0430\\n\",       \"{format(first_datetime, format = '%d %b %H:%M')} - {format(last_datetime, format = '%H:%M')}\",       \" | \u041c\u0438\u043d {minTempCPU}\u00b0C | \u0421\u0440\u0435\u0434\u043d\u0435\u0435 {meanTempCPU_period}\u00b0C | \u041c\u0430\u043a\u0441 {maxTempCPU}\u00b0C\"     ),     x = \"\u0412\u0440\u0435\u043c\u044f\",     y = \"\"   ) +   coord_cartesian(clip = \"off\") +   theme(text = element_text(family = \"Open Sans\"),         panel.background = element_blank(),         axis.title.x = element_text(size = 14),         plot.margin = margin(25, 30, 10, 12),         plot.title.position = \"plot\",         plot.subtitle = element_text(size = 12, color = \"gray60\"),         title = element_text(size = 16),         axis.text.y = element_text(size = 12),         axis.text.x = element_text(size = 12)   ) ggsave(   glue(\"img\/cpu_temp_{format(last_datetime, '%d_%m_%Y_%H_%M')}.png\"),   dpi = 300,   scale = 1.5 ) <\/code><\/pre>\n<p>\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/605\/ad5\/4fc\/605ad54fc4c72b0062ab0e1447681e8c.png\" width=\"1856\" height=\"1601\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/605\/ad5\/4fc\/605ad54fc4c72b0062ab0e1447681e8c.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043a\u0430\u0436\u0434\u044b\u0435 \u0442\u0440\u0438 \u0447\u0430\u0441\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 cron:<\/p>\n<p><code>0 *\/3 * * * Rscript \/home\/pi\/cpu_temp\/cpu_temp_pi.R<\/code><\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0435\u0431\u0435 \u0432 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u0430 (\u0441\u043c. \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 <a href=\"https:\/\/habr.com\/ru\/post\/511222\/\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0431\u043e\u0442\u043e\u0432 \u0432 R<\/a>) \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043b\u0438\u0447\u043d\u044b\u0445 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430:<\/p>\n<pre><code class=\"r\">bot$sendPhoto(chat_id,               photo = glue(\"~\/cpu_temp\/img\/cpu_temp_{format(last_datetime, '%d_%m_%Y_%H_%M')}.png\") )<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/26b\/aef\/e8c\/26baefe8ceaa8871fc641111d28359f3.jpg\" alt=\"\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u043c \u043e\u0442 \u0431\u043e\u0442\u0430\" title=\"\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u043c \u043e\u0442 \u0431\u043e\u0442\u0430\" width=\"720\" height=\"1228\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/26b\/aef\/e8c\/26baefe8ceaa8871fc641111d28359f3.jpg\" data-blurred=\"true\"\/><figcaption>\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u043c \u043e\u0442 \u0431\u043e\u0442\u0430<\/figcaption><\/figure>\n<p><strong>PS:<\/strong> \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 R \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u0438\u0437 <a href=\"https:\/\/r4pi.org\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0435\u043a\u0442\u0430 R4Pi<\/a>. <\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/689522\/\"> https:\/\/habr.com\/ru\/post\/689522\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0414\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 <a href=\"https:\/\/teletype.in\/@weekly_charts\/YodM2Y8SNmM\" rel=\"noopener noreferrer nofollow\">\u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0433\u043e\u0434\u044b \u0432 \u0440\u0435\u0433\u0438\u043e\u043d\u0430\u0445 \u0420\u0424<\/a> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 R, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044e (\u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e \u043a\u0430\u0436\u0434\u044b\u0435 \u0442\u0440\u0438 \u0447\u0430\u0441\u0430) \u043d\u0430 \u043c\u043e\u0451\u043c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u043c \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435 \u2014 Raspberry PI Zero W.<\/p>\n<figure class=\"full-width\"><figcaption>\u041c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0434\u043e\u043c\u0430\u0448\u043d\u0438\u0439 \u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 24\/7<\/figcaption><\/figure>\n<p><strong>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435: <\/strong><a href=\"https:\/\/disk.yandex.ru\/d\/b6Qu6RSAUGXqLg\" rel=\"noopener noreferrer nofollow\">cpu_temp.log<\/a><\/p>\n<p>\u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043c\u0438\u043d\u0443\u0442\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 Raspberry PI, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u043b\u043e\u0433-\u0444\u0430\u0439\u043b\u0435 c \u043f\u043e\u043c\u043e\u0449\u044c\u044e bash-\u0441\u043a\u0440\u0438\u043f\u0442\u0430:<\/p>\n<pre><code class=\"bash\">#!\/bin\/bash date +\"%d.%m.%Y %T\" | tr '\\n' '\\t' >> \/home\/pi\/cpu_temp.log ; vcgencmd measure_temp| tr -d \"temp=\" | tr -d \"'C\" >> \/home\/pi\/cpu_temp.log<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 bash-\u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043f\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0447\u0435\u0440\u0435\u0437 cron \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c (\u043a\u0430\u0436\u0434\u0443\u044e \u043c\u0438\u043d\u0443\u0442\u0443):<\/p>\n<p><code>*\/1 * * * * ~\/cpu_temp.sh<\/code><\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043b\u043e\u0433:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u042d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e R (<a href=\"https:\/\/disk.yandex.ru\/d\/NgkCtteoZ-fPag\" rel=\"noopener noreferrer nofollow\">cpu_temp.R<\/a>), \u0430 \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a \u0432\u0441\u0442\u0430\u0432\u0438\u043c \u043b\u043e\u0433\u043e Raspberry PI:  <a href=\"https:\/\/disk.yandex.ru\/d\/dP16Vwq9sH6RNQ\" rel=\"noopener noreferrer nofollow\">https:\/\/disk.yandex.ru\/d\/dP16Vwq9sH6RNQ<\/a>  <\/p>\n<pre><code class=\"r\">library(tidyverse) library(readr) library(geomtextpath) library(glue) library(here)  # \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u043b\u043e\u0433\u043e\u0442\u0438\u043f Raspberry Pi png &lt;- magick::image_read(\"raspberrypi-logo.png\") img &lt;- grid::rasterGrob(png, interpolate = TRUE)  # \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 (\u043b\u043e\u0433 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b) cpu_temp &lt;- read_delim(     \"cpu_temp.log\",     delim = \"\\t\",     col_names = c(\"datetime\", \"cpu_temp\"),     trim_ws = TRUE) %>%   mutate(datetime = lubridate::as_datetime(datetime,                                            \"%d.%m.%Y %H:%M:%S\",                                            tz = \"Asia\/Yekaterinburg\"))  # \u0412\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0434\u043b\u044f \u0433\u0440\u0430\u0444\u0438\u043a\u0430 -- \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 3 \u0447\u0430\u0441\u0430 \u0438\u0437 \u043b\u043e\u0433\u0430 last_datetime &lt;- cpu_temp$datetime[length(cpu_temp$datetime)] first_datetime &lt;- last_datetime - lubridate::hours(3)  # \u041e\u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u043b\u044f \u0433\u0440\u0430\u0444\u0438\u043a\u0430 (\u043c\u0438\u043d, \u043c\u0430\u043a\u0441, \u0441\u0440\u0435\u0434\u043d\u0435\u0435) maxTempCPU &lt;- max(cpu_temp$cpu_temp[between(cpu_temp$datetime,                                             first_datetime, last_datetime)]) minTempCPU &lt;- min(cpu_temp$cpu_temp[between(cpu_temp$datetime,                                             first_datetime, last_datetime)]) meanTempCPU_period &lt;-   round(mean(cpu_temp$cpu_temp[between(cpu_temp$datetime,                                        first_datetime, last_datetime)]), 1)  # \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u043b\u043e\u0433\u043e mt &lt;- ceiling(max(cpu_temp$cpu_temp)) mt_min &lt;- floor(min(cpu_temp$cpu_temp)) x_max &lt;- last_datetime + lubridate::minutes(25) x_min &lt;- last_datetime + lubridate::minutes(10)  cpu_temp %>%   filter(between(datetime, first_datetime, last_datetime)) %>%   ggplot(aes(datetime, cpu_temp)) +   annotation_custom(     img,     ymin = mt ,     ymax = mt + 8.25,     xmin = x_min,     xmax = x_max   ) +   geom_texthline(     yintercept = mean(cpu_temp$cpu_temp),     size = 3.75,     linetype = \"dashed\",     linewidth = 0.25,     label = glue(\"\u0421\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u0430 \u0432\u0441\u0451 \u0432\u0440\u0435\u043c\u044f: &lt;b>{round(mean(cpu_temp$cpu_temp),1)}&lt;\/b>\u00b0C\"),     hjust = 0.985,     vjust = -0.2,     color = \"gray70\",     rich = TRUE   ) +   geom_texthline(     yintercept = meanTempCPU_period,     size = 3.75,     linewidth = 0.25,     label = glue(\"\u0421\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u0430 3 \u0447\u0430\u0441\u0430: &lt;b>{meanTempCPU_period}&lt;\/b>\u00b0C\"),     hjust = 0.985,     vjust = -0.2,     color = \"gray70\",     rich = TRUE   ) +   geom_step(color = \"gray10\") +   scale_y_continuous(     breaks = seq(mt_min, mt + 1, 2),     limits = c(mt_min, mt + 1),     labels = c(as.character(seq(mt_min, mt - 1, 2)),                glue::glue(\"{mt + 1}\u00b0C\"))   ) +   scale_x_datetime(     \"\u0412\u0440\u0435\u043c\u044f\",     date_breaks = \"30 min\",     date_labels = \"%H:%M\",     expand = c(0.15, 0)   ) +   labs(     title = \"\u0422\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 Raspberry Pi Zero W\",     subtitle = glue(       \"\u041f\u043e\u043c\u0438\u043d\u0443\u0442\u043d\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0442\u0435\u043c\u043f\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 3 \u0447\u0430\u0441\u0430\\n\",       \"{format(first_datetime, format = '%d %b %H:%M')} - {format(last_datetime, format = '%H:%M')}\",       \" | \u041c\u0438\u043d {minTempCPU}\u00b0C | \u0421\u0440\u0435\u0434\u043d\u0435\u0435 {meanTempCPU_period}\u00b0C | \u041c\u0430\u043a\u0441 {maxTempCPU}\u00b0C\"     ),     x = \"\u0412\u0440\u0435\u043c\u044f\",     y = \"\"   ) +   coord_cartesian(clip = \"off\") +   theme(text = element_text(family = \"Open Sans\"),         panel.background = element_blank(),         axis.title.x = element_text(size = 14),         plot.margin = margin(25, 30, 10, 12),         plot.title.position = \"plot\",         plot.subtitle = element_text(size = 12, color = \"gray60\"),         title = element_text(size = 16),         axis.text.y = element_text(size = 12),         axis.text.x = element_text(size = 12)   ) ggsave(   glue(\"img\/cpu_temp_{format(last_datetime, '%d_%m_%Y_%H_%M')}.png\"),   dpi = 300,   scale = 1.5 ) <\/code><\/pre>\n<p>\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043a\u0430\u0436\u0434\u044b\u0435 \u0442\u0440\u0438 \u0447\u0430\u0441\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 cron:<\/p>\n<p><code>0 *\/3 * * * Rscript \/home\/pi\/cpu_temp\/cpu_temp_pi.R<\/code><\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0435\u0431\u0435 \u0432 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442\u0430 (\u0441\u043c. \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 <a href=\"https:\/\/habr.com\/ru\/post\/511222\/\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0431\u043e\u0442\u043e\u0432 \u0432 R<\/a>) \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043b\u0438\u0447\u043d\u044b\u0445 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430:<\/p>\n<pre><code class=\"r\">bot$sendPhoto(chat_id,               photo = glue(\"~\/cpu_temp\/img\/cpu_temp_{format(last_datetime, '%d_%m_%Y_%H_%M')}.png\") )<\/code><\/pre>\n<figure class=\"full-width\"><figcaption>\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u043c \u043e\u0442 \u0431\u043e\u0442\u0430<\/figcaption><\/figure>\n<p><strong>PS:<\/strong> \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 R \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u0438\u0437 <a href=\"https:\/\/r4pi.org\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0435\u043a\u0442\u0430 R4Pi<\/a>. <\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/689522\/\"> https:\/\/habr.com\/ru\/post\/689522\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-338595","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/338595","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=338595"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/338595\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=338595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=338595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=338595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}