Hot answers tagged

112 votes
Accepted

How do you use SPI on an Arduino?

Introduction to SPI The Serial Peripheral Interface Bus (SPI) interface is used for communication between multiple devices over short distances, and at high speed. Typically there is a single "...
Nick Gammon's user avatar
  • 37.9k
12 votes
Accepted

How to increase SD card write speed in arduino

OK. So, I tried the SDFat lib. This library is definitely better than the default SD library that comes with adruino. But that is not how I solved my problem of low data-rate. I followed the ...
Ashish Ranjan's user avatar
7 votes

How do I transfer more than 1 byte at once via SPI bus?

Note that there is also a version of SPI.transfer for multi-byte (buffer) transfers: SPI.transfer(buffer, size) I used the buffer transfer in my library for the TLC59711 (see code) and found the ...
Ulrich Stern's user avatar
7 votes
Accepted

Confused between SPI and I2C for SSD1306 OLED

SCK and SCL are the same thing. Serial ClocK Serial CLock They seem to be interchangeable. The fact you have SDA (Serial DAta) as opposed to separate SDI / SDO or MOSI / MISO pins means it's I2C. ...
Majenko's user avatar
  • 105k
7 votes
Accepted

Is there any standard for colors of Serial Peripheral Interface wires?

No, there is no standard. However: Red is often +5V Black is often GND I often assign colours numerically according to the resistor colour code: 0 - Black 1 - Brown 2 - Red 3 - Orange 4 - Yellow 5 - ...
Majenko's user avatar
  • 105k
6 votes

I2C and SPI at the same time?

is it possible to use I2C and SPI at the same time? Yes it is. Both are implemented in hardware in the chip. They can operate "in the background" and raise an interrupt when there is something to do. ...
Nick Gammon's user avatar
  • 37.9k
5 votes
Accepted

Are there any constants for default SPI port pins defined?

Yes there are. They are defined in pins_arduino.h Below the pins for the yun. // Map SPI port to 'new' pins D14..D17 static const uint8_t SS = 17; static const uint8_t MOSI = 16; static const ...
jantje's user avatar
  • 1,382
5 votes

How to include <SPI.h> outside the .ino file

See my answer How the IDE organizes things. There is no easy way to avoid having to put an include in the main .ino file, unless you write your own build process (or perhaps use another toolchain). I ...
Nick Gammon's user avatar
  • 37.9k
5 votes
Accepted

Writing "theremin" outputs to a MIDI file on an SD card

The short answer would be "yes, it is possible". There are lots of gadgets around that record MIDI. They would have microprocessors in them, and they would have something like an SD card, ...
Nick Gammon's user avatar
  • 37.9k
5 votes
Accepted

Wrong documentation for Mega2560 SPI Pins?

The image is incorrect, unfortunately. The SPI pins are below: PB0 - #SS PB1 - SCK PB2 - MOSI PB3 - MISO
ArduinoFan's user avatar
  • 1,024
5 votes
Accepted

Arduino Array Scope with SPI

When you call SPI.transfer(a, 4);, any "received data" is stored in your byte array, a[]. The original data is overwritten. If you print out the contents of the array before and after the ...
VE7JRO's user avatar
  • 2,560
4 votes

Issue sharing MISO with multiple RC522 RFID Readers

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 ...
Michael's user avatar
  • 61
4 votes

Convert library from using bitbanging to hardware SPI

The standard AVR library has SPI handling. See, for example: http://www.gammon.com.au/spi You don't have to write a library if you don't want, just communicate directly using SPI. The datasheet for ...
Nick Gammon's user avatar
  • 37.9k
4 votes

Are there any detail examples of Si4463

I've looked at the data sheet for this and I think it is the wrong choice of device for a beginner. Can I suggest that you start by looking at a relatively simple DPI interfaced device, such as a ...
Code Gorilla's user avatar
  • 5,637
4 votes

How to increase SD card write speed in arduino

Many factors would decide if you can reach this wanted speed. Only some of these. 1. Your Software The SdFat Library is faster than the standard SD Library of the Arduino IDE. It also has an easy to ...
William Roy's user avatar
4 votes

How to increase SD card write speed in arduino

Avoid the handshake getting a buffer! Use SD.write(buf,size); Hi every one, I'm working in a project with the same issue. I was following the same steps of yours and got exactly the same numbers. I'...
Pinipa's user avatar
  • 41
4 votes
Accepted

Which library to use for 23LC1024 SRAM 1 Mbit

SPI RAM has two modes of operation: single byte and "page mode". In single-byte mode you first send the read or write command followed by the (typically 3-byte) address and then read a byte. That's 5 ...
Majenko's user avatar
  • 105k
4 votes

Why does void loop() stop after some samples?

float sine[5000] ... sine[j]=s+190; A float takes 4 bytes. You are allocating 5000 of them which is 20000 bytes. The Uno has 2048 bytes of RAM. Thus you are running out of RAM and overwriting ...
Nick Gammon's user avatar
  • 37.9k
4 votes
Accepted

What is the tool to send file to SPIFSS on ESP8266/32?

The mkspiffs tool creates bin from file system data (or extracts data from bin). SPIFFS bin is uploaded with esptool over USB or with espota over WiFi. It can be uploaded with the sketch binary in ...
Juraj's user avatar
  • 17.7k
4 votes
Accepted

SPI.transfer(buffer, size) does not send data from buffer

SPI.transfer(&SPI_message,2) is unfortunately destructive. The buffer is updated with the received values. There is a SPI member function[1] that can be used for 16-bit data; SPI.transfer16(...
Mikael Patel's user avatar
  • 7,959
4 votes

Can Serial be safely used in an SPI interrupt routine

Serial should be avoided in ISRs because interrupts are disabled inside ISRs, and Serial transmission uses interrupts to operate. Better to have the ISR set a flag that is read in the next iteration ...
jose can u c's user avatar
  • 6,974
4 votes

Read write with half duplex SPI

All you need is a single resistor. simulate this circuit – Schematic created using CircuitLab When DATA is an input the data from MOSI passes through the resistor to both DATA and MISO. When ...
Majenko's user avatar
  • 105k
4 votes
Accepted

SPI: test by connecting MOSI to MISO

Yes, you can - and it's something I often do when doing low-level electrical testing an SPI interfacce. For every clock that you send out the data presented on MOSI will get reflected on MISO. So if ...
Majenko's user avatar
  • 105k
4 votes

Writing to sd card with a sampling rate 50ms or less? I have a sketch that writes to sd every 1s but jams at faster sampling rates. Please help?

Some tips: Do not open the open and close the file in every loop sequence (I think you can use the flush command to save/update the file. Do not save strings, but save the raw data and pulse string. ...
Michel Keijzers's user avatar
4 votes

SPI Slave Programming for Arduino

SPI.h library by default only support Master mode, the SPI.begin() will automatically set slave select (ss) pin to HIGH whether you have pinMode(ss, OUTPUT) in your setup() code or not and set the ...
hcheung's user avatar
  • 1,277
4 votes
Accepted

When is SPI.beginTransaction required?

Although this question has an accepted answer, I'd like to provide some background and historical reasons to OP's question. Transactional SPI using SPI.beginTransaction() was introduced in 2014, it ...
hcheung's user avatar
  • 1,277
4 votes

RaspberryPi Pico SPI and nrf24l01

For Arduino-pico core ** MISO - pin GP16 ** MOSI - pin GP19 ** CS - pin GP17 ** SCK - pin GP18 Arduino-mbed core ** MISO - pin GP4 ** MOSI - pin GP3 ** CS - pin GP5 ** SCK - pin GP2
khoih-prog's user avatar
4 votes
Accepted

How can I SPI "Latch" (LE/CS/SS) for a specific number of SCLK cycles?

I've achieve this by "bit-banging" via a modified shiftOut() of ArduinoCore-avr/cores/arduino/wiring_shift.c, essentially allowing for two data lines on the same clocking: void keyedShiftOut(...
George Kerwood's user avatar
3 votes

Arduino Nano, ICSP header and 595 Shift register

It is extremely confusing to have a variable val and then use _val in your function but then: shiftOut(dataPin,clockPin,LSBFIRST,val); As James pointed out, you are not sending the value passed to ...
Nick Gammon's user avatar
  • 37.9k
3 votes

Issue sharing MISO with multiple RC522 RFID Readers

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 ...
bigjosh's user avatar
  • 1,553

Only top scored, non community-wiki answers of a minimum length are eligible