0

enter image description here

To save power, I removed the linear regulator from my Arduino Nano clone and powered it via the 5V pin from a regulated source (a rechargeable USB phone charger). However, I've noticed that removing the linear regulator causes the TX pin to stay on all the time, which results in my phone not being able to communicate with the HC05 bluetooth module although it connects fine. I checked that the TX pin is not caused by Serial.print and noticed the same behavior on all the Nano's I've removed linear regulators from. The Nano's I've tested with the linear regulator work fine, though they use more power than I'd like. I've tried resetting the device, but the problem persists.

I'm wondering what's causing this? Isn't powering via 5V pin suppose to bypass the regulator? So what could cause the missing regulator to affect the TX pin? Unfortunately, I'm not experienced enough to connect the dots using the schematic so I was hoping someone could help me.

Though I'm not sure if it'll help, I'ved included my sketch below. Basically, I'm making using a ultrasonic sensor to communicate distance with my phone via bluetooth. It also plays music when it detects movement (using PIR sensor). Since the application is outdoor use I'm powering via battery and trying to minimize energy use. I got it down to ~4 mA by removing linear regulator.

#include <avr/sleep.h>

#define bluetoothIntPin 2
#define pirInterruptPin 3
volatile int state = 0;

int bt_pin = 9;
int pirPin = 8;
int stateData = 0;
int ultraPin = 10;
int trigPin = 11;    // Trigger
int echoPin = 12;    // Echo
int piezoPin = 5;
long duration, cm;
unsigned char inches;
unsigned long timer;
volatile bool signalReceived = false;
volatile bool pirSignalReceived = false;
bool toggle_pir = false;
int incomingByte = 0;
bool song_in_progress = false;
int song_type = 69;

int nokia_melody[] = {

  // Nokia Ringtone 
  // Score available at https://musescore.com/user/29944637/scores/5266155
  
  NOTE_E5, 8, NOTE_D5, 8, NOTE_FS4, 4, NOTE_GS4, 4, 
  NOTE_CS5, 8, NOTE_B4, 8, NOTE_D4, 4, NOTE_E4, 4, 
  NOTE_B4, 8, NOTE_A4, 8, NOTE_CS4, 4, NOTE_E4, 4,
  NOTE_A4, 2, 
};



void setup() {
  pinMode(13, OUTPUT); //set pin 13 as output
  pinMode(ultraPin, OUTPUT);
  pinMode(trigPin, OUTPUT);
  pinMode(pirPin, OUTPUT);
  pinMode(echoPin, INPUT);  
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(bt_pin, HIGH);
  digitalWrite(bluetoothIntPin, HIGH);
  digitalWrite(pirInterruptPin, HIGH);
  digitalWrite(ultraPin, LOW);
  digitalWrite(pirPin, LOW);
  Serial.begin(9600); // Default communication rate of the Bluetooth module
  attachInterrupt(digitalPinToInterrupt(bluetoothIntPin), bluetooth_interrupt, CHANGE);
  attachInterrupt(digitalPinToInterrupt(pirInterruptPin), pir_interrupt, CHANGE);
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  sleep_enable();
  sleep_cpu();
}

void pir_interrupt(){
  // play sound effect
  digitalWrite(LED_BUILTIN, HIGH);   
  delay(5000);
  digitalWrite(LED_BUILTIN, LOW); 
  pirSignalReceived = true;
}

void bluetooth_interrupt(){
  state = !state;
  signalReceived = true;
}

void play_song(int melody[], int notes){
      // sizeof gives the number of bytes, each int value is composed of two bytes (16 bits)
    // there are two values per note (pitch and duration), so for each note there are four bytes
    
    // this calculates the duration of a whole note in ms
    song_in_progress = true;
    int wholenote = (60000 * 4) / tempo;
    
    int divider = 0, noteDuration = 0;
    for (int thisNote = 0; thisNote < notes * 2; thisNote = thisNote + 2) {

    // calculates the duration of each note
    divider = melody[thisNote + 1];
    if (divider > 0) {
      // regular note, just proceed
      noteDuration = (wholenote) / divider;
    } else if (divider < 0) {
      // dotted notes are represented with negative durations!!
      noteDuration = (wholenote) / abs(divider);
      noteDuration *= 1.5; // increases the duration in half for dotted notes
    }

    // we only play the note for 90% of the duration, leaving 10% as a pause
    tone(piezoPin, melody[thisNote], noteDuration * 0.9);

    // Wait for the specief duration before playing the next note.
    delay(noteDuration);

    // stop the waveform generation before the next note.
    noTone(piezoPin);
  }
  song_in_progress = false;
}

void play_tone_once(){
  if (!song_in_progress){
     if (song_type==69){
      int notes = sizeof(nokia_melody) / sizeof(nokia_melody[0]) / 2;
      play_song(nokia_melody, notes);
    }
    if (song_type==79){
      int notes = sizeof(starwars_melody) / sizeof(starwars_melody[0]) / 2;
      play_song(starwars_melody, notes);
    } 
  }
}

void loop() {
  if (signalReceived){
    sleep_disable();
    Serial.write(50);
    delay(500);
    timer = millis();
    digitalWrite(ultraPin, HIGH);
    digitalWrite(pirPin, HIGH);
    while (true){
        digitalWrite(trigPin, LOW);
        delayMicroseconds(2);
        digitalWrite(trigPin, HIGH);
        delayMicroseconds(10);
        digitalWrite(trigPin, LOW);
        pinMode(echoPin, INPUT);
        duration = pulseIn(echoPin, HIGH);
        cm = (duration / 2) / 29.1;   // Divide by 29.1 or multiply by 0.0343
        inches = (duration / 2) / 74; // Divide by 74 or multiply by 0.0135
        Serial.write(inches);
        delay(50);
        incomingByte = Serial.read();
        if (pirSignalReceived){
          play_tone_once();
          pirSignalReceived = false;
        }
        else if (incomingByte == 69){ // automatic pir
          song_type = 69; //nokia
        }
        else if (incomingByte == 79){
          song_type = 79; // starwars
        }
        else if (incomingByte == 89){
          toggle_pir = !toggle_pir;
          if (toggle_pir){
            digitalWrite(pirPin, HIGH); // automate tone            
          } else {
            digitalWrite(pirPin, LOW); 
          }
        }
        else if (incomingByte == 99){
          digitalWrite(pirPin, LOW); 
          play_tone_once();
        }
        if (incomingByte != 49 && incomingByte!=69 && incomingByte != 79 && incomingByte != 89 && incomingByte != 99){
          // receipt from android
          unsigned long timeElapse = millis() - timer;
          if (timeElapse > 7000) {
            break; // exit and SLEEP
          } 
        }
        else {
            // reset the timer
            timer = millis();
          }
  }
  digitalWrite(pirPin, LOW);
  digitalWrite(ultraPin, LOW);
  digitalWrite(LED_BUILTIN, LOW);
  signalReceived = false;
  sleep_enable();
  sleep_cpu();   
  }
}
1
  • you made a hardware change to the board ... please provide a schematic diagram for the board, not a program listing – jsotola Nov 28 '20 at 0:55
1

My Nano clone appears to be the same make as yours. Certainly the underside of it looks identical. On my clone, and I believe yours, the TX LED is wired as follows

5V -- RESISTOR -- LED -- TXD/D1

The 5V node is just the 5V pin which is fed by USB bus voltage via a diode or by the output of the AMS1117 voltage regulator. The TTL level serial TX signal idles high and sinks current through the LED when transmitting the start bit and low data bits. Incidentally, the RX led is wired in the same manner. By contrast the official Nano uses an FTDI that has dedicated LED driving pins.

It seems likely that you have bridged something with the solder that was holding the AMS1117 on the board in the process of removing it. I would note that the regulator is mounted directly under the LEDs and their current limiting resistors and there are at least three vias in that part of the board.

5
  • Would it be possible to bypass the regulator by bridging the Input and Output pins of the voltage regulator instead of completely desoldering it? – I Like Nov 28 '20 at 1:19
  • That's kind of a new question, but I'll just say this much: If the point is to not have any sort of current being used by the regulator, I don't think that will do it. Take for example whatever it is using internally for a voltage reference. This is connected somehow to the input (and in the scenario you outlined the output as well) and gnd. If you can find a schematic for the board, I would add it to your question as jsotola mentioned. – timemage Nov 28 '20 at 1:29
  • thanks. you are right that i probably messed up the circuitry. I desoldered just the legs of the regulator (excluding the heatsink) and avoided the hidden traces. – I Like Nov 28 '20 at 1:55
  • I gather you're saying this to indicate that you achieved some success that way. – timemage Nov 28 '20 at 1:58
  • mostly to validate your answer, but yes i did bypass the regulator – I Like Nov 28 '20 at 2:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.