{"id":1200,"date":"2012-05-04T00:57:51","date_gmt":"2012-05-03T23:57:51","guid":{"rendered":"http:\/\/www.zigbe.net\/?p=1200"},"modified":"2016-02-26T02:07:12","modified_gmt":"2016-02-26T01:07:12","slug":"bmotespir-a-vueltas-con-el-sensor-de-flancos","status":"publish","type":"post","link":"https:\/\/blog.whatsbee.net\/?p=1200","title":{"rendered":"bMotesPIR, a vueltas con el sensor de flancos"},"content":{"rendered":"<p><!--:en--><\/p>\n<p style=\"text-align: justify;\">Let\u2019s change the topic away from gateways for a few days. Today I have deceided to finish a wireless infrared presence sensor I started a few days ago.<\/p>\n<p>The sensor is a PIR of a DFRobot which costs around about 7 of your hard earned dollars. The reason for choosing this particular sensor is because it with a voltage between 3 and 5V, and has a consumption of 50\u00b5A. This consumption is very important as it will take more than 4 years to drain AAA batteries, assuming of course we\u2019re not using the Zigbee network!<\/p>\n<div id=\"attachment_1201\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/blog.whatsbee.net\/wp-content\/uploads\/2012\/05\/62-125-500x500.jpg\"><img aria-describedby=\"caption-attachment-1201\" loading=\"lazy\" class=\"size-medium wp-image-1201\" title=\"62-125-500x500\" src=\"http:\/\/blog.whatsbee.net\/wp-content\/uploads\/2012\/05\/62-125-500x500-300x300.jpg\" alt=\"\" width=\"300\" height=\"300\" srcset=\"https:\/\/blog.whatsbee.net\/wp-content\/uploads\/2012\/05\/62-125-500x500-300x300.jpg 300w, https:\/\/blog.whatsbee.net\/wp-content\/uploads\/2012\/05\/62-125-500x500-150x150.jpg 150w, https:\/\/blog.whatsbee.net\/wp-content\/uploads\/2012\/05\/62-125-500x500.jpg 500w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1201\" class=\"wp-caption-text\">Sensor PIR de DFRobot<\/p><\/div>\n<p>Other characteristics of this sensor are:<\/p>\n<ul>\n<li><em>Type: Digital<\/em><\/li>\n<li><em>Supply Voltage:3<\/em><em>\uff5e<\/em><em>5V<\/em><\/li>\n<li><em>Current:50\u03bcA<\/em><\/li>\n<li><em>Working temperature:0<\/em><em>\u2103<\/em><em>\uff5e\uff0b70<\/em><em>\u2103<\/em><\/li>\n<li><em>Output level(HIGH):4V<\/em><\/li>\n<li><em>Output level(LOW):0.4V<\/em><\/li>\n<li><em>Detect angle:110 Degree<\/em><\/li>\n<li><em>Detect distance:7 meters<\/em><\/li>\n<li><em>Size:28mm\u00d736mm<\/em><\/li>\n<li><em>Weight:25g<\/em><\/li>\n<\/ul>\n<div style=\"text-align: justify;\">The sensor has a high level digital output and two seconds after pluging it in, it scans for two seconds and detects, putting the signal to the low level. The threshold at which the device detects movements in its visable area can be controlled with a sensitivity regulator. control.<\/div>\n<div style=\"text-align: justify;\"><\/div>\n<div>So far so good. The output of the sensor is connected into the digital input of the Xbee, the radio configured and it functions without any major problems both with this gateway and with the rest of the hardware we have made. However, what we want to make is a battery powered sensor which means we have a couple of challenges to solve.<\/div>\n<div>\n<p style=\"text-align: justify;\">Power<\/p>\n<\/div>\n<div>In reality, the sensor has difficulties when the voltage drops below 3. Our nodes are powered by batteries without any kind of regulation and function until the voltage drops below 2.1. In the best case when we use fully charged batteries, they are receive 3V.\u00a0 We could feed the system with 3 batteries which if were fully charged would give us 4.5V of power, however this would be above the voltage limits of the radio. Also we considered the use of a regulator however this could give us issues with respect to energy consumption, circuit complexity etc. The simple solution is to power the node with 3 batteries with a \u2018tap\u2019. The radio receives its power from two of the batteries, whereas the sensor receives its power from all 3 of them. This easily gives us the solution to our problem without having to add unnecessary complexity to the circuit.<\/div>\n<div>\n<p style=\"text-align: justify;\">Sleep mode:<\/p>\n<\/div>\n<div>This is the second of our challenges to overcome. With the node permanently awake, we could detect the change in the input and send a warning packet to the Zigbee network to report immediately the change.\u00a0 If we pretend that the radio is asleep most of the time, we could wake up the radio by putting a low level connection between the leg of the sleep and the output of the sensor. This way every time the sensor detects something, the radio will wake up and send a packet to the network. This way of doing it has a problem; we know when the sensor detects movement (no se que es \u2018presencia\u2019 en ingles, cuando una persona aparece de repente o est\u00e1 en un lugar, en este caso hablamos de un detector de movimiento, por lo tanto el sensor cambia de estado cuando detecta la presencia de algo que se mueve\u2026 lo podemos cambiar por movimiento, aqu\u00ed explica el funcionamiento <a href=\"http:\/\/www.ladyada.net\/learn\/sensors\/pir.html\">http:\/\/www.ladyada.net\/learn\/sensors\/pir.html<\/a>), but we don\u2019t know when it will stop detecting it. When the output of the sensor sends a low signal, it wakes, sends a packet and sleeps. However when it returns to high level, it doesn\u2019t wake up. The GW or the SW might believe that they are constantly receiving the signal.<\/div>\n<div>\n<p style=\"text-align: justify;\"><strong>Solutions:<\/strong> Make the node send a packet every 15 or 20 seconds with the actual state, \u00a0this way a detection of presence will last this period of time. However the problem es that the node will be forced to talk every X seconds to detect the presence and this will have a negetive impact on the battery life.<\/p>\n<p style=\"text-align: justify;\">The other option is to wake the radio every time there is a change from either high to low or low to high, as the radio wakes up by putting a low level pin we need something which sends us a pulse when there is a change. Once again we return to the Signal Edge detector; remember the article <a title=\"Motes:9, a vueltas con el detector de flancos\" href=\"http:\/\/www.zigbe.net\/archivos\/729\"><em>Motes:9, a vueltas con el detector de flanco<\/em><\/a><em>s<\/em><em>?<\/em><\/p>\n<p style=\"text-align: justify;\">The fact is that using the components mentioned in this article has been difficult. After doing SW simulations and some HW tests, the design of the positive and negetive flask detectors with a working Xor port, but the capacitors we used shouldn\u2019t be 100nF, but 10nF; with this they should run smoothly up to 50 Hz<\/p>\n<p style=\"text-align: justify;\">The LTC bMotes has a magnetic sensor which should be able to wake up the radio, the bMotesRedButton and the PIR. This seams to be the most effective way to have the nodes which cause the packets to be sent after an action, and which function with a low power consumption.<\/p>\n<\/div>\n<div style=\"text-align: justify;\"><\/div>\n<div style=\"text-align: justify;\"><\/div>\n<p><!--:--><!--:es-->Vamos a aparcar el tema del gateway por unos d\u00edas, aunque nuestra hoja de ruta va un poco en otra direcci\u00f3n hoy he decidido tomarme un descanso y acabar un sensor de presencia por infrarrojos inal\u00e1mbrico que mont\u00e9 hace unos d\u00edas.<\/p>\n<p>El sensor es un PIR de DFRobot, con un coste aproximado de 7$, el motivo de elegir este y no otro es que funciona con una tensi\u00f3n de 3 a 5V y tiene un consumo de 50uA, el consumo es especialmente importante, con 50uA unas pilas AAA nos durar\u00e1n m\u00e1s de 4 a\u00f1os (en el caso hipot\u00e9tico de que no utiliz\u00e1ramos la red Zigbee).<\/p>\n<div id=\"attachment_1201\" style=\"width: 510px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/blog.whatsbee.net\/wp-content\/uploads\/2012\/05\/62-125-500x500.jpg\"><img aria-describedby=\"caption-attachment-1201\" loading=\"lazy\" class=\"size-full wp-image-1201\" title=\"62-125-500x500\" src=\"http:\/\/blog.whatsbee.net\/wp-content\/uploads\/2012\/05\/62-125-500x500.jpg\" alt=\"\" width=\"500\" height=\"500\" srcset=\"https:\/\/blog.whatsbee.net\/wp-content\/uploads\/2012\/05\/62-125-500x500.jpg 500w, https:\/\/blog.whatsbee.net\/wp-content\/uploads\/2012\/05\/62-125-500x500-150x150.jpg 150w, https:\/\/blog.whatsbee.net\/wp-content\/uploads\/2012\/05\/62-125-500x500-300x300.jpg 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><p id=\"caption-attachment-1201\" class=\"wp-caption-text\">Sensor PIR de DFRobot<\/p><\/div>\n<p>Otras caracter\u00edsicas de este sensor son:<\/p>\n<ul>\n<li>Type: Digital<\/li>\n<li>Supply Voltage:3\uff5e5V<\/li>\n<li>Current:50\u03bcA<\/li>\n<li>Working temperature:0\u2103\uff5e\uff0b70\u2103<\/li>\n<li>Output level(HIGH):4V<\/li>\n<li>Output level(LOW):0.4V<\/li>\n<li>Detect angle:110 Degree<\/li>\n<li>Detect distance:7 meters<\/li>\n<li>Size:28mm\u00d736mm<\/li>\n<li>Weight:25g<\/li>\n<\/ul>\n<p>El sensor tiene una salida digital a nivel alto, despu\u00e9s de alimentarse escanea durante dos segundos y detecta, poniendo la se\u00f1al a nivel bajo, los movimientos en su \u00e1rea de influencia, tiene un regulador de sensibilidad.<\/p>\n<p>Hasta aqu\u00ed todo es sencillo, la salida del sensor se conecta a una entrada digital del Xbee, se configura la radio y ya est\u00e1, funcionando sin mayores problemas con el gateway y con e resto de HW que hemos hecho, a\u00fan as\u00ed, como lo que queremos es hacer un sensor a bater\u00edas tenemos un par de retos a resolver.<\/p>\n<p><strong>Alimentaci\u00f3n:<\/strong><\/p>\n<p>Realmente el sensor tiene dificultades en el momento en el que la tensi\u00f3n de alimentaci\u00f3n baja de los 3V, nuestros nodos se alimentan con bater\u00edas sin ning\u00fan tipo de regulaci\u00f3n, y funcionan hasta con una tensi\u00f3n de 2,1V. En el mejor de los casos (bater\u00edas completamente cargadas) se van a alimentar a 3V, pero es m\u00e1s que normal que la tensi\u00f3n est\u00e9 por debajo. Podr\u00edamos poner tres pilas, pero la tensi\u00f3n de carga completa 4,5V estar\u00eda por encima de los l\u00edmites de alimentaci\u00f3n de la radio, poner un regulador es un problema, por una cuesti\u00f3n de rendimiento energ\u00e9tico, de complejidad del circuito, etc. la soluci\u00f3n sencilla es alimentar el nodo con tres bater\u00edas con una toma intermedia, la radio recibe la tensi\u00f3n de dos y el sensor de tres, resolvemos los diferentes requerimientos de tensi\u00f3n, no intrducimos complejidad en el circuito y todo funciona.<\/p>\n<p><strong>Modos Sleep:<\/strong><\/p>\n<p>Este es el segundo reto a resolver, con el nodo permanentemente despierto podr\u00edamos detectar el cambio en la entrada y enviar un paquete a la red Zigbee advirtiendo de la detecci\u00f3n de forma inmediata, pero pretendemos que la radio duerma la mayor\u00eda del tiempo. Podemos despertar a la radio poniendo una patita a nivel bajo (conectando la pata de sleep a la salida del sensor), de esta forma cada vez que el sensor detecte algo la radio despertar\u00e1 y enviar\u00e1 un paquete a la red. Esta forma de hacerlo tiene un problema, sabemos cuando el sensor detecta presencia, pero no sabemos cuando deja de detectarla. El el momento en el que la salida del sensor se pone a nivel bajo se despierta envia el paquete y se duerme, pero cuando se vuelve a poner a nivel alto, no se despierta, el GW o el SW pueden creer que se est\u00e1 detectando presencia indefinidamente.<\/p>\n<p>Soluciones: Hacer que el nodo mande un paquete cada 15 o 20 segundos con el estado real, de esta forma una detecci\u00f3n de presencia durar\u00e1 este periodo, el problema es que el nodo se ver\u00e1 forzado a hablar cada X segundos detecte presencia o no con la consiguiente reducci\u00f3n de tiempo en la vida de la bater\u00eda.<\/p>\n<p>La opci\u00f3n alternativa es despertar a la radio siempre que haya un cambio, sea de alto a bajo o de bajo a alto, como la radio se despierta poniendo un pin a nivel bajo nos hace falta algo que nos env\u00ede un pulso cuando haya un cambio, de nuevo volvemos al detector de flancos \u00bfos acordais del tema en el art\u00edculo\u00a0<a title=\"Motes:9, a vueltas con el detector de flancos\" href=\"http:\/\/www.zigbe.net\/archivos\/729\">Motes:9, a vueltas con el detector de flanco<\/a>s?<\/p>\n<p>El caso es que utilizando los componentes del art\u00edculo he tenido dificultades, despu\u00e9s de hacer unas simulaciones por SW y unas pruebas con HW el dise\u00f1o del detector de flancos positivos y negativos con una puerta Xor funciona, pero los condensadores utilizados no deben de ser de 100nF, sino de 10nF, con esos valores funciona sin problemas a frecuencias de hasta 50 Hz.<\/p>\n<p>Este es un tema absolutamente recurrente, el bMotes LTC tiene un sensor magn\u00e9tico que debe de ser capaz de despertar a la radio, el bMotesRedButton tambi\u00e9n, el PIR tambi\u00e9n, en definitiva, esta parece la forma m\u00e1s eficaz de tener nodos que tengan que provocar el env\u00edo de paquetes tras una acci\u00f3n y que funcionen a bater\u00edas con un consumo m\u00ednimo.<!--:--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let\u2019s change the topic away from gateways for a few days. Today I have deceided to finish a wireless infrared presence sensor I started a few days ago. The sensor is a PIR of a DFRobot which costs around about&hellip; <br \/><a class=\"read-more-button\" href=\"https:\/\/blog.whatsbee.net\/?p=1200\">Leer m\u00e1s<\/a><\/p>\n","protected":false},"author":1,"featured_media":1201,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0},"categories":[16,2,9],"tags":[111,146,151,173,197],"_links":{"self":[{"href":"https:\/\/blog.whatsbee.net\/index.php?rest_route=\/wp\/v2\/posts\/1200"}],"collection":[{"href":"https:\/\/blog.whatsbee.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.whatsbee.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.whatsbee.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.whatsbee.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1200"}],"version-history":[{"count":1,"href":"https:\/\/blog.whatsbee.net\/index.php?rest_route=\/wp\/v2\/posts\/1200\/revisions"}],"predecessor-version":[{"id":7584,"href":"https:\/\/blog.whatsbee.net\/index.php?rest_route=\/wp\/v2\/posts\/1200\/revisions\/7584"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.whatsbee.net\/index.php?rest_route=\/wp\/v2\/media\/1201"}],"wp:attachment":[{"href":"https:\/\/blog.whatsbee.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.whatsbee.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.whatsbee.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}