0

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?

1 Answers1

0

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;
maral
  • 1,431
  • 1
  • 10
  • 15
  • Thank you for your response . Yes I am collecting X & Y accelerometer readings , now I am receiving data in form of X1X2 Y1Y2 where X1,X2,Y1,Y2 are 2 bytes each when i set Nreadings as 2 so I get 4 bytes from each sensor. My purpose is to transmit more data every time a transmission happens . So yes your answer is helpful ! – Adithya Shetty Feb 12 '15 at 21:24