-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSPortVoltmeter.ino
37 lines (29 loc) · 965 Bytes
/
SPortVoltmeter.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#define F_CPU 16000000
#include <FrSkySportSensor.h>
#include <FrSkySportSensorFlvss.h>
#include <FrSkySportSingleWireSerial.h>
#include <FrSkySportTelemetry.h>
#define VOLTAGE 5.0 // Given in volt
#define VOLTAGE_CONVERSION_FACTOR VOLTAGE/1023
FrSkySportSensorFlvss flvss;
FrSkySportTelemetry telemetry;
/* CONNECTIONS:
* Digital Pin 2: SPort Data
* Analog Pin 0: Battery Balancer 3.7V
* GND connected to either Battery Balancer 0V or SPORT GND
* RAW connected to Batter Balancer 7.4V or higher
*/
#define BATTERY_VOLTAGE_PIN A0
#define SPORT_PIN FrSkySportSingleWireSerial::SOFT_SERIAL_PIN_2
void setup()
{
telemetry.begin(SPORT_PIN, &flvss);
}
void loop()
{
/* DO YOUR STUFF HERE */
/* Make sure you do not do any blocking calls in the loop, e.g. delay()!!! */
int voltageRaw = analogRead(BATTERY_VOLTAGE_PIN);
flvss.setData((float)voltageRaw * VOLTAGE_CONVERSION_FACTOR);
telemetry.send();
}