Infomation about battery indicator


#1

I have some problems with the sketch about the, Battery Indicator on a oled display 0.96 128x32

at the front of the sketc , asking for the; #include <U8g2lib.h>
#include <U8x8lib.h>

I do use a arduino

I hope you could help me out because i have some problems.

because if I download and try to save at IDE I get a error

i hope you could suply with a complete sketch including those U8g2lib h>/U8x8lib h>

I will use the battery indicator for my model truck and I’m not good at programming ( age 77 )

please, I will be greetfull

best wishes

swiftrapid


#2

Hello @swiftrapid,

The u8g2 is a library (not made by us) that you have to install in the Arduino IDE.
Here are the instructions for installing it: https://github.com/olikraus/u8g2/wiki/u8g2install


#3

Dear Ivan

The reason I couldn’t download the u8g2 was, I didn’t have Java installed , I have it now

It’s now installed in the Library manager

I don’t know what to do next

Please may I have some help

Best wishes

swiftrapid


#4

Hello @swiftrapid

I do not have a clear idea of what kind of help do you need, what have you done, or the problem you have.

To post in the forum, please do not answer to forum emails, otherwise the message won’t probably be read. Come here (https://forum.artekit.eu/) and keep writing in this thread.


#5

Like i wrote the sketch U8g2 is installed in the library manager

I want to use with the sketch for the battery indicator to instal it on a Arduino Nano

How do I do that

swiftrapid


#6

In this case I don’t know what to say other than: connect the display then compile and download the sketch to the Arduino.

I am sorry if I can’t give you a better answer, but I really don’t understand the specific problems you have with the example.

If you don’t have basic experience with Arduino or with electronics (needed to be able to connect a display and compile and download an Arduino sketch) then I am afraid I can’t guide you in a step-by-step school fashion, but I can give a hand if you find a specific problem.


#7

when I did compile and downoad the sketch to the arduino Nano, I got a message not enough memory

and I only can use the Nano, because it’s size is just right to fit in my model truck 1:14.5

best wishes

swiftrapid


#8

Arduino:1,8.7 (windows10),Board:Ärduino Nano, Atmega328P"
The sketch uses 7694 bytes (25%) sketch use. maximum is 3070 bytes
roughly varyables use 2479 bytes (121%) of the dynamic memory. Test -431 bytes for local variables .
Maximum is 2048 bytes.
Not enough memory

this is a mesage i got after compile/ upload to my Nano


#9

Hello @swiftrapid,

I see.
Try changing this line:

static unsigned char battery_bitmap[] = {

to this:

static const unsigned char battery_bitmap[] = {

#10

I did but, got another error

‘----------------------------------------------------------’ was not declared in this scope

  • showen as ( a line )

best wishes

swiftrapid


#11

I don’t know about that error. If changed correctly, it should compile.

In any case, the correct line should be:

static const PROGMEM unsigned char battery_bitmap[] = {

And also change:

display.drawXBM(0, 0, 128, 64, battery_bitmap);

with

display.drawXBMP(0, 0, 128, 64, battery_bitmap);

#12

Arduino:1.8.7 (Windows 10), Board:“Arduino Nano, ATmega328P”

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xf1
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xf1
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xf1
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xf1
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xf1
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xf1
avrdude: stk500_recv(): programmer is not responding
Problem by uploaden to board. Zie http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xf1
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xf1
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xf1
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xf1

I got this mesage, after uploading to a Nano

best wishes
swiftrapid


#13

Those are errors while trying to upload. Not related to the sketch.
Check your Arduino setup and wiring.


#14

Then it must work correct no erros

I think I connected all wiring in the correct way ( Breadboard ) should I see something on the display
SSD1306 Oled

where do i connect the battery by nano

suply usb port

ssd1306 arduino
vid 4.64 V - 5v 4.64V
gnd +cs gnd
sck 12
sda 11
res 10
dc 9

Do you think that’s right

Best wishes

swiftrapid


#15

Hi @swiftrapid,

As far as I can tell, the sketch isn’t running because it didn’t finished the download. How the display is connected may be irrelevant at this point, since the sketch should be downloaded with or without the display connected.

If you think there is a problem with this particular sketch, then test the Nano + display with any other sketch. At least it will validate that your setup works OK. Or download any sketch for that matter, so you can test your Nano and the Arduino IDE are working correctly.

Important: note that the sketch doesn’t read any battery so you will have to figure out where and how to connect it. See what the tutorial says about it:

Note that the code up here is a generic one and doesn’t measure any battery. It serves only to show a given battery charge percent. This is because the code for reading a battery will be different for every kind of battery and quantity of batteries you are measuring (because of the different discharge curves).

This sketch it’s just a simple example on how to show a battery indicator. The task of connecting and measuring a battery is left to the user.


#16

Dear Ivan,

I did try to upload the sketch to 3 Nano’s ( to test ) with the same error mesage;

did’t connect anything to them !

avrdude: stk500_recv(): programmer is not responding

What els could be wrong

best wishes

swiftrapid


#17

Hi @swiftrapid,

programmer is not responding

It isn’t related to the sketch. Your programmer is not responding.

You may have problems with your Arduino IDE + Nano setup that are not related to the sketch itself.
Try to download any another sketch that isn’t the display demo (or an empty sketch) to check if you still have problems. If so, I cannot do much from here and suggest you to check the Arduino help.


#18

I did try it on a arduino UNO it works perfect, the display show 3 blocks then ( after ±6 secunds) two then and again ( after ± 6 secunds ) zero is that correct

May I ask something els,

is it possible to have 5 blocks inside the accu

20%,40%,60%.80%,100%

What changes are to be made in the sketch swiftrap

Thank you

swiftrapid


#19

The code is set as a demo that cycles through all the levels.

The code to change is inside the showBatteryLevel function. There you have to set the percents you want (it’s described with comments) and adjust the width of the internal bars (right now each bar has 27 pixels).

Or change

#define BATTERY_MODE_SOLID 0

to

#define BATTERY_MODE_SOLID 1

to have a single solid bar that shows (almost) every percent level.


#20

Dear Ivan,

then I have a question what has to changed to have a working sketch in stead of a demo

I want to use it on a 12v NI-CD accu or Ni-Mh

Best wishes

swiftrad