Remote data logging with Arduino – Bringing it all together…
Now that we have all the pieces, to tie them all togethers we need to configure our Mango M2M server to accept the data from the base unit and do some additional computations on top of those to drive more meaningful information vs just data.
You may want to familiarise yourself with key mango m2m concepts here.
The way i have setup my M2M box is to log raw data point from the arduino, and then to each of those apply the necessary calculations to arrive at the needed information. To do this i have setup two data sources
Contains all data points which are updated by the java application thats acts like the bridge between the base arduino and the mango m2m instance. To set this up :-
1. Add a HTTP Receiver Data source
2. Add Data point
3. Test Data point by http://path to mango/httpds?testKey=testValue
Say the path to your mango instance is http://homeubuntu and your data pointname is rooftemp, and you want to set it to 20.5, the test url will be
Meta Data Source
which uses the data points from the HTTP receiver to convert the RAW reading into required information e.g. RAW ADC point for a NTP resistor to actual temp in Celsius, or the RAW reading from Current Transducer to Power consumption.
- Add a Meta Data source
- Add Data point
- Set parameters of the data point like data type, and update event
- Add point name(s), based on which this data point will be calculated
- Add the calculation script. e.g. following is the script to calculate the temp from a 10K NTP using the RAW reading from the Arduino ADC.
T = 1023-To.past(MINUTE).average; THERMISTORNOMINAL = 10000; // temp. for nominal resistance (almost always 25 C) TEMPERATURENOMINAL = 25; // The beta coefficient of the thermistor (usually 3000-4000) BCOEFFICIENT = 3435; // the value of the 'other' resistor SERIESRESISTOR = 10000; average = 1023.00 / T - 1.00; average = SERIESRESISTOR / average; steinhart = average / THERMISTORNOMINAL; // (R/Ro) steinhart = Math.log(steinhart); // ln(R/Ro) steinhart /= BCOEFFICIENT; // 1/B * ln(R/Ro) steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To) steinhart = 1.0 / steinhart; // Invert steinhart -= 273.15; // convert to C return steinhart ;
to be continued ….