Go Down

Topic: Agentuino - A lightweight SNMP Agent (Read 6 times) previous topic - next topic

LAVco

#25
Dec 11, 2010, 02:12 am Last Edit: Dec 11, 2010, 01:42 pm by LAVco Reason: 1
yesyes:

You mentioned that you are using SNMP to read data from your arduino weather station.  Are the sensors read using non-blocking calls?  Simple test is to place a timer variable at the beginning of your loop and see how long it take to cycle without making an SNMP call.  This may explain why there is latency between SNMP requests.  

I am using a Sensirion SHT?? (Temp/RH) and Intersema BP sensor both over serial or bit bang (together and plan on adding a second BP sensor)) and I don't have a latency problem.  Keep mind that both libraries I have written for these sensors have non-blocking capabilities.

And yes the library does detect non-snmp packets, although there is always room to improve on the implemented method.

arduku:

Myself and John D. have been busy (work pays and this doesn't he he) since we started the project and orbitalair is hardware stricken till he can get a new ethernet sheild or port an ethernet lib.   Although it seems that the wiznet and other chipsets have become the arduino standard.  Anyway hopefully Santa comes through for orbitalair and drops off a new ethernet shield :)

I do intend on spending more time on this project in the new year as it ties into another project I am working on.  

As per the project's web site (http://code.google.com/p/agentuino/); this is an Alpha library and were looking for others to contribute.
Common sense is not so common...

LAVco

Quote
Alcor wrote;
Please excuse the thread intrerruption and the newbie question: Can i use the SNMP agent code to make the arduino a SNMP host? I want to read some values from a router and output a PWM signal from the arduino based on them.

Yes, you could use code from agentuino to talk to a host.  Instead of listening, your requesting and waiting for a response.  In theory the PDU can be used interchangeably.

If you decide to cut code and get it working please share your findings with us.

Regards,

Eric
Common sense is not so common...

yesyes

LAVco, I use blocking calls when reading the sensors. But I don't read them when an SNMP request comes in. I read the Melexis temperature sensor continuously once per loop(). I've added a SHT15 last night and that is being read at least 10 seconds after the previous read (to stop it from getting warm and mess up my readings). The values are stored in global variables. When the SNMP request comes in, it  just replies with the value from the variable.

I have put everything back outside now collecting data. So I can't change code right now (I wish there was a way to update the sketch via the Eth shield instead of USB). Will try it as soon as I bring it in for "maintenance" again or as soon as my 2nd Arduino arrives (which ever is sooner).


I'm really glad you made this library. I'd like to contribute but I'm not a good programmer. I do know some C / C++ and have written small MFC apps on Windows. So the Arduino API feels a bit familiar. But I'm not sure what I could contribute. Maybe some testing?

I still think there is some sort of issue in agentuino when a non-SNMP packet is received. When I call Agentuino.listen() and there was a packet received, I HAVE to send a response packet back, otherwise it will end up in an endless loop trying to process the previous packet.


Another question:

Can you think of any way of supporting a float data type in agentuino? I'd like to send my temperature data with one or 2 decimal places. Currently you only seem to have some integers and strings.
Chris

Location: Berkshire, UK
My Astro and DIY projects website: http://yesyes.info/

LAVco

#28
Dec 15, 2010, 11:24 pm Last Edit: Dec 16, 2010, 12:36 am by LAVco Reason: 1
Quote
yesyes wrote;
Can you think of any way of supporting a float data type in agentuino? I'd like to send my temperature data with one or 2 decimal places. Currently you only seem to have some integers and strings.

SNMP doesn't support floating points.  Strings are possible as per included example e.g. sysName and sysDescr but read the limitations section on our main project page.

Now back to floating point values, as the saying goes, there is more than one way to skin a cat!  Use multipliers and divisors.

Know what your measuring; based on the sensor and parameter being measured there is always a max/min range and resolution that it can measure.  So let's use Temperature and RH as an example.  Say the sensor measures temperature from 70 deg C to -40 deg C and RH from 0 to 100 %.

INT is 65535 (unsigned 16bit int) but it can handle signed values as well -32000 to 32000 (approximation but a 16bit float)

Temperature:
70.00 (upper range) = 7000 (x100)
-40.00 (lower range) = 4000 (x100)

To normalize this further for other types of sensors (some can measure down to -50 deg C etc.) we could simply use 10,000 (max upper range) and -10,000 (min lower range) having an error value of 10,001.  So if the system detects an out of bound measurement (out of range of the sensor's parameter being measured) you can flag it as an error.  So if you receive an SNMP value of 2345, simply divide by 100 to get 23.45 deg C.

RH (floating point with RH is rarely used due to the type of measurement - it's relative :) )
0 (lower range) = 0
100 (upper range) = 100

RH is always 0 to 100 (%) and again you could use 101 to reflect an error.

Resolution; if the sensor's parameter's resolution is only 0.1, your not adding accuracy by offering a resolution of 0.01.

The error codes aren't required and are used as basic QA/QC (meteorological QA/QC is a whole other subject).

On the string side, are you sure you need strings e.g. you can use enumerators in SNMP which consume an INT value versus a string (in the MCU wold that's needless memory consumption).  For example, Precipitation Situation; 1-Light Rain, 2-Moderate Rain, 3-Heavy Rain.

Quote
I read the Melexis temperature sensor continuously once per loop

You don't need to sample that frequently for meteorological related applications.  As per WMO/NWS standards it is recommended to sample air temperature at either 3 or 5 second intervals and is averaged over 1-minute.  Soil temperature is sampled every minute due to the slow rate of change.

Hope this shed's some light on measurements using SNMP.  The above examples are methodologies used in existing meteorological standards that I have been involved with.

Regards,

Eric
Common sense is not so common...

yesyes

Thanks for that. I did think of that way of doing it. But (at least for now) for me the only purpose of using SNMP is to graph (and store) the data with Cacti. And that doesn't seem to have an option to divide received data by 10 or 100. At least none that I could find. I'll have a poke around. Maybe a Cacti script could help.

I only mentioned the strings because you already support them. I won't use them other than for the standard system name and so on. They are hard to graph .. :P

In the end this weather station will go in my observatory (a roll-off roof shed with a telescope inside), record weather data and warn me when there's cloud and rain. And eventually close the roof when it starts raining. But that's not even built yet... ;)
Chris

Location: Berkshire, UK
My Astro and DIY projects website: http://yesyes.info/

Go Up