Arduino SNMP

Hi,

I have configured two sensors (Temp & smoke) using arduino Ethernet shield on LAN. I am trying to set SNMP code in arduino so that i can monitor the status of these sensors at remote locations. Could anyone help please? as i am Arduino beginner.
Thanks.

I am trying to set SNMP code in arduino

You want the Arduino to be a mail server? That doesn't make sense.

PaulS:
You want the Arduino to be a mail server? That doesn't make sense.

SNMP is Simple Network Management Protocol, not SMTP. It has a website at net-snmp.org. Maybe 41j.com/blog/2014/12/arduino-snmp-voltage-monitor could be useful.

SNMP is "Simple Network Monitoring Protocol" - nothing to do with mail (that would be SMTP: Simple Mail Transfer Protocol.)

SNMP is usually pretty complex and bloated code, but IIRC someone has done something that runs on Arduino.
Um... Take a look at: Google Code Archive - Long-term storage for Google Code Project Hosting.

No. I don't want a mail server. I am just trying to upload SNMP code in arduino so that i can monitor the status of these senors at any location. Could anyone help me to get the code.
BTW thanks for the response.

Sure. First, you'll need to install the Agentuino library, which is the most popular SNMP library for Arduino. Download it at storage.googleapis.com/google-code-archive-source/v2/code.google.com/agentuino/source-archive.zip, then extract it and go to agentuino/trunk. Here, you'll find an INSTALL.txt, go ahead and open it up. Follow the instructions, but keep in mind that the Flash, MemoryFree, and Streaming library are all included in that folder. The instructions contain examples to get started. The Streaming library, just FYI, is not what you're probably used to.

Thanks lights0123.
As i verify the code, it shows the following error. Could you please help?

Could you please help?

You need someone else to type "const " between static and char on the highlighted line?

PaulS:
You need someone else to type "const " between static and char on the highlighted line?

Thanks @lights0123. Previous error has been removed but now it shows compiling error i think. Following error is listed..

Arduino: 1.6.8 (Windows 7), Board: "Arduino/Genuino Uno"

Build options changed, rebuilding all
In file included from C:\Users\Saif\AppData\Local\Temp\arduino_modified_sketch_672204\AgentPlus.ino:12:0:

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:55:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:60:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:65:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:70:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:85:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:94:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:105:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:128:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:139:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:163:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:264:2: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:560:2: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:570:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

In file included from C:\Users\Saif\AppData\Local\Temp\arduino_modified_sketch_672204\AgentPlus.ino:13:0:

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:70:23: error: 'prog_char' does not name a type

_FLASH_STRING(const prog_char *arr);

^

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:70:34: error: ISO C++ forbids declaration of 'arr' with no type [-fpermissive]

_FLASH_STRING(const prog_char *arr);

^

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:81:9: error: 'prog_char' does not name a type

const prog_char *access() const

^

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:93:9: error: 'prog_char' does not name a type

const prog_char *_arr;

^

C:\Program Files\Arduino\libraries\Flash-5/Flash.h: In member function 'size_t _FLASH_STRING::length() const':

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:73:21: error: '_arr' was not declared in this scope

{ return strlen_P(_arr); }

^

C:\Program Files\Arduino\libraries\Flash-5/Flash.h: In member function 'char* _FLASH_STRING::copy(char*, size_t, size_t) const':

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:78:20: error: '_arr' was not declared in this scope

strcpy_P(to, _arr + offset) : strncpy_P(to, _arr + offset, size);

^

In file included from C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28:0,

from sketch\AgentPlus.ino.cpp:1:

C:\Program Files\Arduino\libraries\Flash-5/Flash.h: In member function 'char _FLASH_STRING::operator const':

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:88:44: error: '_arr' was not declared in this scope

{ return static_cast(pgm_read_byte(_arr + index)); }

^

In file included from C:\Users\Saif\AppData\Local\Temp\arduino_modified_sketch_672204\AgentPlus.ino:13:0:

C:\Program Files\Arduino\libraries\Flash-5/Flash.h: At global scope:

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:183:29: error: 'prog_char' does not name a type

_FLASH_STRING_ARRAY(const prog_char **arr, size_t count) : _arr(arr), _size(count)

^

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:183:41: error: ISO C++ forbids declaration of 'arr' with no type [-fpermissive]

_FLASH_STRING_ARRAY(const prog_char **arr, size_t count) : _arr(arr), _size(count)

^

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:203:9: error: 'prog_char' does not name a type

const prog_char **_arr;

^

C:\Program Files\Arduino\libraries\Flash-5/Flash.h: In constructor '_FLASH_STRING_ARRAY::_FLASH_STRING_ARRAY(const int**, size_t)':

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:183:62: error: class '_FLASH_STRING_ARRAY' does not have any field named '_arr'

_FLASH_STRING_ARRAY(const prog_char **arr, size_t count) : _arr(arr), _size(count)

^

C:\Program Files\Arduino\libraries\Flash-5/Flash.h: In member function '_FLASH_STRING _FLASH_STRING_ARRAY::operator const':

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:190:26: error: '_arr' was not declared in this scope

{ return _FLASH_STRING(_arr[index]); }

^

C:\Program Files\Arduino\libraries\Flash-5/Flash.h: In member function 'virtual void _FLASH_STRING_ARRAY::print(Print&) const':

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:196:25: error: '_arr' was not declared in this scope

_FLASH_STRING str(_arr*);*

  • ^*
    exit status 1
    Error compiling for board Arduino/Genuino Uno.
    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.

PaulS:
You need someone else to type "const " between static and char on the highlighted line?

Thanks @PaulS for your help. Previous error has been removed but now it shows compiling error i think. Following error is listed..

Arduino: 1.6.8 (Windows 7), Board: "Arduino/Genuino Uno"

Build options changed, rebuilding all
In file included from C:\Users\Saif\AppData\Local\Temp\arduino_modified_sketch_672204\AgentPlus.ino:12:0:

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:55:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:60:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:65:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:70:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:85:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:94:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:105:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:128:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:139:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:163:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:264:2: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:560:2: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

C:\Program Files\Arduino\libraries\Agentuino-master/Agentuino.h:570:1: warning: 'typedef' was ignored in this declaration [enabled by default]

};

^

In file included from C:\Users\Saif\AppData\Local\Temp\arduino_modified_sketch_672204\AgentPlus.ino:13:0:

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:70:23: error: 'prog_char' does not name a type

_FLASH_STRING(const prog_char *arr);

^

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:70:34: error: ISO C++ forbids declaration of 'arr' with no type [-fpermissive]

_FLASH_STRING(const prog_char *arr);

^

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:81:9: error: 'prog_char' does not name a type

const prog_char *access() const

^

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:93:9: error: 'prog_char' does not name a type

const prog_char *_arr;

^

C:\Program Files\Arduino\libraries\Flash-5/Flash.h: In member function 'size_t _FLASH_STRING::length() const':

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:73:21: error: '_arr' was not declared in this scope

{ return strlen_P(_arr); }

^

C:\Program Files\Arduino\libraries\Flash-5/Flash.h: In member function 'char* _FLASH_STRING::copy(char*, size_t, size_t) const':

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:78:20: error: '_arr' was not declared in this scope

strcpy_P(to, _arr + offset) : strncpy_P(to, _arr + offset, size);

^

In file included from C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28:0,

from sketch\AgentPlus.ino.cpp:1:

C:\Program Files\Arduino\libraries\Flash-5/Flash.h: In member function 'char _FLASH_STRING::operator const':

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:88:44: error: '_arr' was not declared in this scope

{ return static_cast(pgm_read_byte(_arr + index)); }

^

In file included from C:\Users\Saif\AppData\Local\Temp\arduino_modified_sketch_672204\AgentPlus.ino:13:0:

C:\Program Files\Arduino\libraries\Flash-5/Flash.h: At global scope:

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:183:29: error: 'prog_char' does not name a type

_FLASH_STRING_ARRAY(const prog_char **arr, size_t count) : _arr(arr), _size(count)

^

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:183:41: error: ISO C++ forbids declaration of 'arr' with no type [-fpermissive]

_FLASH_STRING_ARRAY(const prog_char **arr, size_t count) : _arr(arr), _size(count)

^

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:203:9: error: 'prog_char' does not name a type

const prog_char **_arr;

^

C:\Program Files\Arduino\libraries\Flash-5/Flash.h: In constructor '_FLASH_STRING_ARRAY::_FLASH_STRING_ARRAY(const int**, size_t)':

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:183:62: error: class '_FLASH_STRING_ARRAY' does not have any field named '_arr'

_FLASH_STRING_ARRAY(const prog_char **arr, size_t count) : _arr(arr), _size(count)

^

C:\Program Files\Arduino\libraries\Flash-5/Flash.h: In member function '_FLASH_STRING _FLASH_STRING_ARRAY::operator const':

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:190:26: error: '_arr' was not declared in this scope

{ return _FLASH_STRING(_arr[index]); }

^

C:\Program Files\Arduino\libraries\Flash-5/Flash.h: In member function 'virtual void _FLASH_STRING_ARRAY::print(Print&) const':

C:\Program Files\Arduino\libraries\Flash-5/Flash.h:196:25: error: '_arr' was not declared in this scope

_FLASH_STRING str(_arr*);*

  • ^*
    exit status 1
    Error compiling for board Arduino/Genuino Uno.
    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.

Hi,

SNMP code is successfully uploaded on the arduino uno. I have tried to see the status on Solar wind software but every time i tested, it shows TEST FAILED. Here is the snapshot.. Please guide how to do it.

Thanks.

Are you doing any troubleshooting or investigation?

yes. I am trying.. Am arduino beginner.
Could you please help?

What is the IP address that you used? 10.255.240.20 doesn't sound like a typical local IP address: are you on an enterprise setup? For a home setup, I'd expect 10.0.1.20 or something like that. Are you sure that the IP address, gateway, and subnet are correct? Could you provide a screenshot/copy+paste of Windows' ipconfig or Mac's network settings?

I just read the Agentuino source, and the default port is 161, not 160. In your tester, you need to specify the port as 161. You can change that with this line of code:

void setup()
{
  Serial.begin(9600);
  Ethernet.begin(mac, ip);
  //
  api_status = Agentuino.begin(null,null,160);
  //
  if ( api_status == SNMP_API_STAT_SUCCESS ) {
    //
    Agentuino.onPduReceive(pduReceived);
    //
    delay(10);
    //
    Serial << F("SNMP Agent Initalized...") << endl;
    //
    return;
  }
  //
  delay(10);
  //
  Serial << F("SNMP Agent Initalization Problem...") << status << endl;
}

lights0123:
I just read the Agentuino source, and the default port is 161, not 160. In your tester, you need to specify the port as 161. You can change that with this line of code:

void setup()

{
  Serial.begin(9600);
  Ethernet.begin(mac, ip);
  //
  api_status = Agentuino.begin(null,null,160);
  //
  if ( api_status == SNMP_API_STAT_SUCCESS ) {
    //
    Agentuino.onPduReceive(pduReceived);
    //
    delay(10);
    //
    Serial << F("SNMP Agent Initalized...") << endl;
    //
    return;
  }
  //
  delay(10);
  //
  Serial << F("SNMP Agent Initalization Problem...") << status << endl;
}




Thanks bro. But it shows error "null was not declared in this scope".

Thanks @lights0123. I added the line you mentioned, it shows error "null was not declared in this scope".

Sorry - used to higher-level languages. I read it again, you want

api_status = Agentuino.begin("public","private",160);

@saudkhalid Ping! Just want to make sure you aren't stuck on anything.

Thanks @lights0123. I will continue my working on SNMP arduino in next week and will coordinate with you.

BTW thanks for the help