text:
Should I use LLC to power sensors on grid pcb at 4mtr wire length distance?
I have setup a grid pcb that further distributes power and receive signal from sensors, I know low voltage can detroit if not damage sensors , so I am thinking to put BD-LLC  to distribute power output to 6 sensors connected to PCB shown below.
[ignore 24 volt power that feeds solenoid it is separate and comes from power adapter not from mega though the wire has same red colour] the 5 volt wire connecting to main connector from other connector is not visible.

And I have Arduino Mega from which I am drawing power 5 volt (using digital multimeter I found it's 4.98 volt). And all sensors are connected to this 5volt parallely.
So the question is should I put this BD-LLC on above PCB to distribute correct power output to sensors ?

A logic level converter has nothing to do with power conversion. To answer your real question though there are two more pieces of information that are needed: the current draw of your board, and the gauge of your 4m long power and ground wires.

4m long wire adds 2.79 to 3ohm resistance, the board is on 6.98 voltage input from VIN pin of step down from 24 volt

The voltage at the board end will depend on the current draw of the board, and if that varies then the voltage will vary. You may be better off using a 24V -> 5V step-down at the board and providing 24V to the board instead (known as "point of load regulation") to ensure the board runs at 5V.

In that case I would have to send back 5 volt to VIN  of Arduino mega

Why would you want to? The Arduino is already 5V.

Because from that 24 volt I am feeding both

You aren't making sense. You have 24V->7v->5v and one end, and tee off the 24V to give 24V->5V at the other end. The only power you send down the wire is 24V, and since you are (or should be) using "buck" regulators for this the current draw down the wire will be less, so the wire losses will be less. As long as the two devices share ground it doesn't really matter where the power comes from, as long as both boards run at 5V, not one at 5V and one at "somewhere up to 7V".

Actually you do make sense to put buck converter at the pcb end however my earlier setup used POE so where the 24 volt adapter is connected is also where router is lying inside room, while pcb is lying out in corridor, I can take power in from outside and send 5 volt to mega from PCB. Little bit of more work I would have to do but my original question to boost power for sensors to get exact 5 volt is still not answered

Sending 5V from the board to the Arduino is going to still suffer from the same problem. You will end up with a random voltage at the Arduino due to wire losses dependent on the current draw of the Arduino at any one time.

@Majenko  AFAIK Arduino mega requires 6volt -20volt

The VIN requires minimum 6.2V for linear regulation down to 5V. If you send 5V from board to Arduino it will go into the 5V pin not the VIN pin (which will be connected to nothing). But that 5V will be below 5V because of wire losses.

So do u mean to say I can power mega from 5volt pin as well instead of VIN? I have never tried that!

Transmitting power over longer distances requires careful consideration. The actual voltage you will get at the remote end depends on two major factors:

The resistance of the wire, and
The current draw of the remote device

If you regulate your 24V incoming power down to 7V for the Arduino and then send the Arduino's 5V over 4m of wire to power your remote board the actual voltage the board will receive depends on the amount of current the board draws.
If this current is tiny then the voltage drop for the wire will be small and can largely be ignored. For instance, you quote about 3Ω resistance for 4m of wire, which to me seems incredibly high (32AWG which is like hair thin is only ~0.5Ω/m), but anyway.  If your board draws 100mA, over your 4m wire, which is actually 8m when you take into account the length of the ground wire ("There and back again - an electron's tale.") you would drop (2*3Ω)*0.1 = 6*0.1 = 0.6V, so your 5V would turn to 4.4V by the time your board sees it. Not only that but the ground wire would be offset at the board end by 0.2V, which may impact LOW logic level detection.
So ideally you need to both minimise and mitigate that voltage drop. And both can be done using a buck regulator at the board and powering it from the 24V supply instead of 5V.
By using a buck regulator you massively reduce the current over the wire (for 24V to 5V you could be looking at around a quarter of the current or even less, depending on the efficiency of the regulator) which reduces the voltage drop on both the power and ground wires. It also guarantees that the board runs at 5V regardless of the current draw of the board.
Here's a diagram:

For digital sensors this loss of voltage could cause damage if any incoming logic signals are above the absolute maximum for the sensor (which is usually a function of the supply voltage, say Vcc + 0.3V). For analog sensors it will affect the values you are reading, since the voltage emitted from the sensor is often a function of the supply voltage, and if that is not what you expect it to be your calculations from the ADC values will be incorrect.

To answer your original question "can I use a LLC to distribute power" the answer is "no". The LLC can allow you to interface logic signals between two different voltage levels, but not affect power at all. And further more it requires that you have both voltages availabe for the LLC to operate, and you don't have both voltages, you only have the 5V minus the wire's voltage drop available, so you can't use it to mitigate any offset in the logic levels either.

How do I figure out current draw at remote device(pcb sensor grid) in my case? Do you mean sum up power of all sensors connected to grid?

Sum up the current requirements for all the sensors. You can usually find that kind of information in the datasheet for the sensor.

I do have to step down converter but it does really bothers me

What bothers you about it? The colour?

Baaah u still there, I meant having to put another step down converter

Why does that bother you? It's the normal thing to do.


text:
I have 4 motors connected to their own ESC (that is connected to a power distribution board), how do I connect this to Arduino uno? (Drone)
I am currently working with a bigger drone that I want to connect with an arduino uno.
The motor and ESC that are already soldered together and connected are these: https://hobbyking.com/en_us/mt1806-brushless-combo-include-esc-5030cw-ccw.html
I have also connected it to a power distribution board where I succesfully can connect my 3s lipo battery.
What is currently missing is where I should put the 3 pins on each ESC onto the arduino board. So there are 12 pins in total.
The color on the 3 wires on each ESC are: yellow, red and brown.
Yellow is the signal if i am not mistaken and those should be connected on the PWM pins where I control each motor in the code.
When it comes to the red it is + power and should I ignore to connect these pins? I would like for my battery to power both the motors and the arduino so of course I would prefer to connect it to the arduino uno if it is possible.

Here are just some clarifications for you:

Signal pins don't have to be connected to PWM pins. AFAIK, any digital pins should work.
All grounds togheter! Glad you got that right!
Connect VCC of ESCs directly to the power supply.
Connect power supply to VIn of Arduino (not 5V because you are going to grill it!)

Uptdate

Yes, you can probably solder all the VCC wire of the ESCs togheter.
By power supply, I meant connecting it directly to the battery.

To power the Uno, connect the battery+ to the VIn pin of the UNO.

Thanks a lot for the answer! So far so good :)

Ok!
Ok!
3/4. Do i do the following: Solder all of the VCC of the ESC (the red wire) the same way like I do with the ground and then I connect it to a power supply module? Is this a power supply module I can use? https://www.aliexpress.com/item/Smart-Electronics-MB102-MB-102-Solderless-Breadboard-Power-Supply-Module-3-3V-5V-for-Arduino-Board/32569124727.html?spm=2114.40010208.4.1.Pm4T84 It is for a breadboard i think but can it work with an arduino uno? When it comes to powering teh arduino I am a bit unsure how to do it.

This is one of my first projects so therefor I am very rookie in some areas!

I've updated the answer.

Hi! I was just wondering. I have a 4s battery now that I plan to hookup to a arduino pro mini 5v board instead of a Uno-board. So instead of putting the battery wire to the Vln of the arduino uno I will put it on the "RAW" on the arduino pro mini. Will a 4s or 3s lipo make any difference?

Pro Mini's regulators are quiet bad. I'll suggest to put it to a down converter before passing it to the Arduino.

this is where i will attach the battery: https://hobbyking.com/en_us/hobby-king-quadcopter-power-distribution-board.html to my power distribution board and from that board i will connect the voltage to the RAW and the other pin to the gnd. Does the PDB work as a converter?

source: Stack Exchange

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

sort: votes


text:
Switch a 12V 3.3A component from an Arduino
I need turn off and turn on component from an Arduino UNO.

How can I do that? I am thinking about some transistor (IRF 530N) but I am not sure about it.
Please give me a beginner advice how to implement such a switch.
EDIT: Is this realy good for my problem?

Maybe a relay would be easier?

Are there any advantages using relay instead of transistor?

@RogerRowland is this relay good for me? https://ae01.alicdn.com/kf/HTB1Fz85OVXXXXaXXVXXq6xXFXXXz/C18-2016-1pc-1-Channel-12V-Latching-Relay-Module-with-Touch-Bistable-Switch-MCU-Control.jpg

A relay, as pictured, is a good choice. It provides complete galvanic isolation and switches the power properly.
Another option is to use a MOSFET that can handle enough current (an N-channel switching the ground as a low side switch, or a P-channel switching the power which is itself switched by an N-channel, as a high side switch).

Upvoted, but the OP should be aware that a flyback diode across the relay coil may be needed, especially if they use a relay that isn't in a ready-made module.

You only need that if you are wiring it yourself, in which case you would be following a tutorial. With a module like the one pictured it is all splayed and there is no need for more components.

A simpler relay board than that shown might be better.  The one shown in question is constantly powered by 12 VDC on the DC+, DC- lines.  It is toggled by pressing the button or by a contact-closure on the pins of the white connector.  Amazon and ebay links: https://www.amazon.com/Wrisky-Channel-Latching-Bistable-Control/dp/B01IOTKAFS http://www.ebay.com/itm/1-Channel-12V-Latching-Relay-Module-with-Touch-Bistable-Switch-MCU-Control-/301820150781

Yeah, on closer inspection that one looks odd. You want one of the simpler ones. Sainsmart make some good ones.

I've just bought a few STP16NF06L fets for this very purpose, N channel MOSFET.
The key part of that part number is the L at the end. This indicates low (or Logic) gate threshold, which means it will switch on fully at 5v gate drive, unlike most fets which are sort of conducting at 5v but need 10v to reach their specification (like an IRF530N).
The 16 and the 06 are 16 amps and 60 volts respectively.
You can get about 25 of them for the same price as a UNO, depending on supplier, in the UK here for instance

I think you mean STP16NF06L About one third the price of a UNO clone.

@Jasen No, see the link in the answer

you wrote '60' in your text but the part number is '06'.

@Jasen, why so I did! Thanks. I get cross-eyed with long part numbers, especially when the voltage part drops the trailing 0.

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


text:
Value declared but not coming up as declared
void setup() {
// put your setup code here, to run once:
const int buttonPin2= 2;
const int buttonPin3= 3;
const int buttonPin4= 4;
const int buttonPin5= 5;
int total=0;
int wait=0;
int buttonState = 0;
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
pinMode(buttonPin5, INPUT);
}
void loop() {
int wait=5000;
while(wait>1)
  buttonState = digitalRead(buttonPin2);
  if(buttonState == HIGH){
    total=total+1
    wait=0
  }else{
    int wait=wait-1
  }
int wait=5000
int buttonState = 0;
while(wait>1)
  buttonState = digitalRead(buttonPin3);
  if(buttonState == HIGH){
     total=total+2
    wait=0
  }else{
    wait=wait-1
  }
int wait=5000
int buttonState = 0;
while(wait>1)
  buttonState = digitalRead(buttonPin4);
  if(buttonState == HIGH){
    total=total+4
    wait=0
  }else{
    wait=wait-1
  }
int wait=5000
int buttonState = 0;
while(wait>1)
  buttonState = digitalRead(buttonPin5);
  if(buttonState == HIGH){
    total=total+8
    wait=0
  }else{
    wait=wait-1
  }
int wait=5000
Serial.begin(9600)
while(0=0)
  Serial.println(total)
}

How about the part where you declare it? Can we see that?

Please, edit the question with the relevant code instead of posting it as a comment.

added the code to the top

You should post the whole code. The buttonState will work as is here. However there is the infinite loop (in while (wait > 1) command;

I'm voting to close this question as off-topic because we cannot work with just snippets of code - you must show your whole code.

Learn the meaning of "Scope".

We can easily make that code compile, but whether it works (does what you want) is a different matter. What are you trying to do?

There are many errors in this code. Below I have high-lighted some of them. Please check your C/C++ language reference(s).
void setup() {
// put your setup code here, to run once:
const int buttonPin2= 2;
const int buttonPin3= 3;
const int buttonPin4= 4;
const int buttonPin5= 5;
int total=0;                        <--- not used in setup()
int wait=0;                         <--- dito
int buttonState = 0;                <--- dito
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
pinMode(buttonPin5, INPUT);
}
void loop() {
int wait=5000;
while(wait>1)                             <--- missing block { ??
  buttonState = digitalRead(buttonPin2);
  if(buttonState == HIGH){
    total=total+1                         <--- missing semi-colon ;
    wait=0                                <--- dito
  }else{
    int wait=wait-1                       <--- local declare not used
  }
int wait=5000                             <--- illegal redeclare + semicolon
int buttonState = 0;                      <--- illegal redeclare
while(wait>1)                             <--- missing block ;
  buttonState = digitalRead(buttonPin3);
  if(buttonState == HIGH){
     total=total+2                        <--- missing ;
    wait=0                                <--- and so on.
  }else{
    wait=wait-1
  }
int wait=5000
int buttonState = 0;
while(wait>1)
  buttonState = digitalRead(buttonPin4);
  if(buttonState == HIGH){
    total=total+4
    wait=0
  }else{
    wait=wait-1
  }
int wait=5000
int buttonState = 0;
while(wait>1)
  buttonState = digitalRead(buttonPin5);
  if(buttonState == HIGH){
    total=total+8
    wait=0
  }else{
    wait=wait-1
  }
int wait=5000
Serial.begin(9600)
while(0=0)
  Serial.println(total)
}

Start with something much simpler and learn to master the language. Cut-and-paste programming will not help achieve any goals you might have with this sketch. You are simply wasting your time *<:)#


text:
which spi mode shall i use given this timing diagram
I need some help to ensure my understanding of how this is supposed to work.
I want to know given the attached serial timing diagram which spi mode should I use?
Based on my newly found knowledge I believe it should be mode 1
How do you use SPI on an Arduino?
Is this correct?

Looks more like Mode 0.

We can see from your diagrams that the starting state of the clock line after the CS goes active is low indicating a CPOL of zero.  Also, we see that data changes after the falling edge of the clock indicating the CPHA is also zero.  This infers, according to this reference, that the SPI mode is zero.

If you look at the diagram you showed, it makes sense to use mode zero.

Clearly you need mode 0 or mode 1 because the clock is normally low.
Now looking at the change of the data vs the clock, it makes sense that you sample on the leading edge (mode 0) - the red lines - because the diagram shows that the data is held steady for a while after the clock changes (from low to high).
It wouldn't make sense to sample on the trailing edge because immediately after that (the blue line) the data changes.


text:
How many bluetooth modules can be interfaced with Arduino UNO?
At most how many bluetooth modules(HC-05) can be interfaced to Arduino UNO?

Two. One on the hardware UART (TX/RX pins with the Serial object). One on SoftwareSerial on any two pins you choose.
Any more than that and you will need more hardware UARTs.

You can create as many SoftwareSerial objects as you like, with a BT module on each, within memory, pin, and power constraints. But only one SoftwareSerial object can be listening at a time, which may make any others less than useful.

Also while you are sending on one reception is completely disabled (interrupts disabled) so you can only use one at once. As a rule of thumb, while you can define more than one SoftwareSerial you can only really use one of them. Personally I never even use one. I pick hardware that has enough hardware UARTs to do the job at hand.


text:
Can I design Arduino Mega 2560 circuit without adding ATMega 16?
I want to make Arduino Mega 2560 board.
As the reference files are given on Arduino Site, I don't want to add USB communication on the board.
So can I remove part of ATMega 16?
Will it cause any kind of problem in working of board?
And if It will fine to remove ATMega 16 part, How much part of schematic to be change?

It would be helpful for you to understand what each part does. If you find the Atmega16 useful, you should just add it, if not, your question is answered. :)

Yes @WesleyLee , due to finding more stuff on web I got confused whether it is ok or not and I got proper solution here. Thanks.

When I omit a USB / Serial IC I often put an "FTDI" header, so I can use common USB/Serial converters. Might be useful in your case.

Yes, you can omit the ATmega16U2 and its accompanying parts. That is, the whole right block of schematic in this sheet.
The resulting board will work perfectly fine, it will simply no longer have a built-in programming interface, nor a built-in USB-serial interface. You will likely want to buy an FTDI cable and an AVR programmer, if you do not already have these.

Hi uint128_t, Your answer cleared my confusion and solved my problem. Thanks man.


text:
Microcontroller software shutdown with transistor 2N4401
I am trying to understand why connecting, say, an Arduino digital pin 4 to a 2N4401 pin 2 as well as 5V PSU to 2N4401 pin 1 and Arduino VCC  to 2N4401 pin 3, won't keep power.
When shorting pin 1 and pin 3 on the 2N4401 the MCU is powered on and in-software pin 4 is set to pinMode OUTPUT and HIGHwhich should allow the 2N4401 to let power flow to the MCU for as long as power is available even when the short circuit between 2N4401 pin 1 and 3 is cut.
Instead what happens when the short between pin 1 and 3 is cut, the MCU is turned off instantly.
It's as if the transistor isn't reacting to the pin 4 MCU signal at all.
Could anyone explain why this is happening?
I'm sure I lack a lot of knowledge here and I want to know how I could utilize a 2N4401 to make a SW shutdown system.
Why 2N4401? Why not a MOSFET?
MOSFET's circuits that do SW shutdown are available, but no transistor base SW shutdown circuits are to be found anywhere, and the 2N4401 is all that I have right now.
Update

void setup(){
  pinMode(4, OUTPUT);
}

void loop(){
  digitalWrite(4, HIGH);

  delay(3000);

  digitalWrite(4, LOW);
}

Can you draw your schematic and show your code?

Yes, I updated the question.

Ok, but that Fritzing thing is not a real schematic! However, in you code, there is a problem in the loop function - you probably need another delay after the digitalWrite(4, LOW) otherwise it will immediately write HIGH again on the next loop - so you won't really see the effect of the LOW as it will be too short. A proper schematic is necessary to see which way you have the transistor connected.

Yeah sorry, I thought I'd show you the visual physical representation of what I'm working with. But wait, the HIGH tells the transistor to allow electricity to flow to the board, right?
So my question is why would a delay after LOWbe needed when LOWwould turn it off, which is what I want?

Because loop is executed continuously - so it would turn it back on again at the start of the next loop. It would only be off for a few microseconds. It looks a bit strange to me, are you trying to use the Arduino to turn itself off?

But how? At LOW the power is cut off completely, thus the loop never actually loops.

A proper circuit diagram please (for adults and not babies). If I wanted cartoons I'd watch spongebob squarepants.

How long does it take for the power to decay to the point where the code stops executing? There is capacitance in the supply that will maintain it maybe even for a few hundred milliseconds. Rather than arguing about it, just add another 3 second delay and see if anything changes.

Updated image. It behaves the same way with the extra delay.
I think it's so weird that the transistor is not letting electricity flow through while it's base is set high. When using the same transistor and connecting an LED to it (as an independet purpose ofcourse, not for SW shutoff) then the LED turns on and after a while off, just as expected.

If the base is high, a pnp transistor will be off. How come your battery is only 3 volts too when the arduino is shown as 5 volt? Accuracy in stating and circuitizing what you have done is a fundamental part of EE.

@Andyaka Sorry about that. I updated the image, it should now be corrected and accurate.

A edit was made to the schematic, but that raises more questions than it answers.  It's time to close this mess.

@OlinLathrop no it's not. I updated the image once again, now it really should be correct and I can't see any more errors in it.

The questions gets net three down votes. Only @Olin and Andy answers the question. I admire the patience of you both in teaching the future EE.

There is a [popular among beginners] bug where the I/O pin is set low at the end of the loop then immediately set high at the top of the loop.  In other words, a delay is missing.  More on that here  (that thread is about PICs, but it deals with the same sort of bug).

This is what you appear to be wanting... A manually operated contact (S1 in your "diagram") momentarily shorts out the NPN transistor and applies power to the Arduino. In that short time the contact is active, you want a transistor to by pass this switch and keep applying power to the Arduino so that should the contact go open circuit, power remains on the Arduino.
The main problem, assuming my guess about what you want is correct, is the use of an NPN transistor as an emitter follower; whatever voltage you apply to the base will be about 0.7 volts lower on the emitter so, when the contact opens, the emitter voltage drops to about 4.3 volts to keep the NPN turned on but, that in turn leads to a drop in base voltage and quite rapidly you end up with nothing on the emitter.
You need a PNP transistor that can be turned on much more effectively with an NPN pulling the PNP base towards ground. In other words you need two transistors to do what you want: -

This one is shown at 5.5 volts on the power rail but 5 volts will be fine. It is also shown using a p-channel MOSFET instead of a PNP because the MOSFET will act as a much better "short" when activated.
Here's one that shows a PNP transistor - ignore the 12 volts - it will work on 5 volts: -

The "lamp" is where you connect the Arduino (aka PIC in the circuit). You will be better off with a p-channel FET though but, just in case you decide to use the PNP version you might need to lower R3 to maybe 470 ohms to provide enough base current to pass sufficient collector current to power the Arduino.
You also need to have S1 wired across the "pass" transistor - at the moment you have it connected back on itself and therefore does absolutely nothing. Note that this has been fixed in the question now!

when the contact opens, the emitter voltage drops to about 4.3 volts to keep the NPN turned on but, that in turn leads to a drop in base voltage and quite rapidly you end up with nothing on the emitter. that's what me and a friend discussed earlier today but we weren't too sure, thanks for confirming our suspicions.

Answer accepted! Edit: You don't understand what this will do to the maker community, you will be considered the holy master of self-shutdown Arduinos.

Your question is rather confusing, but some problems are evident just from looking at the schematic:
The schematic is crap.  I have no idea what you're trying to say with the dotted line between the - terminal of the the battery and the processor GND pin.
The line going thru the middle of the transistor is apparently meant to be the connection to the base, but this is sloppy at best.
It took me a while to realize you have the positive power connection at bottom and the ground at top.  Don't do that.
All these things make your schematic hard to read.  Now that I've had to waste time deciphering the schematic, I'll be more brief once we get to talking about the circuit itself.
You say the transistor is a 2N4401, which is NPN, but you show a PNP.  Huh?  Which is it?
There is no base resistor.  The E-B junction looks like a diode to the driving circuit.  When the digital output tries to go low, it will be held one diode drop below power.  That could damager the digital output or collapse the power supply.

Update
You have edited the schematic to show a NPN, but now you have a chip trying to drive itself thru a emitter follower.  The switch also does nothing at all since both its ends are already shorted together.

This isn't an answer, this is criticism, which is 100% fine by me, but leave in the comments. I'm not trying to say anything by the dotted line, I could not connect it in software. By the way, no one is forcing you to help me, whoever does take the time to help me and teach me something new will be appreciated, if respectful. It is an NPN transistor. The base resistor is something new to me that I'll have to read more about. This answer is not an answer, I will not accept as it does not answer my question "why does MCU not stay ON while pin 4 keeps NPN base high".

@vaid: This is too long for a comment, and points 2 and 3 do actually address issues with your circuit.  There are many ways to draw good schematics, including the schematic editor built into this site.  "I could not connect it in the software" is no excuse at all.  So use better software!  And, respect is earned, which you haven't.  In fact, complaining about people pointing out your disrespect only makes it worse.

Hey, I'm new to these things, alright? Not everyone is Nikola Tesla. I'm not complaining at all, you have a requirement? State it and I'll handle the rest. Want me to use the built in editor? Say it. I didn't even know there was one. Be a little bit more considerate. I'm fine with criticism, but keep it on a respectful level, that's all I'm asking for regarding communication. This is getting too off topic and I'm now going to ignore you because I'm here to have a dialog and learn, not a monolog insult.

"you have a requirement? State it".  No.  We expect you to learn to communicate properly elsewhere.  Drawing a schematic is something you are expected to already know how to do before coming here, unless you're explicitly asking about schematic drawing.  "keep it on a respectful level".  Again, respect is earned.  You're not there yet.

Neither are you. But Andy aka is. Get rekt.


text:
How do I do a register read?
Below is the sketch I'm using with the TI 32-bit adc ADS1262. I've been trying to achieve maximum resolution by setting the MODE2 register gain to 101, which is 32V/V. The default PGA setting is 000 or 1V/V. The line I set the gain is: "PC_ADS1262.ads1262_Reg_Write(MODE2, 5<<4 | 2);" I think it is probably set for the 32V/V, but I was wanting to do a register read to make sure where it is actually set at. I do not know how to do the register read, any suggestions?
The ADS1262 datasheet page 85 shows a RREG read register command, but I simply do not know how to use it. BTW, with the adc connected to a 10mV voltage the best results I get are 0.00997589244 volts or 0.00997589149 volts. It jumps between those two voltage readings. So the increment is 0.00000000095 volts. That's pretty good precision, but its not 32-bit. ADS1262 datasheet
 example.ino
 this example gives differential voltage across the AN0 And AN1 in volts
 Hooking-up with the Arduino
 ----------------------
|ads1262 pin label| Pin Function         |Arduino Connection|
|-----------------|:--------------------:|-----------------:|
| DRDY            | Data ready Output pin|  D6              |
| MISO            | Slave Out            |  D12             |
| MOSI            | Slave In             |  D11             |
| SCLK            | Serial Clock         |  D13             |
| CS              | Chip Select          |  D7              |
| START           | Start Conversion     |  D5              |
| PWDN            | Power Down/Reset     |  D4              |
| DVDD            | Digital VDD          |  +5V             |
| DGND            | Digital Gnd          |  Gnd             |
| AN0-AN9         | Analog Input         |  Analog Input    |
| AINCOM          | Analog input common  |                  |
| AVDD            | Analog VDD           |  -               |
| AGND            | Analog Gnd           |  -               |
-----------------------------------------------------------------
*/
#include <SPI.h>
#include <SoftwareSerial.h>
#include <math.h>
#include <ads1262.h>

#define PGA 32
#define VREF 2.50                 // Internal reference of 2.048V
#define VFSR VREF/PGA
#define FSR (((long int)1<<23)-1)

ads1262 PC_ADS1262;                     // class

float volt_V=0;
float volt_mV=0;
volatile int i;
volatile char SPI_RX_Buff[10];
volatile long ads1262_rx_Data[10];
volatile static int SPI_RX_Buff_Count = 0;
volatile char *SPI_RX_Buff_Ptr;
volatile int Responsebyte = false;
volatile signed long sads1262Count = 0;
volatile signed long uads1262Count=0;
double resolution;

void setup()
{
  // initalize the  data ready and chip select pins:
  pinMode(ADS1262_DRDY_PIN, INPUT);                  //data ready input line
  pinMode(ADS1262_CS_PIN, OUTPUT);                   //chip enable output line
  pinMode(ADS1262_START_PIN, OUTPUT);               // start
  pinMode(ADS1262_PWDN_PIN, OUTPUT);                // Power down output

  Serial.begin(9600);
  //initalize ADS1292 slave
  PC_ADS1262.ads1262_Init();                      // initialise ads1262
  Serial.println("ads1262 Initialised successfully....");

 }

void loop()
{
  volatile int i,data;

 if((digitalRead(ADS1262_DRDY_PIN)) == LOW)               // monitor Data             ready(DRDY pin)
  {
    SPI_RX_Buff_Ptr = PC_ADS1262.ads1262_Read_Data();      // read 6 bytes  conversion register
    Responsebyte = true ;
  }

  if(Responsebyte == true)
  {
    for(i = 0; i <5; i++)
    {
      SPI_RX_Buff[SPI_RX_Buff_Count++] = *(SPI_RX_Buff_Ptr + i);
    }
    Responsebyte = false;
  }

  if(SPI_RX_Buff_Count >= 5)
  {

    ads1262_rx_Data[0]= (unsigned char)SPI_RX_Buff[1];  // read 4 bytes adc count
    ads1262_rx_Data[1]= (unsigned char)SPI_RX_Buff[2];
    ads1262_rx_Data[2]= (unsigned char)SPI_RX_Buff[3];
    ads1262_rx_Data[3]= (unsigned char)SPI_RX_Buff[4];

     uads1262Count = (signed long) (((unsigned long)ads1262_rx_Data[0]<<24)|   ((unsigned long)ads1262_rx_Data[1]<<16)|(ads1262_rx_Data[2]<<8)|ads1262_rx_Data[3]);//get the raw 32-bit adc count out by shifting
     sads1262Count = (signed long) (uads1262Count);      // get signed value
     PC_ADS1262.ads1262_Reg_Write(MODE2, 5<<4 | 2);  //Here is where I set the gain
     resolution = (double)((double)VREF/pow(2,31));       //resolution= Vref/(2^n-1) , Vref=2.5, n=no of bits
    // Serial.print(resolution,15);
     volt_V      = (resolution)*(float)sads1262Count;     // voltage = resolution * adc count
     volt_mV   =   volt_V*1000;                           // voltage in mV
     Serial.print("Readout voltage");
     Serial.print(" : ");
     Serial.print(volt_V,9);
     Serial.print(" V ,");

   }

  SPI_RX_Buff_Count = 0;

}

float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

How many digits does float/double give you? https://en.wikipedia.org/wiki/Single-precision_floating-point_format

Not sure if this is what you want Mikael but I did "Serial.print(resolution,35);" and got 0.00000003890134334564208984375000000

In AVR gcc float and double are 32-bit (single precision). This gives from 6 to 9 significant decimal digits precision (as stated in the wiki). You loose 8-bits of information when converting from 32-bit integer to 32-bit floating point.

I think the answer to your original question is 10 digits. For example, 9.997589244mV. But the last two digits are not really that precise and should be rounded off, to 9.9975892, giving 8 digits. That is probably in the 24-bit accuracy area. Do you agree?

Yes, 32-8 is 24 :).

Here are the important parts of the code I use to READ or WRITE to registers in the ADS1263 chip... I hope this helps you over this hurdle...
// The ADS1263 2 byte commands.
// Note the 3 msb are the command, the remaining bits are the starting register address.
// Refer to table 37 on page 85 of the SBAS661B.PDF for details of the ADC command map.
// Read XXXn nnnn register(s) starting at address XXXr rrrr. The first byte 001r rrrr and the second byte 000n nnnn.
// Write XXXn nnnn register(s) starting at address XXXr rrrr. The first byte 010r rrrr and the seconf byte 000n nnnn.
const byte WREG = 0x40; // 0b01000000 ADS1263 Command Write 40h + reg address.
const byte RREG = 0x20; // 0b00100000 ADS1263 Command Read  20h + reg address.
const byte MASK = 0x03; // 0b00000011 mask out the msb's and limit block size from 0 to 3 bytes.

unsigned int ads1263_Read_Reg(byte thisRegister, byte bytesToRead)
{
byte inByte = 0;
unsigned int result = 0;
byte readStatus = 0;
byte readCRC = 0;

... REDACTED
// ADS1263 expects the register address in the lower 5 bits of the byte. So no shifting of the bits is necessary:
// Now combine the address and the command into one byte bit masked to add the read register command.

byte dataToSend = thisRegister | RREG;
byte lengthToRead = byte bytesToRead & MASK; // Enforce a maximum of 3 bytes.

... REDACTED

SPI.transfer(dataToSend);
result = SPI.transfer(0x00);
lengthToRead--;
if (lengthToRad > 0)
    {
    result = result << 8;
    inByte = SPI.transfer(0x00);
    result = result | inByte;
    lengthToRead--;
    }

... REDACTED

Serial.print("Register Data: ");
Serial.println(result, BIN);

... REDACTED
}

If you used an array for a read buffer you would not have to enforce a maximum of four bytes at a time reading as unsigned int can only hold four bytes...


text:
How can I fix stuttering motors that are connected to ESC's [Arduino Uno]?
Been making a few posts about my drone and i am getting closer and closer to my goal to make it work.
Right now I have a problem with stuttering with all four of my motors (sometimes the motors does not even start but they beep instead). This is the motor and esc I use: https://hobbyking.com/en_us/mt1806-brushless-combo-include-esc-5030cw-ccw.html
I put together a very quick schematic on how i have everything connected:

So motor connected to the ESC and the ESC grounds go to arduino Gnd, the signal pins from the ESC goes to different pwm pins and the rest of the esc goes to the power distribution where i also insert my 3s lipo battery. From my power distribution i connect two cables to my arduino uno gnd and vin pin.
When I use this very simple code:
ESC9.write (100);
ESC6.write (100);
ESC5.write (100);
ESC3.write (100);
delay (2000);

ESC9.write (0);
ESC6.write (0);
ESC5.write (0);
ESC3.write (0);
delay (2000);

The motors start like they should but they stutter (some motors move more than others) and as you can see in my code i tell them to stop after 2 seconds to see if i can control them and indeed they stop nicely.
This is a 3 second video on how it looks once I enter my lipo battery:
https://vid.me/XpWg
Is this a case of bad soldering somewhere perhaps or do I need to calibrate my ESC/motor? Codewise I am just using a simple Servo and then I just use the code I posted above. Do I need to add anything else maybe? Since all 4 motors are stuttering/buzzing it is most likely not a problem with the motor/esc i suppose!
My arduino uno is a chinese copy, could that have anything to do with it?
Also I made this post earlier with a little less information but more info about my soldering: All four of my ESC motors stutters when I run it on my Arduino, how can this be fixed?
Appreciate every help and tips!

This seem to be the same problem. You should have just edited the previous question.

Ah ok i am pretty new so i thought i should create a new post with more info.

Please edit the original post with this new information/images.

It isn't clear from your diagram or the video what wire thicknesses you've used or precisely how currents are being routed, or how big your battery is.
Let BPG denote the ground terminal on the battery pack, and BP+ the battery's positive terminal.
There should be heavy wire from BPG to the ground pin of each ESC.  There should be a signal wire (that is, heavy or light, makes little difference as long as motor currents have their own heavy wires to follow) from BPG to an Arduino Gnd pin.
There should be heavy wire from BP+ to the positive voltage pin of each ESC.  There should be a signal wire from BP+ to Arduino Vin.
There should be signal wires from Arduino PWM outputs to ESC PWM inputs.  There should be heavy wires from ESCs to motors.
Also, in your code try changing 100 on up to 200 or 250 (or near whatever the ESC maximum setting is) to see if problem persists at higher levels of PWM drive.  Also if your battery pack is small, add some more packs of the same voltage in parallel, or try a heavier-duty pack.
Edit 1: Check whether each of the motors can work ok by itself.  That is, either comment out three at a time, or use if-statements that check button or jumper settings.  If all the motors work ok singly, try them in pairs or triples.  There are six different combinations of motor pairs, so rather than trying all six of those you might first try the four different sets of three motors at a time, and if that reveals a combination of three motors that fails, try the pair combinations among those three to see if there is some interaction between two motors.  If problems occur when testing with fewer than four motors, try swapping motors on to different ESCs, to find out if the problem is due to a motor, an ESC, or the battery.  (You can also swap motors on ESCs and test all four at once, but testing with fewer motors going should provide a more systematic problem solving method.)

I have used regular arduino jumper cable on everything except with the ESC and motor. with the ESC i soldered a bullet on the red and black wire (that are a little bit thicker than an arduino cable and then i connect those to the power distribution board. On the distribution board there are two slots where i can put two arduino jumper cables and there i put one that goes to the GND and the other to the VIN.

The motors that are connected to the ESC are also 3 thicker wires that i have put together (did not need to solder anything here, just put them together). I tried changing to 100, 200, 250 but it stutters the same with the same frequency. My battery is a 3s lipo with 1500 mah 65C.

This is the motor + esc i use: https://hobbyking.com/en_us/mt1806-brushless-combo-include-esc-5030cw-ccw.html and the battery i use: https://hobbyking.com/en_us/graphene-1500mah-3s-65c-w-xt60.html

Have you tried with two motors only, or three?   See edit 1 for more comments on testing

Will try it now!

A weird thing that is happening now (and also has happend before) is that the drone beeps once i insert my lipo battery

Is that a sign of something?

Some drones beep once when they pair up with transmitter, and continued beeping is a low-voltage signal on some drones; aside from that I don't know.

yeah when it works it beeps twice but now i have the issue that it keeps beeping. like it is some sort of error.

Double check if by mistake there might be a short in the wiring.  What battery voltage do you measure just before, and just after, turning it on?

I do not have an oscillator unfortantly :( which makes it very hard to solve this

Beeping noise comes from the motors when the PWM of ESC does not have enough power to rotate the motor. Since you are hearing a noise, this is a good indication that PWM exists.
Now, if you lower your duty cycle, beeping noise should decrease and vice versa. This way, you can know that the arduino is capable of controlling your ESC PWM and duty cycle.
Since you can control duty cycle and you have a PWM and no motion, there are a couple problems that comes to mind.

PWM of ESC can not follow BLDC rotation speed. So your ESC can't detect back emf of your motor. (From your diagram, I think its a sensorless ESC.) This could happen if ESC voltage sense pin does not work, or there is noise etc. But its unlikely that all ESC are broken.
You say that sometimes it works and there is stuttering. Well, stuttering exists also if BLDC can't sense back emf correctly so it is issuing the wrong angle at the wrong time and this causes the motor to sometimes go back a bit which appears as stuttering.
ESC supply voltage drops when motors are running, this causes ESC to shut down/ behave erratically. This happens when you have bad soldering or thin wires.

I would say that the third is the most probable cause.
As for back emf detection, measure motor back emf yourself using your arduino (if you don't have an osilloscope, of course). Send data to PC and see if there is good back emf when you turn the motors (turn them fast using another motor or your hands with a quick motion)

This is a better image of the schematic/circuit: http://imgur.com/a/JYAiO
The yellow, brown and purple cables are small arduino jumper cables

Can you try with arduino powered from laptop/PC and see it works?

I have tried when I disconnect the cables from power distrubtion board to the arduino and then I power the arduino with the computer while I power the drone with the lipo battery. Is there a way I can power the motors only by the PC?

If i do the thing i mentioned above they still stutter the motors. I have not tested to power the arduino + motors only by pc though. Is that possible?

That is unlikely. Your motors are rated for 11.1V, that for one. Also, they probably will require a ~1A at least for no-load operation. Your PC USB will blow up. Can you try removing all ESC, just leave 1 ESC and motor and try? What happens then?

Will test it later today and get back to you :)

Tried with one motor only but with the same outcome

Do you have an oscilloscope? Can you provide a graph of power and data (PWM) signals?

I do currently not have one :( I have a arduino pro mini here at home, do you think it could be a possibility for the drone to work if i use that one instead of a arduino uno?

If I were you, I'd give it a try. There are many ways a part/whole of a microcontroller might fail even if your hex file verifies and you are sure of your program.


text:
Controlling servo with IR led and photodiode
I have found myself a really nice scheme of a buzzer that is controled by the IR led and photodiode by I want to upgrade it so it can be used for controlling a servo. What I have in mind is that when there is no object the servo whould stand still and when object comes by it will go to 90 degrees, wait for 5 sec and go back to 0 position. I just want to know is that possible for an Arduino starter and where should I look for help. Thanks.

Yes that is possible.
Start by googling for the two halves of your project separately. Find a project, example or tutorial which controls a servo. Get it working. Understand it.  Then find one which deals with a sensor similar to the one you want to use, get it working, understand it.
Then you'll have everything you need to get your project up and running.

Feel free to post a new question if you have a specific problem. Accepting one of the answers to this question, if one helped you, will encourage people to keep helping you.

The convenience of the Arduio development paradigm is that most common hardware projects have been abstracted by software libraries to simple software interfaces.  This is the case for controlling common servos motors.
If you find it sufficient, use the Arduino servo library to control servo motors.  There are only 6 method to understand and in most cases you only need 2 or 3 of them.  This example appears to satisfy your requirements for a sweeping servo.


text:
RFID reader for unknown tag 125kHz
I have an unknown RFID tag and tried to read its value. I bought two readers, RDM6300 125KHZ and RC522 13.56MHz. Each of the readers connected to Arduino works well with the purchased corresponding tags, but not with this tag. According to my information, the tag should be 125kHz tag, but RDM6300 foes not read it. The tag is simply not detected. I am sure that the tag works, I use it to open the door.
So my question is: Is there any other RFID reader for Arduino, which is different than the two that I have, and could work?
Thank you.

It could be something else (in the RFID low freq ~ 125khz) like a HID card.
Also it could be an NFC (high freq 13.56Mhz) that its not compatible with the RC522.
Do you have access to a phone with NFC, to start ruling out what could it be?


text:
Does Atmega-2560 support image processing capability?
As the title says can I perform image processing on Atmega-2560?
Basically I have to capture real time images and detect green or red color.
I have not thought of the frame rate but it is not that fast or slow.

How large images? What type of image processing operations? How fast; frame rate etc. In general - no.

@MikaelPatel I have updated the question.Thank you

Please give numbers. You may as well ask if a bus with an unspecified number of seats can carry an unspecified number of passengers an unspecified distance in an unspecified time. For example: 1024 x 768 pixels, in 24-bit RGB, at 30 FPS. Do you need to detect exact green? A range? What if green and red are mixed? Do you want to detect if there is a single pixel of red, or more than one?

No. Your question really is: Can an 8-bit processor, running at 16 MHz, with 8 KB of RAM, do image processing at an acceptable rate? Unless you are talking about 10 pixels by 10 pixels, at a frame rate of 1 frame per second, then I doubt it.
You may want to ask the "real" question. See The X-Y Problem. There are sensors around that detect colours. If you are making a maze-following robot that needs to stop if it gets near to a red wall, that is a much more achievable objective.


text:
LCD from Arduino Starter Kit not displaying text
I've been tinkering with my new Arduino a bit and I was adding an LCD from the starter kit, using information from the eleventh project in the project book, "Crystal Ball." When I connect the Arduino to my computer, the LCD lights up, but no text is displayed on the screen.
Here are some screenshots of my connections:

Finally, here's the code that I uploaded to the Arduino:
#include <LiquidCrystal.h>

// Create this display with the pins that I wired
LiquidCrystal lcd(12, 11, 2, 3, 4, 5);

void setup()
{
    // This is a 16x2 display
    lcd.begin(16, 2);

    lcd.print("hello!");
}

void loop()
{
}

edit: Additionally, I tried adding a potentiometer to control the display, but to no avail. Below is the wiring for this (back pin goes to the third to last pin for the LCD).

Those photos don't show the circuit adequately.  Please edit your question and add a schematic diagram of the circuit.  If you don't have a schematic diagram drawing program or some other drawing program click the icon (in the edit tool bar) that looks like a pencil pointed at a circuit diagram.

In the end, it turned out being a combination of what Andre's Answer suggested, as well as the "brightness" of the LCD. My potentiometer seems to have kind of a "stick" to it, meaning that to get the LCD to move to the value necessary, I had to crank the thing harder than normal, then it started displaying my text.

Looking at your first picture it looks like you are wired on 12 and 13 not to 11 and 12 like your sketch specifies.
Double check your wiring against this : https://www.arduino.cc/en/Tutorial/HelloWorld
Also take your multi-meter out and buzz your connections.


text:
Powering Arduino with reverse car lights?
I'd like to build a reverse car sensor using Arduino
When we select reverse gear, the reverse lights powers, so we can take electricity from them.
My question is can i power my Arduino directly from the reverse lights wires, or should i use regulators or anything else?

What board are you using? Most boards already have a regulator on it.

Use a switching regulator such as the LM2596. You can get a ready board from eBay for about US$1

can i use car phone charger as a regulator?

It depends very much on the car and your Arduino. There are two factors to consider:

Leeching power off lights can have an adverse effect on the car's ability to sense a blown bulb.
Many Arduinos have a 2 second delay while the bootloader executes (some even have 8 seconds).

If your car doesn't sense blown bulbs (most modern ones now do, even cheap ones) and you can work without a bootloader (programming directly with a USBasp for example) to avoid the power-on delay, then it may be possible, yes.
As has been mentioned by others, using a switching regulator is the best method for powering the board as it avoids excess power loss through heat (which can especially be a problem in confined spaces). I would recommend not using one of the cheap eBay modules, but instead using a proper "cigarette lighter" to USB adaptor (available from all good gas stations priced $5) which is designed to work with automotive voltages. A car's 12V power has transients in excess of 50V sometimes (back EMF from the spark generation) and the electronics have to be able to cope with that - those cheap eBay modules aren't designed for that and could die taking your Arduino with it.

This is just to top off the other answers. If you have a fairly modern car that runs on LED lights, you can easily use that voltage. MOST LEDs run from around 3-6V soyou might want to measure the voltage. If everything is good, then you can connect the positive of the LED to the 5V of your Arduino and GND to GND.


text:
Can't communicate with SIM800 module
I am using Arduino Uno R3 and a SIM800L (voltage regulator built in). My initial setup included a 10kΩ resistor soldered between the lower end of the RX and GND pins on the SIM800L, and a 4.6kΩ resistor soldered on the jumper connecting SIM800L's RX and Arduino's declared TX (pin 7). SIM800L has its own power supply (5v-2A). This is a setup I have used previously on two different SIM800L modules, and everything worked fine without any (visible) problems.
Baud rate is set to 9600 in Arduino IDE, PC port (via Device manager), and the module, through the sketch.
After loading the sketch (first one) shown on this site, the SIM800L connects to the GSM network (I can tell by the delay between blinks), but the module does not respond to AT commands send via serial monitor.
The sketch
#include <SoftwareSerial.h>

//SIM800 TX is connected to Arduino D8
#define SIM800_TX_PIN 8

//SIM800 RX is connected to Arduino D7
#define SIM800_RX_PIN 7

//Create software serial object to communicate with SIM800
SoftwareSerial serialSIM800(SIM800_TX_PIN,SIM800_RX_PIN);

void setup() {
  //Begin serial comunication with Arduino and Arduino IDE (Serial Monitor)
  Serial.begin(9600);
  while(!Serial);

  //Being serial communication witj Arduino and SIM800
  serialSIM800.begin(9600);
  delay(1000);
}

void loop() {
  //Read SIM800 output (if available) and print it in Arduino IDE Serial Monitor
  if(serialSIM800.available()){
    Serial.write(serialSIM800.read());
  }
  //Read Arduino IDE Serial Monitor inputs (if available) and send them to SIM800
  if(Serial.available()){
    serialSIM800.write(Serial.read());
  }
}

Things tried
Thinking that the resistors might be causing this, I removed all of them, and made a clean connection with Arduino. And the problem persisted.
I tried resetting the module, by passing the ATW command into a sketch:
serialSIM800.write("ATW\r\n");

and that also gave no results. Further testing with:
if(!serialSIM800.available()) {
    Serial.println("Not working");
}

indicated where the problem might be.
I have also tried changing the baud rate to 48000, 57600, and 115200, but that did not solve my problem.
The question
Am I right in assuming that a reset to factory settings could solve my problem? If so, how can I reset the module, without the AT commands? If resetting would do me no good, what else could I try?

Serial communications (UART/USART) requires the RX/TX pins of the sender and receiver be swapped.  So connect the TX from the Uno to the RX of the Sim800L, and RX from Uno to TX on module.  (Or, just swap the pin numbers for your softwareserial setup above...)

You're right about the sending and receiving, of course - even the SoftwareSerial.h says, when defining the method - SoftwareSerial(receivePin, transmitPin, inverse_logic=false). But, the setup already works like that, it's the original sketch that swaps the naming for attempted clarity (SIM's TX to Arduino's D8 - Arduino receives on D8, SIM's RX to Arduino's D7 - Arduino sends through D7). I've tried swapping the pins, just to be on the safe side, and, as expected, there was garbled output in Serial monitor. Something along the lines of ÿÿÿ ÿ ÿÿÿÿÿÿÿ ââââ

This is widely happen problem - serial communication with SIM800L stopped working.
You can do reset, but in my case it didn't help: on powered SIM800L module shortcut "RST" pin with the ground for half of second - unit should reset and restart. I think it's defective architecture/firmware, but unfortunately SIMCOM dropped support for this model, so best advise is to avoid SIMCOM until they study how to make quality products.


text:
Does Arduino Tian/LininoOS support Python 3?
I'm using an Arduino Yun running OpenWRT and it only runs Python 2.7.
I need to find a microcontroller+processor+WiFi board that supports Python 3. Does the Arduino Tian work for this, or are there any others?

OpenWRT supports Python 3.3; is OpenWRT on the Yun less capable than elsewhere?  Also see Installing Python3 section in Python page at openwrt.org

it is different. its based on a selfmade kind of openWRT. it does not have ./scripts/ and the path for opkg is: http://downloads.arduino.cc/openwrtyun/1/packages/Packages.gz
im searching for python3+

Linkit Smart 7688 Duo Yun compatible board has support for python3.4 with openWRT 15.05.1. But it lacks some of the nice Arduino stuf like REST API with YunServer/Bridge

Yes, run the following
opkg update
opkg install python3-base_3.4.3-2_ar71xx.ipk

this does not work on Yun v1 nor on Arduino Industrial 101 im still searching for a greater version then 2.7 on one of those boards...


text:
Linking one circuit to two Arduinos
I don't actually have to achieve this, it's more of an attempt to see what the best way to do this is. I'm sure the answer also differs depending on what circuitry you're trying to connect.
In this case, I plan on an Arduino (probably a Pro Mini or similar) that will control some RGB LEDs (via the WS2811 chip). If I wanted to add a second Arduino that would drive the LEDs if the first one failed (obviously very unlikely), I was wondering how I would do it. The WS2811 chip takes 5V, GND and data in.
My best attempt at a solution is using 3 relays which are SPDT. Connect the LEDs to the main Arduino via the normally open, which is controlled by that particular Arduino, and connect the LEDs to the backup Arduino via the normally closed, which is held open by the main Arduino. In the event of a failure, the main Arduino would lose connection to the LEDs while the backup would make a connection.
This probably isn't a very safe way of doing it (especially if the relay failed for example). Is there a way to do this?
The two Arduinos will be powered from two separate laptops.

You are also assuming that the Arduino pin will go LOW if it fails. Also, what if it fails because of a faulty power supply. Then after the power supply takes down the first arduino, it would then take out the second. I'd rather invest time in making the setup and software more robust. E.g. enabling the WatchDog-timer inside the Arduino.

And is there a particular reason you think the relay will be more reliable than the Arduino? You still have a single point of failure, and now it's a device with moving parts.

You first need to make a communication between both Arduinos and then you can control RGB led from any Arduino.
For the connection between both the Arduinos, you can make a serial port interface for doing this, you just need softwareserial.h library. Then you just need to connect the RGB LED to one Arduino. Then when you send a command from another Arduino to that one, the Arduino (Connected to RGB LED) can operate the LED according to the command.

You can try something like this:
Tie both arduino 5V to WS2811 chip VCC.
Tie both arduino GND to WS2811 chip GND.
Tie both arduino DATA LINE to WS2811 chip DATA LINE.
Tie an analog input pin from the backup arduino to chip DATA LINE.
Tie an analog input pin from the main arduino to chip DATA LINE.
Issue RS232 or some form of communications between the main and backup arduino.
Program the main arduino to control the data line. Program the second arduino to:

Sleep, if DATA LINE PWM is present. (Optional: Ask main arduino if operational)
If DATA LINE PWM is absent (you'll see this from analog input), ask main arduino if he is okay or if this is a fault
If no answer is received and PWM is absent, assume main arduino dead, start own PWM on DATA LINE. Also, send message to main arduino that the backup is currently online and he should not intervene.
If main arduino comes alive, he first checks if backup is operational (Also it's good to read if PWM exists). If message is received that backup is operational, send message to backup to shut off and take DATA LINE for self.
If no message is received and no PWM is present in DATA LINE, assume backup dead, take DATA LINE to self.

Further notes:

If you decide to use communications, make sure to use a handshake algorithm to prevent accidental interventions.
You can do this project without the communications between chips but it will depend on your project and will require some clever coding.
Make sure you create some clever time gaps on those messaging and reading stuff.
I would advise you to both use analog readings and communications because it is a sort of double check on seeing who is active at the moment. Communications will ease your code development and analog read is required in case of com line failure.

Good luck!
P.S. Don't just use relays like that. It will make debugging and code writing very difficult.

One other tip: add small resistors on the data outputs of each Arduino (in series) of maybe 100Ω or so. This will limit current through both GPIO pins in the event that you get both Arduinos driving the data line at once.

I forgot to mention that the two Arduinos will be powered from different laptops. Does that matter?

As long as you connect their (the arduinos) GND lines, you should be fine.  On this schematic though, arduino GND's are already connected so it is okay. Also, please consider Majenko's advice. Use resistors, capacitors etc. wherever necessary.

Surely it cannot be safe to supply the WS2811 with 5V from both Arduinos?!

I think it's safe enough if you put a series diode on that 5V supply of both arduinos. This will prevent reverse current on 5V pin. Add 220Ohm resistors in series to data line of both arduinos like Majenko says. This will prevent your pins of burnout if you make a coding mistake. About the GND, it is possible that there is static/DC electricity flow from one laptop from the other on the GND line. This can cause problems. Try to use one laptop if possible. If not, try to connect GND's before the arduinos with some good soldering. This is optional/case dependant, of course.

As a side note: if you put those series diodes, the output voltages of the 5V pins will probably be slightly different so your WS2811 chip will be fed from only one arduino, the other 5V would be reverse polarized. You can pick diodes with different voltage drops to enhance this, as well. But the worst case is 5V is being fed from one and another. Like switching sources. Even in that case, I don't think there is an issue with your setup.


text:
Arduino Disconnects after router password changes
I am working with arduino Uno R3 connected with EPS8266(http://www.amazon.in/ESP8266-Serial-Wireless-Transceiver-Module/dp/B00O34AGSU?tag=googinhydr18418-21&tag=googinkenshoo-21&ascsubtag=858e5035-7713-403a-942e-487a0fe24800). After router password is changed, it should be re programmed with new password. Is there any another way not to do so repeatedly. I managed 2 SSID for router which one have always unique password. But I think this is not a solution. Is there any technique or idea that says only for particular mac address, the SSID will be opened.

Routers have multiple "passwords".  I assume you are talking about your wireless encryption key (i.e. WPA/WPA2 key).  When the encryption key is changed, you are correct: you have to re-program the ESP8266 with the new key, because it can't learn this information on its own.  If this key were broadcast, then your network would not be secure as everyone would be informed of the encryption key.
Why is the key changing?  Is there really a need to change the encryption key often?
MAC addresses can be spoofed, so permitting a specific MAC address to "always connect" is not secure.

Thanks for ur valuable reply.. I am making a very secure wifi protocol that has a function to allow network for particular mac address. Because the device in which it is gonna be loaded will not be touch for next 5 years. In between if router changes may occur than this problem may arise.


text:
How can I read delay of a note that I am playing
I am playing note tone with CapacitiveSensor and an output of tone
like this
void loop() {
    time_before = millis();

    long total1 =  cs_2_3.capacitiveSensor(30);
    long total2 =  cs_2_4.capacitiveSensor(30);

    if((total1>200)||(total2>200)) {

        if(total1>200) {

            tone(12,261);
            time_after = millis();
            Serial.print("Time: ");
            Serial.println(time_after-time_before);
        }
        if(total2>200) {
             tone(12,294);
             time_after = millis();
             Serial.print("Time: ");
             Serial.println(time_after-time_before);
        }
    }
}

How can I read how many seconds I play this note par example

You are not calling noTone() anywhere, and you are calling tone() with two args, so the duration is indefinite. Perhaps you should add more conditional statements to detect when the "press" is released, and stop the tone there, as well as calculate the note length.

@uint128_t - Your comment is the correct answer to this OP's question. You should post it as an answer. As it stands only the code execution time is measured, and not the tone duration, and it is the latter which is the OP's real goal.

@Greenonline Your answer looks pretty good, so I will upvote that :)

Your code currently will only measure the code execution time and not the duration of the note(s) being played.
You need to follow uint128_t's suggestion and rewrite the code to detect the "button release", at which point you measure the time with millis(), and call noTone(). Only then will you be able to measure the note's duration.
I believe that the source of confusion is that you seem to think that tone() acts like delay() and waits for the note to finish - it does not. tone() merely starts the note and then the next instruction is executed, without waiting for the note to end.
So, using millis() straight after calling tone() will actually only measure the time it takes to execute the tone() statement (and a few if statements - depending on whether you use your original code, or Maximus's code).

Try this:
void loop(){
    long total1 =  cs_2_3.capacitiveSensor(30);
    long total2 =  cs_2_4.capacitiveSensor(30);

    if((total1>200)||(total2>200)){

        if(total1>200){
            time_before = millis();
            tone(12,261);
            time_after = millis();

            Serial.print("Time: ");
            Serial.println(time_after-time_before);
        }

        if(total2>200){
            time_before = millis();
            tone(12,294);
            time_after = millis();

            Serial.print("Time: ");
            Serial.println(time_after-time_before);
        }
    }
}

Use code indentation if you can. Also, that first OR (||) is unnecessary. I think you need to re-write this, or is this what you wanted?

I cant use delay(1000).....

That is just a sample code. The author put that there to slow down the data rate between arduino and PC. You could ignore that, the code would work fine. Anyway, for your function, you don't need to use delay.

Time: 158
Time: 159
Time: 157
Time: 159
Time: 158
Time: 157
Time: 159
Time: 158
Time: 155

if i don't use no delay this is the output have
it's not correct

i want the somme of all the time

If you wrote the code correctly, this would mean that your function takes around 160 ms to run.

I put my code and the output
what's wrong?

Have you tried the code?

yes i tried the code
result is 0 or 1

It seems that the OP wants the time of one complete loop cycle ("i want the somme of all the time"), whereas your code, due to the new placement of the time_before = millis(); will only give the time of each tone() call. Maybe an additional time_loop_start = millis(); is required at the beginning of the loop and then have an additional Serial.println(time_after-time_loop_start); at the very end of the loop.  However, this will still only measure the code execution time, and not the length of the note, which is what I suspect is the OP's real goal.


text:
Why do we need to amplify the signal of an electret?
I do understand from my reading that I should amplify the signal from an electret to be able to read it with an Arduino. I'd love to know the science behind that, why should we amplify the signal to be able to get a correct reading ?

You may find Electronics Stackexchange useful for questions like this.

Arduino (or any chip that uses ADC for that matter) has a resolution. For example, arduino analog read divides 5V to 1024 levels. A.k.a 0V -> 0, 5V->1024. That gives you 4.8mV per level.
Now assume that you want to read the voltage fluctuation of a very low voltage power supply that fluctuates from 0 mV to ~8mV. What does the arduino read? You'll see either 0 or 1. So basically, you just can't successfully read that low voltage with your current setup.
Now, if you use an analog OPAMP and amplify that signal to 5V, (0mV->0V, 8mV->5V) then you can use all 1024 levels available to you, provided by arduino.
That's why you need to amplify the signal.

How do you figure out the voltage fluctuation ? (or what is the matching indication in a datasheet ?)

It will be in the datasheet. You just have to read it. I don't think there is a standard symbol for it, but look for Vrms as units maybe.

As Majenko said, you can check the datasheet. It's probably the first thing you want to do dealing with electronics. If you can't find it, then perhaps, just create an amplifier opamp circuit, tie it to arduino or which board you like and read the voltages and send to pc. You can put a potentiometer to opamp to change amplify rate and so on. There is much information about this on google or here.


text:
Interrupts on the Arduino NG
I am a newbie to using arduino.
I am using an arduino NG  (using an atmega8). One of the pins is a button that triggers an interrupt.
The problem I am trying to solve is that I want an arduino NG to store the timestamp (we are using mills as a timer -no need to consider the 50 day rollover error here) when the interrupt pin is pressed.
The timer of the interrupts in milliseconds is stored in an array and there are up to 100 such interrupt button presses.
After searching around I didnt find any information for using interrupts with atmega8 on arduino NG (though there is information of how to use interrupts on atmega168 with arduino NG ).
So my question is: Is this problem solvable with an atmega8 arduino NG? Does the atmega8 arduino NG have interrupts? Just need one interrupt. And what would be the code to read an interrupt on atmega8 version of arduino NG?

Why do you believe that the ATmega8 is that different from the ATmega168 given that the Arduino libraries are designed to abstract away details?

@IgnacioVazquez-Abrams regarding interrupts atmega8 is different168 there-so that may imply the the same code wont work -and I couldnt find any examples when searching

Does the atmega8 arduino NG have interrupts?-

Page 1 of the datasheet:

Yes, it has interrupts.

just need one interrupt.

Page 46 of the datasheet:

It looks like you have 19 of them.

regarding interrupts atmega8 is different168 there-so that may imply the the same code wont work -and I couldnt find any examples when searching

Try using the Arduino libraries. If that doesn't work post your code.

ATmega8-family chips have 19 interrupt vectors, vs 26 in ATmega48/88/168/328-family chips.  (See Table 16.1, Interrupt Vectors in ATmega8A, in chapter 16 of ATmega8 documentation; and see Table 12.1, Interrupt Vectors in ATmega48A and ATmega48PA; Table 12.2, Interrupt Vectors in ATmega88A and ATmega88PA; and Table 12-4, Reset and Interrupt Vectors in ATmega168A and ATmega168PA, in chapter 12 of the ATmega48/88/168/328-family datasheet.)
Both families have INT0 and INT1 External Interrupt Request pins, so if either of those is the pin your application depends on, it should work ok on an ATmega8 system.
I don't see any mention of pin-change-interrupts in ATmega8 documentation so an application depending on PCI's probably wouldn't work.

You should check against the datasheet;

Does the atmega8 arduino NG have interrupts?-just need one interrupt.

It has two external interrupts.

And what would be the code to read an interrupt on atmega8 version of arduino NG?

google or read the datasheet. It is fairly simple to set up and use.


text:
Arduino Uno + USB Host Shield + Motor Shield
We have an obstacle avoiding robot, and we decided to upgrade it by controlling it with a PS3 controller, so I am asking if above the Arduino UNO we can attach the USB host and above the Host attach the motor shield where the motors are connected to?

Read the documentation for both shields and see which (if any) pins they share, then decided if these pins can be shared.

You need to check the I/O used by each shield to make sure there is no conflicts.


text:
how to prevent IR signal to go through 3d printed plastic?
I'm working on two arduino (one a dock, the other one on a robot) communicating through a IR to let the latter know about its location.
I 3D printed a piece which goal was to channel the 3 IR led lights, to prevent them from overlapsing (exactly in the same manner as the Kobuki.
For a reason I don't know, the IR signals seem to go through  the 3D printed piece which doesn't seem to let visible light through.
I known that there is no 100% absorbant materials, and I know "black for visible lights" doesn't necessarily mean "black for IR lights".
I think my problem is more related to my lack of experience in the field. My question is : why do I get signals from a IR led channeled toward a location I am not in ?
Patently, it means my light channels are not channeling light.
Therefore, better : How can I make a better (and cheap) channel for IR light ?
The piece I 3D printed is grey (silvery like I guess)
edit : to prevent incomprehension, i would like to clarify "channel". What I mean is to block all light "not going" in the right direction, whatever happens to that light. I apologize if it is not the word I should have used.

IR (infrared) is like heat, right? If you have a fire in your room, does it still get hot at the other end of the room, even if you have a chair between you and the fire?

We had this problem at a previous job - and it's surprisingly difficult. Long story short, we found that enclosing the devices inside cardboard boxes did NOT work, but wrapping the boxes entirely in aluminum foil, without a single gap, pretty much did work - although then it's difficult to get the cables in. Good luck.

Well one is first and foremost an electromagnetic radiation I can deflect with a mirror while the other is a mechanical energy of shock between molecules, isn't it ?

Oh, really ? I'm going to try and spread a little aluminum on the 3d printed thing, thank you

I use aluminium tape for this kind of thing. It's used for sealing joints in heat ducting. Cheap and easily obtainable, and being self adhesive makes it easy to apply.

Are you sure the signal isn't just reflecting of the walls.

didn't know it existed as tape as well, i'll look for that (I've stuck it with glue for now).

I don't think the signal is reflecting on walls, because I put a specific set up to try it !

You can also get reflective spray paint that is quite good. It's also used for EM shielding on the inside of plastic cases since it's conductive.

Are you using ASK modulation?  Are you using  ASK IR receiver devices commonly found in remotely controlled entertainment equipment?

It could still reflect of the 3D printed material. Try, and temporarily replace the IR leds with visible light leds, and see what you can still see.

You can not use common modulation remote control receivers as they contain an ACG feature which will likely "turn up the volume" until it detects even a weak reflected signal.  Instead consider if this reflective sensor, which does not contain an AGC feature, is appropriate for your design.
Alternatively you might explore the response time of the AGC feature to see if you can defeat its intended purpose.  That is to say, rapidly switch between IR transmitters in order to keep the AGC level at low gain.  Essentially blinding it from weak reflected signals.
You might also transmit continuously on all IR sources and determine if the AGC will put the weak signals below the noise floor.

I don't know if it will work but i've ordered some of these. Do you happen to know if they work with IRremote ( https://github.com/z3t0/Arduino-IRremote ) ?

We are supposed to avoid making recommendations.  However I could not find good technical information w/o referencing an actual part.

When working beyond tried and tested Arduino projects, you need to take the extra effort to verify if components will do what you expect.  In this case, most IR remote controls operate at about 38KHz.  There are exceptions.  Vishay makes several parts based on the linked to specifications.  According to this specification, the last 2 digits of the Vishay part number indicate the operating frequency.  At the bottom of page 1 two parts are listed in the parts table.  There the TSSP4038 is listed as operating at or near 38KHz.

I realize this is old but I have had a similar challenge making an code wheel for an optical encoder.  PLA material did not block the infrared.  however, all of the codewheels that I have made with black PETG material have worked.  Obviously you would want to fill in the shape as much as possible and assure that you do not have gaps between the layers.  Personally I have not had to make any tweaks with the Prusa MK3 printer, black PETG material and the common 0.2 layer height.

The best and cheapest way would be to use BLACK colored printing material as it would absorb the IR waves and would not let them pass!
I did a similar thing when I was building an IR-based Robot so using a black reflector and painting the chassis black increased the efficiency!
Black for visible light is the same for IR too as light is just a small spectrum of electromagnetic radiation, just as IR.

There are plenty of black materials that are completely transparent to IR.

The 3D printing material is generally not.

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


text:
Sweeping servo 90 degrees
#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

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

void loop() {
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}

I have found this code that makes servo go 180 and back, but when I switch 180 degrees with 90, which is what I need, my servo doesn't do that (I tried the code in Arduino simulator).
Do I have to change something elese in the code (like delay time) so it whould go 90 degrees up and then 90 down?
Here is the link of circuit:
https://circuits.io/circuits/3597808-servo-90-degrees

when I swtich 180 degrees with 90 witch is what I need, my servo doesn't do that - So what does it do? ... (I tried the code in Arduino simulator) - What happens with a real Arduino and a real servo? Simulators are merely an approximation. They can never be as good as the real thing.

@Majenko What he does is go 180 degrees up and starts sweeping between 180 and 90 degrees. It is really strage actually, beacuse I didnt inculde 180 degrees in code at all. You think Arduino simulator isn't accurate with servo's?

It sounds like the simulator is rubbish. Get a real servo for your Arduino. They are dirt cheap.

Either that or you are misinterpreting the servo output and what you think is 180° is actually 0°.

@Majenko I will try with real servo but the odd thing is that this first code that I posted is working just for 180 degrees and back, for every other number servo is turning in range between 90 and 180 degrees. BDW simulator is from Autodesk circuits.

Make video of the output and then post it.

@DatHa I edited the question.

No you don't have to change any time delay in order to get it rotating by 90 degrees, delay would just change the speed of rotation of the servo. The simulator you are using is at fault here as the sketch with 180 changed to 90 works flawlessly.
#include <Servo.h>

Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created

int pos = 0;    // variable to store the servo position

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

void loop()
{
  for(pos = 0; pos < 90; pos += 1)  // goes from 0 degrees to 180 degrees
  {                                  // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for(pos = 90; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees
  {
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}

MAKE SURE THAT YOU CHANGE BOTH OF THE 180'S TO 90.

That is what I did, and still nothing..

I just created a simulation on Wokwi Arduino simulator based on your code and it works perfectly fine.
Here is the permanent link

When you first click the "play button", the servo animation jumps around wildly. Why is that happening?

This line of code will properly set up the PWM timers to output the correct signal to move the servo to the value set in 'pos'
myservo.write(pos);

It has nothing do with speed. The servo will try to reach 'pos' as fast as possible.
The delay(15) in your code is the delay time between each "myservo.write(pos);"
The for loop works like this:
myservo.write(0); // Go to 0 degrees
delay(15); // Wait 15ms
myservo.write(1); // Go to 1 degrees
delay(15); // Wait 15ms
myservo.write(2); // Go to 2 degrees
delay(15); // Wait 15ms
myservo.write(3); // Go to 3 degrees
delay(15); // Wait 15ms

etc...
The time in seconds it takes to make a rotation is (range_in_degrees x 15)/1000
e.g. 180deg x 15ms/1000 = 2.7 seconds
90deg x 15ms/1000 = 1.35 seconds
Increasing the 15ms delay will make the servo rotate slower.
Also, make sure that you change the 180 degrees to 90 in BOTH for loops. If you change the value in one, the servo will slowly sweep from 0 to 90, then jump to 180 and slowly swing back to 0 and repeat. (or vice versa, depending on which one you forgot to change)


text:
How is the bootloader activated when device is running?
For the sake of specificity I am referencing my question to Arduino. It applies to all AVRs with hardware USB and a bootloader though.
The bootloader is capable of receiving new program data over the USB interface, and, after programming, releases the interface. It can then for instance be used for the emulation of a serial port, or even register as a HID.
I know what a bootloader is and how it reads program data from the PC and how it writes it to the devices flash memory.
I am asking how the bootloader is triggered again if the user wants to upload a new program. The PC needs to reset the AVR in order to fire up the bootloader. How is this reset instruction implemented in Arduinos with built-in USB hardware (e.g. the Arduino Micro)? Is it solved by performing a software reset after the DTR line goes low just as in e.g. the Arduino Nano, except that the DTR line only exists in software?
EDIT: If that is the case, the solution is unique to Arduinos. I was thinking that there would be some standard way of doing it common to all AVRs.

AFAIR, the Arduino uses the DTR signal from the serial port as a way for the host to trigger a reset of the board (it has nothing to do with USB). This is documented somewhere but I don't recall where.

@RogerRowland So you are saying that after the USB-to-serial decoding is done (in software, on the MC), a change in the (virtual) DTR line triggers a reset?

What I'm saying (or half remembering!) is that the host - the PC end - uses one of the unused serial signals - I think DTR - to reset the Arduino and therefore force it into the bootloader again. If you look at a recent Arduino schematic, you may see what the reset pin it tied to. In the original Arduinos it was necessary to manually press the reset button when programming, which was imprecise and frustrating.

Yes, I know that, but I am specifically asking about AVR with built-in USB capabilities, like the ATMega32u in the Arduino Micro. The USB data lines go directly into the chip. There is no physical DTR signal that could be wired to the reset pin.

So are you asking about Arduino boards or AVR microcontrollers? The former (may) include the latter but they are not the same. Using "Arduino" in your question implies that you're talking about a specific development board, not just a micro. Can you clarify? The general subject of bootloaders is a broad one indeed.

Closing this question was premature, the OP asks a very specific question, which I don't see answered on the linked question.

Check https://www.arduino.cc/en/Guide/ArduinoLeonardoMicro#toc10 for a little bit of explanation. In a micro application that uses the arduino USB-serial library and functions correctly the boot sequence can be triggered by doing something that should rarely occur in normal use (setting the baudrate to 1200). The library (which is part of the application) intereprets this as a request for a reset.

When the library is not used or the applicaton doesn't function correctly you can't reset/bootload a micro "hands-off", you will need to press the reset buttonb manually. This is only needed for arduino's that uise a single chip for both the applicaion anb the serial-USB interface. With the arduino's that have a separate USB-serial chip the DTR line is used, so you can always force a reset, independent of the application controller.

Funny side note: the arduino Due (my favourite) has a separate usb-serial chip, but still uses the "1200 baud" reset (but because it is handled by a separate chip it is a hard reset, unlike on the micro). Unaware of this I once spent a few hours trying to get the serial interface of a Due to work at 1200 baud....

On microcontrollers with bootloader (not just AVRs), the bootloader is a separate executable in flash, and it's typically the program that runs on system startup.  The application will have a special trigger, such as a button sequence, getting a specific byte sequence over I2C, or really anything that will tell the bootloader to enter into its "update" mode.  From there, the bootloader will have some communication (I2C, USB, WiFi, serial, etc) to download and the flash the new application image.
This link has more information about the Arduino bootloader

On the PC side, to trigger a reset on the RESET pin, the PC (avrdude.exe or GNU/Linux equivalent) opens the serial port to Arduino when your press upload and the code is ready to upload. This causes the Data Transmit Ready (DTR) line of the USB/TTL chip to go LOW. The Arduino board has a capacitor charging circuit that uses this LOW (charging the capacitor) signal to momentarily pull down the RESET line of the ATMEGA328P chip before returning it to HIGH (capacitor charging completes). So Arduino resets each time its serial port is opened.
Upon reset, Arduino enters the bootloader.
The bootloader looks at the source that caused the reset. There are several sources that can cause a reset. If the reset was caused by the RESET pin, then it waits for one second for the PC to send in commands. When it receives valid commands, it will start accepting new Arduino code in HEX format and erase the existing code to load new one. If it doesn’t receive valid commands, it times out after one second and triggers a Watch Dog Timer (WDT) reset.

For Arduinos with built-in USB, such as the Micro, the Arduino library (firmware) triggers the system reset.  There's a little chunk of code that looks for the virtual COM port to open at 1200 baud and then close.  When that happens, the code triggers a system reset (by writing a register, typically) which launches the bootloader.

Rather than requiring a physical press of the reset button before an upload, the Micro board is designed in a way that allows it to be reset by software running on a connected computer. The reset is triggered when the Micro's virtual (CDC) serial / COM port is opened at 1200 baud and then closed. When this happens, the processor will reset, breaking the USB connection to the computer (meaning that the virtual serial / COM port will disappear). After the processor resets, the bootloader starts, remaining active for about 8 seconds. The bootloader can also be initiated by pressing the reset button on the Micro. Note that when the board first powers up, it will jump straight to the user sketch, if present, rather than initiating the bootloader.
Because of the way the Micro handles reset it's best to let the Arduino Software (IDE) try to initiate the reset before uploading, especially if you are in the habit of pressing the reset button before uploading on other boards. If the software can't reset the board, you can always start the bootloader by pressing the reset button on the board.

Personal story: I wrote an I2C bootloader for the PIC32.  The only communication with the device was through the I2C bus.  The main application had a special 3 byte trigger that would set a non-initialized variable in RAM, and then trigger a system reset.  The bootloader, which runs on system startup, would check that variable and if it was set, would wait for commands over I2C to download and flash the new application image.  That variable in RAM had to be specially marked as non-initialized, otherwise the C startup code would clear it and the bootloader would never update.
The bootloader also calculated a CRC32 over the application image to validate it before attempting to boot.  If the calculated CRC32 didn't match the stored CRC32 (which was part of the application image), then the bootloader would enter its firmware update mode.  This was a guard against trying to run a corrupted firmware image, which could happen if power was pulled during the update process.

Thanks for the answer. Unfortunately it still misses my main point. I know that e.g. the Arduino Nano has the DTR line hardwired to the reset pin, so the PC can reset the AVR by pulling DTR to ground. How is it done for AVRs with built-in USB hardware? Do the Arduino libraries perform a software reset upon a change in the virtual DTR line?

@polwel I updated the answer to hopefully provide more information about Arduinos with buit-in USB.  The bootloader trigger is done within the Arduino virtual COM port library.


text:
How to get current time and date in arduino without external source?
I'm working on a project using Arduino Uno and SD card shield.
I'd like to store a variable at a specific time everyday in the SD card. How can I get the current time in Arduino ?
Any help would be appreciable.
NOTE : Arduino is NOT connected to PC.

An accurate enough way is to use the millis() function. It  will return the value in milliseconds since the start of the Arduino. If you start the Arduino at a specific time, you will be able to calculate the exact date and time.

Why not an external module?? An RTC such as the DS3231 in merely 5$ and it includes a temperature sensor for you!

Watch out the millis() function will wrap around after about 50 days.

@AndreCourchesne : http://arduino.stackexchange.com/questions/12587/how-can-i-handle-the-millis-rollover

So what if it wraps around? A properly written clock program will not care about that.

without external source

You can't. The Arduino Uno has no real-time clock. A real-time clock is only something like $1 from eBay. For example the DS1307 or DS3231. I found 5 x boards pre-assembled with the clock chip, including battery holder, crystal, chip, and circuit board for $US 4.20 on eBay. Batteries not supplied.
Hook that up to the I2C pins (A4 and A5), set the time once using a suitable sketch, and then you are ready to roll.

If you just want to do something every 24 hours (not necessarily at 9:36 a.m.) then you can just use millis to find when the appropriate number of milliseconds has elapsed. The result from millis will wrap every 49 days roughly but you don't have to worry about that.
Note that this won't let you log the date and time, but you can log something (eg. the temperature) every day, you would just have to know when you started logging.

One possibility to consider is to use a 24-hour plug-in timer that controls the power to the Uno.
I.e. something that looks like this:

The circuit would be: AC outlet -> Timer -> USB charger -> Arduino
You could set the timer to turn off the power to the Uno at say 11:30 PM and turn on again on midnight.
Under such setup, millis() will be the time since the last Uno start, which will usually be the time since the previous midnight.
When debugging, you could set the time-at-Uno-start to other than midnight.
The caveats are:

Your situation allows for daily 30-minute (or whatever the timer increments are) downtime
Can tolerate timer shifts due to power outages


text:
Adding external power supply to any arduino connected component
I have an Arduino Pro Mini 3.3v and the voltage is too small for my buzzer to ring loudly. I want to add a 9v battery to power the buzzer.
This is my current circuit:
Arduino (pin 9) => Buzzer +ve
Arduino Gnd => Buzzer -ve
I want to power the buzzer using an external 9v battery but I have no idea how to implement it in the circuit. All I know is that the ground should be common.
What next?

You can use an NPN transistor for this purpose.
All you have to do is connect it this way
Obviously use a buzzer instead of the motor and pin 9 instead of 4 :D
Arduino (pin 9)==>1k-10k Resistance==>Transistor base
Buzzer +ve ==> + 9V
Buzzer -ve ==> Transistor collector
Transistor Emitter ==> battery -ve ==> Arduino GND.
So now whenever you set the pin 9 to HIGH the transistor would allow current to pass through it from collector to emitter and your buzzer would work just as you wanted.

Sounds good... I was thinking of doing something similar!

Thnx :D you can upvote if this helped you :)

Use a MOSFET. They are like little electronic switches. They will work fine with the 9V that you want to use.
Tutorial.

In this case a regular transistor will also work fine. Use an NPN transistor. The connect the 9V to +ve of the buzzer; -ve of the buzzer to the Collector of the transistor. - of the battery to both GND and the Emitter of the transistor. Connect the Base of the transistor via a resistor (e.g. 1kOhm) to an Arduino pin.

I find a MOSFET just simpler. They are more reliable for beginners.


text:
Use Raspberry and Arduino IDE to programm ESP8266
I currently use Arduino IDE to generate binaries for ESP8266. Afterwards I copy the binaries with SFTP to my Raspberry Pi and flash the binaries using esptool.py.
These are lots of steps I need to do manually. Is it possible to automate this and use the Raspberry Pi as a programmer known to the Arduino IDE?
The goal is, that the "Upload" button in Arduino IDE does the full job.

Are you running the Arduino IDE on Windows, Linux or macOS ?

IDE is running on Windows.

You could try using serial over IP ( http://playground.arduino.cc/Interfacing/SerialNet ). Alternatively add the OTA updating to the ESP so you can do away with the Pi entirely.

You could switch over to an entirely command-line workflow, and then a Makefile would suffice. You will bash/cygwin/some other *nix environment on Windows.

Thanks for your suggestions. The OTA option looks interesting.

I was able to find a solution based on this post: http://www.linuxquestions.org/questions/linux-networking-3/serial-over-lan-from-linux-to-windows-825334/#post4062960
Following steps are necessary.

Install com0com and com2tcp on the Windows machine and socat on the Raspberry.
Then add a virtual COM-pair (COM0 <-> COM25) on the Windows machine with the help of com0com.
Execute following command on the Raspberry. socat file:/dev/ttyAMA0,raw,echo=0,b115200 tcp-l:3016,fork& (adjust the device /dev/ttyAMA0, baudrate b115200 and port 3016 according your needs)
Start com2tcp on the Windows PC with following command. com2tcp --baud 115200 --ignore-dsr \\.\COM25 192.168.0.1 3016
Now you can use COM0 in Arduino IDE to flash the ESP8266 attached to /dev/ttyAMA0 on the Raspberry

Have you tried installing Python for Windows?
http://docs.python-guide.org/en/latest/starting/install/win/
In theory it should work and you should be able to run esptool.py on a Windows command line like you do on your Pi (provided that your usb to serial in recongnized by Windows).
If esptool.py fails to run under Python for Windows I would first suggest to open a ticket with the esptool maintainer and then try under a cygwin environement (https://www.cygwin.com).

I think, I forgot to mention, that I don't have a USB UART Interface on my PC. So there is no way to program over UART and without the Raspberry Pi.

Get a FTDI adapter. Here is a blog post I wrote a while ago about it : http://net-forces.blogspot.ca/2016/07/flashing-esp-01-under-osx.html?m=1