Arduino standalone with 9V battery and accelerometer

accelerometerarduinobatteries

I'm using an Arduino Mega for a project involving an accelerometer. Everything works fine when the board is connected via USB. When I use a 9V battery plugged in with the 2.1mm jack, values are completely messed up.

I'm using a MMA7260Q triple axis accelerometer, which gives an analog voltage for each of the three outputs. The voltage is in ratio to the measured acceleration and to the supply voltage. In order to read the correct values the following code is required: (in the 800 mV/g mode)

 int accValX = analogRead(A0);

 accX = (((accValX*5000.0)/1023.0)-X_0)/800;

Probably the voltage is not constant and that affects the acceleration readings.

I've connected the sensor as shown below. The picture is from this tutorial, the board I've used is the Mega version. The 9v battery is used with the 2.1mm jack and a power adapter as show here.

enter image description here

  • Am I using the correct set up to power on the board? Or should I use the Vin pin to supply the 9V…

  • I've read in this question that 9V batteries are not the best choice to power on the Arduino for a standalone application. What does a LiPo-powered setup require?

Best Answer

Your problem has one of three probable causes.

Cheap or dead 9V battery.

Current draw too much for a 9V battery.

A bad linear regulator on Vin.

Try a new 9V, and not a dollar store brand. If that doesn't work, try a 7.5 to 12 volt adaptor on Vin. This will help eliminate the three probable cause.

Usb bypasses both the linear regulator and avoids the low quality current issue of 9V batteries. A cheap solution for Lipo battery packs are using usb battery packs, they are lipos with charging circuitry, cutoff and boost to 5V. No mudding of the pack or Arduino needed