Go Down

Topic: Using the hardware serial and the need to program (Read 745 times) previous topic - next topic


I guess this is a meta-question with an answer that's obvious in hindsight, but the use of the terms for other reasons has lead to a failure to google the answer.

Is there a clean way to deal with the need to program the sketch onto the arduino (barring those where you pull the processor), and using the hardware serial port?

Just as an example, an AT09 bluetooth appears to come up with TX high, which would presumably be a problem while programming from the USB port, or even the header.  I'm coming up with schemes of using data pins or mosfets to only feed power to hardware devices once the setup() loop is reached, or hardware to detect power on the usb connector, or .  . .

I suspect that I'm missing something--likely something big . . .


You can use the USB connector to program Arduinos. If Your sketch uses Tx/Rx You can use Software Serial for Your application and then awoid conflicts with the downloading channel. This works for UNOs.
Use Your knowledge. If that's not enough, look for education.
Having knowledge, think outside the box to gain more of it. Only trains run like the train, on the rails. The rest run between the rails.


Dec 10, 2018, 04:16 am Last Edit: Dec 10, 2018, 07:56 am by Nick_Pyner
I suspect that I'm missing something--likely something big . . .
Proably not, but you may be seeing a problem that isn't as big as you think it is. Just ensure that Bluetooth is disconnected while you upload the programme. It isn't hard, and all that other stuff is really superfluous. I think the most you would ever need is a normally-on button or a jumper in the power supply to perhaps make things more convenient if you have to reprogramme the project in the field. Having bluetooth on hardware serial means that you can do all your communications debugging using the serial monitor - i.e. without the bluetooth module being connected - thereby only having to connect bluetooth once.



I' currently switching from alt soft serial to AltSoftSerial for debugging what I'm doing, but I've gotten the idea (possibly wrong) that power consumption will be moderately lower with the hardware serial, if for no other reasons than that the cpu will doze and that it will execute less instructions.

I keep finding web references to shutting down the usb circuitry, but the closest I've come to a method is a page noting the power differences and then "TODO  code samples" . . . :smiley-roll:

I had *thought*I'd found the function while reading something else, but apparently not.

Ultimately, these will be about my garden and yard running off batteries recharged by solar cells, so every bit of power I can save helps, including being able to shut it off more often mid-task.

Hey, my tomatoes are at stake! :)

I'm currently considering feeding the power of the AT-09 off a digital pin; it seems to be within the power budget. Alternatively, using a pin to feed it and other peripherals (temp, humidity, water sensors) through a mosfet.  This would also save power as 90% to 99% of the time when the system wakes up it will check the time and see that it isn't due to make a report yet, so why waste power? (note: the AT-09 comes up with its TX high, so I can't simply have it powered if the USB TX could be live).

So the pseudocode would roughly be

Code: [Select]
void setup(){

void loop{
if (millis() < nextActive){doze(0); break;}

digitalWrite(btPower, HIGH);


I suppose that with AltSoftSerial instead of SoftSerial, it could doze between half-bits, too, given the interrupts it uses . . .

It also seems, well, "cleaner" to use the hardware . . .

*Is* there a way  to shut off the usb, which I called "usb.shutoff()" above?  Or is this a matter of cutting traces and using a programmer (I've got a coupe in my pile of parts).

If I use a button/jumper like@Nick_Pyner mentioned, I would still need to disable the  USB hardware with cut traces, wouldn't I?

And one more thought that didn't make it in . . . I've toyed with the idea connecting the USB power to an analog input so that early in setup() it could figure out whether or not to run at all.  Or to use it with a mosfet to deny power to the AT-09 if present . . .

But the biggie remains whether I can shutdown the USB circuitry by software, or whether this needs a hardware solution . . .


If I use a button/jumper like@Nick_Pyner mentioned, I would still need to disable the  USB hardware with cut traces, wouldn't I?
I was only alluding to a means of isolating bluetooth while uploading a revised programme in the field, and it was only as an (unlikely) alternative to unplugging the bluetooth module itself.  I submit all this stuff about cutting the USB circuitry traces is arrant nonsense anyway. If you are worried about that, why don't you get a Pro Mini,  which is made for this sort of thing and is already devoid of the circuitry, feed it with a properly designed power supply - even 3.3v, and programme it with a programmer which you apparently already have?  A case can be made for using software serial in the need for two serial facilities on a Uno etc., but that is not evident here, and you may later regret the bad habit..


In hindsight, pro mini would have been a better choice.  I ordered a binful of this and that and plunged in . . .

. . .

I haven't found a direct answer, but it looks like the FT2232H chip used in a branded nano draws 500ua (but that may be of 1.8v that it's dropped down),  standby for its core, while the less capable CH340 used in clones draws 80uas standby.  Or maybe I'm reading the sheets wrong.  So if the board is spending 99% of time in sleep, that may not be much anyway.

I guess the practical concern comes down to what the TX of the usb chip says to the RX of the 328p when it isn't in use--is it a HIGH like the AT-09, or an open?

I suppose the obvious answer is to check, but with the usb connected to talk to the computer, that might changer the answer.

I suppose.a quick sketch that configures the pin for pulldown input, reads the pin, and turns on one of two less , powered externally, would answer this . . .

And on a breadboard, I suppose I could use altsoftserial and a usb board to talk to the computer serial monitor . . .


it looks like the FT2232H chip used in a branded nano draws 500ua ( Or maybe I'm reading the sheets wrong. 
Well I hope you didn't spend too much time chasing that pearl of wisdom down. Since everybody else's FT2232Hs spend virtually their entire lives in the bottom drawer not connected to anything, you might question why you needed to read the data sheet at all. I think you are just trying to make things harder than they really are. You are far from the first to want to use Arduino to grow tomatoes and you will find plenty of support around here about batteries, sleeping and power saving, none of which involves this rubbish, You should check that out before you by any more binfuls of anything. The bigger the bin, the less likely you are to use bluetooth in the first place. You may find you should have bought NRF24s, which I believe are far more frugal on power than any bluetooth.


Branded nanos use an ft232rl chip.   The ft2232h is entirely different (high speed rather than "full speed", used in some jtag programmers, I think.


The RX pin expects a high as the idle state. So it's not very likely the the USB-to-TTL will not drive its TX pin high

Disconnecting power from the BT module comes with other risks. It's possible that the TX of the arduino powers the BT through the RX line. It's called parasitic powering and is usually a bad idea.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.


Hmm.   Now *what* did it do with the response I just wrote??? 

As far as the FTxxx chips, yes, it appears that I either mistyped when I googled, or didn't catch googles ever-more-promiscuous use of near-matches.

But it looks like the FT232rl still uses a significant portion of an ma on standby.

And as far as the parasitic power goes . . .

Not believing that any engineer could be that daft (which required not recalling that the wall remote for my dining room fan draws its power between hot and ground!), I pulled the vcc to the AT-09.

It not only continued blinking, but it was fully functional, transmitting and receiving as if nothing ever happened . . .

So even if there *were* savable settings that let it power up with the TX pin disabled or the USB off, it looks like it would be a dead end anyway.

On the bright side, there's a 3.3v pro mini on my workbench to experiment with until more arrive, and I can still make the first prototype to put out there using AltSoftSerial (I really *do* want to know the overnight temperature in my hothouse!).

thanks to all (even if you did drive stakes through my poor vampire's heart  :smiley-lol: )

Go Up