{"id":1278,"date":"2024-06-24T15:09:04","date_gmt":"2024-06-24T15:09:04","guid":{"rendered":"https:\/\/iotthinghub.com\/?p=1278"},"modified":"2024-08-11T15:17:06","modified_gmt":"2024-08-11T15:17:06","slug":"counting-visitor-using-internal-eeprom","status":"publish","type":"post","link":"https:\/\/iotthinghub.com\/?p=1278","title":{"rendered":"Counting Visitor using internal EEPROM"},"content":{"rendered":"\n<p class=\"has-text-color has-link-color wp-elements-51abaecf7d9e5ed29313ea6f61522e07 wp-block-paragraph\" style=\"color:#5c5c5c\">EEPROM stands for electrically erasable read only memory. It is a non volatile memory means that it will store the last data if any power failure. Suppose we want to count the number of visitors in a shop. If a power failure occurs then all data will be erased. In that case we can store our counting i.e. important data in EEPROM. Maximum all Atmega family microcontrollers have internal EEPROM memory. They can have from 512 bytes to 4k bytes of EEPROM memory space and is linearly organized. The EEPROM i.e. Electrical Erasable Programmable Read Only Memory stores the values and we can read the values as soon as the power on. In order to read and write data from this memory there is a necessary special access function-<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"457\" src=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/EEPROM-function-1-1024x457.jpg\" alt=\"\" class=\"wp-image-1280\" srcset=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/EEPROM-function-1-1024x457.jpg 1024w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/EEPROM-function-1-300x134.jpg 300w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/EEPROM-function-1-768x342.jpg 768w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/EEPROM-function-1.jpg 1323w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"382\" src=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/EEPROM-function-2-1024x382.jpg\" alt=\"\" class=\"wp-image-1282\" srcset=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/EEPROM-function-2-1024x382.jpg 1024w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/EEPROM-function-2-300x112.jpg 300w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/EEPROM-function-2-768x287.jpg 768w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/EEPROM-function-2.jpg 1328w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" width=\"590\" height=\"130\" src=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/counting-visitor.png\" alt=\"\" class=\"wp-image-1284\" style=\"width:250px;height:auto\" srcset=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/counting-visitor.png 590w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/counting-visitor-300x66.png 300w\" sizes=\"(max-width: 590px) 100vw, 590px\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-344c577f8eb56e441107c5c9e0fdcbae wp-block-paragraph\" style=\"color:#5c5c5c\">In 7 segment display part we write a program to display numbers in 7 segment display. In this section we modify the program to store the numbers of visitor\u2019s in the EEPROM instant of storing in the flash memory. We also introduce a push button to clear the EEPROM, so that we may have the ability to start from beginning. After erasing the EEPROM please restart the device unless useless data will show. We previously learn how to display in seven segment display. Now we introduce new function to display digits using persistence of vision.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\nvoid print(int num)\n{\nfor(i=0;num!=0;i++)\n\t{\n\tdigits&#x5B;i]=num%10;\n\tdigit&#x5B;i]=seven_segment(digits&#x5B;i]);\n\tnum=num\/10;\n\t}\n\t\/* main part display number*\/\n\tfor(i=0;i&lt;3;i++)\n\t{\t\n\t\tPORTD=0x07;     \/\/ Dark condition\n\t\t_delay_ms(5);\n\t\tPORTB=digit&#x5B;i];\n\t\tPORTD&amp;=~(1&lt;&lt;i); \/\/ i display on\n\t\t_delay_ms(5);\n\t\tPORTD=0x07;     \/\/ Dark condition    \n\t\t_delay_ms(5);\n\t\t\n\t}\n}\n<\/pre><\/div>\n\n\n<p class=\"has-text-color has-link-color wp-elements-d469764a5196deb3d06f79b878354075 wp-block-paragraph\" style=\"color:#5c5c5c\">Download the count.c and count.h file. The main program as follow-<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\n#include&lt;avr\/io.h&gt;\n#include&lt;util\/delay.h&gt;\n#include&lt;avr\/eeprom.h&gt;\n#include&quot;count.h&quot;\nuint8_t x,start;\nuint16_t num=0,value,z;\nint main(void)\n{\nDDRB=0xff;\t\t\t\t\t\t\t\t\t\t\/\/7 segment port\nPORTB=0b11111100;\t\t\t\t\t\t\t\t\/\/default value 0 to all the 7 segment;\nDDRD=0x07;\t\t\t\t\t\t\t\t\t\t\/\/7 segment control port\nPORTD|=(1&lt;&lt;PIND4);\t\t\t\t\t\t\t\t\/\/push button to clear the eeprom\nz=eeprom_read_word((uint16_t*) 100);\nnum=z;\n\twhile(1)\n\t{\n\tstart=PIND&amp;0b00010000;\n\tif(start==0)\n\t{\t\n\t\teeprom_update_word((uint16_t*) 100,0); \/\/clear EEPROM\n\t\tnum=0;                                 \/\/clear cash \n\t\tdisplay_zero();\n\t\twhile(!(PIND&amp;0b00001000));\n\t\t_delay_ms(100);                         \/\/wait for switch debouncing delay\n\t}\n\tx=PIND&amp;0b00001000;\n\tif(x==8)\n\t{\n\tnum++;\n\tprint(num);\n\t_delay_ms(150);\n\t\teeprom_update_word((uint16_t*) 100,num);\n\t}\n\telse print(num);\n\t}\nreturn 0;\n}\n<\/pre><\/div>\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-7387b849 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:33.33%\">\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-3e41869c wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/Counting-Visitor.rar\" style=\"border-radius:10px;padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--20);padding-left:var(--wp--preset--spacing--40)\">download<\/a><\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:66.66%\">\n<p class=\"has-text-color has-link-color wp-elements-732a511cd6370033e268b495b4b2f9f5 wp-block-paragraph\" style=\"color:#181717\"><a href=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/Counting-Visitor.rar\">Download the full program with proteus simulation<\/a><\/p>\n<\/div>\n<\/div>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-89a4808046e000b3c378124178174b16 wp-block-paragraph\" style=\"color:#5c5c5c\">As soon as we run the program an extra file is generated that is main.eep, where the program EEPROM value stored. We have to load the main.eep file in the burner software as shown in the figure-<\/p>\n\n\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\"><style type=\"text\/css\">\n#foogallery-gallery-1297 .fg-image { width: 200px; }<\/style>\n\t\t\t<div class=\"foogallery foogallery-container foogallery-carousel foogallery-lightbox-foogallery fg-carousel fg-ready fg-light fg-border-thin fg-shadow-outline fg-loading-default fg-loaded-fade-in fg-caption-hover fg-hover-fade fg-hover-zoom\" id=\"foogallery-gallery-1297\" data-foogallery=\"{&quot;item&quot;:{&quot;showCaptionTitle&quot;:true,&quot;showCaptionDescription&quot;:true},&quot;lazy&quot;:true,&quot;template&quot;:{&quot;maxItems&quot;:5,&quot;scale&quot;:0.11999999999999999555910790149937383830547332763671875,&quot;gutter&quot;:{&quot;min&quot;:-40,&quot;max&quot;:-20,&quot;unit&quot;:&quot;%&quot;},&quot;autoplay&quot;:{&quot;time&quot;:1,&quot;interaction&quot;:&quot;pause&quot;},&quot;centerOnClick&quot;:true,&quot;align&quot;:&quot;center&quot;,&quot;activePosition&quot;:&quot;center&quot;}}\" data-foogallery-lightbox=\"{&quot;thumbs&quot;:&quot;bottom&quot;,&quot;thumbsCaptions&quot;:false,&quot;thumbsBestFit&quot;:false,&quot;thumbsSmall&quot;:false,&quot;thumbsCaptionsAlign&quot;:&quot;default&quot;,&quot;info&quot;:&quot;bottom&quot;,&quot;infoVisible&quot;:true,&quot;infoOverlay&quot;:true,&quot;infoAlign&quot;:&quot;default&quot;,&quot;transition&quot;:&quot;fade&quot;,&quot;hoverButtons&quot;:false,&quot;fitMedia&quot;:false,&quot;noScrollbars&quot;:true,&quot;preserveButtonSpace&quot;:true,&quot;buttons&quot;:{&quot;fullscreen&quot;:true,&quot;info&quot;:true,&quot;thumbs&quot;:false},&quot;video&quot;:{&quot;autoPlay&quot;:true}}\" style=\"--fg-title-line-clamp: 0; --fg-description-line-clamp: 0;\" >\n\t<button type=\"button\" class=\"fg-carousel-prev\" title=\"Previous\"><\/button>\n\t<div class=\"fg-carousel-inner\">\n\t\t<div class=\"fg-carousel-center\"><\/div>\n\t\t<div class=\"fg-item fg-type-image fg-idle\"><figure class=\"fg-item-inner\"><a href=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/ee2.png\" data-caption-desc=\"Open eXtreme Burner. Click &amp;gt; Open. Change-- Standard Intel HEX Files(*.hex) to EEPROM Files(*.eep). Locate main.eep file and click open\" data-attachment-id=\"1298\" data-type=\"image\" class=\"fg-thumb\"><span class=\"fg-image-wrap\"><img decoding=\"async\" width=\"200\" height=\"200\" class=\"skip-lazy fg-image\" data-src-fg=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/cache\/2024\/06\/ee2\/3924541861.png\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22200%22%20height%3D%22200%22%20viewBox%3D%220%200%20200%20200%22%3E%3C%2Fsvg%3E\" loading=\"eager\"><\/span><span class=\"fg-image-overlay\"><\/span><\/a><figcaption class=\"fg-caption\"><div class=\"fg-caption-inner\"><div class=\"fg-caption-desc\">Open eXtreme Burner. Click &gt; Open. Change-- Standard Intel HEX Files(*.hex) to EEPROM Files(*.eep). Locate main.eep file and click open<\/div><\/div><\/figcaption><\/figure><div class=\"fg-loader\"><\/div><\/div><div class=\"fg-item fg-type-image fg-idle\"><figure class=\"fg-item-inner\"><a href=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/ee3.jpg\" data-caption-desc=\"You get this type of massage\" data-attachment-id=\"1299\" data-type=\"image\" class=\"fg-thumb\"><span class=\"fg-image-wrap\"><img decoding=\"async\" width=\"200\" height=\"200\" class=\"skip-lazy fg-image\" data-src-fg=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/cache\/2024\/06\/ee3\/4085028471.jpg\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22200%22%20height%3D%22200%22%20viewBox%3D%220%200%20200%20200%22%3E%3C%2Fsvg%3E\" loading=\"eager\"><\/span><span class=\"fg-image-overlay\"><\/span><\/a><figcaption class=\"fg-caption\"><div class=\"fg-caption-inner\"><div class=\"fg-caption-desc\">You get this type of massage<\/div><\/div><\/figcaption><\/figure><div class=\"fg-loader\"><\/div><\/div><div class=\"fg-item fg-type-image fg-idle\"><figure class=\"fg-item-inner\"><a href=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/eec1.png\" data-caption-desc=\"Now check EEPROM\" data-attachment-id=\"1300\" data-type=\"image\" class=\"fg-thumb\"><span class=\"fg-image-wrap\"><img decoding=\"async\" width=\"200\" height=\"200\" class=\"skip-lazy fg-image\" data-src-fg=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/cache\/2024\/06\/eec1\/2550685851.png\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22200%22%20height%3D%22200%22%20viewBox%3D%220%200%20200%20200%22%3E%3C%2Fsvg%3E\" loading=\"eager\"><\/span><span class=\"fg-image-overlay\"><\/span><\/a><figcaption class=\"fg-caption\"><div class=\"fg-caption-inner\"><div class=\"fg-caption-desc\">Now check EEPROM<\/div><\/div><\/figcaption><\/figure><div class=\"fg-loader\"><\/div><\/div><div class=\"fg-item fg-type-image fg-idle\"><figure class=\"fg-item-inner\"><a href=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/eeprom.png\" data-caption-desc=\"Now click Write&amp;gt; EEPROM\" data-attachment-id=\"1302\" data-type=\"image\" class=\"fg-thumb\"><span class=\"fg-image-wrap\"><img decoding=\"async\" width=\"200\" height=\"200\" class=\"skip-lazy fg-image\" data-src-fg=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/cache\/2024\/06\/eeprom\/753789865.png\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22200%22%20height%3D%22200%22%20viewBox%3D%220%200%20200%20200%22%3E%3C%2Fsvg%3E\" loading=\"eager\"><\/span><span class=\"fg-image-overlay\"><\/span><\/a><figcaption class=\"fg-caption\"><div class=\"fg-caption-inner\"><div class=\"fg-caption-desc\">Now click Write&gt; EEPROM<\/div><\/div><\/figcaption><\/figure><div class=\"fg-loader\"><\/div><\/div><div class=\"fg-item fg-type-image fg-idle\"><figure class=\"fg-item-inner\"><a href=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/eeprom2.png\" data-caption-desc=\"Then click Write&amp;gt; Flash\" data-attachment-id=\"1303\" data-type=\"image\" class=\"fg-thumb\"><span class=\"fg-image-wrap\"><img decoding=\"async\" width=\"200\" height=\"200\" class=\"skip-lazy fg-image\" data-src-fg=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/cache\/2024\/06\/eeprom2\/1585443781.png\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22200%22%20height%3D%22200%22%20viewBox%3D%220%200%20200%20200%22%3E%3C%2Fsvg%3E\" loading=\"eager\"><\/span><span class=\"fg-image-overlay\"><\/span><\/a><figcaption class=\"fg-caption\"><div class=\"fg-caption-inner\"><div class=\"fg-caption-desc\">Then click Write&gt; Flash<\/div><\/div><\/figcaption><\/figure><div class=\"fg-loader\"><\/div><\/div><div class=\"fg-item fg-type-image fg-idle\"><figure class=\"fg-item-inner\"><a href=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/eep.png\" data-caption-desc=\"Change -- Clock Frequency to Initial Contents of Data EEPROM. Then click open next to the EEPROM.\" data-attachment-id=\"1301\" data-type=\"image\" class=\"fg-thumb\"><span class=\"fg-image-wrap\"><img decoding=\"async\" width=\"200\" height=\"200\" class=\"skip-lazy fg-image\" data-src-fg=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/cache\/2024\/06\/eep\/1517142754.png\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22200%22%20height%3D%22200%22%20viewBox%3D%220%200%20200%20200%22%3E%3C%2Fsvg%3E\" loading=\"eager\"><\/span><span class=\"fg-image-overlay\"><\/span><\/a><figcaption class=\"fg-caption\"><div class=\"fg-caption-inner\"><div class=\"fg-caption-desc\">Change -- Clock Frequency to Initial Contents of Data EEPROM. Then click open next to the EEPROM.<\/div><\/div><\/figcaption><\/figure><div class=\"fg-loader\"><\/div><\/div><div class=\"fg-item fg-type-image fg-idle\"><figure class=\"fg-item-inner\"><a href=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/pc2.png\" data-caption-desc=\"Open main.eep as shown in figure\" data-attachment-id=\"1304\" data-type=\"image\" class=\"fg-thumb\"><span class=\"fg-image-wrap\"><img decoding=\"async\" width=\"200\" height=\"200\" class=\"skip-lazy fg-image\" data-src-fg=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/cache\/2024\/06\/pc2\/88930756.png\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22200%22%20height%3D%22200%22%20viewBox%3D%220%200%20200%20200%22%3E%3C%2Fsvg%3E\" loading=\"eager\"><\/span><span class=\"fg-image-overlay\"><\/span><\/a><figcaption class=\"fg-caption\"><div class=\"fg-caption-inner\"><div class=\"fg-caption-desc\">Open main.eep as shown in figure<\/div><\/div><\/figcaption><\/figure><div class=\"fg-loader\"><\/div><\/div><div class=\"fg-item fg-type-image fg-idle\"><figure class=\"fg-item-inner\"><a href=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/Proteus-change.png\" data-caption-desc=\"load the .eep file\" data-attachment-id=\"1305\" data-type=\"image\" class=\"fg-thumb\"><span class=\"fg-image-wrap\"><img decoding=\"async\" width=\"200\" height=\"200\" class=\"skip-lazy fg-image\" data-src-fg=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/cache\/2024\/06\/Proteus-change\/3566890751.png\" src=\"data:image\/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22200%22%20height%3D%22200%22%20viewBox%3D%220%200%20200%20200%22%3E%3C%2Fsvg%3E\" loading=\"eager\"><\/span><span class=\"fg-image-overlay\"><\/span><\/a><figcaption class=\"fg-caption\"><div class=\"fg-caption-inner\"><div class=\"fg-caption-desc\">load the .eep file<\/div><\/div><\/figcaption><\/figure><div class=\"fg-loader\"><\/div><\/div>\t<\/div>\n\t<div class=\"fg-carousel-bottom\"><\/div>\n\t<div class=\"fg-carousel-progress\"><\/div>\n\t<button type=\"button\" class=\"fg-carousel-next\" title=\"Next\"><\/button>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>EEPROM stands for electrically erasable read only memory. It is a non volatile memory means that it will store the last data if any power failure. Suppose we want to count the number of visitors in a shop. If a power failure occurs then all data will be erased. In that case we can store [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-1278","post","type-post","status-publish","format-standard","hentry","category-eeprom"],"_links":{"self":[{"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/posts\/1278","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1278"}],"version-history":[{"count":14,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/posts\/1278\/revisions"}],"predecessor-version":[{"id":2561,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/posts\/1278\/revisions\/2561"}],"wp:attachment":[{"href":"https:\/\/iotthinghub.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}