forked from SolidGeek/VescUart
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to use SoftwareSerial library for communication with VESC
- Loading branch information
Showing
3 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
examples/getVescValuesSoftwareSerial/getVescValuesSoftwareSerial.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
Name: getVescValuesSoftwareSerial.ino | ||
Created: 06-03-2019 | ||
Author: SkewPL | ||
Description: This example shows ability to use SoftwareSerial port to communicate with VESC. Confirmed to be working on ESP8266. | ||
Remember to change the baud rate to a correct value, you can find which baud rate does your VESC use in VESCTool -> UART section. | ||
*/ | ||
|
||
#include <VescUart.h> | ||
#include <SoftwareSerial.h> | ||
|
||
/** Initiate VescUart class */ | ||
VescUart vesc; | ||
|
||
/** Initiate SoftwareSerial class */ | ||
SoftwareSerial vescSerial(13, 15); | ||
|
||
void setup() { | ||
|
||
/** Setup Serial port to display data */ | ||
Serial.begin(9600); | ||
|
||
/** Setup SoftwareSerial port */ | ||
vescSerial.begin(19200); | ||
|
||
/** Define which ports to use as UART */ | ||
vesc.setSerialPort(&vescSerial); | ||
} | ||
|
||
void loop() { | ||
|
||
/** Call the function getVescValues() to acquire data from VESC */ | ||
if ( vesc.getVescValues() ) { | ||
|
||
Serial.println(vesc.data.rpm); | ||
Serial.println(vesc.data.inpVoltage); | ||
Serial.println(vesc.data.ampHours); | ||
Serial.println(vesc.data.tachometerAbs); | ||
|
||
} | ||
else | ||
{ | ||
Serial.println("Failed to get data!"); | ||
} | ||
|
||
delay(50); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters