Sunday, October 20, 2013

Tutorial: Battery charge indicator

If you have your own robot, you will see that you run out of battery at the worst moment. You can prevent this problem using a  Battery charge indicator. You only have to build an easy circuit that uses the integrated circuit LM339N. With this integrated circuit  you will have a Battery charge indicator with five different's levels of charge. Also, in this tutorial we will see how to prepare this circuit to connect it  on an Arduino.

This circuit is calculated for 7.2 volts batteries. That means that ONLY works with 7,2 volts. If you need a Battery charge indicator  for other batteries, you have to change the resistors. I can upload a post, if you ask for them on the comments.


  • LM339N
  • L7805CV
  • Variable Resistor 2KOhms
  • 3 X 220 Ohms Resistor
  • 8.2 KOhms Resistor
  • 4.7 KOhms Resistor
  • 4 leds (with diferent color will look better)

The circuit

Here is a diagram with all the connections that we had to made. I recommend to test it on a protoboard before make any soldering.

Setting up

Before using it we have to calibrate the Battery charge indicator. To calibrate we have to connect a full charge battery and move the variable resistor until all the led's are switched on. Then you have a practical Battery charge indicator! If you have  four led's on your battery is full charge and when all led's are off you have to change the batteries. 

Soldering and preparing for Arduino

Two circuits in the same board
In my case I have two independents  circuits on the same PCB. I also added a switch that permits to use the circuits with out powering the leds. Instead of that, you can connect four wires ( one per each led) to the arduino and print the battery status wherever you want. It just work like a switch, you can get 0 (led off) or 1 (led on).

Please leave a comment an subscribe for new tutorials. You can send your ideas or projects to

Tuesday, October 8, 2013

Sending floats using VirtualWire

We have a problem when we want to send floats using Virtual Wire.If you read the previous tutorials, and you tryed to send floats, you probably got ? .Arduino haven`t got enought power for using all functions with floats. Some functions like sscanf or sprintf are implanted but with out all the functions. You can send strings, ints but not floats because the hardware isn't enought powerfull to suport this part of the function.

 What can we  do?

Well, insted of sending floats we can convert the data into an string, send it and then, in the receiver, convert into a float again . This will be very easy using this function

dtostrf (double __val, signed char __width, unsigned char __prec, char *__s);

For more information:

In the receiver when we get the string we have to use the following lines of code:

char floatbuf[32]; // make this at least big enough for the whole string
stringwithfloat.toCharArray(floatbuf, sizeof(floatbuf));
float f = atof(floatbuf);