OSD Battery Monitoring for Helder's AIO Boards

Various user-contributed guides for hardware-related things
User avatar
HoolyHoo
Posts: 766
Joined: Sat Jul 09, 2016 9:34 pm
Has thanked: 206 times
Been thanked: 741 times

Re: OSD Battery Monitoring for Helder's AIO Boards

Post by HoolyHoo » Tue Oct 17, 2017 5:32 pm

Doktor.Dulli wrote:
Tue Oct 10, 2017 1:44 am
Hello,

Thanks for your great work. Unfortunately I am not able to setup your script to work as it should. I tried debug = 1 to get a hint and to see output of you script.

I'am using it together with the Arduino Leonardo Pro Micro (like lotusalex2000). This works, the Micro is sending the right values. I keep the Analog Pin connected to 5v first of all.
As long as the Micro is not connected to the RaspberryPi, the (Serial Port ACM0 / 1 / 2 not found) loop shows up on screen.
When i connect it, I see your battery symbol on top of my screen, I see values for the voltage (ret) but, now starts the trouble, only six times and nothing else, only cursor.

Like this

Code: Select all

Serial Port ACM0 not found
Serial Port ACM1 not found
Serial Port ACM2 not found
5,1
5,1
5,1
5,1
5,1
5,1
_
when i try "screen /dev/ttyACM2 115200" I see the serial values from the Micro for my Voltage (1023 for 5V). When I change the voltage, i see the right values, too, eg. 0Vs shows 0 and so on. So this works.

Only the loop stops, it wont change to Volts<25 when i try 0Vs on the Analog Input, it wont shutdown, only blinking cursor.
When I reboot the same. It will do the shutdown-script, when I reboot with 0V connected

thanking you in anticipation for helping
The Leonardo pro micro’s pinout is laid differently than what Helder used on his board. What hex did you use and which pin are you using for battery monitoring?

Doktor.Dulli
Posts: 2
Joined: Tue Oct 10, 2017 1:21 am

Re: OSD Battery Monitoring for Helder's AIO Boards

Post by Doktor.Dulli » Sat Oct 21, 2017 6:09 am

HoolyHoo wrote:
Tue Oct 17, 2017 5:32 pm

The Leonardo pro micro’s pinout is laid differently than what Helder used on his board. What hex did you use and which pin are you using for battery monitoring?
I took the Analog-Boot hex and I'm using the A1-Pin of the micro.

Iwant to use my micro with a gamepad lib as a gamepad, which works well with Windows. Even the thumbstick with A2 and A3 Pin works well.

User avatar
Wailer
Posts: 119
Joined: Mon Jan 15, 2018 3:45 pm
Location: Tiel, The Netherlands
Has thanked: 30 times
Been thanked: 38 times

Re: OSD Battery Monitoring for Helder's AIO Boards

Post by Wailer » Sat May 12, 2018 10:29 am

Hey Hoolyhoo,

I know it's an old thread, but i still have a question!
Can you include the arduino sketch (ino) in your repo? The hex is great but if you have a different button layout on your leo/teensy you have to rewire your buttons after loading your hex (non AIO that is).
With the sketch you only have to add your battery monitor part to your own sketch.

Maybe the (arduino) code is posted somewhere else and i overlooked, if that is so my apologies.

JackReacher
Posts: 14
Joined: Fri May 11, 2018 12:49 am
Location: Rome, Italy
Has thanked: 2 times

Re: OSD Battery Monitoring for Helder's AIO Boards

Post by JackReacher » Sat May 12, 2018 1:00 pm

Hi,
I am in the same situation here.. i am really confused on how to use my teensy 2.0 as a gamepad + battery monitor.. i flashed the hex but i am unable to assign the correct pins..if anyone could help would be very appreciated..

User avatar
Wailer
Posts: 119
Joined: Mon Jan 15, 2018 3:45 pm
Location: Tiel, The Netherlands
Has thanked: 30 times
Been thanked: 38 times

Re: OSD Battery Monitoring for Helder's AIO Boards

Post by Wailer » Sun May 13, 2018 8:04 am

JackReacher wrote:
Sat May 12, 2018 1:00 pm
Hi,
I am in the same situation here.. i am really confused on how to use my teensy 2.0 as a gamepad + battery monitor.. i flashed the hex but i am unable to assign the correct pins..if anyone could help would be very appreciated..
I am actually using the sketch found in this thread.
https://sudomod.com/forum/viewtopic.php ... sd+arduino
But I've got a feeling that it's not accurate enough...
A little "nervous" battery symbol (when battery level is getting at a switching point) and the "battery low" message is kicking in quite fast (maybe too soon).
So i wanted to compare this sketch with Hoolyhoo's original arduino sketch.

Just for info, hex files are already compiled sketch files who only need to be uploaded to your arduino.
They cannot be edited.
Sketches can but, you need the arduino ide to compile and upload.
https://www.arduino.cc/en/Main/Software

User avatar
HoolyHoo
Posts: 766
Joined: Sat Jul 09, 2016 9:34 pm
Has thanked: 206 times
Been thanked: 741 times

Re: OSD Battery Monitoring for Helder's AIO Boards

Post by HoolyHoo » Sun May 13, 2018 8:22 am

Wailer wrote:
Sun May 13, 2018 8:04 am
JackReacher wrote:
Sat May 12, 2018 1:00 pm
Hi,
I am in the same situation here.. i am really confused on how to use my teensy 2.0 as a gamepad + battery monitor.. i flashed the hex but i am unable to assign the correct pins..if anyone could help would be very appreciated..
I am actually using the sketch found in this thread.
https://sudomod.com/forum/viewtopic.php ... sd+arduino
But I've got a feeling that it's not accurate enough...
A little "nervous" battery symbol (when battery level is getting at a switching point) and the "battery low" message is kicking in quite fast (maybe too soon).
So i wanted to compare this sketch with Hoolyhoo's original arduino sketch.

Just for info, hex files are already compiled sketch files who only need to be uploaded to your arduino.
They cannot be edited.
Sketches can but, you need the arduino ide to compile and upload.
https://www.arduino.cc/en/Main/Software
Hello, actually I looked and couldn’t find the source file I made but it’s very similar to the post in the link.

You should be able to adjust the battery level icons and video kick in by adjusting the values in the python part of the script. The Arduino sketch only passes the battery levels but the python script does the work.

JackReacher
Posts: 14
Joined: Fri May 11, 2018 12:49 am
Location: Rome, Italy
Has thanked: 2 times

Re: OSD Battery Monitoring for Helder's AIO Boards

Post by JackReacher » Sun May 13, 2018 8:44 am

Thanks wailer, thanks hooly, I saw the thread you are referring a few days ago, but the pins on my teensy are differently numbered, i tried to change but i kept getting error messages (that happens when you are out of you depth😂😂)
Also in that thread says to upload the sketch and then install everything from the hooly guide which is something that got me confused: is it referring to the pyton part on the raspberry?

I guess my knowlwdge here is very limited so if you are able to help me out it would be great!

User avatar
Wailer
Posts: 119
Joined: Mon Jan 15, 2018 3:45 pm
Location: Tiel, The Netherlands
Has thanked: 30 times
Been thanked: 38 times

Re: OSD Battery Monitoring for Helder's AIO Boards

Post by Wailer » Sun May 13, 2018 9:09 am

You're on the right track.
In a nutshell, the arduino measure's the battery voltage and passes this to the raspberry (when asked).
So...
You have to upload the sketch from lotusalex2000 to your arduino and the script from hoolyhoo to your raspberry.

If you open the arduino sketch you can change the button layout in the first part.

Code: Select all

#define NUM_BUTTONS 17
#define BTN_UP 0
#define BTN_DOWN 1
#define BTN_LEFT 2
#define BTN_RIGHT 3
#define BTN_A 4
#define BTN_START 5
#define BTN_Y 6
#define BTN_L1 7
#define BTN_X 8
#define BTN_R1 9
#define BTN_B 10
#define BTN_SELECT 14
I adapted this piece to my leo, i will try to post my code as reference.
I changed a few other things as well, making it easier to remap your buttons.
But will need access to my laptop for that...

Will get back on this....

JackReacher
Posts: 14
Joined: Fri May 11, 2018 12:49 am
Location: Rome, Italy
Has thanked: 2 times

Re: OSD Battery Monitoring for Helder's AIO Boards

Post by JackReacher » Sun May 13, 2018 9:59 am

Thanks, i will try again..

Only one question where do i change the code to assign pin 21(A0) to the battery reading? Is it handled by the second part of the script and works by its own or do i have to tinker with it?

User avatar
Wailer
Posts: 119
Joined: Mon Jan 15, 2018 3:45 pm
Location: Tiel, The Netherlands
Has thanked: 30 times
Been thanked: 38 times

Re: OSD Battery Monitoring for Helder's AIO Boards

Post by Wailer » Sun May 13, 2018 10:49 am

That's in the Gamepad.write(); section
Just change A0 in the analog input you want to use (A0 to A3).

This line:
int sensorValue = analogRead(A0);

You can only use this analog inputs No other!
The other pins are digital only, for this reason the arduino is used, the raspberry has no means of analog reading (otherwise things would have been a lot simpler).

Don't forget the 10K resistor and wire this via the on/of switch to the +side of you lipo.
This 3v line has to be disconnected when the system is down to prevent damage to your arduino (theoretically, because my kids regularly forget to throw the switch after playing with no serious problems so far ;) but better be safe then sorry!).

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest