Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1.  
  2. #if defined(FLOW_METER)
  3.     //vcc adjustment, since ref 1.1V is not exact
  4.     const float flow_vcc_calibration = 1;
  5. #endif
  6.  
  7. #if defined(FLOW_METER)
  8.  
  9.     //emon1.readVcc() returns vcc in mV compared to internal reference 1.1V voltage
  10.     float vcc = emon1.readVcc() * flow_vcc_calibration / 1000.0;
  11.  
  12.     int f = analogRead(A6);
  13.     float flow_ = f * (vcc / 1023.0);
  14.     int t = analogRead(A7);
  15.     float temp_ = t * (vcc / 1023.0);
  16.  
  17.     float flow = (flow_ - 0.375) / 0.03125;
  18.     float temp = (temp_ - 0.5) / 0.03;
  19.  
  20.     Serial.print("FM");
  21.     Serial.print(flow);
  22.     Serial.print(',');    
  23.     Serial.print(temp);
  24.     Serial.print(',');
  25.    
  26. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement