{"id":1356,"date":"2022-04-11T00:00:38","date_gmt":"2022-04-11T00:00:38","guid":{"rendered":"http:\/\/lora.vsb.cz\/?page_id=1356"},"modified":"2023-10-07T07:13:46","modified_gmt":"2023-10-07T07:13:46","slug":"temperature-sensor-ds18b20","status":"publish","type":"page","link":"https:\/\/lora.vsb.cz\/index.php\/temperature-sensor-ds18b20\/","title":{"rendered":"Temperature sensor DS18B20"},"content":{"rendered":"<table style=\"height: 66px;\" width=\"356\">\n<tbody>\n<tr>\n<td style=\"text-align: left; min-width: 100px;\" width=\"10%\"><strong>TTN version:<\/strong><\/td>\n<td><strong><span style=\"color: #008000;\">TTNv3<\/span><\/strong><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left; min-width: 100px;\" width=\"10%\"><strong>Activation:<\/strong><\/td>\n<td>ABP<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left; min-width: 100px;\" width=\"10%\"><strong>Device Class:<\/strong><\/td>\n<td>Class A<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left; min-width: 100px;\" width=\"10%\"><strong>Last updated:<\/strong><\/td>\n<td>October 7, 2023<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>This article provides instructions for making a temperature sensor using <strong>Adafruit Feather 32u4 RFM95 LoRa Radio<\/strong> and <strong>DS18B20<\/strong>. If you haven&#8217;t set up Adafruit Feather 32u4 yet, check out our<strong> <a href=\"http:\/\/lora.vsb.cz\/index.php\/adafruit-feather-32u4\/\" target=\"_blank\" rel=\"noopener\">Adafruit Feather 32u4 tutorial<\/a><\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1380 \" src=\"http:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DS18B20_assembly.jpg\" alt=\"Adafruit Feather 32u4 and DS18B20\" width=\"699\" height=\"416\" srcset=\"https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DS18B20_assembly.jpg 840w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DS18B20_assembly-300x179.jpg 300w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DS18B20_assembly-768x457.jpg 768w\" sizes=\"auto, (max-width: 699px) 100vw, 699px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2><span style=\"color: #189bd6;\"><strong>Prepare<\/strong><\/span><\/h2>\n<ul>\n<li>Adafruit Feather 32u4 RFM95 LoRa Radio<\/li>\n<li>DS18B20<\/li>\n<li>4x wire<\/li>\n<li>4.7k resistor<\/li>\n<li>breadboard (optional)<\/li>\n<li>PC + micro USB cable<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2><strong><span style=\"color: #800000;\">DS18B20<\/span><\/strong><\/h2>\n<p>To measure temperature, we will use the DS18B20 temperature sensor. The sensor measures temperatures in the range of -55 \u00baC to 125 \u00baC. In the range of -10 \u00baC to 85 \u00baC, the measurement accuracy is \u00b1 0.5 \u00baC.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1367 aligncenter\" src=\"http:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DS18B20_sensor.jpg\" alt=\"DS18B20 - sensor\" width=\"269\" height=\"269\" srcset=\"https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DS18B20_sensor.jpg 500w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DS18B20_sensor-300x300.jpg 300w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DS18B20_sensor-150x150.jpg 150w\" sizes=\"auto, (max-width: 269px) 100vw, 269px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2><strong><span style=\"color: #800000;\">Sensor assembly<\/span><\/strong><\/h2>\n<p>Connect everything according to the schematics bellow.<\/p>\n<p>W<span style=\"color: #000000;\">ire up the Adafruit Feather 32u4&#8217;s IO1 pin with pin 6. The sensor is connected using three wires.\u00a0<\/span>The red wire (Vcc) is connected to the supply voltage (3V pin on Adafruit Feather 32u4) and the black wire (GND) is connected to ground (GND pin on Feather). The yellow wire (DQ) is used for data transmission via the 1-Wire bus and is connected to Feather&#8217;s digital pin 12. Between red and yellow DS18B20 wires is connected 4,7k resistor. The sensor requires a stabilized supply voltage in the range of 3 V to 5.5 V for its function.<\/p>\n<h5><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1373 \" src=\"http:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DS18B20_AF32u4.png\" alt=\"Adafruit Feather 32u4 and DS18B20\" width=\"830\" height=\"389\" srcset=\"https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DS18B20_AF32u4.png 1067w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DS18B20_AF32u4-300x141.png 300w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DS18B20_AF32u4-1024x480.png 1024w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DS18B20_AF32u4-768x360.png 768w\" sizes=\"auto, (max-width: 830px) 100vw, 830px\" \/><\/h5>\n<p>&nbsp;<\/p>\n<h2><strong><span style=\"color: #800000;\">Arduino IDE setup<\/span><\/strong><\/h2>\n<ol>\n<li>Run Arduino IDE.<\/li>\n<li>In the Arduino IDE <strong>Library Manager<\/strong>\u00a0search <strong>DallasTemperature<\/strong> by Miles Burton and\u00a0 <strong>install it with all dependencies<\/strong> (library\u00a0<strong>OneWire<\/strong>).<\/li>\n<li>In the Arduino IDE <strong>Library Manager <\/strong>search <strong>CayenneLPP<\/strong> by Electronic Cats and install it.<\/li>\n<li>Download as ZIP this <a href=\"https:\/\/github.com\/rocketscream\/Low-Power\" target=\"_blank\" rel=\"noopener\"><strong>Low-Power library<\/strong><\/a> by Rocketscream.<\/li>\n<li>In the Arduino IDE <strong>Sketch -&gt; Include Library -&gt; Add .ZIP Library&#8230; <\/strong>choose downloaded ZIP.<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h2><span style=\"color: #800000;\"><strong>Printing measured values to Serial Monitor<\/strong><\/span><\/h2>\n<ol>\n<li><strong><a href=\"https:\/\/github.com\/OndrejKnebl\/TTNv3-LoRaVSB\/blob\/main\/DS18B20\/Serial_DS18B20_current_measured_values\/Serial_DS18B20_current_measured_values.ino\" target=\"_blank\" rel=\"noopener\">Copy and paste this program<\/a><\/strong> to your Arduino IDE.<\/li>\n<li>Connect Adafruit Feather 32u4 using micro USB cable to your computer.<\/li>\n<li>In Arduino IDE click on <strong>Upload<\/strong> button to upload program to your Adafruit Feather 32u4.<\/li>\n<li><span style=\"color: #000000;\">In Arduino IDE click on <strong>Serial Monitor <\/strong>button and you should <strong>every 10 seconds<\/strong>\u00a0see this:<\/span><\/li>\n<\/ol>\n<h5><span style=\"color: #ff6600;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3676 \" src=\"http:\/\/lora.vsb.cz\/wp-content\/uploads\/2023\/01\/DS18B20-SerialMonitor.png\" alt=\"DS18B20 Serial Monitor\" width=\"600\" height=\"259\" srcset=\"https:\/\/lora.vsb.cz\/wp-content\/uploads\/2023\/01\/DS18B20-SerialMonitor.png 897w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2023\/01\/DS18B20-SerialMonitor-300x129.png 300w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2023\/01\/DS18B20-SerialMonitor-768x331.png 768w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/span><\/h5>\n<p>&nbsp;<\/p>\n<h2><span style=\"color: #800000;\"><strong>Sending <\/strong><\/span><strong><span style=\"color: #800000;\">measured values <\/span><\/strong><span style=\"color: #800000;\"><strong>to TTS<\/strong><\/span><\/h2>\n<p>We have prepared four programs for measuring temperature. The first program sends the current measured values. The second program sends averages of measured values over a certain period of time. The other two programs extend the first two with a low power mode, which is great when you run this sensor on battery power.<\/p>\n<h4><strong>Programs<\/strong><\/h4>\n<ul>\n<li><a href=\"https:\/\/github.com\/OndrejKnebl\/TTNv3-LoRaVSB\/blob\/main\/DS18B20\/DS18B20_current_measured_values\/DS18B20_current_measured_values.ino\" target=\"_blank\" rel=\"noopener\">Current measured values<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/OndrejKnebl\/TTNv3-LoRaVSB\/blob\/main\/DS18B20\/DS18B20_average_measured_values\/DS18B20_average_measured_values.ino\" target=\"_blank\" rel=\"noopener\">Averages of measured values<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/OndrejKnebl\/TTNv3-LoRaVSB\/blob\/main\/DS18B20\/DS18B20_current_measured_values_low_power_mode\/DS18B20_current_measured_values_low_power_mode.ino\" target=\"_blank\" rel=\"noopener\">Current measured values with low power mode<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/OndrejKnebl\/TTNv3-LoRaVSB\/blob\/main\/DS18B20\/DS18B20_average_measured_values_low_power_mode\/DS18B20_average_measured_values_low_power_mode.ino\" target=\"_blank\" rel=\"noopener\">Averages of measured values with low power mode<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h4><strong><span style=\"color: #000000;\">Instructions<\/span><\/strong><\/h4>\n<ol>\n<li>Copy and paste one of this programs to your Arduino IDE.<\/li>\n<li>In program replace\u00a0<strong>NWKSKEY<\/strong>,\u00a0<strong>APPSKEY<\/strong>\u00a0and\u00a0<strong>DEVADDR<\/strong>\u00a0with keys of your end device registred in TTS. Keys are in\u00a0<strong>TTS -&gt; Applications -&gt; YourAppName -&gt; YourEndDeviceName -&gt; Overview -&gt; Session information<\/strong>.<\/li>\n<li>In\u00a0<strong>TTS -&gt; Applications -&gt; YourAppName -&gt; YourEndDeviceName -&gt; Payload formatters -&gt; Uplink<\/strong>\u00a0change\u00a0<strong>Formatter type<\/strong>\u00a0to\u00a0<strong>CayenneLPP<\/strong>. For more information, check out our\u00a0<a href=\"http:\/\/lora.vsb.cz\/index.php\/cayenne-lpp\/\" target=\"_blank\" rel=\"noopener\"><strong>Cayenne LPP tutorial<\/strong><\/a>.<\/li>\n<li>Click on\u00a0<strong>Save changes<\/strong>.<\/li>\n<li>Connect Adafruit Feather 32u4 using micro USB cable to your computer.<\/li>\n<li>In Arduino IDE click on\u00a0<strong>Upload<\/strong>\u00a0button to upload program to your Adafruit Feather 32u4.<\/li>\n<li><span style=\"color: #000000;\">In\u00a0<strong>TTS -&gt; Applications -&gt; YourAppName -&gt; YourEndDeviceName -&gt; Live data<\/strong> you should <strong>every 5 minutes (Low Power Mode &#8211; 10 minutes)<\/strong> see this:<\/span><\/li>\n<\/ol>\n<h5><span style=\"color: #ff6600;\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1385 aligncenter\" src=\"http:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DS18B20_console.png\" alt=\"DS18B20 - TTS console\" width=\"901\" height=\"467\" srcset=\"https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DS18B20_console.png 1556w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DS18B20_console-300x156.png 300w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DS18B20_console-1024x531.png 1024w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DS18B20_console-768x398.png 768w, https:\/\/lora.vsb.cz\/wp-content\/uploads\/2022\/04\/DS18B20_console-1536x797.png 1536w\" sizes=\"auto, (max-width: 901px) 100vw, 901px\" \/><br \/>\n<\/span><\/h5>\n<h2><span style=\"color: #800000;\"><strong>Data visualization<\/strong><\/span><\/h2>\n<p>If you want to visualize your measured data, continue with the following tutorial:<\/p>\n<ul>\n<li><strong><a href=\"https:\/\/lora.vsb.cz\/index.php\/telegraf-influxdb-grafana\/\" target=\"_blank\" rel=\"noopener\">Telegraf &amp; InfluxDB &amp; Grafana<\/a><\/strong><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>TTN version: TTNv3 Activation: ABP Device Class: Class A Last updated: October 7, 2023 This article provides instructions for making a temperature sensor using Adafruit Feather 32u4 RFM95 LoRa Radio and DS18B20. If you haven&#8217;t set up Adafruit Feather 32u4 yet, check out our Adafruit Feather 32u4 tutorial. &nbsp; Prepare Adafruit Feather 32u4 RFM95 LoRa [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1356","page","type-page","status-publish","hentry","post"],"_links":{"self":[{"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/pages\/1356","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/comments?post=1356"}],"version-history":[{"count":31,"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/pages\/1356\/revisions"}],"predecessor-version":[{"id":6151,"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/pages\/1356\/revisions\/6151"}],"wp:attachment":[{"href":"https:\/\/lora.vsb.cz\/index.php\/wp-json\/wp\/v2\/media?parent=1356"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}