text:
ESP32 Rebooting while converting String to Hex Array
I wrote this code to convert String to Hex Array.
const char* hexstring = "0x21 0x73 0x10 0xfa 0x7a 0x00 0xff .../*40995 character long string*/....0xaa"
void setup() {
    char* temp;
    //Serial.printf("%s",hexstring);
    unsigned int number[8199];

    number[0] = strtoul (hexstring,&temp,16);
    for(int i=1;i<8199;i++)
     number[i]= (int)strtoul(temp, &temp, 16);

    for(int i=0;i<8199;i++)
        {
            if(i%64)
                printf("\n");
            printf("%d, ",number[i]);
        }
}

void loop(){
}

But it is causing ESP32 to reboot.

Could anyone help me with the reason why?

I don't quite understand, what you are trying to do with your code. It doesn't make much sense to me. First: Why are you providing &temp to strtoul()? temp is an uninitialized pointer

Why do you write to number[0] two times instead of using number[i]? Why is that for loop only 5 iterations long, while the other, which does not write to number is 8199 iterations long? All in all I'm not sure how to help here other than pointing these things out. Maybe describe, what you are trying to do

@chrisl I corrected it, it was supposed to be number[i], after searching a bit I found a way to convert a string of hex values into array of hex values. So I have tried it in C online compiler it works fine.
Eg const char* hexstring = "0x21 0x49... becomes unsigned int number[8199]=[33, 73...

My bad, I edited the code to try a shorter string, and mistakenly copied that one. I corrected it now. Iteration is 8199

Still, why do you use temp uninitialized? At that position the parameter is the end pointer (pointer to where the conversion should stop). Null pointer here means conversion until end of string. So this comes down to if temp gets implicitly initialized to the null pointer. Might be the case for your online compiler. Please try using NULL instead of temp gor strtoul()

@chrisl, "where the conversion should stop"  It's actually used as at output not input. It doesn't tell strtoul where to stop lexing, it gives strtoul a means to tell the caller where it did stop. So you can use it to figure out where to resume your next operation, which is what they're doing. If you give it NULL you're just saying "I don't care where" you stopped. If you give it a pointer to a character pointer, you're saying "I do care where you stopped, tell me with this pointer that I'm pointing you at."

@timemage Ah, ok, then I guess I understood that wrong

void setup() {
    char* temp;
    //Serial.printf("%s",hexstring);
    unsigned int number[8199]; <----- too much.

So, you're trying to put a 32796 byte object on the stack. I don't know exactly why you're seeing the manifestation that you are, but I'm not surprised.
I just took an ESP32-CAM and started playing with different sizes and found that around 1800 (unsigned ints) is where things start to go sideways, failing occasionally rather than constantly.  By a 2000 count, it continually reboots with rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) transitioning to rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)   and later to very roughly around 5000 it becomes rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
I may fill out some details later if I look into it deeper. The ESP32 and SDK is complicated enough that there may well be a function can call that will permit a higher stack level. But this is mostly to satisfy curiosity.
Putting very large things (relative to the system size) on the stack is usually not done. I hesitate to try to tell you what exactly you should do; it wouldn't surprise me if you don't need this array at all for what you ultimately want to do, but that's a different question). So, I'll just say get it off the stack through either dynamic memory allocation (e.g. through new or malloc), possibly using a smart pointer (e.g. std::unique_ptr) to manage that since those are available on the ESP32, or perhaps just making the variable either a static local or global. Or again if possible finding out why you might not need this array.
Simple minimal change
So, I'm not going to tell you that this is a good idea, but a minimal change would be to static qualify this as static unsigned int number[8199]; Then you won't get that reset cause, here, for this reason.

Some details for anyone curious
If you want to see some of the guts, you look in the ESP32 core for Arduino where it creates the task that ultimately runs setup() for you. You can see that it calls getArduinoLoopTaskStackSize() returning ARDUINO_LOOP_STACK_SIZE which by default is 8192. 8192 bytes, not unsigned ints. With sizeof(unsigned int) being 4, this is very roughly in the vicinity of the 1800 unsigned ints where things started to fall apart in my testing above. Rather than chase down the configurion I just made a sketch that does Serial.println(getArduinoLoopTaskStackSize()); and yeah, it prints 8192.
getArduinoLoopTaskStackSize is a weakly defined function which would allow something to redefine in elsewhere in the program to overload the default one. So, just out of curiosity I wrote one as follows:
size_t getArduinoLoopTaskStackSize(void) {
  size_t r_size = sizeof(unsigned int [8199]); // exactly the size your array
  r_size += r_size >> 3; // add about 1/8 (or 12.5%) extra
  return r_size;
}

It no longer crashes. Should you do this? Probably not. But, if you ever have a legitimate reason to put a 32K array on the stack on an ESP32 it may be an option. I mostly just did this to see what would happen. It's barely been tested.


text:
Changing frequency by button press
I have to up the frequency by 100 hz by button press for upto 1khz; I am stuck on using the debounce source code. The problem is every time I press button the value for "i" goes to random number instead of going from 400 to 600 to 800 to 1000...to 2000.  I am using prescaler 1.
I have another question regarding the frequency. How can I get the frequency stable at 100hz per button press.
#define LEDPIN 7
float highTime;
float lowTime;
int freq;
float period;

//uint16_t val2= pulseIn(4, HIGH);

ISR(TIMER1_COMPA_vect) {
  digitalWrite(LEDPIN, !digitalRead(LEDPIN));
}
// constants won't change. They're used here to set pin numbers:
const int buttonPin = 5;    // the number of the pushbutton pin
//const int ledPin = 13;      // the number of the LED pin

// Variables will change:

int buttonState;             // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin

// the following variables are unsigned longs because the time, measured in
// milliseconds, will quickly become a bigger number than can be stored in an int.
unsigned long lastDebounceTime = 0;  // the last time the output pin was toggled
unsigned long debounceDelay = 50;    // the debounce time; increase if the output flickers

void setup() {

  Serial.begin(9600);
  pinMode(buttonPin, INPUT_PULLUP);
  //pinMode(ledPin, OUTPUT);

  // set initial LED state
  //digitalWrite(ledPin, ledState);

  pinMode(LEDPIN, OUTPUT);
  // initialize Timer1 (the 16-bit timer) using channel A output compare

  TCCR1A = 0; // set entire TCCR1A register to 0
  TCCR1B = 0; // same for TCCR1B
  TCNT1 = 0; // initialize counter value to 0
  // set compare match register for 100 Hz increments
  OCR1A = 9999; // = 16000000 / (8 * 100) - 1 (must be <65536)
  // turn on CTC mode
  TCCR1B |= (1 << WGM12);
  // Set CS12, CS11 and CS10 bits for 1 prescaler
  TCCR1B |= (0 << CS12) | (1 << CS11) | (0 << CS10);

  // enable timer compare interrupt
  TIMSK1 |= (1 << OCIE1A);
  sei(); // allow interrupts
  interrupts(); // enable global interrupts:
}

void loop() {

  // read the state of the switch into a local variable:
  int reading = digitalRead(buttonPin);
  int MIN = 400;
  int MAX = 2000;
  int i = 0;
  int change = 200;
  int var = 16000000 / (1 * i) - 1 ;
  // check to see if you just pressed the button
  // (i.e. the input went from LOW to HIGH), and you've waited long enough
  // since the last press to ignore any noise:

  // If the switch changed, due to noise or pressing:
  if (reading != lastButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
  }
  for (int i = 400; i <= 2000; i += change) {
    if ((millis() - lastDebounceTime) > debounceDelay) {

      // whatever the reading is at, it's been there for longer than the debounce
      // delay, so take it as the actual current state:

      // if the button state has changed:
      if (reading != buttonState) {
        buttonState = reading;

        // only toggle the LED if the new button state is HIGH
        //for(int ii=MIN; ii<MAX; ii++){
        //

        if (buttonState == HIGH) {
          Serial.print("Value of i: ");
          Serial.println(i);

          //for(int i=MIN; i <= MAX; i+=change){
          //int var = 16000000 / (1 * (ii*2)) - 1 ;
          buttonState != buttonState;
          TCCR1A = 0; // set entire TCCR1A register to 0
          TCCR1B = 0; // same for TCCR1B
          TCNT1  = 0; // initialize counter value to 0
          OCR1A = 16000000 / (1 * i) - 1; // =  (must be <65536)
          // turn on CTC mode
          TCCR1B |= (1 << WGM12);
          // Set CS12, CS11 and CS10 bits for 1 prescaler
          TCCR1B |= (0 << CS12) | (0 << CS11) | (1 << CS10);
          // enable timer compare interrupt
          TIMSK1 |= (1 << OCIE1A);
          highTime = (pulseIn(4, HIGH));
          lowTime = (pulseIn(4, LOW));
          period = highTime + lowTime;
          freq = 1000000 / period;   //getting frequency with totalTime is in Micro seconds
          Serial.print(freq);
          Serial.print("\n");
        }
        //}
        //  }

      }
    }
  }

  // save the reading. Next time through the loop, it'll be the lastButtonState:
  lastButtonState = reading;

}

add a layer of separation between button press detection and the frequency adjustment ... use a flag variable ... check for button press at top of loop() ...  if a valid button press is detected, then set the flag ... do no other response to button press ... further down in loop(), check for the flag ... if it is set, then adjust frequency and clear the flag

can you show me example?

use the Bounce2 library for button handling

source: Stack Exchange

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

sort: votes


text:
How to get power for a nexus 7 while reading serial data from an arduino over usb?
Does anyone know how to simultaneously power a Nexus 7 tablet while simultaneously reading serial data from an arduino over USB? I have had quite some trouble with this and have attempted multiple combinations of usb splitters but no luck. I have also tried to use the nexus's inductive charging while using the arduino usb power. While this does work I need to use the Nexus NFC chip at the same time. What I really need is a solution that allows me USB Data, NFC, and power all at the same time.

You could make a custom cable with three plugs. Connect all red and black wires, but only the other two between the arduino and the nexus. When you plugin the third plug into an DC-Source, both devices get powered. The serial connection should work. Did this with an openmoko freerunner once.

Do you have any tutorials or articles you could point me to for how to get started with this?

I have been at this for 3 days with no luck. Ive cut up and spliced every combination of usb cable i can think of. Does anyone else have any other thoughts?

Oh, I remember that I had to solder a resistor somewhere to make the phone charger think, he can deliver more mA. The charger tend to limit the power to 500mA, which may not be enough though. Try to trick the charger into thinking, that he could provide more mA, because the client can "load" faster. Also try a completely different power supply, preferably not a phone charger.

I can speak only to the USB power, and this is a good article (you can ignore the parts about USB-C): https://www.androidauthority.com/usb-type-c-and-3-1-explained-656552/
To be clear, it's POSSIBLE you wired the cable correctly (did communication work??) but without the resistor then the Nexus will deliberately limit it's power draw to 500ma, or not try to charge at all.  a USB OTG cable might also do the trick..

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


text:
Arduino Pro Micro and HC-05 Bluetooth module
I am using Sparkfun Arduino Pro Micro with an ATmega32u4(3.3v, 8MHz) on it (https://www.sparkfun.com/products/12587) and a HC-05 Bluetooth Module. I also running this on Windows 10.
I've made these connections: (same as this tutorial) with some additional for leds
Arduino Pro Micro TxD (Pin 0) -> HC-05 RxD
HC-05 TxD -> Arduino Pro Micro RxD (Pin 1)
I am following this tutorial: http://playground.arduino.cc/Learning/Tutorial01
I have two Serial ports available for the HC-05 COM30(incoming) and COM31(Outgoing). When I try to send letter 'H' in Serial monitor on COM31 the arduino ide freezes and the HC-05 flashes rapidly. When I try to send letter 'H' in Serial monitor on COM30 it sends but nothing happens as H should ideally turn on the led. The arduino pro works with a button but I would like to send the command externally as in the tutorial. I also try in processing but the same thing happens as when using the arduino serial monitor. I have been trying for a couple of days now with no idea why it is not working, I have tried adjusting baud rates and changing to Serial1 with no change.
I uploaded this to the Arduino to test the Bluetooth module:
#include <SoftwareSerial.h>

char val; // variable to receive data from the serial port
int ledpin = 6; // LED connected to pin 48 (on-board LED)
int ledpin2 = 5;
void setup() {
  pinMode(ledpin, OUTPUT);  // pin 48 (on-board LED) as OUTPUT
  pinMode(ledpin2, OUTPUT);  // pin 48 (on-board LED) as OUTPUT
  Serial.begin(9600);
  Serial1.begin(9600);       // start serial communication at 9600bps
}

void loop() {
  if( Serial1.available() )       // if data is available to read
  {
    digitalWrite(ledpin2, LOW);
    val = Serial1.read();         // read it and store it in 'val'
  } else {
    digitalWrite(ledpin2, HIGH);
  }
  if( val == 'H' )               // if 'H' was received
  {
    digitalWrite(ledpin, HIGH);  // turn ON the LED
  } else {
    digitalWrite(ledpin, LOW);   // otherwise turn it OFF
  }

  delay(100);                    // wait 100ms for next reading
}

Processing code:
//import class to set up serial connection with wiring board
import processing.serial.*;
Serial port;
//button setup
color currentcolor;
RectButton rect1, rect2;
boolean locked = false;
void setup() {
  //set up window
  size(200, 200);
  color baseColor = color(102, 102, 102);
  currentcolor = baseColor;
  // List all the available serial ports in the output pane.
  // You will need to choose the port that the Wiring board is
  // connected to from this list. The first port in the list is
  // port #0 and the third port in the list is port #2.
  println(Serial.list());
  // Open the port that the Wiring board is connected to (in this case 1
  // which is the second open port in the array)
  // Make sure to open the port at the same speed Wiring is using (9600bps)
  port = new Serial(this, Serial.list()[2], 9600);
  // Define and create rectangle button #1
  int x = 30;
  int y = 100;
  int size = 50;
  color buttoncolor = color(153, 102, 102);
  color highlight = color(102, 51, 51);
  rect1 = new RectButton(x, y, size, buttoncolor, highlight);
  // Define and create rectangle button #2
  x = 90;
  y = 100;
  size = 50;
  buttoncolor = color(153, 153, 153);
  highlight = color(102, 102, 102);
  rect2 = new RectButton(x, y, size, buttoncolor, highlight);
}
void draw() {
  background(currentcolor);
  stroke(255);
  update(mouseX, mouseY);
  rect1.display();
  rect2.display();
}
void update(int x, int y) {
  if(locked == false) {
    rect1.update();
    rect2.update();
  } else {
    locked = false;
  }
  //Turn LED on and off if buttons pressed where
  //H = on (high) and L = off (low)
  if(mousePressed) {
    if(rect1.pressed()) {            //ON button
      currentcolor = rect1.basecolor;
      port.write('H');
    } else if(rect2.pressed()) {    //OFF button
      currentcolor = rect2.basecolor;
      port.write('L');
    }
  }
}
class Button {
  int x, y;
  int size;
  color basecolor, highlightcolor;
  color currentcolor;
  boolean over = false;
  boolean pressed = false;
  void update()
  {
    if(over()) {
      currentcolor = highlightcolor;
    } else {
      currentcolor = basecolor;
    }
  }
  boolean pressed()
  {
    if(over) {
      locked = true;
      return true;
    } else {
      locked = false;
      return false;
    }
  }
  boolean over()
  {
    return true;
  }
  void display()
  {
  }
}
class RectButton extends Button {
  RectButton(int ix, int iy, int isize, color icolor, color ihighlight)
  {
    x = ix;
    y = iy;
    size = isize;
    basecolor = icolor;
    highlightcolor = ihighlight;
    currentcolor = basecolor;
  }
  boolean over()
  {
    if( overRect(x, y, size, size) ) {
      over = true;
      return true;
    } else {
      over = false;
      return false;
    }
  }
  void display()
  {
    stroke(255);
    fill(currentcolor);
    rect(x, y, size, size);
  }
}
boolean overRect(int x, int y, int width, int height) {
  if (mouseX >= x && mouseX <= x+width &&
      mouseY >= y && mouseY <= y+height) {
    return true;
  } else {
    return false;
  }
}

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


text:
WiFi thermometers: save different location string as const across many devices
I've built a very simple WiFi thermometer out of an Adafruit ESP8266 HUZZAH breakout board and a TMP36 temperature sensor. I have it reporting the temperature over wifi to my computer which will be storing the data in a database for monitoring purposes. I'd like to make multiple of these devices and place them around the house. My question: I currently have the location of the board as a const char* on the board itself. Doing this for multiple devices is just a bad idea and a nightmare to manage. Is there some way of setting a location variable on the board that will persist across shutdowns? Or am I coming at the problem from completely the wrong direction?

Why not just use the (unique) IP address of each module to identify it and map that to a name on the PC?

I was thinking that would solve the issue, but I'd rather have the resolution contained within this system rather than relying on configuring my router as well.

With a set of DIP switches or jumpers on some of the GPIO, you could encode a unique number for each one - 16 of them with 4 I/Os f/ex. The same code could run on all of them, sample the unique ID  report it along with the temperature. Let the PC-side map IDs to locations.

I like this. Your answer gave me an idea though. I can get a MAC address from the breakout board. Would the MAC ever change? If not, I could send the MAC of the board along with the other data and do some server side mapping with the MAC.

I don't know how the Lua firmware works, but the AT+ interpreter firmware includes commands to set the chip's MAC address, so, yes, it can be changed, but that's a change you would have to make, not one that I could ever imagine would be programmed to happen without you taking explicit action.

The MAC address comes from the ESP8266 chip, not from the breakout board

@JaromandaX: Yes, that's correct. And ?

Just clearing up @Taelsin's misconception that the breakout board has something to do with the MAC address, if that's OK with you


text:
What should I learn next in arduino?
This what I have learned :
digital inputs and outputs

Analog inputs and outputs

Line follower ir sensor

Pir sensor

Ultransonic sensor

Ir transmitter and reciever

Lcd

Key pad

Dc motor

Stepper motor

Servo motor

Interrupts

Timers

Watchdogs

 Arduino with raspberry pi

This topics a made with it some projects so the question is what is next to learn about arduino ? What should be my next steps ??

That really depends on what your goals are. As written, this question can only be answered with personal opinions. Arduino StackExchange is better suited for more objective questions and answers. You may be able to re-write or add to the question to make it possible to answer more objectively.

You say you have learned these things but were you using a motor shield for the DC motor?  How's about building your own H-bridge. And how many types of stepping motors do you now know how to control?  What about micro stepping? And what about graphical LCDs. Do you know how to make custom characters?
As your list is hardware-centric, I would next task you to learn how to write in C++ and create a library for others to use.  Learn what it means to abstract the hardware down to a few simple function calls.  How to create a class which contains an Arduino library for, say, the graphical features of a particular LCD.

Yes I know how to design circuits and drivers such as h-bridge and I use unipolar and bipolar steppers but I don't use the graphical lcd because I use raspberry pi and python Gui instead

The stack exchange paradigm of specific questions and concise answers does not really allow for your type of question ... which, no matter how you word it, is too broad.  That said, do not take my answer too literally.  Instead of arguing against it, find some other hardware (an accelerator chip maybe?) and write an Arduino C++ library for it.  The process actually parallels real life embedded engineering more than most realize.  And, because of that, will give you marketable experience.  Or, in other words, not too many companies will pay for sketches, but C++ HW drivers?  That's a yes.

I will try that

May I add: Python and its GUI is hardly embedded. Being able to program a graphical interface with only 2K of RAM - now that's programming!

Yes I know gui using tkinter and kivy with python

I would get myself familiar with low power, sleeping modes, running on batteries.
Also connect others devices using SPI and I2C to familiarize yourself.
Finally give a go on different communication methods... over serial, ethernet, wireless, can bus, etc. No much point in having stand-alone projects that are isolated or always connected to an USB port. IMO the fun begins when your projects start to talk to each other and to the Internet.
Cheers

Combine
I see a lot of loose "projects", but try to fit (as much as possible) into one single project. Make a line following robot, that balances, has WiFi communication and a display.
Putting all the different parts together may create whole new problems/difficulties.
Stop using Arduino?
Find another IDE, so it's easier to manage a lot more code.
Learn how to set up a toolchain/compiler.
Try programming an ATMega328P without Arduino.
Why? Because it'll learn you how to other devices work, if you're comfortable programming an AVR without Arduino, it's just a little step to using PIC microcontrollers.
Hardware
Design yourself a PCB specific for the project you want to do.
Work on "Professional skills"
Try to make some actual designs, requirement analyses and make a report on the project. This way you can practice for school/future jobs' professional skills.
So what project should you do?
Something you would really like to do.
It's as simple as that.
Something of which you think is going to be a challenge (but not too challenging).

The Nrf24L01 is an inexpensive wireless transceiver with very good Arduino library support, and there are still library opportunities, like star and mesh interconnections. It also requires less overhead than WiFi and ethernet. If you're PhD material, you could implement the OSI stack.

Definitely try to make practical projects that make sense and are actually useful in real life. Automation projects for "smarter home" lets say really do come in handy and it is extremely satisfying when you use them. They don't have to be huge, just do something small that you find interesting. Documenting what you have done and keeping something like a report will help you big time in the future.
I suggest you decide if you like C++ and if you do dig deeper into it.


text:
Is cheap away arduino trustworthy
I have recently decided to buy an arduino over a raspberri pi and have been shopping for a good deal and learning about which model I need and where to buy.
I have come across a few very cheap arduino uno boards that are identical to every other board. These range from an unbelievable $4-$15. Are they officially branded and/or are they trustworthy?
Here is a link to a few links to some I've found:
http://m.ebay.com/itm/New-UNO-R3-ATmega328P-Development-Board-For-Arduino-Compatible-USB-Cable-DIY-/311418263595?nav=SEARCH
http://m.ebay.com/itm/NEW-UNO-R3-ATmega328P-CH340-Mini-USB-Board-for-Compatible-Arduino-WL-/161883302204?nav=SEARCH

The second link is not an exact UNO replica (different FTDI circuitry for USB -> potential driver issues). The first one seems an exact clone (from the PCB view), but obviously not officially branded, and probably using cheap components, all made and assembled in China. Personally I would not go for it.

@jfpoilpret I think it's worth a shot for 1/10 or the normal.arduino price

@J-Clarke I would not because it may appear to work for some time or for some fatures, but if some day it does not work for a new experiment, you will waste a lot of time finding out whether it is due to your program, your circuit or to this poor quality chinese clone (2nd link) or counterfeit (1st link). I can tell that, when working with reliable material, it is already difficult to "debug" your experiments, let alone when using crap...

@jfpoilpret Well the way I look it is like.your first car you buy a wreck because you have no idea howbto use it and you will probably overvoltage it or short the pins by accident

@jfpoilpret - the official Arduino Uno does not use an "FTDI" either.  FTDI is a brand, and perhaps semi-legitimately a casual reference to their flagship FT232 USB-serial chip.  But it is not a valid term for the USB-serial function in general especially in a case where the leading product - the Uno - doesn't even use that chip either.  You are right though that the ch340 can cause some headaches.

The CH340 needs unsigned drivers, which is a little harder to install in Windows 8/10 and OSX, but completely possible. Mine is running fine and can easily do 115k2 baud. I've also got one with FT232, but it appears that FT232 was a counterfeit, which initially bricked the chip. You would then have to reset the VID and PID of the chip, which honestly gave me more of a headache.

Caveat Emptor.
If it's not genuine you can never be sure quite what you are getting. You have to ask with some of then just how they can make them so cheap. Poor quality components is one way. Either counterfeit or reject components which may fail after a short time, or under certain conditions is a big risk.
There are different grades of board each with their own risks...

Genuine. High price, good reliability and quality. Good after sales support. Supports the Arduino cause.
Arduino clone. Genuine Arduino design made by a reputable third party. Almost as good as option 1 but doesn't support Arduino financially.
Arduino Based. A board created for a specific job that is based around genuine Arduino design. Support really only from the (often smaller) manufacturer. Quality varies.
Chinese clone. Low grade components made to original Arduino designs. Little or no support. Poor quality. Often with different USB interface that is unstable and low quality.
Counterfeit. Low quality components. Claims to be a genuine Arduino. Bad build quality.

Options 1-3 are ones I would consider buying. 4 and 5 I would stay well away from.

All the comments on these boards appear to be positive and reflect high quality. All the cheap boards on ebay have 4.5 or more stars. I think they are worth a punt

Be wary of high reviews these days, most of those are fake too. http://i.huffpost.com/gen/2575582/thumbs/o-WET-570.jpg?7

How many Arduinos do you need? If you are just getting one to learn on, for heaven's sake pay the extra fifteen bucks and support the cause.
If you are manufacturing something and need a few dozen boards, buy 50 Chinese ones and chuck the ones that don't work.

I live in Australia and arduino costs about 40-60 dollars

Actually I find many of the ebay shops very conscientious about their items, I have had a few experiences with defective items from ebay and must say that I've still not had a bad experience whether i get my money back or they resend the item, the downside is that it will take a new month for the replacement to get to me, money back usually goes within a few hours.

I wouldn't recommend using ebay-arduinos for "manufacturing". For fun little hobby projects it will be okay. @HansNeve, indeed, I had received a full refund because 2 out of 4 servo's were lost in transit. So I received 2 servo's and didn't have to pay for anything :) (and didn't have to send them back)

While, yes, caveat emptor, I have purchased a number of devices which are based on the Arduino open design. I have not yet had a problem.
Remember that, if you buy more expensive, prominently "Arduino" branded parts, from a third party, you also have no guarantee that they are quality controlled by Arduino. Even "genuine" electronics parts are usually manufactured in China, often in the same factories.
To answer your question, there are a number of ways the costs can be kept down:
Lack of unions, lack of labor laws, economies of scale, markup by the "official" companies, lack of development costs (remember, Arduino is open hardware, copying is allowed), cheap labor, tax, transport costs (there is some trickery in some countries, including Hong Kong, which makes shipping essentially free), shorter supply chain, cheaper components, smaller marketing budget.


text:
Arduino vs Raspberry, Advantages And Disadvantes
I have done extensive research into the differences and here are the questions i have:

What is a micro controller and what differs it from the raspberry pi system
Why buy the Arduino when it is less powerful than the raspberry pi
What projects would either system be better for
Does Arduino run a full OS
Where is the best place to buy arduino and raspberry pi
What is the difference in the ad dons
Which has the most tutorials
What is the different's in power supply and usages
I know i'm asking this on a forum with arduino fans (There is no arduino vs raspberry pi forum) but opinions aside which is the best for beginners (I can program C++ and python as well as building hardware components)
What is the general price different overall including buying extra ad dons/shields

Thank you for your answers :)

This question is also on the Raspberry pi forum to ensure non baits answers: http://raspberrypi.stackexchange.com/questions/43458/arduino-vs-raspberry-advantages-and-disadvantes

Cross-posting within Stack Exchange is not permitted. See: Is cross-posting a question on multiple Stack Exchange sites permitted if the question is on-topic for each site?

And here the answer is the same as the one to this question: "which is better, a car or a a pc?".. the answer is.. it depends! They are completely different systems, with completely different targets, completely different requirements (required electronics, user skills, environment...), It depends on your application. USUALLY simple = arduino, complicated = raspberry, interaction = both, but... it depends ;) The only "real" question is number 4, and its answer is NO, Arduino does not have an OS (you are writing the whole code, no layers between you and the hardware)

1) Here is a great article about microcontrollers and how they differ from a full computer: http://electronics.howstuffworks.com/microcontroller1.htm
tl;dr: A Raspberry Pi runs a full desktop OS (often Linux) and as such, can do most of the things a "typical" computer can do, such as browse the internet or install different programs. An Arduino, however, cannot do that. An Arduino can run one piece of software that you program to it (called a sketch in the Arduino world) and repeat that same program over and over.
2) They have different purposes. A Raspberry Pi is designed as a low-cost desktop computer that you can put anywhere, and also as a platform that is easy to put into different projects. An Arduino is better suited for attaching sensors to, controlling motors, etc.
3) see #2
Also, a Raspberry Pi is typically used when a GUI is wanted, or when more computing power is required. An Arduino is typically used for more real time things such as reading sensors or controlling LED's.
4) No, it does not. Arduino's run C++ compiled as machine code object files.
5) For the Raspberry Pi, Here is the list of official resellers: https://www.raspberrypi.org/products/model-b-plus/
For the arduino, it depends on what kind you're buying and where you live, there are many different styles.
6) As a general rule, Arduino's have more shields. But, a raspberry pi typically needs a screen, mouse, keyboard, etc. Everything a standard computer needs.
7) Entirely depends on what you're trying to do.
8) Both take a 5V input voltage. An Arduino can take up to a 20v input (again, depending on the model) whereas the Raspberry Pi can just be powered with 5v over USB.
9) Again, depends on what you're trying to do. A Raspberry Pi is "easier" to use, as it's a full computer.

Thank you very much i'm thankful for your answer i think the arduino is for me. I like more of the technical side of things :) and plus I've already got a pico itx setup which is very similar to the raspberry pi anyway. And hey the arduino forums seem to be nicer then the snobby raspberry pi fans :p


text:
ADC timer interrupt when ready
I have a microphone and I need as precise values as possible. I have been told by my teacher, that it is somehow possible to make a ADC timer interrupt, which would interrupt always when the value is ready, so that the reading itself would not slow the program down.
    I know, how to use timer interrupts to read the analog value every other ms or something and I even have a code that lets the ADC read automaticly and takes the value, but I need to make it take the value always when it's ready, so that I would have every value the ADC read. I tried to look into the datasheet, but it's too complicated for me.
   How can I achieve such thing? I am using arduino uno.
this is the code I have that sets up the ADC interrupt:
  ADCSRA = 0;
  ADCSRB = 0;
  ADMUX = 0;
  ADMUX |= (1 << REFS0) + (1 << REFS1);
  ADMUX |= (1 << ADLAR);

  ADCSRA |= (1 << ADATE); //enabble auto trigger
  ADCSRA |= (1 << ADIE); //enable interrupts when measurement complete
  ADCSRA |= (1 << ADEN); //enable ADC
  ADCSRA |= (1 << ADSC);
  ADCSRA |= 0b010;

ISR(ADC_vect) {//when new ADC value ready
  af = af + ADCH;
  aaf++;
}

I found this on the internet, but it didn't work as I expected.

ISR(ADC_vect){...} You also probably want to use a timer to start the conversions at an constant interval.

@Gerben: You can also have the ADC trigger itself at a constant rate if you set it to the so called “free running mode”.

@EdgarBonet that rate would be as fast as it can. Aky-her might want to use a lower speed.

@Gerben: Right, but “as fast as it can” is 9615 S/s, which is not excessive for audio processing, and is easier to achieve since you have only one device to configure instead of two.

By “as precise values as possible”, do you mean accurate voltage readings, or accurately-timed, or what?

At 4 MHz, you are clocking it too fast.

I have been told by my teacher that it is somehow possible to make a ADC timer interrupt.

You might have asked him or he could explain it ;)
Generally, if you want to do anything with an Arduino, which isn't implemented by the Arduino libraries, you're going to have to roll your own code (or copy it from the internet).
The answer from Nick will most certainly be enough to help you with the problem. However, it'd be way more cooler to find out how you can solve these problems yourself.
Getting started
I couldn't find a duplicate of this question, though it's a rather common question. You should've checked some of the tutorials on the web, it'll get you started a lot faster.
But don't forget the datasheet and manuals of the ATMega328(P). In case you can't really find something that fits your needs, or if you want to check some background information.
Setting registers (ADC)
This piece of code (from Nick Gammon), sets up the ADC.
  ADCSRA =  bit (ADEN);                      // turn ADC on
  ADCSRA |= bit (ADPS0) |  bit (ADPS1) | bit (ADPS2);  // Prescaler of 128
  ADMUX  =  bit (REFS0) | (adcPin & 0x07);    // AVcc and select input port

Fair enough, but if you wanted to change anything of it, you'll think: "How did he ever come up with this."
These are the registers of the microcontroller. By setting bits in the right pattern, you can enable/disable functions or change settings of the microcontroller.
You should download the ATMega328(P) datasheet. You can very easily navigate through it (if you've got a PDF reader that supports "bookmarks").
Check for "24. Analog to Digital converter" you should read through it, and go to "24.9 (Analog to Digital converter) - Register description.".
Here you can see, which bits of (in example) the ADCSRA register you have to set to enable the adc (ADEN), start the conversion (ADSC). And enable interrupts for it (ADIE).

Interrupts
Since you also want behavior that has to do with interrupts. You should also check out the interrupts bookmark (#12). 12.1 will show you an table with all interrupt vectors.
It's quite a shame that they don't have a nice C example code, they do have an reference manual though, but you'll implement an interrupt handler like this (from Nick Gammon).
// ADC complete ISR
ISR (ADC_vect)
  {
  adcReading = ADC;
  adcDone = true;
  }  // end of ADC_vect

If you now want to interrupt on SPI you can check the datasheet or reference manual for the vector name. (SPI_STC_vect)

it is somehow possible to make a ADC timer interrupt

The ADC and the timers are two different things. If you mean a timer interrupt, I'm not sure why you would want that. If you mean an ADC interrupt, yes you can do do that.
Here is some example code from my page about the ADC which shows using the interrupt (on a Uno):
const byte adcPin = 0;
volatile int adcReading;
volatile boolean adcDone;
boolean adcStarted;

void setup ()
{
  Serial.begin (115200);
  ADCSRA =  bit (ADEN);                      // turn ADC on
  ADCSRA |= bit (ADPS0) |  bit (ADPS1) | bit (ADPS2);  // Prescaler of 128
  ADMUX  =  bit (REFS0) | (adcPin & 0x07);    // AVcc and select input port

}  // end of setup

// ADC complete ISR
ISR (ADC_vect)
  {
  adcReading = ADC;
  adcDone = true;
  }  // end of ADC_vect

void loop ()
{
  // if last reading finished, process it
  if (adcDone)
    {
    adcStarted = false;

    // do something with the reading, for example, print it
    Serial.println (adcReading);
    delay (500);

    adcDone = false;
    }

  // if we aren't taking a reading, start a new one
  if (!adcStarted)
    {
    adcStarted = true;
    // start the conversion
    ADCSRA |= bit (ADSC) | bit (ADIE);
    }

  // do other stuff here

}  // end of loop

I should point out that if you do an analogRead it blocks until the read is done, so the very next line to be executed after analogRead will be when the data is ready.


text:
'serialWrite' was not declared in this scope
Please help me! Once I click the upload button.
I get the following error:

'serialWrite' was not declared in this scope

Here is my code:
int buttonPin
void setup ()
{
beginSerial(9600);
pinMode (buttonPin, INPUT);
}
void loop ()
{
if (digitalRead(buttonPin) == HIGH)
serialWrite('H');
else
serialwrite('L');
delay(1000);
}

Where did you see that anything called "serialWrite" is supposed to exist?

Pay attention to the examples. They would have had Serial.begin (9600); - not beginSerial(9600);. You can't just re-arrange words and drop off punctuation.

Also, int buttonPin won't compile.

Same code! After I upload it. It was an error.  avrdude: stk500v2_getsync(): timeout (something like that


text:
Will there be any pin interference in this Project?
I am working on a project with Arduino Uno Clone. After having a look on my arrangement, please tell me whether I will have to face any difficulty or consider any thing.
I have a relay on pin 2 (drive An Induction cooktop from AC Mains),
6 mini 9g servo from pin 3-8 (want to drive non-pwm pins with any Software library),
a 8 ohm speaker on pin 9,
a microSd card module from pin 10-13 (play .wav files through speaker),
5 pushbuttons from pin A0-A4,
a toy dc motor on A5 (Drive through a transistor). So my questions are:

Will I have to face any pin arrangement problem in my project? If yes, please give me a solution
I have six servos and a dc motor in which only one will be moving at a time, is there really a need of external power source for motors
I have to drive this arrangement through AC Mains, but i dont want to buy An adapter. I have a mobile charger which have written "INPUT 100-250V AC, OUTPUT 4-12V, 800mA" , can I drive my arduino with this?
Can I boost the volume of my speaker by using a transistor or capacitor (I have no idea about amplifier IC) ?
I have to include these librairies, SD library, tmrpcm, SPI, servo, and any one extra to drive servos on non-pwm pins. What would be the total size because my arduino has only 30kb approx?  Thanks To Give Me Time. Please help me.

possibly you will face problems with current drain and timing. There is no ready made solution. You have to get a bit farther by yourself and come back with detailed descriptions of your problems.
check on other threads (google) the issues with driving directly a coil. There are plenty of explanations why you need to be careful about it.
you should at least try to do the math yourself, then ask for verification. Try to calculate the power requirements of each component (average, maximum, peak) and add them up for every scenario. The you can report your finding and ask for confirmation/advice.
Sure you can, there are plenty of solutions available, but you have to define your requirements and constraints. Then it's easy to pick one solution (or at least google for it).
Just try to include them in the project and compile them. It's fast and you will get the answer immediately. There are ways to optimize things, but first you should assess if it's needed.

All in all, to get more help, you should show more in detail what you have already done, what are your concerns and why.

Thanks for Your Time. Basically, after seeing your answer I think that there is a very less chance of any type of pin interference. Sorry, because I am just a student without any special technical background. I am googling these topics. If i get any problem, i will Clear it with you


text:
Esp32(Arduino Core) + Blynk Wifi Connection Problems
So I am making a football playing robot which consists of 3 servo motors. Currently,i am only checking only a single servo(myservoKicker)which is operated via button in the blynk app and trying to read x and y values from joysticks in blynk. I am using wifi communication. I have seen that wifi.begin never properly starts as the serial.print("Blynk Connected") after it does not run, plus on my blynk app the project constantly connects and disconnects.
Note: The code for steering other servo's is not implemented yet and is just a stub.
Board: DoIt ESP32 Devkit V1 30 GPIO
Blynk: 0.6.1
myservoKicker connected to pin 13
#include <ESP32Servo.h>
#include <SPI.h>
#include <Ethernet.h>
#include <ETH.h>
#include <WiFi.h>
#include <WiFiAP.h>
#include <WiFiClient.h>
#include <WiFiGeneric.h>
#include <WiFiMulti.h>
#include <WiFiScan.h>
#include <WiFiServer.h>
#include <WiFiSTA.h>
#include <WiFiType.h>
#include <WiFiUdp.h>
#include <BlynkSimpleEsp32.h>

Servo myservoKICKER;
Servo myservoLEFTWHEEL;
Servo myservoRIGHTWHEEL;
int pos;

char auth[] = "9Itekdu3vf_B_3YmNxxHu9G3Bs_1IWs9";
char ssid[] = "RO IMRAN RO";
char pass[] = "xxxxxxxxxxx";
char localserver[16]= "192.168.1.1";
BLYNK_WRITE(V1)
{
    int xAxis = param[0].asInt();
    int yAxis = param[1].asInt();

    // Do something with x and y
    Serial.print("X = ");
    Serial.print(xAxis);
    Serial.print("; Y = ");
    Serial.println(yAxis);

}
BLYNK_WRITE(V4){                                        //WHEEL CALIBRATION
    int WheelCalibration=param.asInt();
    if(WheelCalibration == 1)
    {
        myservoLEFTWHEEL.attach(26);
        myservoRIGHTWHEEL.attach(27);
        delay(100);
        myservoLEFTWHEEL.write (90);
        myservoRIGHTWHEEL.write (90);
        delay(30000);

    }
}
BLYNK_WRITE(V5){                                        //KICKER 90 DEGREE CALIBRATION
    int KickerCalibration= param.asInt();
    if(KickerCalibration == 1)
    {
        myservoKICKER.attach(13);
        delay(100);
        myservoKICKER.write (90);
        delay(200);

    }
}

void setup(){
    // Attach servos to pins
    myservoLEFTWHEEL.attach(26);                        //1
    myservoRIGHTWHEEL.attach(27);                       //2
    myservoKICKER.attach(13);                           //3

    // detach servos to avoid jitter on power up
    myservoLEFTWHEEL.detach();
    myservoRIGHTWHEEL.detach();
    myservoKICKER.detach();

    Serial.begin(115200);
    delay(10);
    Serial.print("Connecting to ");
    Serial.println(ssid);
    WiFi.begin(ssid,pass);
    int wifi_ctr = 0;
    while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
    }
    Serial.println("WiFi connected");
    Blynk.begin("9Itekdu3vf_B_3YmNxxHu9G3Bs_1IWs9",ssid,pass);
    Serial.println("Blynk connected");
}

void loop()
{
    Blynk.run();
}

1st - try to set option EraseFlash -> Sketch+WiFi Settings
2nd - try to set WiFi.hostname() before WiFi.begin()

the Blynk.begin does WiFi.begin. so remove your WiFi.begin

Your code is not indented properly, which makes it confusing and hard to follow.

just focus on this bit of code:

Serial.begin(115200);
delay(10);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid,pass);
int wifi_ctr = 0;
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("WiFi connected");
Blynk.begin("9Itekdu3vf_B_3YmNxxHu9G3Bs_1IWs9",ssid,pass);
Serial.println("Blynk connected");
}

Did you erase  "Sketch+WiFi Settings"? Did you call WiFi.hostname(...);?

@gbg, how is it relevant? if the wifi settings are deleted they will be stored again, since the sketch passes the ssid and password. and what with hostname? Blynk doesn't care about hostname

@Juraj WiFI.hostname() - sets hostname for DHCP query. My WiFi router does not answer on DHCP query without the hostname set, so, the ESP does'n connect to the WiFi.

@gbg, hostname is always set somehow

@Juraj, IDK, in my case, without this line, connection fails

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


text:
Where are the programatic definitions for different processors stored?
I need to modify an existing library that relies on being able to detrmine what board / processor the code is being run on. To do this, it uses definitions such as this for an Arduino Mega:
// Arduino Mega
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)

I need to update the library for a further 2 boards, namely the Raspberry pi pico (mbed os) and the Robotis OpenCR.
I can't seem t find where the processor name is actually defined. If someone could point me in the right direction, that would be great. Thanks.
Edit:
If anyone knows what the equivelent define is for the raspbery pi pico - rp2040, that would be fantastic!

in Arduino you can use macro ARDUINO_{build.board}  where build.board is defined in boards.txt for example as uno.build.board=AVR_UNO. the #idef is then #ifdef ARDUINO_AVR_UNO

the more you can avoid board detection, the more places your program will run or just need a slight modification instead of something that confuses the developer.

They are defined by the compiler itself, and based on the name of the microcontroller passed to the compiler as (for AVR GCC) -mcpu=<mcu name>.
You can list the defines for a version of GCC using (for example for AVR gcc):
avr-gcc -mmcu=atmega328p -dM -E - < /dev/null

Not sure what you'd use on Windows for /dev/null. Different target compilers use different flags to define the MCU, and you of course need to know the MCU the board uses to pass to the compiler.
You will have to investigate what relevant flags are passed to the compiler for your desired chips, and you can find those by looking in the platform.txt file for the core associated with the board.

I'm most interested in the pico, which would be RP2040 or some variant of that name. I'm not sure it uses the GCC compiler, could be wrong though.

Almost everything that's not Microsoft uses the GCC compiler...


text:
why can Arduino variables of int type contain a value such as A2
How come the following statement is true:
int inputPin = A2;

I thought int variables can only hold integer numbers. Is the A just a representation of a number?
Thanks for any help

Normally, I'd vote to close this, as it's pretty simple and really language related and there's an endless pile of those questions.  But, I've seen this question come up countless times in conversation with new Arduino users in almost exactly this form, often citing A0 instead.  So, I'm voting to leave it open.

It would probably be better written "following statement is valid" or something to that effect, as opposed to "true".

You are correct. A2 is just a number (like everything in a microcontroller). We can look at the corresponding part in pins_arduino.h (a file defined in the variants folder of your used core and of your used board, for me: ~/arduino-1.8.9/hardware/arduino/avr/variants/standard/pins_arduino.h):
#define PIN_A0   (14)
#define PIN_A1   (15)
#define PIN_A2   (16)
#define PIN_A3   (17)
#define PIN_A4   (18)
#define PIN_A5   (19)
#define PIN_A6   (20)
#define PIN_A7   (21)

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

So here the core first defines the macro PIN_A2 as 16 (which is the pin number of that pin) and then it declares a static constant A2 with PIN_A2. So A2 is just the pin number of that pin, 16 in this case.
This is done to make the code more readable. The analog pins are marked with A0 to A7, so it is good to also be able to refer to that with these names. If you wanted, you could also use the pin number directly. But that wouldn't be as easy to read.

It makes no difference to the answer whatsoever, but I'm surprised you're using version 1.8.9.

I'm not using it very often, thus haven't really bothered in updating. But you are right, I should really do an update XD

The value of the symbol 'A2' is an integer - it is an Arduino pin number. For an Uno, it is equal to 16. Are you maybe confusing the pin number, A2, with the value read from A/D channel 2? That would be the value returned by analogRead(A2) or analogRead(PIN_A2) as it has been #define'd. And even then, that value is also an integer between 0 and 1023, which represents the voltage on the pin, 0 representing 0v or Ground, and 1024 representing the reference voltage (therefore, 1023 represents any voltage that is greater or equal to ((1023/1024) * Vref).


text:
How to send int array with ESP8266 http post request?
I'm reading RFID cards' UID with an ESP8266 and trying to send that information to my web server hosted on a Raspberry Pi. I'm currently storing the UID in an int array, but the http.POST(); function takes a string input. I tried adding each UID digit together, but that doesn't work either.
How would you go about sending the uid in the request?
My code:
    /*
    Created by TheCircuit
*/

#define SS_PIN 4  //D2
#define RST_PIN 5 //D1

#include <SPI.h>
#include <MFRC522.h>

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>

const char* ssid = "****";
const char* password = "****";
const char* serverName = "****";
int RELAY = 2; //D6

int UIDs[1][4] = {
  {83, 111, 39, 47}
};

MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.

void setup()
{
  Serial.begin(9600);   // Initiate a serial communication
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522

  pinMode(RELAY, OUTPUT);
  digitalWrite(RELAY, HIGH);

  WiFi.begin(ssid, password);
  Serial.println("Connecting");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to WiFi network with IP Address: ");
  Serial.println(WiFi.localIP());
}

boolean compareUIDs(int a[4], int b[4]) {
  for (int i = 0; i < 4; i++) {
    if (a[i] != b[i]) return false;
  }

  return true;
}

void loop()
{
  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent())
  {
    return;
  }
  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial())
  {
    return;
  }

  // mfrc522.PICC_DumpToSerial(&(mfrc522.uid));

  int UID[4];
  for (int i = 0; i < 4; i++) {
    UID[i] = mfrc522.uid.uidByte[i];
  }

  Serial.print(UID[0]);
  Serial.print(" ");
  Serial.print(UID[1]);
  Serial.print(" ");
  Serial.print(UID[2]);
  Serial.print(" ");
  Serial.print(UID[3]);
  Serial.println();

  for (int i = 0; i < sizeof(UIDs); i++) {
    boolean success = compareUIDs(UIDs[i], UID);
    if (success) {
      Serial.println("ACCESS GRANTED");
      digitalWrite(RELAY, LOW);

      if (WiFi.status() == WL_CONNECTED) {
        HTTPClient http;

        // Your Domain name with URL path or IP address with path
        http.begin(serverName);

        // Specify content-type header
        http.addHeader("Content-Type", "application/json");

        int httpResponseCode = http.POST("UID GOES HERE");

        Serial.print("HTTP Response code: ");
        Serial.println(httpResponseCode);

        // Free resources
        http.end();
      }

      delay(2000);
      digitalWrite(RELAY, HIGH);
      return;
    }
  }
}

You encode it in some string format that the website at the remote end is expecting. Either as a HTTP parameter list, or as a JSON array string, or whatever is needed.

@Majenko could you give me a link or short explanation to get started on that one?

It looks like you've already decided on (or had imposed on you) JSON.  So the simplest method is to use ArduinoJSON (https://arduinojson.org/) to create the JSON string for you.

my StreamLib has CStringBuilder to print to string same way as you print to Serial

you could send it as an integer ... that UID in your code is 536f272f

You could use the (awesome) ArduinoJSON library, but likely overkill for this app. I found it more useful to parse JSON than to construct it.
You could simply print to a buffer and the POST that:
char payload[MAX_PAYLOAD];
sprintf(payload, "{\"uid1\":%d,\"uid2\":%d,\"uid3\":%d,\"uid4\":%d}", UID[0], UID[1], UID[2], UID[3]);

http.POST(payload);

You would #define MAX_PAYLOAD with a value that will be sufficient to hold all the information.
Notice that sprintf allows you to use any formatting options you want (e.g. hexadecimal, etc).
If you wanted to send it as an array:
sprintf(payload, "{\"uid\":[%d,%d,%d,%d]}", UID[0], UID[1], UID[2], UID[3]);


text:
My Arduino isn't showing up on my computer. What should I do?
You have your spangly new Arduino board, you've installed the software, and you plug it in. Nothing happens. Diagnosing problems may be a little tricky for the beginner, so what hoops should you go through to try and work out where the problem is and why you can't get your board working?

Note: this is an FAQ. Do not use it to ask about your specific problem. Comments will be deleted. Either ask a new question detailing all the steps you have taken, or, better, discuss your problem in chat.

Linux
Getting Arduino and Arduino-like boards working properly under Linux can be a troublesome task if you are not familiar with how Linux works.
So I am going to introduce you to some of the basic tools you will need to work out why your board isn’t working as you’d like it to work.
The majority of problems a new user is faced with boil down to one simple thing: permissions. A normal user doesn’t, by default, have permission to talk to much in the way of hardware. That include serial ports and USB serial emulation ports (FTDI, etc). Fortunately granting permission to your user to access the serial ports is a simple matter, and one that you should always do by default to make life much simpler for you. This is done through a Linux permission facility called groups. A group is a name given to a collection of users, files, devices etc., that go together. Permissions can be granted on files to the group that it belongs to, and users that are in that group can access those files. On Linux most devices are just files.
The serial ports are all in the default group dialout, but your normal user isn’t. So you need to add your user to that group. Only root has the permission to do that, so use sudo to execute the commands as root. If you don’t have access to root through sudo or some other means then you will have to seek the assistance of an administrator who does have permission.
First add your user (you’re called fred, right?) to the dialout group:
$ sudo usermod -a -G dialout fred

The “-a” is of vital importance. That says “Add the user to these groups”. Without it you have “Set the user’s groups to be this list”. If you omit the “-a” by accident you will remove your user from any other groups before setting them to be in the dialout group. That means you will never be able to run sudo again. So be sure not to miss that one out, eh?
Now that has only changed the configuration files (/etc/groups in this case) and the change hasn’t actually had any effect yet. The groups are only set when you log in to the computer, so you will either need to log out and back in again or (a more definite solution, especially if you have auto-login turned on) reboot the computer.
Now you should be in the dialout group:
(before)
$ id
uid=1000(fred) gid=1000(fred) groups=1000(fred),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),128(sambashare)

(after)
$ id
uid=1000(fred) gid=1000(fred) groups=1000(fred),4(adm),20(dialout),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),128(sambashare)

Now try it, see if that has got you working.
Next step, if that doesn’t fix your problems, is to see if the computer knows about the Arduino. First look to see if there is a device file for the Arduino and if it has the right permissions:
$ ls -l /dev/ttyACM* /dev/ttyUSB*
ls: cannot access '/dev/ttyUSB*': No such file or directory
crw-rw---- 1 root dialout 166, 0 Aug 24 11:05 /dev/ttyACM0

Don’t worry about the “cannot access…” message unless you get two of them. There are two sets of device names that the Arduino could be under depending on which type it is. Genuine UNO and similar boards (the ones with the ATMega16U2 chip as the USB interface) are /dev/ttyACM*. Clones using the CH340G, and FT232 based boards appear as /dev/ttyUSB*. We just asked for both there, so it complained when it couldn’t find any entries for one of the types. Which is fair enough. If you get:
$ ls -l /dev/ttyACM* /dev/ttyUSB*
ls: cannot access '/dev/ttyACM*': No such file or directory
ls: cannot access '/dev/ttyUSB*': No such file or directory

however, then worry. That can’t find anything at all. The computer doesn’t know the Arduino exists.
One thing to check is the permissions on the files that have been listed above. You see the word “dialout” in the list? That’s the group that the device belongs to, and it should match the group you added yourself to earlier. There are times when it may say “tty” instead. This is because some other program has grabbed the device and is using it to allow remote access to the computer through that serial port. For that you need to make sure that there are no agetty processes using that port. How you do that is very much down to your version of Linux. Modern Debian based systems (such as Debian Jessie and Ubuntu) use systemd to manage it. You can examine what is running on your system using
$ systemctl status

That returns a tree of all the services that your system is running. Look through that list to see if there are any “serial-getty” services running. If there are you should remove them:
$ sudo systemctl stop serial-getty@ttyACM0
$ sudo systemctl disable serial-getty@ttyACM0

While you’re there look through the list for another troublesome member: ModemManager. This is a program used to dial out to the internet through old-fashioned modems (you know, the kind that go beep beep beep squark squeek squark ) or USB DSL modems (that no one uses any more, we’re all wireless now. Remember the old green “frog” modem from way back when…?). That has a habit of grabbing a serial port as soon as it appears and trying to configure a modem attached to it. While that’s happening nothing else can access the serial port. It’s especially a problem with boards like the Arduino Leonardno or chipKIT Lenny which create a new serial port when they enter programming mode. So unless you really need the functionality that ModemManager provides you should just remove it:
$ sudo apt-get remove modemmanager
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED
modemmanager
0 to upgrade, 0 to newly install, 1 to remove and 138 not to upgrade.
After this operation, 2,826 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 180827 files and directories currently installed.)
Removing modemmanager (1.4.12-1ubuntu1) ...
Created symlink from /run/systemd/system/ModemManager.service to /dev/null.
Removed symlink /run/systemd/system/ModemManager.service.
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for hicolor-icon-theme (0.15-0ubuntu1) ...
Processing triggers for dbus (1.10.6-1ubuntu3) ...

Another useful tool is lsusb. This lists the USB devices that are connected to your computer. You should find your Arduino listed there. This is especially useful for boards that don’t present a serial port for programming, but we’ll cover those in more depth a little later on.
$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 80ee:0021 VirtualBox USB Tablet
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Nothing much on this computer. Well, actually I am using a virtual machine for this, as you can see by the VirtualBox USB Tablet entry. But let’s connect my Arduino UNO:
$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 004: ID 2341:0001 Arduino SA Uno (CDC ACM)
Bus 002 Device 002: ID 80ee:0021 VirtualBox USB Tablet
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

So we know that the operating system has identified it. You can find out lots more information about it if you so desire, with:
$ lsusb -v -d 2341:0001

That gives you all the device descriptors for the device. Tells you all you could ever want to know about the information the board sends to the computer when it is connected.
Another useful tool is dmesg. This is the system message log viewer and can be used to find out exactly what is going on with your computer.  It has a useful “keep running” mode specified by the flag -w. I like to run dmesg and then press return a few times to create a breakpoint in the listing, then plug in the board I am diagnosing to see just what the messages are that pertain to that board:
$ dmesg -w
[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Initializing cgroup subsys cpuacct
[ 0.000000] Linux version 4.4.0-24-generic (buildd@lgw01-12) (gcc version 5.3
... lots of stuff spools past ...
[ 19.425870] NFS: Registering the id_resolver key type
[ 19.425883] Key type id_resolver registered
[ 19.425885] Key type id_legacy registered
<press return a few times>

<connect Arduino>
[ 131.232511] usb 2-2: new full-speed USB device number 3 using ohci-pci
[ 131.519307] usb 2-2: New USB device found, idVendor=2341, idProduct=0001
[ 131.519312] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=220
[ 131.519315] usb 2-2: Product: Arduino Uno
[ 131.519317] usb 2-2: Manufacturer: Arduino (www.arduino.cc)
[ 131.519319] usb 2-2: SerialNumber: 64934333235351B002E0
[ 131.605485] cdc_acm 2-2:1.0: ttyACM0: USB ACM device
[ 131.613792] usbcore: registered new interface driver cdc_acm
[ 131.613796] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

Press CTRL+C to terminate the listing.
If nothing appears when you connect the Arduino then there is something fatally wrong. My money is either on a faulty cable (some cheap cables on eBay only have power wires and no data wires) or the Arduino itself is completely dead.
More likely though you get error messages. I can’t replicate them right now (I don’t have a faulty Arduino) but they usually pertain to things like “device not accepting address” and “Error -71”. This is usually caused by bad USB communication. It may, again, be a faulty cable, or it may be that the USB interface chip is not working right. Maybe the crystal has drifted and it’s not running at precisely the right frequency. Maybe it’s a cheap CH340 chip that has failed. Maybe the firmware on the ATMega16U2 has become corrupted.
If all that checks out fine so far and you still can’t upload a sketch there may be something even more fundamentally wrong with your Ardunio board. Maybe it’s time to look to see if there is actually any communication happening. I find the program minicom invaluable, although you could use the ghastly Serial Monitor in the Arduino IDE.
First you need to disable the main chip on your Arduino. You can do this simply by connecting the RESET pin to GND with a piece of wire. Or you can hold the RESET button down, but that means you’re then typing one-handed. That stops the main chip from interfering in any way with the serial communications while you’re testing it. It can also prevent any damage to the chip while testing.
The second step is to connect the TX and RX pins together (pins 0 and 1 usually) with another piece of wire. You are now in what is known as a loopback mode. Any serial data you send to the board should be sent straight back to where it came from. So now fire up minicom and try it out (you will need to install it first of course with sudo apt-get install minicom).
$ minicom -D /dev/ttyACM0 -b 115200

Of course replace the /dev/ttyACM0 with the real device name for your board. The -b 115200 is the baud rate, though that is pretty much irrelevant since we’re not actively communicating with an external device.
Now you should be able to type some gibberish and get some gibberish back. If you do then communication is working fine, and the problem most likely lies within the target MCU – maybe the bootloader has become corrupted and needs re-flashing, or the chip has died.
CTRL+A, X gets you back out of minicom again.
If you didn’t get your gibberish back, or you got back different gibberish than you sent, then there is definitely something up with the serial communications. The main culprit is, again, the USB interface chip.
All this, of course, has been focusing on the traditional Arduino style interface with a USB serial port of some form. Not all boards give you that though. Some, such as the Launchpad boards, use a hardware programmer on the board, and that doesn’t always give a serial port – certainly the programming isn’t done through the serial port. To gain access to those (again by default you don’t have permission to access the low-level devices) you have to get deeper into the operating system.
For these you need to make modifications to the configuration of a system called udev. This is a management system for the devices on your computer and is used to control what happens to them when they are plugged in. One of the things you can do is set the permissions on that device so people can actually access it.
The system is configured by a set of rules in “rules files”. These are stored in /etc/udev/rules.d and there should already be a few in there for other purposes. You will need to, as root, create a new file to put your rules in.
$ sudo nano /etc/udev/rules.d/50-boards.rules

The most important thing to know is the VID and PID (Vendor ID and Product ID) of your board. You can get that from lsusb as above (it’s the vvvv:pppp bit – v = VID, p = PID). You can then feed that into a simple rule, such as:
ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="0033", MODE="0660", GROUP="plugdev"

There we are matching a vendor (04d8 = Microchip) and product (0033 = PICkit2) and assigning it to the group plugdev (make sure you are in that group – default users should be already) and allowing the group members read and write access to it (MODE="0660"). Save that file and restart udev for the changes to take effect (or reboot your computer if you like):
$ sudo /etc/init.d/udev restart

Now plug the device in and you should have permission to access it.

Windows
Ok, the first thing you need to do is identify the kind of board you have. I don't mean is it an Uno, a Mega, or one of Intel's brief forays into the Arduino world - I mean what kind of USB interface the board has.
Boards can be loosely grouped into two categories - CDC/ACM and Custom USB Profile.
Current versions of the official Arduino Uno and Mega are both CDC/ACM devices (CDC/ACM, by the way, stands for Communication Device Class / Abstract Control Model). This means that between the main microcontroller (ATMega328P, ATMega2560, etc) there is another microcontroller - usually an ATMega16U2. This takes the serial data from the main microcontroller and sends it to the PC over USB using the USB CDC/ACM protocol.
You can identify these boards by the chip that is nearest the USB connector.

That small black chip with the Atmel logo on it is the USB interface chip.
Boards of this style have the USB drivers included in the Arduino IDE. If you have installed the IDE properly the drivers should have been installed for you automatically. Also Windows 10 (finally) contains "class compliant" drivers for CDC/ACM, so no drivers actually need to be installed for these boards anyway (installing the Arduino ones doesn't hurt, though, and helps it to show the right board name in the device manager).
The other category of board, "Custom USB Profile", use different chips. And there's lots of different chips it can be using.
Early Arduinos and some other makes of board (such as chipKIT boards from Digilent) use the Future Technologies RT232R chip. This sometimes looks at first glance like the Atmel chip above, but is very very different. You have to check the number on it to be sure. Other times a different package is used and it's obvious it's different.
Then there are the cheap clone boards you get on eBay and Amazon. These, more often than not, use yet another chip - the CH340G. This is a fraction of the cost than the FT232R or ATMega16U2 chips, which is why cheap boards tend to use them. They're also less reliable and harder to get working in some operating systems (most notably OS X).
For these kind of chips you need to install the right driver for the specific chip you have. For the FT232R chips that's not too hard - Future Tech have the drivers on their website.
The CH340G driver is harder to find from a reliable source.(someone with more knowledge please fill this in)
Ok, so your board is a CDC/ACM based one, or you are sure you have installed the right drivers. The next thing to check is if the board is even being seen by the operating system.
When you plug it in for the first time it should pop up a bubble saying it found new hardware:

Or something similar to that. It should also make a noise.
If neither of those happen then it's likely the computer isn't seeing the device at all. This sounds more like a hardware problem than a Windows problem.
The first thing to try is to plug the Arduino into a different port. Even better is, if you have access to one, plug the Arduino into an entirely different computer.  What you are trying to diagnose here is if the problem is related to the Arduino/USB cable or to the computer/USB port.
If it works in a different computer but not your computer then there is something wrong with your USB ports. It may be that you are using a computer that is locked down (such as in a school or an office) where the "group policy" has been configured to not allow any USB devices to be used (chiefly to prevent people bringing in memory sticks with viruses on them). If this is the case you will have to consult with the powers that be in your organisation to get your device authorised.  If not, then you may have more luck plugging your Arduino into a powered USB hub instead of directly into your computer (it may be that the computer can't provide enough current for the Arduino to run properly).
If it's failing equally as badly on another computer / port then you should start looking at the USB cable and the Arduino.
It is quite common for small battery powered devices that are charged through USB to be shipped with cheap cables. These are cables that only have the +5V and GND wires in them - no D+ and D- wires. For obvious reasons these can't be used with an Arduino: with no data wires how can the computer see it? However it's generally impossible to tell these cables apart from a full USB cable.
If you happen to be using one of these cables without knowing it you'll get a power light on the Arduino and not much else. So you need to swap the USB cable for another one - preferably one you know works properly.  If it suddenly springs into life then you know you have a bad cable. Throw the old one away - it's almost useless - or stick a label on it saying "power only" so you know what it is.
Another thing to mention in passing: I have known some of the early Arduino boards to have lower quality USB connectors on them (Uno R2). These sometimes have trouble connecting properly with some cables (not all), so maybe a better quality cable may fix the problem, or tweaking the contacts within the USB connector with a needle may help.
Right - the other direction to go in is if it does identify that you plugged a board in, but can't install the drivers. Maybe it's saying the device failed, or it can't find the drivers.
Step one is to go into the device manager and look for an "Unknown Device":

That is most likely the Arduino.  You should be able to inspect all the data for it to find the USB Vendor ID (VID) and Product ID (PID).  If those are showing up as corrupted, not available, or FFFF, then your Arduino has a serious problem and Windows cannot work out what it is. In this case it may be that the USB interface chip has failed (there have been unsubstantiated rumours that shorting 5V to GND on an Uno R3 can kill the ATMega16U2 chip). There's not much you can do when that has happened.
If you can find reasonable data in the device manager, as in the image below, then it's going to be a case of trying to fix (or find the correct) driver, since you may not have the right one installed. Also note that some other board manufacturers use the same VID and PID as the Arduino and having their drivers installed could cause the Arduino to not function properly - you should uninstall their drivers first, or manually set the Arduino to use the proper Arduino driver.

MAC OS X
Getting an Arduino to work with OS X can be as simple as "plug and play" to almost impossible. It depends on which version of OS X you are using, and more importantly, what "kind" of Arduino you have. "Kind" means, is your Arduino a genuine Arduino, a "counterfeit" claiming to be the real thing or a cheap "knock off" using the CH340 USB interface.
Your first step is to identify exactly what you've got. If you have a CH340 chip on your Arduino like the one on this cheap "knock off" of an Arduino UNO, then you'll need to install a driver so that OS X can communicate with it.

Download a CH340 driver for the exact version number of OS X you are using and install it as per the manufacturer's instructions. If you download a driver for the latest version of OS X and install it on an older version of OS X, it may install just fine. When you plug in your Arduino device, OS X reads the .kext file and sees it's for a newer version of the OS so it doesn't load it, and never will (unless you upgrade to that exact version someday).
Here is a picture of a "counterfeit" Arduino UNO. It uses the ATMEL MEGA 16U2 chip as a USB interface which is "suppose to work" with OS X's existing drivers. If you have one of these and it's "not working", don't bother installing the FTDI drivers because that won't solve your problem.

Unfortunately, what works on one version of OS X doesn't always work on another version. Solutions are usually specific to OS X versions, but there are some common troubleshooting steps to follow once you know what Arduino USB Interface you have and you've installed the correct driver (if required).
Verify that OS X is recognizing your device.

Click on the Apple icon in the top left corner of the menu bar.
Click on "About This Mac".
Click on the "More Info…" button (OS X 10.6) or "System Report…" button under the "Overview" section (OS X 10.7 and higher).
Expand the "Hardware" menu item and click on USB.

You should see something like this:

If you plugged in your Arduino and is not listed somewhere on the USB Device Tree, I can guarantee it will not show up in the Arduino IDE Serial Port Menu. It won't show up in the /dev list using terminal either. Please keep in mind that System Profiler does not refresh automatically. If you un-plug your Arduino and plug it back in again, you have to MANUALLY re-fresh System Profiler to see the current data

If you still can't get your Arduino working, try swapping the USB cable or using a different computer / OS to see if it works.

But what is the question? Unless you have a Chinese device with a CH340 it just works.

And therein lies the information that needs putting in. Also it "just works" in Linux (more so - no need for CH340G drivers) yet things do go wrong - and people need to know how to perform the troubleshooting to identify the problem. Do not assume it "just works" for everyone - the OS may be fine but the Arduino may not be. How do you work that out in OS X? If you know, please fill out this answer with the steps you'd take and the methods you'd use.

Obviously an exercise in futility when contributions are deleted by people who don't even realise OSX is obsolete!


text:
Problem with for loop
I'm having trouble with the syntax of code. I want to have the motor turn when the next average the program measures is 100 or more greater than the previous average it measured. I don't know how to write the if statement:
if(average == (average>=100)) {
for(pos = 0; pos <= 120; pos += 1) {
  sServo.write(pos);
  delay(50);
}
for(pos = 120; pos >= 0; pos -= 1) {
  sServo.write(pos);
  delay(50);
}
}

The motor should

turn when the next average the program measures is 100 or more greater than the previous average it measured

So simply write it:
// Old average is called "average"
// Compute the new average and put it in next_average
if ((next_average - average) >= 100)
{
  // Turn the motor
}
average = next_average;


text:
Unable to upload sketch on Mac OSX El Capitan
I recently dusted off an old Arduino Duemilanove to play with. I can connect it to my Mac laptop with the same USB cable I used previously and I'm able to monitor the serial port and see the output from the last sketch I uploaded (five years ago). Everything is unplugged from the board.
When I try to upload a new sketch, the Arduino IDE gets stuck on Uploading... indefinitely:
Using Port                    : /dev/cu.usbserial-A800eGZI
Using Programmer              : arduino
Overriding Baud Rate          : 19200

The board itself has the green PWR LED and amber TX LED on solid once the currently loaded sketch starts running. Initiating an upload causes the amber L LED to blink three times, then the RX LED blinks twice, and finally the TX LED on solid.
Here is the exact board: https://www.sparkfun.com/products/retired/666

My research into this issue produced many suggestions that have not resolved the problem...
I disabled the built-in FTDI driver:
sudo kextunload -b com.apple.driver.AppleUSBFTDI

And made sure the FTDI driver from ftdichip.com was loaded:
sudo kextload /Library/Extensions/FTDIUSBSerialDriver.kext

I tried csrutil enable --without kext against my better judgement and saw no change.
I also tried a completely separate machine -- my PC running Windows 10 -- and the upload hung there too.
I have tried timing the upload to coincide with a board reset, hoping to sneak my upload in before the current sketch starts running. I did this a lot and got no satisfaction.
I haven't given up yet; there are too many signs of life to think that it's unrecoverable. I'm looking for more suggestions on how to troubleshoot.
I have already ordered another Arduino -- hopefully I can use it to burn the bootloader on the Duemilanove.

This may be relevant: https://github.com/arduino/Arduino/issues/3928

The problem was that I selected ATMega168 when I should have selected ATMega328

Possibly the boot-loader baud rate in the IDE's boards.txt file is wrong. I have older (less than 6 years) '328p chips whose boot-loaders expect 57600 baud, but the boards.txt file in more recent Arduino IDE's try to talk to them at 115200 baud. I've had to duplicate the Arduino Uno entry in boards.txt and make one that specifies 57600 baud, to use these chips.

Thanks for your comment -- ultimately it led me to check everything again which uncovered my mistake.


text:
5v to 4.3v Regulator - For SIM800 module
I want to build a simple voltage regulator  3.8-4.2V with atleast 2A Peak Current Capability for my GSM Shield (It doesn't have regulated power supply), I don't want variation or it may burn the board.
Using voltage divider won't help here as there can be variations.
Somewhere i read LDO are for for this task but i am able to get only 3.3v regulator with 800mA supply.
Can i use 3.3v to power the same ?

What GSM shield?

ISTM that the shield may be designed for being strapped to a Li-ion cell by including a regulator, which is why it has such an unusual input voltage range.

@Majenko http://www.ebay.in/itm/262101582335?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649  This shield

That is one of the worst listings I have come across.

any suggestion for small gsm module easily available ?

Most of the key information derives from the well known SIM800, not the carrier PCB.  That said, if you want something cheap intended for 5v rather than direct lithium cell power, look to USB dongles, though you will need a USB host and to issue mode switch commands and wait for them to take effect.

I have a lipo 3.7v, but can't rely on that, if i add more components there can be voltage fluctuations...USB power is not in list because device   has to be fully portable. I don't think i will be getting 5v as power, i might have to use stepup regulator or so...
I just want device to be as small as possible.I am not experienced in itching ( i tried once at home, unsuccessful) .

If you don't think you will be getting 5v as power, your question is improperly titled.  Further, it's quite a stretch to call this an Arduino question, as it is entirely about the GSM module and not at all about Arduino.

Ah..initially i will be using arduino 5v pins..So this is why...3.3v is just for learning.

There are Variable (LDO) Voltage Regulators available. You can set the output voltage using two resistors. E.g. the LM317

Consider using a buck converter for this.  Search ebay for "buck converter" and you will see items like "Buck Converter Step-Down Adjustable Converter Power Module Regulator LM2596.  That title indicates several things:  the converter is adjustable, it steps voltage down, it's a regulator, and it's based on TI's LM2596 chip.  It's rated at 2 A continuous, 3 A peak.
A buck converter has some advantages over a linear regulator:

Lower dropout (in general), ie, the input voltage has to be at least as much as the output voltage, possibly plus a small margin for one FET loss, but doesn't have to have the 1.1 to 1.3 volt margin typical of an LDO regulator.
Higher efficiency (in general).  For example, 95% is not uncommon.  (The ebay item mentioned above shows 92%.)   A linear regulator, whether LDO or not, turns the input-to-output voltage difference into heat.  A buck converter, on the other hand, uses an inductor and a capacitor to store energy; it refills the capacitor at a controlled rate via the inductor as often as necessary to deliver the required load.  The inductor's DC resistance wastes energy, but that resistance can be kept small.
Smaller parts due to high frequency switching operation.  As operating frequency is increased the inductor can be made smaller.  On the other hand, higher frequencies lead to higher switching losses, so there's a tradeoff.  Note, some SOT3-sized (~1.4 mm x 2.9 mm) transistors eg NTR4503 are rated over 2 A at 25°C and might be usable as an output FET for a buck converter chip, and inductors and capacitors also are available in sizes probably as small as you are looking for, but buying them and building your own converter is unlikely to be cost effective.

Seems a fit for me, I want small circuit, a SMD will do, Any other alternative ?

Many buck regulators are built mostly or entirely with SMD components, but ones meeting your power need won't be tiny.

Is there any stepup buck converter, i searched but i am getting up and down combined, I tested device using arduino 3.3v supply, device powered up but no response, I guess arduino cannot deliver enough power.

No, "stepup buck converter" is a contradiction in terms.  Look for "boost converter".  Boost converter efficiency from a low voltage input often is low.

aha...Thank you...And thank you for explanation, it made things more clear.

I assumed from the title that you have 5V to start with.  Starting with 3.3 would call for a boost converter – but getting 2+ A out of the Arduino 3.3v supply won't happen.  (The amps would be 24.3/3.3, going from 3.3 in to 4.3 out at 100% eff; or 24.3/(3.3*0.85) at 85%)

Hmm...I planned to use 3.7v LIPO batter i guess it has current 800mA...I have another battery, will check.Anyway thanks again.

Just be aware that if you're going to be using this in an RF sensitive application, you want to verify that the frequency that the converter operates at isn't going to introduce spurious signals into your application.

@DavidHoelzer I am newbie in electronics, How to do that, Please point to some article or other resource.

Are you doing anything radio related?  If so, what frequencies will you be using?  Compare that to the frequency of the Buck converter and figure out if they are harmonics of one another.

I planned to use 3.7v LIPO battery

That's what your SIM800 module is intended to be directly powered by, without any intervening boost or buck converter.
Behind all the misdirection of a title that doesn't describe what you are actually trying to do, your question is an exercise in going around in a circle right back to where you started.  Don't try to convert energy from the lithium cell to some other voltage and then from there to the allowed input range of the SIM800 (which is very intentionally that of a single lithium cell), rather use the parts as they were intended to be used.

i guess it has current 800mA..

No, it has a capacity of 800 milliamp hours, not 800 milliamps.
A phone or RC model type lithium cell you would find today would have a "C" rating of 10 or better, but even if we assumed one of only 5, that would predict that your cell should be expected to be able to support pulse loads of 5 times the one-hour draw rate, which would be .8 * 5 = 4 amps.

Thanks for comment, I will give it a direct try, At my place its really hard to get components, i had to wait for 10-15 days for component to be shipped, This is why i didn't try... Somewhere i read that it doesn't operate properly at voltage < 4v. I will give it a try and update.

I've updated the title.

Your title is still wrong, as you've admitted hours ago that your source is not 5v.

Ah..Currently i am testing using 5v source...So...

Don't do that.  It's a completely different problem.

Oh..Please suggest a fair title..i will change ..


text:
Why LED light delay is 5 second in arduino?
My code :
int pin = 8;
int pout = 12;
int result=0;
void setup() {
  pinMode(pin, INPUT);
  pinMode(pout, OUTPUT);
}

void loop() {

  result = digitalRead(pin);

  if(result == 1)
  {
    digitalWrite(pout, HIGH);
    delay(1000);
  }
  if(result == 0)
  {
    digitalWrite(pout, LOW);
  }

}

I have set delay 1 sec but whenever i put high voltage on pin 8 The LED glow for 5 second. why?
How to set delay to none ? means whenever the pin 8 is HIGH the LED will glow else off.

The problem (likely) isn't in your code. You need to include a pull-down resistor in your electronics, so that when you remove the "high voltage" the residual charge stored in the pin due to its capacitance can be drained. Alternatively you can use the internal pull-up resistors, but then you'd need to invert the logic of the pin (high becomes low and vice versa) and instead of connecting "high voltage" you'd need to connect ground to activate the LED.

1. changed result=1 digitalWrite(pout, LOW)and result=0 digitalWrite(pout, HIGH) still have the same issue LED glow for 3,4 second 2. also use this if(result=1) digitalWrite(pout, HIGH); delay(100);digitalWrite(pout, LOW); still no luck LED goes on and off for 3,4 sec. 3. I have put 6k ohms resistor  between LED still No luck. :(

You need to put the resistor between pin 8 and ground, not on the LED.

ohh, awesome :) works now thanks. added 2.2k ohms worked and 680 Ohms is also working. Could you please let me know how to choose resistors?

The precise value doesn't matter. A relatively high value like 10k is customary. The higher the resistor, the less current is wasted when the switch is on, but the slower the residual charge will drain.


text:
How to handle multiple simultaneous Arduino development environments?
I am developing for several different target microcontrollers (on OS X 10.11), which requires some unique combinations of (Arduino) IDE version, library versions, USB drivers, support software, etc.
What are the pros and cons of using separate logged-in users for each environment as opposed to using Virtual Machines? Are there other methods commonly in use to separate environments, and also keep the environments archived for any legacy needs?
Update: I also have a desire to keep these environments as standard as possible: installing released components (e.g., IDE, drivers) and customizing IDE app settings, but trying to avoid source-level forks. This is for my own sanity, and to give best chance of replicating the environment in the future.

That sounds horrible. What about 1.6.x doesn't let you handle all the boards?

Even within 1.6.x there is a lot of variability between versions which can make things simply not work, especially for many alternate-hardware plugins.  The "ordinary" Arduino installation organization for extensions and libraries is pretty seriously broken for any serious software development, being able to specify a custom library path would be a big help.  Not needlessly complaining about .git folders would be a help, too.

You might be able to get custom per-version libraries/ and hardware/ folders by changing the sketchbook directory, the problem is that all versions from 1.5 on seem to want to store such configuration in the same place such as ~/.arduino15/preferences.txt - and it's not clear how you could change that without modifying the source or binary or playing some game like process-unique mounts (which are generally inheritable by children)

You can run multiple versions of the IDE just fine. Just rename Arduino.app to e.g. Arduino-1.5.app. For the different libraries, you can just put the libraries into the app-package /Applications/Arduino.app/Contents/Java/libraries , instead of the regular libraries folder ~/Documents/Arduino/libraries.

@ignacio-vazquez-abrams, the other issue is wanting to avoid regression testing each working environment when updating IDE, libraries, etc. for just one. I'd like to pre-test updates in a non-production clone.

I'm yet to see evidence that there is a sound or comprehensive way to do this, so would be pleased to read better suggestions.  As for why you would want to, there are a number of board support plugins/extensions that are moderately functional on some recent Arduino versions, but partially or entirely incompatible with others.
You can achieve a very limited partial version segregation by creating a new sketchbook folder for each version, which would host your libraries and hardware folders.
To get the IDE to pick this up, you could have a custom preferences file (rather than preferences.txt) with that sketchbook location set.  You can specify the file to use on the command line, for example:
/opt/arduino-1.6.8/arduino --preferences-file ~/.arduino15/alternate.txt

However, there is still quite a bit related to extra board support and similar stored in the settings folder, and at present that is hard coded to the same "Arduino15" or ".arduino15" path for all recent versions.
This hard-coding of the settings folder is implemented in the version of Platform.java applicable to the operating system you are running under, so it is not clear how you could change this except at the source level, by modifying the jar, or by playing file-system level tricks with the operating system (process-unique mounts, etc).

Thanks for your helpful comments and answer. I'll wait to see if someone chimes in specifically about VMs vs. users, etc. (I haven't tried yet, so I'm not even positive if VMs will have issues of their own, but I'm hopeful). I'll also edit my question to include my desire to keep each environment as standard an install as possible (so I don't go insane keeping track of meta-customizations).

Either distinct user ID's (with the whole installation in a user-specific directory) or VMs would probably work pretty well... sorry I skipped over that, I just don't really consider it a reasonable thing to have to resort to for everyday development.

I ended up running arduino-buider, available in Arduino IDE 1.6.6 and newer.
When laying out your project, put a libraries/ and hardware/ folder along side your sketch directory, like so:
YourHipProject/
    Makefile
    hardware/
        Vendor/arch/{boards.txt,platform.txt}
    libraries/
        SomethingUseful/
        NoIdeaHowThisWorks/
    ProjectSketch/
        ProjectSketch.ino
        othersource.cpp

The hardware/ directory is only needed if you need support for 3rd party boards. Then, in the Makefile:
ARDUINO_DIR ?= /opt/arduino-1.6.13 # need to set this for your environment

.PHONY: ProjectSketch

ProjectSketch:
    arduino-builder -compile -verbose \
        -hardware $(ARDUINO_DIR)/hardware \
        -tools $(ARDUINO_DIR)/tools-builder \
        -tools $(ARDUINO_DIR)/hardware/tools/avr \
        -built-in-libraries $(ARDUINO_DIR)/libraries \
        -hardware ./hardware \
        -libraries ./libraries \
        -fqbn=Vendor:arch:board \
        ./ProjectSketch/ProjectSketch.ino

ARDUINO_DIR needs to point to where your Arduino is installed, be sure to set -fqbn= correctly too.
Running make should compile the firmware from ProjectSketch/ with the accompanying libraries and hardware definitions. Also, with verbose compile output enabled, the Arduino IDE will show you how it runs arduino-builder.


text:
Why is the result of this product operation wrong?
I had a problem in a program where the result of product is not what it's supposed to be. For example: 775*775 gives 10801 instead of 6006025.
To try to isolate and resolve the problem, I made a simple sketch to test the result of different products. What I found is that if I do the same product in this way: 775/100.00*775/100.00 then multiply the result by 10000 I get the right value: 600625.00
The attached pictures illustrate what I said.
While I can use this solution in my initial program by I still want to do the multiplication directly as more operations means more time.
I would appreciate any help. Thank you.

Integer overflow. You're multiplying an int by an int then assigning it to a long.  Instead if you multiply a long by a long, or an int by a long, or a long by an int, it should work.
unsigned long res = 775L * 775;

The L suffix tells the compiler to treat it as a long, not an int.