text:
vk2828u7g5lf GPS module over SoftwareSerial
So my goal was simple. Trying to get a GPS speed, and show it on a display (later use it to control a stepper motor). I am using the vk2828u7g5lf GPS module from Banggood, which after days of tinkering and trying several tutorials, I managed to make it work with ONLY the following code:
    boolean gpsStatus[] = {false, false, false, false, false, false, false};
unsigned long start;

#include <SoftwareSerial.h>
SoftwareSerial gpsSerial(3,2); // RX, TX

void setup()
{
  gpsSerial.begin(9600);
  // START OUR SERIAL DEBUG PORT
  Serial.begin(19200);
  //
  //Settings Array contains the following settings: [0]NavMode, [1]DataRate1, [2]DataRate2, [3]PortRateByte1, [4]PortRateByte2, [5]PortRateByte3,
  //[6]NMEA GLL Sentence, [7]NMEA GSA Sentence, [8]NMEA GSV Sentence, [9]NMEA RMC Sentence, [10]NMEA VTG Sentence
  //NavMode:
  //Pedestrian Mode    = 0x03
  //Automotive Mode    = 0x04
  //Sea Mode           = 0x05
  //Airborne < 1G Mode = 0x06
  //
  //DataRate:
  //1Hz     = 0xE8 0x03
  //2Hz     = 0xF4 0x01
  //3.33Hz  = 0x2C 0x01
  //4Hz     = 0xFA 0x00
  //
  //PortRate:
  //4800   = C0 12 00
  //9600   = 80 25 00
  //19200  = 00 4B 00  **SOFTWARESERIAL LIMIT FOR ARDUINO UNO R3!**
  //38400  = 00 96 00  **SOFTWARESERIAL LIMIT FOR ARDUINO MEGA 2560!**
  //57600  = 00 E1 00
  //115200 = 00 C2 01
  //230400 = 00 84 03
  //
  //NMEA Messages:
  //OFF = 0x00
  //ON  = 0x01
  //
  byte settingsArray[] = {0x03, 0xFA, 0x00, 0x00, 0xE1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; //
  configureUblox(settingsArray);
}

void loop()
{
  while(1) {
    if(gpsSerial.available())
    {
    // THIS IS THE MAIN LOOP JUST READS IN FROM THE GPS SERIAL AND ECHOS OUT TO THE ARDUINO SERIAL.
    Serial.write(gpsSerial.read());
    }
  }
}

void configureUblox(byte *settingsArrayPointer) {
  byte gpsSetSuccess = 0;
  Serial.println("Configuring u-Blox GPS initial state...");

  //Generate the configuration string for Navigation Mode
  byte setNav[] = {0xB5, 0x62, 0x06, 0x24, 0x24, 0x00, 0xFF, 0xFF, *settingsArrayPointer, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00, 0x05, 0x00, 0xFA, 0x00, 0xFA, 0x00, 0x64, 0x00, 0x2C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  calcChecksum(&setNav[2], sizeof(setNav) - 4);

  //Generate the configuration string for Data Rate
  byte setDataRate[] = {0xB5, 0x62, 0x06, 0x08, 0x06, 0x00, settingsArrayPointer[1], settingsArrayPointer[2], 0x01, 0x00, 0x01, 0x00, 0x00, 0x00};
  calcChecksum(&setDataRate[2], sizeof(setDataRate) - 4);

  //Generate the configuration string for Baud Rate
  byte setPortRate[] = {0xB5, 0x62, 0x06, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0xD0, 0x08, 0x00, 0x00, settingsArrayPointer[3], settingsArrayPointer[4], settingsArrayPointer[5], 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  calcChecksum(&setPortRate[2], sizeof(setPortRate) - 4);

  byte setGLL[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x2B};
  byte setGSA[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x32};
  byte setGSV[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x39};
  byte setRMC[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x40};
  byte setVTG[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x46};

  delay(2500);

  while(gpsSetSuccess < 3)
  {
    Serial.print("Setting Navigation Mode... ");
    sendUBX(&setNav[0], sizeof(setNav));  //Send UBX Packet
    gpsSetSuccess += getUBX_ACK(&setNav[2]); //Passes Class ID and Message ID to the ACK Receive function
    if (gpsSetSuccess == 5) {
      gpsSetSuccess -= 4;
      setBaud(settingsArrayPointer[4]);
      delay(1500);
      byte lowerPortRate[] = {0xB5, 0x62, 0x06, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0xD0, 0x08, 0x00, 0x00, 0x80, 0x25, 0x00, 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA2, 0xB5};
      sendUBX(lowerPortRate, sizeof(lowerPortRate));
      gpsSerial.begin(9600);
      delay(2000);
    }
    if(gpsSetSuccess == 6) gpsSetSuccess -= 4;
    if (gpsSetSuccess == 10) gpsStatus[0] = true;
  }
  if (gpsSetSuccess == 3) Serial.println("Navigation mode configuration failed.");
  gpsSetSuccess = 0;
  while(gpsSetSuccess < 3) {
    Serial.print("Setting Data Update Rate... ");
    sendUBX(&setDataRate[0], sizeof(setDataRate));  //Send UBX Packet
    gpsSetSuccess += getUBX_ACK(&setDataRate[2]); //Passes Class ID and Message ID to the ACK Receive function
    if (gpsSetSuccess == 10) gpsStatus[1] = true;
    if (gpsSetSuccess == 5 | gpsSetSuccess == 6) gpsSetSuccess -= 4;
  }
  if (gpsSetSuccess == 3) Serial.println("Data update mode configuration failed.");
  gpsSetSuccess = 0;

  while(gpsSetSuccess < 3 && settingsArrayPointer[6] == 0x00) {
    Serial.print("Deactivating NMEA GLL Messages ");
    sendUBX(setGLL, sizeof(setGLL));
    gpsSetSuccess += getUBX_ACK(&setGLL[2]);
    if (gpsSetSuccess == 10) gpsStatus[2] = true;
    if (gpsSetSuccess == 5 | gpsSetSuccess == 6) gpsSetSuccess -= 4;
  }
  if (gpsSetSuccess == 3) Serial.println("NMEA GLL Message Deactivation Failed!");
  gpsSetSuccess = 0;

  while(gpsSetSuccess < 3 && settingsArrayPointer[7] == 0x00) {
    Serial.print("Deactivating NMEA GSA Messages ");
    sendUBX(setGSA, sizeof(setGSA));
    gpsSetSuccess += getUBX_ACK(&setGSA[2]);
    if (gpsSetSuccess == 10) gpsStatus[3] = true;
    if (gpsSetSuccess == 5 | gpsSetSuccess == 6) gpsSetSuccess -= 4;
  }
  if (gpsSetSuccess == 3) Serial.println("NMEA GSA Message Deactivation Failed!");
  gpsSetSuccess = 0;

  while(gpsSetSuccess < 3 && settingsArrayPointer[8] == 0x00) {
    Serial.print("Deactivating NMEA GSV Messages ");
    sendUBX(setGSV, sizeof(setGSV));
    gpsSetSuccess += getUBX_ACK(&setGSV[2]);
    if (gpsSetSuccess == 10) gpsStatus[4] = true;
    if (gpsSetSuccess == 5 | gpsSetSuccess == 6) gpsSetSuccess -= 4;
  }
  if (gpsSetSuccess == 3) Serial.println("NMEA GSV Message Deactivation Failed!");
  gpsSetSuccess = 0;

  while(gpsSetSuccess < 3 && settingsArrayPointer[9] == 0x00) {
    Serial.print("Deactivating NMEA RMC Messages ");
    sendUBX(setRMC, sizeof(setRMC));
    gpsSetSuccess += getUBX_ACK(&setRMC[2]);
    if (gpsSetSuccess == 10) gpsStatus[5] = true;
    if (gpsSetSuccess == 5 | gpsSetSuccess == 6) gpsSetSuccess -= 4;
  }
  if (gpsSetSuccess == 3) Serial.println("NMEA RMC Message Deactivation Failed!");
  gpsSetSuccess = 0;

  while(gpsSetSuccess < 3 && settingsArrayPointer[10] == 0x00) {
    Serial.print("Deactivating NMEA VTG Messages ");
    sendUBX(setVTG, sizeof(setVTG));
    gpsSetSuccess += getUBX_ACK(&setVTG[2]);
    if (gpsSetSuccess == 10) gpsStatus[6] = true;
    if (gpsSetSuccess == 5 | gpsSetSuccess == 6) gpsSetSuccess -= 4;
  }
  if (gpsSetSuccess == 3) Serial.println("NMEA VTG Message Deactivation Failed!");

  gpsSetSuccess = 0;
  if (settingsArrayPointer[4] != 0x25) {
    Serial.print("Setting Port Baud Rate... ");
    sendUBX(&setPortRate[0], sizeof(setPortRate));
    setBaud(settingsArrayPointer[4]);
    Serial.println("Success!");
    delay(500);
  }
}

void calcChecksum(byte *checksumPayload, byte payloadSize) {
  byte CK_A = 0, CK_B = 0;
  for (int i = 0; i < payloadSize ;i++) {
    CK_A = CK_A + *checksumPayload;
    CK_B = CK_B + CK_A;
    checksumPayload++;
  }
  *checksumPayload = CK_A;
  checksumPayload++;
  *checksumPayload = CK_B;
}

void sendUBX(byte *UBXmsg, byte msgLength) {
  for(int i = 0; i < msgLength; i++) {
    gpsSerial.write(UBXmsg[i]);
    gpsSerial.flush();
  }
  gpsSerial.println();
  gpsSerial.flush();
}

byte getUBX_ACK(byte *msgID) {
  byte CK_A = 0, CK_B = 0;
  byte incoming_char;
  boolean headerReceived = false;
  unsigned long ackWait = millis();
  byte ackPacket[10] = {0xB5, 0x62, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  int i = 0;
  while (1) {
    if (gpsSerial.available()) {
      incoming_char = gpsSerial.read();
      if (incoming_char == ackPacket[i]) {
        i++;
      }
      else if (i > 2) {
        ackPacket[i] = incoming_char;
        i++;
      }
    }
    if (i > 9) break;
    if ((millis() - ackWait) > 1500) {
      Serial.println("ACK Timeout");
      return 5;
    }
    if (i == 4 && ackPacket[3] == 0x00) {
      Serial.println("NAK Received");
      return 1;
    }
  }

  for (i = 2; i < 8 ;i++) {
  CK_A = CK_A + ackPacket[i];
  CK_B = CK_B + CK_A;
  }
  if (msgID[0] == ackPacket[6] && msgID[1] == ackPacket[7] && CK_A == ackPacket[8] && CK_B == ackPacket[9]) {
    Serial.println("Success!");
    Serial.print("ACK Received! ");
    printHex(ackPacket, sizeof(ackPacket));
    return 10;
        }
  else {
    Serial.print("ACK Checksum Failure: ");
    printHex(ackPacket, sizeof(ackPacket));
    delay(1000);
    return 1;
  }
}

void printHex(uint8_t *data, uint8_t length) // prints 8-bit data in hex
{
  char tmp[length*2+1];
  byte first ;
  int j=0;
  for (byte i = 0; i < length; i++)
  {
    first = (data[i] >> 4) | 48;
    if (first > 57) tmp[j] = first + (byte)7;
    else tmp[j] = first ;
    j++;

    first = (data[i] & 0x0F) | 48;
    if (first > 57) tmp[j] = first + (byte)7;
    else tmp[j] = first;
    j++;
  }
  tmp[length*2] = 0;
  for (byte i = 0, j = 0; i < sizeof(tmp); i++) {
    Serial.print(tmp[i]);
    if (j == 1) {
      Serial.print(" ");
      j = 0;
    }
    else j++;
  }
  Serial.println();
}

void setBaud(byte baudSetting) {
  if (baudSetting == 0x12) gpsSerial.begin(4800);
  if (baudSetting == 0x4B) gpsSerial.begin(19200);
  if (baudSetting == 0x96) gpsSerial.begin(38400);
  if (baudSetting == 0xE1) gpsSerial.begin(57600);
  if (baudSetting == 0xC2) gpsSerial.begin(115200);
  if (baudSetting == 0x84) gpsSerial.begin(230400);
}

However, this one doesn't have a simple getSpeed() function, so I've tried to move to a library like TinyGPS that does have said function. Everything compiles fine, but it seems I am not getting a GPS signal with this script, while I have an accurate reading with about 7 satellites of the first script. I've triple checked the baud rates, and they all match, so I am stuck here.
    #include <SoftwareSerial.h>

#include <TinyGPS.h>

/* This sample code demonstrates the normal use of a TinyGPS object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/

TinyGPS gps;
SoftwareSerial ss(3,2);

static void smartdelay(unsigned long ms);
static void print_float(float val, float invalid, int len, int prec);
static void print_int(unsigned long val, unsigned long invalid, int len);
static void print_date(TinyGPS &gps);
static void print_str(const char *str, int len);

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

  Serial.print("Testing TinyGPS library v. "); Serial.println(TinyGPS::library_version());
  Serial.println("by Mikal Hart");
  Serial.println();
  Serial.println("Sats HDOP Latitude  Longitude  Fix  Date       Time     Date Alt    Course Speed Card  Distance Course Card  Chars Sentences Checksum");
  Serial.println("          (deg)     (deg)      Age                      Age  (m)    --- from GPS ----  ---- to London  ----  RX    RX        Fail");
  Serial.println("-------------------------------------------------------------------------------------------------------------------------------------");

  ss.begin(9600);
}

void loop()
{
  float flat, flon;
  unsigned long age, date, time, chars = 0;
  unsigned short sentences = 0, failed = 0;
  static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;

  print_int(gps.satellites(), TinyGPS::GPS_INVALID_SATELLITES, 5);
  print_int(gps.hdop(), TinyGPS::GPS_INVALID_HDOP, 5);
  gps.f_get_position(&flat, &flon, &age);
  print_float(flat, TinyGPS::GPS_INVALID_F_ANGLE, 10, 6);
  print_float(flon, TinyGPS::GPS_INVALID_F_ANGLE, 11, 6);
  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);
  print_date(gps);
  print_float(gps.f_altitude(), TinyGPS::GPS_INVALID_F_ALTITUDE, 7, 2);
  print_float(gps.f_course(), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);
  print_float(gps.f_speed_kmph(), TinyGPS::GPS_INVALID_F_SPEED, 6, 2);
  print_str(gps.f_course() == TinyGPS::GPS_INVALID_F_ANGLE ? "*** " : TinyGPS::cardinal(gps.f_course()), 6);
  print_int(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0xFFFFFFFF : (unsigned long)TinyGPS::distance_between(flat, flon, LONDON_LAT, LONDON_LON) / 1000, 0xFFFFFFFF, 9);
  print_float(flat == TinyGPS::GPS_INVALID_F_ANGLE ? TinyGPS::GPS_INVALID_F_ANGLE : TinyGPS::course_to(flat, flon, LONDON_LAT, LONDON_LON), TinyGPS::GPS_INVALID_F_ANGLE, 7, 2);
  print_str(flat == TinyGPS::GPS_INVALID_F_ANGLE ? "*** " : TinyGPS::cardinal(TinyGPS::course_to(flat, flon, LONDON_LAT, LONDON_LON)), 6);

  gps.stats(&chars, &sentences, &failed);
  print_int(chars, 0xFFFFFFFF, 6);
  print_int(sentences, 0xFFFFFFFF, 10);
  print_int(failed, 0xFFFFFFFF, 9);
  Serial.println();

  smartdelay(1000);
}

static void smartdelay(unsigned long ms)
{
  unsigned long start = millis();
  do
  {
    while (ss.available())
      gps.encode(ss.read());
  } while (millis() - start < ms);
}

static void print_float(float val, float invalid, int len, int prec)
{
  if (val == invalid)
  {
    while (len-- > 1)
      Serial.print('*');
    Serial.print(' ');
  }
  else
  {
    Serial.print(val, prec);
    int vi = abs((int)val);
    int flen = prec + (val < 0.0 ? 2 : 1); // . and -
    flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;
    for (int i=flen; i<len; ++i)
      Serial.print(' ');
  }
  smartdelay(0);
}

static void print_int(unsigned long val, unsigned long invalid, int len)
{
  char sz[32];
  if (val == invalid)
    strcpy(sz, "*******");
  else
    sprintf(sz, "%ld", val);
  sz[len] = 0;
  for (int i=strlen(sz); i<len; ++i)
    sz[i] = ' ';
  if (len > 0)
    sz[len-1] = ' ';
  Serial.print(sz);
  smartdelay(0);
}

static void print_date(TinyGPS &gps)
{
  int year;
  byte month, day, hour, minute, second, hundredths;
  unsigned long age;
  gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths, &age);
  if (age == TinyGPS::GPS_INVALID_AGE)
    Serial.print("********** ******** ");
  else
  {
    char sz[32];
    sprintf(sz, "%02d/%02d/%02d %02d:%02d:%02d ",
        month, day, year, hour, minute, second);
    Serial.print(sz);
  }
  print_int(age, TinyGPS::GPS_INVALID_AGE, 5);
  smartdelay(0);
}

static void print_str(const char *str, int len)
{
  int slen = strlen(str);
  for (int i=0; i<len; ++i)
    Serial.print(i<slen ? str[i] : ' ');
  smartdelay(0);
}

The result of the last script looks like this:
Testing TinyGPS library v. 13
by Mikal Hart

Sats HDOP Latitude  Longitude  Fix  Date       Time     Date Alt    Course Speed Card  Distance Course Card  Chars Sentences Checksum
          (deg)     (deg)      Age                      Age  (m)    --- from GPS ----  ---- to London  ----  RX    RX        Fail
-------------------------------------------------------------------------------------------------------------------------------------
**** **** ********* ********** **** ********** ******** **** ****** ****** ***** ***   *******  ****** ***   0     0         0
**** **** ********* ********** **** ********** ******** **** ****** ****** ***** ***   *******  ****** ***   52    0         0
**** **** ********* ********** **** ********** ******** **** ****** ****** ***** ***   *******  ****** ***   104   0         0
**** **** ********* ********** **** ********** ******** **** ****** ****** ***** ***   *******  ****** ***   169   0         0
**** **** ********* ********** **** ********** ******** **** ****** ****** ***** ***   *******  ****** ***   221   0         0

A list of libraries I've tried:
 - NeoGPS
 - NeoGPS (customized version of a forum)
 - TineGPS
 - AdafruitGPS
And some more random (video) tutorials online. If anyone could help me out on this one, I would be highly grateful! (and perhaps keep some hair on my head)

So it turned out it was a loose connection facepalm. Anyway, it still is far from usable. Now the data starts with a blank line, followed by actual gps data. Problem is that even without moving my module, the lat/long/and height (?) Is still moving around allot?

The clue lies in this part of your first sketch:
//NMEA Messages:
//OFF = 0x00
//ON  = 0x01
//
byte settingsArray[] = {0x03, 0xFA, 0x00, 0x00, 0xE1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; //
configureUblox(settingsArray);

The final entry in your configuration is 0x00 which is "turn off NEMA messages".
There's two things to note here:

You are not configuring the GPS receiver in your second code, and
All other GPS libraries of note parse NEMA messages, which your first code turns off.

You will need to replicate the configuration code from your first sketch in your second sketch, but turning ON NEMA messages.


text:
WS2812B LED strip + Arduino First Pixel keeps dying/breaking
I am trying too hook up a WS2812B LED strip to an Arduino Nano. The current strip consists of 6 pixels, and the whole thing is powered by a 5.26 V PC power supply.
The problem is that the first pixel keeps dying after about 1 minute. This means I have to cut the strip and re-solder the connections. Before the failure, the strip runs the correct examples from the FastLED package.

As this happened I looked for solutions. Adafruit's neopixel guide suggested:

adding a 1000 µF capacitor between ground and +5 V to cancel power peaks
adding a 300-500 Ω resistor between the strip_Data_in and D5

I had no 1000 µF+ Capacitor, so I used what I had, 470 µF, and installed it with the resistor.

This did not solve the problem. Another recommendation was to place a diode between the data and +5 V. I think this is to remove any power spikes in the data connection. With a good power supply this should not be necessary I guess, but it couldn't hurt. Another tip was to add a 100 kΩ resistor between data and ground.
Putting all mentioned above together gives something like this:

But in the end nothing changed. I tried alot of variations of solutions:

With and without condensator between ground and Vin.

With and without resistor between data and Arduino, and varied it between 220 Ω to 1 kΩ.

With and without the diodes. I tried connecting data with a diode to ground, +5 V, to both, and to none.

I have tried using a 3.7 V power source to see whether I could avoid burning the pixel. The LEDs had too little power to light up.

I have tried powering via the USB->Arduino->Arduino +5 V pin -> strip +5 V

Any idea where I might be fucking up?
I have burnt 30 pixels so far, with all the same result: blinking, tripping, and eventually failure. Removing the first LED always fixed the problem. This brand of LED strip did work on some other premade controller.
Some of my own ideas, of causes:

There really needs to be a 1000 µF capacitor. (I have never had trouble with voltage peaks with this powersupply, and this does not explain why the system fails after some time, instead of at plugin.)

EDIT 1:
I did some additional tests.

Raised the resistor before the data pin, from the recommended 470 Ω, as high as possible. I reached 8 kΩ (higher did not work). -> Same result, burned pixel

Lowered the voltage on the data input pin, with two resistances, one connected to ground. The LED strip only recognised data input when the 'Din_High' was above 3.5 V. Running at a bit lower voltage stopped the LEDs from recognising data. Yet still, same result -> burned pixel.

Changing the power supply: I changed the PC power supply to a 5 V power bank for loading celphones. The voltage this device was regulated to was between 5.2 and 4.8 V. The behaviour was the same -> burned pixel.

I would guess that IF:

the 5 V is stable and within 5.5 and 4.5 V and

The Din is within 0 and 5 V

The cable should be unable to break itself, right?

Powering via the usb cable is the safest. What was the result with just one rgb led and all the power from the usb 5v? You need another rgb led to compare, can you buy a normal rgb led? Some led controller chips (inside the rgb led) operate at 3.3v and a trick is used to make them work at 5v, perhaps the premade controller did something special to avoid to damage them. Can you show your power supply? If it is cheap and not allowed in your country, then you should not use it. For now, I think the combination of a non-standard led strip together with a cheap power supply might be the problem.

USB 2.0 only allows for 500mA.  It can be more, but that's the (assumed / agreed upon) limit if you are plugging into, for example, a lap top.  I would try a new / better 5 volt USB power supply.  One that can provide several Amps of power.  Guessing, those types of LED can take tens of mA.  Perhaps 60mA.  So 6 x 60mA is 360mA.  So I would at least get a supply that is double that.

In the third picture, take out the bridging jumper on 40. (last before the input pin of the led) Put another series resistor in place of the wire, from the input to the diodes. Also take a short wire and connect the ground track at the module (41) and connect it directly to 51 at the bottom of the Nano, duplicating the ground connection. Keep the wire short, not using premade jumper wires. This is in case you have a point on the breadboard that is not making adequate connections. Your wiring technique is as good as can be expected using a breadboard. A scope would be handy at this point.

does the first pixel flash green before it dies?

first pixel failure seems to indicate a problem with the data line .... the second pixel  is buffered by the first pixel ..... you could also try inserting a diode in series with the 5.26V power supply just to knock 0.6V off the voltage

the data line voltage has a range of -0.5V to VDD+0.5V ...... maybe the power voltage (VDD) drops to the point where the data line voltage is higher than 0.5V above VDD ..... maybe you need to use an open collector driver on the data line with a pullup resistor to VDD line

I found (a part of) the problem:
The soldered pin connections at start of the ribbon had leaking current. This was due to the soldering flux remaining around the pins. Rinsing the connection with water carefully solved the problem.
In earlier runs I soldered with flux and simply wiped it off afterwards. Also note that I am generous in flux usage. I do not know how people can make neat solderingwork without it.
Just scraping, and wiping with tissues between the connections is apparently unreliable. The flux is water solutable, said the package, so I used tap water for cleaning, but I also tried alcohol at times. Of course by taking care not to make anything wet besides the connection, and drying careful afterwards.
Obviously I checked the look of my soldering earlier as well, and it looked quite neat in my opinion. Yet measuring resistance between pins gave varying results, also compared with unsoldered, which made me wonder why.
Cleaning the area around the soldered pins seemed to remove this, which indicates that this may be due to the soldering flux that was remaining. I also heard that flux tends to start flowing again as it heats up under operation, which indicates why the connection seemed good right after soldering, but changed trough time.
Perhaps this is why people use these ultrasonic cleaning baths or something.
About the led strips:
They were one of the cheapest ones available.
About the power supplies:
The first power supply is the 5v line from a PC power supply, which should be able to give quite some amps. ( i forgot how much exactly, but way more than I needed)
The second power supply was a Lithion battery with regulator. The thing says it is able to supply 2 amps, but I stayed far away from this limit.
Thank you for your tips. You help me keep improving myself.
Any more tips on cleaning soldered connections are welcome.
EDIT:
Oh boi! If it isn't the consequences of my own actions!
So this is what SN39 flux does to soldered wires in 2 years. This is a different object, soldered with the same acid based flux thats intended for copper piping, and not for electricals. I have quite some wonky soldering work to replace at my job. Don't be me lads, and only use flux thats intended for electricals.

Very late note on this project, but nonetheless:
I found out that I used a soldering flux which was not suitable for electronics. (S39, which is an acid based flux, which should have been a resin based one)
It solders great but creates corrosion pretty quick, so hence is to be avoided.
Too bad that I never found replacing flux that solders so nice.
I am unsure if this is the cause of the pixels dying ,though.

To my understanding, anything connected to the data line (resistors, diodes, etc) is there to protect to data pin from either sourcing too much current to the LEDs or receive a too high voltage.
The capacitor, on the other hand, is there to provide a buffer and maintain the voltage at the right value when current absorption increases with a spike.
If your LEDS burn up and it's always the first one, assuming they are all programmed to lit up of the same color, the most reasonable reason IMHO is you are feeding too much current, in particular in the form of higher voltage through the resistors on the strip.
I suggest you double check the source voltage with no load and with a light load, then try a different power supply and, as last resort, try to lower the brightness intensity of the LEDS: set brightness to 50% and check if it takes like 3 or 4 times longer to burn the LED, which will be a confirmation about my statement.
The first LED is the one receiving the highest voltage in the strip as the strip itself has a non trivial resistance, especially the cheap ones. Lowering the brightness you are actually lowering the amount of time the LED is on and it should prolong the LED life in a non linear way.
If my assumption is correct, this also means you have already partially damaged all the LEDS on the strip, the closer to the power, the more damaged they are.

I HIGHLY doubt that there would be any significant voltage drop between adjacent LED modules on the strip. If there was that kind of loss then a strip of lights would never work as they do. The most likely point of damage would be to the control input. And there is a reason that Adafruit recommends adding series resistance to the input. It is known to be the weak point.

https://www.kitronik.co.uk/pdf/WS2812B-LED-datasheet.pdf
Check the power supply. It is likely too high a voltage. 5.3V is the absolute max. The resistor is only to prevent signal reflections on long wire runs. Neither it or the diodes are needed for your setup.
For comparison, here are 4 rings of 43 WS2812B each, with only a 0.1uF cap per chip, each ring driven from a different data pin on an Uno, which is off screen, and a 10A power supply (4 rings x 43 LEDs/ring * 60mA/LED = 10.3A max current).
https://www.youtube.com/watch?v=CGOxbehyoM4
You can see the wires are much longer than yours.  Unfortunately the camera doesn't self adjust to the brightness changes too well, so the video can be a bit glary at times.

While you've tried a 470µF capacitor, it might be worth getting a 1000µF capacitor, as recommended. Capacitors help stabilize the power supply, especially during sudden current spikes.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Will this sensor work with arduino?
I'm building an electronic gate. I'm needing a photoelectric sensor to detect cars. This one in the link looks decent. it runs on 12v so I will need to power it separately from the arduino. But does this mean it also puts 12v back to the signal wire? Will that work with ardunio without burning the circuit? How many V can i send into an arduino pin?
thanks
photo electric sensor

Some arduino boards use a 5v microcontroller, some use a 3.3v processor. The input voltage may not be above that. You have to use a few electronic components to fix it. It depends on the output of the detector, but two resistors to lower 12v to 5v is the most common solution. Search for: voltage divider arduino.

I'm not sure what I will end up with, but the one i have now is a arduino uno made by keyestudio. I'm not sure if it means anything but there is a 3.3 and a 5 v power supply from it. Sorry, i'm kinda new at this. but using resistors to drop the voltage does seem like a pretty good solution.

Edit your question to add the information that you're using the Keyestudio Uno. The question should contain all the necessary information rather than having to hunt through the comments for it.

The sensor you specified states:
Output: SPDT Relay Output

If accurate, it may be inferred that the output is simply 3 contacts where one is normally open and the other is normally closed and the 3rd is the common.  If true then you can treat the output as if it were an ordinary Single Poll Double Throw (SPDT) switch.  Note, with regard to processors, an ordinary switch may need to de-bounced.  This depends on how the state of the switch is used.

to my understanding that's basically it. there is a relay inside the sensor and hte sensor just sets off the relay. i should be able to run 5v to it and just listen for that 5v to go to pin2

When connected to 5V the input to the arduino should be 5V.  But what is the input when not connected?  When the relay is open?  Ah, this is where you need a pull down resistor.  So as not to allow the arduino's input to float to an unknown voltage.

yes possibly. the arduino is supposed to have that built in. maybe my off brand arduino doesn't. I had to build my own pull down. but the instructions were pretty clear. just grounding a resistor. When i get my hands on the sensor ill be able to tell if itl work or need the resistor.

Truth is, many embedded processors have the ability to program in a pull up or even a pull down resistor.  I didn't want to go that route as explaining the details requires more than what we do here in a stackexchange comment section.  In addition, these pull up / down resistors are usually weak by design and may not exist on all pins.  Finally, by using a SPDT switch that breaks before makes (most do) and making sure the wiring is correct (we don't want to short out the power supply!!) we can force the digital input both high and low w/o using a resistor.  But do double check the wiring!!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Intermittent jittering servo
I'm controlling a Hitech HS-625MG servo from a 10k slider via a Nano. For a while the motion tracks the slider position even when moved quickly.
Then, for no reason I can find, it will stop following smoothly & only move in jittery steps & then move as expected again!
The code is cut & paste from the pot-servo example..
#include <Servo.h>

Servo myservo_1;  // create servo object to control a servo

int potpin_1 = A0;  // analog pin used to connect the potentiometer

int val_1;    // variable to read the value from the analog pin

void setup() {
  myservo_1.attach(7);  // attaches the servo on pin 9 to the servo object
}

void loop() {
  val_1 = analogRead(potpin_1);             // reads the value of the potentiometer (value between 0 and 1023)

  val_1 = map(val_1, 0, 1023, 0, 180);      // scale it to use it with the servo (value between 0 and 180)

  myservo_1.write(val_1);                   // sets the servo position according to the scaled value

  delay(15);                                // waits for the servo to get there
                                            // have tried values ranging from 5 to 25 same behaviour
}

YouTube vid of the behaviour
Anyone seen this kinda thing before?
EDIT: That is the full code listing & here's the circuit diagram, the same as the knob example frome the Servo examples page except the servo is not being powered by the Nano but is sharing the same power supply. (sorry not next to it at the moment)

We see it all the time. Probably not enough power for the servo motor. Please update your question and show your full sketch and tell how the potentiometer and servo motor is connected or show a schematic.

@Jot have edited the OP. Would a cap across the wiper and ground help?

If you are between working and not-working, then a capacitor might help. I prefer to fix the cause. That the not a full sketch, the loop function is missing a '}' at the end. Did you connect the arduino gnd to the power supply gnd? What kind of power supply is it? 5v 1a ? Please tell us what kind of servo motor it is, can you also give a link to it? A week or so ago, someone had a servo motor that could request more than 2a, it didn't work and a small servo motor was okay.

edited the code. Arduino, wiper & servo (hitec HAS625MG) share the same power rails, V+ = 12v

That is not a 12v servo motor. That servo motor needs 4.8 to 6v, as most servo motors do. That servo motor is fast and has power, and its stall current is 2.5 amps according to this: https://hitecrcd.com/products/servos/sport-servos/analog-sport-servos/hs-625mg/product therefor you need a power supply of 5v 2.5a for the servo motor. This is indeed a power issue that we see all the time.

I feel like an idiot, thankyou its all working now. It might be worth putting this down as a proper answer and using it as a refernece post for when this issue is asked about again?

A servo motor requires a lot of current.
Many have problems when using a servo motor. Sometimes it works a few seconds and then it starts to jitter or it moves a little and then stops or it does nothing and makes a small click noise.
The problem is that servo motors requires a lot of current. Even the small servo motors can require a peak current of 0.5 A. Larger, stronger, and faster servo motors can easily request a peak of a few Amps.
To find the maximum current for the servo motor, look at the stall current of the servo motor.
When a servo starts to turn, it needs a short peak current. That peak current can be near the stall current.
Don't buy a "strong" and "fast" servo motor.
That may sound appealing, but it is better to start with a humble and timid servo motor.
The servo motors have a DC motor with gears inside. Because of the gears it is already strong.
Use a power supply of 5V with enough Amps to be able to supply the stall current of the servo motor.
Use that power supply to power the servo motor (the red wire).
Connect the GND of the power supply to the GND of the servo motor (the black wire) and the GND of the Arduino board.
The 5V pin of the Arduino board can not supply enough power for a servo motor.
It is in the official Arduino examples, but many run into problems with not enough power.


text:
threshold voltage level and blinking problem
I am using arduino pro mini 3.3 V,8 Mhz.vcc of the this arduino is coming from AC-DC converter with regulator 3.3 volt.I am listening analog data from voltage divider approximately 250 milivolts.
I want to basically,If analog voltage will reach 250 milivolts then led on.Otherwise led off.I am using avarage 100 ms for voltage data.
But,I have seen led on blinking for threshold voltage.Such as,The voltage level is changing 248-254.led on,led of,led on...I don't want to blink.
What can you do in such situations?Voltage level and slightly variable voltage?
Thanks

The internal reference of 1.1v might be better as reference. For the blinking at the threshold, add hysteresis to your sketch.

What is the sensetive ac voltage stabilization method coming from
  voltage divider and it contains noise filter capacitor and take
  avarage?

Calculating an average by using 3/4 of the current average and 1/4 of the new measurement (exponential average) works well for me in a lot of situations. You can adjust the constants as you see fit, as long as they add to 1.0. I use powers of 2 and shifting for maximum performance:
// Exp. average: 3/4 old avg + 1/4 new data, with rounding
int16_t xpavg(int16_t newdat, int16_t avg){

   // (3 * avg + 1 * newdat) / 4
   return( (((avg<<2) - avg + newdat) + 2) >> 2 );
}

As Jot mentioned in his comment you can write code to follow a hysteresis. This means, that the LED is only turned on, when the analog value is a bit above the threshold, and only turned off, when it's a bit below the threshold. You can see this behavior in Schmitt Triggers, which work that way (though they are getting the hysteresis via a corresponding electrical circuit, not through code). You wrote, your voltage readings are noisy in the range of about 10mV.
Depending on how your current code is structured, you can reach this goal by using if statements:
if( value > threshold + margin ){
    digitalWrite(LED_pin, HIGH);
} else if( value < threshold - margin ) {
    digitalWrite(LED_pin, LOW);
}

You can choose a good value for margin (this depends on the desired behavior). Start with a margin of 7mV (which should filter out the noise of 10mV) and change it, until it works as intended.

Thanks for answer.I want to ask twto question.
1)If margin coming slightly larger,what can be done?If we apply same think,the range will grow.
2)What is the sensetive ac voltage stabilization method coming from voltage divider and it contains noise filter capacitor and take avarage?I am searching software method?

Sorry, I don't understand your questions (seems, that english is not your native language). The margin would be a constant, which you choose depending on the noise of your analog signal and the desired behavior. You can even define 2 margins for turning on and off at different margins. And what do you mean with the voltage divider and capacitor? You wrote, that you have a signal, that is changing between 248mV and 254mV (noise). What I proposed is a software method.

I am sorry for grammar mistakes.If noise range of the voltage datas 248 mv-258mv then you are true.I can add margin to my code.But,such as If noise range of the voltage datas 190mv-300mv,What can i do?If I add to margin my code,it will be a waste of time for the switch threshold voltage level.Thanks.

If my proposal is too much of a compromise, you only can try to reduce the noise of your signal. Reducing noise in an analog signal can be a complex thing. You can add a low pass filter (combination of capacitor and resistor). You can try to isolate the electronics from the source of the noise (can be a running motor, a power line nearby, etc...). You can try to convert the pure analog signal to a differential signal for the distance from the source to the Arduinos pins (noise gets induced in both lines the same). Difficult to answer, without knowing more about the appliance.


text:
Arduino MEGA with RTOS
I've been coding for FreeRTOS on the MEGA 2560, and was using some LEDs to determine activity per task by toggling each individual LED each time through the task, and monitoring the time using a scope on the LED pin(s). All worked fine until I added the code for the last task.
Only the LED for the last task showed activity, and I assumed I screwed up in the new code, and spent a full day re-doing the code and troubleshooting. Well, it turns out that the code was working just fine. The problem appears to be RTOS is not manipulating the appropriate LED for each task, but using some other pin. The same configuration but with simple test code works fine.
I've tried just about everything I know, with negative results. The 3 tasks are running OK (I still need to do much more testing) so it's not like there is an issue with stack overflow, plus I decided to make ALL the variables as global variables to minimze stack use, and possible conflicts with the variables, which were the same on two of the original programs. I'm using about 600 bytes of RAM for those variables, and have tons of spece in the MEGA in all aspects. The code only uses 14K of the 256K available.
So, I'm officially stumped, and I assume that there's a problem with the task switching somehow, but I'd expect the code to crash eventually if that were the case, but it runs for hours and hours.
Does anyone have any real experience with FreeRTOS that have experienced similar issues related to simple digitalRead and/or digitalWrite problems similar to what I'm seeing?

Just had an idea.....looking at the code size, I realized that it would fit on an UNO. I can't use the UNO for the project because I needs many more pins than it has, but running the code on a different and smalled piece of HW could show some results, either it works better or has a stack size issue.

Well, it runs the same, and doesn't crash, so other than that the problem isn't MEGA specific, no useful data was obtained.

Well, DUMBO (that would be me) found the problem, and it was a real bonehead error.
When I applied the stand-alone code to the RTOS environment, I did not reallocate pin assignments, so there were multiple I/O events writing to the same port that was using the Test LEDs.
I knew that FreeRTOS couldn't be that bad, as if the I/O went to the incorrect pins, the code would be useless.
So, don't take shortcuts, even if you're not ready to complete all segments of the project. Check for duplicate definitions or they will bite you in the ass.......


text:
How to find the difference between two timestamps
I'm using this time library to access the properties of unix timestamps like hours / minutes / etc. What I want to do is get the current time, and an estimated arrival time, and find the difference between them in minutes.
Here's my code: (My estimated time is coming from an API as an INT)
time_t timeEstimated = timeInt;
time_t timeNow = now();

But how do I find the difference between these two timestamps in minutes? I'd like to try and avoid all of the conditionals / math that would come with converting to hours / minutes / seconds / dates and subtracting each component if possible.

Unix timestamps are just a count of seconds since a standard
origin (1970.0 UTC), thus a simple subtraction, followed by a
conversion from seconds to minutes:
float minutes_remaining = (timeEstimated - timeNow) / 60.0;


text:
Why does it skip the first index - shift register issue
So, I wrote this code myself and I'm a noob on the issue. I did get my code working, but cannot understand why it has to be the way it is.
int counter;
int ledValue[] = {
  1,0,1,1,1,1,1,1
};

void setup()
{
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
}

void loop(){
  digitalWrite(5, HIGH);
  for (counter = 8; counter >= 0; --counter) {
  // turn the pin on:
    digitalWrite(2, ledValue[counter - 1]);
    digitalWrite(3, 1);
    digitalWrite(4, 1);
    digitalWrite(2, 0);
    digitalWrite(3, 0);
    digitalWrite(4, 0);
    delay(100);
  // turn the pin off:
  }
  delay(1000);
  digitalWrite(5, LOW);
}

Now, I am puzzled by both the counter = 8 and the [counter -1]. To me it looks like I am loop-ing this 9 times, though I only got 8 items in the array
A. If I make it counter = 7 and [counter -1] my output is 10111110. This loops 8 times (I think), but gives me 7 leds.
B. If I make it counter = 7 and [counter] my output is 01111110. This loops 8 times (I think), gives me 7 leds but also an extra led burning up front, hence braking the prescribed pattern.
C. If I make it counter = 7; counter >= -1 my output is 10111111.(as it should). But how can it be -1?
My guess is that I am doing something wrong at the beginnen, but I can't find what. Tried several tutorials and explanations, but it still puzzles me why the correct running code is that way.
Just to be sure, I am familiar with an array being 0-indexed.
Please helpt me understand my code  ;-)
Edit:
Small addition:

pin 2 is connected to ShiftRegister pin 14
pin 3 is connected to ShiftRegister pin 12
pin 4 is connected to ShiftRegister pin 11
pin 5 is connected to ShiftRegister pin 10

Thanks for the feedback. My lack of understanding does not concern the loop or array. What I can't get my head around is why the shift registers outputs the loop as it does. Would a picture of the setup help?

What do you mean by "expected output"? Most of the LEDs are set to fixed values, so are you saying that the LED on pin 2 should show the pattern 10111111? Since you are going through the array backwards (8 down to 0) I would expect to see 11111101.

But how can it be -1? - an integer can be -1. What do you mean by "how can it be"?

@NickGammon; I meant; How can the index of an array be -1? Since it does work if it counts until (including) -1. And expected output; because with the shift register, the first value put in, is the last value in the row. So, if I want it to replicate a given pattern in LED's I should process backwards. That is, for as far as I do understand shift registers now.

The problem is in the directions the ShiftRegister gets.
This way, it works
...
digitalWrite(2, ledValue[counter - 1]);
digitalWrite(4, 1); //clock pin high
digitalWrite(4, 0);
digitalWrite(3, 1); //latch pin high
digitalWrite(3, 0);
digitalWrite(2, 0);
...

The clock and latch have to be low again before switching the signal back to 0.
In the upgraded version I put the clock and latch in a function.

The correct way to loop through an array of length 8 is:
for (int counter = 0; counter < 8; ++counter) {
    digitalWrite(2, ledValue[counter]);
    // ...
}

If you want to loop through the array backwards, then:
for (int counter = 7; counter >= 0; --counter) {
    digitalWrite(2, ledValue[counter]);
    // ...
}

This loop will visit, in this order, the indices 7, 6, 5... 1 and 0.
For extra clarity, you could define a constant that holds the length of
the array, then replace the numbers 8 and 7 above by VALUES_COUNT
and VALUES_COUNT-1 respectively.
You wrote:

If I make it [...] my output is [...]

Not sure what you mean by that. This code should not have much visible
output, as the LEDs are turned off only microseconds after being turned
on. How do you determine what the program's "output" is? Maybe there is
an issue with the way you are trying to diagnose the problem.

S/he has a delay in the loop, Edgar.

@NickGammon: I saw that delay but, in order to see the pattern, another one would be needed right before digitalWrite(2, 0);.

Oh yeah, good point.

Make the problem as small as possible. For example:
void setup() {
  Serial.begin(9600);

  for( int i=8; i>=0; --i) {
    Serial.println(i);
  }
}

void loop() {
}

The output is:
8
7
6
5
4
3
2
1
0

Those are indeed nine numbers. An array in c++ starts at zero. Your array is from ledValue[0] up to (inclusive) ledValue[7]. See the answer by Edgar Bonet how the for-statements are used.


text:
Program is working wrong while melody playing
My robot working fine but when I added buzzer and melody into code then is something wrong. Melody is playing when accelerometer is activated but rest of the code need to wait to end of melody. I want to play melody in background when program works. How to do it? There is my code:
#include <RedBot.h>
#include <RedBotSoftwareSerial.h>
RedBotAccel accel;
RedBotMotors motors;
int CM;
long CZAS;
bool started = false;
const int buzzer = A0;

int shortTone = 80;
int longTone = 200;
int standardDelay = 50;
int delayBetweenBars = 50;

void setup()
{
   Serial.begin(9600);
   accel.enableBump();
   accel.setBumpThresh(150);
   pinMode(A2, OUTPUT);  //Trig
   pinMode(A3, INPUT);   //Echo
   pinMode(buzzer, OUTPUT);  //Buzzer
}

void pomiar_odleglosci()
{
   digitalWrite(A2, HIGH);
   delayMicroseconds(10);
   digitalWrite(A2, LOW);
   CZAS = pulseIn(A3, HIGH);
   CM = CZAS / 58;
}

void loop(){

   while (!accel.checkBump() && !started) delay(100);
   started = true;

   if(started = true)
   {   DarudeSandstorm();
   }

   pomiar_odleglosci();
   Serial.print("Odleglosc: ");
   Serial.print(CM);
   Serial.println(" cm");

   if(CM>10)
   {
      motors.drive(100);
   }
   else
   {
      motors.drive(-100);
      delay(400);
      motors.stop();

      delay(400);

      motors.rightMotor(100);
      delay(700);
      motors.stop();

      motors.drive(100);
   }

}
//melody

Define wrong. Also, links to code are not wanted. Post your code in your question and format it correctly. Tell us what you expect to happen, and what actually happens.

Where does the melody play? At the DarudeSandstorm function? Where is it defined? Please provide a link for the red robot includes, so that we can check them.

This is all code: https://pastebin.com/aihBQZT1 , and this is library for redbot.h: https://github.com/sparkfun/SparkFun_RedBot_Arduino_Library/blob/master/src/RedBot.h

You are using delay() in many parts of your code, which makes it very trick. I see a couple of possibilities here:
1 - if you have extra time and patience, get rid of all delays and find your around it counting millis() or some similar technique.
2 - if you have some extra bucks, get another controller just to play the melody, an ATtiny85 should be cheap and practical for this.
There is also the super-lazy, almost-no-work-at-all, relatively cheap solution: use a small media/MP3 player module, which also would allow you to have more than one melody and eventually adtiional noises.

So for example how to change delay(1000); to millis?

look at the BlinkWithoutDelay example code in the Arduino IDE


text:
Troubles with APDS-9900 proximity
So I've received few APDS-9900 sensors and found out, there's no library for it (9960 type is supported only). I took that library and device documentation, and created similar library.
Ambient light detection (without interrupts) works well, but there's trouble with proximity detection:
The "Auto-Increment protocol transaction" which should be initiated by writing (0xA0 | reg) to command register, does not work and returns two zeros instead of two bytes. See page 18 of the PDF docs (in repo).
0xE0 (Repeated Byte protocol transaction) returns at least second byte (seems so) of the ADC proximity integration result registers.
https://github.com/suculent/APDS9900_Ambient_Light_and_Proximity_Sensor

Do you have a 1.8v i2c bus? The function wireReadDataWord reads four bytes and the first two are ignored, why?

The APDS-9900 seems to have 1.8V I2C bus and I have it connected to 3.3V ESP8266. I don't have level-shifter, so I guess I could do that with some additional resistance. Single-byte transactions seems to work well.
As of the ignored bytes... first byte returns 0, second returns 10, attempt third returns 40 and the fourth seems to return mostly > 768, one of the ADC integration result registers (high or low, hard to tell, seems like low given the jitter...)

Is the function wireReadDataWord random code and you take two bytes and hope that those are the bytes that you need? Can you replace the contents of wireReadDataWord with two wireReadDataByte?

wireReadDataByte returns always zeroes from PDATAL and PDATAH registers.
There's additional issue, where the proximity data is a 2-byte value, that is constantly updated using the ALS proximity integrator. The wireReadDataWord should solve this by explicitly requesting multi-byte transaction that should safely provide both bytes from the same integration cycle.
This does not happen with the luminance, which is also a 2-byte. I'm seriously thinking about ditching those APDU-9900 and replace with more expensive but more predictable APDU-9960.

I think that is a good choice, because of the 1.8v i2c interface. Perhaps something is damaged with 3.3v. You also need to fix the software issue when requesting two bytes. It seems that you have made a workaround in the function wireReadDataWord, but that workaround is wrong anyway. While waiting for a new sensor, you could check every return value of Wire.requestFrom to see if you got the same number of bytes that you requested.

The workarond by fetching 2-bytes twice is more a debugging work in progress. I've already checked the return values... I suppose the problem will be in 1.8V I2C which will fail on multi-byte transaction attempt.


text:
Setting Fuse Bits From Arduino IDE?
I've come to understand fuse bits in the last few weeks. I'm working on a bitbanging project on an Arduino Pro Micro, and the signals I'm working with are around 30uS each. For this reason, I think I'll need to unset the CKDIV8 to unlock the full 16MHz speed of my micro controller.
Regardless, I can't figure out how to even do that. Is it possible to modify fuse bits through the Arduino IDE? If so, where?
The only other info I've found on this subject so far is that I can do it by chaining two micro controllers together, but at that point we're getting into application specific stuff and I'm nervous to play with the fuse bits by myself until after I've followed a step-by-step guide. I'd hate to, say, erase the bootloader.

There are 8MHz pro micro boards and there are 16MHz pro micro boards. The difference is a different resonator or crystal (and an other voltage regulator). None of them have the CKDIV8 fuse set. I'm curious, what is your project?

I'm (for the last 12 months) trying to capture and interpret messages sent by the head unit of my car's stereo. It uses AVCLAN. My intention is to capture specific button presses so that I can interact with my phone over bluetooth through the buttons already in my car. The bluetooth component I'm using is a BK8000L.

The Arduinos are shipped without CKDIV8 enabled.
New chips without bootloader and the chips after chip erase are having CKDIV8 active.
And you can change the clock prescaller in software, but it mess up everything that depends on it. Delays, serial baud rate and USB as well.
However fuse setings are stored in boards.txt definition file. None of the bootloaders would work with default settings. They are usually compiled for 16MHz @5V and  8MHz @3.3V with xtal or resonator. But the custom boards may have much more options.


text:
ets Jan 8 2013,rst cause:4, boot mode:(1,7)
I am facing a issue with the ESP8266-01 as the following below:
chksum 0x42
csum 0x42
~ld
ets Jan 8 2013,rst cause:4, boot mode:(1,0)
wdt reset
Anyone has the solution please help!!
#include <LiquidCrystal.h>  //Load liquid Crystal Library
LiquidCrystal LCD(12, 11, 5, 4, 3, 2);  //Create Liquid Crystal Object called LCD
#include <ESP8266WiFi.h>

const char* ssid     = "your-ssid";
const char* password = "your-password";
const char* host = "your-localhost";

#define in 7
#define out 8
#define trigPin 10
#define echoPin 13
#define relay 2
#define led 6            //red color
#define led2 A0           //yellow color
#define led3 9           //green color

int count = 0;

int distanceCm;
long duration;

void IN()
{
    count++;
    LCD.clear();
    LCD.print("Number of Item:");
    LCD.setCursor(0,1);
    LCD.print(count);
    delay(10);
    LCD.setCursor(3,1);
    LCD.print(distanceCm);
    delay(10);
    LCD.setCursor(6,1);
    LCD.print(" cm");
    if(distanceCm <= 3){
     delayMicroseconds(10);
     LCD.setCursor(10,1);
     LCD.print("Full");
     digitalWrite(led, HIGH);
  }else{
    digitalWrite(led, LOW);
  }

  if(distanceCm > 3 && distanceCm <= 5){
     delayMicroseconds(10);
     LCD.setCursor(10,1);
     LCD.print("Enable");
     digitalWrite(led2, HIGH);
  } else{
    digitalWrite(led2, LOW);
  }

  if(distanceCm > 5){
     delayMicroseconds(10);
     LCD.setCursor(10,1);
     LCD.print("Empty");
     digitalWrite(led3, HIGH);
  } else {
    digitalWrite(led3, LOW);
  }
  delay(500);
}

void OUT()
{
  count--;
  LCD.clear();
  LCD.print("Number of Item:");
  LCD.setCursor(0,1);
  LCD.print(count);
  delay(10);
  LCD.setCursor(3,1);
  LCD.print(distanceCm);
  LCD.setCursor(6,1);
  LCD.print(" cm");
   if(distanceCm <= 3){
     delayMicroseconds(10);
     LCD.setCursor(10,1);
     LCD.print("Full");
     digitalWrite(led, HIGH);
  }else{
    digitalWrite(led, LOW);
  }

  if(distanceCm > 3 && distanceCm <= 5){
     delayMicroseconds(10);
     LCD.setCursor(10,1);
     LCD.print("Enable");
     digitalWrite(led2, HIGH);
  } else{
    digitalWrite(led2, LOW);
  }

  if(distanceCm > 5){
     delayMicroseconds(10);
     LCD.setCursor(10,1);
     LCD.print("Empty");
     digitalWrite(led3, HIGH);
  } else {
    digitalWrite(led3, LOW);
  }
  delay(500);
}

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  delay(10);

  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);

  pinMode(led, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);

  LCD.begin(16,2);
  LCD.print("Item Counter");
  delay(2000);

  pinMode(in, INPUT);
  pinMode(out, INPUT);
  pinMode(relay, OUTPUT);

  LCD.clear();
  LCD.print("Item In Box:");
  LCD.setCursor(0,1);
  LCD.print(count);

  // We start by connecting to a WiFi network

  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
     // ESP.wdtFeed();
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

 // ESP.restart();
}

int value = 0;

void loop() {

 delay(0);
 delay(5000);
  ++value;

  digitalWrite(trigPin, LOW);
  delayMicroseconds(10);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(50);
  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH);
  distanceCm = duration * 0.034/2;

//******************************************************//
//IR Sensor Counting Object
  if(digitalRead(in))
  IN();
  if(digitalRead(out))
  OUT();

  if(count<=0)
  {
    LCD.clear();
    digitalWrite(relay, LOW);
    LCD.clear();
    LCD.print("No Item in box");
    LCD.setCursor(0,1);
    LCD.print("box is empty");
    delay(200);
  }
   else{
    digitalWrite(relay, HIGH);
   }

  Serial.print("connecting to ");
  Serial.println(host);

  // Use WiFiClient class to create TCP connections
  WiFiClient client;
  const int httpPort = 8095;
  if (!client.connect(host, httpPort)) {
    Serial.println("connection failed");
    return;
  }
  if(WiFi.status() != WL_CONNECTED){
    WiFi.begin(ssid,password);
    while (WiFi.status()!= WL_CONNECTED)
    {
      Serial.println("Waiting for connection");
      delay(0);
    }
  }

  String IRCount, myDistance;
  IRCount = String(count);
  myDistance = String(distanceCm);
  // We now create a URI for the request
  String url = "/Registration/write_data.php";
  url += "?item=";
  url += IRCount;
  url += "&distance=";
  url += myDistance;

  Serial.print("Requesting URL: ");
  Serial.println(url);

  // This will send the request to the server
  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "Connection: close\r\n\r\n");
  int timeout = millis() + 5000;
  while (client.available() == 0) {
    if (timeout - millis() < 0) {
      Serial.println(">>> Client Timeout !");
      client.stop();
      return;
    }
  }

  // Read all the lines of the reply from server and print them to Serial
  while(client.available()){
    String line = client.readStringUntil('\r');
    Serial.print(line);
  }

  Serial.println();
  Serial.println("closing connection");
  delay(0);
}

it is a watchdog reset. what is flashed in the esp8266?

@Juraj Flash Size: 1M(512K SPIFFS) flash Node: DIO

i tried all the flash size already but the error still there

that is not what I asked

Sorry... i don't understand what you mean flashed in the esp8266

GPIO 0  pins that i using it in the esp8266-01

what firmware or sketch is flashed? it is a software error the reset, so tell us what did you upload

I not sure what is the error going on... but i use the WiFiClient example to upload the dummy data to the php localhost webpage and it works but when i use the below following text file to upload the data to the webpage and it shows the above error ESP8266_upload.txt

esp-01 has 4 io pins: RX, TX, io 0 and io 2. other pins are not accessible. io 6 to io 11 are wired to on-board flash memory and can't be used.
what are you thinking by using other pins then 0 and 2? how did you wire those sensors and leds to esp-01?

Because for the sensors and leds... I want pass the sensors data to my server. So is it possible to save my sensor data into the MySQL database and display it on my webpage.   I wired those wires on the Arduino UNO board

Do you have any ideas to pass the sensor data to the PHP localhost server webpage? or is it required to change another wifi receiver to pass the data to my localhost webpage?

My issue is the same as this forum before https://arduino.stackexchange.com/questions/48234/getting-error-ets-jan-8-2013-rst-cause4-boot-mode1-6-wdt-reset But i don't see any solution for this

there is no magic that would read Uno pins in connected esp8266. you could use Firmata with Firmata Master esp8266 library but simpler is to write two sketches

but the other sketches connect to the main sketches?

the problem you linked is different. there is no Uno. sensors are wired to esp8266 dev board

i no write the esp8266 connection in the source code... i just write the sensors that connect to the UNO board... i not sure that is correct or not

you need sketch in Uno and sketch or firmware in esp8266

you mean that i need to create two sketch which is uno boards code and the esp01 source code? Sorry... i totally no idea how to do it

step by step. first create and debug a sketch for Uno without networking with output to Serial Monitor.

or buy an esp8266 dev board like Wemos/Lolin or NodeMcu and attach the sensors to it.


text:
What bootloader is present by default on Arduino Uno?
Or where can i find information of default bootloaders present on each Arduino board. All I could look up was it could be one of these bootloaders on the atmega chip :-
.Atmega
.Atmega8
.bt
.caterina
.caterina-Arduino_Robot
.caterina-LilyPadUSB
.gemma
.lilypad
.optiboot
.stk500v2
This was the list present in the folder ~\Arduino\hardware\arduino\avr\bootloaders.

It is defined in the file "boards.txt" (arduino-1.8.7\hardware\arduino\avr\boards.txt).
For example the Arduino Uno is called "Arduino/Genuino Uno" and it has the bootloader: uno.bootloader.file=optiboot/optiboot_atmega328.hex
You can find that hex file in the folder arduino-1.8.7\hardware\arduino\avr\bootloaders\optiboot.
The official Arduino boards are shipped with the newest bootloaders.
Sometimes the bootloaders are improved or changed. That is mentioned in the Release Notes.
For example the latest change to a bootloader is that the Arduino Nano has now the same optiboot bootloader as the Arduino Uno.
When buying a Arduino clone board, anything is possible.
Some companies make there own Arduino-compatible boards with their own bootloaders.

Exactly what I was looking for. Thanks :)

Optiboot Bootloader for Arduino and Atmel AVR
https://github.com/Optiboot/optiboot/wiki
Take a look at this information.


text:
Arduino RGB LED not working all the time?
I was creating an RGB LED System with one 1 RGB LED controlled by an IR Remote. I wanted to assign a button to trigger a mood-light which cycles through the rainbow, and that works fine. But when I try to make a mode where you can change RGB Values directly, it doesn't work properly. I assigned numbers on the remote to switch the colour that you are changing (e.g 1 is red, 2 is green etc.), and the volume controls how much light is coming but when I have two colors with positive values it only displays one. I have no idea why because the moodlight works fine and even transitions smoothly.
//www.elegoo.com
//2016.12.9

#include "IRremote.h"

// Define Pins
int BLUE = 3;
int GREEN = 5;
int RED = 6;

int addValue = 10;

int receiver = 11; // Signal Pin of IR receiver to Arduino Digital Pin 11

int blueValue = 0;
int greenValue = 0;
int redValue = 0;

bool isMoodLightOn = false;
bool isBlueModeOn = false;
bool isGreenModeOn = false;
bool isRedModeOn = true;

/*-----( Declare objects )-----*/
IRrecv irrecv(receiver);     // create instance of 'irrecv'
decode_results results;      // create instance of 'decode_results'

/*-----( Function )-----*/
void translateIR() // takes action based on IR code received

// describing Remote IR codes

{

  switch(results.value)

  {
  case 0xFFA25D: Serial.println("POWER"); break;
  case 0xFFE21D: Serial.println("FUNC/STOP"); break;
  case 0xFF629D: Serial.println("VOL+"); break;
  case 0xFF22DD: Serial.println("FAST BACK"); break;
  case 0xFF02FD: Serial.println("PLAY/PAUSE");
                 isMoodLightOn = !isMoodLightOn;
                 if (isMoodLightOn == false) {
                  isBlueModeOn = true;
                  isGreenModeOn = false;
                  isRedModeOn = false;

                  setColor(redValue, greenValue, blueValue);
                 } else {
                  isBlueModeOn = false;
                  isGreenModeOn = false;
                  isRedModeOn = false;
                 }
                 break;
  case 0xFFC23D: Serial.println("FAST FORWARD"); break;
  case 0xFFE01F: Serial.println("DOWN");
                 if (isBlueModeOn) {
                  if (blueValue > 0) {
                    blueValue = blueValue - addValue;
                    Serial.println("Red: " + String(redValue) + "Green: " + String(greenValue) + "Blue: " + String(blueValue));
                    setColor(redValue, greenValue, blueValue);
                  }
                 }
                 if (isGreenModeOn) {
                  if (greenValue > 0) {
                    greenValue = greenValue - addValue;
                    Serial.println("Red: " + String(redValue) + "Green: " + String(greenValue) + "Blue: " + String(blueValue));
                    setColor(redValue, greenValue, blueValue);
                  }
                 }
                 if (isRedModeOn) {
                  if (redValue > 0) {
                    redValue = redValue - addValue;
                    Serial.println("Red: " + String(redValue) + "Green: " + String(greenValue) + "Blue: " + String(blueValue));
                    setColor(redValue, greenValue, blueValue);
                  }
                 }
                 break;
  case 0xFFA857: Serial.println("VOL-"); break;
  case 0xFF906F: Serial.println("UP");
                 if (isBlueModeOn) {
                  if (blueValue < 100) {
                    blueValue = blueValue + addValue;
                    Serial.println("Red: " + String(redValue) + "Green: " + String(greenValue) + "Blue: " + String(blueValue));
                    setColor(redValue, greenValue, blueValue);
                  }
                 }
                 if (isGreenModeOn) {
                  if (greenValue < 100) {
                    greenValue = greenValue + addValue;
                    Serial.println("Red: " + String(redValue) + "Green: " + String(greenValue) + "Blue: " + String(blueValue));
                    setColor(redValue, greenValue, blueValue);
                  }
                 }
                 if (isRedModeOn) {
                  if (redValue < 100) {
                    redValue = redValue + addValue;
                    Serial.println("Red: " + String(redValue) + "Green: " + String(greenValue) + "Blue: " + String(blueValue));
                    setColor(redValue, greenValue, blueValue);
                  }
                 }
                 break;
  case 0xFF9867: Serial.println("EQ"); break;
  case 0xFFB04F: Serial.println("ST/REPT"); break;
  case 0xFF6897: Serial.println("0"); break;
  case 0xFF30CF: Serial.println("1"); isRedModeOn = true; isGreenModeOn = false; isBlueModeOn = false; break;
  case 0xFF18E7: Serial.println("2"); isRedModeOn = false; isGreenModeOn = true; isBlueModeOn = false; break;
  case 0xFF7A85: Serial.println("3"); isRedModeOn = false; isGreenModeOn = false; isBlueModeOn = true; break;
  case 0xFF10EF: Serial.println("4"); break;
  case 0xFF38C7: Serial.println("5"); break;
  case 0xFF5AA5: Serial.println("6"); break;
  case 0xFF42BD: Serial.println("7"); break;
  case 0xFF4AB5: Serial.println("8"); break;
  case 0xFF52AD: Serial.println("9"); break;
  case 0xFFFFFFFF: Serial.println("REPEAT"); break;

  default:
    Serial.println(" other button   ");

  }// End Case

  delay(500); // Do not get immediate repeat

} //END translateIR
void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  Serial.begin(9600);
  Serial.println("IR Receiver Button Decode");

  pinMode(RED, OUTPUT);
  pinMode(GREEN, OUTPUT);
  pinMode(BLUE, OUTPUT);

  setColor(redValue, greenValue, blueValue);

  isBlueModeOn = true;
  isGreenModeOn = false;
  isRedModeOn = false;

  irrecv.enableIRIn(); // Start the receiver

}/*--(end setup )---*/

void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
  setColor(redValue, greenValue, blueValue);

  if (irrecv.decode(&results)) // have we received an IR signal?

  {
    translateIR();
    irrecv.resume(); // receive the next value
  }

  setColor(redValue, greenValue, blueValue);

  if (isMoodLightOn == true) {
      int delayTime = 10; // fading time between colors

      redValue = 255; // choose a value between 1 and 255 to change the color.
      greenValue = 0;
      blueValue = 0;

      // this is unnecessary as we've either turned on RED in SETUP
      // or in the previous loop ... regardless, this turns RED off
      // analogWrite(RED, 0);
      // delay(1000);

      for(int i = 0; i < 255; i += 1) // fades out red bring green full when i=255
      {
        redValue -= 1;
        greenValue += 1;
        // The following was reversed, counting in the wrong directions
        // analogWrite(RED, 255 - redValue);
        // analogWrite(GREEN, 255 - greenValue);
        setColor(redValue, greenValue, blueValue);
        delay(delayTime);
      }

      redValue = 0;
      greenValue = 255;
      blueValue = 0;

      for(int i = 0; i < 255; i += 1) // fades out green bring blue full when i=255
      {
        greenValue -= 1;
        blueValue += 1;
        // The following was reversed, counting in the wrong directions
        // analogWrite(GREEN, 255 - greenValue);
        // analogWrite(BLUE, 255 - blueValue);
        setColor(redValue, greenValue, blueValue);
        delay(delayTime);
      }

      redValue = 0;
      greenValue = 0;
      blueValue = 255;

      for(int i = 0; i < 255; i += 1) // fades out blue bring red full when i=255
      {
        // The following code has been rearranged to match the other two similar sections
        blueValue -= 1;
        redValue += 1;
        // The following was reversed, counting in the wrong directions
        // analogWrite(BLUE, 255 - blueValue);
        // analogWrite(RED, 255 - redValue);
        setColor(redValue, greenValue, blueValue);
        delay(delayTime);
      }
  }
  setColor(redValue, greenValue, blueValue);
}/* --(end main loop )-- */

void setColor(int red, int green, int blue) {
  analogWrite(BLUE, blue);
  analogWrite(GREEN, green);
  analogWrite(RED, red);
}

You are using setColor() twice inside your loop function outside of the moodlight code. When not in moodlight mode, this functions repeats rapidly, doing many analogWrites in a short time. This resets the PWM hardware everytime, effectively distorting the signal. Try to remove those 2 lines (you don't need them, since you are already setting the colors within translateIR() ). And you may want the code to be more responsive when in moodlight mode. Then you should restructure your code to be non-blocking, like in the BlinkWithoutDelay example of the Arduino IDE.

I will formulate my comment as a longer answer.
Inside your loop() function, you use setColor() twice, directly in the lowest level. When you are not in the moodlight mode, the whole if statement after it will not be executed, so there isn't much happening inside one iteration of the function and it will cycle through very fast, setting the colors again and again.
THe setColor() function only consists of calls to analogWrite(). It configures the Atmegas hardware, so that a PWM signal will be generated at the pin. For doing so, the corresponding hardware registers (for one of the timers). This also let's the PWM wave start again. If you are doing this very fast (meaning in the range of the PWM signal itself or faster), you will destroy the complete PWM waveform by starting over and over again. Image it as if you wait press the replay button on your music player again and again very fast. You would be able to recognize the music, as it is chopped up due to the replaying.
The aforementioned two lines are not necessary either, since the output of the PWM wave is done by hardware and does not require any code after it has been turned on by analogWrite(). So you can simply delete those two lines.


text:
Power on reset with arduino uno can never happen. Can this be fixed?
When an Arduino Uno is powered on, the USB chip's DTR output pin may (is, in fact) low for a while.  This means that the capacitor C5 is connected from the 328p reset pin to ground.  Thus, when power is applied, the reset pin is held low for 10's of milliseconds after power up (while C5 charges) .
Thus, when the 328p starts, the reason for reset (the MCU register) always is "external reset", not "power on reset", even when  power turns on.
This can be fixed by removing C5, or opening the "reset en" jumper, but then the chip is never reset by the falling of DTR,...that is, bootloading is disabled.
Is there a solution that allows POR and external reset for the bootloader?
Thanks!

Don't use an Arduino with a '328p.

The problem is not the 328p, but the DTR associated reset circuit.  If for example, the USB chip powered up with its pins HIGH , the capacitor would not have to charge on power up.  Unfortunately, it looks as though the USB chip on the Uno powers up with its DTR pin low or tri-stated.  This causes the 328p to report that it received an "external reset", even on power up.

I know what the problem is. And the answer is to use an Arduino that doesn't use that chip. Choose one with an ATMega32U4. It doesn't have the DTR reset system.

I connect a 2n2222 with gnd pin and with res pin..
then if send 5v or HIGH pin from any pin by 1k resister arduino restarts...

User 58927: and in this way, you can reset the chip with an output command. However, the question is about the reset at power on of the Arduino being seen by chip as an “external reset”, rather than a “power on reset”.

See 'DTR-reset' circuit of Arduino Uno below.
After powering-on, when DTR is set low (because a sketch is coming in) the falling edge causes a negative pulse on the 328P's external reset pin of ca. 3 ms (see here). The width of this reset pulse is independent of the time that DTR stays low.
During powering-on the 328P's reset pin is low until the capacitor C5 is sufficiently charged. How long this takes depends mainly on the start-up behavior of Vcc. When DTR is low the capacitor will charge faster because RN2D (from capacitor C5 to ground) is bypassed.
But the main thing is that the power-on reset and the external reset have the same effect (see datasheet): when the rising voltage passes a certain threshold a timer is started and after it times out program execution starts at 0x0000 or at the Boot Reset Address (depending on the setting of the fuses). So, in the powering-on situation it makes no sense to differentiate between Power On Reset and External Reset.

Thank you for your answer. However, there is a reason to differentiate between Power on Reset and External Reset.  The Optiboot bootloader for Arduino will start the user immediately on POR.  On External reset, it will wait and look for bootloading data from the serial port.  Thus, with the current Arduino UNO hardware, this feature of "instant start" in the bootloader cannot be used.

I have answered my own question.
   I added a pull-UP resistor on the DTR line to VCC. Now capacitor C5 does not need to be charged up on power up: both sides of the capacitor start at VCC. Thus, the 328p recognizes a power-up as a "power-up reset", instead of an "external reset", and my sketch starts after 75-milliseconds or so on power up.
    Basically, my circuit is like PimV's diagram, but with the resistor RN2D to VCC, rather than to ground.  At least for the Uno, this fix seems to work.  I suspect this relies on the USB chip (mega16u) being in reset, and it's pins tri-stated, for a while after power up.

The RN2D pulldown is in the official schematic of the Arduino Uno Rev. 3.

Thanks. I Was not looking at the Rev 3. No wonder that node stays low on power up.


text:
Message Interpreter and Handler - How to store a function name in a struct?
For a project, I need to store an array of structures in PROGMEM. Array MessageTable[] will be composed of about ten struct InMessage elements. InMessage looks sort of like this:
struct AvcInMessage {
  MessageHandler  msgHandler;
  byte            dataSize;
  byte            data[8];
  char            description[20];
};

MessageHandler is not a data type... yet. I'm not really sure what data type to use. I want to be able to pick a message from the table and then call MessageTable[x].msgHandler() if that makes sense. I'm almost positive that this involves a pointer. Does someone here have an idea about what I'm looking for?

It might be I'm misunderstanding, but it looks like you want to store in PROGMEM an array of structs containing a reference to an object... That looks a little overkill: do you need to have different message handlers for each item in the array?

typedef void (*MessageHandler)(void);   // def messagehandler as pointer to func

struct AvcInMessage {
  MessageHandler  msgHandler;
  byte            dataSize;
  byte            data[8];
  char            description[20];
} InMessage[] = {
   {
      function1, <datasize>, {<byte0>, <byte1>, ..., }, "DescriptionHere"
   },
   // etc, for however many elements InMessage[] has.
};

The typedef defines a "pointer to function of void returning void" - fix up the argument count and types, and the return type to your needs. We're assuming each element's function has the same kind of arglist and return type. (Update: Sorry for the bug in my first iteration).
The next statement both defines the array of struct and initializes N of them. Provide an element count in the [] if you don't have a full set of initializers at compile time.

I think I understand what you mean, but it doesn't compile. I get expected unqualified-id before ')' token.

should that be typedef void (*MessageHandler)(void);

@JaromandaX has it (thank you!). I've updated my answer.

Confirming that the revised code works. Thank you very much, both.


text:
My Arduino Code but it will not compile, I cannot find what is wrong with it
I tried convining and LCD display, ultrasonic sensons, LEDs and an IR reciever code into one main code. Seperately they work fine, but when I put them toguether it gives me the following error: "Error compiling for board Arduino/Genuino Mega or Mega 2560."
The full error when I compile is :
Arduino: 1.8.5 (Mac OS X), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `__vector_13'
libraries/IRremote/IRremote.cpp.o (symbol from plugin):(.text+0x0): first defined here
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld: Disabling relaxation: it will not work with multiple definitions
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

https://drive.google.com/file/d/1YNOqxE0mAZJsQrV7_zMbRZ_jkur19rXt/view?usp=sharing

have you tried adding two at a time, rather than all or one approach - perhaps then you can determine which two don't co-exist (if all 6 conbinations of two at a time always works, then try 3 at a time) - at least, that's how I'd approach the issue if the error messages did not indicate the nature of the problem

You must post your code and you must also use proper formatting or your question will get closed very quickly

I attached the Code to the post

Your code should be pasted into the question, a link to the code might expire. If it is too long to include then it should be reduced down to a Minimal, Complete, and Verifiable example.

The processor has a fixed number of hardware devices such as timers and serial ports. If two libraries try to use the same device (in this case it looks like timer 2) then you won't be able to compile (let alone run) the code without resolving the issue. Possibly one of them could be altered to use a different timer, however this may not be trivial.
As an example, say you have one alarm clock, but you want to have it ring at both 5 a.m. and 7 a.m. You can't do that per se, you might need to get a second clock.

Looking at the source code in (install directory)/hardware/tools/avr/avr/include/avriomxx0_1.h I see that vector 13 is indeed for Timer 2;
/* Timer/Counter2 Compare Match A */
#define TIMER2_COMPA_vect_num   13
#define TIMER2_COMPA_vect       _VECTOR(13)
#define SIG_OUTPUT_COMPARE2A        _VECTOR(13)

It is Timer2 interrupt with tone() and IRremote, same as here: https://forum.arduino.cc/index.php?topic=120955.0

Judging by the datasheet _vector_13 is "Pin Change Interrupt Request 2" so it might be something to do with pin change interrupts. I didn't look at the code as it wasn't posted above.

When I use the library manager and install IRremote by shirriff and add a tone() call and compile it for the mega 2560, then I get a __vector_13 error. I don't know how vector number 13 is related to Timer2, but it is.

Thanks Jot, i was able to figure out what to do.

@Jot you are right - I looked it up in the source.


text:
nodemcu esp8266 does not boot up when 5V pin is connected as a VIN source
Whenever I boot up the esp8266 or flash code via usb ,I have to remove vin pin otherwise it does not boot up.
If I remove vin pin then flash and boot up happens and then i am able connect vin with 5 V relay.(using VIN to power up relay) .
I dont understand what it has to do with VIN pin.please suggest.
I am using below pins for eight devices
//relay pin setup for funct
int relayOne = 5;
int relayTwo = 4;
int relayThree = 0;
int relayFour = 2;
int relayFive = 14;
int relaySix = 12;
int relaySeven = 13;
int relayEight = 15;

the relay board might be passing 5v to a 3.3v pin via a pullup, i've seen that before on active-low relay modules. Some ESPs might not like 5v. use an n-chan to pull down the relay based on 3.3v from the GPIO

Thanks for the input.Anyway I removed gpio 0 2 15 as it creates problem in boot up.now it’s working fine

IO pins 0, 2 and 15 are boot configuration pins. 15 must be LOW at boot, 2 must not be LOW at boot and 0 determines the flashing mode. For normal run pin 0 must be HIGH. The NodeMcu board has necessary pull-up and pull-down circuits.
You can connect to pins 0, 2 and 15 only devices which don't change the boot state.

Thanks much.
but I don’t understand that why it is working when vin is not connected to relay vcc.it is not booting up only when vin is connected to relay.
Second if I remove device from these 3 pin.which other pins I can use.i have total eight devices to control.
Thanks in advance

it changes if the relay signal pin pulls up or down a pin

Thanks for the support.I removed gpio 0 2 15 and used some other pins.its working fine.

Okay I will do it.i am new to stackexchange .not sure where to do it


text:
Use a button on LCD shield to pause the code
I'm creating a Temperature logging device with thermocouple K and SD card breakout and a RGB LCD Shield Kit w/ 16x2 Character Display (with buttons).
Everything runs ok: temperature displaying on the LCD and logging on txt file on the micro SD card work well
Now I try to configure button on the shield

button UP to reset measurements and timer , it works
button Down to pause measurements, then when pushed again, continue measurements. I don't know how to do that (how to go out the while condition).
 if (buttons) {

if (buttons & BUTTON_UP) {

  lcd.clear();
  lcd.print("RESET ");
  if (SD.exists("datalog.txt")) {

    SD.remove("datalog.txt");
    File dataFile = SD.open("datalog.txt", FILE_WRITE);
  }

  else {

    // open the file. note that only one file can be open at a time,
    // so you have to close this one before opening another.
    File dataFile = SD.open("datalog.txt", FILE_WRITE);
    // if the file is available, write to it:

  }
 StartTime = millis();

  delay(500);

}
if (buttons & BUTTON_DOWN) {
  lcd.clear();
  lcd.print("STOP");
  while (buttons & BUTTON_DOWN){

      ;
  }

}

I already thank you for your help,
Vincent

think about your first two if statements .... why are you testing buttons in the second if statement? .... you already tested it in the first if statement .... same with the last if statement ..... also, check the while (buttons & BUTTON_DOWN){ statement at the bottom ..... do you think that the values of buttons and BUTTON_DOWN will ever change? .... if you think that they will change, then what changes them?

This way of testing the buttons comes from the example given with the adafruit RGB LCD shield library. I tried not to re-test "buttons" in the IF statement after the first if(buttons) but the lcd diplays all statements of the next if(BUTTON_DIRECTION) like all the if test give a TRUE. Sorry it is difficult to be clear.

You are not saying much about how buttons is valorized or its data type, but assuming it is a numeric variable which gets somehow set by, let's say a readButtons() function, then consider the following snippet replacing your while-loop:
do {
  delay(10);
  // re-evaluate whatever sets the buttons variable
  buttons = readButtons();
while(!(buttons & BUTTON_DOWN));

The loop above will continue until the button down is pressed and it's a little resilient regarding contact bouncing, but not 100% reliable, so I assume the readButtons() performs also some debouncing.

Thank you Roberto, you have seen right. I'm using the LCD shield library, with a lcd.readButtons function.

@Vincent if this solves your problem then please accept the answer so that others will be able to use it as a reference


text:
Syntax of binary Constants
I was trying to compile some Arduino code on the PC for testing when I noticed some strange syntax for numerical binary constants.
Convetion seems to be to declare them like so:
    static const uint8_t smiley[] = {
        B00111100,
        B01000010,
        B10100101,
        B10000001,
        B10100101,
        B10011001,
        B01000010,
        B00111100 };

However, when I try to compile this with g++ I get

error: ‘B00111100’ was not declared in this scope

Now when I exchange this for B for the standard C/C++ prefix 0B it works, but I don't want to change the code that I want so simulate!
Is there some clever macro magic at play here?

There is a file (binary.h) with every possible permutation of number between 0 and 255 represented as binary in it. They're stored as C-preprocessor macros:
#define B0 0
#define B00 0
#define B000 0
#define B0000 0
#define B00000 0
#define B000000 0
#define B0000000 0
#define B00000000 0
#define B1 1
#define B01 1
#define B001 1
#define B0001 1
#define B00001 1
#define B000001 1
#define B0000001 1
#define B00000001 1
#define B10 2
#define B010 2
#define B0010 2
#define B00010 2
#define B000010 2
#define B0000010 2
#define B00000010 2
... etc ...

Quite why Arduino decided to do this is anyone's guess.  It makes, as you have seen, for non-portable code.
Personally, I never use (and would never recommend any one else should use) those macros, and instead use the GCC standard binary literal representation 0b.....

1/2 a christmas tree ... lol

The reason they did that is because GCC didn't have the binary representation when Arduino got started. Now the macros still need to be there in order to avoid breaking old code written using them. At this point, I do agree that people should be using the standard binary representation. Yes, there are ancient IDE versions where that code won't compile, but you can only go so far with backwards compatibility.

@jsotola Half a Christmas binary tree ;)


text:
Converting hexadecimal string to floating point value
I am reading data from an energy meter over modbus protocol and I am getting hex values from there. I want to convert that hex string to floating point value.
For example - 0x416f0000 denotes a value of 14.9375.Reference
Can anyone please help me how to do it on Arduino IDE?

You mean Modbus ASCII, right? Non-ASCII Modbus doesn't use hex.

If you do indeed have an ASCII string of hexadecimal numbers (and not a
raw binary float), then your best option may be to do the conversion in
two steps:

convert the string to a 32 bit unsigned number using
strtoul()
reinterpret the binary pattern of this integer as a float.

For example, the following program:
void setup() {
    const char modbus_data[] = "416F0000";
    union {
        uint32_t i;
        float f;
    } data;
    data.i = strtoul(modbus_data, NULL, 16);

    Serial.begin(9600);
    Serial.println(data.f, 4);
}

void loop(){}

prints 14.9375.
Note that for strtoul() to function properly, the hex string must be
followed by a character that is not a valid hex digit (a \0 in the
example above).


text:
ESP8266 Stops Working if I don't provide Wifi during specifc step
To test the WiFi connection I'm sharing the WiFi of my cellphone.
If I stop the WiFi sharing during the command below, the ESP8266 stops working.
It only works if I do a hardware reset.
If I don't stop the WiFi it works normally.
    if(client->POST(urlCal, host, payload))
  { RetornoPost = client->getResponseBody(); }

HTTPS Redirect (Version 2.0)
ESP8266 library version 2.4.2

Does anyone know why ESP8266 stops working?

you forgot to ask a question

If by "stops working" you mean it doesn't do whatever follows the client->POST method invocation, then your interpretation is correct and you could have found my very same information if you had read the open issues on the library before submitting your own.
If I were the author of the library I would be upset by such behavior.

Now it is working! In tests the version "2.5.0-beta2" solves this issue!

Sorry for the wrong information, but unfortunately, the error keeps occurring with "2.5.0-beta2". Sometimes ESP8826 restart when there is an error and is OK. But other times ESP88266 breaks, and I have to do a Hardware Reset.

ESP8266 library version 2.6.3, and watchdog to wait the resposnse, solve this error.