text:
Arduino Due SPI speed reduction
I need to reduce the SPI clock speed of the Arduino Due down to about 100 kHz. Unfortunately my hardware doesn't support higher speeds.
With the current maximum divider of 255, I can only reach a speed of still 320 kHz (SPI.setClockDivider(10, 255);).
Of course I could use a software SPI, but I'm still interested in using the build-in hardware. A possible solution could be to lower the overall clock speed of 84 MHz. Any idea how to achieve this?

You can try using the SPISettings interface:
SPISettings settings(100000, MSBFIRST, SPI_MODE0);

SPI.beginTransaction(settings);
... do your stuff ...
SPI.endTransaction();

Very interesting, it seemed that "setDataMode()" function didn't work correctly, just with SPISettings interface I got the correct mode. Additionally I had to slow down the CS line. The SPI speed was ok in my case. Thanks!


text:
burn arduino bootloader and compiled sketch at same time
How can I write the bootloader and sketch code to an Arduino through the ISP and then write the sketch code again using the Arduino IDE later?
Currently, I can write the bootloader through the ISP and then write the sketch through the Arduino IDE.  This works just like normal.
I can also write the bootloader and sketch through the ISP.  The code runs like normal, but I can't load a new version of the sketch through the Arduino IDE.  It just timesout.
Here's what the IDE says when it attempts to upload the program:
avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM5
         Using Programmer              : wiring
         Overriding Baud Rate          : 115200
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

The Arduino IDE creates two hex files after compiling the sketch: one is just the compiled sketch (Sketch.ino.hex) and the other is the compiled sketch with the bootloader code appended to the end (Sketch.ino.with_bootloader.hex).  So, I feel like this should be possible because Arduino produces the file for me.

There are several plausible reasons that the bootloader doesn't work when contacted by acrdude, driven by the Arduin IDE. It may be that writing a combination of compiled Sketch and bootloader using ISP does not enable the ATmega to run the bootloader in response t the IDEs 'remote' RESET. For example the combination are not linked correctly, so the bootloader is not 'connected' to the RESET interrupt. Or the bootloader is not put into the correct place. DO you know how to use objdump to check that code is at the correct address, and interrupt vectors have the right value?

Summary: IMHO In theory, anything can be written into ATmega flash over ISP.  It should be possible to write the bootloader and program at the same time over ISP. However, IMHO you'll need to post the link script, avrdude configuration and command line, program, and a link to the bootloader to get an accurate answer.

You may well be able to simply concatenate the hex files.

The Arduino IDE concatenates the files for me.  That's the file I'm uploading.  Also, I'm not using AVR dude. My sketch code is compiled by the Arduino IDE.  Everything is done by the Arduino IDE except I am loading the bootloader using the mkII AVR-ISP which connects to Atmel Studio.

I've never seen the arduino IDE do this, but I'm sure you're not mistaken (I have to look into this myself). The first thing that comes to mind, that the wrong fuses are set, so it never jumps to the bootloader. Could you add the verbose output of compiling and uploading the code with bootloader to your question? Also what version are you using?

I figured out the problem.  Turns out the Arduino wasn't being reset after loading the code so it wouldn't startup properly, leading me to believe it wasn't working.  I just had to hit the reset button and then the sketch code executed as normal.  So, you can load the bootloader and sketch code at the same time without doing anything special and it will work as if you loaded the bootloader through ISP and sketch code through Arduino IDE.

If you program via ISP, it erases the boot loader, because you do not need it. The whole point of the boot loader is to allow programming over USB. So if you want to use the normal Arduino USB input to program, burn the bootloader and then do not use the ISP.
Note my knowledge of this dates back to older arduino ~1.0 software, it is possible modifications have been made, but the above should still be true. If you have an ISP you do not need the bootloader at all.

I am programming the sketch's code and bootloader at the same time so the bootloader is not erased.  The bootloader code is definitely there.  I can read the memory through the ISP and see that the bootloader code is there.

Are you setting the programmer option back to the arduino option in the Arduino software? Stk500, is that the programmer that arduino uses by default or is that your ISP?

I am using Atmel Studio to run the AVR-ISP.  Then I connect the USB cable and use the Arduino IDE.  So I'm not changing anything in the Arduino IDE.  The Arduino IDE uses STK500.

Hmm odd, I guess I was not to helpful, hopefully someone else will have more experience with this.

Normally (using the IDE via the serial/USB interface) the bootloader is retained, and the bootloader itself replaces the main code.
If you do ICSP programming then the first thing the programmer has to do is erase the entire chip (including the bootloader). Now nothing is stopping you putting the bootloader back as part of the programming sequence (it would add to the programming time slightly).
As Chris Stratton suggests, this is basically combining the .hex file for the sketch, and the .hex file for the bootloader. I'm not sure that literally concatenating them would work because there are a couple of other "record types" in the .hex file which might confuse the programmer if they were encountered twice - in particular the "end of file" record type.
However a strategy along these lines should give you a file that could be uploaded and put the bootloader back:

Take the .hex file from the compiler, and copy up to, but excluding, the "end of file" record to a temporary file.
Append the desired bootloader .hex file (including the "end of file" line).
Program the chip with the resulting file.

For larger chips (like the Atmega2560) you would need to be cautious about handling the "extended segment address" record because that sets the high-order byte of the address to be programmed.
The hex file format, as documented in my programmer sketch is:
Line format:

  :nnaaaatt(data)ss

  Where:
  :      = a colon

  (All of below in hex format)

  nn     = length of data part
  aaaa   = address (eg. where to write data)
  tt     = transaction type
           00 = data
           01 = end of file
           02 = extended segment address (changes high-order byte of the address)
           03 = start segment address *
           04 = linear address *
           05 = start linear address *
  (data) = variable length data
  ss     = sumcheck

            * We don't use these

I belive what you want to do is program a Arduino by ISP and retain the bootloader, I have done this on occasion by first loading the bootloader onto a chip, then upload the Arduino sketch, then i use the ISP programmer to read the whole flash back into hex file.
This hex file is then used to program the rest of the chips for production. (If you feel this takes too much time, it is possible to strip the hex file down, but that might be a bit complicated)

source: Stack Exchange

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

sort: votes


text:
Buying Arduino Parts Different Manufacturers
I'm looking to buy my first arduino kit. However I have a concern.
If my Arduino Mega is bought from one manufacturer, then can I buy shields or other parts from other manufacturers? Are there any incompatibility issues
Thanks!

Of course you can. In just the same way that you can buy a car from one manufacturer and bumper stickers from another.
That's the whole point of the Arduino platform - mix and match to make things -just like LEGO®.

Awesome! Thanks for the prompt reply.
if you do not mind, are there any basic components which are necessary for any project that I can ensure are in the kit I decide to buy

That's a hard question to answer without knowing what you want to do… You might start by taking a look at some of the Arduino starter kits at Adafruit or some of the other vendors. They will give you a good idea of what you could use to get start with some general hacking and experimenting.

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


text:
Cannot control servos through 32-servo-controller on Aurduino Duamilanove
I have servo (TowerPro sg90) connected to 32 servo controller (this one) through UART interface (RX-TX, GND-GND).
Seller provide documentation how to connect and control my servos, but it isn't work.
Servo work if I connect it indirectly to Arduino. Controller indicate that it is working too (photo below - red led).
I already try different servos. Also try use provided software to control servos from pc through Mac/PC. But it's interface is unreadable for me. I tried different options but servos not responding.
Sketch code below (from sellers examples):
void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.print("#3P500T2000\r\n");
  delay(2000);
  Serial.print("#3P1500T2000\r\n");
  delay(3000);
  Serial.print("#3P2500T2000\r\n");
  delay(2000);
  Serial.print("#3P1500T2000\r\n");
  delay(2000);
}

Photo of my connections:

Sorry if it post duplicate some, but I cannot google this problem.

Just as additional information. If there is a PS2 controller attached to the board, then the serial port seems turned off.

There is one connection missing - the one that powers the servo and board.
At the moment your servo board is getting a small amount of power through the RX pin - disconnect it immediately, you are damaging it.
You need to provide +5V to the +5V terminal block, and also a suitable voltage (+5V should do) to the VCC on the terminal block.

Thank you very much. I will try and accept your answer as soon as possible. Can you provide some reference where I can read about it? Because I cannot figure it out by provided docs.

@rkyr The reference is simply that the servo and board need power (all servos and boards need power) yet you have not provided any. No docs are needed for that - it's just basic knowledge.


text:
Using 2 PING Senors at Once
I am trying to get values for two ping sensors, but am not getting any returns, can someone help me edit my code?
Code
void setup()
{
  Serial.begin(9600);
  pingRange(2);
  pingRange(3);
}

void loop(){
}

  long pingRange (int pingPin)

{
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pingPin, LOW);
  pinMode(pingPin, INPUT);
  return microsecondsToCentimeters(pulseIn(pingPin, HIGH));
}

long microsecondsToCentimeters(long microseconds)
{
  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
  // The ping travels out and back, so to find the distance of the
  // object we take half of the distance travelled.
  return microseconds / 29 / 2;
}

There's one part of your code conspicuous by its absence:
pingRange(2);
pingRange(3);

You're calling the functions, but you're not doing anything with the returned value.  I think you meant to print that value to the serial interface...
Serial.println(pingRange(2));
Serial.println(pingRange(3));


text:
Serial: What is different between Gammon's RS485 (blocking) and RS485 "non blocking" libraries?
The RS485 master-slave communication library on Nick Gammon's page http://www.gammon.com.au/Arduino/RS485_protocol.zip is working for me OK, but on the same hardware wiring is not working for the non-blocking library http://www.gammon.com.au/Arduino/RS485_non_blocking.zip.
I can not find information about the connection of MAX485 on Arduino for non-block version. Is MAX485/RS485 from HW serial (ie Rx=0 and Tx=1)?
If so, how can a slave on the same line at the same time receive from master the message "hello world" and print it to the serial monitor?
Thank you for the explanation.
When I added the SoftwareSerial library into Nick's example for non-blocking, so it works, but is it still a non-blocking?
//Master:
#include <RS485_non_blocking.h>
#include <SoftwareSerial.h>
const byte ENABLE_PIN = 4;
SoftwareSerial mySerial(2,3); //RX = 2 TX = 3

size_t fWrite (const byte what) {
  return mySerial.write (what);
}

RS485 myChannel (NULL, NULL, fWrite, 0);

void setup () {
  Serial.begin (9600);
  mySerial.begin (28800);
  myChannel.begin ();

  pinMode (ENABLE_PIN, OUTPUT);  // driver output enable
}  // end of setup

const byte msg [] = "Hello world";

void loop () {
  digitalWrite (ENABLE_PIN, HIGH);  // enable sending
  myChannel.sendMsg (msg, sizeof (msg));
  digitalWrite (ENABLE_PIN, LOW);  // disable sending
  delay (1000);
}  // end of loop

//Slave:
#include <RS485_non_blocking.h>
#include <SoftwareSerial.h>
const byte ENABLE_PIN = 4;
SoftwareSerial mySerial(2,3); //RX = 2 TX = 3

int fAvailable () {
  return mySerial.available ();
}

int fRead() {
  return mySerial.read ();
}

RS485 myChannel (fRead, fAvailable, NULL, 20);

void setup() {
  Serial.begin(9600);
  mySerial.begin(28800);
  myChannel.begin();
  pinMode (ENABLE_PIN, OUTPUT);  // driver output enable
}  // end of setup

void loop() {
  if (myChannel.update()) {
    Serial.write (myChannel.getData(), myChannel.getLength());
    Serial.println();
  }
}  // end of loop

Regards, Vava
(Sorry for my English... :-)

While tangential to your question, you should verity that the sendMsg() method blocks until the message has been fully emitted (and not merely hardware or software buffered), as if it does not your immediate disabling of the transmit enable pin after that call will truncate your message.

Reference page: http://www.gammon.com.au/forum/?id=11428

The blocking library is intended where you want to wait for incoming data, and are prepared to do nothing else while it arrives. There is also a timeout parameter which lets the code proceed if nothing happens for a specified number of milliseconds.
The non-blocking library is intended for where you need to do other things (like control motors, or read switches) at the same time you are receiving data. For that situation you call an update function periodically which assembles the incoming packet, byte-by-byte if necessary.
When the data is fully received the update returns true, and you can process the packet.

If so, how can a slave on the same line at the same time receive from master the message "hello world" and print it to the serial monitor?

As I stated above in neither case do you receive and print "at the same time", however the non-blocking one does not simply wait until all the data has arrived.

Example code from the linked page:
void loop ()
  {
  if (myChannel.update ())  // returns true when packet fully received
    {
    Serial.write (myChannel.getData (), myChannel.getLength ());
    Serial.println ();
    }

  // do other things while waiting

  }  // end of loop

If in example for non-blocking libraries is the same wiring as in the example of blocking library, where is (in non-blocking example) definition of RX(=2) and TX(=3) pins?

The hardware is the same.

there is limitation for use - only pins which supports change interrupts.

Of course. If the underlying protocol is SoftwareSerial then the usual limitations apply (that is for the Rx pin).

Thank You for the explanation. Let me have a 2 small supplementary questions - 1) If in example for non-blocking libraries is the same wiring as in the example of blocking library, where is (in non-blocking example) definition of RX(=2) and TX(=3) pins? 2) In description of SoftwareSerial (https://www.arduino.cc/en/Reference/SoftwareSerial), there is limitation for use - only pins which supports change interrupts. Is the same limitation for RS485 non-blocking library ?

See amended reply.

The hardware connection should be the same, as blocking vs non-blocking is referring to how you handle the incoming data packets.
Don't quote me on this, but generally, blocking vs non-blocking refers to the use of delay() or similar, which will block anything else from running while that function is being executed.


text:
How many LED Strips can we connect to an Arduino Uno? Is there a way to connect 1-3 meters worth without needing extra parts (relays)?
I am looking at Adafruit to purchase some LED strips for a mod for my computer case, and want to power it with an Arduino.
I am looking at the Uno, but the Mega looks good too.  I hear the Uno is good because if the chip fries, you can just replace it easier than the Mega's chip.  I did hear that the Uno chip had issues, but that was a 2013 post.
Anyways, I am essentially looking to connect about a foot of 144 leds/m to the front of my case, and connect that to the Arduino.  I will then be lining the inside of my case with about 12-15" per side (x4 sides) of 60 leds/m so I wanted to connect that to another part of the Arduino.
I read that each led takes something like 6mA or 60mA each, so that is what we should watch for.  I was trying to search for this question that others asked, but people were looking to connect a lot of strips, and needed relays and whatnot, so I wanted to make sure the Arduino itself could power about 1.5 to 2 meters of Led strips in at least 2 different strip configs (or whatever you want to call them).
I also am curious if there will be an issue programming each strip setup or, if it just is a little more work to get it setup?
Since this is a computer cause led setup, I'm not sure if I should go USB power, or a wall charger?  What is the recommended approach for something like this?
I will definitely be reading up more tutorials and all that important stuff, but I want to buy the stuff now since I realized there's a cyber Monday deal going on, so I don't want to miss out...
Any help is appreciated, thank you!

Yes, the current draw is the main factor here.  That's not really an Arduino issue though, as I will enlighten you about later on when I talk power supplies.
I assume, since you don't mention what the LEDs are, that you are talking about strips of WS2812 "NeoPixel" LEDs (the ones where you can control the colour of each and every individual LED).
I would recommend keeping all the LEDs as one single strip.  That doesn't mean you can cut the strip into segments, just join the ends to each other using wire in one chain.  That way you just have one chain to deal with in the Arduino.  Running multiple chains can be somewhat more resource hungry and I'm not even sure it's possible on an Arduino.  So keep it all as one long chain split into chunks and re-joined with wire.
Now for power.  Your computer has a big powerful power supply in it.  That gives a very good regulated 5V supply with many many amps available.  More than enough to run hundreds of LEDs.  By all means run the Arduino from USB (makes for easy programming - inspect your motherboard, it may well have an internal USB connector that would be ideal (I know mine has).  And then run the LEDs themselves off the +5V direct from the computer's power supply.  A spare hard drive power connector could be good for that.

Thanks for the information.
I'm not sure if there are different kinds, but I'm looking at these
https://www.adafruit.com/products/2328
I'm not sure if the Dotstars are needed over the Neopixels, but they aren't that much more expensive I guess....
So multiple chains aren't a good idea for this? Is there anything that can run them?
I'm just not sure if a I can connect 144 and 60 led strips together?  Also where would I add in the second power connection since ti seems after a meter things start to get dimmer?
For the psu I pull off one of the 5v+ plugs from lets say the 6 pin molex/sata

and then connect it up somewhere on the Arduino (will find out obviously).  I was hoping I could connect it directly to the MB, so that's good.
So I run the Arduino off of the usb, but I run the LEDs from a 5V+ rail?  I figured I ran the LEDs right from the Arduino?
I also read that I could connect multiple Arduinos together with something like the wifi or another shield?  Would that be a smarter approach, but Idk if I need to spend another 25$...?
Thoughts?
Thanks!

They look similar to the WS2812 but I think they are "lighter" on the MCU, so you should be able to have multiple chains. Connect the +5V direct to the LEDs +5V, the LED's ground to both the Arduino ground and the PSU ground, and the LED's data line(s) to the Arduino. Power the Arduino from USB.

Hmm so you think the dotstars will be good then ?  So I would need some sort of wire splitter or something or how do I connect all of this jazz to the Arduino?  I'm not sure what "necessary items" I need to buy....
How can I figure out if I 100% can use multiple chains or not?  I'm not sure if there is anything on ADafruit's site, or if I should check the forums or what not...
Thoughts?
Thanks!

Dotstars look good, yes. You don't need any fancy wire splitters, just some wire cutters and electrical tape will do the job. A soldering iron is probably needed too. I haven't used the Dotstars so I can't say for sure if you can do multiple chains or not - best look at the manual, libraries, examples, and see if anyone else on here has first hand experience of working with them. I'm sure someone else can chime in.

Hmm thanks.  So I just need to split the wire and it will work?  How many times can you split a wire?  Just as long as there is some mini strand that can connect from one source to another to create a current?  sorry if this is a basic electronics question.
I do have a soldering iron and electronics tape, but I figured I would resort to getting down and dirty only if need be.
I don't need multiple chains, as long as I can power the strips enough.  I realize that the strips are powered from an external source, so I guess it will work how I want it.  But a 144 led strip with a 60 led strip?

Oh and will this work for the ground connections?
https://www.adafruit.com/products/1494
these are "Splices" there is one that is a 2 in and that's it, but this 2 in, one out, seems better. I guess the 2 in is just a connection to the 2 wires, but above seems useful for ground connection.  Maybe I'll grab a few of these?
Thoughts?  Thanks!

The important thing to understand here is that there are two things going on:

Powering the LEDs – that's the big power draw and it makes a ton of sense to do that off of the computer power supply.
Controlling the LEDs – that'a a very small load, using one (NeoPixel et al.) or two (DotStar et al.) pins on the Arduino. So there is no need to do anything fancy, you should have more than enough drive in the Arduino pin(s) to handle the LED control.

You might want to take a look at the FastLED library (or head directly to the GitHub repo) it explicitly support multiple strands of LEDs (and interchangeably supports a whole slew of LED type including NeoPixels and DotStars. I think, but haven't tried, you could support multiple strands of NeoPixels by creating several instances and giving each instance its own pin.
DotStars come (if you get a "finished" end) with a connector that has all four wires (Vcc, Gnd, data, and clock) as well as two additional wires for "bulk" power. But if you don't get a finished end you would just solder to the pads that are at each cut point. You probably want to power the strip(s) in parallel – feeding them from each end so that the LEDs at the end don't see too much of a voltage drop.

Thanks for the tips, much appreciated.  I was confused thinking the power was directly from the Arduino.  I've seen peopel use the PSU itself, so I guess I just rip out one of the 5V+ and a ground from the LEDs to the Arduino and PSU?
The issue I'm having is I'm going to be using some 144 LEDs/m and some 60 LEDs/m, so I'm not sure if they are compatible, or what...?
Thoughts/
Thanks! :)

Yes, that's right – either use a spare disk drive connector or put in a wye connector to tap one. I'd be surprised if you didn't have spare. The 144 LED/m and the 60 (and 30) LED/m tapes are all compatible. For the strips that you want to run the same "program" chain their data lines together. If you want to control a strand separately, give it its own data line (on the DotStars I'm not sure if you can use a common clock with individual data lines for segments with different programs, but it seems like that might be possible.

I have a few 4 pin molex connectors from my previous build, but I noticed the pSU I'm looking at has a 6 pin molex/Sata, so I'm not sure what that's about compared to the 4 pin...
There is the 4 pin connector thing on Adafruit's site, but it's out of stock for now :(.  Would it be better to get one of those or...?
I feel like I have a lot to read up on!
I'm also hoping to turn on the Arduino when my comptuer turns on.  Not sure how difficult that is.  I'm looking at one of the Keypads, so it would be interesting to turn it on with a keycode :)!

The wires should be color coded, one of the easier things to do would be to cut off the Molex connector and go directly to the strip (or just pick a connector that you can easily get (like spade or bullet quick connects). If you power the Arduino via USB from the computer it will power up with the computer.

Yeah, I believe red is 5V+?  I'm not sure I follow what you mean by "cutting off the molex connector" do you mean just taking out the red wire or..?
I'll look up the quick connects though.
I could power the Arduino from the wall and then have the computer be turned on from the Arduino right?
Thanks!

I just meant that you don't have to use the Molex if it is hard to find a matching connector, you could pull the wire out or just cut off the connector and treat it as a bare wire. I'd be tempted to handle power the other way around. Power the Arduino from a USB port on the computer (or from the power supply) otherwise you'll need to figure out how to control the power supply and how to integrate that into the Arduino system.

I guess I'll have to see howi t works when I check out some tutorials, it's hard to envision now, but I'll get it.
Well, I see the power can be powered by a wall charger, so I figured if I powered the Arduino with that, and then could power the computer from the ARduino, I would like that :).
Also, I wanted to know if a breadboard is needed to run all of this stuff, or if we had additional things?  Not sure if there is a way around it.
Also I think we need these breadboard wires, right? https://www.adafruit.com/categories/306
I'm assuming I only need male/male?
Thoughts?  Thanks alot! :)

The other answers you have here cover the points well, just to offer my $0.02.
Using a wall adapter
It's really not necessary to use a separate wall adapter and you'd be adding another layer of complexity unnecessarily. So don't bother. Also with a wall adapter you would have to consider grounding it to the computer's power supply, not necessarily an issue, but not required if you use internal power.
Powering your LEDs
your computers power supply is more than capable of handling EVERYTHING you've mentioned (unless you're already maxing it out, which I doubt).
Just make sure that you're powering the LEDs directly from the computer's power supply, and not from the (arduino) board itself, since that 5v is limited to 500mA from the USB connector, and definitely don't drive the main power from a data pin (I'm sure you know that—but just in case :P)
If you do split the strip (running two strips shouldn't be a problem) be sure to provide power where ever you can, ie each end, even in the middle. It will aid in providing even power throughout the strip.
Powering the Arduino
I'd be running the Arduino off it as well, either grab a header cable off the board that has an end you could plug into your arduino and mount it inside, or feed a USB cable through the back and use one of the extra external USB ports. A bonus of running it outside would be you could physically reset the board by unplugging it :) or simply turning it off by doing the same.


text:
Using digital pin 11 for DMDCon and IR remote
I have a project where I would like to control a countdown clock using a remote with:
Arduino Uno R3 Development Board
Funduino Uno Protoshield Board
Freetronics Dot Matrix Display Connector
Arduino IR Reciever
Both the DMDCon and the IR use digital pin 11. Can these two share the pin 11 or is there a workaround of sorts?

The workaround would be to configure the https://github.com/shirriff/Arduino-IRremote library referenced in your question to any available digital input.

Great Thanks For Your Help! I'll give it a try.

@Kerl Not all pins might be supported, see the documentation about supported pins.


text:
Sparkfun MicroSD shield cannot open log file
I'm currently trying to log data from a GPS shield onto a microSD card using a Sparkfun microSD shield. All my code will compile, but when I open the serial monitor the microSD will initialize, but then the log file itself won't be able to be opened. I have formatted the card and reset all the shields and the Arduino itself multiple times, but nothing seems to work.
When I upload the example sketch used to show the functionality of the data logging, provided in the SD.h library by Sparkfun, everything will function properly and it will be able to open the file correctly. I used this file to give me information on how to format my code, so it is very similar.
One thing that I think may be causing the issue is the size of my code. When uploaded, the code uses 80% of total memory and 84% of dynamic. I tried commenting out a lot of the code to see if more free memory would give a different result, but still got the same error.
Any help would be awesome, and thank you in advance! I've included my code below.
// Include FONA, Watchdog, SD card and declare pins
#include "SoftwareSerial.h"
#include "Adafruit_FONA.h"
#include "Adafruit_SleepyDog.h"
#include "SPI.h"
#include "SD.h"

#define FONA_RX 2 //Reset pin
#define FONA_TX 3 //FONA serial TX pin
#define FONA_RST 4 //FONA serial RX pin

//Include software serial
SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
SoftwareSerial *fonaSerial = &fonaSS;

Adafruit_FONA fona = Adafruit_FONA(FONA_RST);

const int chipSelect = 8;

File dataFile = SD.open("data.log", FILE_WRITE);

//Set strings to hold all the data
  String Lat = "";
  String Long = "";
  String KPH = "";
  String Head = "";
  String Alt = "";

  float latitude, longitude, speed_kph, heading, altitude;

//Set integers for the data
  int GPSlat = latitude;
  int GPSlong = longitude;
  int GPSkph = speed_kph;
  int GPShead = heading;
  int GPSalt = altitude;

//Set counter and phone number for location messaging
  int Log_Counter = 0;

// Halt function called when an error occurs.  Will print an error and stop execution while
// doing a fast blink of the LED.  If the watchdog is enabled it will reset after 10 seconds.
//void halt(const __FlashStringHelper *error) {
//  Serial.println(error);
//}

//uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout = 0); //

//uint8_t type; //

void setup() {
  while (!Serial);

  //Initialize serial output
  Serial.begin(115200);
  Serial.println(F("Team Space Bread GPS - Zero-G-luten"));

  //Initialize SD card, then check if card is present
  Serial.print(F("Initializing SD card..."));
  pinMode(SS, OUTPUT);
  digitalWrite(SS, HIGH);
  if (!SD.begin(chipSelect)) {
    Serial.println(F("Card failed or is not present"));
    while (1);
  }
  Serial.println("Card initialized");

  //Open file to log data to
  if (! dataFile) {
    Serial.println(F("Error opening log file"));
    while (1);
  }

  //Initialize FONA module
  Serial.println(F("Initializing FONA.... (may take a couple seconds)"));
  fonaSerial->begin(4800);
  if (!fona.begin(*fonaSerial)) {
  // halt(F("Couldn't find FONA"));
  }
  fonaSS.println("AT+CMEE=2");
  Serial.println(F("FONA is functioning swimmingly"));

  //Enable watchdog timer; if code hangs and will not connect to GPS, WDT will run out after 10 seconds
  //and reset the code
  Watchdog.enable(10000);
  Watchdog.reset();

  //Wait for FONA to connect to cell network
  Serial.println(F("Checking for network..."));
  while (fona.getNetworkStatus() != 1) {
   delay(500);
  }

  //Enable GPS
  Watchdog.reset();
  Serial.println(F("Enabling GPS"));
  fona.enableGPS(true);
  delay(2000);
  Watchdog.reset();
  if (!fona.enableGPS(true)) {
  // halt(F("Failed to turn GPS on, resetting..."));
  }
  Serial.println(F("GPS connection successful"));

  // Start the GPRS data connection.
  Watchdog.reset();
  Serial.println(F("Enabling GPRS"));
  fona.enableGPRS(true);
  delay(2000);
  Watchdog.reset();
  if (!fona.enableGPRS(true)) {
  //  halt(F("Failed to turn GPRS on, resetting..."));
  }
  Serial.println(F("Connected to cellular"));

  //Wait a bit for connection to stabilize
  Watchdog.reset();
  delay(5000);

}

void loop() {
//Reset Watchdog at start of loop - everything must work in less than 10 seconds!
 Watchdog.reset();

// Grab a GPS reading.

  bool gpsFix = fona.getGPS(&latitude, &longitude, &speed_kph, &heading, &altitude);

//Define strings as data intergers
  Lat += String(GPSlat);
  Long += String(GPSlong);
  KPH += String(GPSkph);
  Head += String(GPShead);
  Alt += String(GPSalt);
//Print all data onto SD card
  dataFile.print("GPS lat: ");
  dataFile.println(Lat);
  dataFile.print("GPS long: ");
  dataFile.println(Long);
  dataFile.print("GPS speed KPH: ");
  dataFile.println(KPH);
  dataFile.print("GPS heading: ");
  dataFile.println(Head);
  dataFile.print("GPS altitude: ");
  dataFile.println(Alt);
  dataFile.print(" ");

//Flush file to save data onto card
  dataFile.flush();

//Every loop, add 1 to Log_Counter. When Log_Counter==180 (every 15 minutes), send SMS to number with location
  Log_Counter++;
  if (Log_Counter==180) {
//There has to be a more elegant way to do this, but ¯\_(ツ)_/¯

//Buffer for location and phone number
  char LocationBuffer[48];
//  char SendTo[16];

//Make latitude and longitude into one string
  String(Location) = Lat+=Long+=Alt ;

//Set phone number to text to
//  String(PhoneNumber) = "18143803250";
                       //^^^^This^^^^ is where you put the number to send the location to every 15 minutes

//Location string to char that will be able to send
  Location.toCharArray(LocationBuffer, sizeof(LocationBuffer));

////Set phone number to char
//  PhoneNumber.toCharArray(SendTo, sizeof(SendTo));

//Send SMS w/ location
fona.sendSMS("18143803250", LocationBuffer);
}

//Take mesaurement every 5 seconds
  delay(5000);
}


text:
XBEE S1 Wireless Connection
I have 2 Xbee S1 models, 2 Arduino Wireless Proto Shields, 2 Arduino Megas, and an Xbee Explorer and am trying to make one Arduino Trigger another Arduino to send a pulse, I have tried to set up many tutorials on youtube and digi, but still cannot get it to work.
Can someone walk me through the steps for setup?


text:
Looking at Adafruit's website I'm confused which wallcharger I should get
As the title says there are many different wall chargers to choose from.
12v, 9v, 5v, with different mA amounts...
The starter kit on Adafruit's website mentions to get the 9V 1000mA switching power adapter, so I'm curious if that's what we should get?
here is the link to all of them.
There are regular wall adapters, and these big power supplies...
http://www.adafruit.com/search?q=switching+power+adapter&b=1
I'm just looking to run some LED Strip lights from the arduino and power some joystick buttons, some rotary encoder/knobs, and a keypad to work the LED lights
Thoughts?
Thanks!

This website looks like a pretty official answer for you.
http://playground.arduino.cc/Learning/WhatAdapter

Since you'll probably be connecting other things to the Arduino (LEDs, LCDs, servos) you should get an adapter that can supply at least 500mA, or even 1000 mA (1 ampère). That way you can be sure you have enough juice to make each component of the circuit function reliably.

And

The Arduino's on-board regulator can actually handle up to 20V or more, so you can actually use an adapter that puts out 20V DC. The reasons you don't want to do that are twofold: you'll lose most of that voltage in heat, which is terribly inefficient. Secondly, the nice 9V pin on the Arduino board will actually be putting out 20V or so, which could lead to potential disaster when you connect something expensive to what you thought was the 9V pin. Our advice is to stick with the 9V or 12V DC adapter.

Thank you very much :).
I guess I also could just plug it directly into this computer via USB?  I was thinkign that my new build would be done afterwards, but forgot about this comptuer :P
Thanks!

Your Arduino Uno will use 35 to 50 mA at 5V.  The  “joystick buttons, some rotary encoder/knobs, and a keypad” will draw a small amount of current, probably between 1 and 10 mA.  Thus, power for the Uno and your controls will be well under 100 mA and can be supplied via USB without any problem.  (Also see: How to get more than 100mA from a USB port.)
If your Uno enumerates and negotiates to get 500 mA via USB, you might have 450 mA available out of the +5V pin.  However, in some cases if you need more than a few dozen mA to power other devices, it will make sense to get a separate 5V supply for them.  (Eg, if the devices drag down the +5V and cause the Uno to reset, or if the devices are electrically noisy, like motors, RC servos, relays, solenoids.)  Also, note that thread #70450 at forum.arduino.cc says you can draw 650 mA (or 3.25 W of power) when the Uno is powered via its DC power jack.
If your LED string has up to 6 or 7 WS2812B equivalents, you can power it from the Uno's 5V.  Here is the all-lights-on, full-brightness calculation for six of them:  6 WS2812Bs x 3 LEDs per WS8211 x 21 mA per LED = 378 mA.  For seven:  7 x 3 x 21 mA = 441 mA, which is out there on the edge.
For longer LED strings, figure on a little over 3 W of power for every 10 WS2812B equivalents.  (Calculation: 5 volts x 10  WS2812Bs x 3 LEDs per WS2812B x 21 max mA per LED = 3150 mW = 3.15 W.)  For example, get a 10 W (2 A x 5 V) or greater 5V power supply for a meter of 30- WS2812B-per-meter LED strip, etc.  This power supply will connect directly to the LED strip's power connectors.  The ground from the LED strip will connect to the Uno's ground, to establish a signal reference point.
Note, the absolute max voltage rating for a WS2812B, according to its datasheet, is 5.3 V, so use a supply whose voltage does not exceed 5.3 V.  The absolute min voltage rating is 3.5 V; they will work ok on 3.7 V LIPO batteries, but 3V3 power is out of spec for a WS2812B.
As mentioned in a previous question, if your LED strip is being installed inside a desktop PC, the PC's power supply will have lots of 5 V power available, and you can hook on to one of the red +5V wires and black Gnd wires from its supply to power the LEDs, either while powering the Uno itself from USB power or while using the same +5V to power the Uno as the LEDs.


text:
Is my Arduino Uno broken?
I think I broke my Arduino Uno as I was playing with it. I connected an ultrasonic range finder to it and uploaded a sketch to it. It was working fine until I accidentally touched the ICSP headers for the USB interface (the pins near the USB port). Now,everything is still working but my computer cannot detect it and it does not show up in the device manager or the IDE. Please tell me if it is broken and how to fix it.
BTW, I just bought it and just started using it after another Arduino had the same problem.

What have you tried? At the very least I'd try unplugging the Arduino and rebooting the computer (or in some way forcing a reset on the USB). The Uno may be particularly sensitive, but I've not seen a problem like this with any of my Arduino (and clone) boards. Do you live someplace where static electricity is a problem (I don't).

touching the ISP header or port should not have caused damage. Can your PC detect other usb devices on the same port?

Get down to just the bare Arduino board, disconnect everything, and see what you get..  the Ultrasonic sensor could easily be pulling more power than your USB can supply, only about 500mA.

I have tried deleting the arduino software and downloading it again, I also unplugged the arduino and rebooted my PC but it. I also tried installing older versions of the IDE but it still did not work. My PC cannot detect any other USB devices on the same port. I tried disconnecting everything but it still does not work.

Try other USB port and another computer. If you wish you could try and reprogram the 16u2. If it does not respond it's dead but you can always either replace it or use the Arduino for things that do not require serial.

It did not work. I just bought an arduino mega instead.

Please tell me if it is broken and how to fix it.

See Have I bricked my Arduino Uno? Problems with uploading to board
Those tips may also help with fixing problems with your Mega (if you ever have them). ;)


text:
How can I connect the MP503 to an Arduino Uno (Smoke, Alcohol Sensor)?
I don't know how I can connect an MP503 sensor to my Arduino.
Please help.

http://eleparts.co.kr/data/design/product_file/SENSOR/gas/MP503%20(Ver1.4)%20-%20Manual.pdf

link is broken, use this one: http://eleparts.co.kr/data/design/product_file/SENSOR/gas/MP503%20(Ver1.4)%20-%20Manual.pdf

you really do need to include more information: is it a raw component, part of a circuit, on a shield? What have you tried? Are you looking for how to connect to it electrically or programatically (or both)?

@frarugi87 - Your link appears to be broken as well... both links give 403 Forbidden :-( However, this one seems to work: http://eleparts.co.kr/data/design/product_file/SENSOR/gas/ZP01-MP503%20Air%20Quality%20Module%20V1.4.pdf

Ok, first of all I doubt you will be able to get a lot of measurements with that. Because... I know that kind of sensors and you will quickly get tired of it.
Anyway, you have to connect

pin 1 to +5V
pin 2 to ground
pin 3 to +5V
pin 4 to a resistor towards ground. Value has to be determined.

To chose the value, you have to try. Change resistor values until, in fresh air, the voltage you can sense across the resistor is approx 1V. I think it is arount 10k, but you'll have to try
Chosen the resistor, you have to simply attach the node between pin 4 and the resistor to an analog input and then read the voltage.
Now you have to calibrate the sensor. Put it in a fixed-concentration gas and measure the voltage: nCalib = analogRead(sensorPin);.
Then, when you need to measure the concentration, you just have to read the voltage again with nMeas = analogRead(sensorPin);. The factor Rs/Ro can be calculated with the formula
Rs_over_Ro = nCalib / (1024 - nCalib) * (1024 - nMeas) / nMeas;

Once you have the factor, look at the graph in figure 3 to get the concentration:

As I told you, I think you will quickly get tired of it, but this is how to use it.


text:
Leostick Receiving message from Uno using USB jumpers cables
I have a Arduino Uno which is looping over Serial.println("$testmessage"). Connected to this is a USB cable that i have cut and soldered male jumper leads to . I need to receive this message ("$testmessage") from the Uno using this USB cable without using the leosticks usb connector. After receiving the correct messgae from the Uno i plan to use Serial to send data from the leostick to my pc.
I'm stuck trying to figure out how to receive this message from the Uno.
Currently the the USB 5v and ground is connected to the leosticks 5V, GND pins. The Uno powers on and the the tx led is flashing every 100 milliseconds.
Can i just plug the green and white wires from the USB cable into D0&D1 and except it to work?
(Uno plugs into usb cable in the image)
https://i.stack.imgur.com/M0kbb.jpg

While USB is a serial protocol, it's a completely different serial protocol than the RS-232-style logic-level serial protocol that the Serial library supports.  So the approach mentioned in the question has no logical chance of working.
Also, the USB electrical signal is differential (double-ended, or line-to-line, rather than single-ended, or line-to-ground).  So the mentioned approach has no electrical chance of working.
What may work is to wire from Tx on the Uno to Rxd1 on the Leostick, and from Rx to Txd1, unless that conflicts with the Leostick's USB-Serial link.

I don't think this has any chance of working. You can't use USB to interface between the two devices, as the Leostick can't work as USB host. Your best bet is to use (software) serial.


text:
Newbie and string of 300 WS2811s
I’m trying to make a string of 300 Christmas tree lights where the colour of each of the lights is entirely controllable by my own code. I am a programmer so that side of things is the easy part as far as I’m concerned.
My researches so far have led me (no pun intended) to WS2811s driven by an Arduino. I prefer the look of these to the flat Adafruit-type ones. I don’t own an Arduino yet but have been dipping my toe into this site for quite a while now so am beginning to understand the basics.
I’ve established that I will need to have a fairly hefty 5volt power supply for the LEDs but that the Arduino itself can then run happily on its own USB supply.
Some of the things I’ve read seem to imply that the Arduino will struggle to process my program and supply the data to 300 LEDs at the same time, but it’s not clear what the problem will be. I assume each LED will continue to glow with the same colour until it receives the data for its next colour and the code for “Fire!” which then prompts all of them to switch to their next colour. Is this wrong?
I realise that 3 bytes per LED for 300 LEDs is a fair amount of data to keep having to send up the wire. I will also be having an array in the program to keep track of all 300 colour values.
Will this work? Can you offer any advice that might mean I don’t hit a brick wall somewhere when putting all this together?

You don't need a full Arduino. You can use either a bare AVR chip or breakout or a small Arduino-like for this.

@IgnacioVazquez-Abrams AVR is a new term I've never heard of, can you link to somewhere I can read-up please? What would be the advantage over Arduino, just cost and physical size?

http://stackoverflow.com/questions/1447502/whats-the-difference-relationship-between-avr-and-arduino

Make sure to provide power to the string at multiple locations. With the amount of current 300 leds use, the small resistance in the wires can create a big enough voltage drop for the leds at the end to be dimmer or malfunction.

@IgnacioVazquez-Abrams Thanks, I think the native AVR may be a bit out of my comfort-zone. I'll get the thing working with an Arduino and move on to the big-boy stuff if I get bitten by the bug! I don't get a lot of time to play with things like this - I really just want some Christmas lights that are better than can buy in the shops! I know I can code a better version and just need the hardware to work.

@Gerben Thank you, this is exactly the sort of information I didn't want to find out the hard way. Do you think it would be adequate to just supply the power at both ends? That's quite common on Christmas lights from my experience.

It depends on the wire-gauge, and total wire length. But on second thought you will probably be okay. It's more of an issue in led strips, with only thin copper traces carrying all the current. Wires have a lot bigger cross-section area. But providing power at both end would be a good idea. By the way, a lot of boards, and strips, have decoupling capacitors sprinkled around. I think that would be more important that power.

@Gerben of course, with 300 of them I have to provide up to 18 amps at 5 volts (300*0.06) so thàt will mean a hefty power supply. I'm not familiar with the concept of decoupling capacitors, can you explain please?

The leds are dimmed using PWM. So constantly alternating between using power, and not using power. This creates small power fluctuations  called noise on the power line. If there is enough noise, the chip on the WS2812 will malfunction. The capacitors act like little local reservoirs of power, keeping the power supplied more constant (/less noisy).

I don't think you'll have any problems. The LED's have a data rate of 800kbps, so you can theoretically push out 110 frames per second if your Arduino does nothing but transmit data. If you keep the routine that updates the colors fairly efficient then you'll have nothing to worry about.
Note that the array storing the colors would take up 900 bytes of memory, leaving you with only 1100 bytes for everything else your program would need to store (which should be fine).

Thanks Tom. I didn't realise that there is only 2K of memory on board, I'm sure I will be able to work with that though. I saw a video where this guy says something like "The Arduino will struggle to provide data fast enough", so I was a bit concerned about the speed.

@Lefty of course speed is a concern, but... Since the application requires low resources (you will not make really complex animations, will you?) you won't have issues. Just don't waste too much time in useless things, don't use delays and try to use 8-bit variables.. And avoid mallocs or variable size buffers

No complex animations - just colour fades of individual LEDs which will be fairly sedate. In a way, what I want is to be able to just send data for ONE LED at a time but I realise that there is no actual address for each LED, just this clever bit-shifting thing where each one steals the first 3 bytes and passes the rest on. I take it Delay uses an internal loop to waste cycles? What about the LEDs? Will they maintain the same colour until the next refresh signal?

Yes, they maintain their states.

Excellent, thank you. Unless anyone else gives an answer that concerns me, I think I will invest in the equipment and hopefully get this all working. Is it worth me buying a particular type of Arduino that may be faster just to be sure?

@Lefty: The Arduino will struggle if you restrict yourself to Arduino operations. Using low-level AVR operations (or using a library that does so) will let it keep up handily.

Specifically, FastLED is a good library.

Thank you both, I will look into all this before I start the project. Maybe I'll get it working with just 50 LEDs initially and expand slowly until it hits any problems. Would it be viable to write the program in C initially and then gradually replace the process-heavy parts with low-level code where I need to? Remember that this is all new to me so I have a lot of learning to do!

Using FastLED to get started would help a lot. I don't think you'd need much optimization besides that.

If you only want one led to change at a time, you could choose to make e.g. 5 separate strings of leds. That way you only need to send 1/5th the amount of data per "frame".

@Gerben Amazingly, you have hit upon exactly the idea that I want to do - just change every 5th LED in each change cycle while the others are static. But I really want to keep the number of wires down to a minimum so I don't want to have an extra 4 wires. I also want them to be in one long string. I figured that I could create my "one in 5" idea in software whilst keeping the hardware configured for different future options if I want to change the pattern.


text:
Too many Bytes Using Ultrasonic Sensors
I need to send one transmission and record multiple distances with 4 receivers, but everytime I use more than 2 receivers, the serial data does not print. What can I do?
P.S. I'm using 5 SRF-02 Sensors, 1 transmitter and 4 receivers all via I2C.
#include <Wire.h>

#define cmdByte 0x00                                 // Command byte
#define rangeByte 0x02                             // Byte for start of ranging data

byte highByte = 0x00;                                // Stores high byte from ranging
byte lowByte = 0x00;                                // Stored low byte from ranging
int range = 0;
int rangeData;

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

void loop() {
   D0_1= getRange(0x70, 0x71);
   Serial.println(D0_1);
   D0_2= getRange(0x70, 0x72);
   Serial.println(D0_2);
   D0_3= getRange(0x70, 0x73);
   Serial.println(D0_3);
   D0_4= getRange(0x70, 0x74);
   Serial.println(D0_4);
}

 int getRange (uint8_t send_address, uint8_t rec_address)
 {
  Wire.beginTransmission(rec_address);
  Wire.write((uint8_t)cmdByte);
  Wire.write((uint8_t)0x56);
  Wire.endTransmission();

  Wire.beginTransmission(send_address);             // Start communticating with SRF02
  Wire.write((uint8_t)cmdByte);                         // Send Command Byte
  Wire.write((uint8_t)0x5C);        // Transmit an 8 cycle 40khz burst - no ranging takes place
  Wire.endTransmission();

  delay(80);                                                           // Wait for ranging to be complete

  Wire.beginTransmission(rec_address);       // start communicating with SRFmodule
  Wire.write((uint8_t)rangeByte);                 // Call the register for start of ranging data
  Wire.endTransmission();

  Wire.requestFrom(rec_address, 2);            // Request 2 bytes from SRF module

  while(Wire.available() < 2);                    // Wait for data to arrive
  highByte = Wire.read();                           // Get high byte
  lowByte = Wire.read();                           // Get low byte

  range = (highByte << 8 ) + lowByte;              // Put them together

 delay(120);

 return(range);                                                    // Returns Range
 }

My magic crystal ball tells me that.... You didn't even say what ultrasonic sensor you are using!

Whoops, my apologies, I'm using SRF-02 sensors.

Now it's easier ;) Did you check the addresses on the bus? Check also the LEDS (see here for the led coding). And... Can you timeout when the I2C does not reply? Check with the main library or try to use a software one which does timeout...

the LEDS don't blink if I try to use more than 3 receivers.

@Umbus your code doesn't compile. Missing declarations of D0_x variables. Also did you changed the addresses of 4 sensors to 0xE2, 0xE4, 0xE6, 0xE8 and tested every single one alone? Did they respond correctly?

If the leds blink when you put 2 of them and don't if you put 3, then the prblem is 1) the power supply or 2) the pullups on the I2C. You put only two resistors (one on SCL and one on SDA) right?

i dont use resistors

@Personagem it compiles on my computer with a slight error and will run, and all the sensors have the right address, I've checked the blinking lights


text:
Arduino is freezing after 10-15 minutes
I am having a problem with my Arduino freezing after a small amount of time. I'm using an RTC DS1307 breakout to keep track of the time and display the time on an LCD. It displays hours, minutes and seconds (updated every second).
Then I have 25V which is supplied by a transformer and connected to a set of LEDs through a CAT4101 constant-current sink LED driver. The Arduino board is powered by a 2amp USB transformer.
At a set time, the timer should set off the process to dim the lights.
Everything is working well if I set the lights to dim within a few minutes. However, if I leave the board on for more than 10-15 minutes then everything seems to freeze (i.e. the time on the LCD stops being updated and stays stuck at the moment it froze).
I originally thought it could have been something to do with my code. But I then skimmed everything down to the bare essential and just uploaded the code necessary to update the time on the LCD. And even in this case it freezes.
The only way I managed to avoid things freezing was to disconnect the CAT4101 pin 1 from Arduino's PWM and disconnect pin 2 from Arduino's 5V.
What could be causing this issue?
CAT4101
pin 1 = connected to Arduino PWM
pin 2 = connected to +5v
pin 3 = connected to ground
pin 4 = connected to ground with 2kOhm resistor
pin 5 = connected to LED cathode

UPDATE
Code below (I have stripped down the code by removing any additional functions and leaving only the bare code which is leading the application to crash).

#include <Wire.h>
#include <RTClib.h>
#include <LiquidCrystal.h>

RTC_DS1307 rtc;
DateTime now;
LiquidCrystal lcd(7, 8, 9, 10, 11 , 12);

void setup() {
  Wire.begin();
  rtc.begin();
  lcd.begin(16,2);

 if (!rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(__DATE__, __TIME__)); // time = hh:mm:ss format, e.g. 06:01:01
  }

  lcd.clear();
}

void loop() {
  now = rtc.now();
  updateDisplay();
}

void updateDisplay(){
 int h = now.hour(); // Get the hours right now and store them in an integer called h
 int m = now.minute(); // Get the minutes right now and store them in an integer called m
 int s = now.second(); // Get the seconds right now and store them in an integer called s

 lcd.setCursor(0, 0); // Set the cursor at the column zero, upper row...
 lcd.print(" The time is: "); // ...with spaces to clear characters from setting alarm.
 lcd.setCursor(4, 1); // Move the cursor to column four, lower row
 if (h<10){   // Add a zero, if necessary, as above
  lcd.print(0);
 }
 lcd.print(h);   // Display the current hour
 lcd.setCursor(6, 1); // Move to the next column
 lcd.print(":");  // And print the colon
 lcd.setCursor(7, 1); // Move to the next column
 if (m<10){   // Add a zero, if necessary, as above
  lcd.print(0);
 }
 lcd.print(m);   // Display the current minute
 lcd.setCursor(9, 1); // Move to the next column
 lcd.print(":");  // And print the colon
 lcd.setCursor(10, 1); // Move to the next column
 if (s<10){   // Add a zero, if necessary, as above
  lcd.print(0);
 }
 lcd.print(s);   // Display the current second
}

In my opinion it is a small bug in the code. I can start saying random line numbers or.. You can put the CODE!!!

@Martin have you tried powered the CAT4101 with external source and not arduino? Try that and also place a capacitor in Vin as present in schematics of datasheet

Yes, code please, and LCD model number.

Does it still crash when running the blink sample code? If not, the problem must be in the code somewhere.

you are right guys, it's something in the code as the same setup still works with the simple "blink" sample code.
I have updated the post with my scaled down code, keeping just the core part which is still causing the system to crash.

Personally I'd avoid running it without delays. Just put a 50-100 ms delay between runs, or use the millis() function if you want to avoid the rest of the program to stop. Then I'd update just the fields on the LCD that I need, not all of them every time. So compare the h, m and s variables to the one you stored in memory and update them only if they differ. This will reduce the traffic on the lcd lines and reduce the possibility of a malfunction. And please, h, m and s will never be greater than 255, so PLEASE use byte, not int

Can you confirm that the problem still occurs with the CAT4101 not only excluded from the code, but disconnected from the circuit too? So you just have the LCD and the RTC module connected to the Arduino. Try the following, one at a time: [1] power it directly via USB, rather than by the 2A transformer [2] Ditch the RTC and have the LCD just update arbitrary numbers [3] Disconnect LCD and connect the RTC. After each rtc.now(), test if now.second() is the same as the previous call - if not then toggle the LED. If the LED stops blinking the program has frozen.

There is a problem with the library or the combination of the library and the Arduino system code. I have been running many tests now with only 1 line of text. After a few hours, I experience the same problem with a (20x4) display. I use different Arduino Mega's and displays so a defect in my hardware can be excluded. I also use 2 different power supplies 1 Is a lab supply hence the power supply can also be excluded. Using delay or millis() to slow down the refresh rated does not solve the problem (or may be part of it). If i find the solution i will post it here.

I would add a delay(100); to the bottom of your loop()
I'm betting even odds that solves it.

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


text:
I2C connection with MT9D111 camera module, strange results after writing registers via i2C
I am currently working on a camera platform based on the MT9D111 module from Micron. The first thing to do is to write the configuration to the numerous registers of the chip which is done via an i2C connection.
I adapted the code from here for testing this with an Arduino Uno. 3.3V supply and 8MHz clock are also provided by the Arduino.
Everything seems to work fine, but there are some odds which I don't know the reason for.
So here is the code (I just added the soft reset sequence according to the Developers Guide):
const int freqOutputPin = 9;   // OC1A output pin for ATmega328 boards

#define TMR1 0

#include <Wire.h>
#include <avr/io.h>
#include <util/delay.h>
//#include <TimerOne.h>
#include <avr/interrupt.h>

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

  TCCR1B |= (1 << CS10);  //selecting prescaler 0b001 (Tclk/1)
  TCCR1B &= ~((1 << CS12) | (1 << CS11)); // turn off CS12 and CS11 bits
  TCCR1A |= ((1 << WGM11) | (1 << WGM10)); //Configure timer 1 for TOP mode (with TOP = OCR1A)
  TCCR1B |= ((1 << WGM13) | (1 << WGM12));
  TCCR1A |= (1 << COM1A0); // Enable timer 1 Compare Output channel A in toggle mode
  TCCR1A &= ~(1 << COM1A1);
  TCNT1 = 0;
  OCR1A = TMR1;

  delay(500);  //Initial delay
  Wire.begin(); // join i2c bus as master
  Serial.begin(9600);
  Serial.println("MT9D111 Camera Module + Arduino");
  Serial.println("Read and Write 16-bit register value example");
  Serial.println("*  Read expected value = 0x1519 from Register 0x00");
  Serial.println("*  Write value = 0xA5F0 to Register 0x20:1");
  Serial.println();
  init1(); //execute code just 1 time
}

void loop() {
}

void init1() {
  int16_t a;

  delay(500);  //wait until start
  Serial.print("Soft reset first");
  Serial.println();
  soft_reset();//do a soft reset at startup

 //***************Configuration here!****************//
  Serial.print("Read result from register 0x00");
  a = read_reg(0);
  Serial.println();
  Serial.print("0x");
  Serial.println(a, HEX);  //print result
  Serial.println();
  Serial.print("Read original data from register 0x0a, should be 11");
  Serial.println();
  a = read_reg(10);
  Serial.print("0x");
  Serial.println(a, HEX);  //print result
  Serial.println();

  //Enable this part for writing register
  //Some example reads and writes follow
  Serial.print("Writing 0xA5F0 in register 0x20:1");
  Serial.println();
  write_reg(32, 1, 165, 240);
  Serial.print("Read new value from register 0x20:1");
  Serial.println();
  a = read_reg(32);
  Serial.print("0x");
  Serial.println(a, HEX);  //print result
  Serial.println();
  Serial.print("Writing 0xA1F3 in register 0x20:1");
  Serial.println();
  write_reg(32, 1, 161, 243);
  Serial.print("Read new value from register 0x20:1");
  Serial.println();
  a = read_reg(32);
  Serial.print("0x");
  Serial.println(a, HEX);  //print result
  Serial.println();
}

//Write 2Byte register
void write_reg(int reg_address, int page, int data_msb, int data_lsb) {
  delay(5);  //5ms
  Wire.beginTransmission(93); // transmit to device 93, Camera Module
  Wire.write(240);   //page register address
  Wire.write(0);
  Wire.write(page);   //select page 0/1/2
  Wire.endTransmission(1);    // stop transmitting
  Wire.beginTransmission(93); // transmit to device 93, Camera Module
  Wire.write(reg_address);   //register address 8bit, decimal
  Wire.write(data_msb);  //msbyte
  Wire.write(data_lsb);  //lsbyte
  Wire.endTransmission(1);    // stop transmitting
}

//read 2Byte register
//be careful about selected register page
int16_t read_reg(int reg_address) {
  int16_t err;
  delay(5);  //5ms
  Wire.beginTransmission(93); // transmit to device 93, Camera Module
  Wire.write(reg_address);   //register address 8bit, decimal
  err = Wire.endTransmission(1);    // stop transmitting
  Serial.println(err);
  Wire.requestFrom(93, 2, 1); //request value form device 93, 2 bytes with stop bit
  int16_t result = ((Wire.read() << 8) | Wire.read());  //read 16 bits
  return result;
}

//Perform Soft reset, required at startup
void soft_reset(){
  write_reg(101, 0, 160, 0);//write registers according to dev guide
  write_reg(195, 1, 5, 1);
  write_reg(13, 0, 0, 33);
  delay(5);
  write_reg(13, 0, 0, 0);
  delay(5);//wait for i2c to be ready again
}

Running this code gives me the following result on the serial monitor:

So here are the questions:

Do you have any ideas why I get an extra FFFF when reading a register after writing it? (underlined in blue)
Why are there some extra zeros in the output? (marked in yellow)

How did you get this to work. I tried the same code with OV2640 but I always get error as 2 and value read as 0xFFFF. Please help me.

Would you still happen to have the MT9D111 Dev Guide? I can't seem to find it online.

Found it here: https://files.niemo.de/aptina_pdfs/MT9D111_Dev_Guide.book.pdf

The 0 comes from your code:
Serial.println(err);

It's printing the error code. 0, hence no error.
As for the extra FFFF I'd say it's because you are using signed integers. Change your a declaration to uint16_t and see if that fixes it.

Thanks, that was some fast help. Solved the problems :-)

Happy to help :-)

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


text:
Arduino RTC - getting the time from RTC after the power is cut off
I have a new DS1307 (original, not a Chinese rip off), with a new battery. It is working great, but when I turn the Arduino off (it is currently connected to laptop) and then turn it back on, it resets the time.
The line that sets the time is (in setup part of code):
setDS1307time(30, 42, 21, 4, 26, 11, 14);

So, when the Arduino gets the power back it runs the program again and it overrides the correct current time.
How can I avoid this?

Remove that line of code. You only need to set the time once.

But how do I set the time for the first time? Upload the program with this line and then upload it for the second time without this line?

Make a time-setting function in your code, and in your loop() code watch for a specific command that sets the time. I use 'T20151201101010' in my own machines. When they get such a command, they adjust their clock. You will see that the DS1307 can grow slowly off-base, and having a time-setting function comes handy.

Alright, I'm a noob, can you please tell me more, or can you send me your source code?

How are you accepting commands for your application? Basically whatever that process is, add another command to set the time.

Yeah but set to what? I'm totally confuesed right now

Oh, you'd set it to whatever time the user (the issuer of the command) says it is. In the example above the time is 2015-12-01 10:10:10 (today at 10:10:10 in the morning, presumably local time). The string of numbers would need to be parsed into something that could be used to set the RTC.

I'm not sure if we understand each other. There will be no user, if power is cut off, arduino has to get time from either RTC or NTP as soon as possible, there is no chance of doing it manually.

Without knowing the DS1307 well, I think there are two options:

Make the setting of the clock a UI function (you should probably do this in any case since you will want users to have the ability to set the clock). The user would have to initiate the action (and put in the time to set) so there would be no problems the clock getting reset inappropriately, or
Do a check for sanity of the clock before you run that line. You might be able to do that through the clock API (e.g., make a call to check the time, or to get the clock status and see if it makes sense) or you could do it by storing the clock status in nonvolatile memory. The very worst case would be that you store the time of last boot and check that it seems reasonable (e.g., the time you get from the RTC is after the last boot and is within reason – say no more than a month or a year ago). If the time is too far off to feel confident you could issue a "check time" warning.

If you have a network connection using NTP as well as the RTC would be a very smart option. NTP can hold the time within a few milliseconds. The RTC would then provide you with protection against a network outage.
If you are using the Arduino to manage scheduled events one thing you'll want to think about is events that are scheduled in a moment of time that is either "skipped" as you advance the clock or that "repeats" if you set the clock back. One way to handle that is to never "jump" time, but to always just speed it up or slow it down.

The point is, I just need to set the time once and then let it be for indefinite amount of time.

No. You will see that you will need to readjust the time regularly. The DS1307 isn't that precise.

But since you have a network connection, it would be good to look into running NTP. NTP (network time protocol) will hold your time to within a fraction of a second.

No matter how good the RTC is there are reasons why you might want to set the time – battery failure, summer time, moving to a different time zone, initial setting error, …).

yeah but NTP server will not help at all if my connection falls. Maybe use NTP server if the power is cut off and maybe once a week to refresh the time?

NTP expects the network to go down from time to time. It will recover as soon as it can communicate with its peers again. In the mean time the RTC will help you stay close and will give you a good estimate of the time if you need to reboot. You could use NTP to update the RTC from time to time as well.

But I need to get time from NTP server every 30 seconds or so (it could be every minute, but I was trying NTP time before and there were some faults here and there and I didn't get the correct current time. Is this OK, or will it screw up with CPU usage too much? Or should I use RTC time, and refresh it once a day (at 0:00, get NTP packet and refresh RTC time with it)

I would just let it run. You could cut it down to every few minutes or even every day depending on how good a job the Arduino is doing of keeping time. But I don't think you'll have issues of CPU utilization.

So is constant RTC time with NTP packet refresh okay? Or are you talking about constant NTP time with RTC as backup?

I would probably do the later, but I think either one is fine. The one thing I'd want to confirm is whether or not NTP can work intermittently. Some of what it does is to measure propagation delays so that it can accurately set the clock. You might need to read the NTP spec or experiment a bit if you feel like you can't run in continuously.

Exactly, I was doing a test, and in like 2/100 of NTP packet request failed. And if I set to get the time every minute, every fail could mean bad things for me. I could set it to 30 seconds, but then again, who said there can be no two fails in a row? RTC is great so far and I think it should be fine if I would refresh it once a day (and if power is cut off). Even though I'll try to get the time from RTC (if power is cut off), because what is the point of RTC if it doesn't save the time when the power is cut off?

NTP should deal just fine with request failures. It should definitely not set a bogus time – the Internet is designed around the idea that the network is not guaranteed to be reliable. As you are testing a good thing to do would be to compare the RTC with NTP time over a decently long interval (at least long enough for the RTC to start to drift off). I think the DS1307 is good for a few seconds a day, so you could probably get by with running NTP every couple of hours (so that time would stay close even during a relatively long outage).

Great, then I'll just use RTC as primary time source, and run NTP method  every few hours to get exact current time. Then I'll just parse that time and set RTC. Btw, what is the easiest way to find out that the power was cut off? Like if(powerIsBack(){runNTPmethod()} ? And btw, you are a great person, this is not the first question you are helping me with, and you seem very patient with  noobs :)

If setup() runs, it is because the system has been restarted. It could becuase the reset button was pushed, or it could be due to a power-cycle. But either way, the code will start over completely. So you could

Deal with restart issues in setup() as it will only be called once per session (unless you call it in your own code); or
Make a variable static boolean PowerCycled = true; and clear it once your code has dealt with its re-start issues. After a restart, the initialzed data will get reloaded, including PowerCycled with it's initial value of true restored.

Yeah, I'll probably go with boolean variable and it should work just fine, thank you!


text:
Issue sharing MISO with multiple RC522 RFID Readers
so for about the last 8.5 hours (almost non-stop) I have been trying to figure out one issue and I have exhausted every search I could possibly think of.
I'm building a puzzle that requires 5 RFID readers on the 1 Arduino, but for the sake of testing i've only been using 2.
Both readers work independantly, I can read out the UIDs of the little cards, which is all I need to do, but as soon as I make them share the MISO line, it simply stops printing anything out. I have no idea why.
Both readers have a common external 3.3v power supply and ground, they share all other lines but have an individual Slave Select. For testing I put both of their MISO cables into a breadboard which then leads into the Arduino on PIN 12, but it will only print out the UID when only ONE cable is plugged into the breadboard.
So is there something special I need to do to make this work? Is there a reason why the readers sharing a MISO line would break it? Even if i don't initialise one of them, just for the fact that it's plugged in still breaks it. I have tried setting one to HIGH and one to LOW, both to LOW, both to HIGH, nothing changes it.
Also, something else kind of confusing to me, it's meant to be active LOW to activate the SS, but when only 1 is plugged into the MISO line, it doesn't seem to matter which state it's in, it always prints...
I did a little bit of testing on my sketch just a moment ago and realised that when both are plugged into the MISO, the sketch will not progress past this line (which is also the first line in the loop)
if ( ! mfrc522_2.PICC_IsNewCardPresent())
        return;

I know everything else is working because it works when there is nothing else plugged into the MISO line, but I need it to work when all the others are plugged in too.
Please please please, if you have any idea, let me know.
I'm using the MFRC522 Library
EDIT:
This is basically the setup i'm using:

I'm not using any voltage translators or shifters, everything is 5v from the arduino except for the power to the readers which is coming from an external 3.3v supply like mentions previously.
I'm pretty certain that this is the datasheet for the RC522 i'm using, though i'm not sure if it's V1 or V2, but given the differences between them I don't think it matters:
http://www.nxp.com/documents/data_sheet/MFRC522.pdf
I don't know if they are able to share MISO lines like someone below said, I just assumed I could?

You are using a 5V arduino board without voltage translators, right? If so, you are out-of-specs for those modules, so this can make them malfunction

@frarugi87, that the readers work individually suggests that's not the problem.  Also, MISO is an input to Arduino and 3V3-system outputs to 5V-system inputs are said to work ok.

Jesse Mount, please edit question and specify voltages used; whether voltage translators/shifters are used; and the model numbers of the readers.  While SPI slaves typically use open-drain outputs so MISO can be wired together, some don't.  Without a model number, who can say?

@jwpat7 Surely you mean tri-state outputs, not open-drain outputs...

@Majenko, thanks, that's what I should have meant, regarding SPI.  Was thinking of IIC by mistake.

@jwpat7 Incidentally, I can find no mention of tri-state on MISO in the MFRC522 datasheet. Doesn't mean there isn't, but also doesn't mean there is...

Jesse Mount, perhaps look at the May 06, 2014 11:34 pm post on raspberrypi.org/forums and indicate here if your RFC22's match one of the 2 shown there (3rd link's bad).  That post also tells how to verify protocol is SPI etc.  Note, that thread implies your hookup diagram should be ok but if desperate you could use a multiplexer, eg a  74LS153 would let you select 1 line of 4

The one I have looks like the red one, but it's blue.
'Image Here'.
I'm sure it's using SPI as I have no trouble communicating with the Serial from the RC522. The only issue i'm having is using more than 1. If there is another RC522 plugged into the MISO line, it causes a communication error and prevents any data from being printed out on the Serial from either device, regardless of if the 2nd one is initiated or not, or at which logic state the SS pins are set at.

@jwpat7 actually the problem is not on the arduino side, but on the device side. You are sending 5V on pins which can support only 3.8V if I remember correctly (Vcc + 0.5). So you are working out of specs. If they happen to work even in these conditions ok, but you can expect strange behaviors from this setup. IMHO the first thing to do is to lower the 5V inputs to 3.3. Even a passive voltage divider can work. Then, when you are sure that you are working following the specs, you can modify something else

Where you able to figure anything out?  I'm having a similar issue.  http://arduino.stackexchange.com/questions/29494/connecting-saleae-logic-8-to-miso-pin-12-on-uno-3-w-nrf24l01-halts-program
Sounds like it might be the same type of problem.

I don't have reputation to comment but I want to thank Michael. His solution is perfect, I was stuck for days. So, Multi RFID with software SPI works as a charm!

I am joining this conversation VERY late, however maybe my answer can help someone who is just now looking into this.
I was able to get SEVEN RC522 readers working on one Arduino! My solution was very similar to your idea, except instead of the SS pin, I used the MISO pin.

If you look into how the pins work, all of them are outputs going from the master (Arduino) to the slaves (RC522), EXCEPT for the MISO pin which is an input going from the slaves to the master.
So I gave each RC522 scanner it's own MISO pin on the Arduino, and the rest of the pins were shared with all the scanners.
To get it working with the code, the simplest solution I found was to initialize a new RFID using the corresponding MISO pin each time I wanted to read from one of the RC522s.
This worked for the Arduino because you can set several of the digital pins as MISOs, however I haven't figured out how to get this working on a Raspberry Pi yet (without using a multiplexer) because the Pi has a few specific pins that are used for MISO.
I was using the old Sunfounder library. At the bottom of this page (http://wiki.sunfounder.cc/index.php?title=Mifare_RC522_Module_RFID_Reader), if you download the "RFID-RC522_test_experiment" zip file it will have the library included. Just copy and paste the RFID1 folder into your Arduino Library folder. Here is a simple tutorial for that library: https://www.sunfounder.com/learn/RFID_kit_V1_for_Arduino/lesson-29-rfid-entrance-guard-system-rfid-kit-v1-0-for-arduino.html
Here is some example code. It is pretty ugly but it worked.
void checkRFID(int i){
  if(i==0){
    rfid.begin(2,4,5,7,3,6);
  }
  if(i==1){
    rfid.begin(2,4,5,8,3,6);
  }
  if(i==2){
    rfid.begin(2,4,5,9,3,6);
  }
  if(i==3){
    rfid.begin(2,4,5,10,3,6);
  }
  if(i==4){
    rfid.begin(2,4,5,11,3,6);
  }
  if(i==5){
    rfid.begin(2,4,5,12,3,6);
  }
  if(i==6){
    rfid.begin(2,4,5,13,3,6);
  }
  delay(100);
  rfid.init();
  uchar status;
  uchar str[MAX_LEN];
  // Search card, return card types
  status = rfid.request(PICC_REQIDL, str);
  if (status != MI_OK)
  {
    return;
  }
  // Show card type
  rfid.showCardType(str);
  //Prevent conflict, return the 4 bytes Serial number of the card
  status = rfid.anticoll(str);
  if (status == MI_OK)
  {
    memcpy(serNum, str, 5);
    rfid.showCardID(serNum);//show the card ID
    Serial.println();
    Serial.println();
  }
  delay(100);
  rfid.halt(); //command the card into sleep mode
}

were you using an Arduino Uno or one of the other Arduinos?

How do you assign the digital pins as MISO? What library were you using for your SPI?

@sa_leinad I used normal Arduino Uno

@sa_leinad and I used sunfounder's libary. Here is their tutorial: https://www.sunfounder.com/learn/RFID_kit_V1_for_Arduino/lesson-29-rfid-entrance-guard-system-rfid-kit-v1-0-for-arduino.html
With their library you initialize the RFID by providing all the pins that should be used for each RC522 pin, like this: rfid.begin(irq,sck,mosi,miso,nss,rst); so it was as simple as changing the miso pin that i provided.
So for example I would do rfid.begin(2,4,5,7,3,6); to check one reader, then do rfid.begin(2,4,5,8,3,6); to check the next reader, and so on.

Michael, you're awesome!!! I had problems to connect 5 rfid-modules for a week and nothing helped. You fixed my problem, thank you. It works perfectly :)

@Michael did you connected only SCK,MOSI,SS,MISO? did you left unconnected IRQ and RST? SS pin is the SDA, correct?

Hey man, you saved my time. Thank you. I just wonder why that library isn't in libraries or another places?

In fact, the "trick" don't really came from the RFID LIB from Sunfounder, but from the "sub librairy" they re using, which is in the same folder and which is.... SoftSPI! This lib seems to act a bit like Software serial as it allow you to declare the PINS you want for SPI. Very interesting!!!!

Looking at the datasheet for the MFR522, it is not clear that it even supports multidrop SPI. It does not mention anything about the state of the SPI output pins when the chip is not selected. It also mentions that the chip uses the slave select line to detect what communication mode to use upon startup, but does not mention anything about how the chip will react to changes on that pin after startup.
Considering this, along with the fact to your library also does not seem to support connections to multiple MFR522, my guess is that this chip only supports a 1-to-1 SPI link.
Further, the SPI Timing characteristics in the datasheet specify how lon gthe SS (called NSS) must be high before communication can begin, but does not specify how long after SS goes low that the MISO goes tri-state, which would be an important thing to know if the chip did support multidrop SPI.
This is all backed up by the behavior you are seeing. If both chips are driving the MISO line simultaneously, then communication will not be possible when both are connected.
To support multiple MFR522 connections, you could possibly...

Use a multiplexing buffer to only enable SPI lines to one chip at a time. Downside is you would need Extra hardware, but upside is that you could probably use existing library intact by selecting the desired MFR522 before making the linrary calls.

Connect each MFR522 to different GPIO pins on the Arduino and bit bang the SPI to each chip independently. Upside is that you don't need any extra hardware and you potentially have a lot of flexibility on how you access the MFR522's. Downside is you will have to retrofit this bit-banged SPI into the library or use (or write) a different library.

I've seen this question come up many times over the years, so if you do choose option #2, please publish your code so others can use it!
An Experiment
I'd propose you do this to find out if your chips are compatible with multi-drop SPI...

Power up your system with a RC522 reader.
Check and make sure it works.
Disconnect the SS and MISO lines from the RC522 so they are no longer connected to the Arduino (or anything else). Leave the RC522 powered up - if it resets it might loose the auto-detected SPI configuration.
Use a jumper to connect the SS line to ground.
Connect the MISO line to ground with a 1K ohm resistor.
Use a multimeter to check the voltage on the MISO line.
Connect the MISO line to Vcc with the 1K ohm resistor.
Use a multimeter to check the voltage on the MISO line.
Connect the SS line to Vcc.
Repeat steps 3-6.

Report back the table of the 4 voltage readings you got and we should have our answer!

While the data sheet could be clearer, It is extremely unlikely that a chip which claims to be an SPI peripheral will fail to ultimately tristate the MISO line when not selected.  At any rate it should be easily tested.

I'd be inclined to agree, but a quick google search shows many people with the exact same problem - connecting a 2nd MFRC522 to the MISO line inhibits the 1st one from working. Also note that other NXP datasheets specifically mention tristate when available (ie the PCF85063BTL states that the SPI data out line is "is high-impedance when not driving". Without having a couple of the chips in hand to test there is no way to know for sure, but based on all the evidence I think most likely this chip does not support multidrop SPI.

If anyone has 2 of these in the NYC area, LMK and we can scope them up and get a final authoritative answer!

You don't need two of them to test that behavior - you can test it with one and a resistor.

"along with the fact to your library also does not seem to support connections to multiple MFR522" -- this doesn't seem to be true.  It contains example code for using multiple readers: https://github.com/miguelbalboa/rfid/blob/master/examples/ReadUidMultiReader/ReadUidMultiReader.ino

I do not know if every module has a pull-up resistance in sck and mosi if that is the case, it could be that for every module connected over teh lines the resistance gets lower. so maybe the module can not drop the voltage so there is no comunication. check with a multimeter the resistance between Vcc and MOSI it has to be around 4.7k generally.
hope this could help.


text:
On Arduino Due webserver, there is a 5 second delay on Windows, only when connected via native port
My Due webserver was working perfectly fine for months when connected to Linux via the native port.
But when connected to Windows 10 via the native port, if the Arduino webserver is idle for about 5 minutes (when no client calls a webpage), then there is a strange 5-10 second delay before the webpage is able to load. This delay doesn't happen when connected to the webserver via the programming port.
It almost seems like maybe Windows is putting the port to sleep when it notices an idle delay, and then it has to wait for the port to wake up before it can call the webpage.
On the Windows "Power Settings" I set the computer to never go to sleep, and also in the Power "Advanced Settings" I disabled the USB "selective suspend".
Do you have any ideas why there would be this strange delay only on Windows and only when connected via the native port?

ADDITIONS: I made a simplified example that reproduces the problem on my machine. I wonder if anyone can see any problems with this code.
First, the python code. Note that if the python script is never run, there are no delays on the Arduino webserver, and everything works as expected.
import serial, sys

SERIALPORT = "COM5" # Change this to your serial port!

# Set up serial port
try:
  ser = serial.Serial(SERIALPORT, 115200, timeout=0)
except serial.SerialException:
  sys.exit()

ser.write("Hello World")
print("Hello World")

ser.close()

And below is the simplified Arduino code. It's just a simple webserver that serves a page that has a "reload" button that reloads the page. You can hit "reload" as many times as you want, and the program never freezes. But if you run the python code above and then try to reload the page, there is a long delay (anywhere between 10-60 seconds by my current estimate).
If you comment out all of the "SerialUSB.print" lines that are anywhere in the loop (in this simplified case, there's only 1 line at: "SerialUSB.println (data);" in the processData function), then the webpage never freezes, even if you run the python code frequently.
In my real-world example, my python code was running once a minute, causing random freezes. If I stopped the python code from running, then there were no more freezes on the webpage. I ended up commenting out all of my SerialUSB.print statements that were in the loop, and that way I could have the python code running on schedule, and my program had full functionality (except for the loss of SerialUSB.print).
#include <Ethernet.h>

byte mac[] = {
  0x04, 0xBA, 0xB0, 0xCC, 0xDF, 0x04
};
EthernetServer server(80);
EthernetClient client;

const byte MAX_INPUT = 25; //for processIncomingByte

void setup ()
{
  SerialUSB.begin (115200);
  Ethernet.begin(mac);
  SerialUSB.print("server is at ");
  SerialUSB.println(Ethernet.localIP());
}  // end of setup

bool processIncomingByte (const byte inByte)
{
  static char input_line [MAX_INPUT];
  static unsigned int input_pos = 0;
  switch (inByte)
  {
    case '\n':   // end of text
      input_line [input_pos] = 0;  // terminating null byte
      if (input_pos == 0)
        return true;   // got blank line
      // terminator reached! process input_line here ...
      processData (input_line);
      // reset buffer for next time
      input_pos = 0;
      break;
    case '\r':   // discard carriage return
      break;
    default:
      // keep adding if not full ... allow for terminating null byte
      if (input_pos < (MAX_INPUT - 1)) input_line [input_pos++] = inByte;
      break;
  }  // end of switch
  return false;    // don't have a blank line yet
} // end of processIncomingByteWeb

void processData (const char * data)
{ //Note: since there are no GET requests in this simple example, I removed the parts for processing GET.
  SerialUSB.println (data);
  if (strlen (data) < 4)
    return;
}  // end of processDataWeb

void loop ()
{
  client = server.available();
  if (client) {
    boolean done = false;
    while (client.connected() && !done)
    {
      while (client.available () > 0 && !done)
        done = processIncomingByte (client.read ());
    }  // end of while client connected

      client.println("HTTP/1.1 200 OK");
      client.println("Content-Type: text/html");
      client.println();
      client.print("");
      client.print("Reload");
      delay(10); client.stop();
  }
}  // end of loop

This is not technically a problem for me anymore, except for having had to comment out all my "SerialUSB.print" statements. But I am interested in learning what is causing this strange behavior.
Note: the "processIncomingByte" and "processData" functions are mainly from Mr. Gammon's writings and tutorials, and they are working flawlessly for me in 2 other Arduino webservers I have running. I wanted to note this because if I had written the functions myself, then obviously they would require much more scrutiny.

How does the USB port relate to the Due running as a webserver?!

Good point! I guess that adds to the mystery! I can't figure out why there would be a delay (only after being idle) with the native port, but no delay with the programming port... and only on Windows.

But you still haven't mentioned how you are making the Due a webserver.  It's a subtle hint to say "We need to see and understand your setup and your code" before we can help you out.

I'm sorry. I'm using an ethernet shield. This setup was working flawlessly for months on Linux, and works fine on Windows only when the Due is connected via the programming port. My code is too long to post or to simplify for the forum, but basically it's nothing unique, and it's mostly just using code from Nick Gammon's tutorials. I prefer to have it connected via the native port because some of my push-buttons send keystrokes to the computer. I rarely push those buttons (only once or twice a day), so it's doubtful that the sending of the keystrokes is related to the delay.

Re "My code is too long to post" -- arduino.stackexchange pages use scrolling windows to display code.  If the problem is a code issue, show the code.  People who answer questions effectively often like to determine for themselves what can be ruled out – typically they've seen hundreds of instances where someone says, "It can't be that" but it is

Okay, thanks for the advice. I'll try to format the code for posting here later. It will take me a while though, so I don't imagine I'll get it done until tomorrow.

I found out some new important info: There's a python script that sends data to the Due via the serial port every minute. When I stop the scheduled task from running the python script, there are no more delays for the webserver. Whenever I had attached the Due via the programming port, I didn't have the python script send the data to that port, and I'm pretty sure that's why there was never a delay with the programming port. When I edited the python script to send data to the Due's programming port number, it had the effect of resetting the Due every minute. (cont...)

So when the Due is connected via the native port the python script ends up causing it to have long delays. When it's connected via the programming port the python script causes the Due to reset once every minute. When the python script is disabled then there are no problems. I'm pretty sure this is a problem with my python code, so I'm not sure if it belongs here. I was having other problems porting my python code to Windows, and I learned that python scripts need some modifications when moving from Linux to Windows. BTW the script basically sends weather and email data to the Due.

If your Due program is written properly then it shouldn't cause any delays. If it's not written properly (and serial code so often is not written properly) then it's possible to see delays.  Post your Due code - at least the portion of it that deals with the serial.

Thanks @Majenko. I think I narrowed it down, and soon will be able to share some code that replicates the exact problem. Basically the sketch only freezes on SerialUSB.print("whatever");. When I comment all of those out of my code, then everything works perfectly. There seems to be no problem with Serial.print or Serial2.print.

I made a simplified version that reproduces the problem, and added the code to the post above. Thanks everyone for reading!

Consider an alternative approach to the problem.  I lost about a weeks worth of work assuming Windows 7 networking worked.  When I used wireshark (on the Windows computer and on an independent Linux computer connected using an Ethernet Hub), I found that Windows can fail a network and not really tell you about it.  I was able to run ping from Windows. It will appeared to make several attempts.  However, wireshark saw absolutely no attempt on Windows part to put anything on the network.  So, we turned to Linux to finish up development work. My bet, Windows momentarily failed your network.

@Jerry - Do you connect using IP addresses or names?  Also IPv4 or IPv6?

@Matt - IP addresses only, and IPv4.

@Jerry - Damn, thought it might be a WINS issue and adding your host to /etc/hosts might have fixed it.

@Matt - Thanks for sharing your ideas. I would love to eventually figure this out some day. I've been discovering from other peoples' experiences that there are some strange quirks with the Arduino Due, and now that the board is technically officially discontinued from the Arduino product line, I'm not expecting the stranger bugs to get ironed out. I'm still open to the idea that it might be a Windows networking problem, and every once in a while I do experiments with it (including those suggested here), but so far I've found nothing.

This is speculation as it may be nearly impossible for any given person to simulate your network (for example, not only the version of Windows you are running but all the drivers installed and hardware specific to your Ethernet interface ... to only mention a few variables).
Consider using a network monitor to capture all communications set out by the Windows computer.  Consider the Windows computer occasionally failing your network.  Consider the delay you experience may be the time it takes for Windows to recover from what it thinks is a bad network.
The observation is that Windows sends out many autonomous messages over a new network in a "discovery" mode.  The suspicion is that the lack of response to some or all of these messages will result in Windows failing a network.
Windows does have ways of reporting the status of networks that vary with the version of Windows. But these methods (menus) can be frustrating to use as they don't appear to update often enough to reflect the true behavior of traffic coming out of the Windows computer.
Regardless, test if the state of the network is always good.  Also, test if connecting equipment Windows might expect on a functioning network (for example, a router with a DHCP server) improves the response time.  This, as an effort / test to determine if Windows is more responsive while connected to a healthy / active network.