How to set software serial TX pin to low when not in use?

So I've got an arduino pro mini communicating with a bluetooth module fine. And to save power I sleep the arduino for 30 seconds at a time and power down the bluetooth module too.

The only problem is that when I go to sleep, the Arduino's Software Serial TX pin stays high and it leaks 30 mA through the RX pin of the Bluetooth module!

How can I set the Arduino Tx pin to stay low when I go to sleep?

This is the initialiser

SoftwareSerial BTSerial(3, 4);
 BTSerial.begin(9600);

And this is the sleep section

Serial.println("Sleeping void");
  delay(100);
  digitalWrite(BLE_RESET, LOW);
  digitalWrite(BLE_POWER, LOW);
  Serial.print("Ball_sleep_time:");
  Serial.println(Ball_sleep_time);
  delay(50);
  if (Ball_sleep_time >= 20)
  {
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
    LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF);
  }
  if (Ball_sleep_time >= 21) LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  if (Ball_sleep_time >= 22) LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  if (Ball_sleep_time >= 23) LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  if (Ball_sleep_time >= 24) LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  if (Ball_sleep_time >= 25) LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  if (Ball_sleep_time >= 26) LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  if (Ball_sleep_time >= 27) LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  if (Ball_sleep_time >= 28) LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  if (Ball_sleep_time >= 29) LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  if (Ball_sleep_time >= 30) LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);          
  digitalWrite(BLE_RESET, HIGH);
  digitalWrite(BLE_POWER, HIGH);  
  Serial.println("Ball awake");

I've tried quite a few ideas but it always seems to result in garbled characters when the unit wakes up. As the code above stands, I never get any garbled characters.

"How can I set the Arduino Tx pin to stay low when I go to sleep?"

digitalWrite( ) it low, or pinMode( ) it to an INPUT.

CrossRoads:
"How can I set the Arduino Tx pin to stay low when I go to sleep?"

digitalWrite( ) it low, or pinMode( ) it to an INPUT.

Thanks, that did the trick. Although it required the matching

digitalWrite(pin, HIGH )

to stop it from spewing out garbage over the serial link when it woke back up. I'm guessing it confuses the Software serial library otherwise because it's expecting that pin to be still high, and not have to re-set it high again.

Here's the working code in case anyone wants it.

  Serial.println("Sleeping void");
  delay(100);
  digitalWrite(BLE_RESET, LOW);
  digitalWrite(BLE_POWER, LOW);
  Serial.print("Ball_sleep_time:");
  Serial.println(Ball_sleep_time);
  //BTSerial.flush();
  //BTSerial.end();
  delay(50);
  digitalWrite(4, LOW);

  if (Ball_sleep_time >= 20)
  {
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
    LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF);
  }
  if (Ball_sleep_time >= 21) LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  if (Ball_sleep_time >= 22) LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  if (Ball_sleep_time >= 23) LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  if (Ball_sleep_time >= 24) LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  if (Ball_sleep_time >= 25) LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  if (Ball_sleep_time >= 26) LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  if (Ball_sleep_time >= 27) LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  if (Ball_sleep_time >= 28) LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  if (Ball_sleep_time >= 29) LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  if (Ball_sleep_time >= 30) LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF);
  digitalWrite(BLE_RESET, HIGH);
  digitalWrite(BLE_POWER, HIGH);
  digitalWrite(4, HIGH);
  //SoftwareSerial BTSerial(3, 4);
  //BTSerial.begin(9600);  
  //BTSerial.flush();
  Serial.println("Ball awake");

The Serial system idles with the Tx pin HIGH. The START bit is the transition from idle to active

...R

open sesame

to Dave_Sausages:

Because of your post I was able to solve my problem yesterday. I am using the ATmega328P DIL package running on 4.8 V battery at 16mHz. No regulator, no USB to serial converter, no LED's, with sleep mode for an hour before making some external temperature & humidity measurements and a Lora transmitter chip to send the data to my house (awake time of 15 seconds before next hourly nap including the Lora chip). I'm consuming about 35 mA avg. for 15 seconds and 32uA for an hour. The day before I was consuming 430uA instead of 32uA because I am using the SoftwareSerial to communicate with the Lora chip. When the microcontroller and the Lora chip go to sleep, the SoftwareSerial Tx pin is staying high and loaded by the voltage divider resistors needed to talk with the 3.3V Lora chip. I did the same thing that you did. I perform a digitalWrite LOW to the Tx pin before sleeping and back to HIGH at wakeup. I want to thank you for your investigations and post which avoided my spending a lot of time. Your solution will increase my battery life by a factor of 10! Bye!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.