Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. [ProMini] Blue LED on Pin 13 wont turn off

[ProMini] Blue LED on Pin 13 wont turn off

Scheduled Pinned Locked Moved Troubleshooting
13 Posts 4 Posters 3.0k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • rollercontainerR Offline
    rollercontainerR Offline
    rollercontainer
    wrote on last edited by
    #1

    I try to get a 2 AA node to work. I desoldered the voltage regulator and the power led from my 3,3V 8Mhz Pro Mini. Then I tried 1 MHz bootloaders and fuses. But the Pin13 LED keeps on burning. I tried to set it to low and high (for maybe chinese reverse logic) but it wont turn off. Strange is: I can blink it on purpose. Then I thought: maybe its an bootloader issue. But same thing wirth original bootloader and on another Pro Mini guess what? Right, the same thing.

    Is there something in the beta lib lighting up my led?

    I am using this 2.0.0-beta sketch with SI7021:

    // Relais Node for MySensors 2.0.0-beta
    
    // I am using the filename and compile date for sktech announcements:
    #include <string.h>
    // Strip the path info from __FILE__
    // For Windows use '\\' instead of '/'.
    #define __FILENAME__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
    
    #define MY_DEBUG
    #define MY_RADIO_NRF24
    #define SKETCH_NAME __FILENAME__
    #define SKETCH_DATE __DATE__
    #define MY_NODE_ID 70
    #define MY_PARENT_NODE_ID 0
    #define MY_REPEATER_FEATURE false
    
    #include <SPI.h>
    #include <MySensor.h>
    #include <Wire.h>
    #include <SI7021.h>
    #include <RunningAverage.h>
    #include <avr/power.h>
    
    //#define BATT_SENSOR    199
    #define AVERAGES 2
    #define CHILD_ID_TEMP  0
    #define CHILD_ID_HUM   1
    #define MEASURE_INTERVAL 60000
    #define FORCE_TRANSMIT_INTERVAL 30
    #define HUMI_TRANSMIT_THRESHOLD 0.5
    #define TEMP_TRANSMIT_THRESHOLD 0.5
    
    #define LED 13
    #define SI7021_POWER 2
    SI7021 humiditySensor;
    
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    
    #ifdef BATT_SENSOR
    MyMessage msgBatt(BATT_SENSOR, V_VOLTAGE);
    #endif
    
    // Global settings
    int measureCount = 0;
    int sendBattery = 0;
    boolean isMetric = true;
    boolean highfreq = true;
    boolean transmission_occured = false;
    
    // Storage of old measurements
    float lastTemperature = -100;
    int lastHumidity = -100;
    long lastBattery = -100;
    
    RunningAverage raHum(AVERAGES);
    
    /****************************************************
    
       Setup code
    
     ****************************************************/
    void setup() {
      pinMode(SI7021_POWER, OUTPUT);
      //pinMode(LED, OUTPUT);
    
      digitalWrite(SI7021_POWER, HIGH);
      //digitalWrite(LED, HIGH);
      delay (100);
      Serial.begin(9600);
      raHum.clear();
      sendTempHumidityMeasurements(false);
      sendBattLevel(false);
      humiditySensor.begin();
      digitalWrite(SI7021_POWER, LOW);
      //flashLED(5);
    }
    
    void presentation()  {
    
      sendSketchInfo(SKETCH_NAME, SKETCH_DATE);
      present(CHILD_ID_HUM, S_HUM, "Humidity");
      present(CHILD_ID_TEMP, S_TEMP, "Temperature");
    
    #ifdef BATT_SENSOR
      present(BATT_SENSOR, S_POWER);
    #endif
    }
    
    
    /***********************************************
    
        Main loop function
    
     ***********************************************/
    void loop() {
      digitalWrite(SI7021_POWER, HIGH);
      //digitalWrite(LED, LOW);
      delay (100);
      measureCount ++;
      sendBattery ++;
      bool forceTransmit = false;
      transmission_occured = false;
    
      if (measureCount > FORCE_TRANSMIT_INTERVAL) { // force a transmission
        forceTransmit = true;
        measureCount = 0;
      }
    
      sendTempHumidityMeasurements(forceTransmit);
    
      digitalWrite(SI7021_POWER, LOW);
      //digitalWrite(LED, HIGH);
      sleep(MEASURE_INTERVAL);
    }
    
    
    /*********************************************
    
       Sends temperature and humidity from Si7021 sensor
    
       Parameters
       - force : Forces transmission of a value (even if it's the same as previous measurement)
    
     *********************************************/
    void sendTempHumidityMeasurements(bool force)
    {
      bool tx = force;
    
      si7021_env data = humiditySensor.getHumidityAndTemperature();
    
      raHum.addValue(data.humidityPercent);
    
      float diffTemp = abs(lastTemperature - (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths) / 100.0);
      float diffHum = abs(lastHumidity - raHum.getAverage());
    
      Serial.print(F("TempDiff :")); Serial.println(diffTemp);
      Serial.print(F("HumDiff  :")); Serial.println(diffHum);
    
      if (isnan(diffHum)) tx = true;
      if (diffTemp > TEMP_TRANSMIT_THRESHOLD) tx = true;
      if (diffHum > HUMI_TRANSMIT_THRESHOLD) tx = true;
    
      if (tx) {
        measureCount = 0;
        float temperature = (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths) / 100.0;
    
        float humidity = data.humidityPercent;
        Serial.print("T: "); Serial.println(temperature);
        Serial.print("H: "); Serial.println(humidity);
    
        send(msgTemp.set(temperature, 1));
        send(msgHum.set(humidity, 1));
        lastTemperature = temperature;
        lastHumidity = humidity;
        transmission_occured = true;
        if (sendBattery > 60) {
          sendBattLevel(true); // Not needed to send battery info that often
          sendBattery = 0;
        }
        //flashLED(1);
      }
    }
    
    /********************************************
    
       Sends battery information (battery percentage)
    
       Parameters
       - force : Forces transmission of a value
    
     *******************************************/
    void sendBattLevel(bool force)
    {
      if (force) lastBattery = -1;
      long vcc = readVcc();
      if (vcc != lastBattery) {
        lastBattery = vcc;
    
    #ifdef BATT_SENSOR
        send(msgBatt.set(vcc));
    #endif
    
        // Calculate percentage
    
        vcc = vcc - 1900; // subtract 1.9V from vcc, as this is the lowest voltage we will operate at
    
        long percent = vcc / 14.0;
        sendBatteryLevel(percent);
        transmission_occured = true;
      }
    }
    
    /*******************************************
    
       Internal battery ADC measuring
    
     *******************************************/
    long readVcc() {
      // Read 1.1V reference against AVcc
      // set the reference to Vcc and the measurement to the internal 1.1V reference
    #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
      ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
    #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
      ADMUX = _BV(MUX5) | _BV(MUX0);
    #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
      ADcdMUX = _BV(MUX3) | _BV(MUX2);
    #else
      ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
    #endif
    
      delay(2); // Wait for Vref to settle
      ADCSRA |= _BV(ADSC); // Start conversion
      while (bit_is_set(ADCSRA, ADSC)); // measuring
    
      uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH
      uint8_t high = ADCH; // unlocks both
    
      long result = (high << 8) | low;
    
      result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
      return result; // Vcc in millivolts
    
    }
    
    void flashLED(int count) {
      int i;
      for (i = 0 ; i < count ; i++) {
        digitalWrite(LED, HIGH);
        delay(10);
        digitalWrite(LED, LOW);
        delay(200);
      }
    }
    
    
    
    1 Reply Last reply
    0
    • sundberg84S Offline
      sundberg84S Offline
      sundberg84
      Hardware Contributor
      wrote on last edited by sundberg84
      #2

      @rollercontainer - could be, some bootloaders use this led to indicare its ready.
      Arduino Pro Mini bootloader for example blinks if its loaded and waiting for a sketch to be uploaded. Depends on which bootloader you use and how that is coded.
      But once you upload a sketch on the original bootloader it does not blink (unless there is radio traffic - ie signals going to and from the nrf24l01+ on pin 13.

      Controller: Proxmox VM - Home Assistant
      MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
      MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
      RFLink GW - Arduino Mega + RFLink Shield, 433mhz

      rollercontainerR 1 Reply Last reply
      0
      • rollercontainerR Offline
        rollercontainerR Offline
        rollercontainer
        wrote on last edited by
        #3

        You are right, I missed that one. 13 is a radio pin AND the led output. So I have to move the radio pin or desolder the led, right?

        1 Reply Last reply
        0
        • mfalkviddM Offline
          mfalkviddM Offline
          mfalkvidd
          Mod
          wrote on last edited by
          #4

          I keep the led13 on my battery-powered units. It is useful for basic troubleshooting and the power used is small enough to be ignored.

          1 Reply Last reply
          1
          • sundberg84S sundberg84

            @rollercontainer - could be, some bootloaders use this led to indicare its ready.
            Arduino Pro Mini bootloader for example blinks if its loaded and waiting for a sketch to be uploaded. Depends on which bootloader you use and how that is coded.
            But once you upload a sketch on the original bootloader it does not blink (unless there is radio traffic - ie signals going to and from the nrf24l01+ on pin 13.

            rollercontainerR Offline
            rollercontainerR Offline
            rollercontainer
            wrote on last edited by
            #5

            @sundberg84 Thanks a lot for opening my eyes!

            I moved the radio to soft spi and now it works like intended.

            #define MY_DEBUG
            #define MY_RADIO_NRF24
            // RobotDyn Pro Mini 3,3V 8Mhz has blue LED on Pin13 which is used by radio and will be lit all the time.
            // Therfore, I moved the radio as it is done for the ethernet gateway.
            #define MY_SOFTSPI
            #define MY_SOFT_SPI_SCK_PIN 14  // Analog 0
            #define MY_SOFT_SPI_MOSI_PIN 15 // Analog 1
            #define MY_SOFT_SPI_MISO_PIN 16 // Analog 2
            #define MY_RF24_CE_PIN 5
            #define MY_RF24_CS_PIN 6
            
            #define SKETCH_NAME __FILENAME__
            #define SKETCH_DATE __DATE__
            #define MY_NODE_ID 70
            #define MY_PARENT_NODE_ID 0
            #define MY_REPEATER_FEATURE false
            
            1 Reply Last reply
            0
            • B Offline
              B Offline
              boozz
              wrote on last edited by
              #6

              @rollercontainer

              And you opened my eyes with the soft-spi remark. I just realized this could be an option to connect a LCD to a pro-mini as some kind of temperature indicator for multiple sensors. This is still on my wish-list.

              • outside temperature (low, high, current).
              • multiple room temperatures
              • etc..

              Thanks,

              BR,

              Boozz

              1 Reply Last reply
              0
              • rollercontainerR Offline
                rollercontainerR Offline
                rollercontainer
                wrote on last edited by
                #7

                How about an I2C Display? Two wires on A4 &A5...

                1 Reply Last reply
                2
                • sundberg84S Offline
                  sundberg84S Offline
                  sundberg84
                  Hardware Contributor
                  wrote on last edited by
                  #8

                  Going OT now - but @boozz here is an example of my i2c lcd (A4 + A5).
                  https://www.openhardware.io/view/23/In-wall-LCD-SwitchScene-controller-for-MySensors

                  Controller: Proxmox VM - Home Assistant
                  MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
                  MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
                  RFLink GW - Arduino Mega + RFLink Shield, 433mhz

                  B 1 Reply Last reply
                  0
                  • sundberg84S sundberg84

                    Going OT now - but @boozz here is an example of my i2c lcd (A4 + A5).
                    https://www.openhardware.io/view/23/In-wall-LCD-SwitchScene-controller-for-MySensors

                    B Offline
                    B Offline
                    boozz
                    wrote on last edited by
                    #9

                    @sundberg84

                    Thanks for the example, I'll have a look at it and yes we're going OT now. :grin:

                    BR,

                    Boozz

                    1 Reply Last reply
                    0
                    • rollercontainerR Offline
                      rollercontainerR Offline
                      rollercontainer
                      wrote on last edited by
                      #10

                      no problem, my fault was solved. Feel free to capture the thread ^^

                      1 Reply Last reply
                      0
                      • mfalkviddM Offline
                        mfalkviddM Offline
                        mfalkvidd
                        Mod
                        wrote on last edited by mfalkvidd
                        #11

                        Another thing that's slightly OT... How much more power does soft spi use compared to hardware spi? Is it more or less than the led?

                        1 Reply Last reply
                        0
                        • rollercontainerR Offline
                          rollercontainerR Offline
                          rollercontainer
                          wrote on last edited by
                          #12

                          Excellent question. I dont know.

                          1 Reply Last reply
                          0
                          • rollercontainerR Offline
                            rollercontainerR Offline
                            rollercontainer
                            wrote on last edited by
                            #13

                            Here are some scientific messurements: http://cc.oulu.fi/~kmikhayl/site-assets/pdfs/2012_NTMS.pdf

                            Table on last page says: SoftSPI consumes about double the electricity of a Hardware SPI on a PIC system. So, desoldering the LED is the thing to do.

                            Thx for the hint.

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            28

                            Online

                            11.7k

                            Users

                            11.2k

                            Topics

                            113.1k

                            Posts


                            Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • MySensors
                            • OpenHardware.io
                            • Categories
                            • Recent
                            • Tags
                            • Popular