Distance sensor works on USB but not on battery

Hi all,

I'm quite new to the all Arduino wonder, so please don't blame me so far :slight_smile:

I have one small project: I've built a small distance sensor using an Arduino Nano, a NRF24L01 radio and a HC-SR04 sensor. I've setup the whole stuff using the sketch provided at MySensors.

However, I've got a small issue here: when USB connected to my computer, the sensor works perfectly, powers up and sends the value to the gateway. But when I use an external power source (1x9V battery please don't blame me), the sensor powers up but no value is being sent.

I've already read that this could come from not enough power being sent to the sensor. Please note that the battery is brand new. I've measured the values, and the sensor receives 6.22V with the battery vs. 5.96V with the USB. The same applies for the radio which receives 3.95V with the battery vs. 4.02V with the USB.

So can someone please help me to understand what is going on and how to solve the issue? Should I use any kind of capacitor? Of which value and where wired?
Thanks a lot in advance for your help!

n2xt:
1x9V battery please don't blame me

I really don't know why you would write that, as I submit you should accept all the blame for a self-inflicted problem. You have already proven that there is nothing wrong with your equipment and code - until you change to a 9v battery, which you even measure and see that it gives only the bare minimum voltage.

There was some good discussion recently on using a capacitor with a SIM900 shield, but I'm not sure it would help much as I imagine the nano runs continuously and the NRF is intermittent, but the latter runs on practically nothing anyway. I don't know anything about the HC-SR04, but you can be pretty sure that the 9v battery is the real problem and I imagine you will have to do a lot of research into sleep modes, and other methods of power saving, if you insist on using a battery that hasn't got any.

Hi Nick,
Thanks for your answer. Anyway, the thing I don't understand is that it seems that I have as much V on the sensor with the USB as with the battery...
In that case what is the best approach to provide "portable" power?
Thanks again Nick!

The volts are only part of the game, you need watts to actually do anything. USB provides adequate power direct. A 9v battery provides inadequate power via a voltage regulator wherein a lot is wasted, and just heats up the regulator.

The solution is to use a battery that is up to the job, and put the 9v, which isn't up to the job, back in the smoke detector where it belongs. 6xAA NiMH is probably a fair minimum. Then there is all the power saving stuff I alluded to, but don't actually know much about.