Engineers Garage

  • Projects and Tutorials
    • Circuit Design
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Components
    • Contributions
  • Articles
    • EG Blogs
    • Insight
    • Invention Stories
    • How to
    • What Is
    • News
      • EE Design News
      • DIY Reviews
      • Guest Post
      • Sponsored Content
  • Forums
    • EG Forum Archive
    • EDABoard.com
    • Electro-Tech-Online
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • Video
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering

SNMP(Simple Network Management Protocol) Implementation on Arduino Ethernet Shield: Monitoring Room Temperature

July 8, 2019 By EG Projects

In this tutorial i am going to teach you how to implement snmp over arduino Ethernet shield and monitor a remote system over a network. So what is snmp? Snmp stands for Simple Network Management Protocol. As the name depicts the protocol is used to monitor the equipment/peripherals connected to a network. Snmp can monitor and update the status of network peripherals such as routers, servers, printers, switches, hubs and other devices connected to a network. Today snmp protocol is widely used in telecom industry to monitor the status of remote BTS(Base Stations) sites and data centers. At BTS sites snmp is used to monitor the generator status, rectifier voltages, battery voltages and ups efficiency etc. Almost all the telecom industry is using snmp for their remote site telecom equipment monitoring.

A network that implements snmp protocol consist of two broad entities. 

  • SNMP Agents
  • SNMP Managers

An Snmp Agent is a program that is installed on a particular hardware. It gathers the data about hardware(Temperature, Status etc) and keeps the data with him. Snmp Manager is device that gets data from snmp agent. Snmp managers requests the agents to send particular data when ever is needed. Snmp protocol has a defined format for data fetching called MIB(Management Information Base). Manager’s call this mib for fetching data and agents gather data across this mib. Mib is a hierarchical structure of data placement and format etc. This tutorial will not go in deep details of snmp protocol rather it will only focus on implementing snmp on arduino Ethernet shield. If you are a newbie and want to learn more i suggest to google snmp details and structure.

Snmp(Manager) uses pull mechanism to fetch data from remote locations(Agents). Snmp is advantageous only if we do not need our data regularly. Since its a pull method so fetching data regularly will place heavy load on manager. In case we regularly and instantaneously need data we have to implement push protocols such as MQTT etc. In push protocol the agent sends data to manager when any condition is meet or an intrusion is detected. 

Demo Snmp over Arduino Project: LM35 Temperature monitoring over network

In the following demo project I am going to install snmp manager on my laptop and arduino will act like an agent. Arduino Ethernet shield is mounted on arduino uno and Lm35 temperature sensor is connected to analog channel-0 of arduino. Agent(arduino) will calculate the temperature and upon receiving the fetch request from manger it will send data to manager.
Snmp implementation on arduino

Snmp implementation on arduino

Snmp Manager Software

I used iREASONING mib browser as manager. Its easy to install and working with it is straight forward I installed it on my laptop. iREASONING offers a free student as well as trial version of mib browser. Its a great resource to check the agent behavior. You can download the free and trial version from this page. iREASONING Browser. 

Snmp Agent

At agent side we have arduino uno with Ethernet shield mounted on it.  I used Agentuino an open source library to implement agent functionality on my arduino. Agentuino is an open source library which helps in implementing agent functionality on arduino Ethernet shield. Snmp version v 1.2 is implemented by the library. It supports get, set and walk methods.

Project Circuit Diagram

Mount Arduino Ethernet shield on Arduino uno. Connect LM35 Vout pin to Analog channel-0 of arduino. Vout is middle pin of lm35. Ground gnd pin of lm35 with arduino ground. Apply vcc +5 volts to another pin of lm35, connect it to +5 volt pin of arduino. Insert on end of network cable in RJ45 port of arduino Ethernet shield and connect other end of network cable to PC or your lap top on whom you installed the snmp manager.
​
Note:
You can use any other arduino board if you want. Code is compatible with all arduino boards mega etc. Make sure to use TTL level boards. Arduino due is a +3.3v board, Ethernet shield will not work with it.
If you are new and don’t know about LM35 Pin out, its internal structure and formula derivation for arduino than i have some good tutorial for you.
Arduino Ethernet shield with LM35 temperature sensor- SNMP

Arduino Ethernet shield with LM35 temperature sensor- SNMP

Lm35 Pin out and Working

Lm35 with Arduino: Deriving Formula

Coming to the code portion. In the code i defined 2 OID’s. Across one OID agent is gathering temperature in Celsius/centigrade and across another in Fahrenheit. Also their are some system OID’s across which system information is hard-coded. You can see the system information hard-coded in the code in the code below. Their are total 5 systems OID’s containing information about system contact,name,location,services and general system description. 

System OID’s

const char sysDescr[] PROGMEM      = “1.3.6.1.2.1.1.1.0”;  // System Description
const char sysContact[] PROGMEM    = “1.3.6.1.2.1.1.4.0”;  // System Contact
const char sysName[] PROGMEM       = “1.3.6.1.2.1.1.5.0”;  // System Name
const char sysLocation[] PROGMEM   = “1.3.6.1.2.1.1.6.0”;  // System Location

const char sysServices[] PROGMEM   = “1.3.6.1.2.1.1.7.0”;  // System Services

Custom OID’s

const char temperatureC[]       PROGMEM     = “1.3.6.1.3.2016.5.1.0”;     //Temperature in Celsius
const char temperatureF[]       PROGMEM     = “1.3.6.1.3.2016.5.1.1”;     //Temperature is Fahrenheit

The function pduReceived() defines the information about the OID’s. Agentuino.listen() function is listening to snmp requests. This statement is present in the loop function to execute for ever. When ever any snmp request arrives the Agentuino.listen() function identifies it and passes the control to pduReceived() function. pduReceived() function extract’s the OID from the manager request, compares it with the OID’s it has, if matched than perform next step. Sends back the needed information if the request is get and sets the new parameters if the request is set.   

Testing the Snmp Agent and Manager

Before beginning with the test let me clear you some more general concepts. When ever we use Ethernet shield with arduino we define the mac address of shield and assign it a IP in code. Any device on network has an IP and mac address. So if Ethernet shield is going to be used on network it must have one. I assigned my Ethernet shield    

static byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };  //Mac Address for Arduino Ethernet Shield
static byte ip[] = { 192, 168, 20, 6 };                                           //IP Address for Arduino Ethernet Shield

To establish communicate between two network devices both must on same network. So we must bring our agent and manager on same IP series. Agent(Ether Shield) is at 192.168.20.6. So we must bring our PC or laptop at the same series 192.168.20..… I assigned my manager laptop IP 192.168.20.5. How i assigned this IP is Go to > Open Network and Sharing Center > Local Area Connection > Properties > Internet Protocol Version 4 > Insert IP and Sub net click OK. 
Snmp manager IP settings

Snmp manager IP settings

Now we have uploaded code to the arduino and made all the necessary settings its time to test the diy project. Open the MIB Browser insert the agent address, insert OID whose data is required set operations to GET and click go. Results will appear in the widow below.
iREASONING MIB browser settings for snmp

iREASONING MIB browser settings for snmp

Download the project code and please give us your feed back on the project. In case you have any queries please write them below in the comments section.

Watch the project video and results here

Project files/code

Related Articles Read More >

A Bluetooth-controlled datalogger robot
touch bell push
How to design a touchless bell push using Arduino
SMS-enabled scrolling message board using Arduino
Interfacing stepper motor with 8051(89c51,89c52 ) microcontroller

Featured Tutorials

  • Capacitive Touch Controlled Robot using X-Bee Module
  • Keypad Controlled RF based Wireless Robot
  • A Bluetooth-controlled datalogger robot
  • Keypad Controlled And Industrial Gas Monitoring Wireless Robot
  • Joystick Controlled Wireless Robot
  • CAN Protocol – Understanding the Controller Area Network Protocol

Stay Up To Date

Newsletter Signup

EE Training Center Classrooms

“ee

“ee

“ee

“ee

Recent Articles

  • How to build an IR remote-operated RGB LED strip using Arduino
  • Maxim launches automotive-grade secure authenticator for enhanced vehicle safety
  • Samsung offers compact, WiFi-enabled VRF air-conditioning systems
  • Nexperia launches industry’s first 80-V RET family for high-voltage circuits
  • The Amazing World of Robotics and its Promising Future
...

RSS EDABOARD.com Discussions

  • Rippe current rating of aluminium electrolytic capacitor is very low.
  • Start-up resistor for offline flyback suffers overvoltage..but is it OK?
  • Why disabled autoCsEnable in SPI doesn't allow CS gpio control in EFR32FG14
  • Spice correlation issue
  • Mic preamp and Tx on MAX260x

RSS Electro-Tech-Online.com Discussions

  • new to Ardunio but trying to compile
  • Any Ideas As to why circuit keeps breaking
  • 12v zvs induction heater
  • First time using MOSFETs project
  • Engine Temperature using an AD590 on the Oil Pressure Wire to the engine
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2021 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Circuit Design
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Components
    • Contributions
  • Articles
    • EG Blogs
    • Insight
    • Invention Stories
    • How to
    • What Is
    • News
      • EE Design News
      • DIY Reviews
      • Guest Post
      • Sponsored Content
  • Forums
    • EG Forum Archive
    • EDABoard.com
    • Electro-Tech-Online
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • Video
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering