![](/media/cache/group/TVZ_logotip.png.50x50_q85.jpg)
Uploading sensor data (voltage divider, MAX4172, INA219) over Ethernet to Thing Speak service. Uses old mbed revision that is compatible with NetServices library. I2C communication is made with I2CR library.
Dependencies: C12832 I2CR INA219 NetServices mbed
Fork of NetServices_HelloWorld by
Diff: Sensor.cpp
- Revision:
- 7:1da0a084cd69
- Parent:
- 6:ebbde59c5a1d
--- a/Sensor.cpp Fri Nov 20 08:28:11 2015 +0000 +++ b/Sensor.cpp Sun Nov 29 13:41:05 2015 +0000 @@ -2,19 +2,13 @@ #include "mbed.h" Sensor::Sensor(PinName sensorPin, float Koef) : sensorInput(sensorPin), K(Koef) { -//* Implementacija kontruktora kako bi spojio dani ulazni pin i koeficijent množenja sa privatnim varijablama klase Sensor + } -void Sensor::read() { - //* Očitvanje vrijednosti analognom ulaza 10 puta i spremanje vrijednosti u float polje readVal[] - readVal[0] = sensorInput; +float Sensor::read() { + readVal[0] = sensorInput; + realVal = readVal[0]; //* Računanje srednje vrijednosti + return realVal *= K; } -float Sensor::calc() { - //* Potrebno je postaviti 0 u lokalnu varijablu sum 0kako se u njoj nebi pojavili neki neočekivani brojevi - - realVal = readVal[0]; //* Računanje srednje vrijednosti - return realVal *= K; //* Vračanje stvarne vrijednosti za daljnu obradu -} -