text:
Concatenate string constants
Please take a look at following example (I have Java background):
const char* BT_ADDRESS = "abcd,ef,ghijkl";

void bar(const char* string) {
  ...
}

void foo() {
   bar("AT+BIND=" + BT_ADDRESS);
   bar("AT+LINK=" + BT_ADDRESS);
}

How to achieve this with "Arduino-C++" so BT_ADDRESS only has to be entered at one location?

That depends on what print does.

There is, as you may expect with C, many different ways of doing this.
The simplest is probably to use, instead of a const variable, a preprocessor macro.
In C you can concatenate string literals like this:
print("AT+BIND=" "abcd,ef,ghijkl");

Note the lack of anything but spaces between the strings - they are concatenated together. You can even do it on separate lines - it's a technique that is great for incredibly long strings.
Now you can, of course, replace one of those with a preprocessor macro:
#define BT_ADDRESS "abcd,ef,ghijkl"
print("AT+BIND=" BT_ADDRESS);
print("AT+LINK=" BT_ADDRESS);

The preprocessing replaces BT_ADDRESS with the string literal "abcd,ef,ghijkl" and all is well.
Other options, depending on what print does, is to expand it to take two const char * parameters and deal with them both separately.  For instance, you might have:
void print(const char *command, const char *data) {
    Serial.print(command);
    Serial.println(data);
}

print("AT+BIND=", BT_ADDRESS);

If you don't know how many parameters you may want to pass you could use variadic arguments:
#include <stdarg.h>

void print(int count, ...) {
    va_list args;
    va_start args, count);

    for (int i = 0; i < count; i++) {
        const char *arg = va_arg(args, const char *);
        Serial.print(arg);
    }
    va_end(args);
}

print(2, "AT+BIND=", BT_ADDRESS);

Yet another option is to pre-format the data into a single string using the various string operators.  For example:
int len = strlen("AT+BIND=") + strlen(BT_ADDRESS);
char temp[len + 1]; // Be sure to keep space for the terminating NULL.
strcpy(temp, "AT+BIND=");
strcat(BT_ADDRESS);
print(temp);

I could go on all night with different options...  The first one using the preprocessor is probably easiest though.

Get rid of strange print() and use standard stdout, fprintf() and % format tokens.
#include <stdio.h>
#include <Stream.h>

// printf to file support http://arduino.cc/playground/Main/Printf
// we need fundamental FILE definitions and printf declarations
// apparently it eats 1k FLASH by saves to much copy&paste and hopefully even FLASH

// create a output function
// This works because Serial.write, although of
// type virtual, already exists.
static int stream_putchar (char c, FILE *stream) {
    ((Stream*)(stream->udata))->write(c);
    return 0;
}

void SetupFileStream(FILE* file, Print* stream) {
    fdev_setup_stream(file, stream_putchar, NULL, _FDEV_SETUP_WRITE);
    file->udata = stream;
}

#ifdef UDRE0
// non interrupt transmit function
static int uart_putchar (char c, FILE *stream) {
    volatile byte *ucsrna = (byte*)(stream->udata);
    while ( !bitRead( ucsrna[0], UDRE0) ) {;}  // wait for transmit buffer is empty
    ucsrna[&UDR0-&UCSR0A] = c;
    return 0;
}

void SetupUartStream(FILE* file, volatile byte *ucsrna) {
    fdev_setup_stream(file, uart_putchar, NULL, _FDEV_SETUP_WRITE);
    file->udata = (void*) ucsrna;
}
#endif

#define INFO(fmt, args...) \
    fprintf_P(stderr, PROGSTR("INFO: " fmt), ## args);

// create a FILE structure to reference our UART output function in main project file
static FILE myStdOut = {0};
void setup() {
....
    Serial.begin(19200);
    SetupUartStream(&myStdOut, &UCSR0A);   // when debugging in AvrStudio then debugger is saturated by debug messages in user data empty interrupt handler if used buffered stream output
    // The uart is the standard output device STDOUT
    stdout = &myStdOut;
    stderr = stdout;
...
}

....
const char* BT_ADDRESS_RAM = "abcd,ef,ghijkl";
const char* PROGMEM BT_ADDRESS_FLASH = "abcd,ef,ghijkl";

INFO("AT+BIND=%s", BT_ADDRESS_RAM);
INFO("AT+BIND=%S", BT_ADDRESS_FLASH);

print was just an example name of a method.

If print() is just example and you need concatenated string (not streamed output) then you can use standard sprintf(), strcat() or so. Because you have initialized variable const char* you must do in runtime, bar("AT+LINK=" + BT_ADDRESS) is attempt to do it in compilation time.

Concatenating at compilation time (where possible) is what I need.

Then you can use:
#define BT_ADDRESS "abcd,ef,ghijkl"
bar("AT+BIND" BT_ADDRESS);
But you should clarify what means entered at one location, because it can mean to avoid copy pasting or to save FLASH memory avoiding duplicate strings there.


text:
two dimensional array
how can i store serial port available test to a two dimensional array. strings are separated with Z and end of text with #
pls help if anyone alrdy a solution
i am posting my program here
  String readstr;
  String finalstr;
  char *messages[][20] = { "" };
  int i, k = 0, lp;
  char chArray[] = "hai";
  String str(chArray);

  void setup() {
      Serial.begin(9600);
      Serial.println("System ready........"); // so I can keep track of what is loaded
  }

  void loop()
  {
      int flag = 0;
      while (Serial.available() > 0)
      {
          char c = Serial.read();  //gets one byte from serial buffer
          if (c == '#')
          {
              finalstr = readstr;
              readstr = "";
              flag = 1;
          }                 // I am getting data here on #
          else    // and is available with finalstr
          {
              readstr += c;     //makes the string readstr
          }
      }

      if (flag == 1)    // once data is available and terminated with #
      {
          int j = 0, l = 0;
          flag = 0;
          //Serial.print(finalstr.length());
          for (i = 0; i < finalstr.length(); i++)     //want to split in to strings
          {
              //Serial.println(finalstr.length());
              // Serial.println(i);
              if ((finalstr[i] != 'Z'))          // if any char is Z, then split
              {
                  // Serial.println(finalstr[3]);
                  messages[j][l] = finalstr[i];          // rearanging in to String messages
                  chArray[j] = finalstr[i];
                  messages[j][l] = '\0';
                  Serial.println(messages[j][i]);    // here it is not working
                  l++;
                  // Serial.println(j);
              }
              else
              {
                  l = 0;
                  j++;
                  String str(chArray);
                  // strncpy(messages[k],chArray,str.length());   // this is not working need help
                  //  Serial.println(messages[0]);
                  //delay(2000);
                  Serial.println(k);
                  k++;
                  //Serial.println(str);
              }

          }
          for (i = 0; i < j; i++)
          {
              Serial.println(messages[i]);    // I am getting here garbage value
          }
          k = 0;
          j = 0;
          l = 0;
      }
  }

is this a school assignment? ........... what is the problem?  ....... do you get errors? ..... please use the edit button to add information to your post

Hi sir,  thinks for your reply.
I want to split serially available text data to number of strings based on the separator character Z and end of data #
pls advice me to save the character data parsed to string array

source: Stack Exchange

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

sort: votes


text:
Blinking 2 LED having input from serial monitor
Sir while entering the values on the serial monitor, I ask the user to enter the value for red led voltage(0-255) then again ask for yellow at the red voltage asking it produces the user to  put the value, after that it asks for yellow led input but the time to enter the value for yellow led input is very less and so it does not get entered and the futher program starts. So only red led works where as Yellow does not.
int REDledpin=9;        //RED led on pin 9 of the uno board.
int YELledpin=7;        //YELLOW led on pin 8 of the uno board.
int REDonleddelay=500;  //The red led will be on for 500 ms.
int REDoffleddelay=500; //The red led will be off for 500 ms.
int YELonleddelay=600;  //The YELLOW led will be on for 600 ms.
int YELoffleddelay=600; //The YELLOW led will be off for 600 ms.
int countredled=5;        //The RED LED count variable
int countyellowled=5;     //The YELLOW LED count variable
String red="Red led is blinking";
String Yellow="Yellow led is blinking";
int redintensity;
int yellowintensity;

void setup() {
  Serial.begin(9600);
  pinMode(REDledpin,OUTPUT);
  pinMode(YELledpin,OUTPUT);

  Serial.println("How much voltage you want to apply to the red LED (0-255)?");
  while(Serial.available()==0){}
  redintensity= Serial.parseInt();

  Serial.println("How much voltage you want to apply to the yellow LED (0-255)?");
  while(Serial.available()==0){}
  yellowintensity = Serial.parseInt();

}

void loop() {
Serial.println(red);
for(int j=1;j<=countredled;j=j+1)
  {
    Serial.print("The red LED blink star: ");
    Serial.println(j);
    analogWrite(REDledpin,redintensity);
    delay(REDonleddelay);
    analogWrite(REDledpin,0);
    delay(REDonleddelay);
  }

Serial.println(" ");
Serial.println(Yellow);
  for(int j=1;j<=countyellowled;j=j+1)
  {
   Serial.print("The yellow LED blink stars");
   Serial.println(j);
   digitalWrite(YELledpin,yellowintensity);
   delay(YELonleddelay);
   digitalWrite(YELledpin,0);
   delay(YELoffleddelay);
  }
 Serial.println(" ");
}

add while (Serial.read() != -1); after parseInt() to read the line termination characters

@Juraj was on the right track however the end-of-line characters for example may not be buffered and the problem could continue.
The correct approach is the wait for the end-of-line character specifically.  Let's take the easy way out and use Serial.readStringUntil
#define EOL_CHAR '\n'

void setup() {
  Serial.begin(9600);
  pinMode(REDledpin,OUTPUT);
  pinMode(YELledpin,OUTPUT);

  Serial.println("How much voltage you want to apply to the red LED (0-255)?");
  while(Serial.available()==0){}
  redintensity= Serial.parseInt();

  Serial.readStringUntil(EOL_CHAR); // clear serial buffer to end of line character

  Serial.println("How much voltage you want to apply to the yellow LED (0-255)?");
  while(Serial.available()==0){}
  yellowintensity = Serial.parseInt();

}

This all depends on what you're Serial Monitor is sending as a new line; it could be CR (\r), LF (\n) or CRLF (\r\n), so change the EOL_CHAR value accordingly depending on your serial monitor setup.

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


text:
How to convert a string to long int?
I'm new to Arduino and my first project is an RFID reader. since I need a lot of known tags list , i have a problem with not enough memory. for that reason I want to convert strings like :  "426d9244", "1265dd39"... to a long int. I know it's been asked but as a new programer I find it hard to understand. an example would be very appreciated also.

You could use the atol() function. However, I think that is not your problem. Perhaps you have blocks of code that is repeated a few times. Do you use the Serial.println in combination with the F() macro?

If all those are known tags, you can put them in the source code as
32 bit integers. No
need to convert. Or rather, let the compiler do the conversion:
const uint32_t ID_num[ARRAYSIZE] PROGMEM = {
    Oxbcc0f1c3, Ox821a7d39, Ox4924887c, ...
};

When you read a tag number in hex, in order to compare it with the known
tags, you convert it to the same type using strtoul() from
avr-libc:
uint32_t tag_id = strtoul(tag_string, NULL, 10);

Actualy , it did the compare without even converting the tag_id... , it works perfect now,  HOGE thanks!!!

Please "accept" the answer to show that it helped you. Thanks!

It's a bit unclear what you want to do with the 'd'or 'dd'in between.
You can check some functions:

strtok: which can split a string based on delimiters (in your case probably 'd'). Than you get an array of strings (e.g. for the first: { "426", "9244"}.
For each string ("426" and "9244") you use function atol to convert it into a long integer.


text:
Can't write to serial immediately from PC to Arduino nano via pl2303 usb to ttl converter
Goal:
I am trying to send some characters to Arduino through serial from PC via a Prolific PL2303 USB to TTL converter(Chinese clone).
I have wrote a simple sketch(attached bellow) which should light up the LED if 'n' is found or should switch the LED off if 'f' is found from serial.
What's Happening:
I opened up the serial monitor. Send a character(say 'n' which should light up the LED). But nothing happened though the RX/TX LEDs flashed. Then I re opened the serial monitor. And just after re opening the serial monitor LED light up! Every time when I issue a character from serial monitor nothing happens. But just after re opening the monitor character is sent.
H/W Connection:

Arduino Vin -> LiPo positive rail(+11V)
Arduino GND -> LiPo negative rail(GND)
Prolific GND -> Arduino GND
Prolific RX -> Arduino TX
Prolific TX -> Arduino RX

Arduino Sketch:
int led = 13;

void setup() {
  // put your setup code here, to run once:
  pinMode(led, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  if(Serial.available() > 0){
    char bytesReceived = Serial.read();
    Serial.println(bytesReceived);

    if(bytesReceived == 'n'){
      digitalWrite(led, HIGH);
    }
    else if(bytesReceived == 'f'){
      digitalWrite(led, LOW);
    }
  }
}

Additional Notes:

Platform Windows 10
Installed Prolific PL2303 driver from here
This code is working using USB cable provided with Arduino.(I need longer cable)

Can't understand why this strange thing is happening. Any kind of help will be appreciated.
Thanks!

When I run the script first time .... what does that mean? .... please describe in detail the steps that you follow to run the script "the first time"

why are you using a python script during testing? .... open a serial monitor window and press keys on a keyboard

That means I have to run the script twice to make the serial transmit to happen:
$ python testscript.py
$ python testscript.py

Also tested with arduino serial monitor. Showing same behavior. If I open serial monitor and send 'n' nothing happens(LED should light up). But after re opening the serial monitor LED lights up(Character is sent).
Actually I am doing a pyqt project with this hence testing with python script.
@jsotola

This sounds like a problem with the Prolific clone.  I know Prolific have been fighting clones of their chips with tweaks to their drivers, so it may be that your Prolific chip is not a real one and won't work right. Try a different adaptor, like an FT232 one, or bend an Arduino without the main MCU (or the main MCU held in RESET) to the use for testing.

I have experienced similar behavior with clone chips. What worked for me is using ferrite choked USB cables similar to these; as you referenced as well, I observed that the problem occurs with either longer cable, or with cables without ferrite chokes on them. This might have to do with the PCB or the cheap chips being prone to electromagnetic interference.

I have purchased a 5m USB extension cable. It's working fine.


text:
nrf24l01+ contradicting itself?
I have recently bought a few of these chips on boards along with some "adapter boards" which supposedly regulates the 5v to propper 3.3v with the required capacitors.
So power supply shouldn't be a problem although I haven't tried with a separate power supply.
Ok, so I like to build my stuff from scratch to really know everything that's going on so I'm not using a library for this chip but I've read the datasheet in it's entirety and have understood all the features.
At first after going through every option one of the modules was successfully sending out packets as indicated by the TX_DS interrupt but nothing was showing up on the one in receiver mode, and after lots of checking I chose to disable every feature and managed to finally get some action as the receiver interrupted each time the transmitter sent out a packet with no CRC and no ACK.
But now there's an issue, the datasheet clearly states:

The RX_DR IRQ is asserted by a new packet arrival event.
      The procedure for handling this interrupt should be:
1) read payload through SPI,
2) clear RX_DR IRQ,
3) read FIFO_STATUS to check if there are more payloads available in RX FIFO,
4) if there are more data in RX FIFO, repeat from step 1).

However upon getting the interrupt and reading out 33 bytes with the command, the status register reads 4E (0100 1110) saying that the interrupt was indeed RX_DR but also the pipe number bits are all on meaning an empty RX FIFO. The following 32 bytes read 0.
How can this be? Has anyone experienced something similar?
UPDATE: Tested with separate power supply on RX side, issue still stands.
Pictures: https://1drv.ms/f/s!Ag6xBMoahJ8xkOkWMG89RIAa1m71Kw
Arduino code: (feel free to correct me I'm no expert in this language :p)
Main
void setup() {
  attachInterrupt(digitalPinToInterrupt(radio.irq), interrupt, FALLING);
  Serial.begin(9600) ;
  Serial.write("\n    ----Boot----\n\nInitializing radio...\n");

  //Starts radio as PRX
  //Sets channel
  //Sets bitrate to 1Mbps
  if (radio.init()) {
    Serial.println("Radio ready.\n\n ----Boot complete----\n\n");
  } else {
    Serial.write("Couldn't initialize radio!\n\n  ----Boot failed----\n");
    return;
  }
  delay(10);
  digitalWrite(9, HIGH);
}

void loop() {
}

void interrupt() {
  Serial.write("\nINTERRUPT\n");
  digitalWrite(9, LOW);

  radio.readRegister(0x17, 2, true, BIN);
  radio.readRXpayload(true);
  radio.clearIRQ();

  digitalWrite(9, HIGH);
}

Radio class
#include "BitUtils.h"

BitUtils utils;

uint8_t* tmp = (uint8_t*)malloc(sizeof(uint8_t) * 33);
uint8_t initialPipe0[5] = {0x28, 0x18, 0xdb, 0xc2, 0x86};
uint8_t beaconAddress[5] = {0x29, 0x26, 0x13, 0x12, 0x00};

class Radio {
  public:
    uint8_t nullmsg[1] = {0x00};

    uint8_t rx_config[1] = {0b00100011}; //0x00
    uint8_t tx_config[1] = {0b00100010}; //0x00
    uint8_t aa_config[1] = {0b00000000}; //0x01
    uint8_t ch_config[1] = {0b00110100}; //0x05
    uint8_t rf_config[1] = {0b00000110}; //0x06
    uint8_t features_config[1] = {0b00000000}; //0x1D

    uint8_t clear_irq[1] = {0b01110000}; //0x07

    uint8_t clk = 13;
    uint8_t miso = 12;
    uint8_t mosi = 11;
    uint8_t slaveselect = 10;
    uint8_t chipenable = 9;
    uint8_t irq = 2;

    SPISettings spiConfig = SPISettings(2000000, MSBFIRST, SPI_MODE0);

    boolean init() {
      noInterrupts();

      pinMode(clk, OUTPUT);
      pinMode(miso, INPUT);
      pinMode(mosi, OUTPUT);
      pinMode(slaveselect, OUTPUT);
      pinMode(chipenable, OUTPUT);
      pinMode(irq, INPUT);
      digitalWrite(clk, LOW);
      digitalWrite(slaveselect, HIGH);
      digitalWrite(chipenable, LOW);
      delay(11);

      transfer(nullmsg, 1, tmp);
      if (tmp[0] != 0b00001110) {
        return false;
      }

      writeRegister(0x00, rx_config, 2); Serial.print("0x00: ");
      readRegister(0x00, 2, true, BIN);
      writeRegister(0x01, aa_config, 2); Serial.print("0x01: ");
      readRegister(0x01, 2, true, BIN);
      writeRegister(0x05, ch_config, 2); Serial.print("0x05: ");
      readRegister(0x05, 2, true, BIN);
      writeRegister(0x06, rf_config, 2); Serial.print("0x06: ");
      readRegister(0x06, 2, true, BIN);
      writeRegister(0x1D, features_config, 2); Serial.print("0x1D: ");
      readRegister(0x1D, 2, true, BIN);

      pipeAddress(initialPipe0, 0);
      pipeAddress(beaconAddress, 1);

      Serial.print("Pipe 0 address: ");
      readRegister(0x0A, 6, true, HEX);
      Serial.print("Pipe 1 address: ");
      readRegister(0x0B, 6, true, HEX);

      delay(2);
      interrupts();
      return true;
}

    //    -- Operations --

    void clearIRQ() {
      writeRegister(0x07, clear_irq, 2);
      Serial.println("Cleared IRQ");
    }

    void sendTXpayload(uint8_t data[], boolean ack) {
      uint8_t message[33] = {0b10100000};
      if (!ack) {
        message[0] = 0b10110000;
      }
      for (int i = 31; i > -1; i--) {
        message[32 - i] = data[i];
      }

      transfer(message, 33, tmp);
      pulseCE(12);
      delay(2);
    }
    void readRXpayload(boolean report) {
      uint8_t message[33] = {0b01100001};

      transfer(message, 33, tmp);
      if (report) {
        utils.prtArr(tmp, 33, HEX);
      }
    }

    void mode(char m) {
      digitalWrite(chipenable, LOW);

      if (m == 't') {
        writeRegister(0x00, tx_config, 2);
        Serial.println("Set tx mode.");
      }
      if (m == 'r') {
        writeRegister(0x00, rx_config, 2);
        Serial.println("Set rx mode.");
      }
    }

    void pipeAddress(uint8_t* address, uint8_t number) {
      uint8_t pipeNumber = 0x0A + number;
      for (int i = 4; i > -1; i--) {tmp[4 - i] = address[i];}

      if (number < 2) {
        writeRegister(pipeNumber, tmp, 6);
      }else{
        writeRegister(pipeNumber, address, 2);
      }
    }

    void sendTo(uint8_t* address) {
      for (int i = 4; i > -1; i--) {
        tmp[4 - i] = address[i];
      }
      writeRegister(0x10, tmp, 6);
      Serial.print("TX Address: ");
      readRegister(0x10, 6, true, HEX);
    }

    void setChannel(uint8_t ch) {
      writeRegister(0b00000101, new uint8_t[1] {ch}, 2);
      Serial.write("Frequency set to: ");
      Serial.print(2400 + tmp[1], DEC);
      Serial.println("MHz");
    }

    //    -- Low operations --

    void readStatus(boolean prt) {
      transfer(nullmsg, 1, tmp);
      if (prt) {
        utils.prtArr(tmp, 2, BIN);
      }
    }
    void readRegister(uint8_t address, uint8_t amount, boolean prt, uint8_t format) {
      uint8_t message[amount] = {address};
      transfer(message, amount, tmp);

      if (prt) {
        utils.prtArr(tmp, amount, format);
      }
    }
    void writeRegister(uint8_t address, uint8_t* data, uint8_t amount) {
      uint8_t message[amount] = {(uint8_t)(0b00100000 | address)};
      for (uint8_t i = 1; i < amount; i++) {
        message[i] = data[i - 1];
      }

      transfer(message, amount, tmp);
    }
    void pulseCE(int duration) {
      digitalWrite(chipenable, HIGH);
      delayMicroseconds(duration);
      digitalWrite(chipenable, LOW);
    }

    //    -- Bidirectional SPI bus --

    void transfer(uint8_t* data, uint8_t amount, uint8_t* output) {
      SPI.beginTransaction(spiConfig);
      digitalWrite(slaveselect, LOW);
      delayMicroseconds(1);

      for (uint8_t i = 0; i < amount; i++) {
        output[i] = SPI.transfer(data[i]);
      }

      delayMicroseconds(1);
      digitalWrite(slaveselect, HIGH);
      SPI.endTransaction();
    }
};

Can you post the Arduino code?

@MichaelT edited in the code

I am wondering if your issue is related to the problem I am having with my nRF24L01's? See https://arduino.stackexchange.com/questions/85874/nrf24l01-continuously-reading-closed-pipe

My advice would be to strip out all of the unnecessary code to make a minimal complete example (MCVE).  The nRF24L01 is not so complicated when you get to know the data registers, and unfortunately that's where a lot of people get stuck, by trying to use the libraries without reading the datasheet.  However, the posted code suggests that you have done your homework.  This is how I set up nRF24L01 to use IRQ (chronological order from top to bottom):
// Begin SPI
// Register 0x0A: set receiver addresses
// Register 0x11: set payload number of bytes

// flush RX (spi transfer B11100010) and TX (spi transfer B11100001)

// attach ISR on IRQ digital input pin.

// start the main program loop

This is the ISR called:
void isr(){
// Read payload data
digitalWrite(CSN_pin, LOW);
 data_in[0] = SPI.transfer(B01100001); //read payload register
 data_in[1] = SPI.transfer(B00000000);
 data_in[2] = SPI.transfer(B00000000);
 data_in[3] = SPI.transfer(B00000000);
 // etc
digitalWrite(CSN_pin, HIGH);

// flush RX
digitalWrite(CSN_pin, LOW);
 SPI.transfer(B11100010);//flush RX
digitalWrite(CSN_pin, HIGH);

// Read status register 0x07
digitalWrite(CSN_pin, LOW);
 SPI.transfer(0x07);
 reg7 = SPI.transfer(0x00);
digitalWrite(CSN_pin, HIGH);

reg7 |= B01000000; // RX_DR set bit 6
// write back to status register
digitalWrite(CSN_pin, LOW);
 SPI.transfer(0x20+0x07);
 SPI.transfer(reg7);
digitalWrite(CSN_pin, HIGH);
}

Edit: bit 6 of the status register is the RX_DR flag.  If this is 1 (which is the case in the OP's example), then the data have not been received.  Set bit 6 to clear the interrupt.

I thought RX_DR stood for Data Ready, and in page 30 they state:
After the packet is validated, Enhanced ShockBurst™ disassembles the packet and loads the payload into the RX FIFO, and asserts the RX_DR IRQ.

You're right, but the data sheet (p59) also says RX_DR=0 is asserted when new data arrive in RX FIFO, write 1 to clear bit.  This is what the code in my answer does.  Remember also MASK_RX_DR=0, but that's default on startup.

That would be odd no? The reset values for the IRQs are 0, and I do get the interrupt when a packet is sent out by the other radio. RX_DR transitions to 1 in the status register, furthermore, upon writing 1 to clear the bit it does go back to 0. Don't know why they made it this way but at least this is what is happening with me. Main issue was asserted IRQ and rest of device stating empty FIFOs.

I just follow what the data sheet says.  The (pseudo) code written above does work, I use that with my own nRF24 projects.


text:
Problem with Arduino driver! Port option not visible. How to resolve it?
I am not able to upload sketch because my Windows 8.1 PC is not able to recognise it. It used to work fine but suddenly my driver disappeared from my device manager and no light is shown on the Arduino uno led also.
I tried to uninstall and install the Arduino IDE again but still didn't work.
Note:- whenever I connect the USB cable to my PC, I see a dim light glowing for few milli seconds.
Update:- Also my Arduino board is not dead since it worked when connected to other pc but not working with my windows pc.
What could be the problem? How do I install the port driver back?

Is it a Genuine Arduino or a cheap Chinese clone?

cheap Chinese i think

If you bought it off Amazon or eBay then it will be. Chances are it's dead. Get a new one.

got if from souq, yea have to check. or maybe problem in usb cable?

i think you have unsigned drivers see https://forum.arduino.cc/index.php?topic=205837.0

"dim light glowing" says "dead board" to me.  Probably CH340G. Probably breathed on it wrong.

I changed my pc setting to allow unsigned driver but still not working. Board is not dead since it worked when connected to other pc.

but then, the power LED is lit?

its working now

Problem solved
I connected the arduino with my motor shield on top of it which stopped the power supply from pc. Now its working fine.

Sometimes Windows will disable a given USB port if it think's the attached device is malfunctioning.  Try using a different USB port on your PC.  If that does't work try
rebooting your PC.

I think that's the problem. I connected the Arduino to another PC and it worked so problem is not in the board but in my pc driver. Even using different usb port didn't work. How do I reboot the pc exactly?

No LED = no power being supplied. That would imply a bad port, a bad cable, or a damaged board (open circuit due to a damaged trace or part).
A brief LED can mean the board was drawing too much current and the computer shut down that port to protect itself. That would imply a damaged board (short circuit due to burned out part, bad wiring if you have any on the board, or something conductive touching your board where it shouldn't (anywhere!).
Try substituting ports, cables, & Arduinos - one thing at a time - until something changes to give you a clue to what component is faulty.
You might also have a driver problem, but a good board/cable/port should power up anyway.

Problem is in driver. I connected the Arduino board to another PC and it started working but not working in my pc.


text:
Error - invalid conversion from 'char' to 'const char*', Not able to connect on pubnub server using node mcu
I have node mcu with ESP8266 wifi module. When i am trying to upload an example code then its not working.
This is the Error:-
inline PubSubClient* PubNub::subscribe(const char* channel, int timeout)

                      ^

exit status 1
invalid conversion from 'char' to 'const char*' [-fpermissive]

Code:-
#include <ESP8266WiFi.h>
#define PubNub_BASE_CLIENT WiFiClient
#define PUBNUB_DEFINE_STRSPN_AND_STRNCASECMP

#include <PubNub.h>

const char *ssid =  "mym404";     // replace with your wifi ssid and wpa2 key
const char *pass =  "786110786";

char pubkey = 'pub-c-4a9cdbca-5688-4939-a852-f63cf6743980';
char subkey = 'sub-c-9b4067ae-1293-11e9-b4a6-026d6924b094';

char pubchannel = 'demo_keyset';
char subchannel = 'demo_keyset';

void setup() {
    /* For debugging, set to speed of your choice */
    Serial.begin(9600);

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

       WiFi.begin(ssid, pass);
       while (WiFi.status() != WL_CONNECTED)
          {
            delay(500);
            Serial.print(".");
          }
      Serial.println("");
      Serial.println("WiFi connected");

    /* Start the Pubnub library by giving it a publish and subscribe
       keys */
    PubNub.begin(pubkey, subkey);
}

void loop() {
    /* Maintain DHCP lease. For other HW, you may need to do
       something else here, or maybe nothing at all. */

    /* Publish message. You could use `auto` here... */
    PubNonSubClient *pclient = PubNub.publish(pubchannel, "\"message\"");
    if (!pclient) return;
    PublishCracker cheez;
    cheez.read_and_parse(pclient);
    /** You're mostly interested in `outcome()`, and,
        if it's "failed", then `description()`.
    */
    Serial.print("Outcome: "); Serial.print(cheez.outcome());
    Serial.print(' '); Serial.println(cheez.to_str(cheez.outcome()));
    Serial.print("description: "); Serial.println(cheez.description());
    Serial.print("timestamp: "); Serial.println(cheez.timestamp());
    Serial.print("state: "); Serial.print(cheez.state());
    Serial.print(' '); Serial.println(cheez.to_str(cheez.state()));
    pclient->stop();

    /* Wait for news. */
    PubSubClient *sclient = PubNub.subscribe(subchannel);
    if (!sclient) return; // error
    String msg;
    SubscribeCracker ritz(sclient);
    while (!ritz.finished()) {
        ritz.get(msg);
        if (msg.length() > 0) {
            Serial.print("Received: "); Serial.println(msg);
        }
    }
    sclient->stop();

    delay(1000);
}

Code is taken from pubnub arduino github example - https://github.com/pubnub/arduino/blob/master/examples/AdafruitFeatherM0WINC1500/AdafruitFeatherM0WINC1500.ino

are you able to compile PubNubDemo.ino?

change char * subchanel to const chat *  subchanel

Tried but now it gives this error - invalid conversion from 'int' to 'const char*' [-fpermissive] , even pubnubDemo.ino shows same error.

problem was in the declaration of API keys and channel on the above code
Here is the right code:-
const char * pubkey = "publisher key from your account";
const char * subkey = "subscriber key from your account";

const char * pubchannel = "demo_keyset";
const char * subchannel = "demo_keyset";


text:
Cheap Wired Multipoint Mesh Network
I'm looking to make a 15 x 15 grid of load sensors and RGB LEDs for an interactive dance floor. Each node will be driven by an arduino and the entire floor will be managed by a RaspberryPi. I'm trying to figure out the best way to have the nodes communicate with the Pi. Ideally the network would have these characteristics:

Low cost per node
Raspberry Pi as the master, arduino nodes as slaves
Ability to know where each node is in the grid
Healing: If a node goes down it doesn't take out all the others.
Can easily replace broken nodes
The electronics for each node will be ~12 inches apart
The master will be 5 - 10 feet away from the matrix.

So far I have been toiling over a few ides.
I2C
This would allow each node to be addressable, however, it seems that Arduino will only allow up to 127 addresses and this matrix will have at least 225 nodes.
SPI
If daisy chained it would be easy to know where each node is in the matrix. But if one node were to break all the nodes after it would stop communicating. (right?) I could have each row daisy chained separately, so if one goes down it only affects that row.
1-Wire
1-wire also looks promising. I'd have to figure out my own way of determining node placement, which could be achieved a variety of ways.
Custom Serial
Each node has a serial connection (rx/tx) for each of it's four sides. This would allow it to communicate to each of it's neighbors directly and pass along messages that are not addressed to it. If one node were to go down, the message would be automatically routed around the broken node since there are several paths to each destination. This option is a little crazy and I'd prefer to avoid something so custom and convoluted.
USB
This would require a USB hub in each node.
XBee
Too expensive.
Other thoughts or options?

Would they scale to a system of 225+ nodes in a close space?

Seems to me that an Arduino per node is not a cheap way to go. Those are fairly expensive general-purpose devices. Why not build a simpler custom board based on one of the AVR chips like an ATiny? If you're building 225 nodes then $30/node gets really expensive.

Ultimately doing a custom AVR per node is the plan. I'll just be prototyping it with arduino first. Each node doesn't even need to be smart, so it would be even better if I could find a simple way to mux/demux the input/output from each panel without a microcontroller.

I'd probably skip the self healing and do a daisy chained asynchronous serial (probably bit-bang in ATtiny).  Perhaps modeled on DMX LED rope byte-peeling you could do something where each node peels a byte of command off the front and adds a byte of sensor status to the end before forwarding the message.  A failure would mean one pixel goes dead (or stuck) and no data comes back, but you could easily see and replace that one.  Electrically  skip the grid and just do one snaking linear chain, or perhaps several if you can't move enough data on one line.

I think I would use RS-485.
With this standard, you can write your own communication-protocol and with arduino it is easy to use with the Serial class. As extensions for the Arduino you only use the MAX485 because it uses the UART-cip of the Arduino.
I have absolutely no experience with the rasperypi but I think it does also have an UART-Cip what would mean, that you can also connect the MAX485.

For I2C you can try http://www.linear.com/product/LTC4312
This will allow you to make two I2C networks to address all the nodes.
However, the wiring for I2C will be a nightmare, but it might be necessary if you want the nodes to be independent.

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


text:
Communication Protocol Best Practices and Patterns
Every time I design a serial protocol to be used between two arduinos, I feel a bit like I'm reinventing a wheel. I wonder if there are any best practices or patterns people follow. This question is less about the actual code, but more about the format of the messages.
For example, if I wanted to tell an arduino to flash it's first LED 3 times I might send:
^L1,F3\n

'^': starts a new command
'L': Defines the command, (L: target this command to an LED)
'1': Target the first LED
',': Command line separator, new value in this message to follow
'F': Flash sub-command
'3': 3 times (Flash the LED three times)
'\n': End the command

Thoughts? How do you usually approach writing a new serial protocol? What about if I wanted to send a query from arduino 1 to arduino 2 and then receive a response?

There are a lot of ways to write a serial protocol depending on what functionality you might want and how much error checking you need.
Some of the common things you see in point to point protocols are:
End of message
The simplest ASCII protocols just have an end of message character sequence, often \r or \n as this is what gets printed when the enter key is hit. Binary protocols might use 0x03 or some other common byte.
Start of message
The problem with just having end of message is that you don't know what other bytes have already been received when you send your message. These bytes would then be prefixed to the message and cause it to be interpreted wrongly. For example, if the Arduino just woke from sleep there might be some garbage in the serial buffer. To get around this you have a start of message sequence. In your example, ^,  in binary protocols often 0x02
Error Checking
If the message can be corrupted we need some error checking. This could be a checksum or a CRC error or something else.
Escape Characters
It could be that the checksum adds to a control character, such as the 'start of message' or 'end of message' byte, or the message contains a value equal to a control character. The solution is to introduce an escape character. The escape character is placed before a modified control character so that the actual control character is not present. E.g. if a start character is 0x02, using the escape character 0x10 we can send the value 0x02 in the message as the byte pair 0x10 0x12 (byte XOR control character)
Packet number
If a message is corrupted we could request a resend with a nack or retry message, but if multiple messages have been sent then only the latest message can be resent. Instead the packet can be given a number that rolls over after a certain number of messages. For example, if this number is 16, the transmitting device can store the last 16 messages send and if any were corrupted the receiving device can request a resend using the packet number.
Length
Often in binary protocols you see a length byte which tells the receiving device how many characters are in the message. This adds another level of error checking as if the correct number of bytes were not received then there was an error.
Arduino specific
When coming up with a protocol for Arduino the first consideration is how reliable is the communications channel. If you are sending over most wireless mediums, XBee, WiFi, etc, there is already built in error checking and retries and thus no point in putting these in your protocol. If you are sending over RS422 for a couple of kilometres then it will be necessary. The things I would include are the start of message and end of message characters, as you have. My typical implementation looks something like:
>messageType,data1,data2,…,dataN\n
Delimiting the data parts with a comma allows for easy parsing, and the message is sent using ASCII. ASCII protocols are great because you can type messages into the serial monitor.
If you want a binary protocol, maybe to shorten the message sizes, you will have to implement escaping if a data byte can be the same as a control byte. Binary control characters are better for systems where the full spectrum of error checking and retries is desired. The payload can still be ASCII if desired.

Isn't it possible that the garbage ahead of the real start of message code could contain a start of message control code? How would you deal with this?

@CMCDragonkai Yes this is a possibility, especially for single byte control codes. However if you encounter a start control code halfway through parsing a message, the message is discarded and parsing restarts.

I do not have any formal expertise on serial protocols, but I've used them quite a few times, and more or less settled on this scheme:
(Packet header)(ID byte)(data)(fletcher16 checksum)(Packet Footer)
I usually make the header 2 bytes and the Footer 1 byte. My parser will dump everything when it sees a new packet header, and attempt to parse the message if it sees a footer. If the checksum fails, it will not ditch the message, but continue adding until the footer character is found and a checksum succeeds. That way the footer only needs to be one byte since collisions don't disrupt the message.
The ID is arbitrary, sometimes with the length of the data section being the bottom nibble (4 bits). A second length bit could be used but I normally don't bother since the length does not need to be known to parse correctly, so seeing the right length come through for a given ID is just more confirmation that the message was correct.
The fletcher16 checksum is a 2 byte checksum with nearly the same quality as CRC but is much easier to implement. some details here. The code can be as simple as this:
for(int i=0; i < bufSize; i++ ){
   sum1 = (sum1 + buffer[i]) % 255;
   sum2 = (sum2 + sum1) % 255;
}
uint16_t checksum = (((uint16_t)sum1)<<8) | sum2;

I've also used a call and respone system for critical messages, Where the PC will send a message every 500ms or so until it gets an OK message with a checksum of the whole original message as data (including the original checksum).
This scheme is, of course, not well suited for being typed into a terminal like your example would be.  Your protocol seems pretty good for being limited to ASCII and I'm sure is easier for a quick project that you want to be able to directly read and send messages. For larger projects it is nice to have the density of a binary protocol and the security of a checksum.

Since "[your] parser will dump everything when it sees a new packet header" I wonder if this does not create problems if by chance the header is encountered inside of data?

@humanityANDpeace The reason for dropping it is that when a packet gets cut off it will never parse correctly, so when do you decide its garbage and move on? The easiest, and in my experience good enough, solution is to drop an bad packet as soon as the next header comes in. I've been using a 16 bit header without issue, but you could make it longer if certainty is more important that bandwidth.

So what you refere to as a header is somewhat of a Magic 16bit combination. i.e. 010101001 10101010, right? I agree it is only 1/256*256 change to hit, but it also disables ever using this 16bit inside your data, else it gets misinterpreted as a header and you discard the message, right?

@humanityANDpeace I know it's a year later, but you need to introduce an escape sequence. Before sending, the server checks the payload for any special bytes, then escapes them with another special byte. Client side, you have to put the original payload back together. This does mean that you cannot send fixed length packets and does complicate the implementation. There are many serial protocol standards to choose from that all address this. Here is a very good read on the topic.

If you're into standards, then you may take a look at ASN.1 / BER TLV encoding. ASN.1 is a language used to describe data structures, made specifically for communication. BER is a TLV method of encoding the data structured using ASN.1. Problem is that ASN.1 encoding may be tricky at best. Creating a full fledged ASN.1 compiler is a project in itself (and a particularly tricky one at that, think months).

It's probably better to keep just the TLV structure. TLV basically consists of three elements: a tag, a length and a value field. The tag defines the type of the data (text string, octet string, integer etc.) and the length the length of the value.
In BER the T also denotes if the value is a set of TLV structures itself (a constructed node) or directly a value (a primitive node). That way you can create a tree in binary, much like XML (but without the XML overhead).
Example:
TT LL VV
02 01 FF

is an integer (tag 02) with a length of the value of 1 (length 01) and value -1 (value FF). In ASN.1 / BER the integers are sign big endian numbers, but you can of course use your own format.
TT LL (TT LL VV, TT LL VV VV)
30 07  02 01 FF  02 02 00 FF

is a sequence (a list) with length 7 containing two integers, one with value -1 and one with value 255. The two integer encodings together make up the value of the sequence.
You can simply toss this into an online decoder too, aint that nice?

You can also use indefinite length in BER which will allow you to stream data. In that case you do need to parse your tree correctly though. I'd consider it an advanced topic, you need to know about breadth first and depth first parsing, for one.

Using a TLV scheme basically allows you to think of any kind of data structure and encode it. ASN.1 goes a lot further than that, giving you unique identifiers (OID's), choices (a lot like C-unions), includes of other ASN.1 structures etc. etc. but that may be overkill for your project. Probably the best well known ASN.1-defined structures today are the certificates used by your browser.

If not, you've got the basics covered. Your commands can be created and read by both humans and machines which is a big plus. You might add a checksum to detect a mal-formed command or one damaged in transit, especially if your channel includes long cable or a radio link.
If you need industrial strength (your device mustn't cause or allow someone to get hurt or die; you need high data rates, fault recovery, missing packet detection etc.) then look to some of the standard protocols and design practices.

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


text:
AttachInterrupt in a library
I'm having trouble adding attachInterrupt in a library that I am creating. I researched a lot, and I noticed that this is a common mistake, but do not quite understand the answers I found.
The error in question is this:
sketch_nov04a.ino: In function 'void setup()':
sketch_nov04a:10: error: argument of type 'void (Teste::)()' does not match 'void (*)()'

My library is as follows:
Teste.h
#ifndef TESTE_H
#define TESTE_H
#include <Arduino.h>

class Teste
{
public:
    volatile long lastWindIRQ;
    volatile byte windClicks;

  void wspeedIRQ();
};
#endif

Teste.cpp
#include "Teste.h"

void Teste::wspeedIRQ()
{
  if (millis() - this.lastWindIRQ > 10)
  {
    this.lastWindIRQ = millis();
    this.windClicks++;
  }
}

my implementation
#include <Teste.h>

Teste teste;

void setup()
{
  Serial.begin(9600);
  pinMode(2, INPUT);
  digitalWrite(2, HIGH);
  attachInterrupt(0, teste.wspeedIRQ, FALLING);
}

void loop()
{
  Serial.println(teste.windClicks);
  delay(3000);
}

EDIT: Updated the error and corrected the problem cited by Ignacio

The problem is that wspeedIRQ() is a member function (i.e. it's part of the Teste class), but attachInterrupt() expects a non-member function (i.e. a function which is static and/or not part of a class at all).
This is a very important distinction in C++ because it affects how the compiler calls the function behind-the-scenes. There is unfortunately no way to use a member function directly with attachInterrupt().
Various workarounds are possible though. The simplest is to write a wrapper function which calls the member function. For example:
Teste teste;

// This is a non-member function...
void isr()
{
    // ...which calls the member function:
    teste.wspeedIRQ();
}

void setup()
{
    //...

    // Setup interrupt to use a non-member function
    attachInterrupt(0, isr, FALLING);
}

As a side note, your implementation of wspeedIRQ() won't compile at the moment anyway. The reason is that this. is invalid. It's a pointer so the correct syntax is this->.
(In practice, you usually don't need to use this to access member data. C++ figures it out automatically, unless there's a naming conflict.)

Normally you should use digitalPinToInterrupt(pin) to translate the actual digital pin to the specific interrupt number not the pin switch comparison attachInturrupt( , , )that is limited to pin 2,3 on an arduino uno ...or if you spend more money well... here's a list.
Board                              Digital Pins Usable For Interrupts
Uno,    Nano, Mini, other 328-based 2, 3
Mega,   Mega2560, MegaADK           2, 3, 18, 19, 20, 21
Micro, Leonardo, other 32u4-based   0, 1, 2, 3, 7
Zero                                all digital pins, except 4
MKR1000 Rev.1                       0, 1, 4, 5, 6, 7, 8, 9, A1, A2
Due                                 all digital pins
                                    all digital pins (Only pins 2, 5, 7, 8,
                                    10,  11, 12, 13 work with CHANGE

delay() won't work b/c values won't return from millis() (don't ask why)
https://www.arduino.cc/en/Reference/AttachInterrupt explains how to use inturrupts like let me recite the beggining
Interrupts are useful for making things happen automatically in microcontroller programs, and can help solve timing problems. Good tasks for using an interrupt may include reading a rotary encoder, or monitoring user input.... blah blah
what pete didn't mention is what Interrupt Service Routines were... and how these special functions have unique limitations other functions like in c++ do not.... from c-strings to structs to overloading to f-structs to t-templates. ISR's are as short as possible and should not return anything! if your cheap and don't want to spend more than $5 for a arduino you can use sketch to use multiple isr's you can set them up as priority
but your non member functions should be volatile and global... and millis() relies on interrupts to count, so it will never increment inside an ISR. Since delay() requires interrupts to work, it will not work if called inside an ISR. micros() works initially, but will start behaving erratically after 1-2 ms. delayMicroseconds() does not use any counter, so it will work as normal. and .... global variables are used to pass data between an ISR and the main program. To make sure variables shared between an ISR and the main program are updated correctly, declare them as volatile.


text:
PHP/My SQL Database -> to Arduino Serial Monitor
I'm using this domain http://www.decathlon.commonarchitecture.ca/ to host my phpmyadmin database and php code. I would like to read a specific column of the database in the serial monitor, displaying each number one right after the other. I'm unsure of whether to work with a GSM shield, an Ethernet shield or an Arduino wifi shield. Here is my php code (indents are off I know):
<?php

 $dbhost = "mysql.commonarchitecture.ca";
 $username = "arduinodb";
 $password = "*******";
 $db = "arduinodb" ;

    mysql_connect("$dbhost" , "$username" , "$password");
     //echo "Connected" ;

    //select db
    mysql_select_db($db);
    //echo "Connected to db" ;

  $sql="SELECT * FROM data";

  $records=mysql_query($sql);

 ?>

 <!DOCTYPE html>

 <title> Consumption Data </title>

 Day
 Date
 Water Consumption (liters per person)

 <?php

    while($data=mysql_fetch_assoc($records)) {

         echo "
";

         echo "".$data['id']."	";

         echo "".$data['date']."	";

         echo "".$data['value']."	";

         echo "
";

     }//end while

     ?>

The code works, however I'm unsure of how to go about reading the data on an Arduino (very new to Arduino)
Here's my Arduino code paired with an ethernet shield
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {   0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

IPAddress ip(192, 168, *, *);

EthernetClient client;

char server[] = "www.decathlon.commonarchitecture.ca";

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

  // attempt a DHCP connection:
  Serial.println("Attempting to get an IP address using DHCP:");
  if (!Ethernet.begin(mac)) {
  // if DHCP fails, start with a hard-coded address:
  Serial.println("failed to get an IP address using DHCP, trying
  manually");
     Ethernet.begin(mac, ip);
  }

  Serial.print("My address:");
  Serial.println(Ethernet.localIP());
}

void loop()
{
    // connect to the server
    if (client.connect(server, 80))
    {
        // print to serial monitor
        Serial.println("connected...");
        Serial.println("ARDUINO: forming HTTP request message");

        // send data the server through GET request
        client.print("GET /index.php?value");
        client.println(" HTTP/1.1");
        client.print("HOST:  ");
        client.println(server);

        Serial.println("ARDUINO: HTTP message sent");

        // give server time to receive request
        delay(1000);

        // get the response from the page and print it to serial port
        // to ascertain that request was received properly
        if(client.available())
        {
            Serial.println("ARDUINO: HTTP message received");
            Serial.println("ARDUINO: printing received headers and
script response...\n");

            while(client.available())
            {
                char c = client.read();
                Serial.print(c);
            }
        }
        else
        {
            Serial.println("ARDUINO: no response received / no response
received in time");
        }

        client.stop();
    }
    // do nothing forever after:
    while(true);
}

My issue now is in getting the Arduino to read my php data, can I not use an http GET request to display data in my serial monitor? Am I using this function properly? There's a ton of documentation on posting Arduino sensor data to the web using php/my sql but not as much on retrieval of set data back into the serial monitor. Here's what the monitor reads currently...
Attempting to get an IP address using DHCP:
My address:192.168.*.*
connected...
ARDUINO: forming HTTP request message
ARDUINO: HTTP message sent
ARDUINO: no response received / no response received in time

Any one of a GSM shield, an Ethernet shield or an Arduino wifi shield should be able to pull a web page from a web server and feed it into your Arduino.
I highly recommend buying hardware from people that put lots of example program text on their website, rather than trying to save a few nickles buying "equivalent" hardware from people that don't give any examples, leading to hours of frustration.
Some of the places I've found that have lots of example program text (in no particular order):

Arduino Ethernet Shield 2: links to "Getting Started with the Arduino Ethernet Shield and Ethernet Shield 2" which in turn links to example code "WebClient: make a HTTP request" and "WebClientRepeating: Make repeated HTTP requests."
Arduino Ethernet Shield 2: links to Arduino Ethernet2 Library which in turn links to example code
W5500 Ethernet Shield for Arduino v1.0: links to WIZ5500 based Ethernet Shield library for Arduino which in turn links to example code "WebClient" and "WebClientRepeating"
Adafruit FONA 800 Shield - Voice/Data Cellular GSM for Arduino: links to Datasheets & App notes, and the "SIM800 IP App Note" has some brief examples of using HTTP to pull from a web server.
SparkFun ESP8266 Thing - Dev Board: links to ESP8266 Thing Development Board Hookup Guide, which has an example that "Read all the lines of the reply from server and print them to Serial". (related: "Quick Tip: HTTP GET with the ESP8266 Thing" )

If I were you, I would test the hardware with exactly the example programs given for that hardware, and resist the urge to "improve" them until after I confirm that the example programs actually do work.
(Perhaps you already did that? If so, please update your question to say the example code seemed to run OK, and exactly which example code you tried, and what minor changes you made that still seemed to run OK, so we can focus on what changed between "partially working" vs. "not even that part working").
(I personally find it easier to parse JSON data sent by a web server set up to send out "Content-Type: application/json; charset=utf-8", or TOML data sent by a web server as "Content-Type: text/plain; charset=utf-8",
rather than programmatically parse HTML tables sent by a web server set up to send out "Content-Type: text/html; charset=utf-8", but any of these ways should work).

Firstly if you really are using an Uno then you cant read the data without putting the uno on a network (obviously).  To do this you could get either a Ethernet shield of a Wifi shield.  A wifi shield is probably based on an ESP8266 and you talk to it by creating a serial connection (using a software serial port).  There are plenty of examples and messages on here to get you started.
Once that's working you need to write a web client (note that this is much easier if you program the ESP8266 rather than the Arduino).  Your client needs to request the page from your server and then parse the returned data and extract the field you want.
While you are waiting for you network shield to arrive you could practice doing it on a Windows PC with Visual Studio, it will be easier to debug.


text:
Incorrect data being received on RX of NRF24L01P
I am running a setup of two NRF24L01P's on homemade code where the TX sends an analog signal fed through a standard pot, and the RX simply prints out the signal. But the RX seems to be getting incorrect data, meaning that where the centre value on TX side is 670, the centre value on RX side is 180. Why is this happening? I have auto acknowledgement, and dynamic payload enabled. I also tried setting 250KBPS and 2000KBPS with the max power setting, and still the results dont change. Is this because of loss of power in the wireless communication? Will a voltage follower be needed?
Function definitions in code:
/* CONNECTIONS
 * NRF    ARDUINO
 * GND    GND
 * VCC    VCC
 * CE     D7
 * CSN    D8
 * MOSI   D11
 * SCK    D13
 * MISO ``D12
 * IRQ    D2*/

 #include <SPI.h>
 #define CE_PIN 7
 #define CSN_PIN 8
 #define MOSI_PIN 11
 #define SCK_PIN 13
 #define MISO_PIN 12
 #define W_REGISTER B00100000
 #define R_RX_PAYLOAD B01100001
 #define W_TX_PAYLOAD B10100000
 #define FLUSH_TX B11100001
 #define FLUSH_RX B11100010
 #define RF_SETUP 0x06
 #define RF_DR_LOW 5
 #define RF_DR_HIGH 3
 #define RF_CH 0x05
 #define EN_RXADDR 0x02
 #define ERX_P0 0
 #define SETUP_AW 0x03
 #define RX_ADDR_P0 0x0A
 #define FEATURE 0x1D
 #define EN_DPL 2
 #define EN_AA 0x01
 #define CONFIG 0x00
 #define PWR_UP 1
 #define PRIM_RX 0
 #define MASK_RX_DR 6
 #define MASK_TX_DS 5
 #define MASK_MAX_RT 4
 #define EN_CRC 3
 #define CRCO 2
 #define STATUS 0x07
 #define RX_DR 6
 #define TX_DS 5
 #define MAX_RT 4
 #define NOP B11111111
 #define TX_ADDR 0x10
 #define DYNPD 0x1C

 byte data_buff;
 int address = 123;
 byte data_recieve;

//******************************** write a byte to a regster *******************************
void writeRegister(byte reg_address, byte data)
{
  bitClear(PORTB, 0);
  SPI.transfer(W_REGISTER | reg_address);
  SPI.transfer(data);
  bitSet(PORTB, 0);
}

//******************************* set the air data rate *******************************
void setAirDataRate(int air_data_rate)
{
  switch(air_data_rate)
  {

    case 250:
     setRegisterBit(RF_SETUP, RF_DR_LOW, 1);
     setRegisterBit(RF_SETUP, RF_DR_HIGH, 0);
     break;

    case 1000:
     setRegisterBit(RF_SETUP, RF_DR_LOW, 0);
     setRegisterBit(RF_SETUP, RF_DR_HIGH, 0);
     break;

    case 2000:
      setRegisterBit(RF_SETUP, RF_DR_LOW, 0);
      setRegisterBit(RF_SETUP, RF_DR_HIGH, 1);
      break;

    default:
      Serial.println("WRONG AIR DATA RATE ENTERED!");
      break;
  }
}

void setRegisterBit(byte reg_address, byte bit_add, byte bit_val)
{
  getRegisterStat(reg_address);

  if(bit_val == 1)
  {
    bitSet(data_buff, bit_add);
  }

  else
  {
    bitClear(data_buff, bit_add);
  }

  bitClear(PORTB, 0);
  SPI.transfer(W_REGISTER | reg_address);
  SPI.transfer(data_buff);
  bitSet(PORTB, 0);

  Serial.print(bit_add);
  Serial.print(" bit set to ");
  Serial.print(bit_val);
  Serial.print(" in register ");
  Serial.println(reg_address);
}

void getRegisterStat(byte reg_address)
{
  bitClear(PORTB, 0);
  SPI.transfer(reg_address);
  data_buff = SPI.transfer(0);
  bitSet(PORTB, 0);
}

void enableDPL( int pipe_number)
{
  setRegisterBit(FEATURE, EN_DPL, 1); //enable dpl by EN_DPL = 1
  setRegisterBit(DYNPD, pipe_number, 1); //DPL_Px = 1
}

void openReadingPipe()
{
  setRegisterBit(EN_RXADDR, 0, 1); //ERX_P0 = 1
  writeRegister(RX_ADDR_P0, address);//set address for datapipe
  Serial.print("Data Pipe open with address:  ");
  Serial.println(address);
}

void openWritingPipe()
{
  setRegisterBit(EN_RXADDR, 0, 1); //ERX_Px = 1
  writeRegister(TX_ADDR, address);//set address for datapipe
  writeRegister(RX_ADDR_P0, address);
}

//******************************* set the frequency *******************************
void setChannelFreq(int frequency)
{
  int  frequency_val = frequency - 2400;
  if(frequency_val <= 125 && frequency_val > 0)
  {
    writeRegister(RF_CH, frequency_val);
  }

  else
    Serial.println("WRONG FREQUENCY VALUE ENTERED!");
}

//******************************* print the status of the register *******************************
void printRegStatus(byte reg_address)
{
  getRegisterStat(reg_address);

  switch(reg_address)
  {
    case RF_SETUP:
    bitRead(data_buff, 3) ? Serial.println("AIR DATA RATE SET TO 2000KBPS") : bitRead(data_buff, 5) ? Serial.println("AIR DATA RATE SET TO 250KBPS") : Serial.println("AIR DATA RATE SET TO 1000KBPS");
    break;

    case EN_RXADDR:
    bitRead(data_buff, 0) ? Serial.print("Data Pipe 0 open with address:  ") : Serial.print("Data Pipe 0 not open with address:  ");
    Serial.println(address);
    break;

    case RF_CH:
    Serial.print("The set frequency is:");
    Serial.println(2400 + data_buff);
    break;

    case CONFIG:
    bitRead(data_buff, MASK_RX_DR) ? Serial.println("RX_DR interrupt not reflected on IRQ") : Serial.println("RX_DR interrupt is active low on IRQ");
    bitRead(data_buff, MASK_TX_DS) ? Serial.println("TX_DS interrupt not reflected on IRQ") : Serial.println("TX_DS interrupt is active low on IRQ");
    bitRead(data_buff, MASK_MAX_RT) ? Serial.println("MAX_RT interrupt not reflected on IRQ") : Serial.println("MAX_RT interrupt is active low on IRQ");
    bitRead(data_buff, EN_CRC) ? Serial.println("CRC is Enabled!") : Serial.println("CRC is diabled!");
    bitRead(data_buff, CRCO) ? Serial.println("CRC is 2 bytes.") : Serial.println("CRC is 1 byte.");
    break;

     case EN_AA:
    bitRead(data_buff, 0) ? Serial.println("ENABLE AUTO ACK ON PIPE 0") : Serial.println("AUTO ACK NOT ENABLED");
    break;

    case FEATURE:
    bitRead(data_buff, EN_DPL) ? Serial.println("DYNAMIC PAYLOAD LENGTH ENABLED") : Serial.println("DYNAMIC PAYLOAD LENGTH NOT ENABLED!");
    break;

    case DYNPD:
    bitRead(data_buff, 0) ? Serial.println("DYNAMIC PAYLOAD ON DATA PIPE 0 ENABLED!") : Serial.println("DYNAMIC PAYLOAD NOT ENABLED IN DATA PIPE!");
    break;

    case TX_ADDR:
    Serial.print("ADDRESS: ");Serial.println(data_buff);
    break;

    case RX_ADDR_P0:
    Serial.print("ADDRESS: ");Serial.println(data_buff);
    break;

    case SETUP_AW:
    if(bitRead(data_buff, 1) == 0 && bitRead(data_buff, 0 == 1))
    Serial.println("ADDRESS WIDTH 3 BYTES!");
    break;

  }
}

//******************************* set the address width *******************************
void setAddressWidth(byte address_width)
{
  switch(address_width)
  {
    //addres width is 3 bytes
    case 3:
    setRegisterBit(SETUP_AW, 0, 1);
    setRegisterBit(SETUP_AW, 1, 0);
    break;

    //address width is 4 bytes
    case 4:
    setRegisterBit(SETUP_AW, 0, 0);
    setRegisterBit(SETUP_AW, 1, 1);
    break;

    //address width is 5 bytes
    case 5:
    setRegisterBit(SETUP_AW, 0, 1);
    setRegisterBit(SETUP_AW, 1, 1);
    break;

    default:
    Serial.println("WRONG ADDRESS WIDTH ENTERED!");
    break;
  }
}

//******************************** enable auto acknowledgment *******************************
void enableAutoACK()
{
  setRegisterBit(EN_AA, 0, 1);
}

//******************************** enable auto acknowledgment *******************************
void clearInterrupts()
{
  setRegisterBit(STATUS, RX_DR, 1);
  setRegisterBit(STATUS, TX_DS, 1);
  setRegisterBit(STATUS, MAX_RT, 1);
}

void confirmTransmit()
{
  Serial.print("PACKET SENT SUCCESSFULLY!!");
  setRegisterBit(STATUS, TX_DS, 1);

}

void setupRadio(int air_data_rate, int frequency, byte address_width)  //air data rate in kbps, frequency in MHz, address width in bytes
{

  DDRB = B00101001;
  DDRD = B10000000;
  Serial.begin(115200);
  SPI.begin();
  //set air data rate
  setAirDataRate(air_data_rate);

  //set frequency
  setChannelFreq(frequency);

  //set address width
  setAddressWidth(address_width);

  //flush the rx and tx fifo
  bitClear(PORTB, 0);
  SPI.transfer(FLUSH_RX);
  bitSet(PORTB, 0);

  bitClear(PORTB, 0);
  SPI.transfer(FLUSH_TX);
  bitSet(PORTB, 0);

  //enable dpl
  enableDPL(0);

  //enable CRC
  setRegisterBit(CONFIG, EN_CRC, 1);
  setRegisterBit(CONFIG, CRCO, 0);

  bitClear(PORTD, 7); //set CE low
  bitSet(PORTB, 0);// keep CSN high
}

//******************************** setup the RX *******************************
void setupRX()
{
    //open up the pipe for transmission
    openReadingPipe();

    //mask tx and max rt IRQ
    setRegisterBit(CONFIG, MASK_MAX_RT, 1);
    setRegisterBit(CONFIG, MASK_TX_DS, 1);

    //power up module
    setRegisterBit(CONFIG, PWR_UP, 1);

    //Tpd2stby delay
    delay(5);

    attachInterrupt(digitalPinToInterrupt(2), recieveData, FALLING);

    //clear any interrupt flag
    clearInterrupts();

    //set PRIM_RX bit
    setRegisterBit(CONFIG, PRIM_RX, 1);
    bitSet(PORTD, 7); //set CE high
    delay(1);
}

//******************************** setup the TX *******************************
void setupTX()
{
  openWritingPipe();
  setRegisterBit(CONFIG, PRIM_RX, 0);

  //mask rx and max rt interrupt
  setRegisterBit(CONFIG, MASK_RX_DR, 1);
  setRegisterBit(CONFIG, MASK_MAX_RT, 1);

  //enable autoACK
  enableAutoACK();

  setRegisterBit(RF_SETUP, 2, 1);
  setRegisterBit(RF_SETUP, 1, 1);
  setRegisterBit(CONFIG, PWR_UP, 1);

  delay(5);

  attachInterrupt(digitalPinToInterrupt(3), confirmTransmit, FALLING);

  clearInterrupts();
  delay(1);
}

//******************************** read data from RX FIFO *******************************
void recieveData()
{
  Serial.println("RECIEVE ISR BEGUN");

  bitClear(PORTD, 7); //set CE_PIN low
  delayMicroseconds(100);

  bitClear(PORTB, 0);
  SPI.transfer(R_RX_PAYLOAD);
  data_recieve = SPI.transfer(NOP);
  bitSet(PORTB, 0);

  bitClear(PORTB, 0);
  SPI.transfer(RPD);
  data_buff = SPI.transfer(NOP);
  delay(1);
  bitSet(PORTB, 1);

  bitRead(data_buff, 0) ? Serial.println("THERE IS ENOUGH POWER!") :
  Serial.println("THERE IS NOT ENOUGH POWER!");

  delayMicroseconds(15000);
  setRegisterBit(STATUS, RX_DR, 1);

  bitSet(PORTD, 7);
  delayMicroseconds(100);

  Serial.print("THROTTLE :");
  Serial.println(data_recieve);
 }
//******************************** write data to be transmitted *******************************
void transmitData(byte data)
{
  bitClear(PORTB, 0);
  SPI.transfer(FLUSH_TX);
  bitSet(PORTB, 0);

  bitClear(PORTB, 0);
  SPI.transfer(W_TX_PAYLOAD);
  SPI.transfer(data);
  bitSet(PORTB, 0);

  bitSet(PORTD, 7);
  delayMicroseconds(1000);
  bitClear(PORTD, 7);

  delayMicroseconds(130);

  /*bitClear(PORTB, 0);
  SPI.transfer(0x17);
  data_buff = SPI.transfer(NOP);
  bitSet(PORTB, 0);
  bitRead(data_buff, 4) ? Serial.println("TX FIFO EMPTY!") :
  Serial.println("DATA IN TX FIFO");*/
}

The RX code (all function definitions are same obviously):
void setup(){
  setupRadio(1000, 2515, 3);
  setupRX();
 /*printRegStatus(CONFIG);
 printRegStatus(TX_ADDR);
 printRegStatus(RX_ADDR_P0);
 printRegStatus(EN_AA);
 printRegStatus(RF_CH);
 printRegStatus(FEATURE);
 printRegStatus(RF_SETUP);
 printRegStatus(SETUP_AW);*/

}

void loop(){

 delay(1000);
}

The TX code (all function definitions are same obviously):
void setup(){
      setupRadio(1000, 2515, 3);
      setupTX();
     /*printRegStatus(CONFIG);
     printRegStatus(TX_ADDR);
     printRegStatus(RX_ADDR_P0);
     printRegStatus(EN_AA);
     printRegStatus(RF_CH);
     printRegStatus(FEATURE);
     printRegStatus(RF_SETUP);
     printRegStatus(SETUP_AW);
     printRegStatus(DYNPD);*/

    }

    void loop(){
     int throttle_raw = sqrt(pow(analogRead(A2), 2) + pow(analogRead(A3), 2));
      transmitData(throttle_raw);
      Serial.println(throttle_raw);
      delay(1000);
    }

Probably has to do with the fact that you're passing an int-sized parameter to a function that takes a byte. Your transmitData() doesn't take multi-byte values into account. Why not use existing libraries?

Your new TX function:
void transmitData(byte * data, byte len)
{
  bitClear(PORTB, 0);
  SPI.transfer(FLUSH_TX);
  bitSet(PORTB, 0);

  bitClear(PORTB, 0);
  SPI.transfer(W_TX_PAYLOAD);

  len = min(len, 32); // since 32 is max size
  for (int i = 0; i < len; i++)
    SPI.transfer(*data++);
  bitSet(PORTB, 0);

  bitSet(PORTD, 7);
  delayMicroseconds(1000);
  bitClear(PORTD, 7);

  delayMicroseconds(130);

  /*bitClear(PORTB, 0);
  SPI.transfer(0x17);
  data_buff = SPI.transfer(NOP);
  bitSet(PORTB, 0);
  bitRead(data_buff, 4) ? Serial.println("TX FIFO EMPTY!") :
  Serial.println("DATA IN TX FIFO");*/
}

To receive data with dynamic payloads enabled, you need to know the size of the incoming payload before you read. Study getDynamicPayloadSize() in the RF24 library and pass the value returned as the second argument to the RX function below. Your new RX function should look like this:
void recieveData(byte * data, byte len)
{
  Serial.println("RECIEVE ISR BEGUN");

  bitClear(PORTD, 7); //set CE_PIN low
  delayMicroseconds(100);

  bitClear(PORTB, 0);
  SPI.transfer(R_RX_PAYLOAD);
  for (int i = 0; i < len; i++){
    *data = SPI.transfer(0xff); data++;
  }
  bitSet(PORTB, 0);

  bitClear(PORTB, 0);
  SPI.transfer(RPD);
  data_buff = SPI.transfer(NOP);
  delay(1);
  bitSet(PORTB, 1);

  bitRead(data_buff, 0) ? Serial.println("THERE IS ENOUGH POWER!") :
  Serial.println("THERE IS NOT ENOUGH POWER!");

  delayMicroseconds(15000);
  setRegisterBit(STATUS, RX_DR, 1);

  bitSet(PORTD, 7);
  delayMicroseconds(100);
 }

In both functions, you pass in buffers to hold the data you want to send or receive. In your case, since you're sending ints, a call like this transmitData(&throttle, 2) should do. Since you already know the size of what you're sending, you can simply pass 2 as length to receiveData() and skip querying the payload size like this receiveData(&throttle, 2). Casting will be done implicitly.
If, in fact, receiveData is an ISR like your comments say (maybe you're using some IRQ pin), you'll have to split it in two; one part to handle the interrupt quickly by setting an available flag or something (obviously taking no arguments) to be polled in loop() and another to actually read the data. Or you can just setup the buffer as a global thing and hard-code a 2-byte read in the ISR. Though I have to say your maybe-ISR is terrible, what with huge delays and prints everywhere and I don't know how it manages to work at all.
Basically, if you want to understand the chip, it doesn't hurt to look at existing code to understand the 'right' way to do stuff.

In RF24, why does he define the parameter for the buffer in write_payload as a void* ?

@BabaYaga So that you can pass a pointer to any sort of data type without needing to cast it first. Casting is done within write_payload().


text:
Delay in displaying data received from UART when used with PCINT on PIN0
I have been trying to find a solution for UART receive interrupt for my UNO board and I came across a possible solution in : PCInt
I did a small editing in the following portion of the code to make it work for UART.(code works like a loop-back test)
void RXint(void) {
char k;
if(Serial.available()>0)
{
k=Serial.read();
Serial.print(k);
}}
void setup()
{
Serial.begin(9600);
PCattachInterrupt(0, RXint, FALLING);
}
void loop()
{}

The code works pretty well with one big drawback.
The character displayed is having one char delay, what i mean is that for the following input

qwerty

output is

qwert

That means if I enter the 5th char,the output will be 4th one.
When the first input is given, it doesn't show output till the second input is entered.
Can someone help me out with this
(This is only a test code, the interrupt part is to be used in a larger code where the loop() carries out different tasks and interrupt is to be raised when data is received via UART)  .

Forget about interrupts and rename RXint → loop. It should work like a charm. Serial already handles the UART interrupt pretty well. Trying to manage the incoming data in an interrupt is misguided.

@EdgarBonet Actually this is only a testing code. The real code is a long one consisting of other connected devices and in that code I need to add interrupt for UART as the data is to b stored to a RAM. I cant use Serial.event() as it checks only at the ending of loop.

“I need to add interrupt for UART as the data is to be stored to a RAM”. The Serial object already provides an interrupt that does exactly what you want: it stores the incoming data in a RAM buffer. It makes little sense to add a second buffering layer of your own. “I cant use Serial.event() as it checks only at the ending of loop”. Checking at the end of loop() is fine, unless your loop() is too slow. If this is the case, then your real problem is: too many blocking calls. It's not a problem about serial interrupts at all.

Here the working is like, the data is received in a sequence and the received data is stored into an External RAM(from where further processing is done). Of course the loop() is slow as it needs to be reading RTC and pushing data to other devices and I cant miss a character in sequence that I am receiving. Cause of these reasons I am trying to implement interrupt.

Your interrupt is happening at the same time the START bit of the next frame is arriving in the hardware. As a result you don't have that data yet, because it's still to arrive. All you have is what has gone before. You won't get the new character until the frame has finished arriving and the UART RX interrupt fires and the byte gets copied out of the RX FIFO and placed into the Arduino receive buffer.
The way you are doing it is completely wrong. The data is already being captured using an interrupt and placed in a buffer for you to deal with as you see fit at a time that suits you (as long as it is before the buffer overflows).
If you can't read it fast enough using your main loop (or variations thereon) then you need to rethink how you are doing your main loop.

are there no USART interrupts in arduino?

You mean besides the one I already mentioned that the API already uses to receive the incoming bytes...?

I am a little new to this. It would be much helpful if you could show me a way how to do this without an interrupt. I tried Serial.event(), but my main loop() is too long i guess, so its not working as expected.

So make your main loop() shorter. Get rid of delays, while loops, etc. You don't want to write blocking code on an Arduino or you find you can't do much.

As other have emphasized, make sure your loop runs freely, without delays or blocking while loops.  It would be very unusual to have a loop that really takes > 64ms (the input buffer overflow time @ 9600).
However, there is one case where a frequently-used library is blocked for 150ms or more:  SDfat.  If you are logging data, the library may have to wait for the SD card to accept more data.  It is an indeterminate length of time, and it is specific to the individual card.  In this case, you have two choices:

process the RX characters as they arrive, during the RX character interrupt; or
add a yield call to the offending SDFat method.

For the former solution, I have posted modified versions of the most commonly-used Arduino serial port libraries.  They all have a new attachInterrupt method that allows your function to be called for each RX character.  See NeoHWSerial (a modified HardwareSerial), NeoICSerial (a modified AltSoftSerial) and NeoSWSerial (a more-efficient alternative to SoftwareSeriall).


text:
Oscillating Analog Readings
I am using a JIC 139 UV Sensor (datasheet) with an Arduino Mega 2560 and should be reading smooth curves as I bring a UV source to towards the sensor. Instead, my curves are increasing and oscillating. How can I remove the oscillations and what is the cause of these oscillations?
Code:
float mapfloat(long x, long in_min, long in_max, long out_min, long out_max)
{
    return (float)(x - in_min) * (out_max - out_min) / (float)(in_max - in_min) + out_min;
}

int averageAnalogRead(int pinToRead)
{
    byte numberOfReadings = 8;
    unsigned int runningValue = 0;

    for(int x = 0 ; x < numberOfReadings ; x++)
        runningValue += analogRead(pinToRead);
    runningValue /= numberOfReadings;

    delay(100);

    return(runningValue);
}

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

void loop() {

   float pinRead0 = averageAnalogRead(0);
   float pVolt0 = pinRead0 / 1024.0 * 5.0;

   // In mW/m^2
   Serial.println(pVolt0);
   //  Serial.println(mapfloat(pVolt0, 0.0, 5.0, 0.0, 15.0));

   delay(100);
}

`
Here is a sample screenshot from the Serial Plotter at 3 different distances from the UV Source:

Would post cicuit but don't have enough reputation. Will post as response.
edit: I added a very large capacitor(3300 uf) between the output pin and ground which seemed to smooth the values a little bit but the noise still exists
edit: The x-axis is number of readings and the y-axis is voltage(0-5v) calculated from analogRead()

It is not your sketch, the sketch is okay. How stable is the 5V of the Arduino Uno ? It is most likely the analog circuit.

5 volt is stable at 5.01, any ideas as to what may be wrong with the analog circuit?

What is the x-axis scale?  (Eg, is it reading number, time, etc)?  [Please edit  reply into your question]

Without seeing circuit and construction details and oscilloscope traces, it's difficult or impossible to say what the problem is.  It may be due to op amp instability due to a large capacitive load.  It may reflect a beat frequency between some sensor and MCU signals, or aliasing between 60-Hz noise and your data-conversion rate.
Regarding op amp instability, see for example the article Op Amps Driving Capacitive Loads, by Grayson King.  Here is a quote from that article:

Q. How does capacitive loading affect op amp performance?
  A. To put it simply, it can turn your amplifier into an oscillator. Here's how: [...]

Rather than just connecting that big 3300 μF capacitor to the output pin, perhaps instead try attaching an Active Low Pass Filter to the output, or a unity-gain op amp followed by a Passive Low Pass Filter; etc.  Put big capacitors across power into the UV source and power into the sensor, instead of on the sensor output.
Regarding beat frequencies and aliasing, low-frequency oscillation like that seen in the trace may occur as a difference of two higher-frequency signals, or as a sampling artifact.  To check this out, attach an oscilloscope to the UV source and see if its power consumption oscillates; and/or try a more-rational sampling scheme than that shown in your code.
For example, instead of taking 8 readings within one millisecond in averageAnalogRead() and then waiting 100 ms, perhaps add a delay(1) inside the loop so that readings are spread out slightly more.  Remove the delay(100) from within averageAnalogRead().  Compensate by changing the other delay(100) in loop() to, for example, delay(191) or delay(193).  Try various delay amounts to see if they have an effect on the waveform.


text:
Eleminate noise from a Relay in ArduinoFFT
I have built a circuit with an Arduino Nano to measure frequency from my music, it's basically this schema but I changed the code a little bit to fit my needs.
My problem is I want to add a Relay (I have an arduino single relay module) to the circuit and when I connect the signal on my 5v, it create a lot of noise in the frequency I get from ArduinoFFT.
What my code is doing is getting an average of the frequency to detect if music is currently playing. Here is a sample of data I get when there is no music playing:
2 2 2 4 1 0 0: 1
2 2 4 1 0 0 1: 1
4 4 1 0 0 1 0: 1
1 1 0 0 1 0 4: 1
0 0 0 1 0 4 1: 1
0 0 1 0 4 1 5: 1
1 1 0 4 1 5 3: 2
0 0 4 1 5 3 2: 2
4 4 1 5 3 2 0: 2
1 1 5 3 2 0 0: 1

Here, this is with music (good old rock :) ):
16 16 22 17 20 21 29: 20
22 22 17 20 21 29 28: 22
17 17 20 21 29 28 22: 22
20 20 21 29 28 22 25: 24
21 21 29 28 22 25 28: 25
29 29 28 22 25 28 27: 26
28 28 22 25 28 27 32: 27
22 22 25 28 27 32 27: 26
25 25 28 27 32 27 29: 28
28 28 27 32 27 29 23: 27

And finaly when I connect the relay (with arduino digital pin or if I jump it with the 5v, it the same result):
5 5 5 6 4 4 7: 5
5 5 6 4 4 7 5: 5
6 6 4 4 7 5 4: 5
4 4 4 7 5 4 4: 4
4 4 7 5 4 4 5: 4
7 7 5 4 4 5 4: 4
5 5 4 4 5 4 4: 4
4 4 4 5 4 4 4: 4
4 4 5 4 4 4 6: 4
5 5 4 4 4 6 4: 4

The problem with this is that when I'm playing smooth music, the numbers are not that high, it's basically the same as when the relay is on.
Here is a schema of what I did, it's my first try, let me know if anything is not fine with it.

simulate this circuit – Schematic created using CircuitLab

How are you trying to connect this relay and can you show us the noise you get?

Separate the relay power from Arduino, if that not what you want, we can only guessing because you didn't provide much info for troubleshooting.

I added more details on the data I have and a picture of my setup.

Please consider a schematic; it’s difficult to see what’s going on here.

@DaveNewton, here it is, it's my first attempt to create a schema so, I hope everything is fine with it ;)

what are you switching with the relay? If it's DC, I would use a MOSFET instead.

@dandavis, no, it's AC.


text:
Is there a way to update Arduino uno Over The Air
I have the Arduino uno with a Ethernet W5100 Shield and would like to remotely sketches.  Is there a way to update Arduino uno over the air?  If not, is there a wired network arduino solution that will allow update over the air.
I've done this on the esp8266 using there tools but I can't find one for the Uno.
Thanks

Also asked at: http://forum.arduino.cc/index.php?topic=511708 If you're going to do that then please be considerate enough to add links to the other places you cross posted. This will let us avoid wasting time due to duplicate effort and also help others who have the same questions and find your post to discover all the relevant information.

Not with WiFi, nor with Ethernet. People have managed it with Bluetooth, but only because it can create a transparent serial bridge. The bootloader only talks serial, so you have to use something that is serial to program it.
The only possible way is to use another WiFi (or Ethernet) device, such as the ESP8266, to act as a serial bridge to connect the Arduino's serial port (and reset signal) to your computer over WiFi. A bit of a waste of an ESP8266 since that is then the sole task it would have (unless you craft a far more complex sketch for the ESP8266 to allow it to do other things as well).

Thanks for the quick reply.  What about any of the other arduino family or compatibles?

You would need a board that a) has WiFi built in, and b) has a bootloader capable of operating with it (or other similar facilities). I don't know of an Arduino that does that. I do know of the ESP8266 though (and so do you). Oh, and I have done it using an ESP8266 connected to an Arduino to bootload the Arduino.

There is a sketch I created for bootloading Arduino-like boards using an ESP8266 as a serial bridge (https://github.com/MajenkoProjects/WiFiSerialDTR). It does the reset for you using a simulated DTR signal, and (though not properly tested yet) also should implement RFC2217 for baud rate changing. Note: the ESP8266 is then only for bootloading and nothing else.

The Ariadne bootloader project enables upload over Ethernet to AVR boards with Ethernet shield.


text:
Reading 4 to 20ma pressure sensor using uno
I have a OsiSense™ XMLP pressure sensor that I want to read from my Arduino uno. This is the circuit I am looking at building for measure 4 to 20 milliamp.

I've read online to find out how to build the circuit.  Can you tell me if it is correct?
Also I dont understand why it works and I'm hoping you can correct my thinking.  Following ohms law we want to leave 5v when 20 milliamps goes through the circuit.  We know the voltage on the circuit is a constant 24 volts (short cable runs) and we know the maximum current is 20 milliamps so my maths says :
Resistance = Voltage  / I (current)
We need to leave 5 volts for the Arduino to read when the sensor is at maximum pressure so we subtract 5 from 24.
Resistance = 19  / 20 milliamp
So the resistor to select to give us a maximum of 5 volts is a 0.95 Kilohms resistor.  I dont see where the 250 ohm resistor comes in? please help.

To read a current with the Arduino you first have to convert that current to a voltage - and you do that by passing it through a resistance. The voltage dropped across that resistance as the current changes is what interests you.

simulate this circuit – Schematic created using CircuitLab
For a 4-20mA current you need to choose a resistance that gives voltages that are within the 5V range that an Arduino can read.
The biggest voltage drop across the resistor will occur when the current is at maximum (20mA) so you can use that to calculate a good resistor value to use:
R = V/I = 5 / 0.02 = 250

And for the same resistance at minimum current:
V=IR = 0.004 × 250 = 1

So across the resistor you would get between 1V (4mA) and 5V (20mA).
250Ω resistors aren't that common, so a more common value would be used instead - such as the commonly available 220Ω.  Substituting the 250Ω for a 220Ω would give voltages:
@20mA: V=IR = 0.02 × 220 = 4.4V
@4mA:  V=IR = 0.004 × 220 = 0.88V

Both comfortably within the Arduino's range and also gives a bit of wriggle room in case of any small over-current conditions.
It can also be good to protect the analog input of the Arduino with a resistor + zener diode to prevent damage in the case that the resistor fails / becomes disconnected and you get the full output voltage applied direct to the Arduino:

simulate this circuit

Thanks for getting back to me so quick.  I'm still not understanding correctly.  ill have another read tonight and let it sink in.  As you can tell, im fairly new to this so maybe missing some basic understanding.

In the second circuit R2 is just there to limit the current through the zener in the case of an over vintage situation. R1 is the same as in the first circuit and takes 99.9999% of the current through it to create a voltage drop.

@Majenko what is the leakage current of the 1N4733A at 5V ? When R1 got a loose leg, and 24V would be at R2, then a continuous voltage of 24V requires a resistor of 4W for R2. For basic protection making R2 10k and removing the zener will work as well.

You're fixated on 24V. Forget 24V. That is the maximum it could be when open circuit. It should never be more than 20mA, which is 40mW through a 100Ω resistor.

Sorry, I forgot that the current is maximum 20mA. The leakage of the zener diode is probably too small to have any influence. Even more so when you set the 20mA to 4.4V. Sorry again. I get it now.


text:
Emergency stop button for arduino mega code and circuit attached
I am trying to control steppers with pushbuttons and sensors.I want to add one more Pushbutton so that I can press it to stop the circuit and code running if something goes wrong in between.
Below is the code I am using to run the steppers:
int dirpin_T1 = 26;
int dirH_T1 = 28;
int steppin_T1 = 30;
int dirpin_F1 = 5;
int dirH_F1 = 6;
int steppin_F1 = 7;

int PB17ACW = 23;
int PB17ACCW = 22;
int PB17BCW = 25;
int PB17BCCW = 24;

int S01 = 34; // SENSOR INPUTS
int S02 = 35;
int S03 = 36;
int S04 = 37;

void setup()
{
  pinMode(dirpin_T1, OUTPUT);
  pinMode(dirH_T1, OUTPUT);
  pinMode(steppin_T1, OUTPUT);
  pinMode(dirpin_F1, OUTPUT);
  pinMode(dirH_F1 , OUTPUT);
  pinMode(steppin_F1, OUTPUT);

  pinMode(PB17ACW, INPUT_PULLUP);
  pinMode(PB17ACCW, INPUT_PULLUP);
  pinMode(PB17BCW, INPUT_PULLUP);
  pinMode(PB17BCCW, INPUT_PULLUP);

  pinMode(S01, INPUT);
  pinMode(S02, INPUT);
  pinMode(S03, INPUT);
  pinMode(S04, INPUT);
}

void loop()
{
  if (digitalRead(PB17ACW) == LOW &&  digitalRead(PB17ACCW) == LOW)
  {
    // STOP MOTOR WHEN NO KEY PRESSED
  }

  // FOR FORWARD ROTATION
  if (digitalRead(PB17ACW) == HIGH &&  digitalRead(PB17ACCW) == LOW )
  {
    digitalWrite(dirpin_T1, LOW );     // Set the direction.
    digitalWrite(dirH_T1, LOW);
    delay(1000);

    for (int i = 0; i < 32767; i++)     // Iterate for 4000 microsteps.(32767)
    {
      digitalWrite(steppin_T1, LOW);  // This LOW to HIGH change is what creates the
      digitalWrite(steppin_T1, HIGH); // "Rising Edge" so the easydriver knows to when to step.
      delayMicroseconds(50);
    }

    digitalWrite(dirpin_F1, LOW );     // Set the direction.
    digitalWrite(dirH_F1, LOW);
    delay(1000);
    do
    {
      digitalWrite(steppin_F1, LOW);  // This LOW to HIGH change is what creates the
      digitalWrite(steppin_F1, HIGH); // "Rising Edge" so the easydriver knows to when to step.
      delayMicroseconds(50);
    } while (digitalRead(S01) == LOW);

    delay(1000);

    digitalWrite(dirpin_T1, LOW );     // Set the direction.
    digitalWrite(dirH_T1, HIGH);
    delay(1000);

    for (int i = 0; i < 32767; i++)     // Iterate for 4000 microsteps.(32767)
    {
      digitalWrite(steppin_T1, LOW);  // This LOW to HIGH change is what creates the
      digitalWrite(steppin_T1, HIGH); // "Rising Edge" so the easydriver knows to when to step.
      delayMicroseconds(50);
    }
  }

  // FOR  BACKWARD ROTATION
  if (digitalRead(PB17ACW) == LOW &&  digitalRead(PB17ACCW) == HIGH)
  {
    digitalWrite(dirpin_T1, LOW );     // Set the direction.
    digitalWrite(dirH_T1, LOW);
    delay(1000);

    for (int i = 0; i < 32767; i++)     // Iterate for 4000 microsteps.(32767)
    {
      digitalWrite(steppin_T1, LOW);  // This LOW to HIGH change is what creates the
      digitalWrite(steppin_T1, HIGH); // "Rising Edge" so the easydriver knows to when to step.
      delayMicroseconds(50);
    }
    digitalWrite(dirpin_F1, LOW );     // Set the direction.
    digitalWrite(dirH_F1, HIGH);
    delay(1000);
    do
    {
      digitalWrite(steppin_F1, LOW);  // This LOW to HIGH change is what creates the
      digitalWrite(steppin_F1, HIGH); // "Rising Edge" so the easydriver knows to when to step.
      delayMicroseconds(50);
    } while (digitalRead(S02) == LOW);

    delay(1000);
    digitalWrite(dirpin_T1, LOW );     // Set the direction.
    digitalWrite(dirH_T1, HIGH);
    delay(1000);

    for (int i = 0; i < 32767; i++)     // Iterate for 4000 microsteps.(32767)
    {
      digitalWrite(steppin_T1, LOW);  // This LOW to HIGH change is what creates the
      digitalWrite(steppin_T1, HIGH); // "Rising Edge" so the easydriver knows to when to step.
      delayMicroseconds(50);
    }
  }
//WANT CODE TO STOP CODE ANYTIME I PRESS STOP BUTTON

}

This is a site where you ask questions. You don't just ask for code to be written for you. What is the question?

The simplest would be to use an interrupt triggered by the button and loop forever in the isr.

The best option is to convert the delay() based code to a millis() based state machine. That way the code will never block and always be going through the loop and the place where you check wether that button was hit.
Then when that button is hit you transition to the E_STOP state which turns off all motors until the restart button is hit which goes to recalibrate the position if needed.

A more quick and dirty solution is to replace every every delay with
unsigned long current = millis();
while(milis() - current < delay){
    if(E_Stop()){
        stopped = true;
        return;
    }
}

And add a if check to bail out to every loop.
 for (/*...*/)
  {
    //...
    delayMicroseconds(50);
    if(E_Stop()){
        stopped = true;
        return;
    }
  }

At the start of loop() you then add a
if(stopped){
    //check for restart signal if true recalibrate otherwise return
}


text:
On/off button for Arduino Mega for 5V input pin- hardware based auto on/off arduino(PUSHBUTTON NOT AS INTERRUPT)

I am working on Arduino Mega project where I want to add a PUSHBUTTON (Any other can be suggested) that will be programmed in my arduino code, such that if I would press the button arduino code should stop working and when I will press the button back the code should resume from the moment where it stopped.
Button will be attached to 5v pin so that will turn off/on the arduino.

yes but now i am trying to add a pushbutton at power supply pin (5v) of arduino board.  It will work as auto power on/off of to the arduino.

Your question is very badly written, and a lot of infos are missing. In any case, from what I understood from your comments, you want a button that works this way:

The arduino is not powered up
You press the button; the arduino turns on, and starts the operations.
You press the button; the arduino shuts down.
You press the button; the arduino turns on, and resumes the operations from where it was.

I'm not sure about the last point, so first of all I'll give you some hints about the first three points.
You can modify the circuit in a way similar to this:

simulate this circuit – Schematic created using CircuitLab
(I named the two arduino pins as A and B because it is not important which pins you use, just two separate pins).
The diodes can be any diode (e.g. 1N4148). The PMOS and NMOS are not critical, provided that they can fully turn on with a 4-5V gate voltage and that the PMOS can bear the current you need.
When the arduino is shut down, the NMOS is off, and so is the PMOS. When you press the button, the voltage on the NMOS gate becomes about 4.5V, so it turns on. the PMOS turns on too, and so the arduino sees some power. At the very first moment, it has to pull pin B to 5V. This way even when the button is not pressed anymore, the board will be powered. When the user presses the button, the arduino can sense it through pin A. This way it can go into shutdown mode. Here is a sort of base for handling this behavior. Please note that I'm using the Bounce2 library, since I particularly like it when dealing with buttons (it automagically handles bounces and also give more info about the edges).
#include <Bounce2.h>

const byte pinA = the pin A number;
const byte pinB = the pin B number;

Bounce pinA_debounced = Bounce();

void shutdown() {
    // Turn off the board
    digitalWrite(pinB, LOW);
    // Farewell, cruel world!
    while(1); // wait for a power off
}

void setup() {
    // Turn on the board
    pinMode(pinB,OUTPUT);
    digitalWrite(pinB, HIGH);

    // Initializate the debounced pin
    pinA_debounced.attach(pinA, INPUT_PULLUP);

    // Other setup instructions
}

void loop() {
    // Update the Bounce instance :
    pinA_debounced.update();

    if (pinA_debounced.rose())
        shutdown();

    // Other loop instructions
}

If you want to save your data in order to resume it, well, this highly depends on your actual code. You will have to identify what is your "current status", then save it to EEPROM.
Here is, for instance, a program which outputs on serial one sequential number (from 0 to 254, then restart from 0) every second. When you shut it down, it will start again from the last one:
#include <Bounce2.h>

const byte pinA = the pin A number;
const byte pinB = the pin B number;

const byte valueAddress = 0x10; // Any value is fine for this
// as long as it is in the available EEPROM

Bounce pinA_debounced = Bounce();
byte value;
unsigned long lastMillis;

void shutdown() {
    // Save status BEFORE turning down the power
    EEPROM.update(valueAddress, value);

    // Turn off the board
    digitalWrite(pinB, LOW);
    // Farewell, cruel world!
    while(1); // wait for a power off
}

void setup() {
    // Turn on the board
    pinMode(pinB,OUTPUT);
    digitalWrite(pinB, HIGH);

    // Initializate the debounced pin
    pinA_debounced.attach(pinA, INPUT_PULLUP);

    // Restore the current value from EEPROM
    value = EEPROM.read(valueAddress);
    Serial.begin(9600);
    lastMillis = millis() - 1000;
}

void loop() {
    // Update the Bounce instance :
    pinA_debounced.update();

    if (pinA_debounced.rose())
        shutdown();

    if ((millis() - lastMillis) >= 1000)
    {
        lastMillis += 1000;
        Serial.println(value);
        value++;
    }
}

If you rewrite the code to be a state machine so that loop() never blocks it's pretty easy to add:
bool paused = false;
void loop(){
    //read button
    if(buttonPressed){
        paused = !paused;
    }
    if(paused){
        return;
    }
    //rest of code written so it never blocks and returns as fast as possible
}

Then the resume part is handled by the extra already required by needing to be able resume on next call of loop.
If you go for full power off then you need to write out your state to non-volatile memory and read it back in on init.

This is not an answer to the question asked - you've neither shown how to control the Arduino's power, nor how to suspend it to a low power mode as an alternative to literally switching it on/off.

if I would press the button arduino code should stop working and when I will press the button back the code should resume from the moment where it stopped.

the simplest would be use an interrupt trigger by the button to set a flag and the execution would either loop around the flag or go straight through, depending on the state of the flag.

Just one question: why use an interrupt? I can understand if you have blocking code, so with an interrupt you can even never exit the interrupt function until the button is pressed again, but why use the interrupt like this?

@frarugi87 - Like most of "dannyf"'s posts this fails to address the question which is the topic of the page, but to answer your question, if you want to programmatically suspend a piece of code without its cooperation, an interrupt is in general your only choice.

@ChrisStratton I understand that, that's why I wrote "I can understand [you want to use interrupts] if you have blocking code". But danny's solution is to set a flag in the interrupt, then in the code loop on that flag until the flag is cleared. If you want to block an "uncooperating" code, you have to use an interrupt and never exit the interrupt until you want to resume operations, otherwise you can just poll the pin inside the program rather than checking for a flag..