I was supplying my device (timer) with USB and my capacitive sensor was working. It is connected in that way: two pins, first receives, second sends. There is resistor between them and one cable which leads to foil. I touch the foil and Timer starts working.
But i decided to change method of power supply to 9V battery. Everything is working except of that sensor. I have to touch the battery to make sensor working, probably because of circuit closing. What can I do to repair that sensor - connect it to ground? How? With second cable connected to foil and ground on my board?
Sounds like a grounding issue. Can you supply a schematic?
Unfortunately, I don’t have schematic but I did small “schematic” (drawing) where you can see how I connected that sensor.
Power supply: Battery 9V + battery clip + 2.1/5.5 plug.
Sensor: From pins 0 and 1 cables connected with resistor 10K and one cable to foil.
I use digital pins for connecting LCD, buzzer, diode, switches and one capacitive sensor. GND from the “digital pins side” connected to board, 5V from the other side also to board.
Try using other pins. Pins 0 and 1 (RX and TX) have connections to them on board that will interfere with what you are trying to do.
It doesn't help, sorry, my mistake - I tried to use 0 and 1 few days ago but it wasn't good. So I've changed it into 8 and 9 pins. And there is a problem on these pins. I was reading about problems with ground with sensors, maybe something with that?
Is it possible to check serial monitor when arduino is connected to 9V battery? What would supply arduino when I connect both battery and USB?
In this circuit, you don't need ground (you are the ground!)
Make sure you have the foil on the RX (receive) side, not the transmit side like you show in your diagram.
Make sure your resistor is about 200K - 400K, not 10K.
Edit: Actually 1Meg to 10Meg ohms might even work better.
Ok, I was thinking about trying with other resistor. But what is interesting for me is that: with USB supply it's ok, with battery supply it's not ok. So there is some influence of the type of powef supply. And what is more interesting: it works when I touch sensor and battery at the same time
I was using 10K resistor because it gave me quite good results to achieve the effect when sensor works only when you touch it quite hard. I will get bigger resistors and I will manipulate with it through the code.
But it is still very fascinating for me why it works only when I touch battery
With the USB, you are connecting to a bigger ground system and the effect would be stronger.
BTW, if you use a 9V battery with the USB, the power will come from the 9V battery but the larger ground will still come from the USB (computer).
It might also be a good idea to measure the 9V battery once everything is hooked up to make sure it maintains about 7V or more for the regulator to work right. Make sure the Vcc on the ATmega does not drop too low as this might affect things as well.
You are measuring the capacitance between the foil and circuit common. When you touch the foil, your body is essentially making it as if the foil were much larger. In the case of using a power supply, the circuit common is coupled to Earth ground by capacitive coupling in the power supply.
On a battery, now the only coupling between you and circuit common is the very small traces on the Arduino.
So try putting two pieces of foil next to each other, one connected to the Arduino pin as usual, the other to Arduino ground. The amount of capacitance will still be a lot less than it was using a power supply, but lots more than without the foil.
Yes they are, and I explain how to recharge them with Arduino in this video: Recharge CR2032 button cell batteries with Arduino - YouTube
Reuse to save the planet!