 	// start acquisition (with double readings to avoid interferences [1])
 	digitalWrite(LED_PIN, HIGH);
 
+
 	// current sensor
 	raw_acs0 = analogRead(A11);		// J5 (pin 2)
 	raw_acs0 = analogRead(A11);		// J5 (pin 2)
 
 	// calculate output is Amps
-	acs0 = (float) (ACS_ZERO - raw_acs0) * ACS714_CONV;
+	//acs0 = (float) (ACS_ZERO - raw_acs0) * ACS714_CONV;
+	acs0 = (float) (raw_acs0 - 202)  * ACS715_CONV;
 
 	// send current report
 	report_current();
 
 
-	// acquisition loop delta
+	// acquisition slow-loop delta
 	delta = millis() - time_iq;
 
 	// limit data rate
-	if( delta > DELTA_IQ ) {
+	if( delta > DELAY_SLOW ) {
 		
 		// analog inputs (battery)
 		raw_bat0 = analogRead(A0);		// J4 (pin 1)

long b5;


// ACS714 current sensor 
//	working in reverse current flow to keep output signal within 0-2.5V range
//	2.5V output is the steady 0A initial reading
float acs0;
int raw_acs0;


// the setup routine runs once when you press reset:
void setup() {
	// disable watchdog, because of [8]
	wdt_disable();

	// not ready
	pinMode(LED_PIN, OUTPUT);
	digitalWrite(LED_PIN, LOW); 

	// while the serial stream is not open, flash the on-board led:
	while(!Serial) {
		digitalWrite(LED_PIN, HIGH);
		delay(DELAY_SETUP);

	SOFTWARE.
*/

// ** LM35 Analog Temperature Sensor
// 	[1]: http://learn.adafruit.com/tmp36-temperature-sensor
//
// ** HIH-4043 Humidity Sensor
// 	[2]: https://www.sparkfun.com/products/9569
// 	[3]: http://bildr.org/2012/11/hih4030-arduino/
// 	[4]: http://forum.arduino.cc/index.php/topic,19961.0.html
//
// ** BMP085 Barometric Pressure Sensor
// 	[5]: https://www.sparkfun.com/products/11282
// 	[6]: https://www.sparkfun.com/tutorials/253
//
//  [7]: http://linux.die.net/man/8/picocom
//  [8]: http://forum.arduino.cc/index.php?topic=128717.0
//  [9]: http://www.nongnu.org/avr-libc/user-manual/group__avr__watchdog.html

#include <avr/wdt.h>
#include <Wire.h>

#define DELAY_SETUP 250         // setup flashing delay
#define DELAY_FAST 500 			// fast acquisition loop
#define DELAY_SLOW 2000 		// slow acquisition loop

// Reference voltages (fine tuned):
//	measured using AREF when the shield is in place and 
//	the Arduino is powered by external power with vehicle
#define ADC_INTERNAL_V 	0.002483f	// manual calibration (was 0.002502f)
#define ADC_INTERNAL_MV 2.483f		// manual calibration (was 2.502f)
#define ADC_DEFAULT_V 0.004887f		// uncalibrated
#define ADC_DEFAULT_MV 4.887f		// uncalibrated

#define LED_PIN 13

#define BAT_R1 24000.0f 		// R1 (ohm)
#define BAT_R2 2200.0f 			// R2 (ohm)

#define LM35_MVC 10.0f			// mV/C
#define ACS715_MVA 133.0f		// mv/A
#define ACS714_MVA 185.0f 		// mv/A

#define BMP085_ADDRESS 0x77		// I2C address
#define BMP085_OSS 0 			// Oversampling Setting
#define BMP_MAX 1000 			// Loop protection (number of loops)

// Voltage Divider (for battery levels)
const float BAT_RK = (BAT_R1 + BAT_R2) / BAT_R2;

// Allegro ACS715 0A to 30A
const float ACS715_CONV = ADC_INTERNAL_MV / ACS715_MVA;			// Amps per ADC level

// Allegro ACS714 current sensor
//const int ACS_ZERO = (int) 2500 / ADC_INTERNAL_MV;			// ADC reading for 2.5V (~ 1007)
//const float ACS714_CONV = ADC_INTERNAL_MV / ACS714_MVA;		// Amps per ADC level

unsigned long time_iq;
unsigned long delta;
