I am a programmer and have only been playing on the electronics side for a couple of years. I am self taught on the electronics side. I am starting to get more involved in micro-controllers and I have encountered this issue several times. I have solved the problem but I am not sure it is the correct way though.
Sensor data being sent to a micro-controller usually provides 100s of samples per second. One of my past projects was a lie dectector, it started off as a just measuring the resistance of the persons skin but evolved to using to a micro-controller based system. It was based off the make magazine "Truth Meter" (
http://makezine.com/projects/the-truth-meter-2). This project helped me to understand filtering and op-amps on the hardware side (circuit). I took the output from the Truth Meter into an Arduino for further processing. I tried to output the data to a LCD as a graph but I could not find a good method to smooth out the data so I just used 5 LEDs to register the changes in the resistance of the person's skin. Worked pretty good could have been better but you have to start somewhere. Now the problem is coming up again in my current project. I am working on a low power ATMEGA 328P wireless sensor. End state is to build basic sensor and test it to make sure my design is working. I then plan on added one of Atmel CryptoAuthentication chips to digitally sign the packets to add another layer of security. Concept is only to accept packets from digitally signed sources. I have been using the EEVBlog battery tutorials to help design the lower power circuit and I would not be where I am with out those tutorials.
I have a pcb on the way that has just engough to run the ATMEGA 328-P off a 3V power source, LEDS, voltage regulator etc gone. I not sure if I will use the Arduino bootloader or not yet. I need to test the power consumption on the base components to determine the best way to power the circuit before I add the power circuit to the design. Which leads me to my issue of smoothing again. I was looking for a way to log voltage and current consumption and the cost of logging multi-meters are to expensive for hobby use. So I am finishing my own data logging circuit using an Arduino and INA219 for current and voltage monitoring. Graphing the raw data the graph is very rough. The data from the INA219 has a range of 0.03 V on a voltage source from a 7805. Current readings have a range of .02 mA.
The method I am using now is collecting a 100 samples and finding the mean then reporting that value as the final result. It takes the Arduino about 500ms to run through all the calculations and push out the results. I delay the program for about 500ms to collect my readings once a second. Am I on the right track or is there a better way? As I move forward and start collecting more data with other sensors I am going to run into this issue again so I am looking the best path forward.
I am slowly pulling way from Arduino bootloader and will end up working with the ATMEGA directly. I have background in assembly programming and have taken a micro-controller class which taught me how to read the data sheets and work with registers and EEPROM. I like working with the chips that way as I had more control and things were very fast. I am slowly adding the hardware I need to program ATMEGA chips without the Arduino bootloader just not there yet. The development board I had to use for the class is the size of a PC motherboard and is too big to work with for everyday use. I am thinking on purchasing the AVR Dragon as my programmer because of the debugging it provides. I have just switched to Atmel Studio for my Arduino programming and love it. The debugging I can do with VisualMicro is so helpful. No more writing debugging code to find out how long a loop takes to run or what my variables are doing.
Any guidance would be helpful - thank you in advance