text:
5V pin output on arduino
Sorry for the newbie question (just started learning electronics).
I just saw a tutorial that says that the 5V output pin on the Arduino delivers more amps (if needed) when connecting more voltage to the board (connecting to the 9 - 12V instead of 5V).
Does that mean that the 5V pin then delivers more than 5V as well?

Time for a crash course in electronics and power:
The 5V pin only ever provides 5V. That's why it's the "5V" pin. (assuming, of course, that you give the board more than 5V).
In simple linear electronics you have three values:

The voltage
The current
The load

Generally two of the three are either "fixed" or "known" and the third changes depending on the other two. For simple resistive circuits (where the load is a simple resistor) this relationship is Ohm's Law.

If the voltage is fixed, and
If the load changes, then
The current will also change to keep the relationship stable.

A "power supply" (any device which provides power to some other device) generally has two parameters: Voltage and Current.  One of those is always fixed. The other is always variable, and quoted as a maximum that the supply can give.
For the Arduino's 5V pin the parameters are:

Voltage: 5V
Current: 800mA Maximum

That means that the 5V pin has a fixed voltage of 5V, but the current is free to change depending on the load up to a maximum of 800mA (or a lower limit if you are providing the input power from a source with a lower current. There is also heat to consider with the Arduino - see below).
The two values, voltage and current, combine together to give the "power" of the power supply, through simple multiplication. So the Arduino's 5V pin is 5V × 0.8A = 4 watts maximum.
When you provide power to the Arduino through the barrel jack it first goes through a linear voltage regulator.  This is the device which takes the incoming voltage and reduces it to 5V. Since energy can neither be created nor destroyed it does that reduction in energy by converting some of it to heat.
Say you connect something up that needs 100mA and you plug in a 9V power supply to the board. Let's also assume that the Arduino itself needs 50mA (I like nice round numbers).

That's 150mA in total for the "load".
The incoming voltage is 9V
The outgoing voltage is 5V

The power of the input is thus 9V × 0.15A = 1.35W
The power of the output is then 5V × 0.15A = 0.75W
The power difference is 0.6W
That 0.6W is converted from electrical energy to heat energy by the voltage regulator and "thrown away".
So the "heavier" your load (the more current you demand from the 5V pin) the greater the heat that is generated by the voltage regulator.
When the regulator gets too hot one of two things happen:

A good quality regulator will shut down and you will lose power to the board
A cheap Chinese regulator will likely "fail short" and feed your 9V direct into the Arduino causing components to release their Magic Smoke™ and stop working

Thank you so much, made things clear! :)

Don't you mean to say "A cheap Chinese regulator will likely "fail short" and feed your 9V supply voltage directly into the Arduino causing components to release their Magic Smoke™ and stop working?" (I've always loved the idea that electronics contains magic smoke.)

@DuncanC Yep - typo.


text:
How to send UDP data packet between two access point?
I am new to arduino programming and nodeMcu boards.I have two ESP8266 bards as access points and one board get some data form WiFi stations and resend that data to other access point. but the problem is second access point didn't receive any data packet from first access point.
This is the code of Access point which collect data and resend it to upper level Access point. This Access point successfully received the data from the WiFi stations.
const char *ssid1 ="SecondAP";
const char *pwd1 = "12345678910";

const char *ssid2 ="FirstAP";
const char *pwd2 = "123456789101";

ESP8266WiFiMulti WiFiMulti;

IPAddress local_IP(192,168,4,10);
IPAddress gateway(192,168,4,9);
IPAddress subnet(255,255,255,0);
IPAddress NextAP(192,168,4,9);
StaticJsonDocument<200> doc;
unsigned int locPort1 = 1000;
unsigned int locPort2 = 2000;
WiFiUDP udp1;
WiFiUDP udp2;
char packetBuffer[100];
IPAddress addrs;

void setup() {

  Serial.begin(9600);
  delay(10);
  Serial.println('\n');

  ConnectToAP();
  delay(1000);
  EnableAP();
  delay(1000);

  udp1.begin(locPort1);
  udp2.begin(locPort2);
}

void loop() {

int Icb = 0;

  Icb = udp1.parsePacket();

  if(Icb > 0){
      GetSensorDataPacket();
      Icb = 0;
    }
}

void EnableAP(){

  WiFi.softAPConfig(local_IP, gateway, subnet);
  WiFi.softAP(ssid2 , pwd2);
  delay(1000);

  Serial.print("Access Point \"");
  Serial.print(ssid2);
  Serial.println("\" started");
  Serial.print("IP address:\t");
  Serial.println(WiFi.softAPIP());
}

void ConnectToAP(){

  WiFi.mode(WIFI_STA);
  WiFiMulti.addAP(ssid1, pwd1);

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

  int i = 0;
  while (WiFiMulti.run() != WL_CONNECTED) {

   delay(1000);
   Serial.print(++i); Serial.print(' ');
  }

  Serial.println('\n');
  Serial.println("Connection established!");
  Serial.print("IP address:\t");
  Serial.println(WiFi.localIP());
}

void GetSensorDataPacket(){

  Serial.println("GetSensorDataPacket Function");
  udp1.read(packetBuffer,100);
  DeserializationError error = deserializeJson(doc, packetBuffer);

  IPAddress ClientAddrs = udp1.remoteIP();

  double SensorData = doc["SensorData"];
  int ClientID = doc["ID"];

  delay(1000);
  Serial.println();
  Serial.print("Sensor reading = ");
  Serial.println(SensorData);
  Serial.print("Client ID = ");
  Serial.println(ClientID);

  SendDataToNextAP(SensorData,ClientID);
}

void SendDataToNextAP(double Sensor_Data,int Client_ID){

  StaticJsonDocument<500> jsonBuffr;
  Serial.println("I'm in SendDataToNextAP Function");

  udp2.beginPacket(NextAP, locPort1); //gateway
  JsonObject Sob1 = jsonBuffr.to<JsonObject>();
  Sob1["SensorData"] = Sensor_Data;
  Sob1["ID"] = Client_ID;
  serializeJson(jsonBuffr, udp2);

  udp2.println();
  udp2.endPacket();

  delay(1000);
}

This is the code of upper Access point which should receive data packet from first access point but didn't receive any data from the first access point.
const char *ssid = "SecondAP";
const char *pwd = "12345678910";
ESP8266WiFiMulti WiFiMulti;

IPAddress local_IP(192,168,4,9); // Ip address of this node
IPAddress gateway(192,168,3,1);
IPAddress subnet(255,255,255,0);

StaticJsonDocument<200> doc;
unsigned int locPort1 = 1000;
WiFiUDP udp1;
char packetBuffer[100];

void setup() {

  Serial.begin(9600);
  delay(10);
  Serial.println('\n');

  EnableAP();
  udp1.begin(locPort1);
  delay(1000);
}

void loop() {

int Icb = 0;

  Icb = udp1.parsePacket();
  if(Icb > 0){
      Serial.println("Got a Udp packet");
      GetSensorDataPacket();
    }
}

void EnableAP(){

  WiFi.softAPConfig(local_IP, gateway, subnet);
  WiFi.softAP(ssid,pwd);
  delay(1000);

  Serial.print("Access Point \"");
  Serial.print(ssid);
  Serial.println("\" started");
  Serial.print("IP address:\t");
  Serial.println(WiFi.softAPIP());
}

void GetSensorDataPacket(){

  Serial.println("GetSensorDataPacket Function");
  udp1.read(packetBuffer,100);
  DeserializationError error = deserializeJson(doc, packetBuffer);

  IPAddress ClientAddrs = udp1.remoteIP();

  double SensorData = doc["SensorData"];
  int ClientID = doc["ID"];

  delay(1000);
  Serial.println();
  Serial.print("Sensor reading = ");
  Serial.println(SensorData);
  Serial.print("Client ID = ");
  Serial.println(ClientID);
}

I couldn't find the reason for that. If anyone knows the solution for that please help me?
Thanks!

you have two networks with the same IP range. and gateway(192,168,3,1); is what?

Sorry It's my mistake. it should be gateway(192,168,4,8).

Thank you very much..It works after change IP address.

The two network interfaces (station and SoftAP) of the middle esp8266 must have different IP address range. If the top AP has 192.168.4.x, set for the AP of the middle IP for example 192.168.5.1. Because with same IP address ranges the esp8266 doesn't know to which network do you want to send the UDP message.

source: Stack Exchange

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

sort: votes


text:
How do I set up an ATTiny861A-PU for flashing with Arduino Uno?
I have found instructions for 8 pin Tiny but none for my 20 pin. How do I set this chip up on the breadboard for bootloading with Arduino?

First you need to find (or implement) an Arduino core for the MPU. After that comes the easy part - flashing the device.

@Bookshire did you "defined" attiny for Arduino IDE? have you installed ATTiny Core?

The principle is the same, it's all only ISP (In System Programming), and nothing different from any other microcontroller, that uses ISP. Look at the descriptions of the used pins for the 8-pin Attinys, then connect the pins with the same description on your 20-pin chip.
Namely you have to connect the pins MOSI, MISO, SCK, RESET, VCC and GND. MOSI and MISO are the data lines, SCK the clock signal. If you look into a pinout diagram or - even better - at the pin configuration diagram in the chips datasheet, you will see pins, that are marked this way. The rest of the pins is pretty much self explaining.

Since you are using an Uno as programmer and didn't have a capacitor between Reset and ground of the programmer, I will explain, why this capacitor is needed here.
The Atmega328p on the Uno doesn't have a native USB interface. So in order to connect it via USB to a PC, there is another microcontroller on the Uno (on original board the Atmega16U2), which has a native USB interface. This microcontroller then is the middleman between Atmega328P and PC. It connects to the Serial (UART) interface of the 328P and translates that to USB communication.
Everytime that the corresponding serial port is opened on the PC, the PC sends a DTR signal, which is connected to the 328P's reset pin. So, when the Arduino IDE tries to connect to the Serial port for flashing the Attiny, the Uno get's resetted and hence cannot flash the Attiny.
The capacitor between Reset and Ground will hold the Reset pin high for long enough, so that this reset does not happen and the Uno can do it's duty.
On Arduino boards with native USB interface this is not necessary, since they don't have this hardwired connection to a reset and they communicate directly over USB.

I have done as the instructions on arduino's site. I've used the "old style" when connecting them.
First I load the sketch and then I use burn bootloader.
This is the error I get:
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding

What do you mean by "old style"? The error shows, that you have a problem with the programmer, not with the to-be-flashed chip. I assume, that you want to use an Arduino as ISP programmer. Have you uploaded the ArduinoISP sketch to it before trying to flash the ATtiny? Also do you have the capacitor between reset and ground of the Arduino?

Old style - Arduino homepage explaining the set up uses that terminology.
Use an Arduino as ISP - Yes, you assume correct.
Have you uploaded the scetch? - Yes, I am uploading the scetch to my Arduino before I try to flash.
Have a capacitor between reset and GND? - No, I have not added one. I am following the instructions from Arduino's homepage. What size is the capacitor supposed to be?

What type of Arduino do you use as programmer? The capacitor is important for all Arduinos, that don't have a native USB interface (for example Uno or Nano). This Arduino site states 10uF for it. I used 47uF successfully for flashing an Attiny.

I am using an Arduino Uno. I don't have capacitors of those sizes, so I will have to try this approach another day.

I appreciate the extra information of why it's needed, thanks. I have found one with the value 22uF/25V. Will this suffice?

Yes, that should work. If this is an electrolytic capacitor, be sure so use the correct polarity.

Well, atleast now I get a different error message. avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x20

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


text:
Setting up I2C with HTU21D, no response after beginTransmission
I'm playing with the temperature/humidity sensor HTU21D. Datasheet: https://www.te.com/commerce/DocumentDelivery/DDEController?Action=showdoc&DocId=Data+Sheet%7FHPC199_6%7FA6%7Fpdf%7FEnglish%7FENG_DS_HPC199_6_A6.pdf%7FCAT-HSC0004
The sensor is properly wired and yields reasonable values if I use the library and example here: https://github.com/sparkfun/SparkFun_HTU21D_Breakout_Arduino_Library/blob/master/examples/SparkFun_HTU21D_Demo/SparkFun_HTU21D_Demo.ino
But I'm more interested in how I2C works, so I'm trying to write a small sketch from scratch to communicate with the sensor. Here is what I have right now:
#include <Wire.h>

#define SensorAddress 0x40
#define SoftReset 0xFE
#define TriggerTemperatureNoHold 0xF3
#define TriggerHumidityNoHold 0xF5

void setup(){

    Serial.begin(9600);
    Serial.println("HTU21D library");

    //delay(50);

    //Wire.beginTransmission(SensorAddress);
    //Wire.write(SoftReset);
    //Wire.endTransmission();

    //delay(50);
    Serial.println("init finished");

}

void loop(){

    Serial.println("entering");
    Wire.beginTransmission(0x40);
    Wire.write(0xF3);
    Wire.endTransmission();
    Serial.println("hello");

    //Hang out while measurement is taken. datasheet says 50ms, practice may call for more
    bool validResult;
    byte counter;
    for (counter = 0, validResult = 0 ; counter < 10 && !validResult ; counter++){
        delay(100);

        //Comes back in three bytes, data(MSB) / data(LSB) / Checksum
        validResult = (3 == Wire.requestFrom(0x40, 3));
        Serial.println(validResult);

    }
    Serial.println("here");
}

I'm in the middle of debugging the sketch. When the sketch is uploaded, I'm reading on the serial connection, and all I can see is:
HTU21D library
init finished
entering

It seems the program hangs on the first communication attempt, when I send the TriggerTemperatureNoHold command.
Could you give me a hand please? I don't understand why it's hanging there.

You forgot Wire.begin()...

ah...Indeed....thanks

Post an answer, so I can accept it. Even if my question was slightly dumb...

You forgot Wire.begin();.  You should add it in setup().
Wire.begin(); will configure the IO pins for I2C usage. Without that the signals don't get in or out of the MCU, so I2C functions that wait for an ACK signal never see it and don't complete.


text:
Editing a particular position in a file stored in SD card
I am trying to store some variables in a text file which is saved in a SD card, using the SD library. Every time my program runs, it load the values of those variables from the file. After a few minutes, my program will attempt to change the value of some variables (not all).
This is what I would in a C program. I would locate the position (using position()) where the values to be edited is present, and then using the seek() function I would write at the given position thus overwriting the file.
Each variable is stored in a separate row. But for some reason the program only writes at the end of the file, even if I have moved the file pointer elsewhere. How can I do the above task?
A simple example of the code is as follows:
#include <SD.h> //Load SD library

int chipSelect = 53;
File file;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(chipSelect, OUTPUT); // chip select pin must be set to OUTPUT mode

  Serial.print("Welcome!");
  Serial.println();

  bool initialization_state = SD.begin(chipSelect);
  delay(400); // SD card needs sometime to intialize

  if (!initialization_state) { // Initialize SD card
    Serial.println("Could not initialize SD card."); // if return value is false, something went wrong
  } else {  // if return value is true
    Serial.println("SD card initialized");
  }

  SD.remove("misc.txt");
  file = SD.open("misc.txt",FILE_WRITE);
  file.print("Once you know the central idea and a rough plan for your paragraphs, you need to arrange them in a certain manner to get your story across.");
  file.println();
  file.print("Following are some possible ways of organizing your paragraphs.");
  file.println();
  file.print("Narration: Tell a story. Go chronologically, from start to finish. Description: Provide specific details about what something looks, smells, tastes, sounds, or feels like.");
  file.println();
  file.print("Organize spatially, in order of appearance, or by topic. Process: Explain how something works, step by step. Perhaps follow a sequence—first, second, third.");
  file.close();
  read_file();
  Serial.print("Read?");
  Serial.println();

  update_file();
  read_file();
}

void loop() {
  // put your main code here, to run repeatedly:
}

void read_file() {
  Serial.println("--- Reading file ---");
  file = SD.open("misc.txt", FILE_READ);

  char character;
  while( (character = file.read()) != -1) {
    Serial.print(character);
  }
  Serial.println();
  file.close();
}

void update_file() {
  file = SD.open("misc.txt", FILE_READ);
  char character;
  while( (character = file.read()) != '\n') {}
  byte pos = file.position();
  file.close();

  file = SD.open("misc.txt", FILE_WRITE);
  file.seek(pos);
  file.print(" Love, love, love.");
  file.close();
}

In this program I am attempting to overwrite the second line. The while loop breaks at the first newline character. I store the location of the first character in the second line in a variable pos. Then I open the file object for writing, I seek the position where I want to write (using file.seek(pos) ) and then I print into the file. But when I read the file, the text "Love, love, love." is written at the end.
I am using the linux Arduino IDE 1.8.9.

Personally I would read the file line by line, writing each line to a temporary file. You then change the lines that need changing on the fly. Afterwards you delete the old file and rename the temporary file to the old name. That way you can more easily handle changes in the length of data.

@Majenko Ok. But I was wondering if my approach could be performed on an arduino? Does the SD library not support it?

No reason why it shouldn't. However: how do you know that you are not seeking to the end of the file?

Because once I had located and stored pos. I closed the file object. Then opened another file object in FILE_READ, used file.seek(pos) to go to the location and printed the remaining file on the serial monitor. It had worked.

The problem is that you are opening the file with FILE_WRITE.  That is a combined macro that is made up of:
#define FILE_WRITE (O_READ | O_WRITE | O_CREAT | O_APPEND)

The key one there is O_APPEND.  In the source code (SdFile.cpp) t says:

O_APPEND - If set, the file offset shall be set to the end of the file prior to each write.

So the seek does nothing if O_APPEND is set, since it is overridden.
So instead you need to open the file without O_APPEND.  In fact you don't need to close and open the file at all, since if opened correctly you can hop around at will reading and writing.  The flag O_RDWR is a combination of O_READ and O_WRITE.
For example:
void update_file() {
  file = SD.open("misc.txt", O_RDWR);
  char character;
  while( (character = file.read()) != '\n') {}
  file.print(" Love, love, love.");
  file.close();
}

The O_CREAT flag that is part of FILE_WRITE will create a new file if you try and open one that doesn't exist. By omitting that SD.open will fail if the file you are trying to modify doesn't exist.

Isn't file.seek(file.position()); a no-op?

@EdgarBonet Probably, yes.


text:
LED fader function freezes and becomes unresponsive after a few cycles
My LED controller has a color fader mode that I am making. The controller's loop() function grabs incoming serial data to set the amount of colors, fade speed, mode, and other info then runs the correct mode with the colors that it read from the serial port
When in color fader mode, the controller "freezes" at a certain color and becomes unresponsive to further input until I unplug it and plug it back in or reupload the code (the latter means that it still responds to something).
For testing purposes I am using red, green, and blue in that order. This stopping color can happen anywhere from in the middle of the transition from red to green in the first cycle to going through multiple cycles and stopping on blue depending on the fade speed. This only became a problem after I switched from using delay() to millis(). Why is that and what can I do to fix it?
The reason I switched to using millis is because the delays would stack infinitely and the arduino would become unresponsive to commands
Here is my relevant code:
#include <Adafruit_DotStar.h>
#include <SPI.h>

#define NUMPIXELS 60
#define DATAPIN    4
#define CLOCKPIN   5

Adafruit_DotStar strip(NUMPIXELS, DOTSTAR_BRG);

// Variables
int mode;
int numColors;
int fadeSpeed;
int BBCC;
int R[100];
int G[100];
int B[100];
int Bright[100];

int currColor;

void setup() {

#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000L)
  clock_prescale_set(clock_div_1); // Enable 16 MHz on Trinket
#endif
  strip.begin(); // Initialize pins for output
  strip.show();  // Turn all LEDs off ASAP

  currColor = 0;
}

void loop() {
  strip.show();                     // Refresh strip
  delay(20);                        // Pause 20 milliseconds (~50 FPS)

  getData();

  switch (mode)
  {
    case 1:                  // Mode 1: Solid Color
    {
      for (int i = 0; i < NUMPIXELS; i++)
      {
        if (i % 2 == 0)
          strip.setPixelColor(i, G[0], R[0], B[0]);// Sets whole strip to Color 1
      }
      strip.setBrightness(Bright[0]);
      strip.show();
      break;
    }
    case 2:                  // Mode 2: Multi Color Fader
    {
      colorFade();
      break;
    }
    case 3:                  // Mode 3: Multi Color Pattern
    {
      int j = 0;
      for (int i = 0; i < NUMPIXELS; i++)
      {
        if (i % 2 == 0)
        {
          strip.setPixelColor(i, G[j], R[j], B[j]); // sets a repeating pattern
          if (j == (numColors - 1))
            j = 0;
          else
            j++;
        }
      }
      strip.setBrightness(Bright[0]);
      strip.show();
      break;
    }
    case 4:                  // Mode 4: Music-Reactive Wave Form
    {

      break;
    }
    case 5:                  // Mode 5: Music-Reactive Color Jump
    {

      break;
    }
    default:                 // Default Mode: Incandecent Simulation
    {
      for (int i = 0; i < NUMPIXELS; i++)
      {
        if (i % 2 == 0)
          strip.setPixelColor(i, 150, 200, 40); // Sets whole strip to default value
      }
      strip.setBrightness(255);
      strip.show();
      break;
    }
  }

}

void colorFade()
{
  int del = 100;     // 100 milisecond
  if (currColor >= numColors - 1)
  {

    int steps = fadeSpeed * del;
    int Rdiff, Gdiff, Bdiff, BrightDiff;

    Rdiff = R[0] - R[currColor];
    Gdiff = G[0] - G[currColor];
    Bdiff = B[0] - B[currColor];
    BrightDiff = Bright[0] - Bright[currColor];

    for (int i = 0; i <= steps + 5; i++)
    {
      for (int j = 0; j < NUMPIXELS; j++)
      {
        if (j % 2 == 0)
          strip.setPixelColor(j, (G[currColor] - (Gdiff * i)), (R[currColor] - (Rdiff * i)), (B[currColor] - (Bdiff * i))); // Sets whole strip to value
      }
      //strip.setBrightness((Bright[currColor] - (BrightDiff * i)));
      strip.show();
      //delay(del);
      int timer = millis() + del;
      while(millis() < timer)
      {

      }
    }
    currColor = 0;
  }
  else
  {
    int steps = fadeSpeed * del;
    int Rdiff, Gdiff, Bdiff, BrightDiff;

    Rdiff = R[currColor + 1] - R[currColor];
    Gdiff = G[currColor + 1] - G[currColor];
    Bdiff = B[currColor + 1] - B[currColor];
    BrightDiff = Bright[currColor + 1] - Bright[currColor];

    for (int i = 0; i <= steps + 5; i++)
    {
      for (int j = 0; j < NUMPIXELS; j++)
      {
        if (j % 2 == 0)
          strip.setPixelColor(j, (G[currColor] - (Gdiff * i)), (R[currColor] - (Rdiff * i)), (B[currColor] - (Bdiff * i))); // Sets whole strip to value
      }
      //strip.setBrightness((Bright[currColor] - (BrightDiff * i)));
      strip.show();
      //delay(del);

      int timer = millis() + del;
      while(millis() < timer)
      {

      }
    }
    currColor++;
  }
}

start debugging by running only the fade selection ... preset mode to 2 ....  comment out getData(); in loop()

how would I debug this in arduino IDE? I can't find any command for breakpoints and I don't know what I would need to look at if i used serial.println() to read values

There is no debugging in the normal embedded firmware sense WRT Arduino programming.  That is why you need to start small and not add anything more complex until the small thing works.

it is not "Arduino" ... it is "C++" .... insert mode = 2; in  setup() ...  replace getData(); with // getData();

After looking elsewhere, you can debug arduino by sending something to serial monitor via Serial.println(). That would have been helpful to mention since I could check the values of timer and millis() using this command. timer was overflowing because of the int data type, and millis() would eventually roll over and stop at an upper limit. That was causing the problem

@BoatHouse Please write an answer to your question, so that others can profit from it. Thank you

The problem with the above code lies with overflow. timer should be an unsigned long, because millis() outputs an unsigned long. This causes the freeze because after timer hits its upper limit, This setup works better:
unsigned long timer = (unsigned long)millis() + del;
      while((unsigned long)millis() < timer)
      {
        //wait for as long as del says to
      }

This setup should be able to run for a long time without overflowing


text:
Arduino is incorrectly reading serial input from C# program
I am trying to create a program to operate my arduino based LED controller. I'm pretty sure that my C# program is outputting to serial port correctly as I double checked the output in Debug.WriteLine(). The program is supposed to send information to the arduino in the following format (newlines included):
mode
number of colors
blend speed
beats until color change
Red   <---
Green <---
Blue  <---
Brightness <---

the last 4 are the only ones that matter for now as I am trying to get the LED's to show up one solid color first before worrying about other modes or patterns. The debug writeline loop output of my last test looks like this
1
1
0
1
209
255
255
219

This should be translating to the relevant arduino variables the same way but instead, I only get white light that seems to randomly brighten or darken when I mess with the color/brightness sliders
My code for the arduino is below. I am very new to this so it's probably not even close to right. getData() at the bottom is the function that most likely is the culprit, but I'll put the rest in just in case:
#include <SPI.h>
#include <Adafruit_DotStar.h>

#define NUMPIXELS 60

Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DOTSTAR_BRG);

// Variables
int mode;
int numColors;
int fadeSpeed;
int BBCC;
int R;
int G;
int B;
int Bright;
String buff;

void setup() {
  strip.begin();
  strip.show();
  //Serial.begin(9600);
}

void loop() {
  getData();

  if (mode == 1)
  {
    //strip.setPixelColor(0, R, G, B);
    strip.setBrightness(Bright);
    strip.show();
  }
}

void getData()
{
 // if (Serial.available() > 0)
 // {
    buff = Serial.read();
    int result = buff.toInt();
   mode = result;
   if (mode != -1)
   {
    buff = Serial.read();
    int result = buff.toInt();
    numColors = result;
    buff = Serial.read();
    result = buff.toInt();
    fadeSpeed = result;
    buff = Serial.read();
    result = buff.toInt();
    BBCC = result;
    buff = Serial.read();
    result = buff.toInt();
    R = result;
    buff = Serial.read();
    result = buff.toInt();
    G = result;
    buff = Serial.read();
    result = buff.toInt();
    B = result;
    buff = Serial.read();
    result = buff.toInt();
    Bright = result;//Serial.read();
    strip.setPixelColor(0, R, 0, 0);
    //strip.setBrightness(Bright);
    strip.show();
   }
   else
   {
    strip.setPixelColor(0, R, 0, 0);
    //strip.setBrightness(Bright);
    strip.show();
   }
//  }
}

You should only read from Serial, when there is actually something to read in the buffer.

How can I check if something is in there?

Serial.read() reads a single character (or -1 if there isn't one there).  https://majenko.co.uk/blog/reading-serial-arduino

Your Serial receive code is not correct in some ways:

You should only read from Serial, if there is really something to read. For the first read, that is not the problem, since you checked against the return value being -1 (which is the return code for "there is no new data in the buffer). But after that, you read without ever checking, if there is something to read. You need to understand, that the data is really send serially. The bytes come in one after another and there is no concept as messages on the Serial interface (which is actually called UART in non-Arduino environments). More over, there might be small pauses somewhere in the transmission, since you cannot foresee, when exactly the PC will send the data (the PC has a bunch of other tasks to do, too). So it might be, that you have received one byte, which will lead you into the if statement, but the rest of the data will arrive later. All data is then read as -1, since there is no data in the buffer.
You have to check, if there is actually data to read, before reading. This can be done with Serial.available(). It will return the number of new data bytes in the buffer. For example, if you want to read 8 bytes, you should wait, until at least 8 bytes are inside the buffer by using if(Serial.available >= 8).
You are sending the data from the PC as ASCII encoded text. That means, that every number above 9 consists of multiple data bytes. The 4 values, that you are interested in, are all over 200, which means, that you need to read 3 bytes to get them. But you only call Serial.read() once for every value. That will give you the first digit, which is a 2 for all values in the shown data. More over, since you only read 1 byte, where there is the whole number (which may be multiple bytes) plus 1 or 2 bytes for the new line (depending on the chosen line ending \n or "\n\r"), The whole reading gets misaligned to the data structure. Now the read data (if there is any) is also dependent on how much data was send for the values before.
Keep in mind, that with ASCII encoded text, you may need multiple Serial.read() calls to actually read a full number. I will describe the way to go here in the next point.
As I already mentioned above, there is no message protocol on the Serial interface. Lost data would lead to misalignment and thus garbled data. But you can impose an own protocol onto the Serial stream of data. It is a good practice, to first receive a full message (maybe with multiple data values inside it) and then process it. For that I would suggest a new data structure
mode|number of colors|blend speed|beats until color change|Red|Green|Blue|Brightness\n

The new line is here realized only with a newline character (\n). The values are separated with a vertical dash. You should put an if(Serial.available()>0) into your loop function. Then inside that if statement, you read one character and add it to a buffer. If you read the \n character, you start to process the buffer. You can then convert one value after another from the buffer and save them into variables. After that, you clear the buffer. You can see this style in the SerialEvent example, that comes with the Arduino IDE. You should also read Majenko's blog article about reading the Serial interface on the Arduino.

That said, you should be cautious with using String object on the Arduino. Sure, Strings are convenient, but they dynamically allocate the needed memory during the runtime. On microcontrollers, which normally have very limited RAM memory, that can lead to heap fragmentation (heap is the memory area for dynamic memory allocation). When using String objects, the underlying buffer get's often recreated. As buffers get allocated and deleted later, that can lead to small memory areas, which are unused, but to small to actually be used by the buffer. You can fill up your RAM very fast with that.
It is better to not use String, but directly a char array with a fixed length. Majenko also wrote an article about the String problem: The Evils of Arduino Strings

First off this is NOT how to read from the serial USART!
buff = Serial.read();
int result = buff.toInt();

Serail.read returns a single byte, you are treating it as a string, then trying to parse it; you will never see anything other than 0-9 if your lucky (its very unlikely that buff contains a valid string, chances are it will just keep going till it finds a \0, and return some random number, or just fail.
EDIT: It seems I was mistaken, the 'read()' returns an int, nominally only a byte is returned, but a 16-bit -1 (0xffff) is returned for an error; the documentation could be clearer here.
Second the arduino serial library has a huge flaw, -1 is used as a failure to read, but -1 (i.e. 255) could be a valid piece of data, this makes the return value useless, as you don't know if 255 is the correct value, or an error. The only way around this is with Serial.available so you must use this to control your code or you won't know whats going on.
Finally, you can write binary data in c# with .Write(byte[] ...) and then read it in binary back, so you don't have to parse it.

the -1 and 255 confusion exists only in 8 bit values ... a 16 bit integer would no longer have the confusion .... -1 = 0xff = 255 .... -1 = 0xffff = 65535

i just confirmed it on an Uno ... defined buff as integer int buff; .... serial.read() returns -1 (0xFFFF) when there is no data ... and returns 255 (0x00FF) correctly when 255 is sent

use Realterm to send 0xff


text:
How to read a text file line by line
I am making an LED controller that reads instructions from a text file on my computer. I need to get the arduino to read this text file line by line and put each line into the appropriate variables. I'm using a sparkfun pro micro which is a knock off arduino pro micro. The pro micro is connected via USB
I've seen people use the SD library, but I don't know if this will work for my situation because I am reading directly from the computer and not an SD card. Is this the correct approach, or is there an additional/alternate library that I need to use?

You have Serial. That's all you have. Read the data, parse it. On the PC use some software to send the file (Putty, for example).

What you can do is:

Read character by character and copy it to a temporary buffer of the maximum length of one line.
When you parsed an end of line symbol, you start parsing the (complete) line in the buffer.
In this line parsing (preferably a separate function), you parse the line, using string to type conversion functions, like atoi (string to an inter) etc. Also you can use the C function strtok to split the string based on a symbol (e.g. comma).
After parsing the line, clear the buffer (you already processed it), and continue filling the buffer again until it is full.
Don't forget to check for end of file.

Can that be done through the SD library?

No. As I mentioned in my comment to your question, all you have is Serial. You can only read what something on the PC happens to send to the Arduino.

As Majenko says, only Serial. The SD library (https://www.arduino.cc/en/Reference/FileRead) has functions to read, either one by one or a predefined amount, in both cases, it's unrelated to the end of a line, so you need the C parsing functions.

The Arduino cannot read data on the PC.
Instead the PC has to send the data to the Arduino, and the Arduino has to parse (interpret) that data.
You need two things:

A piece of software running on the PC that sends the file contents to the Arduino over serial
Software on the Arduino that accepts the stream of data coming in over the serial port and does something with it.

It is no different to handling commands that are manually typed by someone using the Serial Monitor - it's just they tend to come in a lot faster when being sent by the PC from a file.


text:
How to load Atmega328p 8mhz board using board manager
I need to load the Atmega328p 8kHz board definition using the board manager and can not find a way.  Any help will be appreciated.

8Khz or 8Mhz? AFAIK there is no 8Khz built-in crystal/osscilator.

Your question doesent make much sense, Are you using a 8MHz crystal or do you want to use the internal 8MHz rc oscillator?

And.. do you already have the board definition or not?

Assuming that you have a 3.3V Atmega328P and are using an external 8MHz occilator:
In the Arduino IDE click on Tools.
Scroll down until you see an option starting with the word Board:
Select the option called Arduino Pro or Pro Mini
Click the Tools menu once again.
This time select the option starting with Processor:
Select the Atmega328P (3.3V, 8MHz)
Done!
Alternatively you can edit the boards.txt file located somewhere similar to C:\Program Files (x86)\Arduino\hardware\arduino\avr
Fuse bits can be calculated using one of these online tools:

http://www.engbedded.com/fusecalc/
http://eleccelerator.com/fusecalc/

Assuming that you have a 3.3V Atmega328P and are using an external 8MHz occilator: If this is not the case then please amend your question with the specifics and I will edit my answer to suit.

The 3.3V part shouldn't matter.

Was the answer helpful? If so, please accept it by clicking on the "tick" icon next to the answer, and also possibly upvote it. This indicates to other users that you found the answer useful, and it also stops Stack Exchange from periodically "bumping" your question in the hope of getting an accepted answer. Thanks for your understanding and cooperation!

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


text:
Arduino Human Infrared Sensor
I started out again with Arduino (beginner), but I wanted to know if I could connect another human infrared sensor like this to the Arduino Uno. I know how to connect a simple pir like this one, but I dont know for sure how to connect the 12V one (if its possible). Guess the red wire goes to a seperate 12V power supply, brown goes to ground and blue then goes to a digital pin on the arduino arduino? I didnt really understand the description that was available for the 12V sensor, so thats why I am asking (I want to be entirely sure before buying).
Thanks

They're exactly the same - just one is in a fancy box and has a light sensor so it only triggers at night.

@Majenko But it says it needs 12V So the output pin of the Sensor should be fluctuating in 12V But Arduino Pins are 5V tolerant.

site says "N- Blue (zero line), L- Brown (connected FireWire), Output - Red (sensor output lines)". honestly the colors are meant for AC, but i guess it's been re-purposed... 12v is too high for arduino, use an optocoupler.

It's impossible to tell quite what the output will be from some pictures and chinglish. It should be a relay but who knows? Banggood never has any datasheets. You will need to dismantle one to find out for sure.

Blue - Ground, connect to Arduino GND
Brown - Power, connect to external 12V source.
Red - 12 V output. Connect via a diode to arduino input pin. Enable pullup on arduino pin.
This way when the sensor output is low it will pull the arduino pin low. When the output is high the diode blocks the 12V from frying the arduino while the internal pullup ensures the input pin goes to a safe voltage for a high pin.
Don't put the diode the wrong way around or things will go bang.

simulate this circuit – Schematic created using CircuitLab

I think it should be compatible with Arduino with a bit of support. Now the first issue is this that we don't really know that what sensor is this detaily. So we can't really find a datasheet that could say it's pinout or its electrical characteristics. Now assuming those pinouts are similar to those of the any sensor that are VCC Data Out GND Then you could probably use it but according to that page it says it needs 12V So according to that Data Out also must be fluctuating with voltage near 12V. So the solution would be to use a voltage divider circuit. Now you could find the resistor values from the Google. I think that setup should be Okay  but I can't tell anything up to you provide us with any data sheet.

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


text:
How to Capture Data from a Webpage in Arduino and Display it over Serial Monitor of ESP8266?
My Code is as follows->
#include <SoftwareSerial.h>

SoftwareSerial ESP8266(8,9);

String inData;
void setup() {
ESP8266.println("AT");
delay(1000);
ESP8266.println("AT+RST");

}

void loop() {
 String cmd = "AT+CIPSTART=\"TCP\",\"";
 cmd += "api.thingspeak.com";  // 184.106.153.149 thingspeak IP address
 cmd += "\",80";
 ESP8266.println(cmd);

 if(ESP8266.find("Error"))
 {
   Serial.println("AT+CIPSTART error");
   return;
}
String hostt = "GET /apps/thinghttp/send_request?api_key=689WYA85WW1VJSBA";
hostt += "\r\n";
hostt += "Host:api.thingspeak.com";
hostt += "\r\n\r\n\r\n\r\n\r\n\r\n";
ESP8266.println(hostt);

cmd = "AT+CIPSEND=";
cmd += String(hostt.length());
ESP8266.println(cmd);

if(ESP8266.find(">")){
ESP8266.print(hostt);
}
else{
ESP8266.println("AT+CIPCLOSE");
// alert user
Serial.println("AT+CIPCLOSE");
}
delay(5000);
}

Is this the write code? Where am I going wrong?
I am not able to see the required fetched data.
Help me with this.

You seem to only have half a get request there. Where's the HTTP/1.0 ?

Where you are going wrong is you are not receiving a response. You are sending a request and then just walking away not caring what happens.

Okay, then what more code do I need to write along with this code? So, that I may keep getting the data in void loop() ?

Okay. Guys, After obtaining this '>' symbol, I inserted GET /HTTP/1.1 and pressed Enter and then typed api.thingspeak.com/apps/thinghttp/send_request?api_key=**************   .Now I got the Output as +IPD,728:

The page you were looking for doesn't exist (404)

The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.

Now what? Where am I going wrong ?

Please edit your question to add further information. This is not a forum where you gradually tease out information in a whole heap of comments.

There are two basic things you are doing wrong:
Firstly your HTTP request is wrongly formatted.  You have:
GET /apps/thinghttp/send_request?api_key=689WYA85WW1VJSBA
Host:api.thingspeak.com

What it should look like is:
GET /apps/thinghttp/send_request?api_key=689WYA85WW1VJSBA HTTP/1.0
Host: api.thingspeak.com:80

Also you only need one blank line after your request, not 5 as you seem to have.
Secondly you are not actually doing anything with the data the site is sending you. You make the request with +CIPSEND= but then the response, which is in the form +IPD,<len>:<data> is completely ignored.  You need to use the SoftwareSerial's .read() and associated functions to receive that data into the Arduino so you can actually do something with it - like send it down through Serial.
Tips:

Look for +IPD, first
Read up to the : and interpret it as a number
You now now how many bytes to read from the data section
Read that data
Do something with it

Okay. Thanks @majenko for the reply . What is the proper Syntax to send a proper HTTP request. Can you help me with it. ?

That should actually have been a comment but the really annoying Android app is crap. You hav ethe right format in your code, but not in your manual test.

I am sorry, I don't understand. I am a Newbie. So, just help me with what should I write after the > Symbol , so that I can get my desired output? Help me with the syntax

You have seen the kind of thing it responds with in your test... +IPD,:. You need to use the serial read commands to read that data in and interpret it so you can then display it how you want. At the moment the response is going nowhere because you just aren't reading it. I suggest you find a few more tutorials that show you how.

Yes, I will refer to how to Serial.read() my required command from that data after +IPD, . Thanks for the heads up. And, just one question, to you. -> Now whenever I type : GET /HTTP/1.1 and then after \n\r I type in this: api.thingspeak.com/apps/thinghttp/send_request?api_key=VD9G5A50GGKH01J0 , why does it say "the Webpage is not available ? " I even tried googling for this, but didn't find any hopeful answer.

Because that is a badly formed request. Read your own code, it has the right form in it.

or it almost does - it lacks the HTTP/1.0 at the end of the GET request.

I am not getting that. It lacks the HTTP/1.0 request means what do you mean to say by that?    Can you Answer me with the correct form of the Syntax for that sentence. Pls?

Yep. Thanks for that. It worked. :) My > is now responding with a proper answer.


text:
I2C on non I2C pins, possible?
I have 2 I2C devices that uses the same address. One of them is the DS3231 RTC. I use this library for the DS3231. I dont want to mess with the other one cause it is way more complicated then this one.:
#include <DS3231.h>

http://www.rinkydinkelectronics.com/library.php?id=73
Then, there is an object declaration for the real time clock:
DS3231  rtc(SDA, SCL);

I wounder if I can change that to:
DS3231  rtc(A0, A1);

I've seen the library but I haven't understand it yet (duh... I'm so stupid!). But is it possible to use an other pair of pins for I2C communication.
Note that I've already tried to use the soft I2C library but I really want to avoid it because it is just too much. If it is the final solution then so be it.

I suspect it wouldn't work because of interrupts and stuff.  Its really a question against the Wire library, because I suspect that's what it uses underneath.

If you can't get it to work you might want to look at a I2C Multiplexer (http://www.ti.com/product/PCA9544A) or in a board (http://www.hobbytronics.co.uk/pca9544a-i2c-mux?utm_source=google&utm_medium=googleshopping&utm_campaign=googlebase&gclid=CPWPmOel1c8CFUKVGwodx1gAkQ).  From a quick glance it looks like these might do the job and they are relatively cheep (~£5).

Have you read the big yellow block on the web page you link to? It kind of answers your question quite succinctly.

What is the other I2C device?

The library above is actually software I2C (from what I can see in the source code).

@MikaelPatel the other board is a GY-521

You can change the address of the GY-521 by pulling the AD0 pin to Vcc. After that the address will be 0x69 instead of 0x68.

Thanks, I also have to add this line in my code. But it should work fine:     MPU6050 mpu(0x69);

Great. Good point about changing the code to select the correct address. Would be very helpful for others with the same problem.

Ok, so I've realise that the anwser was somewhat on the page of the library (that I completly ignored). I can change the pins like I did because the library uses a "TWI-/I2C-like protocol".

The library has not been tested in combination with the Wire library and I have no idea if they can share pins. Do not send me any questions about this. If you experience problems with pin-sharing you can move the DS3231/DS3232 SDA and SCL pins to any available pins on your development board. This library will in this case fall back to a software-based, TWI-/I2C-like protocol which will require exclusive access to the pins used.


text:
Make Arduino Executable File
On a Pi, to execute a C++ code, you'll need a Makefile.
Is there an equivalent with the Arduino? Where I have some valid C++ files to upload without the IDE's help, but instead with an executable?

See also http://arduino.stackexchange.com/questions/32998/how-to-convert-arduino-example-sketch-to-a-complete-c-project

On a Pi you absolutely do not need a Makefile to execute C++ code. Regarding building an executable from C++ code on Pi, you may want to use a Makefile to help you do it, but having a Makefile is in no way mandatory.

You can find several Makefile solutions for Arduino on Internet. Some of them are listed in this question: http://arduino.stackexchange.com/questions/348/how-to-organize-my-arduino-projects-structure-for-easy-source-control Now since I am using NetBeans IDE for my Arduino projects (check out https://github.com/jfpoilpret/fast-arduino-lib/blob/master/ArduinoDevSetup.docx for a description of my setup), it automatically creates Makefiles for me.

Whether you compile manually with a Makefile (or Arduino-Builder) or in the IDE, the end result is a HEX file.  This is a text file describing the data to load into the flash memory.
You then use avrdude to install it into the Arduino - either from the IDE or by running it manually (or specifying it in your Makefile, etc).
A Makefile doesn't produce an executable. A Makefile is merely a recipe - a set of instructions - telling the make program which programs to run (gcc, avr-gcc, etc) and in what order (and with what flags) to compile your code.
There are many Arduino Makefile projects out there that do it all for you.

Take a look at platformio.org. It Provides a simple CLI environment to compile, upload and monitor.


text:
Error message - help needed
As many of you know (if you read my bio or simply read my previous questions), I'm trying to build a rocket. The code was going well, but once I split my objects into 2 files, a .h and .cpp file, this error message appeared.
The full code is on GitHub because it is simply too long!
Here is the error message :
Arduino: 1.8.1 (Windows 7), Board: "Arduino Pro or Pro Mini, ATmega328 (5V, 16 MHz)"

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpInitialize()'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpPacketAvailable()'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetAccel(long*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetAccel(int*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetAccel(VectorInt16*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetQuaternion(long*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetQuaternion(int*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetQuaternion(Quaternion*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetGyro(long*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetGyro(int*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetGyro(VectorInt16*, unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetLinearAccel(VectorInt16*, VectorInt16*, VectorFloat*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetLinearAccelInWorld(VectorInt16*, VectorInt16*, Quaternion*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetGravity(VectorFloat*, Quaternion*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetEuler(float*, Quaternion*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetYawPitchRoll(float*, Quaternion*, VectorFloat*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpProcessFIFOPacket(unsigned char const*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpReadAndProcessFIFOPacket(unsigned char, unsigned char*)'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

sketch\vehicle.ino.cpp.o (symbol from plugin): In function `Fins':

(.text+0x0): multiple definition of `MPU6050::dmpGetFIFOPacketSize()'

sketch\Gyroscope.cpp.o (symbol from plugin):(.text+0x0): first defined here

exit status 1
Error compiling for board Arduino Pro or Pro Mini.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Perhaps edit your question and say whether IDE starts the compile and link, or if not, show the commands used to compile and link the code.  Also, while code may be lengthy, in the question you could show a summary of the #include statements used in each unit of code.

The problem is the way the author of the MPU6050 library wrote MPU6050_6Axis_MotionApps20.h is not compatible with the way you're using the library. Multiple proposals for fixing the issue have been submitted but they are all outdated to some extent:
https://github.com/jrowberg/i2cdevlib/pull/174
download at https://github.com/martinjos/i2cdevlib/archive/master.zip
https://github.com/jrowberg/i2cdevlib/pull/162
download at https://github.com/cgel/i2cdevlib/archive/master.zip
https://github.com/jrowberg/i2cdevlib/pull/268
download at https://github.com/onliner10/i2cdevlib/archive/master.zip

This is 3 years way too late, but here's what I did

In my own mpu_sensor.h file, I only included

#ifndef MPU_SENSOR_H
#define MPU_SENSOR_H

#include "MPU6050.h"
#include "helper_3dmath.h"
....
#endif

Note that I don't include MPU6050_6Axis_MotionApps20, since most datatypes are declared in MPU6050 and helper_3dmath

In my mpu_sensor.cpp file, here's my includes:

#include "MPU6050_6Axis_MotionApps20.h"
#include "mpu_sensor.h"

Please note that MPU6050_6Axis_MotionApps20.h must be before the line that includes mpu_sensor.h.
It works now.
I agree that the library itself should be updated, but it seems like the author is not updating for the past few years.


text:
Arduino project list: What do I need?
Being new to Arduino I would like to know if I can build a project on this platform.
I want to connect Arduino to a few car parking sensors, a video camera and a mobile phone. The preferred language is JavaScript.

Is it something feasible?
Are there JavaScript libraries that can help with automation?
What version of Arduino should I use? Arduino UNO or something else?

Thanks,
George

Can't be answered: you don't give enough detail about what you want to do. However, the word "camera" when coupled with "Arduino" usually means "No. Get a Pi."

Arduino is in C/C++/a bit of Java Script. That's the normal IDE language so no you can't change it. Even other compiler mostly use one of the many C languages.
Car parking sensor question anwsered here.
For the hardware, use an UNO Rev3. It's the latest and most expandable board. It's also cheaper then others and easy to use.

Thanks a lot.
I have also found out about this JS library for Arduino and more:
http://johnny-five.io/


text:
Adding more storage to microprocessor 3.3v trinket
Project:
I'm a software guy trying to learn more about hardware so I've decided to do a project that uses a small micro controller which plays short sound clips over a .5w speaker.
The microcontroller I've selected is Adafruits 3v Pro Trinket along with their 2.5w mono amplifier. The microcontroller however does not have much storage that I could put sound clips on. I'm considering buying a micro sd card breakout board but I'm not sure if this would work (or how to even wire it to the microcontroller). I don't necessarily need to be able to remove the storage and I only need ~16mb so does anyone have suggestions on other chips I could get in place of using an SD Card? I've been searching on Adafruit but haven't been able to find anything.
Rational:
I would love to use a larger micro controller with a build in sd card slot but I need to be able to stick this inside a 1.5" diameter tube, so space is tight and hence the small micro controller.
Links to parts:

Microcontroller: https://www.adafruit.com/products/2010
Amp: https://www.adafruit.com/products/2130
Speaker: https://www.adafruit.com/products/1890
SD Breakout: https://www.adafruit.com/products/254

16 megabits or 16 megabytes? The price difference is not trivial.


text:
Do I use an Arduino or an ARM based Launchpad board for my commercial project?
I want to use a board for an Industrial Project, which is based on temperature sensing, sharing and data storage.
Which board do I use?
Will it be reliable for a long span of time?
Will it be foolproof?

Neither: use a PIC32 based chipKIT board. But then that's just my opinion, just like every other answer you will get to such a question.

Microcontrollers are basically made to run "forever". But where/how are you sharing/storing data? Just sensing temperatur and sending it over RS485 (common in industry) can be achieved by making your own board, but you'll have to be sure that it can resist voltage spikes etc. Also your code has to be able to recognize and act upon errors.

Adding to Candice the Cyborg's answer above.
Which board do I use?
Since its a commericial project you are going to sell then -I would say the right answer is the cheapest ARM or Arduino based board (when migrated to breadboard) to make your project.
Will it be reliable for a long span of time?
For reliability ARM and arduino would be reliable-they are after all both professional engineering products-and both can be used to make commercial products. I am assuming can be sure that your software for the ARM or Arduino is not buggy and professional-thus there is no reliability issues from the software. The span of time that the arduino can retain information reliably is given  in the data sheet-I think its about 100 years.
Will it be foolproof?
Yes if you can be sure that you get the hardware design correct and the software correct-I would imagine this is where a problem would probably come from for your device.

If you are want to be professional, make a custom PCB. This lets your project be neither and also stronger. This also makes you look like you actually spent more time on the project and make it great for industries.
If you still want to use an Arduino based board, you might as well use an Teensy 3.2. They are small, powerful and are still at a low price. Buy it here.
If you make a good case for your project, it could last quite a long time. It might even last many years of continuous run outside at unregulated temperatures. Just make sure it doesn't get in contact with water or high levels of humidity and you should be good.

thanks for the advice. Seems quite reliable. I think I will make a custom PCB then. Now my question is, which processors do you think are reliable? ARM processors or the ATMega based ones?

A couple of sensors or a simple circuit will run fine with an ATmega. Want more power, a more reliable and fast processor use ARM. An ARM is better in everyway except the price and the simplicity.

All processors are reliable. It's the software that people write to run on them that isn't.


text:
ESP8266 as WiFi for Arduino
I have a pretty simple project, where some data has to be read from a mySQL server. My idea is to do this with an ESP8266, and then provide that data to the Arduino Mega.
Is this possible or am I going to have to use the ESP8266 itself? I highly doubt that I would have enough pins then.
I read something about AT-commands. But I have no idea how to send those commands to the ESP.
Thanks in advance,
Michidez

Yes its possible, you can use the ESP8266 as a dumb Wifi to Serial convertor.  Set you Arduino IDE up so you can program the ESP8266 like an Arduino, and then write a simple program to connect to the WIFI network and read the data from the server, then just print it to the default serial console with a special sequence of characters at the beginning of each line, like 'DATA'.
Connect the serial port on the ESP8266 to the Mega, don't forget top cross the RX and TX wires and then write a program on the mega that reads from the serial port you have allocated and only process lines beginning with the special sequence of characters.
Yes you could use the AT commands, but that involves a fair amount of learning. pain and different software, when you already probably have the knowledge that you need.
Some of the later version of the ESP8226 can run at 160MHz and have 1MByte or memory so you might want to hand off some of the data crunching to the ESP.  (But that's a decision for later, once its working).
Hope that helps.

Check out ESP-LINK You can find it here
ESP-LINK is a esp8266 wifi-serial bridge, outbound TCP, and arduino/AVR/LPC/NXP programmer. It has several configuration, one of them allowes uploading new firware ower wifi, or to act as a serial link just like if usb cable is pluged in and serialport viewer is active. The website has great documentation and has one of the slickest configuration interfaces seen on ESP.

Could you expand out your answer a bit please? Perhaps a brief description of what we find if we visit the link (I've already done that).  Plus describe the gist of what it is about. Stack Exchange frowns on link-only answers. If the link ever goes down the answer becomes useless.

Updated the answer with more info


text:
Arduino - Turn on LED when Potentionmeter is used
I'm very new to the Arduino/Microcontroller-world, so please be patient :)
I have 4 potentiometers and I want my LED to blink up, when one of these is beeing used.
So far., so good.. the potentiometers are sending singnals to my inputs A0-A3. In the code I read and buffer the values of send to the inputs, so when a new value is recieved (potentiometer is beeing used), the funcion blinkLED() is beeing triggered:
int ledPin = 13;

int pin[] =             {A0, A1, A2, A3};
int cc[] =              {20, 21, 22, 23};
int potiValues[] =      {0,  0, 0, 0};
int potiValuesTmp[] = {0, 0, 0, 0};

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

void loop() {
    // READ EVERY PIN
    for(int i=0; i<=3; i++){
        potiValues[i] = map(analogRead(pin[i]), 0, 1023, 0, 127);
        if(potiValues[i] != potiValuesTmp[i]) {
            // NEW VALUE RECIEVED - MAKE OUTPUT
            Serial.println("Pin ");
            Serial.print(pin[i]);
            Serial.print(" - ");
            Serial.print("Value: ");
            Serial.print(potiValues[i]);
            blinkLED();
        }
        potiValuesTmp[i] = potiValues[i];
    }
}

void blinkLED() {
    digitalWrite(ledPin, HIGH);
    delay(1000);
    digitalWrite(ledPin, LOW);
}

It somehow works on the emulator circuits.io, but I'm not sure if I did it right(?) Maybe someone could have a look and tell me, what to improve?
But my main question is:
When the function blinkLED() is triggered, there is this delay,.. does the whole loop()-function wait, too?

Put a resistor in series with your LED or it will damage both the LED and the Arduino. 150 Ω or higher would be suitable. See LED calculator.

When the function blinkLED() is triggered, there is this delay,.. does the whole loop()-function wait, too?

Yes, when you call a function it doesn't return until it is done, and delay is blocking.
You can rewrite a bit like this:
int ledPin = 13;

int pin[] =             {A0, A1, A2, A3};
int cc[] =              {20, 21, 22, 23};
int potiValues[] =      {0,  0, 0, 0};
int potiValuesTmp[] =   {0, 0, 0, 0};

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

unsigned long lastFlash;
int flashesToGo;
const unsigned long flashTime = 50; // ms

void loop() {
    // READ EVERY PIN
    for(int i=0; i<=3; i++){
        potiValues[i] = map(analogRead(pin[i]), 0, 1023, 0, 127);
        if(abs (potiValues[i] - potiValuesTmp[i]) > 3) {
            // NEW VALUE RECEIVED - MAKE OUTPUT
            Serial.print("Pin ");
            Serial.print(pin[i]);
            Serial.print(" - ");
            Serial.print("Value: ");
            Serial.println(potiValues[i]);
            flashesToGo = 10;
            potiValuesTmp[i] = potiValues[i];
        }
    }

   // flash LED if required

   if (flashesToGo > 0)   // need more flashing?
      {
      // is it time to toggle the LED?
      if (millis () - lastFlash >= flashTime)
        {
        // toggle LED
        if (digitalRead (ledPin) == HIGH)
          digitalWrite (ledPin, LOW);
        else
          digitalWrite (ledPin, HIGH);
        // remember when we did it
        lastFlash = millis ();
        // count down
        flashesToGo--;  // one less flash
        } // end of time for another flash
      }
   else
     digitalWrite (ledPin, LOW);  // ensure LED off

}

What this does is add to the main loop a few lines of code that toggle the LED after a certain time is up (50 ms currently). It counts down the number of toggles from a desired starting point (eg. 10) until they are all done. This means that the LED will flash without blocking.
Each time you detect a new analog reading the number of flashes is reset back to the maximum.

I modified your test for if the analog reading changed to be:
if(abs (potiValues[i] - potiValuesTmp[i]) > 3)

I found that without that, the LED flashed continually because the readings were slightly different each time (eg. 51, 52, 51, 50) which would probably just be error in the ADC reading.
With that change, it doesn't count as "changed" unless the reading changes by 3 (you could make it more, or less than that).

I want the LED to blink up just once - when I turn one of the potentiometers

In that case change:
flashesToGo = 10;

to:
flashesToGo = 2;

That is one HIGH and one LOW (one flash in total).

Yes, the main loop (aka void loop) will have to wait during the delay. One method of escaping that problem is to use the millis() function. There is an example code called "blinkWithOutDelay" (or something like that). It pretty much uses the ATmega's internal timer. This method is more for advanced users. The millis() functions is will return you the number of milliseconds since the start of your program.
Also, potentiometers are always in use. They will report back data everytime. Its not like if it had too fixed states like ON or OFF. So the problem is that they are all in used at the same time. You might consider changing the values of potiValuesTmp. My varying that variable, you can make it so that at least one potentiometer has to be higher then a certain point.

Hey, thank you very much, I will have a look on the mentioned example.
Just to verify I have not misunderstood you with this potentiometers.. I did this in my code, didn't I ? I mean, I buffer the values in the array so I can detect, when a potentiometer is beeing.. "used" :) .. or, did I get something wrong here?

well, if they aint all at the zero position, they will be considered as USED in your program

by used you mean used one time, right?.. but not "used live" (sorry I don't know how to say that) .. I want the LED to blink up just once - when I turn one ot the potentiometers .. just like a status-LED which says "here.. you just did something"

change all the vals of potiValuesTmp[] to 512

sorry, I don't get it :/

can you please explain it to me, what/how you mean that?


text:
multiple multiplexer (4051) - how to process the inputs?
I have my Arduiono which has only a limited amount of Inputs/Outputs. But in my project I will have to attach a ton of potentiometers/buttons/LEDs, so I will have to use the IC4051-Multiplexer/Demultiplexer.
I have understood how to switch the Inputs/Outputs via the 3-Bits. But I don't get it, how to connect multiple ID4051s and process the signals(?)
Can someone explain that to me?

The 4051s are only useful, for your potentiometers. For leds, I'd use shift-registers. For buttons you could use input-shift-registers. Though there are better options. E.g. chips that can scan a matrix of buttons, or chips that send you an interrupt, if one of the buttons is pressed (so you don't have to constantly poll the button states.
As to the original question. You can connect the S1, S2, S3, and Z pins of multiple chips to the same pins on the Arduino. You need to use a different Arduino pin for each of the chips E pin.
You can then set the E pin of the chip you want to read to LOW. You then set the correct S1-3 pins to select which output/input of that chip you want to connect to. You then read the value from the Z pin.
I hope that makes sense. Otherwise, let me know.

Re “You need to use a different Arduino pin for each of the chips E pin”, one can instead use a 74LS138.  This uses 3 address lines to select 1 of 8 outputs to pull low.

I have no experience of this chip but I would guess that you would need to connect the child level multiplexer to the output of the parent and use the outputs to drive the address lines.
You could look at an MCP23008 or MCP23016, these are 8 and 16 bit GPIO expanders that you control via I2C.  You can have 8 of the MCP230008 (64 pins) before you need to look at I2C bus expanders (which you can get).  I think its the same for the 16 bit version, but you would need to double check.


text:
SD card reader and lcd display
I have sd card reader and lcd display. I want to display bitmap with u8g2 library. My bitmap looks like:
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x3f, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00

If i write it in arduino ide like:
static unsigned char bytes[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x3f, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00
};

Everything works fine. So how can i read it from sd card to have same result as in second code?

This is talked about in multiple Arduino threads.  This thread, this thread & this thread are just 3 found.
It appears reading and SDCard using an Arduino results in a text like character string.  The task is to parse this (if necessary) and convert it to the desired individual values.
The most efficient way to do this might be to use the toCharArray() to copy the String’s characters to a character array (buffer).  However, this implies the data is stored exactly as needed in the SDCard.  Which may be difficult to do.  Simply put, the program would read in a string (of likely unprintable letters) from the SDCard.  Then use the above function to convert that string into the supplied character array (buffer).
(Some more experienced readers might say if one used a union here, that the character string and the array of type characters would occupy the same memory and hence have the same data.  So no call to a conversion function is needed.  Once you read in the data as a string, it would be available to read out as an array of characters.)
More often it is preferred to store SDCard data for Arduino's in a (printable) text format.  Further it appears most store data using the CSV format.  When reading back this format the strings have to be parsed.  That is, the commas need to be found and the printable numbers between the commas need to be individually converted from short character strings to values.  The function atoi() is used to convert a character string like "123" to the integer value 123.  Then you can cast that number from an integer to an unsigned character to store in your array.
Another and perhaps easier approach is to use the toint() function call.  It would appear reading a number followed by a carriage return from the SDCard then unsung this function will result in an integer value.  You would not have to look and remove delineation characters as the toint() function is looking for carriage returns as the delineating character for you.
Many times working with an unknown amount of data is a problem.  If your data will always be a fixed size of 36 bytes - this should not concern you.


text:
ESP8266 still connects to wifi even after flashed with empty sketch
So, my wifi is a hotspot password protected. I was developing a program until I decided to comment the ssid and passwords from it, to prevent the ESP from connecting to the internet. But then it still connected. After some debugging, I decided to upload an empty sketch. It still connects to the hotspot!
What is going on?! How does it still know my SSID and password when loaded with an empty sketch!?

The Espressif esp8266 SDK remembers the SSID and password on flash to start connecting immediately after boot. The WiFi channel is stored in the RTC memory (cleared on power down)
You can control this with WiFi.persistent() and WiFi.setAutoConnect().

Thanks. That seems to be it!


text:
how to get text box values from webserver of esp32 and print them in to serial monitor by using <webserver.h> library
Actually I'm trying to get the values from esp32 server webpage. Suppose there is a web page containing some text box fields, user has to enter some details in it and this details I want to be print on serial monitor.
And didn't get any solution regarding that. Though it is working with ESPAsyncWebServer.h library, that i found here -- > https://randomnerdtutorials.com/esp32-esp8266-input-data-html-form/
but I want to do this task with webserver.h library, for some reason I don't want to use ESPAsyncWebServer.h library.. Hope you all guys can understand what I'm trying to ask and say. Thank You.

Do you, first of all, understand how HTML forms function?

html side if i try method = post, then how would i fetch this post value in arduino ? in php its so easy to fetch with $_POST["value"], but in arduino i don't have any idea about it. new to arduino programming so facing this problem.

POST data is just in the body of the request. I don't know how webserver.h will present that to you.

thats the problem brother, i guess i need to dig more deep into this library.

see the SimpleAuthentification example

I didn't get one  @Juraj  .. Still struggling and finding a way to do this task :(

$_POST["value"] is server.arg("value")


text:
how to convert date to timestamp?
How should I convert date format(dd-mm-yyyy) to timestamp value . Can anyone suggest code how to convert and where to put code .

What do you mean by "timestamp value"? And how should we know where to put that resulting code? And what have you tried so far? Where do you use it with Arduino?

It is good for you?
struct tm tm;
time_t fecha;
if ( strptime(timestamp, "%Y-%m-%d %H:%M:%S", &tm) != NULL )
  fecha = mktime(&tm);
else

// Another thing

Welcome to Arduino.SE. To increase the benefit of all users looking at your post, you should add some explanation to your code. Consider a lot of the users here newbies. At least add some comments in your code.


text:
ESP-12e, Arduino IDE, NeoPixel Strip - Flickering
I have a NeoPixel RGB strip connected directly to my NodeMCU ESP12-e board. I'm using Arduino IDE with the NODEMCU 1.0 ESP 12-e module to programm the board.
ESP12-e | NeoPixels
GND    ---> GND
3.3V   ---> +5V
GPIO0  ---> Din

With the 3.3V output I have a strange flickerin on the LEDs.
When I use the VIV 5V output of the ESP12-e the flickerin is gone, but the lights turn off after a few seconds and some lights turn on with strange behavior.
I guess 5V is to much for the board? What can I do to get rid of the 3.3V flicker?
EDIT: I'm using WS2812B LED Strip Band with 224 LEDs 5050 SMD connected directly (see above) to a NodeMCU ESP-12e (http://learn.acrobotic.com/uploads/esp8266_devkit_pinout.png)
I'm using:
#include <ESP8266WiFi.h>
#include <Adafruit_NeoPixel.h>

I'm turning LEDs on for example like this:
#define PIN 0
#define NUMPIXELS 224

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int individualPixels[NUMPIXELS];
  void allOn(){
      for(uint16_t i=0; i<pixels.numPixels(); i++) {
        individualPixels[i]=1;
        pixels.show();
      }
    }

   for (int i=0; i<sizeof(individualPixels); i++){
    if (individualPixels[i]==1){
      pixels.setPixelColor(i, pixels.Color(red,green,blue)); //Set Neopixel color
    }
    else{
      pixels.setPixelColor(i,pixels.Color(0,0,0));
    }
  }
  pixels.show();

The ESP12-e is plugged in via USB Power
Thanks in advance

how many LEDs are you using?

maybe 3.3V GPIO is not enough to provide an assertive HIGH when Vin is 5V, and when Vin =3.3V it is. Is it viable for you to try and make a level shifter?

I found a solution for my problem:
USB Powerbank --> ESP12-e --3.3V--> WS2812 --> FLICKER
USB Powerbank --> ESP12-e --5V--> WS2812  --> Strange behavior

Solution:
USB Powerbank with 2 Outputs:
Output 1 --> ESP12-e
Output 2 --> WS2812
Connect GND form Output 2 with GND ESP12-e

This works without level shifter.

Have a google for (WS2812 or Neopixels) and ESP, it should give several good hints on how to wire it up reliably. Also really read this: https://learn.adafruit.com/adafruit-neopixel-uberguide/overview .
But some things to consider:

WS2812 requires 5V, so you do want to use a 5v source, not 3.3v.
Make sure all your grounds are connected together, especially if you have a separate power supply for the leds.
The data input on the WS2812 needs a 5v high signal, especially when the WS2812 is (correctly) powered by 5v. This means you probably need some kind of level shifter, which needs to be able to switch fast as well, cause it's a pretty high frequency signal.
224 WS2812's can chew up a lot of power, so make sure your 5v source can handle that. When all are set to full white, it's 20ma per color per led, that's 60ma per led, so 13,44 AMP maximum. Your average USB charger isn't gonna cope with that :) You can use a power supply which provides less power if you make sure you only turn on a few leds/colors at a time, but if you accidentially turn on more, voltage is gonna drop and stuff will stop working :)


text:
NodeMCU ESP-12e - Timing errors
I'm using the ESP-12e with Arduino IDE. With that I'm trying to build a clock with a WS2812B LED strip matrix that I've build.
When I try to display the seconds on my matrix there are strange timing problems. It shows me the numbers how I should, the LEDs work OK but ..it misses seconds spontaneously. sometime it jumps the numbers like 00 01 03 06, sometimes 00 02 03 05.. sometimes it hangs at one number for a short time.

Is the problem in my code?
Or is it due to hardware limitations of the ESP-12e?
How can I do it better?

Here is my sketch (I removed some number definitions [...] for better overview):
#include <ESP8266WiFi.h> //WiFi
#include <Adafruit_NeoPixel.h> //LEDs
#include <TimeLib.h> //Time
#include <WiFiUdp.h> //Synchronize Time

const char* ssid = "XXXXX";
const char* password = "XXXXXXX";

WiFiClient wifiClient;

//NTP Servers
  static const char ntpServerName[] = "us.pool.ntp.org";
  const int timeZone = 1; // Central European Time
  WiFiUDP Udp;
  unsigned int localPort = 8888;  // local port to listen for UDP packets
  time_t getNtpTime();
  void digitalClockDisplay();
  void printDigits(int digits);
  void sendNTPpacket(IPAddress &address);

  // Setup Wifi
void setup_wifi() {

  delay(10);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

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

  randomSeed(micros());

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

/*-------- NTP code ----------*/
// ====================================

const int NTP_PACKET_SIZE = 48; // NTP time is in the first 48 bytes of message
byte packetBuffer[NTP_PACKET_SIZE]; //buffer to hold incoming & outgoing packets

time_t getNtpTime()
{
  IPAddress ntpServerIP; // NTP server's ip address

  while (Udp.parsePacket() > 0) ; // discard any previously received packets
  Serial.println("Transmit NTP Request");
  // get a random server from the pool
  WiFi.hostByName(ntpServerName, ntpServerIP);
  Serial.print(ntpServerName);
  Serial.print(": ");
  Serial.println(ntpServerIP);
  sendNTPpacket(ntpServerIP);
  uint32_t beginWait = millis();
  while (millis() - beginWait < 1500) {
    int size = Udp.parsePacket();
    if (size >= NTP_PACKET_SIZE) {
      Serial.println("Receive NTP Response");
      Udp.read(packetBuffer, NTP_PACKET_SIZE);  // read packet into the buffer
      unsigned long secsSince1900;
      // convert four bytes starting at location 40 to a long integer
      secsSince1900 =  (unsigned long)packetBuffer[40] << 24;
      secsSince1900 |= (unsigned long)packetBuffer[41] << 16;
      secsSince1900 |= (unsigned long)packetBuffer[42] << 8;
      secsSince1900 |= (unsigned long)packetBuffer[43];
      return secsSince1900 - 2208988800UL + timeZone * SECS_PER_HOUR;
    }
  }
  Serial.println("No NTP Response :-(");
  return 0; // return 0 if unable to get the time
}

// send an NTP request to the time server at the given address
void sendNTPpacket(IPAddress &address)
{
  // set all bytes in the buffer to 0
  memset(packetBuffer, 0, NTP_PACKET_SIZE);
  // Initialize values needed to form NTP request
  // (see URL above for details on the packets)
  packetBuffer[0] = 0b11100011;   // LI, Version, Mode
  packetBuffer[1] = 0;     // Stratum, or type of clock
  packetBuffer[2] = 6;     // Polling Interval
  packetBuffer[3] = 0xEC;  // Peer Clock Precision
  // 8 bytes of zero for Root Delay & Root Dispersion
  packetBuffer[12] = 49;
  packetBuffer[13] = 0x4E;
  packetBuffer[14] = 49;
  packetBuffer[15] = 52;
  // all NTP fields have been given values, now
  // you can send a packet requesting a timestamp:
  Udp.beginPacket(address, 123); //NTP requests are to port 123
  Udp.write(packetBuffer, NTP_PACKET_SIZE);
  Udp.endPacket();
}

// NEO PIXELS
// ====================================

// Setup
#define PIN 0
#define NUMPIXELS 224

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int individualPixels[NUMPIXELS];

// Time variables
int hs;
int m;
int s;

// For Loops
int x;

// RGB color variables
int red;
int green;
int blue;

void colorBlue(){
  red = 0;
  green = 0;
  blue = 100;
}

/* IN LOOP Light pixels corresponding to current time */
void neoPixler(){
  for (x=0; x<sizeof(individualPixels); x++){
    if (individualPixels[x]==1){
      pixels.setPixelColor(x, pixels.Color(red,green,blue)); //Set Neopixel color
    }
    else{
      pixels.setPixelColor(x,pixels.Color(0,0,0));
    }
  }
  pixels.show(); //Display Neopixel color
}

// ALL OFF
void turnOff(){
  for(x=0; x<pixels.numPixels(); x++) {
    individualPixels[x]=0;
    pixels.show();
  }
}

//Numbers
void dl_one(){
  individualPixels[160]=1;
  individualPixels[161]=1;
  individualPixels[146]=1;
  individualPixels[147]=1;
  individualPixels[116]=1;
  individualPixels[117]=1;
  individualPixels[102]=1;
  individualPixels[103]=1;
  individualPixels[72]=1;
  individualPixels[73]=1;
  individualPixels[58]=1;
  individualPixels[59]=1;
  individualPixels[28]=1;
  individualPixels[29]=1;
  individualPixels[148]=1;
  individualPixels[149]=1;
  individualPixels[112]=1;
  individualPixels[113]=1;
}
void dr_one(){
  individualPixels[172]=1;
  individualPixels[173]=1;
  individualPixels[134]=1;
  individualPixels[135]=1;
  individualPixels[128]=1;
  individualPixels[129]=1;
  individualPixels[90]=1;
  individualPixels[91]=1;
  individualPixels[84]=1;
  individualPixels[85]=1;
  individualPixels[46]=1;
  individualPixels[47]=1;
  individualPixels[40]=1;
  individualPixels[41]=1;
  individualPixels[136]=1;
  individualPixels[137]=1;
  individualPixels[124]=1;
  individualPixels[125]=1;
}
void dl_two(){
  individualPixels[152]=1;
  individualPixels[153]=1;
  individualPixels[156]=1;
  individualPixels[157]=1;
  individualPixels[158]=1;
  individualPixels[159]=1;
  individualPixels[160]=1;
  individualPixels[161]=1;
  individualPixels[144]=1;
  individualPixels[145]=1;
  individualPixels[118]=1;
  individualPixels[119]=1;
  individualPixels[104]=1;
  individualPixels[105]=1;
  individualPixels[102]=1;
  individualPixels[103]=1;
  individualPixels[68]=1;
  individualPixels[69]=1;
  individualPixels[64]=1;
  individualPixels[65]=1;
  individualPixels[22]=1;
  individualPixels[23]=1;
  individualPixels[24]=1;
  individualPixels[25]=1;
  individualPixels[26]=1;
  individualPixels[27]=1;
  individualPixels[28]=1;
  individualPixels[29]=1;
  individualPixels[30]=1;
  individualPixels[31]=1;
}
void dr_two(){
  individualPixels[34]=1;
  individualPixels[35]=1;
  individualPixels[36]=1;
  individualPixels[37]=1;
  individualPixels[38]=1;
  individualPixels[39]=1;
  individualPixels[40]=1;
  individualPixels[41]=1;
  individualPixels[42]=1;
  individualPixels[43]=1;
  individualPixels[52]=1;
  individualPixels[53]=1;
  individualPixels[80]=1;
  individualPixels[81]=1;
  individualPixels[92]=1;
  individualPixels[93]=1;
  individualPixels[90]=1;
  individualPixels[91]=1;
  individualPixels[132]=1;
  individualPixels[133]=1;
  individualPixels[130]=1;
  individualPixels[131]=1;
  individualPixels[168]=1;
  individualPixels[169]=1;
  individualPixels[170]=1;
  individualPixels[171]=1;
  individualPixels[172]=1;
  individualPixels[173]=1;
  individualPixels[140]=1;
  individualPixels[141]=1;
}

[......]

// Seconds
// ====================================
void print_numbers(byte num){
  byte num10;
  byte num1;
  num1=num%10;
  num10=(num-num1)/10;
  switch (num10){     //10...
  case 0:
    dl_null();
    break;
  case 1:
    dl_one();
    break;
  case 2:
    dl_two();
    break;
  case 3:
    dl_three();
    break;
  case 4:
    dl_four();
    break;
  case 5:
    dl_five();
    break;
  }
  switch (num1){      //1...
  case 0:
    dr_null();
    break;
  case 1:
    dr_one();
    break;
  case 2:
    dr_two();
    break;
  case 3:
    dr_three();
    break;
  case 4:
    dr_four();
    break;
  case 5:
    dr_five();
    break;
  case 6:
    dr_six();
    break;
  case 7:
    dr_seven();
    break;
  case 8:
    dr_eight();
    break;
  case 9:
    dr_nine();
    break;
  }

}
void seconds(){
/* Get current time */
s=second();
turnOff();
print_numbers(s);
neoPixler();      // Lights
}

void setup() {

  // Debug info
  Serial.begin(115200);
  Serial.println(F("Booting"));

  setup_wifi();

  // Setup UDP Time + Sync Time
  Serial.println("Starting UDP");
  Udp.begin(localPort);
  Serial.print("Local port: ");
  Serial.println(Udp.localPort());
  Serial.println("waiting for sync");
  setSyncProvider(getNtpTime);
  setSyncInterval(3000);

/* NEO PIXELS ------------------------------------------------------------------------------------------------------*/
  colorBlue(); //Standard Color
  pixels.begin(); //Begin Neopixel string
  pixels.show(); // Initialize all pixels to 'off'
}

void loop() {
  seconds();
}

It's likely the problems are in your code somewhere; but not enough information is available to say for sure.

Your first step toward debugging the problem probably should be taking any ESP-12e issues out of the mix.  At the beginning of getNtpTime() temporarily add something like return 1477897101UL + millis()/1000; to get a sync-time that advances at the correct rate and is repeatable for testing.  If the display suddenly begins updating smoothly, look for problems in your time code, else in the display code.

The technique of duplicating a whole bunch of individualPixels[116]=1; lines (with different pixel numbers) is crude, tedious, verbose, error-prone, inflexible, etc.  You might instead create some arrays and use a loop to set pixel data.  For example:
const byte L1[] = {160, 161, 146, 147, 116, 117, 102, 103, 72, 73, 58, 59, 28, 29, 148,
  149, 112, 113, 0};
...
const byte R2[] = {34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 52, 53, 80, 81, 92, 93, 90,
  91, 132, 133, 130, 131, 168, 169, 170, 171, 172, 173, 140, 141, 0};

void loadDigit(byte *pixelList) {
  for (byte j=0; pixelList[j]; ++j)
    individualPixels[pixelList[j]] = 1;
}
...
   loadDigit(L1);  // Write a left 1
...
   loadDigit(R2);  // Write a right 2

You could also create an array of addresses of number-data arrays, to get rid of the crude, tedious (etc.) switch/case statements in print_numbers().  For example:
const byte *digitsL[] = {L0, L1, L2, L3, L4, L5, L6, L7, L8, L9};
const byte *digitsR[] = {R0, R1, R2, R3, R4, R5, R6, R7, R8, R9};
...
if (num>9)
  loadDigit(digitsL[num/10]);  // Write tens digit
loadDigit(digitsR[num%10]);    // Write units digit

If your matrix is logically organized, all of the 1's in R0 are at constant offsets from the 1's in L0 (for example, 12 more), and similarly for other digits.  If that's the case, you could modify loadDigit() to take a second parameter, offset, which indicates where to place the digit in the matrix, ie, tells loadDigit() how much to add via a statement like individualPixels[offset+pixelList[j]] = 1;.  Then you could leave out the R0 ... R9 arrays (and digitsR[] as well) and use code like the following:
...
if (num>9)
  loadDigit(digitsL[num/10], 0);  // Write tens digit at left
loadDigit(digitsL[num%10], 12);   // Write units digit at right

A drawback to using const byte arrays like L0 ... L9 and R0 ... R9 is that when your program starts they get copied from PROGMEM into RAM for access.  It would make sense to declare them in PROGMEM, and use them directly from PROGMEM by appropriate changes.  [Edit: See example program, below]

Note, a string of 224 WS2812B units takes about 6.7 ms to update:  224 units x 24 bits x 1.25 μs/bit.  Each time you update your matrix of lights, the millis() counter, timer0_millis, will lose 5 or 6 ms because pixels.show() runs with interrupts turned off.  To compensate, you could add 5 to timer0_millis after each update.  To make the loss always be 5 ms instead of sometimes 5 and sometimes 6, add the following code just before pixels.show():  unsigned long now=millis(); while (now==millis());, which will stall until the end of the current millisecond.  To see how to change timer0_millis, see the  “Better Alternative” section of my answer to “How to keep accurate millis() while using ADC_sleep mode?”.

I'd remove the pixels.show() call from turnOff() because you will (I think) always be calling pixels.show() shortly after that, after loading number images, to turn on a bunch of other pixels.  That is, clear the array, fill the necessary 1's, then show, without a show between clearing and filling.

Following is an example program that illustrates storing a constant array of bytes in PROGMEM, and accessing its entries via pgm_read_byte() calls.
// Sketch that accepts a number k via serial input, and responds with
// the k-th set of numbers from among some sets of numbers stored in
// PROGMEM.  This avoids copying the array data into RAM.  jiw 31 Oct 2016

#include <Streaming.h>  // Ref: http://arduiniana.org/libraries/streaming/

// Set up datatext in PROGMEM
const byte L1[] PROGMEM = { 102, 103, 112, 113, 116, 117, 146, 147, 148,
                149, 160, 161, 28, 29, 58, 59, 72, 73, 0};

const byte R1[] PROGMEM = { 124, 125, 128, 129, 134, 135, 136, 137, 172,
                173, 40, 41, 46, 47, 84, 85, 90, 91, 0};

const byte L2[] PROGMEM = { 152, 153, 156, 157, 158, 159, 160, 161, 144,
                145, 118, 119, 104, 105, 102, 103, 68, 69, 64,
                65, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 0};

const byte R2[] PROGMEM = { 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 52,
                53, 80, 81, 92, 93, 90, 91, 132, 133, 130,
                131, 168, 169, 170, 171, 172, 173, 140, 141, 0};
const  void* Addrs[] = { L1, R1, L2, R2 };
enum { nAddrs = sizeof Addrs / sizeof Addrs[0] };

void prompt() {
  Serial << endl << "Please enter item number from 1 to " << _DEC(nAddrs) << ": ";
}

void setup() {
  Serial.begin(115200);         // init serial port
  prompt();         // Issue initial prompt
}

void loop() {
  char c, d;
  while (Serial.available()) { // Get characters
    c = Serial.read();
    if (c >= '0' && c <= '9') {
      Serial << c << endl;  // Echo the entered digit
      d = c - '0' - 1;
      if (d>=0 && d < nAddrs) {
        byte k=0, t = pgm_read_byte(Addrs[d]);
        Serial << "Set #" << _DEC(d+1) << ": ";
        while (t) {
          Serial << _HEX(t) << ' ';
          t = pgm_read_byte(++k + Addrs[d]);
        }
        Serial << endl;
      }
      prompt();         // Issue prompt after any digit
    }
  }
}

Thank you very much for your extensive answer. You just fixed my problems. "pixels.show():  unsigned long now=millis(); while (now==millis());" did the thing. Also thanks for the suggentions regarding the pixel definitions

with "const byte L1[] = (160, 161, 146, 147, 116, 117, 102, 103, 72, 73, 58, 59, 28, 29, 148,
149, 112, 113, 0);" I get "initializer fails to determine size of "L1". I also don't really get the PROGMEM thing.

@proto, those (...) initializers should have been  {...}.  (Now corrected in answer.)  See example program now at end of answer for use of pgm_read_byte() to get data from a PROGMEM array.  It ran ok on a Nano. Note, feel free to upvote answer

upvoted already but because I have under 15 rep it isn't viewed in public ;)

When I'm trying it like this I get the error:
invalid conversion from 'const byte* {aka const unsigned char*}' to 'byte* {aka unsigned char*}' [-fpermissive]

    #include <ESP8266WiFi.h> //WiFi
    #include <Adafruit_NeoPixel.h> //LEDs

    // 1
    const byte L1[] = {160, 161, 146, 147, 116, 117, 102, 103, 72, 73, 58, 59, 28, 29, 148,  149, 112, 113, 0};
    const byte R1[] = {172, 173, 134, 135, 128, 129, 90, 91, 84, 85, 46, 47, 40, 41, 136, 137, 124, 125, 0};
...
    const byte *digitsL[] = {L0, L1, L2, L3, L4, L5, L6, L7, L8, L9};
    const byte *digitsR[] = {R0, R1, R2, R3, R4, R5, R6, R7, R8, R9};

    void loadDigit(byte *pixelList) {
      for (byte j=0; pixelList[j]; ++j)
        individualPixels[pixelList[j]] = 1;
    }

    void print_numbers(byte num){
      if (num>9){
        loadDigit(digitsL[num/10]); // Write tens digit
      }
      else {
      loadDigit(digitsR[num%10]);  // Write units digit
      }
    }

    void seconds(){
    turnOff();
    print_numbers(byte second());
    //print_numbers(second());
    neoPixler();
    }

EDIT:
It works when I add "const" to the loadDigit
    //0
    const byte L0[] = {156, 157, 158, 159, 160, 161, 152, 153, 110, 111, 108, 109, 66, 67, 64, 65, 144, 145, 118, 119, 100, 101, 74, 75, 56, 57, 24, 25, 26, 27, 28, 29, 0};
    const byte R0[] = {168, 169, 170, 171, 172, 173, 140, 141, 122, 123, 96, 97, 78, 79, 52, 53, 132, 133, 130, 131, 88, 89, 86, 87, 44, 45, 36, 37, 38, 39, 40, 41, 0};
    //1
    const byte L1[] = {160, 161, 146, 147, 116, 117, 102, 103, 72, 73, 58, 59, 28, 29, 148,  149, 112, 113, 0};
    const byte R1[] = {172, 173, 134, 135, 128, 129, 90, 91, 84, 85, 46, 47, 40, 41, 136, 137, 124, 125, 0};

  void loadDigit(const byte *pixelList) {
      for (byte j=0; pixelList[j]; ++j)
        individualPixels[pixelList[j]] = 1;
    }
    void print_numbers(byte num){
      if (num>9){
        loadDigit(digitsL[num/10]);
        loadDigit(digitsR[num%10]);
        }
      else {
        loadDigit(digitsR[num%10]);
      }
    }
    void seconds(){
      s=second();
      turnOff();
      print_numbers(s);
      neoPixler();
    }

NTP is a protocol implemented over UDP which is a connectionless protocol.  If packets are lost then neither the client nor the server will be aware of their loss.  So on top of everything else that might be wrong your data source may also be injecting additional errors.  You should take the time from a timer on the board and update it from NTP when you receive data.

That's what TimeLib.h does.  It syncs at intervals, and the setSyncInterval(3000) statement sets the interval to 3000 seconds, or 50 minutes.  The default sync interval is 5 minutes.  Between syncs, TimeLib depends on millis().