0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

如何使用Arduino控制GoPro

454398 ? 來(lái)源:工程師吳畏 ? 2019-08-19 09:25 ? 次閱讀

第1步:材料

如何使用Arduino控制GoPro

對(duì)于這個(gè)項(xiàng)目,你只需要做幾件事。

首先,你顯然需要一臺(tái)GoPro相機(jī)。這些說(shuō)明適用于最新型號(hào)(GoPro Hero 6)。雖然,我只是用GoPro Hero 4和GoPro Hero Session 5進(jìn)行了個(gè)人測(cè)試.Hero Session模型與其他模型的控制略有不同,但我們將在稍后介紹。

您還需要Arduino MKR1000或Arduino MKR Zero。在這些說(shuō)明中,我使用MKR1000。您可以使用另一個(gè)兼容Arduino的無(wú)線微控制器板(例如Feather),但我沒有親自嘗試過(guò)。

您還需要一根用于Arduino的USB線,一臺(tái)運(yùn)行Arduino開發(fā)軟件的計(jì)算機(jī)(我假設(shè)您有),以及安裝了GoPro應(yīng)用程序的智能手機(jī)。

如果你沒有這樣的東西,或者之前從未使用過(guò)Arduino,我強(qiáng)烈建議你在開始這個(gè)項(xiàng)目之前先閱讀Arduino類!

步驟2:配置相機(jī)的Wifi

您需要做的第一件事就是打開并配置相機(jī)的wifi連接。我不打算深入研究這個(gè)問題,因?yàn)橐呀?jīng)有很多教程可以做到這一點(diǎn)。

在GoPro Hero4上,最簡(jiǎn)單的方法就是將相機(jī)連接到按照應(yīng)用中的說(shuō)明操作您的手機(jī)

一旦手機(jī)與相機(jī)配對(duì),請(qǐng)使用應(yīng)用程序打開相機(jī)的設(shè)置,并為wifi網(wǎng)絡(luò)提供您選擇的新名稱和密碼。

在GoPro上英雄會(huì)話5,同樣的方法也適用。首先,按照應(yīng)用中的說(shuō)明將相機(jī)連接到手機(jī)。這將自動(dòng)配置wifi網(wǎng)絡(luò)的名稱和密碼。

要在相機(jī)上查看wifi網(wǎng)絡(luò)名稱,請(qǐng)導(dǎo)航至《 Camera Info “,該名稱位于“連接設(shè)置”菜單。

步驟3:查找GoPro的MAC地址

啟用wifi后,您需要確定相機(jī)的MAC(媒體訪問控制)地址。在處理傳統(tǒng)的Hero系列GoPros時(shí),這個(gè)地址是一個(gè)很好的信息。但是,如果您使用的是GoPro Hero Session,則此地址是必須的。

為了獲得它,首先使用上一步中的網(wǎng)絡(luò)名稱和密碼將計(jì)算機(jī)連接到相機(jī)的wifi網(wǎng)絡(luò)。

一旦登錄到您的相機(jī)的wifi網(wǎng)絡(luò),打開計(jì)算機(jī)上的任何舊網(wǎng)頁(yè)瀏覽器,并訪問以下網(wǎng)址:

http://10.5.5.9/gp/gpControl/info

此網(wǎng)址應(yīng)打印一個(gè)字符串您的網(wǎng)絡(luò)瀏覽器中的信息類似于:

{“model_number”21,“model_name”:“HERO5Session”,“firmware_version”:“HD5.03.02.51.00”,“serial_number”:“C3212365684485 ”, “board_type”: “0×05”, “ap_mac”: “0641631510c4”, “ap_ssid”: “GP54688615”, “ap_has_default_credentials”: “0”, “能力”: “16”}

如果沒有,請(qǐng)確保您的相機(jī)已打開,并且仍然連接到wifi。

我們感興趣的字符串中的位是字符串“ap_mac:”之后的數(shù)字。 這個(gè)12位數(shù)字和數(shù)字字符串是MAC地址。在我的情況下,這是 0641631510c4 。

一旦確定了地址,每?jī)蓚€(gè)字符將其分開,并按如下格式進(jìn)行格式化:

0x06,0x41,0x63,0x15,0x10,0xC4

步驟4:將Arduino連接到GoPro Hero

為了讓Arduino與GoPro Hero系列相機(jī)通信,它需要使用PIN配對(duì)。要獲取引腳,請(qǐng)?jiān)谑謾C(jī)菜單中導(dǎo)航以將相機(jī)與應(yīng)用配對(duì)。這應(yīng)該在所有后期型號(hào)相機(jī)上生成4位數(shù)的PIN(Hero 3及更早版本的PIN有6位數(shù))。

針腳僅持續(xù)3分鐘,所以時(shí)間至關(guān)重要。

您需要手動(dòng)將PIN兩個(gè)次插入兩者 它所說(shuō)的地方:

//?。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。??。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。?!

//在這里輸入你的PINX XXXX在哪里了//!?。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。??。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。?!

一旦輸入了引腳,你只需不到三分鐘就可以將它上傳到Arduino并與相機(jī)建立連接。

說(shuō)到哪個(gè),別忘了輸入GoPro的wifi憑據(jù),其中包含:

//?。。。。。。。。。。。。。。。。。。。。。。。。。??。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。?! ?。。。。。。。?!

//輸入你的WIFI名字,密碼在這里

//?。。。。。。。。。。。。。。。。。。。。。??。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。?! !?。。。。。。。。。。?!

為了所有意圖和目的,一旦您成功上傳了代碼,就不會(huì)發(fā)生任何事情。然而,如果您從GoPro的設(shè)置菜單導(dǎo)航回視頻屏幕,您現(xiàn)在應(yīng)該能夠發(fā)送命令(我們將在稍后介紹)。

如果在接下來(lái)的步驟中您似乎無(wú)法向相機(jī)發(fā)送命令,請(qǐng)返回并重復(fù)此步驟。

使用其PIN碼將GoPro與Arduino配對(duì)的代碼:

#include

#include

#include

int status = WL_IDLE_STATUS;

//!?。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。?!

//ENTER YOUR WIFI NAME AND PASSWORD HERE

//?。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。?!

char ssid[] = “XXXXXXXXXXXX”; // your network SSID (name)

char pass[] = “XXXXXXXXXXXX”; // your network password (use for WPA, or use as key for WEP)

WiFiClient client;

const char* host = “10.5.5.9”;

const int httpPort = 80;

void setup(){

//Initialize serial and wait for port to open:

Serial.begin(115200);

// check for the presence of the wifi module:

if (WiFi.status() == WL_NO_SHIELD) {

Serial.println(“WiFi not present”);

// don‘t continue:

while (true);

}

// attempt to connect to Wifi network:

while ( status != WL_CONNECTED) {

Serial.print(“Attempting to connect to SSID: ”);

Serial.println(ssid);

// Connect to WPA/WPA2 network. Change this line if using open or WEP network:

status = WiFi.begin(ssid, pass);

// wait 8 seconds for connection:

delay(8000);

}

Serial.println(“Connected to wifi”);

printWifiStatus();

// START PIN

StartPin();

delay(10000);

// FINISH PIN

FinishPin();

}

void loop(){

//Nothing to do here!

delay(1000);

}

void StartPin(){

Serial.print(“connecting to ”);

Serial.println(host);

if (!client.connect(“10.5.5.9”, httpPort)) {

Serial.println(“connection failed”);

return;

}

//?。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。?/p>

//ENTER YOUR PIN HERE WHERE IT SAYS XXXX

//?。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。?!

String StartUrl = “/gpPair?c=start&pin=XXXX&mode=0”;

Serial.print(“Requesting URL: ”);

Serial.println(StartUrl);

client.print(String(“GET ”) + StartUrl + “ HTTP/1.1 ” +

“Host: ” + host + “ ” +

“Connection: close ”);

Serial.println(“Started”);

}

void FinishPin(){

Serial.print(“connecting to ”);

Serial.println(host);

if (!client.connect(“10.5.5.9”, httpPort)) {

Serial.println(“connection failed”);

return;

}

//!?。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。?!

//ENTER YOUR PIN HERE WHERE IT SAYS XXXX

//?。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。?/p>

String StopUrl = “10.5.5.9/gpPair?c=finish&pin=XXXX&mode=0”;

Serial.print(“Requesting URL: ”);

Serial.println(StopUrl);

client.print(String(“GET ”) + StopUrl + “ HTTP/1.1 ” +

“Host: ” + host + “ ” +

“Connection: close ”);

Serial.println(“Finished”);

}

void printWifiStatus() {

// print the SSID of the network you’re attached to:

Serial.print(“SSID: ”);

Serial.println(WiFi.SSID());

// print your WiFi shield‘s IP address:

IPAddress ip = WiFi.localIP();

Serial.print(“IP Address: ”);

Serial.println(ip);

// print the received signal strength:

long rssi = WiFi.RSSI();

Serial.print(“signal strength (RSSI):”);

Serial.print(rssi);

Serial.println(“ dBm”);

}

步驟5:將Arduino連接到GoPro Hero會(huì)話

GoPro會(huì)話沒有要響應(yīng)的PIN。然而,它有它自己的特點(diǎn),使連接它真的很煩人。正如您可能已經(jīng)注意到的那樣,只要您完成錄制,或者就此而言,只要您使用相機(jī)完成大部分操作,它就會(huì)關(guān)閉并進(jìn)入睡眠模式。

在您發(fā)送GoPro Hero任何類型的命令之前,您需要將其喚醒。最簡(jiǎn)單的方法是手動(dòng)按下攝像機(jī)背面的菜單按鈕,并在幾秒鐘的窗口中發(fā)出命令。然而,這很煩人,并且在任何方面都不是特別實(shí)用。

喚醒GoPro的更好方法是使用WOL數(shù)據(jù)包或“魔術(shù)數(shù)據(jù)包”。這個(gè)首字母縮寫詞代表Wake-on-Lan,是遠(yuǎn)程喚醒計(jì)算機(jī)從睡眠模式的協(xié)議。它需要使用UDP協(xié)議從Arduino發(fā)送字節(jié)到GoPro以喚醒它。這有點(diǎn)煩人,因?yàn)樗c您發(fā)送所有其他控制命令的協(xié)議不同。如果你不熟悉編程,代碼也不那么漂亮,處理起來(lái)會(huì)有點(diǎn)復(fù)雜。

然而,當(dāng)它工作時(shí),它真的像魔術(shù)一樣工作。通過(guò)向Arduino發(fā)送命令,看到我的相機(jī)醒來(lái)后,我從未停止驚訝。

WOL命令(代碼中的 CameraInitiate()功能)需要在大多數(shù)其他命令之前發(fā)送,并且通常應(yīng)該延遲1-2秒?;旧?,您需要在需要喚醒相機(jī)時(shí)(大多數(shù)時(shí)間)發(fā)送它。發(fā)送命令后,您需要暫停片刻才能讓相機(jī)實(shí)際喚醒。

在下面的示例中,在設(shè)置中調(diào)用WOL功能,因此它只會(huì)喚醒第一次運(yùn)行時(shí)使用相機(jī)。

不要忘記在提示的代碼中輸入GoPro的wifi憑據(jù)和MAC地址!

以下是喚醒相機(jī)的代碼:

#include

#include

#include

int status = WL_IDLE_STATUS;

//?。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。?!

//ENTER YOUR WIFI NAME AND PASSWORD HERE

//?。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。?!

char ssid[] = “XXXXXXXXXXXX”; // your network SSID (name)

char pass[] = “XXXXXXXXXXXX”; // your network password (use for WPA, or use as key for WEP)

int localPort = 7;

byte broadCastIp[] = { 10,5,5,9 };

//?。。。。。。。。。。。。。。。。。。。。。。。。。?!

//ENTER YOUR MAC ADDRESS HERE

//!?。。。。。。。。。。。。。。。。。。。。。。。。?!

byte remote_MAC_ADD[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

int wolPort = 9;

WiFiUDP Udp;

WiFiClient client;

const char* host = “10.5.5.9”;

const int httpPort = 80;

void setup(){

//Initialize serial and wait for port to open:

Serial.begin(115200);

// check for the presence of the wifi module:

if (WiFi.status() == WL_NO_SHIELD) {

Serial.println(“WiFi not present”);

// don’t continue:

while (true);

}

// attempt to connect to Wifi network:

while ( status != WL_CONNECTED) {

Serial.print(“Attempting to connect to SSID: ”);

Serial.println(ssid);

// Connect to WPA/WPA2 network. Change this line if using open or WEP network:

status = WiFi.begin(ssid, pass);

// wait 8 seconds for connection:

delay(8000);

}

Serial.println(“Connected to wifi”);

printWifiStatus();

delay(1000);

// WAKE UP YOUR SLEEPY CAMERA!

CameraInitiate(){

// NOTE: If this does not seem to be working,

// turn your camera on and off and try again.

}

void loop(){

//Nothing to do here!

delay(1000);

}

// FUNCTION TO WAKE UP THE CAMERA

void CameraInitiate(){

//Begin UDP communication

Udp.begin(localPort);

//Send the magic packet to wake up the GoPro out of sleep

delay(2000);

SendMagicPacket();

delay(5000);

// Absolutely necessary to flush port of UDP junk for Wifi client communication

Udp.flush();

delay(1000);

//Stop UDP communication

Udp.stop();

delay(1000);

}

// Function to create and send magic packet

// Taken and translated from here:

// https://www.logicaprogrammabile.it/wol-accendere-computer-arduino-wake-on-lan/

void SendMagicPacket(){

//Create a 102 byte array

byte magicPacket[102];

// Variables for cycling through the array

int Cycle = 0, CycleMacAdd = 0, IndexArray = 0;

// This for loop cycles through the array

for( Cycle = 0; Cycle 《 6; Cycle++){

// The first 6 bytes of the array are set to the value 0xFF

magicPacket[IndexArray] = 0xFF;

// Increment the array index

IndexArray++;

}

// Now we cycle through the array to add the GoPro address

for( Cycle = 0; Cycle 《 16; Cycle++ ){

//eseguo un Cycle per memorizzare i 6 byte del

//mac address

for( CycleMacAdd = 0; CycleMacAdd 《 6; CycleMacAdd++){

magicPacket[IndexArray] = remote_MAC_ADD[CycleMacAdd];

// Increment the array index

IndexArray++;

}

}

//The magic packet is now broadcast to the GoPro IP address and port

Udp.beginPacket(broadCastIp, wolPort);

Udp.write(magicPacket, sizeof magicPacket);

Udp.endPacket();

}

void printWifiStatus() {

// print the SSID of the network you‘re attached to:

Serial.print(“SSID: ”);

Serial.println(WiFi.SSID());

// print your WiFi shield’s IP address:

IPAddress ip = WiFi.localIP();

Serial.print(“IP Address: ”);

Serial.println(ip);

// print the received signal strength:

long rssi = WiFi.RSSI();

Serial.print(“signal strength (RSSI):”);

Serial.print(rssi);

Serial.println(“ dBm”);

}

步驟6:發(fā)送GoPro命令

在本例中,我將展示如何發(fā)送命令開始和停止視頻錄制。

也就是說(shuō),使用此處演示的相同方法,您可以為攝像機(jī)內(nèi)的每個(gè)功能發(fā)送命令。 GoPro Hero 4命令似乎是所有后續(xù)型號(hào)的標(biāo)準(zhǔn)設(shè)置。但是,一些較新的相機(jī)具有新功能和特定于攝像頭的命令,值得研究。您可以通過(guò)單擊特定相機(jī)型號(hào)的鏈接在Unofficial GoPro WiFi API github頁(yè)面上找到相機(jī)特定命令。

以下示例使用5秒鐘錄制,停止錄制,等待5個(gè)以上秒,然后重新開始。如果您正在使用Hero Session,請(qǐng)務(wù)必取消喚醒GoPro的代碼行。

再次,不要忘記輸入您的GoPro的wifi憑據(jù)和MAC地址!

發(fā)送開始和停止錄制命令的代碼:

#include

#include

#include

int status = WL_IDLE_STATUS;

//!?。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。?!

//ENTER YOUR WIFI NAME AND PASSWORD HERE

//?。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。?!

char ssid[] = “XXXXXXXXXXXX”; // your network SSID (name)

char pass[] = “XXXXXXXXXXXX”; // your network password (use for WPA, or use as key for WEP)

int localPort = 7;

byte broadCastIp[] = { 10,5,5,9 };

//?。。。。。。。。。。。。。。。。。。。。。。。。。。?/p>

//ENTER YOUR MAC ADDRESS HERE

//?。。。。。。。。。。。。。。。。。。。。。。。。。?!

byte remote_MAC_ADD[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

int wolPort = 9;

WiFiUDP Udp;

WiFiClient client;

const char* host = “10.5.5.9”;

const int httpPort = 80;

void setup(){

//Initialize serial and wait for port to open:

Serial.begin(115200);

// check for the presence of the wifi module:

if (WiFi.status() == WL_NO_SHIELD) {

Serial.println(“WiFi not present”);

// don‘t continue:

while (true);

}

// ADD THIS TO LOOP??????????????

// MAKE ITS OWN FUNCTION???????

// attempt to connect to Wifi network:

while ( status != WL_CONNECTED) {

Serial.print(“Attempting to connect to SSID: ”);

Serial.println(ssid);

// Connect to WPA/WPA2 network. Change this line if using open or WEP network:

status = WiFi.begin(ssid, pass);

// wait 8 seconds for connection:

delay(8000);

}

Serial.println(“Connected to wifi”);

printWifiStatus();

}

void loop(){

// Add code to check to see if wifi is still on. If not, stop and keep trying to connect

// WAKE UP CAMERA FROM SLEEP AND CONNECT

CameraInitiate();

// Add code to make sure that camera recognized (status 31)

// START RECORDING

StartRecording();

delay(5000);

// STOP RECORDING

StopRecording();

delay(5000);

}

void StartRecording(){

Serial.print(“connecting to ”);

Serial.println(host);

if (!client.connect(“10.5.5.9”, httpPort)) {

Serial.println(“connection failed”);

return;

}

//Command for starting recording

String StartUrl = “/gp/gpControl/command/shutter?p=1”;

Serial.print(“Requesting URL: ”);

Serial.println(StartUrl);

client.print(String(“GET ”) + StartUrl + “ HTTP/1.1 ” +

“Host: ” + host + “ ” +

“Connection: close ”);

Serial.println(“Recording”);

}

void StopRecording(){

Serial.print(“connecting to ”);

Serial.println(host);

if (!client.connect(“10.5.5.9”, httpPort)) {

Serial.println(“connection failed”);

return;

}

//Command for stopping recording

String StopUrl = “/gp/gpControl/command/shutter?p=0”;

Serial.print(“Requesting URL: ”);

Serial.println(StopUrl);

client.print(String(“GET ”) + StopUrl + “ HTTP/1.1 ” +

“Host: ” + host + “ ” +

“Connection: close ”);

Serial.println(“Stopped”);

}

// FUNCTION TO WAKE UP THE CAMERA

void CameraInitiate(){

//Begin UDP communication

Udp.begin(localPort);

//Send the magic packet to wake up the GoPro out of sleep

delay(2000);

SendMagicPacket();

delay(5000);

// Absolutely necessary to flush port of UDP junk for Wifi client communication

Udp.flush();

delay(1000);

//Stop UDP communication

Udp.stop();

delay(1000);

}

// Function to create and send magic packet

// Taken and translated from here:

// https://www.logicaprogrammabile.it/wol-accendere-computer-arduino-wake-on-lan/

void SendMagicPacket(){

//Create a 102 byte array

byte magicPacket[102];

// Variables for cycling through the array

int Cycle = 0, CycleMacAdd = 0, IndexArray = 0;

// This for loop cycles through the array

for( Cycle = 0; Cycle 《 6; Cycle++){

// The first 6 bytes of the array are set to the value 0xFF

magicPacket[IndexArray] = 0xFF;

// Increment the array index

IndexArray++;

}

// Now we cycle through the array to add the GoPro address

for( Cycle = 0; Cycle 《 16; Cycle++ ){

//eseguo un Cycle per memorizzare i 6 byte del

//mac address

for( CycleMacAdd = 0; CycleMacAdd 《 6; CycleMacAdd++){

magicPacket[IndexArray] = remote_MAC_ADD[CycleMacAdd];

// Increment the array index

IndexArray++;

}

}

//The magic packet is now broadcast to the GoPro IP address and port

Udp.beginPacket(broadCastIp, wolPort);

Udp.write(magicPacket, sizeof magicPacket);

Udp.endPacket();

}

void printWifiStatus() {

// print the SSID of the network you’re attached to:

Serial.print(“SSID: ”);

Serial.println(WiFi.SSID());

// print your WiFi shield‘s IP address:

IPAddress ip = WiFi.localIP();

Serial.print(“IP Address: ”);

Serial.println(ip);

// print the received signal strength:

long rssi = WiFi.RSSI();

Serial.print(“signal strength (RSSI):”);

Serial.print(rssi);

Serial.println(“ dBm”);

}

步驟7:接收GoPro狀態(tài)更新

可以使用此鏈接從GoPro接收狀態(tài)更新:

http://10.5.5.9/gp/gpControl/status

當(dāng)調(diào)用此鏈接時(shí),它提供了一個(gè)JSON對(duì)象,可以使用此Camera Status指南進(jìn)行解析。

最簡(jiǎn)單的方法是使用計(jì)算機(jī)連接到GoPro的wifi網(wǎng)絡(luò),并使用Web瀏覽器加載上述鏈接。

它將返回如下內(nèi)容:

{“status”{“1”:1,“2”:2,“3”:0,“4”: 0, “6”:0, “8”:0, “9”:0, “10”:0, “13”:0, “14”:0, “15”:0, “16”:0, “17”:1, “19”:0, “20”:0, “21”:0, “22”:0, “23”:0, “24”:0, “26”:0,“27 “:0,” 28 “:82,” 29 “:” “ ”30“: ”“, ”31“:0, ”32“:0, ”33“:0, ”34“:2796,” 35 “:1917,” 36 “:0,” 37 “:1,” 38 “:0,” 39 “:1,” 40 “:” %12%05%13%0℃%04%0E”, “41” :0, “42”:0, “43”:0, “44”:0, “45”:0, “46”:1, “47”:1, “48”:1, “49”:0 , “54”:15476384, “55”:1, “56”:0, “57”:3927, “58”:0, “59”:0, “60”:500, “61”:2“, 62 “:0,” 63 “:0,” 64 “:0,” 69 “:1,” 71“ :12 , “72”:19, “73”:20, “74”:0}, “設(shè)置”:{ “1”:0, “2”:1, “3”:8 “4”:0” 5 “:0,” 6 “:1,” 7 “:1,” 8 “:1,” 9 “:0,” 10 “:0,” 11 “:0,” 12 “:0,” 13” :1, “14”:0, “15”:4, “16”:0, “17”:4 “18”:1, “19”:0, “20”:0, “21”:1 , “22”:0, “23”:0, “24”:0, “25”:0, “26”:4 “27”:0, “28”:4 “29”:5“, 30 “:0,” 31 “:0,” 32 “:3601,” 33 “:0,” 34 “:0,” 35 “:0,” 36 “:0,” 37 “:0,” 38“ :0, “39”:4 “40”:0, “41”:13, “42”:8, “43”:0, “44”:8, “45”:8中, “46”:0 , “47”:0, “48”:0, “52”:1, “54”:1, “57”:0, “58”:1, “59”:6中, “60”:8,” 61 “:1,” 62 “:2500000,” 63 “:7,” 64 “:4”,65 “:0,” 66 “:0,” 67 “:0,” 68 “:0,” 69” :1, “70”:0, “71”:0, “73”:0, “74”:0, “75”:3, “76”:3, “78”:1, “84”:0 , “85”:0, “86”:1, “87”:40 “89”:12, “91”:0, “92”:12, “95”:1, “96”:0}}

老實(shí)說(shuō),每次我試圖用我的Arduino工作都會(huì)讓我的GoPro崩潰。由于我沒有真正需要這個(gè)功能用于我正在進(jìn)行的大型項(xiàng)目,我在這部分停止了我的輪子。

但是,由于nes3dprinting,這里有一些代碼可以用于ESP8266板:

// Code by https://www.instructables.com/member/nes3dprinting/

// This is for an ESP8266, not the MKR1000

// Made this for a GoPro Hero+. Should work for Hero4- Latest(Hero7)

//https://github.com/KonradIT/goprowifihack/blob/master/HERO/CameraStatus.md

#include ESP8266WiFi.h

// ArduinoJson Version 5.13

#include ArduinoJson.h

#include ESP8266HTTPClient.h

//########################## Enter GoPro WiFi Details Here #############################

const char* ssid = “GoProHero+”;

const char* pass = “GoProHero+”;

//######################################################################################

const char* host = “10.5.5.9”;

const int httpPort = 80;

void setup() {

Serial.begin(115200);

WiFi.mode(WIFI_STA);

WiFi.begin(ssid,pass);

}

void loop() {

if (WiFi.status() == WL_CONNECTED) {

// Prints the Current Mode of the Camera: Video-0, Photo-1, MultiShot-2

// https://github.com/KonradIT/goprowifihack/blob/master/HERO/CameraStatus.md

// Pick desired status from function below

GetStatus();

}

}

void GetStatus() {

//Serial.println(“Getting Status Updates”);

HTTPClient http; //Object of class HTTPClient

http.begin(“http://10.5.5.9/gp/gpControl/status”);

int httpCode = http.GET();

//Serial.print(“httpCode: ”);

//Serial.println(httpCode);

//Check the returning code

if (httpCode 》 0) {

// Parsing - Created Using ArduinoJson Assistant

// https://arduinojson.org/v5/assistant/

const size_t bufferSize = JSON_OBJECT_SIZE(2) + JSON_OBJECT_SIZE(55) + JSON_OBJECT_SIZE(64) + 730;

DynamicJsonBuffer jsonBuffer(bufferSize);

String str = http.getString();

//Serial.println(str);

JsonObject& root = jsonBuffer.parseObject(str);

JsonObject& status = root[“status”];

int status_1 = status[“1”]; // 1

int status_2 = status[“2”]; // 4

int status_3 = status[“3”]; // 0

int status_4 = status[“4”]; // 0

int status_6 = status[“6”]; // 0

int status_8 = status[“8”]; // 0

int status_9 = status[“9”]; // 0

int status_10 = status[“10”]; // 0

int status_11 = status[“11”]; // 0

int status_13 = status[“13”]; // 0

int status_14 = status[“14”]; // 0

int status_15 = status[“15”]; // 0

int status_16 = status[“16”]; // 0

int status_17 = status[“17”]; // 1

int status_19 = status[“19”]; // 0

int status_20 = status[“20”]; // 0

int status_21 = status[“21”]; // 0

int status_22 = status[“22”]; // 0

int status_23 = status[“23”]; // 0

int status_24 = status[“24”]; // 0

int status_26 = status[“26”]; // 0

int status_27 = status[“27”]; // 0

int status_28 = status[“28”]; // 0

const char* status_29 = status[“29”]; // “”

const char* status_30 = status[“30”]; // “GoProHero+”

int status_31 = status[“31”]; // 0

int status_32 = status[“32”]; // 0

int status_33 = status[“33”]; // 0

int status_34 = status[“34”]; // 4431

int status_35 = status[“35”]; // 4860

int status_36 = status[“36”]; // 0

int status_37 = status[“37”]; // 0

int status_38 = status[“38”]; // 0

int status_39 = status[“39”]; // 1

const char* status_40 = status[“40”]; // “%12%0B%0C%17%1E%08”

int status_41 = status[“41”]; // 0

int status_42 = status[“42”]; // 0

int status_43 = status[“43”]; // 1

int status_44 = status[“44”]; // 0

int status_45 = status[“45”]; // 0

int status_46 = status[“46”]; // 0

int status_47 = status[“47”]; // 0

int status_48 = status[“48”]; // 0

int status_49 = status[“49”]; // 0

long status_54 = status[“54”]; // 15899787264

int status_55 = status[“55”]; // 1

int status_56 = status[“56”]; // 4

int status_57 = status[“57”]; // 0

int status_58 = status[“58”]; // 0

int status_59 = status[“59”]; // 0

int status_60 = status[“60”]; // 500

int status_61 = status[“61”]; // 2

int status_62 = status[“62”]; // 0

int status_63 = status[“63”]; // 0

int status_64 = status[“64”]; // 2215

JsonObject& settings = root[“settings”];

int settings_1 = settings[“1”]; // 0

int settings_2 = settings[“2”]; // 11

int settings_3 = settings[“3”]; // 5

int settings_4 = settings[“4”]; // 0

int settings_5 = settings[“5”]; // 0

int settings_6 = settings[“6”]; // 1

int settings_7 = settings[“7”]; // 0

int settings_8 = settings[“8”]; // 0

int settings_9 = settings[“9”]; // 0

int settings_10 = settings[“10”]; // 0

int settings_11 = settings[“11”]; // 0

int settings_12 = settings[“12”]; // 0

int settings_13 = settings[“13”]; // 0

int settings_14 = settings[“14”]; // 4

int settings_15 = settings[“15”]; // 0

int settings_16 = settings[“16”]; // 0

int settings_17 = settings[“17”]; // 0

int settings_18 = settings[“18”]; // 0

int settings_19 = settings[“19”]; // 0

int settings_20 = settings[“20”]; // 0

int settings_21 = settings[“21”]; // 0

int settings_22 = settings[“22”]; // 0

int settings_23 = settings[“23”]; // 0

int settings_24 = settings[“24”]; // 0

int settings_25 = settings[“25”]; // 0

int settings_26 = settings[“26”]; // 0

int settings_27 = settings[“27”]; // 0

int settings_28 = settings[“28”]; // 0

int settings_29 = settings[“29”]; // 3

int settings_30 = settings[“30”]; // 0

int settings_31 = settings[“31”]; // 0

int settings_32 = settings[“32”]; // 10

int settings_33 = settings[“33”]; // 0

int settings_34 = settings[“34”]; // 0

int settings_35 = settings[“35”]; // 0

int settings_36 = settings[“36”]; // 0

int settings_37 = settings[“37”]; // 0

int settings_38 = settings[“38”]; // 0

int settings_39 = settings[“39”]; // 0

int settings_49 = settings[“49”]; // 100

int settings_50 = settings[“50”]; // 0

int settings_51 = settings[“51”]; // 2

int settings_52 = settings[“52”]; // 1

int settings_53 = settings[“53”]; // 1

int settings_54 = settings[“54”]; // 0

int settings_55 = settings[“55”]; // 3

int settings_56 = settings[“56”]; // 0

int settings_57 = settings[“57”]; // 0

int settings_58 = settings[“58”]; // 0

int settings_59 = settings[“59”]; // 0

int settings_60 = settings[“60”]; // 8

int settings_61 = settings[“61”]; // 1

long settings_62 = settings[“62”]; // 700000

int settings_63 = settings[“63”]; // 1

int settings_64 = settings[“64”]; // 2

int settings_68 = settings[“68”]; // 0

int settings_69 = settings[“69”]; // 0

int settings_70 = settings[“70”]; // 0

int settings_72 = settings[“72”]; // 0

int settings_73 = settings[“73”]; // 0

int settings_74 = settings[“74”]; // 0

int settings_75 = settings[“75”]; // 0

int settings_76 = settings[“76”]; // 0

int settings_77 = settings[“77”]; // 0

//########################### Set Desired State to Update Here ##########################################

Serial.print(“The Current State is: ”);

Serial.println(status_43);

//######################################################################################################

} else {

Serial.println(“No Response From Camera”);

}

}

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • Arduino
    +關(guān)注

    關(guān)注

    187

    文章

    6453

    瀏覽量

    185915
  • Gopro
    +關(guān)注

    關(guān)注

    0

    文章

    74

    瀏覽量

    28880
收藏 人收藏

    評(píng)論

    相關(guān)推薦

    arduino控制步進(jìn)電機(jī)代碼

    Arduino是一種開放源代碼的電路板平臺(tái),它可以用于控制各種不同的電子設(shè)備,包括步進(jìn)電機(jī)。步進(jìn)電機(jī)是一種電動(dòng)機(jī),可以通過(guò)下達(dá)特定的指令來(lái)控制每個(gè)步進(jìn)的角度,從而使電機(jī)旋轉(zhuǎn)到指定的位置。在本文
    的頭像 發(fā)表于 02-14 16:29 ?1611次閱讀

    arduino中while循環(huán)怎么跳出

    執(zhí)行某段代碼的情況。然而,如何在合適的時(shí)機(jī)跳出 while 循環(huán)是一個(gè)需要注意的問題。本文將詳細(xì)介紹 Arduino 中 while 循環(huán)的基本概念,以及如何使用不同的技巧跳出該循環(huán)來(lái)實(shí)現(xiàn)代碼的靈活控制
    的頭像 發(fā)表于 02-14 16:22 ?1821次閱讀

    如何使用Arduino控制RGB LED

    在本指南中,您將學(xué)習(xí)如何使用Arduino控制RGB LED。RGB(紅-綠-藍(lán))LED可以通過(guò)混合不同強(qiáng)度的紅、綠、藍(lán)光來(lái)產(chǎn)生多種顏色。您將學(xué)習(xí)創(chuàng)建一個(gè)基本Arduino RGB LED電路,并以一些基本顏色為例循環(huán)。
    的頭像 發(fā)表于 02-11 10:28 ?3702次閱讀
    如何使用<b class='flag-5'>Arduino</b><b class='flag-5'>控制</b>RGB LED

    如何使用Arduino UNO板和電位器控制伺服電機(jī)

    在本Arduino伺服電機(jī)教程中,您將學(xué)習(xí)如何使用Arduino UNO板和電位器控制伺服電機(jī)。
    的頭像 發(fā)表于 02-11 10:11 ?1930次閱讀
    如何使用<b class='flag-5'>Arduino</b> UNO板和電位器<b class='flag-5'>控制</b>伺服電機(jī)

    如何設(shè)置Arduino IR發(fā)射器電路

    在本指南中,您將學(xué)習(xí)如何設(shè)置 Arduino IR發(fā)射器電路。它使您可以控制IR(紅外線)LED,并從Arduino發(fā)送任何遠(yuǎn)程控制代碼。這意味著你可以用它來(lái)
    的頭像 發(fā)表于 02-11 09:44 ?700次閱讀
    如何設(shè)置<b class='flag-5'>Arduino</b> IR發(fā)射器電路

    如何使用arduino控制接觸器?

    我將避免鉛酸電池過(guò)載。我想通過(guò)使用近 30A 的接觸器和 arduino uno 板來(lái)控制電池過(guò)載。如何使用arduino控制接觸器?
    發(fā)表于 01-22 07:14

    arduino和單片機(jī)的區(qū)別比較

    和軟件的微控制器平臺(tái),它通過(guò)一種簡(jiǎn)化和標(biāo)準(zhǔn)化的方式,使電子開發(fā)變得更加容易。Arduino主板上集成了處理器、輸入輸出引腳、電源供應(yīng)等電路,能夠連接各種傳感器和執(zhí)行器,通過(guò)編程進(jìn)行控制和交互。
    的頭像 發(fā)表于 01-02 16:18 ?8354次閱讀

    基于WiFi的Arduino網(wǎng)絡(luò)控制方案

    電子發(fā)燒友網(wǎng)站提供《基于WiFi的Arduino網(wǎng)絡(luò)控制方案.rar》資料免費(fèi)下載
    發(fā)表于 11-10 10:30 ?0次下載
    基于WiFi的<b class='flag-5'>Arduino</b>網(wǎng)絡(luò)<b class='flag-5'>控制</b>方案

    能否用arduino代替PLC做機(jī)器的控制?

    能否用arduino代替PLC做機(jī)器的控制?
    發(fā)表于 11-09 08:06

    Arduino提供的PWM控制功能入門(1)

    今天來(lái)學(xué)習(xí)一下 Arduino 提供的 PWM 控制功能,它可以用來(lái)控制電機(jī)轉(zhuǎn)速,LED 明亮等。
    的頭像 發(fā)表于 10-31 16:32 ?1987次閱讀
    <b class='flag-5'>Arduino</b>提供的PWM<b class='flag-5'>控制</b>功能入門(1)

    怎么用arduino控制舵機(jī)轉(zhuǎn)動(dòng)一定角度?

    怎么用arduino控制舵機(jī)轉(zhuǎn)動(dòng)一定角度
    發(fā)表于 10-18 06:16

    如何使用Python和PinPong庫(kù)控制Arduino

    與傳感器和其他物理設(shè)備集成的應(yīng)用程序。如果您已經(jīng)掌握了Python的基礎(chǔ)知識(shí),那么您可以通過(guò)使用Python來(lái)控制Arduino來(lái)入門。本文目的主要是向您展示如何使用PinPong庫(kù)通過(guò)Python
    的頭像 發(fā)表于 10-13 10:59 ?742次閱讀
    如何使用Python和PinPong庫(kù)<b class='flag-5'>控制</b><b class='flag-5'>Arduino</b>

    基于arduino設(shè)計(jì)的手勢(shì)控制小車

    基于arduino的手勢(shì)控制小車
    發(fā)表于 09-25 06:06

    利用Arduino制作智能空調(diào)

    宿舍總是太熱,我們決定用Arduino來(lái)建造我們自己的空調(diào)。每個(gè)房間都有自己的溫度傳感器、通風(fēng)井和風(fēng)扇控制器。Arduino的工作是監(jiān)控室溫并控制風(fēng)扇以達(dá)到所需的溫度。
    發(fā)表于 09-22 06:32

    Arduino的PWM控制代碼

    如果你需要一個(gè)具體的代碼示例,我可以為你提供一個(gè)Arduino的PWM控制代碼。Arduino是一款常用的開源電子原型平臺(tái),它提供了PWM功能。以下是一個(gè)簡(jiǎn)單的Arduino代碼示例,
    發(fā)表于 09-21 08:57