gistfile1.txt
· 15 KiB · Text
原始檔案
====
int powerPin = 5;
byte messageA[] = {0xA6, 0x12, 0x02, 0x10, 0x14, 0xCF};
byte messageB[] = {0xA6, 0x12, 0x02, 0x11, 0x14, 0x0B};
byte messageC[] = {0xA6, 0x12, 0x02, 0x89, 0x01, 0x1C};
====
byte messageD[] = {0xA6, 0x12, 0x02, 0x85, 0x24, 0x4D}; // CHANGE LOOP TO MODIFY AND TEST
====
===
byte messageC[] = {0xA6, 0x12, 0x02, 0XF5, 0xE4, 0x31}; // LIGHT ON & ESC ON & KPH & MAX SPEED
===
How did you figure out the 0xA6, 0x12, 0x02, 0x85, 0x24, 0x4D command? Really how did you discover the 0x24 portion. I tried a lot of different numbers in the fifth location with no luck?
===
#include <Arduino.h>
int powerPin = 5;
byte messageA[] = {0xA6, 0x12, 0x02, 0x10, 0x14, 0xCF}; // MAKES HEADLIGHT BLINK ONCE
byte messageB[] = {0xA6, 0x12, 0x02, 0XE1, 0x14, 0x92}; // LIGHT OFF & ESC ON & MPH & SLOW
byte messageC[] = {0xA6, 0x12, 0x02, 0XE3, 0x14, 0x03}; // LIGHT Flash & ESC ON & MPH & SLOW
byte messageD[] = {0xA6, 0x12, 0x02, 0XE5, 0x14, 0xA9}; // LIGHT ON & ESC ON & MPH & SLOW
byte messageE[] = {0xA6, 0x12, 0x02, 0XE1, 0xE4, 0xE6}; // LIGHT OFF & ESC ON & MPH & FAST
byte messageF[] = {0xA6, 0x12, 0x02, 0XE3, 0xE4, 0x77}; // LIGHT Flash & ESC ON & MPH & Fast
byte messageG[] = {0xA6, 0x12, 0x02, 0XE5, 0xE4, 0xDD}; // LIGHT ON & ESC ON & MPH & FAST
byte messageH[] = {0xA6, 0x12, 0x02, 0XF1, 0x14, 0x7E}; // LIGHT OFF & ESC ON & KPH & SLOW
byte messageI[] = {0xA6, 0x12, 0x02, 0XF3, 0x14, 0xEF}; // LIGHT Flash & ESC ON & KPH & SLOW
byte messageJ[] = {0xA6, 0x12, 0x02, 0XF5, 0x14, 0x45}; // LIGHT ON & ESC ON & KPH & SLOW
byte messageK[] = {0xA6, 0x12, 0x02, 0XF1, 0xE4, 0x0A}; // LIGHT OFF & ESC ON & KPH & FAST
byte messageL[] = {0xA6, 0x12, 0x02, 0XF3, 0xE4, 0x9B}; // LIGHT Flash & ESC ON & KPH & Fast
byte messageM[] = {0xA6, 0x12, 0x02, 0XF5, 0xE4, 0x31}; // LIGHT ON & ESC ON & KPH & FAST
void setup() {
// initialize Serial1:
Serial.begin(9600);
pinMode(powerPin, OUTPUT);
digitalWrite(powerPin, HIGH);
Serial.write(messageA, sizeof(messageA));
delay(500);
}
void loop() {
delay(500);
// Pick what ever driving profile you want and remove the "//" to make that part of the code active
//Serial.write(messageB, sizeof(messageB));
//Serial.write(messageC, sizeof(messageC));
//Serial.write(messageD, sizeof(messageD));
//Serial.write(messageE, sizeof(messageE));
//Serial.write(messageF, sizeof(messageF));
//Serial.write(messageG, sizeof(messageG));
//Serial.write(messageH, sizeof(messageH));
//Serial.write(messageI, sizeof(messageI));
//Serial.write(messageJ, sizeof(messageJ));
//Serial.write(messageK, sizeof(messageK));
//Serial.write(messageL, sizeof(messageL));
//Serial.write(messageM, sizeof(messageM));
}
===
Found in hex dump:
"0xa6,0x12,0x2,0x95,0x1,0xbd"
"0xa6,0x12,0x2,0x91,0x1,0x86"
The reason I mentioned 3-6 occurences is that one of the matches contains coming four sequences in one straight sequence.
0xa6,0x12,0x2,0x90,0x1,0x42,0xa6,0x12,0x2,0x89,0x1,0x1c,0xa6,0x12,0x2,0x8d,0x1,0x27,0xa6,0x12,0x2,0xf2,0x1,0x89
===
conclusoes:
Lights:
ON -- A6 12 02 8D 01 27
OFF -- A6 12 02 89 01 1C
Sound:
CONFIRMCAO ?? A6 12 02 90 01 42
R2D2 -- A6 12 02 89 01 1C
ESC:
?? A6 12 02 F2 01 89
?? A6 12 02 A9 01 DD
?? A6 11 01 80 01 42
===
Ok, so I got my ES-200G running yesterday.
I reach 37km/h on freewheel, haven't tested with load yet since my scoot is in a thousand pieces on my workbench.
These are the codes I used:
{0xA6, 0x12, 0x02, 0x10, 0x14, 0xCF} - boot the scooter, lights on, km/h, sent once at startup
{0xA6, 0x12, 0x02, 0XF5, 0xE4, 0x31} - this is sent every 500ms
===
#include <FastCRC.h>
FastCRC8 CRC8;
bool firstdigit = 0; //Still unknown function
bool seconddigit = 0; //Still unknown function
bool fastAcceleration = 1; //1 for on, 0 for off
bool KPH = 1; //1 for KPH, 0 for MPH
bool fifthdigit = 0; //Still unknown function
bool Light = 1; //1 for on, 0 for off
bool LightBlink = 0; //1 for on, 0 for off
bool ESCOn = 1; //1 for on, 0 for off
int SpeedLimit = 255; //Beetwen 0 and 255
int forth = 0;
byte buf[6] = {0xA6, 0x12, 0x02};
void setup() {
Serial.begin(9600);
calculateforth();
buf[3] = forth;
buf[4] = SpeedLimit;
buf[5] = CRC8.maxim(buf, 5);
}
void loop() {
Serial.write(buf, sizeof(buf));
delay(500);
}
void calculateforth() {
if (firstdigit == 1){
forth = forth + 128;
}
if (seconddigit == 1){
forth = forth + 64;
}
if (fastAcceleration == 1){
forth = forth + 32;
}
if (KPH == 1){
forth = forth + 16;
}
if (fifthdigit == 1){
forth = forth + 8;
}
if (Light == 1){
forth = forth + 4;
}
if (LightBlink == 1){
forth = forth + 2;
}
if (ESCOn == 1){
forth++;
}
}
===
or take several diodes in throughput direction in series, works also. (500-700mV per regular silicon diode)
There will be no big current and therefore no big in rush at all. The biggest option would be when using a ESP32 for example but even that chips doesn't draw more than 200mA @ 3,3V. The LM2596 has a converting efficiency around 94% plus it takes approximately 5-8mA to power itself so if you lower the input voltage about 10V we're talking about 17-32 volt to the regulator what is within its operating range. 200mA @ 3,3V= 660mW, 660mW divided by 0.94~=702.1mW, for the highest current we take 17V as lowest case so 702.1mW divided by 17V = 4,13mA, 4,13ma plus 8mA selfpower is 12,13mA, 10V diodes loss times 12,13mA = 121,3mW loss in heat on the diode when powering a ESP32 in full load giving approximately 88% safety factor when using a 10V 1W type.
Cheers
===
// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__ESP32CORE_BLE
#include <RemoteXY.h>
// RemoteXY connection settings
#define REMOTEXY_BLUETOOTH_NAME "Your Scooter"
#define REMOTEXY_ACCESS_PASSWORD "password"
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
{ 255,4,0,0,0,155,0,8,8,1,
2,0,6,16,22,11,4,26,31,31,
79,78,0,79,70,70,0,129,0,8,
8,18,6,16,80,111,119,101,114,0,
2,0,36,18,18,8,1,26,31,31,
79,78,0,79,70,70,0,129,0,39,
10,12,6,16,70,97,115,116,0,3,
3,13,48,9,25,3,26,129,0,14,
38,15,6,16,76,105,103,104,116,0,
129,0,27,49,8,6,16,79,110,0,
129,0,27,58,9,6,16,79,102,102,
0,129,0,27,66,24,6,16,66,108,
105,110,107,105,110,103,0,2,0,7,
89,14,7,14,26,31,31,79,78,0,
79,70,70,0,129,0,24,90,28,5,
16,79,84,65,32,85,112,100,97,116,
101,0 };
// this structure defines all the variables of your control interface
struct {
// input variable
uint8_t switch_1; // =1 if switch ON and =0 if OFF
uint8_t speed_switch; // =1 if switch ON and =0 if OFF
uint8_t select_1; // =0 if select position A, =1 if position B, =2 if position C, ...
uint8_t ota_update; // =1 if switch ON and =0 if OFF
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
/**
httpUpdate.ino
Created on: 27.11.2015
*/
#include <Arduino.h>
#include <WiFi.h>
#include <WiFiMulti.h>
#include <ArduinoOTA.h>
#include <HTTPClient.h>
#include <HTTPUpdate.h>
const char* ssid = "SSID";
const char* password = "PASSWORD";
byte slow[] = {0xA6, 0x12, 0x02, 0x35, 0x14, 0xF1}; // Speed Limit to 20 km/h
byte fast[] = {0xA6, 0x12, 0x02, 0x35, 0xFF, 0x38}; // Maximum Speed
byte off[] = {0xA6, 0x12, 0x02, 0x00, 0xFF, 0xEA};
byte fast_stealth[] = {0xA6, 0x12, 0x02, 0x31, 0xFF, 0x03};
byte fast_blinking[] = {0xA6, 0x12, 0x02, 0x33, 0xFF, 0x92};
byte slow_stealth[] = {0xA6, 0x12, 0x02, 0x31, 0x14, 0xCA};
byte slow_blinking[] = {0xA6, 0x12, 0x02, 0x33, 0x14, 0x5B};
int run_once = 0;
void setup() {
Serial.begin(9600);
RemoteXY_Init ();
}
void loop() {
ArduinoOTA.handle();
if((RemoteXY.ota_update == 1) && (run_once == 0))
{
Serial.println("Booting");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("Connection Failed! Rebooting...");
delay(5000);
ESP.restart();
}
// Port defaults to 8266
// ArduinoOTA.setPort(8266);
// Hostname defaults to esp8266-[ChipID]
ArduinoOTA.setHostname("Your Scooter");
// No authentication by default
ArduinoOTA.setPassword((const char *)"password");
ArduinoOTA.onStart([]() {
Serial.println("Start");
});
ArduinoOTA.onEnd([]() {
Serial.println("\nEnd");
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
});
ArduinoOTA.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
else if (error == OTA_END_ERROR) Serial.println("End Failed");
});
ArduinoOTA.begin();
Serial.println("Ready");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
run_once = 1;
}
if((RemoteXY.ota_update == 0) && (run_once == 0))
{
RemoteXY_Handler ();
if((RemoteXY.switch_1 == 1) && (RemoteXY.speed_switch == 0) && (RemoteXY.select_1 == 0))
{
Serial.write(slow, sizeof(slow));
}
else if((RemoteXY.switch_1 == 1) && (RemoteXY.speed_switch == 0) && (RemoteXY.select_1 == 1))
{
Serial.write(slow_stealth, sizeof(slow_stealth));
}
else if((RemoteXY.switch_1 == 1) && (RemoteXY.speed_switch == 0) && (RemoteXY.select_1 == 2))
{
Serial.write(slow_blinking, sizeof(slow_blinking));
}
else if((RemoteXY.switch_1 == 1) && (RemoteXY.speed_switch == 1) && (RemoteXY.select_1 == 0))
{
Serial.write(fast, sizeof(fast));
}
else if((RemoteXY.switch_1 == 1) && (RemoteXY.speed_switch == 1) && (RemoteXY.select_1 == 1))
{
Serial.write(fast_stealth, sizeof(fast_stealth));
}
else if((RemoteXY.switch_1 == 1) && (RemoteXY.speed_switch == 1) && (RemoteXY.select_1 == 2))
{
Serial.write(fast_blinking, sizeof(fast_blinking));
}
else
{
Serial.write(off, sizeof(off));
}
delay(200);
}
}
===
/*
-- VOI Controller --
This source code of graphical user interface
has been generated automatically by RemoteXY editor.
To compile this code using RemoteXY library 2.4.3 or later version
download by link http://remotexy.com/en/library/
To connect using RemoteXY mobile app by link http://remotexy.com/en/download/
- for ANDROID 4.5.1 or later version;
- for iOS 1.4.1 or later version;
This source code is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
*/
//////////////////////////////////////////////
// RemoteXY include library //
//////////////////////////////////////////////
// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__ESP32CORE_BLE
#include <RemoteXY.h>
#include <Arduino.h>
// RemoteXY connection settings
#define REMOTEXY_BLUETOOTH_NAME "VOI Controller V3"
//#define REMOTEXY_ACCESS_PASSWORD "password" //dont work for me -> why?
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
{ 255,4,0,0,0,151,0,10,52,1,
2,1,12,22,39,7,52,8,31,31,
80,111,119,101,114,0,83,104,117,116,
32,100,111,119,110,0,2,1,12,34,
39,7,52,8,31,31,70,97,115,116,
32,115,112,101,101,100,0,83,108,111,
119,32,83,112,101,101,100,0,129,0,
7,4,49,6,16,86,79,73,32,67,
111,110,116,114,111,108,108,101,114,32,
86,51,0,2,1,12,46,39,7,52,
8,31,31,76,105,103,104,116,115,32,
111,110,0,76,105,103,104,116,115,32,
111,102,102,0,2,1,12,58,39,7,
52,8,31,31,80,111,119,101,114,32,
86,79,73,0,83,104,117,116,32,100,
111,119,110,32,86,79,73,0 };
// this structure defines all the variables and events of your control interface
struct {
// input variables
uint8_t switch_power; // =1 if switch ON and =0 if OFF
uint8_t switch_fastspeed; // =1 if switch ON and =0 if OFF
uint8_t switch_light; // =1 if switch ON and =0 if OFF
uint8_t switch_powervoi; // =1 if switch ON and =0 if OFF
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
////////////////////////////////////////////
// Scooter Command include //
///////////////////////////////////////////
byte slowvoi[] = {0xA6, 0x12, 0x02, 0x65, 0x14, 0x86}; // Speed Limit to 20 km/h (tested on voi by mayaku)
byte slow1[] = {0xA6, 0x12, 0x02, 0XF1, 0x14, 0x7E}; // LIGHT OFF & ESC ON & KPH & SLOW (tested by Wileok)
byte slow2[] = {0xA6, 0x12, 0x02, 0XF5, 0x14, 0x45}; // LIGHT ON & ESC ON & KPH & SLOW (tested by Wileok)
byte fastvoi[] = {0xA6, 0x12, 0x02, 0x35, 0xFF, 0x38}; // Maximum Speed (tested on voi by mayaku)
byte fast1[] = {0xA6, 0x12, 0x02, 0XF1, 0xE4, 0x0A}; // LIGHT OFF & ESC ON & KPH & FAST (tested by Wileok)
byte fast2[] = {0xA6, 0x12, 0x02, 0XF5, 0xE4, 0x31}; // LIGHT ON & ESC ON & KPH & FAST (tested by Wileok)
byte off[] = {0xA6, 0x12, 0x02, 0x00, 0xFF, 0xEA}; //Off (tested on voi by mayaku)
void setup()
{
RemoteXY_Init ();
Serial.begin(9600);
}
void loop()
{
RemoteXY_Handler ();
if((RemoteXY.switch_power == 1) && (RemoteXY.switch_fastspeed == 0) && (RemoteXY.switch_light == 0)) //light off + slow
{
Serial.write(slow1, sizeof(slow1));
}
else if((RemoteXY.switch_power == 1) && (RemoteXY.switch_fastspeed) == 0 && (RemoteXY.switch_light == 1)) //light on + slow
{
Serial.write(slow2, sizeof(slow2));
}
else if((RemoteXY.switch_power == 1) && (RemoteXY.switch_fastspeed) == 1 && (RemoteXY.switch_light == 0)) //light off + fast
{
Serial.write(fast1, sizeof(fast1));
}
else if((RemoteXY.switch_power == 1) && (RemoteXY.switch_fastspeed) == 1 && (RemoteXY.switch_light == 1)) //light on + fast
{
Serial.write(fast2, sizeof(fast2));
}
else if((RemoteXY.switch_power == 1) && (RemoteXY.switch_fastspeed) == 0 && (RemoteXY.switch_powervoi == 1)) //voi slow + light???
{
Serial.write(slowvoi, sizeof(slowvoi));
}
else if((RemoteXY.switch_power == 1) && (RemoteXY.switch_fastspeed) == 1 && (RemoteXY.switch_powervoi == 1)) //voi fast + light???
{
Serial.write(fastvoi, sizeof(fastvoi));
}
else
{
Serial.write(off, sizeof(off));
}
delay(200);
}
===
Max speed:
#include <Arduino.h>
int powerPin = 5;
byte messageA[] = {0xA6, 0x12, 0x02, 0x10, 0x14, 0xCF};
byte messageB[] = {0xA6, 0x12, 0x02, 0x11, 0x14, 0x0B};
byte messageC[] = {0xA6, 0x12, 0x02, 0x35, 0xFF, 0x38};
void setup() {
// initialize Serial:
Serial.begin(9600);
pinMode(powerPin, OUTPUT);
digitalWrite(powerPin, HIGH);
}
void loop() {
delay(500);
Serial.write(messageC, sizeof(messageC));
}
===
Niebieski - 13 (3v3)
Zielony - 17
Głośnik - 26
==
| 1 | ==== |
| 2 | int powerPin = 5; |
| 3 | byte messageA[] = {0xA6, 0x12, 0x02, 0x10, 0x14, 0xCF}; |
| 4 | byte messageB[] = {0xA6, 0x12, 0x02, 0x11, 0x14, 0x0B}; |
| 5 | byte messageC[] = {0xA6, 0x12, 0x02, 0x89, 0x01, 0x1C}; |
| 6 | |
| 7 | ==== |
| 8 | byte messageD[] = {0xA6, 0x12, 0x02, 0x85, 0x24, 0x4D}; // CHANGE LOOP TO MODIFY AND TEST |
| 9 | ==== |
| 10 | === |
| 11 | byte messageC[] = {0xA6, 0x12, 0x02, 0XF5, 0xE4, 0x31}; // LIGHT ON & ESC ON & KPH & MAX SPEED |
| 12 | |
| 13 | === |
| 14 | How did you figure out the 0xA6, 0x12, 0x02, 0x85, 0x24, 0x4D command? Really how did you discover the 0x24 portion. I tried a lot of different numbers in the fifth location with no luck? |
| 15 | === |
| 16 | #include <Arduino.h> |
| 17 | |
| 18 | int powerPin = 5; |
| 19 | byte messageA[] = {0xA6, 0x12, 0x02, 0x10, 0x14, 0xCF}; // MAKES HEADLIGHT BLINK ONCE |
| 20 | |
| 21 | byte messageB[] = {0xA6, 0x12, 0x02, 0XE1, 0x14, 0x92}; // LIGHT OFF & ESC ON & MPH & SLOW |
| 22 | byte messageC[] = {0xA6, 0x12, 0x02, 0XE3, 0x14, 0x03}; // LIGHT Flash & ESC ON & MPH & SLOW |
| 23 | byte messageD[] = {0xA6, 0x12, 0x02, 0XE5, 0x14, 0xA9}; // LIGHT ON & ESC ON & MPH & SLOW |
| 24 | |
| 25 | byte messageE[] = {0xA6, 0x12, 0x02, 0XE1, 0xE4, 0xE6}; // LIGHT OFF & ESC ON & MPH & FAST |
| 26 | byte messageF[] = {0xA6, 0x12, 0x02, 0XE3, 0xE4, 0x77}; // LIGHT Flash & ESC ON & MPH & Fast |
| 27 | byte messageG[] = {0xA6, 0x12, 0x02, 0XE5, 0xE4, 0xDD}; // LIGHT ON & ESC ON & MPH & FAST |
| 28 | |
| 29 | byte messageH[] = {0xA6, 0x12, 0x02, 0XF1, 0x14, 0x7E}; // LIGHT OFF & ESC ON & KPH & SLOW |
| 30 | byte messageI[] = {0xA6, 0x12, 0x02, 0XF3, 0x14, 0xEF}; // LIGHT Flash & ESC ON & KPH & SLOW |
| 31 | byte messageJ[] = {0xA6, 0x12, 0x02, 0XF5, 0x14, 0x45}; // LIGHT ON & ESC ON & KPH & SLOW |
| 32 | |
| 33 | byte messageK[] = {0xA6, 0x12, 0x02, 0XF1, 0xE4, 0x0A}; // LIGHT OFF & ESC ON & KPH & FAST |
| 34 | byte messageL[] = {0xA6, 0x12, 0x02, 0XF3, 0xE4, 0x9B}; // LIGHT Flash & ESC ON & KPH & Fast |
| 35 | byte messageM[] = {0xA6, 0x12, 0x02, 0XF5, 0xE4, 0x31}; // LIGHT ON & ESC ON & KPH & FAST |
| 36 | |
| 37 | |
| 38 | void setup() { |
| 39 | // initialize Serial1: |
| 40 | Serial.begin(9600); |
| 41 | pinMode(powerPin, OUTPUT); |
| 42 | digitalWrite(powerPin, HIGH); |
| 43 | Serial.write(messageA, sizeof(messageA)); |
| 44 | delay(500); |
| 45 | } |
| 46 | |
| 47 | void loop() { |
| 48 | delay(500); |
| 49 | // Pick what ever driving profile you want and remove the "//" to make that part of the code active |
| 50 | |
| 51 | //Serial.write(messageB, sizeof(messageB)); |
| 52 | //Serial.write(messageC, sizeof(messageC)); |
| 53 | //Serial.write(messageD, sizeof(messageD)); |
| 54 | //Serial.write(messageE, sizeof(messageE)); |
| 55 | //Serial.write(messageF, sizeof(messageF)); |
| 56 | //Serial.write(messageG, sizeof(messageG)); |
| 57 | //Serial.write(messageH, sizeof(messageH)); |
| 58 | //Serial.write(messageI, sizeof(messageI)); |
| 59 | //Serial.write(messageJ, sizeof(messageJ)); |
| 60 | //Serial.write(messageK, sizeof(messageK)); |
| 61 | //Serial.write(messageL, sizeof(messageL)); |
| 62 | //Serial.write(messageM, sizeof(messageM)); |
| 63 | } |
| 64 | === |
| 65 | Found in hex dump: |
| 66 | "0xa6,0x12,0x2,0x95,0x1,0xbd" |
| 67 | |
| 68 | "0xa6,0x12,0x2,0x91,0x1,0x86" |
| 69 | |
| 70 | The reason I mentioned 3-6 occurences is that one of the matches contains coming four sequences in one straight sequence. |
| 71 | 0xa6,0x12,0x2,0x90,0x1,0x42,0xa6,0x12,0x2,0x89,0x1,0x1c,0xa6,0x12,0x2,0x8d,0x1,0x27,0xa6,0x12,0x2,0xf2,0x1,0x89 |
| 72 | === |
| 73 | conclusoes: |
| 74 | |
| 75 | Lights: |
| 76 | ON -- A6 12 02 8D 01 27 |
| 77 | OFF -- A6 12 02 89 01 1C |
| 78 | |
| 79 | |
| 80 | Sound: |
| 81 | CONFIRMCAO ?? A6 12 02 90 01 42 |
| 82 | R2D2 -- A6 12 02 89 01 1C |
| 83 | |
| 84 | ESC: |
| 85 | |
| 86 | ?? A6 12 02 F2 01 89 |
| 87 | ?? A6 12 02 A9 01 DD |
| 88 | ?? A6 11 01 80 01 42 |
| 89 | === |
| 90 | Ok, so I got my ES-200G running yesterday. |
| 91 | I reach 37km/h on freewheel, haven't tested with load yet since my scoot is in a thousand pieces on my workbench. |
| 92 | |
| 93 | These are the codes I used: |
| 94 | |
| 95 | {0xA6, 0x12, 0x02, 0x10, 0x14, 0xCF} - boot the scooter, lights on, km/h, sent once at startup |
| 96 | {0xA6, 0x12, 0x02, 0XF5, 0xE4, 0x31} - this is sent every 500ms |
| 97 | === |
| 98 | #include <FastCRC.h> |
| 99 | |
| 100 | FastCRC8 CRC8; |
| 101 | |
| 102 | bool firstdigit = 0; //Still unknown function |
| 103 | bool seconddigit = 0; //Still unknown function |
| 104 | bool fastAcceleration = 1; //1 for on, 0 for off |
| 105 | bool KPH = 1; //1 for KPH, 0 for MPH |
| 106 | bool fifthdigit = 0; //Still unknown function |
| 107 | bool Light = 1; //1 for on, 0 for off |
| 108 | bool LightBlink = 0; //1 for on, 0 for off |
| 109 | bool ESCOn = 1; //1 for on, 0 for off |
| 110 | int SpeedLimit = 255; //Beetwen 0 and 255 |
| 111 | |
| 112 | |
| 113 | int forth = 0; |
| 114 | byte buf[6] = {0xA6, 0x12, 0x02}; |
| 115 | |
| 116 | void setup() { |
| 117 | Serial.begin(9600); |
| 118 | calculateforth(); |
| 119 | buf[3] = forth; |
| 120 | buf[4] = SpeedLimit; |
| 121 | buf[5] = CRC8.maxim(buf, 5); |
| 122 | } |
| 123 | |
| 124 | |
| 125 | void loop() { |
| 126 | Serial.write(buf, sizeof(buf)); |
| 127 | delay(500); |
| 128 | } |
| 129 | |
| 130 | void calculateforth() { |
| 131 | if (firstdigit == 1){ |
| 132 | forth = forth + 128; |
| 133 | } |
| 134 | if (seconddigit == 1){ |
| 135 | forth = forth + 64; |
| 136 | } |
| 137 | if (fastAcceleration == 1){ |
| 138 | forth = forth + 32; |
| 139 | } |
| 140 | if (KPH == 1){ |
| 141 | forth = forth + 16; |
| 142 | } |
| 143 | if (fifthdigit == 1){ |
| 144 | forth = forth + 8; |
| 145 | } |
| 146 | if (Light == 1){ |
| 147 | forth = forth + 4; |
| 148 | } |
| 149 | if (LightBlink == 1){ |
| 150 | forth = forth + 2; |
| 151 | } |
| 152 | if (ESCOn == 1){ |
| 153 | forth++; |
| 154 | } |
| 155 | } |
| 156 | === |
| 157 | or take several diodes in throughput direction in series, works also. (500-700mV per regular silicon diode) |
| 158 | There will be no big current and therefore no big in rush at all. The biggest option would be when using a ESP32 for example but even that chips doesn't draw more than 200mA @ 3,3V. The LM2596 has a converting efficiency around 94% plus it takes approximately 5-8mA to power itself so if you lower the input voltage about 10V we're talking about 17-32 volt to the regulator what is within its operating range. 200mA @ 3,3V= 660mW, 660mW divided by 0.94~=702.1mW, for the highest current we take 17V as lowest case so 702.1mW divided by 17V = 4,13mA, 4,13ma plus 8mA selfpower is 12,13mA, 10V diodes loss times 12,13mA = 121,3mW loss in heat on the diode when powering a ESP32 in full load giving approximately 88% safety factor when using a 10V 1W type. |
| 159 | Cheers |
| 160 | === |
| 161 | // RemoteXY select connection mode and include library |
| 162 | #define REMOTEXY_MODE__ESP32CORE_BLE |
| 163 | |
| 164 | #include <RemoteXY.h> |
| 165 | |
| 166 | // RemoteXY connection settings |
| 167 | #define REMOTEXY_BLUETOOTH_NAME "Your Scooter" |
| 168 | #define REMOTEXY_ACCESS_PASSWORD "password" |
| 169 | |
| 170 | |
| 171 | // RemoteXY configurate |
| 172 | #pragma pack(push, 1) |
| 173 | uint8_t RemoteXY_CONF[] = |
| 174 | { 255,4,0,0,0,155,0,8,8,1, |
| 175 | 2,0,6,16,22,11,4,26,31,31, |
| 176 | 79,78,0,79,70,70,0,129,0,8, |
| 177 | 8,18,6,16,80,111,119,101,114,0, |
| 178 | 2,0,36,18,18,8,1,26,31,31, |
| 179 | 79,78,0,79,70,70,0,129,0,39, |
| 180 | 10,12,6,16,70,97,115,116,0,3, |
| 181 | 3,13,48,9,25,3,26,129,0,14, |
| 182 | 38,15,6,16,76,105,103,104,116,0, |
| 183 | 129,0,27,49,8,6,16,79,110,0, |
| 184 | 129,0,27,58,9,6,16,79,102,102, |
| 185 | 0,129,0,27,66,24,6,16,66,108, |
| 186 | 105,110,107,105,110,103,0,2,0,7, |
| 187 | 89,14,7,14,26,31,31,79,78,0, |
| 188 | 79,70,70,0,129,0,24,90,28,5, |
| 189 | 16,79,84,65,32,85,112,100,97,116, |
| 190 | 101,0 }; |
| 191 | |
| 192 | // this structure defines all the variables of your control interface |
| 193 | struct { |
| 194 | |
| 195 | // input variable |
| 196 | uint8_t switch_1; // =1 if switch ON and =0 if OFF |
| 197 | uint8_t speed_switch; // =1 if switch ON and =0 if OFF |
| 198 | uint8_t select_1; // =0 if select position A, =1 if position B, =2 if position C, ... |
| 199 | uint8_t ota_update; // =1 if switch ON and =0 if OFF |
| 200 | |
| 201 | // other variable |
| 202 | uint8_t connect_flag; // =1 if wire connected, else =0 |
| 203 | |
| 204 | } RemoteXY; |
| 205 | #pragma pack(pop) |
| 206 | |
| 207 | /** |
| 208 | httpUpdate.ino |
| 209 | |
| 210 | Created on: 27.11.2015 |
| 211 | |
| 212 | */ |
| 213 | |
| 214 | #include <Arduino.h> |
| 215 | |
| 216 | #include <WiFi.h> |
| 217 | #include <WiFiMulti.h> |
| 218 | #include <ArduinoOTA.h> |
| 219 | #include <HTTPClient.h> |
| 220 | #include <HTTPUpdate.h> |
| 221 | const char* ssid = "SSID"; |
| 222 | const char* password = "PASSWORD"; |
| 223 | |
| 224 | |
| 225 | byte slow[] = {0xA6, 0x12, 0x02, 0x35, 0x14, 0xF1}; // Speed Limit to 20 km/h |
| 226 | byte fast[] = {0xA6, 0x12, 0x02, 0x35, 0xFF, 0x38}; // Maximum Speed |
| 227 | byte off[] = {0xA6, 0x12, 0x02, 0x00, 0xFF, 0xEA}; |
| 228 | byte fast_stealth[] = {0xA6, 0x12, 0x02, 0x31, 0xFF, 0x03}; |
| 229 | byte fast_blinking[] = {0xA6, 0x12, 0x02, 0x33, 0xFF, 0x92}; |
| 230 | byte slow_stealth[] = {0xA6, 0x12, 0x02, 0x31, 0x14, 0xCA}; |
| 231 | byte slow_blinking[] = {0xA6, 0x12, 0x02, 0x33, 0x14, 0x5B}; |
| 232 | |
| 233 | int run_once = 0; |
| 234 | |
| 235 | void setup() { |
| 236 | Serial.begin(9600); |
| 237 | RemoteXY_Init (); |
| 238 | |
| 239 | } |
| 240 | |
| 241 | void loop() { |
| 242 | ArduinoOTA.handle(); |
| 243 | if((RemoteXY.ota_update == 1) && (run_once == 0)) |
| 244 | { |
| 245 | |
| 246 | Serial.println("Booting"); |
| 247 | WiFi.mode(WIFI_STA); |
| 248 | WiFi.begin(ssid, password); |
| 249 | while (WiFi.waitForConnectResult() != WL_CONNECTED) { |
| 250 | Serial.println("Connection Failed! Rebooting..."); |
| 251 | delay(5000); |
| 252 | ESP.restart(); |
| 253 | } |
| 254 | |
| 255 | // Port defaults to 8266 |
| 256 | // ArduinoOTA.setPort(8266); |
| 257 | |
| 258 | // Hostname defaults to esp8266-[ChipID] |
| 259 | ArduinoOTA.setHostname("Your Scooter"); |
| 260 | |
| 261 | // No authentication by default |
| 262 | ArduinoOTA.setPassword((const char *)"password"); |
| 263 | |
| 264 | ArduinoOTA.onStart([]() { |
| 265 | Serial.println("Start"); |
| 266 | }); |
| 267 | ArduinoOTA.onEnd([]() { |
| 268 | Serial.println("\nEnd"); |
| 269 | }); |
| 270 | ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { |
| 271 | Serial.printf("Progress: %u%%\r", (progress / (total / 100))); |
| 272 | }); |
| 273 | ArduinoOTA.onError([](ota_error_t error) { |
| 274 | Serial.printf("Error[%u]: ", error); |
| 275 | if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed"); |
| 276 | else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed"); |
| 277 | else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed"); |
| 278 | else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed"); |
| 279 | else if (error == OTA_END_ERROR) Serial.println("End Failed"); |
| 280 | }); |
| 281 | ArduinoOTA.begin(); |
| 282 | Serial.println("Ready"); |
| 283 | Serial.print("IP address: "); |
| 284 | Serial.println(WiFi.localIP()); |
| 285 | run_once = 1; |
| 286 | } |
| 287 | |
| 288 | |
| 289 | if((RemoteXY.ota_update == 0) && (run_once == 0)) |
| 290 | { |
| 291 | |
| 292 | RemoteXY_Handler (); |
| 293 | |
| 294 | if((RemoteXY.switch_1 == 1) && (RemoteXY.speed_switch == 0) && (RemoteXY.select_1 == 0)) |
| 295 | { |
| 296 | Serial.write(slow, sizeof(slow)); |
| 297 | } |
| 298 | |
| 299 | else if((RemoteXY.switch_1 == 1) && (RemoteXY.speed_switch == 0) && (RemoteXY.select_1 == 1)) |
| 300 | { |
| 301 | Serial.write(slow_stealth, sizeof(slow_stealth)); |
| 302 | } |
| 303 | |
| 304 | else if((RemoteXY.switch_1 == 1) && (RemoteXY.speed_switch == 0) && (RemoteXY.select_1 == 2)) |
| 305 | { |
| 306 | Serial.write(slow_blinking, sizeof(slow_blinking)); |
| 307 | } |
| 308 | |
| 309 | |
| 310 | else if((RemoteXY.switch_1 == 1) && (RemoteXY.speed_switch == 1) && (RemoteXY.select_1 == 0)) |
| 311 | { |
| 312 | Serial.write(fast, sizeof(fast)); |
| 313 | } |
| 314 | |
| 315 | else if((RemoteXY.switch_1 == 1) && (RemoteXY.speed_switch == 1) && (RemoteXY.select_1 == 1)) |
| 316 | { |
| 317 | Serial.write(fast_stealth, sizeof(fast_stealth)); |
| 318 | } |
| 319 | |
| 320 | else if((RemoteXY.switch_1 == 1) && (RemoteXY.speed_switch == 1) && (RemoteXY.select_1 == 2)) |
| 321 | { |
| 322 | Serial.write(fast_blinking, sizeof(fast_blinking)); |
| 323 | } |
| 324 | |
| 325 | else |
| 326 | { |
| 327 | Serial.write(off, sizeof(off)); |
| 328 | } |
| 329 | delay(200); |
| 330 | } |
| 331 | |
| 332 | |
| 333 | } |
| 334 | === |
| 335 | /* |
| 336 | -- VOI Controller -- |
| 337 | |
| 338 | This source code of graphical user interface |
| 339 | has been generated automatically by RemoteXY editor. |
| 340 | To compile this code using RemoteXY library 2.4.3 or later version |
| 341 | download by link http://remotexy.com/en/library/ |
| 342 | To connect using RemoteXY mobile app by link http://remotexy.com/en/download/ |
| 343 | - for ANDROID 4.5.1 or later version; |
| 344 | - for iOS 1.4.1 or later version; |
| 345 | |
| 346 | This source code is free software; you can redistribute it and/or |
| 347 | modify it under the terms of the GNU Lesser General Public |
| 348 | License as published by the Free Software Foundation; either |
| 349 | version 2.1 of the License, or (at your option) any later version. |
| 350 | */ |
| 351 | |
| 352 | ////////////////////////////////////////////// |
| 353 | // RemoteXY include library // |
| 354 | ////////////////////////////////////////////// |
| 355 | |
| 356 | // RemoteXY select connection mode and include library |
| 357 | #define REMOTEXY_MODE__ESP32CORE_BLE |
| 358 | |
| 359 | #include <RemoteXY.h> |
| 360 | #include <Arduino.h> |
| 361 | |
| 362 | // RemoteXY connection settings |
| 363 | #define REMOTEXY_BLUETOOTH_NAME "VOI Controller V3" |
| 364 | //#define REMOTEXY_ACCESS_PASSWORD "password" //dont work for me -> why? |
| 365 | |
| 366 | |
| 367 | // RemoteXY configurate |
| 368 | #pragma pack(push, 1) |
| 369 | uint8_t RemoteXY_CONF[] = |
| 370 | { 255,4,0,0,0,151,0,10,52,1, |
| 371 | 2,1,12,22,39,7,52,8,31,31, |
| 372 | 80,111,119,101,114,0,83,104,117,116, |
| 373 | 32,100,111,119,110,0,2,1,12,34, |
| 374 | 39,7,52,8,31,31,70,97,115,116, |
| 375 | 32,115,112,101,101,100,0,83,108,111, |
| 376 | 119,32,83,112,101,101,100,0,129,0, |
| 377 | 7,4,49,6,16,86,79,73,32,67, |
| 378 | 111,110,116,114,111,108,108,101,114,32, |
| 379 | 86,51,0,2,1,12,46,39,7,52, |
| 380 | 8,31,31,76,105,103,104,116,115,32, |
| 381 | 111,110,0,76,105,103,104,116,115,32, |
| 382 | 111,102,102,0,2,1,12,58,39,7, |
| 383 | 52,8,31,31,80,111,119,101,114,32, |
| 384 | 86,79,73,0,83,104,117,116,32,100, |
| 385 | 111,119,110,32,86,79,73,0 }; |
| 386 | |
| 387 | // this structure defines all the variables and events of your control interface |
| 388 | struct { |
| 389 | |
| 390 | // input variables |
| 391 | uint8_t switch_power; // =1 if switch ON and =0 if OFF |
| 392 | uint8_t switch_fastspeed; // =1 if switch ON and =0 if OFF |
| 393 | uint8_t switch_light; // =1 if switch ON and =0 if OFF |
| 394 | uint8_t switch_powervoi; // =1 if switch ON and =0 if OFF |
| 395 | |
| 396 | // other variable |
| 397 | uint8_t connect_flag; // =1 if wire connected, else =0 |
| 398 | |
| 399 | } RemoteXY; |
| 400 | #pragma pack(pop) |
| 401 | |
| 402 | //////////////////////////////////////////// |
| 403 | // Scooter Command include // |
| 404 | /////////////////////////////////////////// |
| 405 | |
| 406 | byte slowvoi[] = {0xA6, 0x12, 0x02, 0x65, 0x14, 0x86}; // Speed Limit to 20 km/h (tested on voi by mayaku) |
| 407 | byte slow1[] = {0xA6, 0x12, 0x02, 0XF1, 0x14, 0x7E}; // LIGHT OFF & ESC ON & KPH & SLOW (tested by Wileok) |
| 408 | byte slow2[] = {0xA6, 0x12, 0x02, 0XF5, 0x14, 0x45}; // LIGHT ON & ESC ON & KPH & SLOW (tested by Wileok) |
| 409 | |
| 410 | byte fastvoi[] = {0xA6, 0x12, 0x02, 0x35, 0xFF, 0x38}; // Maximum Speed (tested on voi by mayaku) |
| 411 | byte fast1[] = {0xA6, 0x12, 0x02, 0XF1, 0xE4, 0x0A}; // LIGHT OFF & ESC ON & KPH & FAST (tested by Wileok) |
| 412 | byte fast2[] = {0xA6, 0x12, 0x02, 0XF5, 0xE4, 0x31}; // LIGHT ON & ESC ON & KPH & FAST (tested by Wileok) |
| 413 | |
| 414 | byte off[] = {0xA6, 0x12, 0x02, 0x00, 0xFF, 0xEA}; //Off (tested on voi by mayaku) |
| 415 | |
| 416 | void setup() |
| 417 | { |
| 418 | RemoteXY_Init (); |
| 419 | |
| 420 | Serial.begin(9600); |
| 421 | } |
| 422 | |
| 423 | void loop() |
| 424 | { |
| 425 | RemoteXY_Handler (); |
| 426 | if((RemoteXY.switch_power == 1) && (RemoteXY.switch_fastspeed == 0) && (RemoteXY.switch_light == 0)) //light off + slow |
| 427 | { |
| 428 | Serial.write(slow1, sizeof(slow1)); |
| 429 | } |
| 430 | else if((RemoteXY.switch_power == 1) && (RemoteXY.switch_fastspeed) == 0 && (RemoteXY.switch_light == 1)) //light on + slow |
| 431 | { |
| 432 | Serial.write(slow2, sizeof(slow2)); |
| 433 | } |
| 434 | else if((RemoteXY.switch_power == 1) && (RemoteXY.switch_fastspeed) == 1 && (RemoteXY.switch_light == 0)) //light off + fast |
| 435 | { |
| 436 | Serial.write(fast1, sizeof(fast1)); |
| 437 | } |
| 438 | else if((RemoteXY.switch_power == 1) && (RemoteXY.switch_fastspeed) == 1 && (RemoteXY.switch_light == 1)) //light on + fast |
| 439 | { |
| 440 | Serial.write(fast2, sizeof(fast2)); |
| 441 | } |
| 442 | else if((RemoteXY.switch_power == 1) && (RemoteXY.switch_fastspeed) == 0 && (RemoteXY.switch_powervoi == 1)) //voi slow + light??? |
| 443 | { |
| 444 | Serial.write(slowvoi, sizeof(slowvoi)); |
| 445 | } |
| 446 | else if((RemoteXY.switch_power == 1) && (RemoteXY.switch_fastspeed) == 1 && (RemoteXY.switch_powervoi == 1)) //voi fast + light??? |
| 447 | { |
| 448 | Serial.write(fastvoi, sizeof(fastvoi)); |
| 449 | } |
| 450 | else |
| 451 | { |
| 452 | Serial.write(off, sizeof(off)); |
| 453 | } |
| 454 | delay(200); |
| 455 | } |
| 456 | === |
| 457 | Max speed: |
| 458 | #include <Arduino.h> |
| 459 | |
| 460 | int powerPin = 5; |
| 461 | byte messageA[] = {0xA6, 0x12, 0x02, 0x10, 0x14, 0xCF}; |
| 462 | byte messageB[] = {0xA6, 0x12, 0x02, 0x11, 0x14, 0x0B}; |
| 463 | byte messageC[] = {0xA6, 0x12, 0x02, 0x35, 0xFF, 0x38}; |
| 464 | |
| 465 | void setup() { |
| 466 | // initialize Serial: |
| 467 | Serial.begin(9600); |
| 468 | |
| 469 | pinMode(powerPin, OUTPUT); |
| 470 | digitalWrite(powerPin, HIGH); |
| 471 | } |
| 472 | |
| 473 | void loop() { |
| 474 | delay(500); |
| 475 | Serial.write(messageC, sizeof(messageC)); |
| 476 | } |
| 477 | === |
| 478 | |
| 479 | Niebieski - 13 (3v3) |
| 480 | Zielony - 17 |
| 481 | Głośnik - 26 |
| 482 | |
| 483 | |
| 484 | == |
| 485 |