{"id":26057419,"url":"https://github.com/aabbtree77/atmega88-enc28j60","last_synced_at":"2025-06-25T14:35:07.058Z","repository":{"id":279822184,"uuid":"940099389","full_name":"aabbtree77/atmega88-enc28j60","owner":"aabbtree77","description":"Connecting ATmega to the internet with enc28j60 and C.","archived":false,"fork":false,"pushed_at":"2025-02-27T16:12:54.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-08T11:15:21.602Z","etag":null,"topics":["334-ntc103-rc","atmega","atmega88","avr-gcc","communication","embedded","enc28j60","ethernet","iot","thermistor","thermistor-to-digital","udp"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aabbtree77.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-27T16:03:18.000Z","updated_at":"2025-02-27T16:19:50.000Z","dependencies_parsed_at":"2025-02-27T22:56:01.637Z","dependency_job_id":null,"html_url":"https://github.com/aabbtree77/atmega88-enc28j60","commit_stats":null,"previous_names":["aabbtree77/atmega88-enc28j60"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aabbtree77/atmega88-enc28j60","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabbtree77%2Fatmega88-enc28j60","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabbtree77%2Fatmega88-enc28j60/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabbtree77%2Fatmega88-enc28j60/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabbtree77%2Fatmega88-enc28j60/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aabbtree77","download_url":"https://codeload.github.com/aabbtree77/atmega88-enc28j60/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aabbtree77%2Fatmega88-enc28j60/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261892308,"owners_count":23225903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["334-ntc103-rc","atmega","atmega88","avr-gcc","communication","embedded","enc28j60","ethernet","iot","thermistor","thermistor-to-digital","udp"],"created_at":"2025-03-08T11:15:24.962Z","updated_at":"2025-06-25T14:35:07.017Z","avatar_url":"https://github.com/aabbtree77.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Introduction\n\nThis is a bare-bones demo code for a remote server/client device that reads in the analog sensors of the environment and \ncommunicates them to a PC via the UDP. The PC may also send the UDP packets to control five switches, which, in turn, can change \nthe environment. The device uses the ethernet chip ENC28J60 with the ATmega88 microcontroller. \n\n# System\n\nThe structure of the system is shown in Fig. 1.\n\n      (0)         (1)                            (3)                                (5)\n    Sensors   ------------                  --------------                     --------------\n    ---------\u003e| ATmega88 |        (2)       |   Router   |        (4)          | Linux PC   |\n    \u003c---------| ENC28j60 |\u003c----Ethernet----\u003e|            |\u003c----Ethernet------\u003e | (Ubuntu)   |\n    Outputs   ------------                  --------------                     --------------\n\nFigure 1. Network architecture of the remote server/client control device. In the LAN case \n          the router is not necessary.\n\n\n## Sensors and Outputs\n\nAll the four analog input lines ADC0-ADC3 of ATmega88 are sequentially scanned by using Single Conversion \nMode. At present, the system reads in the four voltages that depend on the four 334-NTC103-RC thermistors, \nstores the voltages in a digital form, and converts them to the degrees in Celsius, see the function \nadc88_m2t(...) in adc_m88.c. In addition, the function\n\nvoid adc88_adjust(uint8_t adjust_flag)\n\nis created to control the switches by providing binary control signals on the pins of the Port D \n(PD0, PD1, PD3, PD4). The output PD7 is left free. The switches are connected to the electric heaters which \nraise the environment temperature if it falls below a specified threshold.\n\nThe NTC thermistors are such that their resistance decreases when the temperature rises. As a result, the \nchange in the ADC values is of the opposite sign. The adjusting function uses two arrays:\n\nuint16_t t_on[4]={450,450,450,450};\nuint16_t t_off[4]={350,350,350,350}; \n\nTheir elements are set by hand and indicate when the corresponding output should be turned on or off in order to keep the environment temperature above a specified threshold.\n\n## Device\n\nSee the article by Guido Socher at http://tuxgraphics.org/electronics/200606/article06061.shtml.\nThe implicit design criterion and the sole reason for the use of the ENC28J60 chip is the minimization of \nthe number of the chip's pins.\n\n## Ethernet\n\nStandard 10BASE-T Ethernet cable.\n\n## Router\n\nAny standard router that you use to connect your PC to the internet is OK. One should write the device MAC, \nIP and the port number to the router's tables to obtain the chance of everything getting connected. \nThe IP address for the device must be local.\n\n## Ethernet\n\nThe system uses Internet's transport layer by sending the UDP packets. In order to minimize the packet \ncollisions, or buffer overflow, it is good to use the device to respond to separate commands, \nas opposed to, say, a constant generation of the UDP packets. Occasional rebooting might still be necessary.\n\n## PC\n\nCommunication with the device is done from a PC by running **udpcom** in the Linux shell, see\nhttp://tuxgraphics.org/electronics/200606/article06061.shtml.\n\n# Setup\n\n3.1 Assemble all the hardware according to the scheme given by Guido Socher, see the link above. The scheme must be from the web article, not the one provided in the archived files, i.e. check if the clock signal is external: ENC28j60's Pin 3 (CLKout) should be connected to ATmega88's Pin 9 (PD5, XTAL1).\n\n3.2 sudo aptitude install binutils, gcc-avr, avr-libc, avrdude.\n\n3.3 Clone this folder, and type: make. The resulting main.hex may look to be of the size 15.3 KB, but this is\nnothing to worry about as each symbol in it is the hexadecimal number which takes 4 bits, not a byte, and so \nthe  actual code size to write is less than 8KB (should be about 6KB). This is the part where you begin \nto worry if you  plan to add some new libraries.\n\n3.4 Set up the stk200 interface to connect the device to your PC and write sudo make install. \nThis should write the file main.hex to the flash of ATmega88.\n\n3.5 Turn the power of the device off, unplug the stk200 interface cable, plug in the ethernet cable, turn\nthe power on, and run the udpcom commands in several scenarios:\n\n\tTurn on the automatic temperature adjustment: udpcom password,a=1 \u003cIP address\u003e\n\t\n\tTurn off the automatic temperature adjustment: udpcom password,a=0 \u003cIP address\u003e\n\n\tSet the output PD7 to 1: udpcom password,s=5 \u003cIP address\u003e\n\t\n\tSet the output PD1 to 0: udpcom password,r=2 \u003cIP address\u003e\n\t\n\tRead the status of all the output pins: udpcom password,p \u003cIP address\u003e\n\t\n\tRead all the temperature measurements in Celsius: udpcom password,m \u003cIP address\u003e\n\t\n\u003cIP address\u003e is the IP address of the router in the global setting, or any local IP address of the device if \nthe LAN is configured without a router. The IP and MAC addresses, and the port number, all specified \nin main.c, should match the ones written in the router's table.\n\nThe automatic adjustment overrides the \"s=x\" and \"r=y\" commands, and that is the default setting. It must \nbe turned off with \"a=0\" before issuing the \"s=x\" and \"r=y\" commands.\n\t\n# History, Credits\n\nThe project was completed by me and Saulius Rakauskas in 2010. He assembled the hardware and did all the fine work\nwith the network configuration, while I wrote the code. In essence, this is an adaptation of the work \nby Guido Socher:\n\n\"An AVR microcontroller based Ethernet device\"\n\nhttp://tuxgraphics.org/electronics/200606/article06061.shtml\n\nWe added the analog-to-digit conversion, which resulted in the files adc_m88.c (h), and the adjustments in the \nfiles main.c and Makefile.\n\n# Licence\n\nGPL V2 for the modified Guido Socher's code. MIT for the ADC functions. Use the code at your own risk.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faabbtree77%2Fatmega88-enc28j60","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faabbtree77%2Fatmega88-enc28j60","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faabbtree77%2Fatmega88-enc28j60/lists"}