|
|
|
@ -11,13 +11,19 @@
|
|
|
|
|
|
|
|
|
|
#define esc1pin 15
|
|
|
|
|
#define esc2pin 13
|
|
|
|
|
#define fallbackpin 36
|
|
|
|
|
#define voltageEnable 12
|
|
|
|
|
#define voltagePin 36
|
|
|
|
|
#define failsafeValue 127
|
|
|
|
|
#define ONE_WIRE_BUS 14
|
|
|
|
|
#define fanRelais 16
|
|
|
|
|
|
|
|
|
|
#define DELETEBEFOREPAIR 0
|
|
|
|
|
|
|
|
|
|
// Resistors in Ohms
|
|
|
|
|
const float deviderR1 = 1275; // needs to be calibrated carefully using a multimeter because of tolerances of the resistors
|
|
|
|
|
const float deviderR2 = 22000;
|
|
|
|
|
const float refVoltage = 3.3;
|
|
|
|
|
|
|
|
|
|
Servo esc1;
|
|
|
|
|
Servo esc2;
|
|
|
|
|
SSD1306 display(0x3c, 5, 4);
|
|
|
|
@ -194,7 +200,36 @@ void checkTemperature() {
|
|
|
|
|
sendTemperatureDecimals = (temperature - sendTemperature) * 100;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void checkVoltage() {
|
|
|
|
|
digitalWrite(voltageEnable, HIGH);
|
|
|
|
|
Serial.print("Voltage: ");
|
|
|
|
|
int value = analogRead(voltagePin);
|
|
|
|
|
Serial.println(value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float batteryVoltage = 0.0;
|
|
|
|
|
int total = 0;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
|
total += analogRead(voltagePin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
batteryVoltage = (refVoltage / 4095.0) * ((float)total / 10.0);
|
|
|
|
|
// Now we have the actual Voltage, lets calculate the value befor the devider
|
|
|
|
|
batteryVoltage = batteryVoltage / ( deviderR1 / (deviderR1 + deviderR2));
|
|
|
|
|
|
|
|
|
|
sendVoltage = abs(floor(batteryVoltage));
|
|
|
|
|
sendVoltageDecimals = (batteryVoltage - sendVoltage) * 100;
|
|
|
|
|
Serial.print("Voltage: ");
|
|
|
|
|
Serial.println(batteryVoltage);
|
|
|
|
|
digitalWrite(voltageEnable, LOW); // change to low
|
|
|
|
|
delay(5);
|
|
|
|
|
Serial.print("VoltageOFF: ");
|
|
|
|
|
Serial.println(analogRead(voltagePin));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setup() {
|
|
|
|
|
|
|
|
|
|
Serial.begin(115200);
|
|
|
|
|
Serial.println("ESPNowSkate Receiver");
|
|
|
|
|
|
|
|
|
@ -202,6 +237,8 @@ void setup() {
|
|
|
|
|
display.flipScreenVertically();
|
|
|
|
|
display.setFont(ArialMT_Plain_16);
|
|
|
|
|
|
|
|
|
|
pinMode(voltageEnable, OUTPUT);
|
|
|
|
|
|
|
|
|
|
// Init escs, min and max value similar as Traxxas TQI 1100, 1900
|
|
|
|
|
// chanel, minAngel, maxAngel, minPulseWidth, maxPulseWidth
|
|
|
|
|
esc1.attach(esc1pin, 0, 0, 255, 1100, 1900);
|
|
|
|
@ -260,4 +297,5 @@ void loop() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkTemperature();
|
|
|
|
|
checkVoltage();
|
|
|
|
|
}
|
|
|
|
|