{"id":4235,"date":"2016-08-15T18:42:14","date_gmt":"2016-08-15T18:42:14","guid":{"rendered":"http:\/\/hetpro-store.com\/TUTORIALES\/?p=4235"},"modified":"2016-10-22T17:26:46","modified_gmt":"2016-10-22T17:26:46","slug":"graficacion-sensores-lcd-nextion","status":"publish","type":"post","link":"https:\/\/hetpro-store.com\/TUTORIALES\/graficacion-sensores-lcd-nextion\/","title":{"rendered":"LCD Nextion y Graficas"},"content":{"rendered":"<h2><strong>LCD Nextion y graficas<\/strong><\/h2>\n<p style=\"text-align: justify;\">En el siguiente tutorial vamos a graficar en una LCD Nextion las temperaturas de tres sensores distintos y que trabajan con diferentes protocolos de comunicaci\u00f3n (One-Wire, I2C, Anal\u00f2gico), las gr\u00e1ficas y los valores num\u00e8ricos los mostraremos en la Pantalla Nextion de 2.4&#8243;.<\/p>\n<p style=\"text-align: justify;\">Es importante mencionar que Las librer\u00edas para la pantalla Nextion est\u00e1n configuradas para trabajar con el Arduino Mega 2560 con los pines Serial 2 (Rx2, Tx2). Si desea utilizar otra Tarjeta Arduino es necesario modificar el archivo <strong>NexConfig.h<\/strong>, ver archivo <strong>readme.md<\/strong> en la carpeta de la libreria Nextion de Itead.<\/p>\n<p style=\"text-align: justify;\">Las librer\u00edas para la Pantalla Nextion podr\u00e1n descargarlas en el enlace de abajo.<\/p>\n<h3><strong>Materiales\u00a0<\/strong><\/h3>\n<ul>\n<li>Arduino Mega 2560<\/li>\n<li>DS18B20 (Sensor de Temperatura One-Wire)<\/li>\n<li>MCP9808 (Sensor de Temperatura I2C)<\/li>\n<li>MCP9700 (Sensor de Temperatura Anal\u00f2gico)<\/li>\n<li>Pantalla Nextion 2.4&#8243;<\/li>\n<li>Protoboard<\/li>\n<\/ul>\n<h3><strong>C\u00f3digo de Arduino<\/strong><\/h3>\n<p>En el c\u00f2digo de Arduino esta comentado donde conectar cada sensor de Temperatura y la Pantalla Nextion.<\/p>\n<p>[code language=\u00bbcpp\u00bb]<\/p>\n<p>\/*HeTPro Herramientas Tecnol\u00f2gicas Profecionles*\/<br \/>\n\/*Tutorial para graficar Temperaturas de 3 sensores distintos*\/<br \/>\n\/*Protocolos de comunicacion I2C, One-Wire y Anal\u00f2gico*\/\u00e7<br \/>\n\/*<br \/>\n                       Conexiones<br \/>\n    Nextion: Conectar a SERIAL 2 TX2 RX2(Librerias por default funciona en SERIAL 2)<br \/>\n    DS18B20: Conectar pin de Salida a pin Digital 3 de Arduino Mega(Sensor Digital One-Wire)<br \/>\n    MCP9808: Conectar a Pines I2C (20, 21) (Sensor Digital I2C)<br \/>\n    MCP9700:: Conectar a PIN Anal\u00f2gico A0 (Sensor Anal\u00f2gico)<br \/>\n*\/<br \/>\n\/*Sensor de Temperatura MCP9808 con Comunicacion I2C *\/<br \/>\n#include &lt;Wire.h&gt;;<br \/>\n#include &quot;Adafruit_MCP9808.h&quot;<br \/>\n\/*Crea El Sensor MCP9808 un objeto*\/<br \/>\nAdafruit_MCP9808 tempsensor = Adafruit_MCP9808();<br \/>\n\/*********************************************************\/<br \/>\n\/*Sensor de Temperatura DS18B20 ONE-WIRE*\/<br \/>\n#include &amp;lt;OneWire.h&amp;gt;<br \/>\n#include &amp;lt;DallasTemperature.h&amp;gt;<br \/>\n#define ONE_WIRE_BUS 3 \/\/Pin 3 a Salida DS18B20<br \/>\nOneWire ourWire(ONE_WIRE_BUS);<br \/>\nDallasTemperature sensors(&amp;ourWire);<br \/>\n\/**********************************************************\/<br \/>\n\/*Nextion*\/<br \/>\n#include &quot;Nextion.h&quot; \/*Libreria para Pantalla Nexion*\/<br \/>\n\/*Funcion para Graficar las Temperaturas en la Nextion*\/<br \/>\nNexWaveform s0 = NexWaveform(0, 1, &quot;s0&quot;);<br \/>\n\/*Funciones para mostrar las temperaturas numericamente*\/<br \/>\nNexNumber n0 = NexNumber(0, 1, &quot;n0&quot;);<br \/>\nNexNumber n1 = NexNumber(0, 1, &quot;n1&quot;);<br \/>\nNexNumber n2 = NexNumber(0, 1, &quot;n2&quot;);<br \/>\nint i;<br \/>\n\/*********************************************************\/<br \/>\n\/* Sensor de Temperatura Anal\u00f2gico MCP9700*\/<br \/>\nint mcp1 = A0;<br \/>\nfloat mcpT1 = 0;<\/p>\n<p>void setup()<br \/>\n{<br \/>\n Serial.begin(9600);<br \/>\n \/*Inicializacion de LCD nextion 2.4&quot;*\/<br \/>\n nexInit();<br \/>\n \/*Inicializacion de Sensor DS18B20*\/<br \/>\n sensors.begin();<br \/>\n \/*Inicializacion MCP9808*\/<br \/>\n \/* Direccion tempsensor.begin(0x19)*\/<br \/>\n  if (!tempsensor.begin(0x19)) {<br \/>\n    Serial.println(&quot;No se enconto MCP9808!&quot;);<br \/>\n    while (1);<br \/>\n  }\/\/end if(MCP9808)<br \/>\n}\/\/end void setup()<\/p>\n<p>void loop()<br \/>\n{<br \/>\n  \/*Lectura del sensor I2C MCP9808*\/<br \/>\ntempsensor.shutdown_wake(0);\/\/prepata el sensor para leer temperatura en MCP9808<br \/>\nfloat c = tempsensor.readTempC();\/\/lee la temperatura en MCP9808<br \/>\ndelay(5);<br \/>\n  \/*Lectura del sensor DS18B20 ONE-WIRE*\/<br \/>\nsensors.requestTemperatures(); \/\/lee temperatura en ds18b20<br \/>\ndelay(5);<br \/>\ni= sensors.getTempCByIndex(0);\/\/ lee la temperatura y asigna el valor en i<br \/>\n\/*Lectura del sensor Anal\u00f2gico MCP9700*\/<br \/>\n  mcpT1 = analogRead(mcp1)*5 \/ 1024.0;<br \/>\n  mcpT1 = mcpT1 &#8211; 0.5;<br \/>\n  mcpT1 = mcpT1 \/ 0.01;<br \/>\n  delay(5); <\/p>\n<p>\/*Funciones para enviar las lecturas de los sensores a la Nextion *\/<br \/>\n\/*DS18B20*\/<br \/>\n s0.addValue(0, i);\/*Graficar Temperatura de DS18B20*\/<br \/>\n n2.setValue(i);\/*Mostrar el Valor de DS18B20*\/<br \/>\n \/*MCP9700*\/<br \/>\n s0.addValue(1, mcpT1);<br \/>\n n1.setValue(mcpT1);<br \/>\n \/*MCP9808*\/<br \/>\n s0.addValue(2, c);<br \/>\n n0.setValue(c);<\/p>\n<p>tempsensor.shutdown_wake(1); \/\/ shutdown MSP9808 &#8211; power consumption ~0.1 mikro Ampere<\/p>\n<p>}\/\/ end loop<br \/>\n[\/code]<\/p>\n<p><strong>Imagenes y video del Tutorial<br \/>\n<\/strong>En el siguiente link se encuentra el video del Funcionamiento completo del Tutorial: <a href=\"https:\/\/www.youtube.com\/watch?v=LGWgJ3lgcFw&amp;spfreload=5\">https:\/\/www.youtube.com\/watch?v=LGWgJ3lgcFw&amp;spfreload=5<\/a><\/p>\n<figure id=\"attachment_4239\" aria-describedby=\"caption-attachment-4239\" style=\"width: 3600px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/hetpro-store.com\/TUTORIALES\/graficacion-sensores-temperatura-lcd-nextion\/next4\/\" rel=\"attachment wp-att-4239\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-4239 size-full\" src=\"http:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next4-e1471283886368.jpg\" alt=\"LCD Nextion\" width=\"3600\" height=\"2160\" srcset=\"https:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next4-e1471283886368.jpg 3600w, https:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next4-e1471283886368-300x180.jpg 300w, https:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next4-e1471283886368-768x461.jpg 768w, https:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next4-e1471283886368-1024x614.jpg 1024w\" sizes=\"auto, (max-width: 3600px) 100vw, 3600px\" \/><\/a><figcaption id=\"caption-attachment-4239\" class=\"wp-caption-text\">Sensores de Temperatura y Nextion de 2.4&#8243;<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_4238\" aria-describedby=\"caption-attachment-4238\" style=\"width: 3600px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/hetpro-store.com\/TUTORIALES\/graficacion-sensores-temperatura-lcd-nextion\/next3\/\" rel=\"attachment wp-att-4238\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-4238 size-full\" src=\"http:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next3-e1471283660313.jpg\" alt=\"LCD Nextion\" width=\"3600\" height=\"2160\" srcset=\"https:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next3-e1471283660313.jpg 3600w, https:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next3-e1471283660313-300x180.jpg 300w, https:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next3-e1471283660313-768x461.jpg 768w, https:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next3-e1471283660313-1024x614.jpg 1024w\" sizes=\"auto, (max-width: 3600px) 100vw, 3600px\" \/><\/a><figcaption id=\"caption-attachment-4238\" class=\"wp-caption-text\">Gr\u00e1ficas de los sensores de temperatura.<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<figure id=\"attachment_4237\" aria-describedby=\"caption-attachment-4237\" style=\"width: 3600px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/hetpro-store.com\/TUTORIALES\/graficacion-sensores-temperatura-lcd-nextion\/next2\/\" rel=\"attachment wp-att-4237\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-4237 size-full\" src=\"http:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next2-e1471283609953.jpg\" alt=\"LCD Nextion\" width=\"3600\" height=\"2160\" srcset=\"https:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next2-e1471283609953.jpg 3600w, https:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next2-e1471283609953-300x180.jpg 300w, https:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next2-e1471283609953-768x461.jpg 768w, https:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next2-e1471283609953-1024x614.jpg 1024w\" sizes=\"auto, (max-width: 3600px) 100vw, 3600px\" \/><\/a><figcaption id=\"caption-attachment-4237\" class=\"wp-caption-text\">En la imagen podemos apreciar las gr\u00e1ficas y los valores de las temperaturas.<\/figcaption><\/figure>\n<figure id=\"attachment_4236\" aria-describedby=\"caption-attachment-4236\" style=\"width: 3600px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/hetpro-store.com\/TUTORIALES\/graficacion-sensores-temperatura-lcd-nextion\/next1\/\" rel=\"attachment wp-att-4236\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-4236 size-full\" src=\"http:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next1.jpg\" alt=\"LCD Nextion\" width=\"3600\" height=\"2160\" srcset=\"https:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next1.jpg 3600w, https:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next1-300x180.jpg 300w, https:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next1-768x461.jpg 768w, https:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next1-1024x614.jpg 1024w\" sizes=\"auto, (max-width: 3600px) 100vw, 3600px\" \/><\/a><figcaption id=\"caption-attachment-4236\" class=\"wp-caption-text\">Valores para los tres sensores de temperatura<\/figcaption><\/figure>\n<h3><strong>Enlaces de Inter\u00e9s<\/strong><\/h3>\n<p><a href=\"http:\/\/www.microchip.com\/wwwproducts\/en\/MCP9808\" target=\"_blank\">&#8211; Hoja de Datos MCP9808<br \/>\n<\/a><a href=\"http:\/\/ww1.microchip.com\/downloads\/en\/DeviceDoc\/21942e.pdf\" target=\"_blank\">&#8211; Hoja de Datos MCP9700<br \/>\n<\/a><a href=\"https:\/\/hetpro-store.com\/TUTORIALES\/pantalla-nextion-arduino\/\" target=\"_blank\">&#8211; Tutorial Editor de Nextion y Arduino UNO<br \/>\n<\/a><a href=\"https:\/\/hetpro-store.com\/TUTORIALES\/sensor-de-temperatura-ds18b20\/\" target=\"_blank\">&#8211; Tutorial DS18B20<br \/>\n<\/a><a href=\"https:\/\/github.com\/itead\/ITEADLIB_Arduino_Nextion\" target=\"_blank\">&#8211; Nextion Editor<br \/>\n-Librterias Nextion<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>LCD Nextion y graficas En el siguiente tutorial vamos a graficar en una LCD Nextion las temperaturas de tres sensores distintos y que trabajan con diferentes protocolos de comunicaci\u00f3n (One-Wire, I2C, Anal\u00f2gico), las gr\u00e1ficas y los valores num\u00e8ricos los mostraremos en la Pantalla Nextion de 2.4&#8243;. Es importante mencionar que Las librer\u00edas para la pantalla [&hellip;]<\/p>\n","protected":false},"author":16,"featured_media":4239,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_members_access_role":[],"_members_access_error":""},"categories":[14,20,22,23],"tags":[56,118,128,113,114],"class_list":["post-4235","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-pantallas-lcd-tft","category-sensores-analogicos","category-sensores-digitales","tag-arduino","tag-lcd","tag-nextion","tag-sensor","tag-temperatura"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v15.1.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>LCD Nextion y Graficas de sensores de temperatura<\/title>\n<meta name=\"description\" content=\"LCD Nextion y Graficaci\u00f3n de tres sensores de temperatura que trabajan con los protocolos de comunicaci\u00f3n I2C, One-Wire y Anal\u00f2gico.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/hetpro-store.com\/TUTORIALES\/graficacion-sensores-lcd-nextion\/\" \/>\n<meta property=\"og:locale\" content=\"es_ES\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"LCD Nextion y Graficas de sensores de temperatura\" \/>\n<meta property=\"og:description\" content=\"LCD Nextion y Graficaci\u00f3n de tres sensores de temperatura que trabajan con los protocolos de comunicaci\u00f3n I2C, One-Wire y Anal\u00f2gico.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/hetpro-store.com\/TUTORIALES\/graficacion-sensores-lcd-nextion\/\" \/>\n<meta property=\"og:site_name\" content=\"HeTPro-Tutoriales\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/HeTPro-142107212482616\/\" \/>\n<meta property=\"article:published_time\" content=\"2016-08-15T18:42:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-10-22T17:26:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/hetpro-store.com\/TUTORIALES\/wp-content\/uploads\/2016\/08\/next4-e1471283886368.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"3600\" \/>\n\t<meta property=\"og:image:height\" content=\"2160\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hetpro1\" \/>\n<meta name=\"twitter:site\" content=\"@hetpro1\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/hetpro-store.com\/TUTORIALES\/wp-json\/wp\/v2\/posts\/4235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hetpro-store.com\/TUTORIALES\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hetpro-store.com\/TUTORIALES\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hetpro-store.com\/TUTORIALES\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/hetpro-store.com\/TUTORIALES\/wp-json\/wp\/v2\/comments?post=4235"}],"version-history":[{"count":0,"href":"https:\/\/hetpro-store.com\/TUTORIALES\/wp-json\/wp\/v2\/posts\/4235\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hetpro-store.com\/TUTORIALES\/wp-json\/wp\/v2\/media\/4239"}],"wp:attachment":[{"href":"https:\/\/hetpro-store.com\/TUTORIALES\/wp-json\/wp\/v2\/media?parent=4235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hetpro-store.com\/TUTORIALES\/wp-json\/wp\/v2\/categories?post=4235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hetpro-store.com\/TUTORIALES\/wp-json\/wp\/v2\/tags?post=4235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}