Arduino powered speedometer

I forgot something, something I mentioned myself in post #23. Now it is safe to connect USB.

Keep the odometer value in a normal variable, after it's read from EEPROM at startup.
Write the live odometer value back to EEPROM every 10 minutes or similar, or when speed reaches zero - so the EEPROM is not being updated frequently and you wont lose much distance in case of electrical failure.

GPS units usually have a warm start time, like 10 minutes since last powered on or something, where startup and acquisition is quite fast (a few seconds?). A cold start could takes much longer for acquisition and we could probably assume that would be OK since the car may also require warm-up.

Better get back to the MOSFET from post #99.

If you still want help, just ask.

Could have read War and Peace by now.
An Arduino epic.

Still, iterations like these is what produces a decent design.

Hmm
Read post #122
Sometimes, it can get so long that you lose track of the original question.
Design by committee has its benefits, but the Arduino community is a large committee.

The focus of this thread has indeed changed, so has the title. The original question was about strange measurements on a bus line. In hindsight I attribute this to thoughtless use of power sources, without being able to pinpoint it exactly. The first actual schematics showed 4 different voltage regulators, plus 2 on the board, it's easy to lose track.

More like total confusion for the OP who has apparently left the topic 4 days ago.

No, I am still here, and getting over my confusion. I have been busy trying to change my design to incorporate the recommendations, but it has been a moving target. I have finally caught up, I think, so I have attached the latest design. I have mostly gone with what @stitech has recommended, but with a few changes. I agree with @jim-p that I shouldn’t connect battery voltage to the Arduino input, even through the voltage divider, so I put in an opto-isolator on one place. It is really an on-off situation, and so the optoisolator will work fine there. Unfortunately, the other instance is measuring voltage, so I could not elminate it. I also believe that @jim-p said that he agreed with putting a voltage regulator on the Vin, so I have added that. I did look at the datasheets more closely, and have seen some of the things I missed before. Thanks, @jim-p, for insisting that I look at them. I saw why the TP2104 MOSFET was such a bad choice now. I am learning, and that is the whole point of Arduino anyway, isn’t it?

My observations of your latest schematics:

  • You went back to an optocoupler for Switched 12V. Why? (What's wrong with the protection the voltage divider provided, other than complying to jim-p's bible?)
  • You will blow the optocoupler the moment you apply Switched 12V.
  • You use 5% resistors (probably carbon film) in a circuit that is able to measure with 10bit accuracy. (Metal film resistors, usually 1%, are recommended for general applications.)
  • You use 0.25W resistors. In most cases 0.125W is sufficient and saves space (your choice).
  • You added a capacitor to the voltage divider of 12V from Battery. Why? (You introduced a delay of 125ms to an input that is meant to give you 90ms before saving your data.)
  • The capacitor at the voltage divider of 12V from Battery will blow your input the moment you switch off the power to the Nano Every.
  • You flipped Q4.
  • You went back to a 9V regulator before the regulator of the Nano Every. Why? (What advantage do you expect, other than complying to jim-p's bible?) (It also reduces the time you have to save your data, which may or may not be significant.)
  • Remove the connection between 3V3 and AREF. (Was meant A0, not used anymore.)
  • Remove R8 and R10. MOSI and MISO don't require pull-ups, let alone pull-downs. (Are you even using them?)
  • Remove R9. TB6612 has a pull-down internally.

Keep the good work up with reading datasheets.

I just thought that it would be safer.

I see that. I missed the input voltage. I don’t see one that handles the 15V. Back to the voltage divider.

Where do I learn this?

You had one on your diagram. I just used a larger one because I have them on hand.

Can you explain, so I don’t make the mistake again?

I read here: Arduino Nano Every Specifications/Functions | Spiceman, that the recommended voltage is 7-12 V, and elsewhere that the best is 9v.

I was just using aadvice like found in this: Understanding the Pull-up/Pull-down Resistors With Arduino : 6 Steps - Instructables

Thanks. Missed that one, too. I look at these datasheets, but I often don’t know which data is pertinent to my decisions. I need all the help I can get.

I have two more commandments for my Bible:
Never connect a powered device to an unpowered Arduino.
Always connect a 0.1uF decoupling capacitor on all IC Vcc pins.

Should I do something like this:

The problem is that you have the 12V battery connected to the Arduino through the voltage divider when the Arduino is unpowered. Supplying a voltage to an unpowered device can cause all kinds of unknown problems. It should be disconnected when the Arduino is powered down.

If it's safe enough, you can add any amount of safety blankets without any benefits.

The input of that optocoupler is a LED. Any voltage applied without a resistor will result in unlimited current.

Google: resistor carbon metal.

In post #52 I indeed added a capacitor. Also, the signal came in without any protection. In later versions the signal came from after a TVS. Using a component just because it is "on hand" is not good design.

When VCC to the ATmega4809 drops, the capacitor will discharge it's energy through the parasitic diode of the pin, current not limited by anything. To be safe, the current into a pin should be limited to 1mA or less.

Spiceman made a very common mistake: he mixed up the Nano and the Nano Every.

That page covers pull-ups and pull-downs in combination with pushbuttons, very basic. The SPI peripherial in the AVR microprocessors is designed to work without pull-ups (read the datasheet). And: do you even use these pins?

A diode array is a solution for a problem that does not apply to your case.

I understand. How can I solve this problem?

As said: limit the current to less than 1mA.

Connect he voltage divider to the Drain of Q5. That way when you turn off the Adduino you will also disconnect the voltage.

I see that in order to protect your car wiring you will need to blow two fuses.

It does indeed disconnect the voltage from the divider. One thing though: it still is disconnected when I want to measure the voltage to switch Q5 on, so it never will be switched on. Plus: more safety blankets...