[ProMini] Blue LED on Pin 13 wont turn off

  • 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 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);
    // 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);
      digitalWrite(SI7021_POWER, LOW);
    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);
        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;
      digitalWrite(SI7021_POWER, LOW);
      //digitalWrite(LED, HIGH);
       Sends temperature and humidity from Si7021 sensor
       - 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();
      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;
       Sends battery information (battery percentage)
       - 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
        // 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;
        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);
      ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
      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);
        digitalWrite(LED, LOW);

  • Hardware Contributor

    @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.

  • 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?

  • Mod

    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.

  • @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

  • @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..




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

  • Hardware Contributor

    Going OT now - but @boozz here is an example of my i2c lcd (A4 + A5).

  • @sundberg84

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



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

  • Mod

    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?

  • Excellent question. I dont know.

  • 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.