progamming an arduino with RPI's tx/rx pins

Dear people,

I am going to solder a shield for a raspberry pi 3B. This shield will also contain an arduino nano. I need the arduino as a signal generator to control model trains. The RPI will run a program which communicates to this arduino serially.

I have a working setup and now I am packing it togather. My current plan is to use the usb cable to the arduino like I am doing now. But as I am soldering the arduino on the pi I started wondering. Could I use the Rx/Tx pins and 3V3 pin of the pi instead of the usb cable

Ofcourse that is possible. But unfortunately this raspberry Pi also needs to flash the arduino with new programs. I do this via the arduino-cli tool. The whole action is done remotely from my work PC. I send a hex file over with SCP and then I run a shellscript to start the uploading.

Now the question: Can I directly flash a program using just the Rx/Tx pins of both devices. I understand I also need to let the raspberry give a reset pulse on the arduino's reset pin in order for this to work.

Has this been done before? I am guessing it is not that hard and I can do it relatively easy, but asking in advance does not hurt right?

Bas

No, the bootloader needs a pulse on DTR to enter programming mode.

bask185: I understand I also need to let the raspberry give a reset pulse on the Arduino's reset pin in order for this to work.

Correct. So you need an available I/O pin on the Pi to do this.

But you also need a level converter - such as a 74HCT14 with two gates in tandem - between the Pi and Nano to generate the required 5 V level for the reset and it makes sense to also buffer the Tx line from Pi to Nano with the other available gates (unused gates tied to ground or 5 V) and a series diode (cathode to Nano) and pull-up to 3.3 V to limit the logic level back to the Pi.

If you are not using the USB interface on the Nano, you might as well use a Pro Mini,

aarg: No, the bootloader needs a pulse on DTR to enter programming mode.

I litterly typed this

I understand I also need to let the raspberry give a reset pulse on the arduino's reset pin in order for this to work.

Did you miss this, or did you just read the title and press 'reply' before reading anything else I wrote?

Paul__B: But you also need a level converter - such as a 74HCT14 with two gates in tandem - between the Pi and Nano to generate the required 5 V level for the reset and it makes sense to also buffer the Tx line from Pi to Nano with the other available gates (unused gates tied to ground or 5 V) and a series diode (cathode to Nano) and pull-up to 3.3 V to limit the logic level back to the Pi.

Well I was thinking, were I to go for the Tx/Rx pins, I would just feed the arduino with the 3V3 pin of the RPI instead. So I can directly tie the Rx/Tx pins to eachother.

What I do not know. If I feed an arduino with 3V3 does the reset pin still has to be raised to 5V or would 3V3 suffice?

If you are not using the USB interface on the Nano, you might as well use a Pro Mini,

No not really, considere the following:

  • The nano's are generally cheaper on banggood. I buy them for €1,70 ~ €1,80 each.
  • I already bought them en masse. I have plenty of them lying around right now. And I have 0 pro mini's
  • I am generally very content with the usb socket as well as with the onboard voltage regulator.
  • If I would need a logic level converter, I can either spend atleast 4€ shipping costs or I have to wait 3 weeks to get one here.
  • I happen to have some very short mini-usb cables which I am not using.
  • Space is in abundance today, so I care little for that 1cm extra space.

  • if I I need a logic level converter. That chip also has to be on the PCB, so the space you would safe would be needed for this converter. In the long run you would only gain more costs, more space and slightly more effort

Bas

The Arduino that operates at 3.3 V is the 3.3 V Pro Mini with an 8 MHz crystal. A 5 V Pro Mini, Nano or UNO (or similar) with a 16 MHz crystal will not operate reliably at 3.3 V. It might operate, but you cannot depend on it. :roll_eyes:

It should be obvious that the Reset pin ties to Vcc (with a resistor).

Whatever you are using that operates at 5 V arguably should use a level converter although the Arduino will generally be able to read the P's 3.3 V signals directly. It probably will operate, but you cannot depend on it 100%. :roll_eyes:

Paul__B: The Arduino that operates at 3.3 V is the 3.3 V Pro Mini with an 8 MHz crystal. A 5 V Pro Mini, Nano or UNO (or similar) with a 16 MHz crystal will not operate reliably at 3.3 V. It might operate, but you cannot depend on it. :roll_eyes:

This I hear for the first time. Where do you get this from? The datasheet dictates that the atmega328p works with anything above 2.7V, therfore 3V3 should not be a problem. I fed arduinos with 2 AA batteries and never had any problems with them.

It should be obvious that the Reset pin ties to Vcc (with a resistor).

In my eyes this was also likely the case, but I would not ever make the assumption in the first place. I once build a device which had to read out certain program ID numbers out of PIC uControllers. In order to do that you have to force the things into program mode. And in order to do that you had to apply a voltage of ~12V on the reset pin. However, some of the devices needed 9V and another one worked with yet another voltage. This device I made also was used at both 3V3 and 5V. Point: some uControllers may work in mysterious ways.

For all I know there could be an internal 4.5V zener diode behind that reset pin or whatever. Anyways next time I'll look that up in the datasheet. I was just wondering if other people were using this method to program arduino's

Whatever you are using that operates at 5 V arguably should use a level converter although the Arduino will generally be able to read the P's 3.3 V signals directly. It probably will operate, but you cannot depend on it 100%. :roll_eyes:

That is indeed arguably allright, you often get away with current limiting resistors and a pair of clamping diodes. Honesty, I have never used a level shifter before. I do use an optocoupler now and then but that is only for high voltages (12V- 18V)

Bas

bask185: This I hear for the first time.

There is a first time for everything, but better believe it from a member with almost 20k posts. There is a graph somewhere in that datasheet linking operating voltage to max clock speed. IIRC, 16Mhz should have a supply voltage of >=3.85volt. Under-volting is the same overclocking. Sometimes it works, sometimes it doesn't. Not across the whole temp range, or not every part/module inside the processor. Leo..

Wawa: ...but better believe it from a member with almost 20k posts

Not to offend you but this is really not an argument, not that I don't believe you or something. But the amount of posts is no good measurement for one's intelligence.

If somebody talks alot it does not make him smarter perse. We have this guy at work, who talks in a bombastic way about everything. He pretends he knows everything about every subject, this may be about software or it may be about star trek or cars or whatever. He always ends up saying things which are aren't true. But boy, can he talk with conviction.

There are still people with lots of posts who still say you should not use typedefs or macros or that you should never connect power supplies parallel or never connect 3V3 with 5V devices blah blah...

So again, I do believe you. + I am grateful for your help. But I simply don't take everything for granted anymore.

Kind regards,

Bas

bask185: I once build a device which had to read out certain program ID numbers out of PIC uControllers. In order to do that you have to force the things into program mode. And in order to do that you had to apply a voltage of ~12V on the reset pin. However, some of the devices needed 9V and another one worked with yet another voltage. This device I made also was used at both 3V3 and 5V. Point: some uControllers may work in mysterious ways.

Nothing whatsoever mysterious about it.

Programming mode (which applies also to the ATmegas for "parallel" programming) is a completely different situation to normal operation. Normal operation is specified between 1.8 to 5.5 V and within that range you provide inputs - including the reset pin which is incidentally, a "normal" I/O pin itself if you so choose - strictly within the range of ground to the supply voltage. That's just how it works. :grinning:

There are a few constraints however regarding the supply voltage, in particular that how fast you may reliably clock the microprocessor depends on the supply voltage and there is a "brown-out" detector which defaults to a certain voltage (but may be re-programmed to any of three settings or disabled).


bask185: There are still people with lots of posts who still say you should not use typedefs or macros or that you should never connect power supplies parallel or never connect 3V3 with 5V devices blah blah...

And in context, they may well be dead right!

(I don't know about the typedefs ... :cold_sweat: )

So did you Google for the "speed/voltage graph of an Atmega328" (images). Leo..

Wawa: So did you Google for the "speed/ voltage graph of an Atmega328" (images).

Figure 29-1 in the datasheet to be specific. :roll_eyes: