PDA

View Full Version : Remote sensing of GoPro from its blinking LED?



Gerald
- 24th March 2023, 07:02
Hi

I am rather rusty on BASIC programming, having been absent from it for 40+ years. I have a remotely controlled GoPro, using third party remote control from YOCTOP (https://www.amazon.com/YOCTOP-Smart-Remote-Control-Screen/dp/B09NNY66VN) This remote has been hacked and a PIC12F683 inserted. The pic "presses" the record button to start a recording and has to press it again to stop. The cycle I want is 3 seconds of recording time every minute.

Mainloop:
if CYCLE = 0 then goto Mainloop ' do not do any recording
if cycle = 1 then gosub recording ' do the record cycle

Recording:
low RECPB ' Low Rec PB to start recording
Pause 500 ' start recording for 3 seconds
high RECPB ' High Rec PB after recording start
for j = 1 to 3000 ' Loop count for rec timing
pause 1
next j
low RECPB ' Low Rec PB to stop recording
Pause 500 ' Stop recording after 3 seconds
high RECPB ' High Rec PB after recording Stop
for k = 1 to 57000 ' Pause for 57 seconds and repeat cycle.
pause 1 '
next k
return

goto mainloop

end


This works fine until I press the record button manually and then the system records for 57 seconds and skips 3 . . . .

I need to detect if the cycle has been "inverted" and flash a red LED at me to manually press record again.

The Yoctop remote has a green LED that gives feedback as follows: Steady ON means not recording. Blinking 0.5s off / 0.5s on means recording.

What I thought of doing was to sample the on/off status of that LED over a moving window of 1.0 seconds. If on and off periods are similar (within 5%), it is recording. If on exceeds off (by more than 10%) it is not recording. Finally the pic must check if it is recording in the 57 sec when it is not supposed to record and then blink a red led at me. But I am stumped on how to do that elegantly in BASIC. Any and all help would be very much appreciated, thank you in advance.

(A friend has built similar for me before and I used it to make these non-monetized YouTubes (https://www.youtube.com/@quickrealroad/videos))

Ioannis
- 24th March 2023, 07:37
I think the remote YOCTOP has two way communication with your camera. If this is true, is it by IR, RF cable?

It is the only way to be sure for the state your camera is in.

Ioanins

Gerald
- 24th March 2023, 10:12
It communicates with Wifi. (I can see the Yoctop on my Android wifi connections and that is the method of updating the Yoctop). Inside the Yoctop is an Espressif ESP32-WROOM-32U which is supposed to be "powerful, generic Wi-Fi + Bluetooth + Bluetooth LE MCUmodules that target a wide variety of applications, ranging from low-power sensor networks to the most
demanding tasks, such as voice encoding, music streaming and MP3 decoding."

I have no idea of the code in there.

Ioannis
- 24th March 2023, 12:44
If the GoPro communication protocol is known, you may use a cheap ESP module and then try to write code to do just that. A PIC with WiFi is too much...

There is a Basic Interpreter for ESP modules and you can find it here https://cicciocb.com/forum/viewforum.php?f=1 and in the forum a lot of people can help on the ESP thing.

Ioannis

Gerald
- 24th March 2023, 12:56
I think my first post has been misunderstood . . . I am not trying to do Wifi with the pic. The wifi module is still in the Yoctop and still works as original. I have put the pic on top of the system there already. Already I can push the record button with the pic and the pic sees the Yoctop status LED as an input.

Ioannis
- 24th March 2023, 14:22
Oh, I see what you meant.

OK, an idea is to have the internal clock set at HFINTOSC=8MHz, then prescaller at 1MHz. So the system clock will be 1MHz/4= 250KHz.

Feed that clock to the Timer1 with a prescaller of 8. So the Timer1 will roll-over every 2 seconds.

With the timer1 you may check the green LED for the time it stays ON and OFF and conclude if the GoPro is recording or not.

Hope this helps.
Ioannis

Gerald
- 24th March 2023, 14:49
Thanks. It is going to take me a while to understand that.

tumbleweed
- 24th March 2023, 17:04
In post 1, the GOTO MAINLOOP is in the wrong place. Move it to before the "recording" label.

It may still not do what you're looking for, but fix that for sure.

Gerald
- 25th March 2023, 06:13
In post 1, the GOTO MAINLOOP is in the wrong place. Move it to before the "recording" label.

It may still not do what you're looking for, but fix that for sure.

I don't understand your logic. Would you mind giving me more information?

tumbleweed
- 25th March 2023, 10:54
Here's what you have now (I removed some of the code for clarity)


Mainloop:
if CYCLE = 0 then goto Mainloop ' just loop
if cycle = 1 then gosub recording ' call the subroutine and then return to the next statement

' after executing the above for cycle= 1 you'll return here
' the next statement is the beginning of the "recording" subroutine
' it'll execute that, hit the 'return' and cause a problem since there was no matching call

Recording:
' do stuff
return

' you'll never get here
goto mainloop



Without changing any of the code to test 'cycle', here's what it should look like


Mainloop:
if CYCLE = 0 then goto Mainloop ' just loop
if cycle = 1 then gosub recording ' call the subroutine and then return to the next statement

goto mainloop ' infinite loop back to main

Recording:
' do stuff
return