When I change Nreadings from 1 to 2 in the oscilloscope header file, I end up getting 4 bytes of data from one sensor. My doubt is whether these 4 bytes are in the form of 2 sets of 2 bytes at different instants? If so should I average these 2 sets before I display them?
The Oscilloscope application samples a sensor every fixed interval (defined as DEFAULT_INTERVAL
in the header file), and as soon as it collects NREADINGS
samples, it sends a packet containing these readings. Then, the readings counter is reset to zero.
So if you change NREADINGS
to 2
, a packet will be sent every two samples (and it will contain two readings). Since a size of a sample is 2 bytes (uint16_t
), this results in 4 bytes of readings data per packet. What you do with such data depends on what you want to achieve. Oscilloscope comes with a Java application that displays data received by the BaseStation application on a graph (see README.txt).
I think that everything is explained in the source code:
/* Number of readings per message. If you increase this, you may have to
increase the message_t size. */
NREADINGS = 10,
And the packet definition:
typedef nx_struct oscilloscope {
nx_uint16_t version; /* Version of the interval. */
nx_uint16_t interval; /* Samping period. */
nx_uint16_t id; /* Mote id of sending mote. */
nx_uint16_t count; /* The readings are samples count * NREADINGS onwards */
nx_uint16_t readings[NREADINGS];
} oscilloscope_t;