0
\$\begingroup\$

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?

\$\endgroup\$
  • \$\begingroup\$ Can you show the circuit? Sound like grounding issues. \$\endgroup\$ – Eugene Sh. Nov 18 '14 at 17:29
  • \$\begingroup\$ I'm drawing it with Fritzing. Anyway it works well when connected via usb. \$\endgroup\$ – UserK Nov 18 '14 at 17:43
  • 1
    \$\begingroup\$ LiPo powering will require a LDO 3.6V regulator, reducing the MCU frequency to below 12MHz, and setting the BOR to 2.7V. \$\endgroup\$ – Ignacio Vazquez-Abrams Nov 18 '14 at 18:00
  • 1
    \$\begingroup\$ Then either switch to a buck-boost converter or use part of the MCU as a boost converter. \$\endgroup\$ – Ignacio Vazquez-Abrams Nov 18 '14 at 18:11
  • 2
    \$\begingroup\$ Something seems fishy here - you are powering the accelerometer off the Arduino's regulated 3.3v so it shouldn't be sensitive to unregulated supply voltage. What is your voltage on the battery under load? What is your voltage on the 3.3v rail, and on the accelerometer output? Note that there are probably better solutions, such as digital output accelerometers. A typical modern micro-quadcopter board contains a 6 axis gyro/accelerometer chip, a reprogrammable microcontroller (varies), a bidirectional 2.4 GHz radio and is already designed for battery power in a small, inexpensive board. \$\endgroup\$ – Chris Stratton Nov 18 '14 at 18:52
1
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ A cheap 9v battery was the problem. \$\endgroup\$ – UserK Nov 21 '14 at 0:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.