body:
I am using multiple temperature sensors using I2C. Some of the sensors are connected via TCA9548 multiplexer. When I run the sketch it runs fine for a few minutes but then it suddenly stops working while printing the results. I have tried changing the baud rate, trying two different arduinos but it happens on both arduinos. So I wonder if it's some kind of buffer overflow (serial prints) or there is any collision happening on the I2C bus. Now the only other way I can think of is to run each sensor separately and see if I can find the problematic sensor. Or are there better ways to fix the issue?

    /* 9 temperature & Humidity Sensors
        1 x BME280 #1 (0x77)[Ch 0]
        1 x BME280 #2 (0x77) [Ch 1]
        1 x BME280 #3 (0x76)
        1 x SHT21 (0x40) [Ch 7]
        1 x Si7021 (0x40) [Ch 5]
        1 x HTU21D (0x40) [Ch 6]
        1 x HDC1080 (0x40) [Ch 4]
        1 x AHT10 (0x38)
        1 x HDC2080 (0x41)

    */

    #include <Wire.h>
    #include <Adafruit_Sensor.h>
    #include <Adafruit_BME280.h>
    #include <Sodaq_SHT2x.h>
    #include "SparkFunHTU21D.h"
    #include <HDC2080.h>
    #include "ClosedCube_HDC1080.h"
    #include <AHT10.h>
    #include "Adafruit_Si7021.h"

    Adafruit_BME280 bme1; // I2C
    Adafruit_BME280 bme2; // I2C
    Adafruit_BME280 bme3; // I2C
    HTU21D HTU;
    HDC2080 HDC2080(0x41);
    ClosedCube_HDC1080 hdc1080;
    AHT10 AHT(AHT10_ADDRESS_0X38);

    Adafruit_Si7021 Si7021 = Adafruit_Si7021();
    bool enableHeater = false;
    uint8_t loopCnt = 0;

    unsigned long delayTime;

    #define MPLXADR 0x70 // Address of TCA9548A I2C Multiplexer
    void multiplexer (uint8_t ch) { //ch is the channel on Multiplexer
      if (ch > 7) return;

      Wire.beginTransmission(MPLXADR);
      Wire.write(1 << ch);
      Wire.endTransmission();
    }

    void setup() {
      Serial.begin(115200);

      while (AHT.begin() != true)
      {
        Serial.println(F("AHT10 not connected or fail to load calibration coefficient")); //(F()) save string to flash & keeps dynamic memory free
        delay(5000);
      }
      Serial.println(F("AHT10 OK"));

      HDC2080.begin();

      // Begin with a device reset
      HDC2080.reset();

      // Set up the comfort zone
      HDC2080.setHighTemp(28);         // High temperature of 28C
      HDC2080.setLowTemp(22);          // Low temperature of 22C
      HDC2080.setHighHumidity(55);     // High humidity of 55%
      HDC2080.setLowHumidity(40);      // Low humidity of 40%

      // Configure Measurements
      HDC2080.setMeasurementMode(TEMP_AND_HUMID);  // Set measurements to temperature and humidity
      HDC2080.setRate(ONE_HZ);                     // Set measurement frequency to 1 Hz
      HDC2080.setTempRes(FOURTEEN_BIT);
      HDC2080.setHumidRes(FOURTEEN_BIT);

      //begin measuring
      HDC2080.triggerMeasurement();

      Serial.println();

      Serial.println(F("BME280 test"));

      //BME280 sensor 1
      //  multiplexer(0);
      //  if (! bme1.begin(0x77, &Wire)) {
      //    Serial.println("Could not find a valid BME280 sensor, check wiring!");
      //    while (1);
      //  }

      // weather monitoring
      //  Serial.println("-- Weather Station Scenario --");
      //  Serial.println("forced mode, 1x temperature / 1x humidity / 1x pressure oversampling,");
      //  Serial.println("filter off");
      //  bme1.setSampling(Adafruit_BME280::MODE_FORCED,
      //                   Adafruit_BME280::SAMPLING_X1, // temperature
      //                   Adafruit_BME280::SAMPLING_X1, // pressure
      //                   Adafruit_BME280::SAMPLING_X1, // humidity
      //                   Adafruit_BME280::FILTER_OFF   );

      //BME280 sensor 2
      multiplexer(1);
      if (! bme2.begin(0x77, &Wire)) {
        Serial.println("Could not find a valid BME280 sensor, check wiring!");
        //while (1);
      }

      // weather monitoring
    //  Serial.println("-- Weather Station Scenario --");
    //  Serial.println("forced mode, 1x temperature / 1x humidity / 1x pressure oversampling,");
    //  Serial.println("filter off");
      bme2.setSampling(Adafruit_BME280::MODE_FORCED,
                       Adafruit_BME280::SAMPLING_X1, // temperature
                       Adafruit_BME280::SAMPLING_X1, // pressure
                       Adafruit_BME280::SAMPLING_X1, // humidity
                       Adafruit_BME280::FILTER_OFF   );

      //BME280 sensor 3
    //  if (! bme3.begin(0x76, &Wire)) {
    //    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    //    //while (1);
    //  }

      // weather monitoring
    //  Serial.println("-- Weather Station Scenario --");
    //  Serial.println("forced mode, 1x temperature / 1x humidity / 1x pressure oversampling,");
    //  Serial.println("filter off");
    //  bme3.setSampling(Adafruit_BME280::MODE_FORCED,
    //                   Adafruit_BME280::SAMPLING_X1, // temperature
    //                   Adafruit_BME280::SAMPLING_X1, // pressure
    //                   Adafruit_BME280::SAMPLING_X1, // humidity
    //                   Adafruit_BME280::FILTER_OFF   );
    //
    //  // suggested rate is 1/60Hz (1m)
    //  delayTime = 10000; // in milliseconds

      Serial.println("Initiating HTU21D");
      multiplexer(6);
      HTU.begin();

      Serial.println("HDC1080 Arduino Test");

      // Default settings:
      //  - Heater off
      //  - 14 bit Temperature and Humidity Measurement Resolutions
      multiplexer(4);
      hdc1080.begin(0x40);

      Serial.println("Si7021 test!");

      multiplexer(5);
      if (!Si7021.begin()) {
        Serial.println("Did not find Si7021 sensor!");
        //while (true);
      }

    }

    void loop() {

      unsigned long newTime = millis();
      static unsigned long oldTime = 0;

      if (newTime - oldTime >= 60000) {
        oldTime = newTime;

        printValuesHDC2080();

        multiplexer(4);
        printValuesHDC1080();

    //    bme3.takeForcedMeasurement(); // has no effect in normal mode
    //    printValuesBME3();

        multiplexer(1);
        bme2.takeForcedMeasurement(); // has no effect in normal mode
        printValuesBME2();

        multiplexer(6);
        printValuesHTU();

        multiplexer(5);
        printValueSi7021();

        printValuesAHT();

        //  multiplexer(0);
        //  bme1.takeForcedMeasurement(); // has no effect in normal mode
        //  printValuesBME1();

        multiplexer(7);
        printValuesSHT21();

        Serial.println();
        Serial.println();
      }
    }

    //void printValuesBME1() {
    //
    //  Serial.println();
    //  Serial.print("BME1 Readings");
    //  Serial.write(9); // printing a tab using ASCII code
    //  Serial.print("Temperature = ");
    //  Serial.print(bme1.readTemperature());
    //  Serial.println(" *C");
    //  Serial.write(9); // printing a tab using ASCII code
    //  Serial.print("Humidity = ");
    //  Serial.print(bme1.readHumidity());
    //  Serial.println(" %");
    //}

    void printValuesBME2() {

      Serial.print("BME2: ");
      Serial.write(9); // printing a tab using ASCII code
      Serial.print("T = ");
      Serial.print(bme2.readTemperature());
      Serial.write(9); // printing a tab using ASCII code
      Serial.print("H = ");
      Serial.println(bme2.readHumidity());
    }

    void printValuesBME3() {

      Serial.print("BME3: ");
      Serial.write(9); // printing a tab using ASCII code
      Serial.print("T = ");
      Serial.print(bme3.readTemperature());
      Serial.write(9); // printing a tab using ASCII code
      Serial.print("H = ");
      Serial.println(bme3.readHumidity());
    }

    void printValuesSHT21() {
      Serial.print("SHT21: ");
      Serial.write(9); // printing a tab using ASCII code
      Serial.print("T = ");
      Serial.print(SHT2x.GetTemperature());
      Serial.write(9); // printing a tab using ASCII code
      Serial.print("H = ");
      Serial.println(SHT2x.GetHumidity());
    }

    void printValuesHTU() {
      Serial.print("HTU: ");
      Serial.write(9); // printing a tab using ASCII code
      float humd = HTU.readHumidity();
      float temp = HTU.readTemperature();

      Serial.print("T = ");
      Serial.print(temp, 2);
      Serial.write(9); // printing a tab using ASCII code
      Serial.print("H = ");
      Serial.println(humd, 2);
    }

    void printValuesHDC2080() {
      Serial.print("HDC2080:");
      //Serial.write(9); // printing a tab using ASCII code
      Serial.print("T = "); Serial.print(HDC2080.readTemp());
      Serial.write(9); // printing a tab using ASCII code
      Serial.print("H = "); Serial.println(HDC2080.readHumidity());
    }

    void printValuesHDC1080() {
      Serial.print("HDC1080:");
      // Serial.write(9); // printing a tab using ASCII code
      Serial.print("T = ");
      Serial.print(hdc1080.readTemperature());
      Serial.write(9); // printing a tab using ASCII code
      Serial.print("H = ");
      Serial.println(hdc1080.readHumidity());
    }

    void printValuesAHT() {
      /* DEMO - 1, every temperature or humidity call will read 6 bytes over I2C, total 12 bytes */
      Serial.print(F("AHT10: "));
      Serial.write(9); // printing a tab using ASCII code
      Serial.print(F("T = ")); Serial.print(AHT.readTemperature()); //by default "AHT10_FORCE_READ_DATA"
      Serial.write(9); // printing a tab using ASCII code
      Serial.print(F("H = ")); Serial.println(AHT.readHumidity());    //by default "AHT10_FORCE_READ_DATA"
    }

    void printValueSi7021() {
      Serial.print(F("Si7021: "));
      // Serial.write(9); // printing a tab using ASCII code
      Serial.print("T = ");
      Serial.print(Si7021.readTemperature(), 2);
      Serial.write(9); // printing a tab using ASCII code
      Serial.print("H = ");
      Serial.println(Si7021.readHumidity(), 2);

      //
      //  // Toggle heater enabled state every 30 seconds
      //  // An ~1.8 degC temperature increase can be noted when heater is enabled
      //  if (++loopCnt == 30) {
      //    enableHeater = !enableHeater;
      //    Si7021.heater(enableHeater);
      //    // Serial.print("Heater Enabled State: ");
      //    if (Si7021.isHeaterEnabled()) {
      //      //  Serial.println("ENABLED");
      //    } else {
      //      // Serial.println("DISABLED");
      //
      //      loopCnt = 0;
    }

Code with delay:

    /* 9 temperature & Humidity Sensors
        1 x BME280 #1 (0x77)[Ch 0]
        1 x BME280 #2 (0x77) [Ch 1]
        1 x BME280 #3 (0x76)
        1 x SHT21 (0x40) [Ch 7]
        1 x Si7021 (0x40) [Ch 5]
        1 x HTU21D (0x40) [Ch 6]
        1 x HDC1080 (0x40) [Ch 4]
        1 x AHT10 (0x38)
        1 x HDC2080 (0x41)

    */

    #include <Wire.h>
    #include <Adafruit_Sensor.h>
    #include <Adafruit_BME280.h>
    #include <Sodaq_SHT2x.h>
    #include "SparkFunHTU21D.h"
    #include <HDC2080.h>
    #include "ClosedCube_HDC1080.h"
    #include <AHT10.h>
    #include "Adafruit_Si7021.h"

    Adafruit_BME280 bme1; // I2C
    Adafruit_BME280 bme2; // I2C
    Adafruit_BME280 bme3; // I2C
    HTU21D HTU;
    HDC2080 HDC2080(0x41);
    ClosedCube_HDC1080 hdc1080;
    AHT10 AHT(AHT10_ADDRESS_0X38);

    Adafruit_Si7021 Si7021 = Adafruit_Si7021();
    bool enableHeater = false;
    uint8_t loopCnt = 0;

    unsigned long delayTime;

    #define MPLXADR 0x70 // Address of TCA9548A I2C Multiplexer
    void multiplexer (uint8_t ch) { //ch is the channel on Multiplexer
      if (ch > 7) return;

      Wire.beginTransmission(MPLXADR);
      Wire.write(1 << ch);
      Wire.endTransmission();
    }

    void setup() {
      Serial.begin(115200);

      while (AHT.begin() != true)
      {
        Serial.println(F("AHT10 not connected or fail to load calibration coefficient")); //(F()) save string to flash & keeps dynamic memory free
        delay(5000);
      }
      Serial.println(F("AHT10 OK"));

      HDC2080.begin();

      // Begin with a device reset
      HDC2080.reset();

      // Set up the comfort zone
      HDC2080.setHighTemp(28);         // High temperature of 28C
      HDC2080.setLowTemp(22);          // Low temperature of 22C
      HDC2080.setHighHumidity(55);     // High humidity of 55%
      HDC2080.setLowHumidity(40);      // Low humidity of 40%

      // Configure Measurements
      HDC2080.setMeasurementMode(TEMP_AND_HUMID);  // Set measurements to temperature and humidity
      HDC2080.setRate(ONE_HZ);                     // Set measurement frequency to 1 Hz
      HDC2080.setTempRes(FOURTEEN_BIT);
      HDC2080.setHumidRes(FOURTEEN_BIT);

      //begin measuring
      HDC2080.triggerMeasurement();

      Serial.println();

      Serial.println(F("BME280 test"));

      //BME280 sensor 1
      //  multiplexer(0);
      //  if (! bme1.begin(0x77, &Wire)) {
      //    Serial.println("Could not find a valid BME280 sensor, check wiring!");
      //    while (1);
      //  }

      // weather monitoring
      //  Serial.println("-- Weather Station Scenario --");
      //  Serial.println("forced mode, 1x temperature / 1x humidity / 1x pressure oversampling,");
      //  Serial.println("filter off");
      //  bme1.setSampling(Adafruit_BME280::MODE_FORCED,
      //                   Adafruit_BME280::SAMPLING_X1, // temperature
      //                   Adafruit_BME280::SAMPLING_X1, // pressure
      //                   Adafruit_BME280::SAMPLING_X1, // humidity
      //                   Adafruit_BME280::FILTER_OFF   );

      //BME280 sensor 2
      multiplexer(1);
      if (! bme2.begin(0x77, &Wire)) {
        Serial.println("Could not find a valid BME280 sensor, check wiring!");
        //while (1);
      }

      // weather monitoring
      //  Serial.println("-- Weather Station Scenario --");
      //  Serial.println("forced mode, 1x temperature / 1x humidity / 1x pressure oversampling,");
      //  Serial.println("filter off");
      bme2.setSampling(Adafruit_BME280::MODE_FORCED,
                       Adafruit_BME280::SAMPLING_X1, // temperature
                       Adafruit_BME280::SAMPLING_X1, // pressure
                       Adafruit_BME280::SAMPLING_X1, // humidity
                       Adafruit_BME280::FILTER_OFF   );

      //BME280 sensor 3
      //  if (! bme3.begin(0x76, &Wire)) {
      //    Serial.println("Could not find a valid BME280 sensor, check wiring!");
      //    //while (1);
      //  }

      // weather monitoring
      //  Serial.println("-- Weather Station Scenario --");
      //  Serial.println("forced mode, 1x temperature / 1x humidity / 1x pressure oversampling,");
      //  Serial.println("filter off");
      //  bme3.setSampling(Adafruit_BME280::MODE_FORCED,
      //                   Adafruit_BME280::SAMPLING_X1, // temperature
      //                   Adafruit_BME280::SAMPLING_X1, // pressure
      //                   Adafruit_BME280::SAMPLING_X1, // humidity
      //                   Adafruit_BME280::FILTER_OFF   );
      //
      //  // suggested rate is 1/60Hz (1m)
      //  delayTime = 10000; // in milliseconds

      Serial.println("Initiating HTU21D");
      multiplexer(6);
      HTU.begin();

      Serial.println("HDC1080 Arduino Test");

      // Default settings:
      //  - Heater off
      //  - 14 bit Temperature and Humidity Measurement Resolutions
      multiplexer(4);
      hdc1080.begin(0x40);

      Serial.println("Si7021 test!");

      multiplexer(5);
      if (!Si7021.begin()) {
        Serial.println("Did not find Si7021 sensor!");
        //while (true);
      }

    }

    void loop() {

      unsigned long newTime = millis();
      static unsigned long oldTime = 0;

      if (newTime - oldTime >= 60000) {
        oldTime = newTime;

        printValuesHDC2080();
        delay(50);

        multiplexer(4);
        printValuesHDC1080();
        delay(50);

        //    bme3.takeForcedMeasurement(); // has no effect in normal mode
        //    printValuesBME3();

        multiplexer(1);
        bme2.takeForcedMeasurement(); // has no effect in normal mode
        printValuesBME2();
        delay(50);

        multiplexer(6);
        printValuesHTU();
        delay(50);

        multiplexer(5);
        printValueSi7021();
        delay(50);

        printValuesAHT();
        delay(50);

        //  multiplexer(0);
        //  bme1.takeForcedMeasurement(); // has no effect in normal mode
        //  printValuesBME1();

        multiplexer(7);
        printValuesSHT21();
        delay(50);

        Serial.println();
        Serial.println();
      }
    }

    //void printValuesBME1() {
    //
    //  Serial.println();
    //  Serial.print("BME1 Readings");
    //  Serial.write(9); // printing a tab using ASCII code
    //  Serial.print("Temperature = ");
    //  Serial.print(bme1.readTemperature());
    //  Serial.println(" *C");
    //  Serial.write(9); // printing a tab using ASCII code
    //  Serial.print("Humidity = ");
    //  Serial.print(bme1.readHumidity());
    //  Serial.println(" %");
    //}

    void printValuesBME2() {

      Serial.print("BME2: ");
      Serial.write(9); // printing a tab using ASCII code
      Serial.print("T = ");
      Serial.print(bme2.readTemperature());
      Serial.write(9); // printing a tab using ASCII code
      Serial.print("H = ");
      Serial.println(bme2.readHumidity());
    }

    void printValuesBME3() {

      Serial.print("BME3: ");
      Serial.write(9); // printing a tab using ASCII code
      Serial.print("T = ");
      Serial.print(bme3.readTemperature());
      Serial.write(9); // printing a tab using ASCII code
      Serial.print("H = ");
      Serial.println(bme3.readHumidity());
    }

    void printValuesSHT21() {
      Serial.print("SHT21: ");
      Serial.write(9); // printing a tab using ASCII code
      Serial.print("T = ");
      Serial.print(SHT2x.GetTemperature());
      Serial.write(9); // printing a tab using ASCII code
      Serial.print("H = ");
      Serial.println(SHT2x.GetHumidity());
    }

    void printValuesHTU() {
      Serial.print("HTU: ");
      Serial.write(9); // printing a tab using ASCII code
      float humd = HTU.readHumidity();
      float temp = HTU.readTemperature();

      Serial.print("T = ");
      Serial.print(temp, 2);
      Serial.write(9); // printing a tab using ASCII code
      Serial.print("H = ");
      Serial.println(humd, 2);
    }

    void printValuesHDC2080() {
      Serial.print("HDC2080:");
      //Serial.write(9); // printing a tab using ASCII code
      Serial.print("T = "); Serial.print(HDC2080.readTemp());
      Serial.write(9); // printing a tab using ASCII code
      Serial.print("H = "); Serial.println(HDC2080.readHumidity());
    }

    void printValuesHDC1080() {
      Serial.print("HDC1080:");
      // Serial.write(9); // printing a tab using ASCII code
      Serial.print("T = ");
      Serial.print(hdc1080.readTemperature());
      Serial.write(9); // printing a tab using ASCII code
      Serial.print("H = ");
      Serial.println(hdc1080.readHumidity());
    }

    void printValuesAHT() {
      /* DEMO - 1, every temperature or humidity call will read 6 bytes over I2C, total 12 bytes */
      Serial.print(F("AHT10: "));
      Serial.write(9); // printing a tab using ASCII code
      Serial.print(F("T = ")); Serial.print(AHT.readTemperature()); //by default "AHT10_FORCE_READ_DATA"
      Serial.write(9); // printing a tab using ASCII code
      Serial.print(F("H = ")); Serial.println(AHT.readHumidity());    //by default "AHT10_FORCE_READ_DATA"
    }

    void printValueSi7021() {
      Serial.print(F("Si7021: "));
      // Serial.write(9); // printing a tab using ASCII code
      Serial.print("T = ");
      Serial.print(Si7021.readTemperature(), 2);
      Serial.write(9); // printing a tab using ASCII code
      Serial.print("H = ");
      Serial.println(Si7021.readHumidity(), 2);

      //
      //  // Toggle heater enabled state every 30 seconds
      //  // An ~1.8 degC temperature increase can be noted when heater is enabled
      //  if (++loopCnt == 30) {
      //    enableHeater = !enableHeater;
      //    Si7021.heater(enableHeater);
      //    // Serial.print("Heater Enabled State: ");
      //    if (Si7021.isHeaterEnabled()) {
      //      //  Serial.println("ENABLED");
      //    } else {
      //      // Serial.println("DISABLED");
      //
      //      loopCnt = 0;
    }

title: Multiple sensors I2C stop working suddenly

Answers: 0


body:
Trying to hook up an hazzah feather to a pca9685 scl sda connection and have a bno055 connected to that.The 5 volts to power the PCA is not taken from feather. I have a GPS module connected to pin 12 of feather again not powered from feather. Gps interface works fine. I see it though web page interface.
Then I hook up the PCA. the wifi chip overheats and feather is fried

title: Huzzah feather scl sda

Answers: 0


body:
I am using atmega 2560 to control 590 LED lights with NeoPixels library.

I also got an IR receiver connected so I could control the LED properties and it does work but only when the LEDs are not engaged, the moment the code for LED's goes off the IR receiver keep returning random rubish.

Pressing the same button on a remote:

    11:48:18.394 -> FF3AC5
    11:48:19.550 -> D53AFF52
    11:48:58.586 -> 24AE7D4E
    11:48:59.341 -> 4CB0FADF
    11:48:59.742 -> 4CB0FADF
    11:49:00.491 -> 6BDBBF60
    11:49:09.462 -> A8E05FBB
    11:49:10.612 -> 40892F89
    11:49:11.067 -> 3AD8A119
    11:49:11.515 -> 2C1330B0
    11:49:14.176 -> DDE32E9D
    11:49:16.597 -> FF1AE5
    11:49:17.445 -> A8E05FBB
    11:49:17.499 -> FFFFFFFF
    11:49:18.502 -> FF1AE5
    11:49:18.548 -> FFFFFFFF
    11:49:19.350 -> FF1AE5

IR connection diagram below:
[![enter image description here][1]][1]

My code below:

    #include <IRremote.h>
    #include <Adafruit_NeoPixel.h>

    int LED_pin = 6;
    int PIR_pin_D = 4;
    int PIR_pin_U = 3;
    int IR_pin = 2;

    int LDR_pin = A0;

    int pirInputU = LOW;
    int pirInputD = LOW;
    int ldrInput =  0;
    int irInput = 0;

    bool goignDown = false;
    bool goingUp = false;

    //states
    bool lights = true;
    bool constantMode = false;
    byte ledBrightness = 50;
    byte mode = 0;

    int lightDuration = 8000;
    int sensorDelay = 1500;

    #define NUM_LEDS 590
    #define NUM_STEPS 14

    int numOfLEDs[NUM_STEPS] {41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 57, 41};

    Adafruit_NeoPixel strip(NUM_LEDS, LED_pin, NEO_GRB + NEO_KHZ800);
    int32_t currentColour = strip.Color(255, 255, 255);

    IRrecv irrecv(IR_pin);
    decode_results results;

    void setup()
    {
      strip.begin();
      strip.setBrightness(ledBrightness);

      irrecv.enableIRIn();

      pinMode(LDR_pin, INPUT);    // declare sensor as input
      pinMode(IR_pin, INPUT);    // declare sensor as input
      pinMode(PIR_pin_U, INPUT_PULLUP);  // declare sensor as input
      pinMode(PIR_pin_D, INPUT_PULLUP);  // declare sensor as input

      strip.clear();
      strip.show();

      delay(10000);
      Serial.begin(9600);
    }

    void loop()
    {
      ldrInput = analogRead(LDR_pin);    // read input value

      checkIrInput();

      if (ldrInput < 60 && lights)
      {
        pirInputU = digitalRead(PIR_pin_U); // read input value
        pirInputD = digitalRead(PIR_pin_D); // read input value
        checkIrInput();
        //UPSTAIRS SENSOR
        if (pirInputU == HIGH && pirInputD == LOW) // check if the input is HIGH
        {
          moveDown(currentColour);
          delay(lightDuration);
          moveDown(strip.Color(0, 0, 0));
          delay(sensorDelay);
          pirInputD = digitalRead(PIR_pin_D); // read input value
        }

        //DOWNSTAIRS
        if (pirInputD == HIGH && pirInputU == LOW) // check if the input is HIGH
        {
          moveUp(currentColour);
          delay(lightDuration);
          moveUp(strip.Color(0, 0, 0));
          delay(sensorDelay);
          pirInputU = digitalRead(PIR_pin_U); // read input value
        }
      }
    }

    void clearLedStrip()
    {
      strip.clear();
      strip.show();
    }

    void checkIrInput()
    {
      //Serial.println("pooling");

      while (!irrecv.isIdle());  // if not idle, wait till complete

      if (irrecv.decode(&results))
      {
        Serial.println(results.value, HEX);

        switch (results.value)
        {
          case 0xFF1AE5: //red
            {
              currentColour = strip.Color(255, 10, 10);
              break;
            }
          case 0xFF9A65: //green
            {
              currentColour = strip.Color(10, 255, 10);
              break;
            }
          case 0xFFA25D: //blue
            {
              currentColour = strip.Color(10, 10, 255);
              break;
            }
          case 0xFF22DD: //white
            {
              currentColour = strip.Color(255, 255, 255);
              break;
            }
          case 0xFF18E7: //yellow
            {
              currentColour = strip.Color(255, 255, 0);
              break;
            }
          case 0xFF58A7: //purple
            {
              currentColour = strip.Color(186,85,211);
              break;
            }
          case 0xFF02FD:
            {
              lights = !lights;
              break;
            }
          case 0xFF827D:
            {
              constantMode = !constantMode;
              break;
            }
          case 0xFF3AC5:
            {
              ledBrightness += 10;
              if (ledBrightness > 100)
                ledBrightness = 100;
              strip.setBrightness(ledBrightness);
              break;
            }
          case 0xFFBA45:
            {
              ledBrightness -= 10;
              if (ledBrightness < 10)
                ledBrightness = 10;
              strip.setBrightness(ledBrightness);
              break;
            }
        }
        irrecv.resume();
      }
    }

    void moveDown(uint32_t colour)
    {
      int start = 0;

      for (int step = 0; step < NUM_STEPS; step++)
      {
        int end = (start + numOfLEDs[step]) - 1;
        int midPoint = start + numOfLEDs[step] * 0.5;

        checkIrInput();

        for (int led = start, temp = 0; led <= midPoint; led++, temp++)
        {
          strip.setPixelColor(led, colour);
          strip.setPixelColor(end - temp, colour);
          strip.show();
        }
        checkIrInput();
        start += numOfLEDs[step];
      }
    }

    void moveUp(uint32_t colour)
    {
      int start = NUM_LEDS - numOfLEDs[NUM_STEPS - 1];

      for (int step = NUM_STEPS - 1; step >= 0; step--)
      {
        int end = (start + numOfLEDs[step]) - 1;
        int midPoint = start + numOfLEDs[step] * 0.5;

        checkIrInput();

        for (int led = start, temp = 0; led <= midPoint; led++, temp++)
        {
          strip.setPixelColor(led, colour);
          strip.setPixelColor(end - temp, colour);
          strip.show();
        }
        checkIrInput();
        start -= numOfLEDs[step];
      }
    }

Is atmega 2560 not powerfull enough? Or is there something that I am doing wrong?

Any feedback welcome, thank you.

  [1]: https://i.stack.imgur.com/2XhdL.png

title: Atmega 2560 IR receiver returning random values with using NeoPixels

Answers: 0


body:
Hiii Friends....,
                  I am Trying to Build Components tester Using Arduino Specifically Atmega328p Chip .
I Downloaded The Ardutester Millenium Code From Here ..  https://create.arduino.cc/projecthub/plouc68000/ardutester-millenium-the-ultimate-uno-mega-versions-c81db4

Edited Makefile.h By Enabling i2c lcd Interface And Adding My I2c Lcd Adress ...   But it wont work

I tried On Uno And Mega Also Serial Monitor Output seems ok But It Doesnt Display anything on 16*2 lcd

Thanks ...... :)
![enter image description here](https://i.stack.imgur.com/YghPT.jpg)![enter image description here](https://i.stack.imgur.com/LNLV0.jpg)

Code is available at that page sir...
Thanks for your reply

title: Ardutester Millenium I2c Lcd Not Showing Anything!

Answers: 1

body: The schematic you posted is not for I2C. You have a connection to the regular 2x16 LCD character display. For the I2C an SSD1306.


body:
I have an Arduino Uno and a usb 2.0 shield in which I connected a keyboard to. I have all the necessary libraries installed but what I am trying to figure out is how to light an led when I press a specific key.

I am new to codding Arduino boards and I have done a lot of reading but I cant figure out my issue I feel like if I get this figured out I will be a lot better off in my future projects.

    #include <hidboot.h>
    #include <usbhub.h>
    #ifdef dobogusinclude
    #include <spi4teensy3.h>
    #endif
    #include <SPI.h>

    int SKEY = 8;

    class KbdRptParser : public KeyboardReportParser
    {
        void PrintKey(uint8_t mod, uint8_t key);

      protected:

        void OnKeyDown  (uint8_t mod, uint8_t key);
        void OnKeyUp    (uint8_t mod, uint8_t key);
        void OnKeyPressed            (uint8_t key);
    };

    void KbdRptParser::PrintKey(uint8_t m, uint8_t key)
    {
      MODIFIERKEYS mod;
      *((uint8_t*)&mod) = m;
      Serial.print((mod.bmLeftCtrl   == 1) ? "C" : " ");
      Serial.print((mod.bmLeftShift  == 1) ? "S" : " ");
      Serial.print((mod.bmLeftAlt    == 1) ? "A" : " ");
      Serial.print((mod.bmLeftGUI    == 1) ? "G" : " ");

      Serial.print(" >");
      PrintHex<uint8_t>(key, 0x80);
      Serial.print("< ");

      Serial.print((mod.bmRightCtrl   == 1) ? "C" : " ");
      Serial.print((mod.bmRightShift  == 1) ? "S" : " ");
      Serial.print((mod.bmRightAlt    == 1) ? "A" : " ");
      Serial.println((mod.bmRightGUI  == 1) ? "G" : " ");
    };

    void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key)
    {
      Serial.print("DN ");
      PrintKey(mod, key);
      uint8_t c = OemToAscii(mod, key);

    }

    void KbdRptParser::OnKeyUp(uint8_t mod, uint8_t key)
    {
      Serial.print("UP ");
      PrintKey(mod, key);
    }

    void KbdRptParser::OnKeyPressed(uint8_t key)
    {
      Serial.print("ASCII: ");
      Serial.println((char)key);
    };

    USB Usb;
    HIDBoot<USB_HID_PROTOCOL_KEYBOARD>    HidKeyboard(&Usb);

    KbdRptParser Prs;

    void setup() {

     Serial.begin(9600);
    #if !defined(__MIPSEL__)
      while (!Serial);
      Serial.println("Start");

      if (Usb.Init() == -1)
        Serial.println("OSC did not start.");

      delay( 1 );

      HidKeyboard.SetReportParser(0, &Prs);

    }

    void loop() {
     Usb.Task();
    }

Anyways I know how to make if statements and how to activate pins on the Arduino but I cant figure it out in this keyboard library. For now I just made it print "TRUE" since there is not need to get complicated if I cant get the first step to work. Before I made that if statement the serial monitor would show the value assigned to the key and label it DN # and when I let up on the key it would say UP # but how can I translate that to sending a pulse to whatever pin when I push a key and stop sending a pulse when I let up on the key?

Also in my if statement that I made I know I need something before == sign but I tried multiple things and they did not work so I just left it blank and the reason I used the number 16 was because that was the value assigned to the S key in which I wanted to use to light an led. Anyways any help would be greatly appreciated!

title: Problems with Arduino Uno Usb 2.0 shield when using a keyboard

Answers: 0


body:
I'm using [this tutorial][1] to connect my ESP8266-01 WiFi Module to Arduino UNO with Arduino IDE v. 1.8.13.

[![Tutorial snippet][2]][2]

It works and the module can connect to my WiFi.
However, when I try to upload my code, it says:

`avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x30`

What could be the problem, since when I remove the reset pin it uploads the code, but now the WiFi goes down.

  [1]: http://www.teomaragakis.com/hardware/electronics/how-to-connect-an-esp8266-to-an-arduino-uno/
  [2]: https://i.stack.imgur.com/QJYqb.png

title: Cant upload arduino code when ESP8266-01 module is connected

Answers: 1

body:
Your problem is that there are two ways of wiring your ESP-01 module to the Arduino:

1. Wired so the PC has access to it and the Arduino is effectively disabled, and
2. Wired so the Arduino has access to it

You are wired in configuration 1 at the moment whereby the Arduino is effectively turned off and the USB connection goes direct to the ESP-01. When you try and upload code to the Arduino it's the ESP-01 that the computer is talking to, not the Arduino.

You need to wire it in configuration 2. In this configuration the TX/RX pins of the ESP-01 connect to any two pins of the Arduino except pins 0 and 1, and the RESET pin is not connected to anything. Then you can't talk to the ESP-01 through the serial monitor - instead you have to write code for the Arduino that uses SoftwareSerial to communicate for you.

There are many many tutorials online about communicating between the Arduino and the ESP-01.


body:
I'm creating a log of events, stored as a txt file. If it matters, I'm using ESP8266.

To display the log of each IOT, I'm publishing the txt file to a disgnated MQTT topic for all my IOT devices (later on to Telegram ). For sorting ( new first and old last ) I read each line into char array, post it to MQTT, and save it back to txt file.

Currently char array is defined as: `char log_array[20][200]` - meaning I'm keeping a log of 20 records, of 200 chars long.

Is it the right way ( declare a char array ) ? are there any limitation for size of array ( say 200 records )

Guy

title: Size limitation on char Array on ESP8266

Answers: 0


body:
I am using WiFiEsp Library, ESP8266-01 Wifi Module, Arduino UNO and Arduino v.1.8.13.
ESP Details: AT version:1.2.0.0.
SDK version:1.5.4.1(39cb9a32)
v1.0.0.

The module is also in AT+CWMODE=1.

My module connection is as follows:

RX: Pin 6

TX: Pin 7

VCC: 3.3V

GND: GND

CH-PD: 3.3V

I have created a wifi hotspot on my phone which I try to connect to using the module, so that I can be able to pass some variables from arduino sensor to my php script which is hosted locally on phpMyadmin.

However, I can not seem to make the connection past connecting to wifi, since it says wifi shield is not present. Even the AT commands dont work.

What could I be doing wrong? Below is my code snippet:

    #include "WiFiEsp.h"
    // Emulate Serial1 on pins 6/7 if not present
    #ifndef HAVE_HWSERIAL1
    #include "SoftwareSerial.h"
    SoftwareSerial Serial1(6, 7); // RX, TX
    #endif
    char ssid[] = "Googz";            // your network SSID (name)
    char pass[] = "********";        // your network password
    int status = WL_IDLE_STATUS;     // the Wifi radio's status
    char server[] = "localhost/bella/espdata.php";

    // Initialize the Ethernet client object
    WiFiEspClient client;
    void setup(){
      // initialize serial for debugging
      Serial.begin(115200);
      // initialize serial for ESP module
      Serial1.begin(9600);
      // initialize ESP module
      WiFi.init(&Serial1);
      // check for the presence of the shield
      if (WiFi.status() == WL_NO_SHIELD) {
        Serial.println("WiFi shield not present");
        // don't continue
        while (true);
      }

      // attempt to connect to WiFi network
      while ( status != WL_CONNECTED) {
        Serial.print("Attempting to connect to WPA SSID: ");
        Serial.println(ssid);
        // Connect to WPA/WPA2 network
        status = WiFi.begin(ssid, pass);
      }

      // you're connected now, so print out the data
      Serial.println("You're connected to the network");

      printWifiStatus();

      Serial.println();
      Serial.println("Starting connection to server...");
      // if you get a connection, report back via serial
      if (client.connect(server, 80)) {
        Serial.println("Connected to server");
        // Make a HTTP request
        client.println("GET /asciilogo.txt HTTP/1.1");
        client.println("Host: arduino.cc");
        client.println("Connection: close");
        client.println();
      }
    }

    void loop()
    {
      // if there are incoming bytes available
      // from the server, read them and print them
      while (client.available()) {
        char c = client.read();
        Serial.write(c);
      }

      // if the server's disconnected, stop the client
      if (!client.connected()) {
        Serial.println();
        Serial.println("Disconnecting from server...");
        client.stop();

        // do nothing forevermore
        while (true);
      }
    }

title: ESP8266-01 WiFiEsp Timeout error

Answers: 0


body:
[![enter image description here][1]][1]

I have connected two temp sensors and an OLED display to a NodeMCU using I2C. When the program reaches the instruction to print the measurements on the display the program crashes and NodeMCU resets itself. In the serial monitor I see "rst cause 2". I did search about this online but couldn't find a similar issue involving an OLED. I wonder what is causing this reset and how to fix it?

    #include <Wire.h>
    #include <Adafruit_Sensor.h>
    #include <Adafruit_BME280.h>
    #include <Sodaq_SHT2x.h>
    #include <Adafruit_SSD1306.h>

    //defining OLED dimensions
    #define WIDTH 128
    #define HEIGHT 32
    #define OLED_RESET -1

    Adafruit_SSD1306 display(OLED_RESET);

    Adafruit_BME280 bme1; // I2C

    void setup() {
      Serial.begin(115200);

      Wire.begin();
      display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initiate OLED

      Serial.println(F("BME280 test"));

      //BME280 sensor 1
      if (! bme1.begin(0x77, &Wire)) {
        Serial.println("Could not find a valid BME280 sensor, check wiring!");
        while (1);
      }

      //  weather monitoring
    //  Serial.println("-- Weather Station Scenario --");
    //  Serial.println("forced mode, 1x temperature / 1x humidity / 1x pressure oversampling,");
    //  Serial.println("filter off");
      bme1.setSampling(Adafruit_BME280::MODE_FORCED,
                       Adafruit_BME280::SAMPLING_X1, // temperature
                       Adafruit_BME280::SAMPLING_X1, // pressure
                       Adafruit_BME280::SAMPLING_X1, // humidity
                       Adafruit_BME280::FILTER_OFF   );
    }

    void loop() {
      unsigned long newTime = millis();
      static unsigned long oldTime = 0;

      if (newTime - oldTime >= 10000) {
        oldTime = newTime;

        float temp1 = 0.0;
        float humid1 = 0.0;
        float temp2 = 0.0;
        float humid2 = 0.0;

        takeReadingsBME(temp1, humid1);
        printValuesBME(temp1, humid1);

        takeReadingsSHT(temp2, humid2);
        printValuesSHT(temp2, humid2);
        displayResults(temp1, temp2, humid1, humid2);
      }
    }

    void printValuesBME(float temp, float humid) {

      Serial.println();
      Serial.print("BME: ");
      Serial.write(9);
      Serial.print("T = ");
      Serial.print(temp);
      Serial.write(9);
      Serial.print("H = ");
      Serial.println(humid);
    }

    void printValuesSHT(float temp2, float humid2) {
      Serial.print("SHT21: ");
      Serial.write(9);
      Serial.print("T = ");
      Serial.print(temp2);
      Serial.write(9);
      Serial.print("H = ");
      Serial.println(humid2);
    }

    void displayResults(float temp1, float temp2, float humid1, float humid2) {
      display.clearDisplay();
      display.setTextColor(WHITE);
      display.setTextSize(1);
      display.setCursor(0, 0);
      display.print("Sensor Data");
      display.println();
      display.print("BME ");
      display.print("T = ");
      display.print(temp1,1);
      display.print(" H = ");
      display.println(humid1,1);
      //display.setCursor(0, 0);
      //  display.print("ST: ");
      //  display.print("T = ");
      //  display.print(SHT2x.GetTemperature(), 1);
      //  display.print(" H1 = ");
      //  display.println(SHT2x.GetHumidity(), 1);
      display.display();
    }

    void takeReadingsBME(float &temp1, float &humid1) {

      bme1.takeForcedMeasurement();
      temp1 = bme1.readTemperature();
      humid1 = bme1.readHumidity();
    }

    void takeReadingsSHT(float &temp2, float &humid2) {

      temp2 = SHT2x.GetTemperature();
      humid2 = SHT2x.GetHumidity();
    }

  [1]: https://i.stack.imgur.com/x24hn.png

title: OLED display on I2C causes esp8266 to reset

Answers: 0


body:
"An error ocurred while uploading the sketch"

I'm having this specific error when uploading a sketch to my board and the IDE doesn't specify the problem correctly.

It's version is 1.8.13 for Windows 10.

I would like to get a file with detailed information about the IDE's error. Where should I look for it?

title: Where is the Arduino IDE log file located? Not the Serial Monitor

Answers: 1

body:
There is no log file. Instead you need to turn on both "compilation" and "upload" under the "Show verbose output during:" option in Preferences.

This will give you far more information about any errors in the output scroll pane at the bottom of the IDE.

On Linux if you run the IDE from the command line you get large amounts of logging on stdout. There may be a way of doing the same from Windows.


body:
Hi everyone I have a project and I need to run a dc motor for amount of time without using delay I use DelayWithoutBlink technique.
In this code the motor should run for 5 second in cw then it will change the direction it will other 5second in ccw direction but it seems that there is something wrong with my code, any help would be greatly appreciated.

```cpp
unsigned long timeRun = 5000;
boolean choiceOne = false;
boolean choiceTwo = false;
boolean directionOne;
boolean directionTwo;
unsigned long timeRunOne;
unsigned long timeRunTwo;

void setup() {
    Serial.begin(9600);
    pinMode(8, OUTPUT);
    pinMode(9, OUTPUT);
}

void loop() {
    char t = Serial.read();
    if (t == 'a') {
        while (choiceOne == false) {
            digitalWrite(9, HIGH);
            digitalWrite(8, LOW);
            directionOne = true;
            timeRunOne = millis();
            if (directionOne && (millis()-timeRunOne > timeRun)) {
                choiceOne = true;
            }
        }
    }
    if (t == 'b') {
        while (choiceTwo == false) {
            digitalWrite(9, LOW);
            digitalWrite(8, HIGH);
            timeRunTwo = millis();
            directionTwo = true;
            if (directionTwo && (millis()-timeRunTwo > timeRun)) {
                choiceTwo = true;
            }
        }
    }
}
```

title: Run a dc motor for amount of time without delay

Answers: 0


body:
You can see in my crumby schematic that I am using a Non-latching relay to turn on a 3A circuit (one of them arc lighters), which is powered by a 25C (supposedly) lipo battery. That same battery also powers an Arduino through a TP4056. This works fine when I first turn it all on, but once the relay is activated by the Arduino, the lighter + Relay only turn on for a split second before stopping (when the Arduino is powered via USB, it works fine). I am thinking that the Arduino+Relay+Lighter is too much for the battery, even though it claims to be 25C. It is just strange because the Arduino+Activated Relay consume what, like 200 mA?

Notes:
When I manually turn on the lighter, the light on the Arduino dims a fair bit, but stays on.
The Arduino is running at logic level of 3.3V so that I didn't need a booster.
[![enter image description here][1]][1]
As for fixes, I was thinking about trying to use a transistor or SSR instead of the chunky relay I have now (which would be good, I need this to be compact). Or maybe the TP4056 is failing to provide enough output despite a decent input?

I am FAR from an electrical engineer so if anyone has any pro tips for improving this it would be much appreciated.

  [1]: https://i.stack.imgur.com/Qacjr.jpg

title: Relay + Arduino uses too much power for battery to handle. Which solution is best?

Answers: 1

body:
The TP4056 is a battery charger, not a voltage regulator. It cannot be used to supply power to a device like an Arduino. It is designed for charging the Lithium Ion battery from a 5V (e.g., USB) source.

By trying to use it as a power supply you're asking for trouble. It thinks it's trying to charge a battery (from a 3.7V nominal source) and will be doing things like:

* Running constant current making the voltage fluctuate wildly as current demands change
* Running constant voltage with limited current causing starving of power
* Shutting off when it thinks it sees the non-existent battery being fully charged.

The TP4056 should be connected to a 5V USB power source and to the battery for charging it. The battery should be then through a (very) low-dropout regulator (ideally a switching regulator with zero dropout bypass ability) to power the Arduino at 3.3V.

Alternatively, if you don't need a (reasonably) precise 3.3V then you can power the Arduino directly from the battery.


body: I have given pwm output on pin(9) and I Want pin(10) to be high when pin(9) is low and pin(10) to be low when pin(9) is high.  So what should i add to my code?

title: I want 2 output pins to working alternately

Answers: 2

body:
would something like the following work?

```
digitalWrite(9,  !digitalRead(10));
```

like this: https://forum.arduino.cc/index.php?topic=128698.0

body:
You can set pin 10 to run in “inverted PWM” mode, and leave
pin 9 in the default non-inverted mode. Pin 9 is the “OC1A”
pin of the AVR microcontroller (output compare of Timer 1,
channel A), whereas pin 10 is OC1B (channel B of the same
timer). Inverting the PWM mode of channel B is a matter of changing
a single bit in one of the control registers of Timer 1:

```cpp
TCCR1A |= _BV(COM1B0);
```

You can do this once in `setup()`, the setting should persist. Then just
`analogWrite()` the same value to both pins. For some background on how
all this works, see the [datasheet of the ATmega328P
microcontroller][datasheet] (the MCU at the hearth of your Uno),
especially section 16 “16-bit Timer/Counter1 with PWM” and table
16-3 “Compare Output Mode, Phase Correct and Phase and Frequency Correct
PWM”.

[datasheet]: http://ww1.microchip.com/downloads/en/DeviceDoc/ATmega48A-PA-88A-PA-168A-PA-328-P-DS-DS40002061A.pdf


body:
I am using the Arduino's Adafruit Finger Sensor library, and it has an example to enroll a fingerprint. I want it to enroll one print and exit/break out of the loop because it currently enrolls a user, then goes back to asking for a fingerprint.
Here is the code:

    #include <Adafruit_Fingerprint.h>
    SoftwareSerial mySerial(2, 3);
    Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);
    uint8_t id;
    void setup()
    {
      Serial.begin(9600);
      while (!Serial);  // For Yun/Leo/Micro/Zero/...
      delay(100);
      Serial.println("\n\nAdafruit Fingerprint sensor enrollment");

      // set the data rate for the sensor serial port
      finger.begin(57600);

      if (finger.verifyPassword()) {
        Serial.println("Found fingerprint sensor!");
      } else {
        Serial.println("Did not find fingerprint sensor :(");
        while (1) { delay(1); }
      }
    }

    uint8_t readnumber(void) {
      uint8_t num = 0;

      while (num == 0) {
        while (! Serial.available());
        num = Serial.parseInt();
      }
      return num;
    }

    void loop()                     // run over and over again
    {
      Serial.println("Ready to enroll a fingerprint!");
      Serial.println("Please type in the ID # (from 1 to 127) you want to save this finger as...");
      id = readnumber();
      if (id == 0) {// ID #0 not allowed, try again!
         return;
      }
      Serial.print("Enrolling ID #");
      Serial.println(id);

      while (!  getFingerprintEnroll() );
    }

    uint8_t getFingerprintEnroll() {

      int p = -1;
      Serial.print("Waiting for valid finger to enroll as #"); Serial.println(id);
      while (p != FINGERPRINT_OK) {
        p = finger.getImage();
        switch (p) {
        case FINGERPRINT_OK:
          Serial.println("Image taken");
          break;
        case FINGERPRINT_NOFINGER:
          Serial.println(".");
          break;
        case FINGERPRINT_PACKETRECIEVEERR:
          Serial.println("Communication error");
          break;
        case FINGERPRINT_IMAGEFAIL:
          Serial.println("Imaging error");
          break;
        default:
          Serial.println("Unknown error");
          break;
        }
      }

      // OK success!

      p = finger.image2Tz(1);
      switch (p) {
        case FINGERPRINT_OK:
          Serial.println("Image converted");
          break;
        case FINGERPRINT_IMAGEMESS:
          Serial.println("Image too messy");
          return p;
        case FINGERPRINT_PACKETRECIEVEERR:
          Serial.println("Communication error");
          return p;
        case FINGERPRINT_FEATUREFAIL:
          Serial.println("Could not find fingerprint features");
          return p;
        case FINGERPRINT_INVALIDIMAGE:
          Serial.println("Could not find fingerprint features");
          return p;
        default:
          Serial.println("Unknown error");
          return p;
      }

      Serial.println("Remove finger");
      delay(2000);
      p = 0;
      while (p != FINGERPRINT_NOFINGER) {
        p = finger.getImage();
      }
      Serial.print("ID "); Serial.println(id);
      p = -1;
      Serial.println("Place same finger again");
      while (p != FINGERPRINT_OK) {
        p = finger.getImage();
        switch (p) {
        case FINGERPRINT_OK:
          Serial.println("Image taken");
          break;
        case FINGERPRINT_NOFINGER:
          Serial.print(".");
          break;
        case FINGERPRINT_PACKETRECIEVEERR:
          Serial.println("Communication error");
          break;
        case FINGERPRINT_IMAGEFAIL:
          Serial.println("Imaging error");
          break;
        default:
          Serial.println("Unknown error");
          break;
        }
      }

      // OK success!

      p = finger.image2Tz(2);
      switch (p) {
        case FINGERPRINT_OK:
          Serial.println("Image converted");
          break;
        case FINGERPRINT_IMAGEMESS:
          Serial.println("Image too messy");
          return p;
        case FINGERPRINT_PACKETRECIEVEERR:
          Serial.println("Communication error");
          return p;
        case FINGERPRINT_FEATUREFAIL:
          Serial.println("Could not find fingerprint features");
          return p;
        case FINGERPRINT_INVALIDIMAGE:
          Serial.println("Could not find fingerprint features");
          return p;
        default:
          Serial.println("Unknown error");
          return p;
      }

      // OK converted!
      Serial.print("Creating model for #");  Serial.println(id);

      p = finger.createModel();
      if (p == FINGERPRINT_OK) {
        Serial.println("Prints matched!");
      } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
        Serial.println("Communication error");
        return p;
      } else if (p == FINGERPRINT_ENROLLMISMATCH) {
        Serial.println("Fingerprints did not match");
        return p;
      } else {
        Serial.println("Unknown error");
        return p;
      }

      Serial.print("ID "); Serial.println(id);
      p = finger.storeModel(id);
      if (p == FINGERPRINT_OK) {
        Serial.println("Stored!");
      } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
        Serial.println("Communication error");
        return p;
      } else if (p == FINGERPRINT_BADLOCATION) {
        Serial.println("Could not store in that location");
        return p;
      } else if (p == FINGERPRINT_FLASHERR) {
        Serial.println("Error writing to flash");
        return p;
      } else {
        Serial.println("Unknown error");
        return p;
      }
    }

Output is that after storing the fingerprint, it requests for finger to enroll, but I want it to exit after storing. Is this possible?

title: Breaking out of the arduino fingerprint enroll loop

Answers: 1

body:
Your `getFingerprintEnroll()` function is missing a return statement. Inside the `if (p == FINGERPRINT_OK)` statement, you need to insert

    return 0;

after the Serial print. Only when returning zero, you will exit the while loop inside the `loop()` function.


body:
Trying to create an ESP32 access to a public Spple calendar, but after connecting to the server and saving to SPIFFS it fails at the same point each time. I end up with a file of around 220 kB, when the total file should be 800 kB.

If it's helpful:
Headers from URL show:
Tranfer-Encoding: Chunked
Connection: keep-alive

Arduino IDE:
```
Sketch uses 891474 bytes (68%) of program storage space. Maximum is 1310720 bytes.
Global variables use 39640 bytes (12%) of dynamic memory, leaving 288040 bytes for local variables. Maximum is 327680 bytes.
```

Any help would be greatly appreciated, I've spent way more hours than I'd like to admit even getting here.

```c++
#include <WiFi.h>
#include <HTTPClient.h>
#include "FS.h"
#include "SPIFFS.h"

/* You only need to format SPIFFS the first time you run a
   test or else use the SPIFFS plugin to create a partition
   https://github.com/me-no-dev/arduino-esp32fs-plugin */
#define FORMAT_SPIFFS_IF_FAILED true

const char* ssid = "House N";     // your network SSID (name of wifi network)
const char* password = "Sebastian1963George"; // your network password
int LED_inbuilt = 2;

void setup() {
  Serial.end();
  delay(100);
  Serial.begin(115200);
  pinMode(LED_inbuilt, OUTPUT);
  delay(1000);
  Serial.print("WIFI status = ");
  Serial.println(WiFi.getMode());
  WiFi.disconnect(true);

  delay(1000);
  WiFi.mode(WIFI_STA);
  delay(1000);
  Serial.print("WIFI status = ");
  Serial.println(WiFi.getMode());

  digitalWrite(LED_inbuilt, HIGH);
  delay(500);
  digitalWrite(LED_inbuilt, LOW);
  delay(500);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi..");
  }

  Serial.println("Connected to the WiFi network");

  if (!SPIFFS.begin(FORMAT_SPIFFS_IF_FAILED)) {
    Serial.println("SPIFFS Mount Failed");
    return;
  }
}

const char* root_ca= \
"-----BEGIN CERTIFICATE-----\n" \
"MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTEL\n" \
"MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE\n" \
"BxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMT\n" \
"IkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDgwMzA2MDAw\n" \
"MDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdy\n" \
"ZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09N\n" \
"T0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlv\n" \
"biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSR\n" \
"FtSrYpn1PlILBs5BAH+X4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0J\n" \
"cfRK9ChQtP6IHG4/bC8vCVlbpVsLM5niwz2J+Wos77LTBumjQjBAMB0GA1UdDgQW\n" \
"BBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/\n" \
"BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VGFAkK+qDm\n" \
"fQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdv\n" \
"GDeAU/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY=\n" \
"-----END CERTIFICATE-----\n";

void loop() {
  getCalendar();

  delay(1000);
  readFile(SPIFFS, "/calendar.txt");
}

void getCalendar() {
 File file = SPIFFS.open("/calendar.txt", "a");

 if (!file) {
   Serial.println("- failed to open file for writing");
   return;
 }

 if ((WiFi.status() == WL_CONNECTED)) { // Check the current connection status
   HTTPClient http;
   http.begin("https://p64-caldav.icloud.com/published/2/MTExOTIzNTUyNDExMTkyM_t4rBfkJzy02anGOy6aHJIsgECeJGkvldH8kJEjylMtRScq7BUY4vOst7NZU_0bLtKJ0JICjDL0ECuF9L_p8lQ", root_ca); //Specify the URL and certificate
    int httpCode = http.GET(); // Make the request

    if (httpCode == HTTP_CODE_OK) { // Check for the returning code
      http.writeToStream(&file);
    }

    file.close();
    Serial.println("you have finished downloading");
    http.end(); // Free the resources
  }

  delay(1000);
}

void readFile(fs::FS &fs, const char * path) {
  Serial.printf("Reading file: %s\r\n", path);

  File file = fs.open(path);
  if (!file || file.isDirectory()) {
    Serial.println("- failed to open file for reading");
    return;
  }

  Serial.println("- read from file:");

  while (file.available()) {
    Serial.write(file.read());
  }
}

void deleteFile(fs::FS &fs, const char * path) {
  Serial.printf("Deleting file: %s\r\n", path);
  if (fs.remove(path)) {
    Serial.println("- file deleted");
  } else {
    Serial.println("- delete failed");
  }
}

```

title: How to download a large text file using HTTPS on an ESP32?

Answers: 0


body:
I recently bought an ATtiny85 based development board. (picture below)

[![Digispark clone][1]][1]

I managed to install it correctly following the official guides, without a problem.
Drivers are installed correctly, and I used the Arduino IDE to actually upload a few sketches and tested them in two computers.

*SUDDENLY*

It has stopped working, based on my research, it seems that the bootloader got damaged. Any idea on how to fix this? I thought about burning the bootloader using Arduino, but I have barely got an idea on how to begin.

Backside of the Attiny85
[![Digispark clone][2]][2]

  [1]: https://i.stack.imgur.com/5OnaW.jpg
  [2]: https://i.stack.imgur.com/vN5xq.jpg

title: Digispark ATtiny85 not recognized (bootloader problem)

Answers: 1

body:
The 3 [default][4] ways to re-program your tiny on that board are:
- [micronucleus][1] bootloader (sketches only)
- ISP prog. (sketches & set-fuses, InSystemProgramming)
- HV prog. (re-set fuses, HighVoltage = 12V don't worry)

The bootloader in itself is like a sketch on the chip (at the beginning, taking up flash space) and talks through the software USB port on that board. It then rewrites parts of its own flash from the data the host sends, when you upload new sketches.

If that part gets damaged it won't get recognized by the host anymore and you can't use the board to reprogram itself. Unless the chip/parts died to ESD or other reasons, **you still can use ISP/HV programming on the chip, which is the solution to your problem.**

Read up on [fuses][2], they are the init settings of your chip (like a BIOS) defining its behaviour. There are some fuses which can only be set once, after which they can only be changed by the HV method. Depending their setting on your chip, this could also be done with normal ISP programming.

This [instructables][3] shows how to build a HV programmer, but also demonstrates using an Arduino as normal ISP programmer (Step 4).

The original Digispark comes with the RSTDISBL fuse set, meaning you can't directly use ISP (which requires the reset pin). Thats why HV programming is neccessary, to regain the reset pin, after that you can reflash the bootloader via ISP. From then on you can use the bootloader again, to reprogram (upload) your sketches.

  [1]: https://github.com/micronucleus/micronucleus
  [2]: https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf#G1.2073549
  [3]: https://www.instructables.com/How-to-unlock-Digispark-ATtiny85-and-convert-it-to/
  [4]: https://digistump.com/wiki/digispark/tutorials/programming


body: How do I disable drag-and-drop text editing in Arduino IDE?  This is very annoying.  If not careful, this causes code to move around when trying to copy and paste...

Answers: 0


body:
I have a cheap ESP01 relay module and am using it with ESPEasy. I soldered the GPIO pin 16 to RST to allow deep sleep and that all works great.

However when the unit wakes up the relay flickers quite a bit. The application I had in mind was for a 12v fridge which draws quite a bit of current on start up. I think this flickering would damage the fridge compressor or controller pretty quickly, not to mention wearing out the relay itself.

I need the unit to wake up from deep sleep, and keep the relay in the off position, unless triggered by some external criteria.

Perhaps a capacitor would absorb the pin high voltage for a short period until it's booted? Trouble is that I don't really want to hack the module, I'll probably break something.

[![ESP01 Module][1]][1]

  [1]: https://i.stack.imgur.com/QFNqr.jpg

title: How to prevent flickering relay upon waking from deep sleep using ESP01 board?

Answers: 2

body:
Apparently it's a pretty common issue for people using this board. There are a  couple of solutions here that I will try: https://github.com/IOT-MCU/ESP-01S-Relay-v4.0/issues/1

The most non invasive one with Tasmoto firmware didn't work in my case. So I will try another pin and if that fails, bite the bullet and introduce a capacitor.

body:
The only two pins that don't glitch or change state during reset and boot are GPIO4 and GPIO5, and neither of them are brought out to the 2x4 header on an ESP-01.
https://rabbithole.wwwdotorg.org/2017/03/28/esp8266-gpio.html

All of the other pins will make your relay click or chatter.  Pick a different module, or try soldering a wire onto GPIO4 or 5. The boot time is ~ 150ms long, so it'd take a long time constant R-C circuit to filter it out, on the order of 1/2 second or more.


body:
This [item][1] was bought for battery use with deep sleep purposes. For doing so in ESP8266 `reset` pin must be connected to `Gnd` pin in order to wake up. This board lacks a `reset` on- board pin.
Since spec states it has a such capabilities - I wonder if someone has succeeded with putting it to sleep ( and wake it back on ).

PS - I know that on-chip `gpio16` can be soldered to on-chip `gnd` - I'm hoping there is a more elegant, not soldering invloved, solution.
Guy

  [1]: https://www.aliexpress.com/item/32860090110.html?spm=a2g0s.9042311.0.0.70534c4dSBq9RI

title: WeMos D1 ESP-Wroom-02 Mother Board ESP8266 - where is reset pin for deep-sleep

Answers: 1

body:
This support page has the instructions for enabling deep sleep:

[Support for WeMos D1 ESP-Wroom-02 Nodemcu][1]

edit by Guy: in short, solder/connect pins as shown circled in red:

[![image of board][2]][2]

  [1]: https://github.com/arendst/Tasmota/issues/1236
  [2]: https://i.stack.imgur.com/kRmHT.jpg


body:
I want to shine LED in 64 of 255 duty cycles = level of brightness but it pops up this error (see picture). Can anybody tell me why and help me ? Thank you.

    void setup() {
      // put your setup code here, to run once:

    }

    void loop() {

      analogWrite(11, 64)
      delay{1000};
      analogWrite(11, 0)
      delay(1000);

      // put your main code here, to run repeatedly:

    }

[![enter image description here][1]][1]

  [1]: https://i.stack.imgur.com/h1fLe.jpg

title: ARDUINO expected ';' before 'delay'

Answers: 1

body:
You should write ";" end of each lines.

    analogWrite(11, 64);
    delay(1000);
    analogWrite(11, 0);
    delay(1000);


body:
**The problem**

Hey. I'm trying to use the sensor Mq131 to measure some ozone data in a closed environment, but I'm having some bad time to adjust the trim in the sensor and get results in ppb. By searching on the internet I could not find any elucidative manual/instruction.

----------

**My Hardware set**

As my first attempt, I've made the following wiring with the Arduino UNO and the sensor module.
[![Wiring of the Mq131 in Arduino UNO][1]][1]

Notice that my potentiometer does not have any indication of the resistance reached when spinning the potentiometer screw.

[![Picture the sensor. Detail on potentiometer screw.][2]][2]

----------

**My software script**

To get the value of tension in the output from the sensor I'm using the following approach.

```
int sensor_AOUT = A1; //connected from AOUT to the sensor to A1 on the Arduino
int sensor_DOUT = 2; //connect DOUT from sensor to Arduino pin 2
int wartosc_AOUT; //variable for the value of AOUT
int wartosc_DOUT; //variable for the value of DOUT

void setup() {
 Serial.begin(9600); //start the monitor serial port
 pinMode(2, INPUT); //set pin 2 as input

}

void loop() {

 wartosc_AOUT = analogRead(sensor_AOUT); //load values from AOUT
 wartosc_DOUT = digitalRead(sensor_DOUT); //load values DOUT

 Serial.print("D0: "); //display on serial monitor
 Serial.print(wartosc_DOUT);
 Serial.print(" -- A0: ");
 Serial.println(wartosc_AOUT);
 delay(200); //delay between consecutive readings
 }
```
which gives me values 30 < A0 <50. How can I get a value in ppb (parts per billion) and how can I calibrate the potentiometer screw?

----------
**Sensor Datasheet**

The datasheet of this sensor can be found in [this][3] link.

  [1]: https://i.stack.imgur.com/LEJ9P.jpg
  [2]: https://i.stack.imgur.com/7ZDei.png
  [3]: http://www.sensorica.ru/pdf/MQ-131.pdf

title: How to Adjust MQ131 Sensor?

Answers: 0


body:
I am using arduino HTTPClient to do the post request in ESP32. Can anyone help me with the part where I will be able to post an image file along with some data.

The below code works perfectly fine with only sending user_name and image_type-
```
#include <HTTPClient.h>

http.begin("https://www.somelink.com/post-image");

http.addHeader("Content-Type", "application/x-www-form-urlencoded");

String httpRequestData = "user_name=Shidhartha&image_type=Outdoor";

int httpResponseCode = http.POST(httpRequestData);
if(httpResponseCode > 0){
  String response = http.getString();
  Serial.println(response);
}else{
  Serial.print("Error on sending POST: ");
  Serial.println(httpResponseCode);
}
```

title: How to post image using Arduino HTTPClient

Answers: 1

body:
Below is the perfectly working code I got from [here](https://RandomNerdTutorials.com/esp32-cam-post-image-photo-server/).
```
#include <Arduino.h>
#include <WiFi.h>
#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"
#include "esp_camera.h"

const char* ssid = "REPLACE_WITH_YOUR_SSID";
const char* password = "REPLACE_WITH_YOUR_PASSWORD";

String serverName = "192.168.1.XXX";   // REPLACE WITH YOUR Raspberry Pi IP ADDRESS
//String serverName = "example.com";   // OR REPLACE WITH YOUR DOMAIN NAME

String serverPath = "/upload.php";     // The default serverPath should be upload.php

const int serverPort = 80;

WiFiClient client;

// CAMERA_MODEL_AI_THINKER
#define PWDN_GPIO_NUM     32
#define RESET_GPIO_NUM    -1
#define XCLK_GPIO_NUM      0
#define SIOD_GPIO_NUM     26
#define SIOC_GPIO_NUM     27

#define Y9_GPIO_NUM       35
#define Y8_GPIO_NUM       34
#define Y7_GPIO_NUM       39
#define Y6_GPIO_NUM       36
#define Y5_GPIO_NUM       21
#define Y4_GPIO_NUM       19
#define Y3_GPIO_NUM       18
#define Y2_GPIO_NUM        5
#define VSYNC_GPIO_NUM    25
#define HREF_GPIO_NUM     23
#define PCLK_GPIO_NUM     22

const int timerInterval = 30000;    // time between each HTTP POST image
unsigned long previousMillis = 0;   // last time image was sent

void setup() {
  WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
  Serial.begin(115200);

  WiFi.mode(WIFI_STA);
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.print("ESP32-CAM IP Address: ");
  Serial.println(WiFi.localIP());

  camera_config_t config;
  config.ledc_channel = LEDC_CHANNEL_0;
  config.ledc_timer = LEDC_TIMER_0;
  config.pin_d0 = Y2_GPIO_NUM;
  config.pin_d1 = Y3_GPIO_NUM;
  config.pin_d2 = Y4_GPIO_NUM;
  config.pin_d3 = Y5_GPIO_NUM;
  config.pin_d4 = Y6_GPIO_NUM;
  config.pin_d5 = Y7_GPIO_NUM;
  config.pin_d6 = Y8_GPIO_NUM;
  config.pin_d7 = Y9_GPIO_NUM;
  config.pin_xclk = XCLK_GPIO_NUM;
  config.pin_pclk = PCLK_GPIO_NUM;
  config.pin_vsync = VSYNC_GPIO_NUM;
  config.pin_href = HREF_GPIO_NUM;
  config.pin_sscb_sda = SIOD_GPIO_NUM;
  config.pin_sscb_scl = SIOC_GPIO_NUM;
  config.pin_pwdn = PWDN_GPIO_NUM;
  config.pin_reset = RESET_GPIO_NUM;
  config.xclk_freq_hz = 20000000;
  config.pixel_format = PIXFORMAT_JPEG;

  // init with high specs to pre-allocate larger buffers
  if(psramFound()){
    config.frame_size = FRAMESIZE_SVGA;
    config.jpeg_quality = 10;  //0-63 lower number means higher quality
    config.fb_count = 2;
  } else {
    config.frame_size = FRAMESIZE_CIF;
    config.jpeg_quality = 12;  //0-63 lower number means higher quality
    config.fb_count = 1;
  }

  // camera init
  esp_err_t err = esp_camera_init(&config);
  if (err != ESP_OK) {
    Serial.printf("Camera init failed with error 0x%x", err);
    delay(1000);
    ESP.restart();
  }

  sendPhoto();
}

void loop() {
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= timerInterval) {
    sendPhoto();
    previousMillis = currentMillis;
  }
}

String sendPhoto() {
  String getAll;
  String getBody;

  camera_fb_t * fb = NULL;
  fb = esp_camera_fb_get();
  if(!fb) {
    Serial.println("Camera capture failed");
    delay(1000);
    ESP.restart();
  }

  Serial.println("Connecting to server: " + serverName);

  if (client.connect(serverName.c_str(), serverPort)) {
    Serial.println("Connection successful!");
    String head = "--RandomNerdTutorials\r\nContent-Disposition: form-data; name=\"imageFile\"; filename=\"esp32-cam.jpg\"\r\nContent-Type: image/jpeg\r\n\r\n";
    String tail = "\r\n--RandomNerdTutorials--\r\n";

    uint16_t imageLen = fb->len;
    uint16_t extraLen = head.length() + tail.length();
    uint16_t totalLen = imageLen + extraLen;

    client.println("POST " + serverPath + " HTTP/1.1");
    client.println("Host: " + serverName);
    client.println("Content-Length: " + String(totalLen));
    client.println("Content-Type: multipart/form-data; boundary=RandomNerdTutorials");
    client.println();
    client.print(head);

    uint8_t *fbBuf = fb->buf;
    size_t fbLen = fb->len;
    for (size_t n=0; n<fbLen; n=n+1024) {
      if (n+1024 < fbLen) {
        client.write(fbBuf, 1024);
        fbBuf += 1024;
      }
      else if (fbLen24>0) {
        size_t remainder = fbLen24;
        client.write(fbBuf, remainder);
      }
    }
    client.print(tail);

    esp_camera_fb_return(fb);

    int timoutTimer = 10000;
    long startTimer = millis();
    boolean state = false;

    while ((startTimer + timoutTimer) > millis()) {
      Serial.print(".");
      delay(100);
      while (client.available()) {
        char c = client.read();
        if (c == '\n') {
          if (getAll.length()==0) { state=true; }
          getAll = "";
        }
        else if (c != '\r') { getAll += String(c); }
        if (state==true) { getBody += String(c); }
        startTimer = millis();
      }
      if (getBody.length()>0) { break; }
    }
    Serial.println();
    client.stop();
    Serial.println(getBody);
  }
  else {
    getBody = "Connection to " + serverName +  " failed.";
    Serial.println(getBody);
  }
  return getBody;
}
```


body:
I'm using a Relay Channel and NodeMCU(8266-WIFI). When i trigger the connection, LED Turns ON in Node MCU But the Relay connection is not working. I'm not sure what is the issue, Please help to fix it..

My Pin connection as follows.

> 1. NodeMCU (VIN) -> Relay (VCC)
>  2. NodeMCU (G) -> Relay (G)
>  3. NodeMCU (D1) -> Relay (IN4)

My code as follows,

    #include <ArduinoJson.h>
    #include <ESP8266WiFi.h>
    #include <FirebaseCloudMessaging.h>
    #include <Firebase.h>
    #include <FirebaseHttpClient.h>
    #include <FirebaseArduino.h>
    #include <FirebaseError.h>
    #include <FirebaseObject.h>

    // Set these to run example.
    #define FIREBASE_HOST "xxx-xxxx.firebaseio.com"
    #define FIREBASE_AUTH "xxxxxx"
    #define WIFI_SSID "xxxx"
    #define WIFI_PASSWORD "xxxxx"

    void setup() {
      Serial.begin(9600);

      // connect to wifi.
      WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
      Serial.print("connecting");
      while (WiFi.status() != WL_CONNECTED) {
        Serial.print(".");
        delay(500);
      }
      Serial.println();
      Serial.print("connected: ");
      Serial.println(WiFi.localIP());

      pinMode(D1, OUTPUT);
      pinMode(LED_BUILTIN, OUTPUT);

      Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
      Firebase.set("LED_STATUS",0);
    }

    int n = 0;

    void loop() {
      // Get value
      n=Firebase.getInt("LED_STATUS");

      if (n==1) {
         digitalWrite(D1, LOW);
         digitalWrite(LED_BUILTIN, LOW);
         Serial.print("LED is ON ");
         Serial.println(Firebase.getInt("LED_STATUS"));
         delay(1000);
      }
     else{
       //LED_BUILTIN
       digitalWrite(D1, HIGH);
       digitalWrite(LED_BUILTIN, HIGH);
       Serial.print("LED is OFF ");
       Serial.println(Firebase.getInt("LED_STATUS"));
       delay(1000);
     }

    }

[![Connection PICTURE][1]][1]

  [1]: https://i.stack.imgur.com/wfSHN.jpg

title: Relay with NodeMCU is not working

Answers: 1

body:
I found that the 3V isn't enough to power the relay.
https://www.instructables.com/Getting-Started-With-ESP8266LiLon-NodeMCU-V3Flashi/ shows the board supplies USB power (pin VU).

You can remove the jumper that connects signal voltage to relay power and connect the relay board to the USB power.

After that change I could turn the relays on and off, but I could not reliably power 4 relays, 2 relays as shown below seems fine.

[![enter image description here][1]][1]

  [1]: https://i.stack.imgur.com/U6K7N.png


body:
so im new on arduino coding, and i made this code, where i input from serial monitor and then use it as a command for digital write. the problem is, sometimes the code work perfectly but then when i input 4, both D3 ad D4 is high and that also happens in D5 and D6. but its inconsistent, and i also print the 'out' value and also which digital pin is high to make it easier.

    byte b;
    int out;
    int D3 = 3;int D4 = 4;int D5 = 5;int D6 = 6;int D7 = 7;int D8 = 8;
    void setup() {
      Serial.begin(9600);
      pinMode(out, OUTPUT);
      digitalWrite(D3, LOW);digitalWrite(D4, LOW);digitalWrite(D5, LOW);digitalWrite(D6, LOW);digitalWrite(D7, LOW);digitalWrite(D8, LOW);

    }

    void loop() {
      while (Serial.available() == 0) {}
      b = Serial.read() - 48;
      out = b;
      Serial.print("\n Out is ");
      Serial.println(out);
      digitalWrite(out, HIGH);
      delay(600);
     if (digitalRead(D3) == HIGH)
    {
       Serial.print("D3 HIGH");
    }
     if (digitalRead(D4) == HIGH)
    {
       Serial.print("D4 HIGH");}
     if (digitalRead(D5) == HIGH)
    {
       Serial.print("D5 HIGH");
    }
     if (digitalRead(D6) == HIGH)
    {
       Serial.print("D6 HIGH");
       }
     if (digitalRead(D7) == HIGH)
    {
       Serial.print("D7 HIGH");
    }
     if (digitalRead(D8) == HIGH)
    {
       Serial.print("D8 HIGH");
       }
      digitalWrite(out, LOW);
      delay(1000);

    }

does anyone know why this happens? or can anyone recommend another method to do what im tryinng to do? thank you guys!!!

title: inconsistent digital output on simple code

Answers: 1

body:
If I look at the first 5 lines:

    byte b;
    int out;
    int D3 = 3;int D4 = 4;int D5 = 5;int D6 = 6;int D7 = 7;int D8 = 8;
    void setup() {
      Serial.begin(9600);
      pinMode(out, OUTPUT);

You see that `pinMode`out, OUTPUT)` uses a variable `out` which is not initialized (it's only declared in `int out`'.

I assume `D3` to `D8` are all output pins, so you have to replace the last line with:

    pinMode(D3, OUTPUT);
    pinMode(D4, OUTPUT);
    pinMode(D5, OUTPUT);
    pinMode(D6, OUTPUT);
    pinMode(D7, OUTPUT);
    pinMode(D8, OUTPUT);

Also, since you are using all pins in the same way, I suggest you use two variables: `startPin` and `endPin`. Then you can use a `for` loop to iterate through all pins. Also

- always initialize variables.
- use '0' instead of 48 when you convert from a byte value to a character (since you don't need to know the ASCII value of '0').

I don't have an Arduino compiler at hand, but it should look something like:

    byte b = 0;
    int out = 0;
    const byte startPin = 3;
    const byte endPin = 8;

    void setup() {
      Serial.begin(9600);
      for (byte pin = startPin; pin <= endPin; pin++)
      {
          pinMode(pin, OUTPUT);
          digitalWrite(pin, LOW);
      }
    }

    void loop() {
      while (Serial.available() == 0) {}
      b = Serial.read() - '0';
      out = b;
      Serial.print("\n Out is ");
      Serial.println(out);
      digitalWrite(out, HIGH);
      delay(600);

      ...

However, from here you are using the pins as INPUT pins. You cannot change those on the fly, you might change them manually (by using `pinMode(pin, INPUT)`), but it does not seem normal to switch input and output pins, so maybe you should explain what you are intending with your application.


body: I am making an Arduino multimeter for current measurement. I first thought about using a shunt but that fails to work since I need to measure current in the mA range.

title: What Minimum Value Can I Measure With ACS712 30A Current Sensor?

Answers: 2

body:
That model has a sensitivity of 66mV/A which means for every 1A of current passing through it outputs 66mV.

The Arduino's ADC when running at 5V has a resolution of (5/1024) 4.88mV per LSB.

That means that 4.88/66 gives you 0.074 - or 74mA per LSB.

Since 1LSB is considered to be in the noise area of the signal you can expect the minimum usable value to be double that - 148mA

Which is pretty useless for measuring currents in the mA range.

You would get better results with the 5A variant, but still not great.

body:
The [datasheet for the ACS712][1] shows the following:

[![enter image description here][2]][2]

This means the 30A variant has a sensitivity of 66mV/A. This means a reading of 1A will show 66mV plus some bias voltage. The Arduino ADC is 10-bit, meaning it has 2^10 = 1024 increments across a default 5V voltage reference for the Uno, Nano, etc. This gives it a measuring resolution of 5V/1024 increments = 4.88mV voltage resolution. 4.88mV / 66mV/A = 0.074A, or 74mA.

So, the default _resolution_ of an Arduino Uno, Nano, etc, is **74mA.** Realistically it will bounce around this value, so your _precision_ might be about 3~4x this, or around **300mA**, and your accuracy is as good as you calibrate it, which could easily be around this value too if you calibrate it well.

74mA resolution isn't bad, but there are several tricks to improve this. Here are a few:

**1. External hardware solutions:**

1. **Use the 20A or 5A version instead of the 30A version of the ACS712.** The 5A version has a sensitivity of 185mV/A, which automatically improves your resolution to 4.88mV / 185mV/A = 0.026A, or **26mA**, which is 74mA/26mA = **2.8x better**.
1. **Buy an external ADC with high-resolution.** This [Adafruit ADS1115 16-Bit ADC](https://www.adafruit.com/product/1085) ([datasheet][3]) will improve your resolution on the 30A version of the ACS712 as follows. Minimum resolution of the ADC is now 5V/2^16 = 5V/65535 = 0.0763mV instead of 4.88mV, and 0.0763mV / 66mV/A = 0.001156A, or **1.156mA**.

**2. Software solutions (freebies!):**

1. **Change your voltage reference to use the internal 1.1V internal reference.** This is easy: call `analogReference(INTERNAL)` in your `setup()` function. Done! See: https://www.arduino.cc/reference/en/language/functions/analog-io/analogreference/. If I recall correctly, this is a diode-based internal voltage reference (see the ATmega328 datasheet), and can be off by as much as 10% from part to part, so calibrate it for each individual Arduino you have and you will get good results! Now, your ADC resolution is 1.1V/1024 = 1.07mV instead of the Arduino's default 4.88mV, so your current resolution is 1.07mV / 66mV/A = **16.2mA**, which is 74mA/16.2mA = **4.6x better**.
1. **Use oversampling to increase the Arduino's 10-bit ADC to up to ~16 bits or so.** Atmel Application Note [AVR121: Enhancing ADC resolution by oversampling][4] explains this very well, albeit it requires some serious study. There are libraries which exist to do this for you which you can Google for. I wrote one of them. [Here is a link to my website where I present one such library I wrote](https://www.electricrcaircraftguy.com/2014/05/using-arduino-unos-built-in-16-bit-adc.html). The gist is this: to get an 11-bit reading (which is 1-bit better than your hardware ADC resolution of 10-bits) you need to take 4^1 = 4 10-bit readings, sum them, then divide by 2^1 = 2. Your max value will be 1023 x 2 = 2046. To get a 16-bit reading (which is 6-bits better than your hardware ADC resolution of 10-bits) you need to take 4^6 = 4096 10-bit readings, sum them, and divide by 2^6 = 64. Your max value will be 1023 x 64 = 65472. Your voltage resolution will be improved from 4.88mV to ~0.0764mV _at best_. It won't be as good as a true 16-bit ADC, like the Adafruit one above, but it's good enough for many uses. Keep in mind that 4096 10-bit readings takes some time, so I also recommend you speed up the ADC clock to improve reading rate at 10-bits from ~10kHz to ~50kHz. This is also where a library comes in handy to make this easy to do. Free and open source solutions already exist. Here's a table I made back when I first read the  AVR121 application note and practiced oversampling. Consider the resolution values beyond ~16-bits to be purely theoretical. Oversampling has its limits.
    1. [![enter image description here][5]][5]

What would I do? I'd use the 1.1V internal voltage reference and oversampling with increased ADC clock speed on the ACS712 part which provides the minimum acceptable max current (ie: choose the 5A version not the 20A or 30A version if 5A is enough, or the 20A version not the 30A version if 20A is enough). **Just be sure that your max voltage now at the analog pins will not exceed the 1.1V Vref value**. If it will, use the standard 5V reference for the ADC, and just do oversampling alone. My current resolution would end up being a few mA in the end. If I can't sample at the desired frequency using oversampling (I don't know what dynamic effects you may be trying to measure), then I'd use an external high-resolution ADC which can sample faster than oversampling at high resolutions would allow.

----

And if that's not good enough, what would I do? I'd use a precision shunt, ie: "current resistor" with the right value such that I can measure values at the right range. If I need amplification I'd buy an external ADC and/or op-amp from Adafruit until I have everything sized just right. Remember, if your shunt (current resistor) is too small to measure the low currents you need, do the following:

1. Use a higher resistance value. V = IR (Voltage = Current x Resistance), so increase R to increase the V across it for a given current, I.
1. Use an op-amp to amplify the voltage drop across the resistor (go for an Adafruit one since Adafruit makes it easy and has the world's best examples).
1. Use a high-resolution ADC, and/or oversampling to increase your sensitivity to measure small voltage changes.

  [1]: https://www.sparkfun.com/datasheets/BreakoutBoards/0712.pdf
  [2]: https://i.stack.imgur.com/pvS2n.png
  [3]: https://cdn-shop.adafruit.com/datasheets/ads1115.pdf
  [4]: http://ww1.microchip.com/downloads/en/Appnotes/doc8003.pdf
  [5]: https://i.stack.imgur.com/hmZOq.png


body:
I have the following code, which allows me by scanning a typical 128 barcode to write this code in SD card under the Header "FA" as well as the time and date of scanner under the Header "Zeit".
I use for that an Arduino Uno, Waveshare scanner module connected in Serial to the arduino and SD/RTC mounted on top of the Arduino.

```
#include <SoftwareSerial.h>
#include <SPI.h>
#include <SD.h>
#include <string.h>
#include <Wire.h>
#include "RTClib.h"
#define rxPin 2
#define txPin 3
RTC_DS1307 RTC;
SoftwareSerial mySerial = SoftwareSerial (rxPin, txPin);
File main_folder; // initialize folder for saving
File dataFile; // initialize sd file
const int chipSelect = 10; // CS pin on sd card module
int prev_file_indx = 0; // used for file naming
String fileName = "000";
char timestamp[30];

const unsigned int MAX_INPUT = 50; // how much serial data we expect before a newline

void dateTime(uint16_t* date, uint16_t* time) {
  DateTime now = RTC.now();
  sprintf(timestamp, "d:d:d -/-/- \n", now.hour(), now.minute(), now.second(), now.month(), now.day(), now.year() - 2000);
  // return date using FAT_DATE macro to format fields
  *date = FAT_DATE(now.year(), now.month(), now.day());

  // return time using FAT_TIME macro to format fields
  *time = FAT_TIME(now.hour(), now.minute(), now.second());
}

void setup ()
{
  Serial.begin (115200);
  mySerial.begin (115200);
  Wire.begin();
  if (!RTC.begin()) {
    return;
  }

  pinMode(10, OUTPUT);
  if (!SD.begin(chipSelect)) {
      return;
    }

    main_folder = SD.open("/");
    fileName = sd_saver(main_folder);

 // end of setup

    delay(1500);
    dataFile = SD.open("DATA"+fileName+".csv",FILE_WRITE);
  if (dataFile) {
    Serial.println(dataFile);
    Serial.println("Writing Headers...");
    dataFile.println("FA,  Zeit");
    dataFile.close(); // close the file
    Serial.println("File closed, Headers written");
  }
 }//Open-Create file , populatrd with headers (2 collumns)

void process_data (const char * data)//to process the incomingserial data (from Scanner + timestamp when scanned) after a terminator received

{ delay(500);
    SdFile::dateTimeCallback(dateTime);
  DateTime now = RTC.now();
  sprintf(timestamp, "d:d:d -/-/- \n", now.hour(), now.minute(), now.second(), now.month(), now.day(), now.year() - 2000);
     dataFile = SD.open("DATA"+fileName+".csv",FILE_WRITE);
  if (dataFile) {
    Serial.println("Writing to file...");
    dataFile.print (data);
    dataFile.print(",");
    dataFile.println (timestamp);
    Serial.println (data);
    Serial.println (timestamp);
    Serial.println("Done.");
    dataFile.close();
  } else {
    Serial.println("error opening test.txt");
    delay(1000);
  }

}

void processIncomingByte (const byte inByte) //Processsing of the incoming scanned data
{
  static char input_line [MAX_INPUT];
  static unsigned int input_pos = 0;

  switch (inByte)
  {

    case '\n':   // end of text
      input_line [input_pos] = 0;  // terminating null byte

      // terminator reached! process input_line here ...
      process_data (input_line);

      // i here reset the buffer for the next time
      input_pos = 0;
      break;

    case '\r':   // discard the carriage return
      break;

    default:
      // keep adding if not full and permit for a terminating null byte
      if (input_pos < (MAX_INPUT - 1))
        input_line [input_pos++] = inByte;
      break;

  }  // end of the switch

} // end of processIncomingByte

void loop() {
  delay(2000);

  // if serial data available, process it
  while (mySerial.available () > 0)
  processIncomingByte (mySerial.read ());
  mySerial.write(processIncomingByte);
  delay(1000);

  //possibility to do other stuff while testing digital?? ...

}  // end of loop

String sd_saver(File dir){
  while(true){
    // iterate all files to ensure no overwrites
    File entry = dir.openNextFile();
    if (!entry){
      break;
    }
    // naming routine
    String entry_name = entry.name();
    if ((entry_name.substring(4,7)).toInt()>=prev_file_indx){
      prev_file_indx = (entry_name.substring(4,7)).toInt()+1;
      if (prev_file_indx>=100){
        fileName = String(prev_file_indx);
      } else if (prev_file_indx>=10){
        fileName = "0"+String(prev_file_indx);
      } else{
        fileName = "00"+String(prev_file_indx);
      }
    }
    entry.close();
  }
  return fileName;
}
```

[![Resulting file logged in the SD card][1]][1]

  [1]: https://i.stack.imgur.com/wszMI.png

My question is, can you come up with a way or guidance on how I should redo the code so that allows me to split the information of the barcode in different headers? that is columns. So for example the number "10000" as shown in the image after "@" to be in logged in another column called "Machine Number" ? I tried to insert control characters in the barcode to be scanned , but they are not interpreted as such but as characters .

Any help or thoughts are most than welcome

Thanks

title: How to separate in columns the data contained in a barcode

Answers: 0


body:
I'm doing a really simple project with an Arduino Nano and found a problem.
The circuit is a simple temperature sensor and a tension read from an analog pin everything showed on a Nokia 5110 LCD.

When the Nano is connected to the USB everything works and the reads are perfect.

When I install the circuit on my car taking the 12V to the Vin and the GND from the centraline everything goes bad: I certainly know that the 12V is obviously not stable and oscillates a lot (between 12V and 14V).

What can be the solution? Should I add some ref or should I regulate the input tension to maintain it stable to a certain quantity?

title: Extremely unstable analogRead() on Arduino Nano when powered from an external source

Answers: 1

body:
You can use a branded 5 V charger made for cars. You can directly connect this to 5 V pin of the Arduino.

By doing this:

 1. you are protecting the Arduino from the noise as well as high voltage spikes coming from the car 12 V supply
2. protecting yourself and others coming in contact with the Arduino or the sensors connected to the Arduino.

You can also
1. consider filtering the analog data read
2. protection circuits such as surge protection diodes or a 5.7 V Zener across 5 V and Ground of Arduino


body:
I'm trying to send numerical data from inertial sensors from my Arduino to a Python script via serial (PySerial).
I found that if I continuously send the data from the Arduino without stopping, the serial buffer fills up quickly and the sensor measurements that the Python reads becomes delayed.

To fix this, I thought of having the Python script send over a transmit command to the Arduino when it needs data. I'm sending a char 't' to signify this command, but the delay between Python sending the command and the Arduino sending the data is too large.

I'm wondering if there's a 'proper' way of doing this, as I'm sure it's probably been done before?

title: Best way to ask Arduino for data from Python?

Answers: 1

body:
This is not a complete answer to your problem, but currently you seem to have some misconceptions, that prevent you from pin pointing the actual problem.

The data transmission from the sensor, over the Arduino to your python script on the PC has multiple places, where a bottleneck can appear. The total data rate will then be at maximum as large, as the smallest bottleneck allows it to be.

First you have a potential bottleneck in the communication between sensor and Arduino. You haven't stated, what kind of IMU chip you have and how it communicates. Typical IMU chips like the MPU series are interfaces via I2C or SPI. SPI can be sped up rather greatly, while I2C is not that easy to speed up. But it depends greatly on the capabilities of the used chip. You can find information about that in the corresponding datasheet of the chip.

---

The next interface is the Serial (UART) interface between Arduino and PC. This interface has a fixed baudrate. When you use `Serial.write()` or its siblings, you simply fill the send buffer of the `Serial` library. The data will then be send out automatically at the correct timing for your baudrate. The transmission always happens, if the python script is reading or not. The transmission also happens, when the serial buffer of the script is full. The Arduino does not know about the buffer being full. So in this case the data is not delayed, but lost.

---

The last - and probably most important - potential bottleneck is how you read and send the data on Arduino and in the python script. Here I'm covering the Arduino side.

You should not use functions like `Serial.readString()`, as they work with a timeout, which will slow down your code drastically. Instead you should read the Serial data byte by byte into a buffer, delimiting your message with a special character (for example the newline character `\n`). You check, if there is any data `Serial.available()`, and if yes, you read one byte into a `char` array, which is your own buffer. You are doing that repeatedly, until you read the delimiting character. Then you process the complete message. That way will give you some important improvements:

- You can do things in the meantime (for example reading new data from your sensor)
- It works without any arbitrary timeout, thus not slowing down your code unnecessaryly
- The delimiting character frames a full message, so that you can distinguish two different messages from each other and thus easier process them

---

Considering the above, you should make the requirements clearer:

- How much latency between the actual sensor measurements and the receiving in the python script is ok for you, meaning: How old can the measurements be, that the python script gets? (You just stated, that it is too large, but you have not mentioned how large)

- Do you need continuous data transmission, or just one or a few sets of the IMU data?

Then you can check for the needed speed and data rate. Check, if all involved interfaces and codes can really handle your requirements.

Also it would be easier for us to help you, when you show your current code in your question.


body:
Can analog pins be defined by their digital pin number, and be used for analog purposes?

For example, instead of defining `A0` for a pinout with the Uno, it could be `14`?

Where is this documented? Is there a PDF type manual related to this, but not so low level to get into the ATmega chip?

[![enter image description here][1]][1]

https://www.arduino.cc/en/Hacking/PinMapping2560

  [1]: https://i.stack.imgur.com/As4Tn.png

title: Can analog pins be defined as either their analog name (A0) or their digital pin number?

Answers: 1

body:
> For example, instead of defining A0 for a pinout with the Uno, it could be 14?

Yes. In fact A0 is just a placeholder for the number 14.

For all these things you should look in the `pins_arduino.h` file (Arduino\variants\wifio) for any variant you are interested in. That's where most of these symbols are defined. For example:

```
#define PIN_A0   (14)
#define PIN_A1   (15)
#define PIN_A2   (16)
#define PIN_A3   (17)
#define PIN_A4   (18)
#define PIN_A5   (19)
#define PIN_A6   (20)
#define PIN_A7   (21)

static const uint8_t A0 = PIN_A0;
static const uint8_t A1 = PIN_A1;
static const uint8_t A2 = PIN_A2;
static const uint8_t A3 = PIN_A3;
static const uint8_t A4 = PIN_A4;
static const uint8_t A5 = PIN_A5;
static const uint8_t A6 = PIN_A6;
static const uint8_t A7 = PIN_A7;
```

Incidentally, on the Uno you can also just use `0` for A0 with `analogRead()`.


body:
I'm trying to drive an external DAC via SPI interface using ESP32 chip. But I cannot achieve the desired speed (>1M transfers/sec, each transfer consists of 16bits). The reason is not the SPI speed itself, which could be set as high as 40MHz, but the time delay between two consecutive SPI transfers.

A sample code is as follows:

    #include <SPI.h>

    void setup()
    {
        Serial.begin(115200);
        SPI.begin();
        SPI.beginTransaction(SPISettings(40000000,MSBFIRST,SPI_MODE0));
    }

    void loop()
    {
        unsigned long tstart=micros(),count=0;

        byte data[18]={0,1,2,1,3,1,0,1,2,1,3,1,0,1,2,1,3,1};

        while(micros()-tstart<1000000)
        {
            for(byte i=0;i<9;i++)
              SPI.transfer16(0b0101010110101010);
            count+=9;
        }

        Serial.println(count);
    }

The output shows that ESP32 can do approximately 694,800 transfers/sec, still far away from my requirement of 1M transfers/sec. However, theoretically, using a 40M SPI bus, each transfer only takes 16/40M sec, which should enable a >2M transfers/sec speed, so the difference must originate from the time delay between two consecutive SPI transfers.

I know that these delays can possibly be canceled by transferring more data in a single transfer command. However, the interface of DAC requires me to pulse SYNC once (set it high and then low) before each SPI transfer, which is not possible if I use a single SPI transfer command.

I have searched for solutions online and found two related problems:

The one [here](https://github.com/espressif/esp-idf/issues/368) suggests disabling all MUTEX commands in *esp32-hal-spi.c/h*. It seems reasonable, but I see no effects, probably because the compiler has already deleted those codes in optimization.

Another [here](https://esp32.com/viewtopic.php?t=1383) suggests using RMT to replace SPI, but suffer from timing issues.

I think there is also room for improvement as I only need to output data, and I access SPI on a single thread, so the solution can be thread-unsafe.

So I'm here to ask, is there any way to accelerate the SPI transfers? Thanks a lot in advance!

title: Reduce time between two consecutive SPI transfers on ESP32

Answers: 0


body:
**The Problem**

I've been working on a project that requires the use of a CAN Bus Shield v2 on an Arduino. For most of the time it has worked great, completely as intended. But recently, I was trying to hookup a 24V heater to a MOSFET to be controlled by the Arduino. I had hooked it up the pin 2 which later I found out was a bad idea because pin 2 is for the interrupt signal. I uploaded the code and the heater did not turn on.

A while later I tried to upload code to the Arduino and it would not upload, citing a not in sync error. So, switched the Arduino board out for another one of the same model and the code uploaded just fine. But, the CAN Shield was throwing a "CAN Bus Shield Init FAILED" error over and over again. And the INT light was staying permanently on. And the Rx light would stay on if I tried to send a message on the bus from another node.

My question is, will I have to purchase a new shield or is there a way to fix this?

**What I have tried**

 - Turning it off and on again
 - Using the shield on the old Arduino
 - Wiping the Arduino and adding the code again
 - Reverting to an older piece of code
 - Setting pin 2 HIGH (this turned off the INT light but did not fix the init problem)
 - Sending various messages on the CAN Bus
 - Flipping the OBD switch on/off
 - Trying different resistors

<!-- Begin schematic: In order to preserve an editable schematic, please
     don't edit this section directly.
     Click the "edit" link below the image in the preview instead. -->

![schematic](https://i.stack.imgur.com/XQW4d.png)

<!-- End schematic -->

title: CAN Bus Shield Initialization Failed

Answers: 0