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 Segundo Equipo

Committer:
tsoic
Date:
Fri Nov 20 08:28:11 2015 +0000
Revision:
6:ebbde59c5a1d
Child:
7:1da0a084cd69
Uploading sensor data ( Voltage divider, MAX4172, INA219) over ethernet to Thing Speak service.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tsoic 6:ebbde59c5a1d 1 #include "Sensor.h"
tsoic 6:ebbde59c5a1d 2 #include "mbed.h"
tsoic 6:ebbde59c5a1d 3
tsoic 6:ebbde59c5a1d 4 Sensor::Sensor(PinName sensorPin, float Koef) : sensorInput(sensorPin), K(Koef) {
tsoic 6:ebbde59c5a1d 5 //* Implementacija kontruktora kako bi spojio dani ulazni pin i koeficijent množenja sa privatnim varijablama klase Sensor
tsoic 6:ebbde59c5a1d 6 }
tsoic 6:ebbde59c5a1d 7
tsoic 6:ebbde59c5a1d 8 void Sensor::read() {
tsoic 6:ebbde59c5a1d 9 //* Očitvanje vrijednosti analognom ulaza 10 puta i spremanje vrijednosti u float polje readVal[]
tsoic 6:ebbde59c5a1d 10 readVal[0] = sensorInput;
tsoic 6:ebbde59c5a1d 11
tsoic 6:ebbde59c5a1d 12 }
tsoic 6:ebbde59c5a1d 13
tsoic 6:ebbde59c5a1d 14 float Sensor::calc() {
tsoic 6:ebbde59c5a1d 15 //* Potrebno je postaviti 0 u lokalnu varijablu sum 0kako se u njoj nebi pojavili neki neočekivani brojevi
tsoic 6:ebbde59c5a1d 16
tsoic 6:ebbde59c5a1d 17 realVal = readVal[0]; //* Računanje srednje vrijednosti
tsoic 6:ebbde59c5a1d 18 return realVal *= K; //* Vračanje stvarne vrijednosti za daljnu obradu
tsoic 6:ebbde59c5a1d 19 }
tsoic 6:ebbde59c5a1d 20