text:
What do these pins mean? Where should I plug them in?
I am trying to collect data from the arduino into a SD card for the first time, so I bought the adapter at my local electronics/arduino shop. However, I could not find an explanation as to what each pin does, and the other adapters that I have seen online have different pins, so I am not sure what to do with the pins (except for the obvious ones, GND and VCC)

The order of pins is as follows:
CD, DO, GND, SCK, VCC, DI, CS.
Could you help me figure out what they mean and where to plug them into my arduino?

for Uno use an 5 V SD card adapter. this is only for 3.3 V

You should read the documentation.

See https://www.instructables.com/id/Adafruit-Sparkfun-MicroSD-Breakout-and-Arduino-Mic/ for a useful starting point

This is called the SPI interface (See Serial Peripheral Interface, Wikipedia. The pin names typically used for SPI are:

GND : Power Ground
VCC : Power input
CS : Chipselect
SCK/SCLK (SD-Clock): SPI Clock
MOSI (SD-DI, DI) : SPI Master out Slave in
MISO (SD-DO, DO) : SPI Master in Slave out
CD: Card Detect (see comment of rollinger below (thanks).

On an Arduino Uno the SPI pins are:

CS – digital 10; this can be in principle any pin
SCK – digital 13
MOSI – digital 11
MISO – digital 12

I'd expect CD to be card detect, switch signalling when a card has been inserted- e.g. see https://www.instructables.com/id/Adafruit-Sparkfun-MicroSD-Breakout-and-Arduino-Mic/ for hookup of a similar / same board

@rollinger Thanks ... and yes, that sounds more plausible than my search on google, so I updated my question. Thanks/credits to you.

CS = Chip select
DI = Data In (MOSI)
VCC
SCK = Serial Clock
GND
DO = Data Out (MISO)
CD (not sure what it stands for, but this pin isn't used when connecting to an Arduino. I think it's used for faster transfers.)

Note that SD card run at 3.3Volt, not 5V. Also the input pins of the SD can't handle 5Volt signals. So you need to convert the 5V signals coming out of the UNO to 3.3V before connecting to the SD card.

Oh that is actually a problem for me, because I wanted to run it from the arduino! How can I convert it? Would a voltage divider be good enough?

It appears you can, but you'd have to run at a lower speed, so it doesn't work out of the box with the standard libraries. But nothing a few lines of code can't fix.

Could CD stand for Card Detect? changing state depending on whether a card is physically in the slot.

CD could be one of two things:
a) a simple mechanical switch on the socket, usually used for Card Detect.  Measure from the pin to Gnd and see if contact is open/closed when a card is plugged in.
b) the fifth IO pin to a uSD card.  See the chart on the middle of this data sheet
https://www.molex.com/pdm_docs/sd/472192021_sd.pdf
You will see there are 4 data lines for parallel operation (Dat0, Dat1, Dat2, and CD/Dat3), and the Clock and Command (CMD) pin.   Arduino uses serial operation over the SPI bus tho, so in this case CD is likely card detect from what appears to be a mechanical lever switch at the bottom of the socket.
This drawing shows how the pins are used
http://www.dotmana.com/weblog/wp-content/uploads/izQKT.png

Your question's been well answered, but I just wanna point out, when you get the library code that lets you access the SD card, there will probably be instructions on what pins to wire up where. That's nearly always the case. Particularly since this one uses the SPI pins.
There's also loads of instruction websites that would take you through it. The cheap Chinese stuff is nearly always copies of designs from the West, as seen on popular websites. So the instructions usually apply. Arduino is bloody great! Good luck in your adventure.


text:
DHT.h Library not being imported
I am trying to read the humidity and temperature using a DHT11 temperature sensor for an Arduino UNO using the DHT.h library. I have my code below:
#include <DHT.h>
#define dataPin 4
dht DHT;

void setup() {
  Serial.begin(9600)

}

void loop() {
  int readData = DHT.read11(dataPin);
  float t = DHT.temperature;
  float h = DHT.humidity;
  Serial.println("Temperature: ")
  Serial.print(t)
  Serial.print(" ºC")
  Serial.println("Humidity: ")
  Serial.print(h)
  Serial.print(" % ")
  delay(2000)
}

When compiling the program, it gives me an error:
fatal error: DHT.h: No such file or directory

I have also tried with lower case letters, but it will not work. Is there any reason why? Do I have to install it? I have tried to search for the library in the Arduino app Sketch - Include Library - Manage Libraries, but the library is not there.

Actually it is a custom library by adafruit. It is present at https://github.com/adafruit/DHT-sensor-library

adafruit/DHT-sensor-library is not the correct library for the code in the question. That code is written for a different library, which I have provided instructions for below.

it seems nothing problem with your library. Have you calibrate your formula(math eq inside coding)?

Download https://github.com/RobTillaart/Arduino/archive/master.zip
Copy the Arduino-master/libraries/DHTstable subfolder of the downloaded file to the libraries subfolder of your sketchbook folder. You can find the location of your sketchbook folder at File > Preferences > Sketchbook location in the Arduino IDE.
Change the first line of your sketch from:
#include <DHT.h>

to:
#include <dht.h>

Now when you try to compile the sketch you will still encounter many errors. However, these are caused by a paucity of semicolons, not by the DHT library, and thus off-topic for this question.

Thanks, @per1234, now it is not showing an error. But, the readings of humidity and temperature are not correct. Here the temperature is nearly 20-degree Celsius with humidity nearly 60%. But Arduino shows the temperature of 2.3-degree Celsius and humidity of 13%. Why so? How to correct this?

I have had problems using some DHT library versions.  I suggest that you try using a different version of dht.h
This version works for me (there are newer versions, but I recommend starting with this oldie but goldie):
dht.h (606B 6/12/2012)
//
//    FILE: dht.h
// VERSION: 0.1.00
// PURPOSE: DHT Temperature & Humidity Sensor library for Arduino
//
//     URL: http://arduino.cc/playground/Main/DHTLib
//
// HISTORY:
// see dht.cpp file
//

#ifndef dht_h
#define dht_h

#if ARDUINO >= 100
 #include "Arduino.h"
#else
 #include "WProgram.h"
#endif

#define DHT_LIB_VERSION "0.1.00"

class dht
{
public:
    int read11(uint8_t pin);
    int read22(uint8_t pin);
    double humidity;
    double temperature;

private:
    uint8_t bits[5];  // buffer to receive data
    int read(uint8_t pin);
};
#endif
//
// END OF FILE
//

try to download this library in this link and insert it to your ide, it works for me.
https://github.com/adafruit/DHT-sensor-library

source: Stack Exchange

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

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

sort: votes


text:
Maximum power rating for Arduino UNO revision 2 (SMD)
I have located the 5V voltage regulator chip on my Arduino board which I am hoping to use to power an attached device (which draws up to 500 mA at 5V).  The chip is next to the plug for the external voltage supply.  It says: ON RUX 117-5.  It looks like it's in a SOT−223 package (body about 6.1 by 3.4mm).
I used this page to shows 3 different possible voltage regulators from ON Semiconductors: https://www.mouser.co.uk/ON-Semiconductor/Semiconductors/Power-Management-ICs/Voltage-Regulators-Voltage-Controllers/LDO-Voltage-Regulators/_/N-5cgac?P=1z0wa29Z1z0xwtvZ1z0zlrjZ1ywvc7yZ1yxz1yoZ1ywvc5z
This gives two unique data sheets for NCP1117LP and NCP1117, NCV1117.  But this is where I'm stuck.  They look pretty similar but not exactly the same data sheets.  Also I don't know what RUX stands for, perhaps this is important in figuring out what power rating the Arduino 5V line has.
Additionally the mouser.co.uk site says they're in SOT-223-3 packages but then gives dimensions which a) aren't the dimensions of the chip I have and b) are the dimensions of the SOT-223-4 package (6.3mm wide instead of the ~6.1 mm I have).
I don't care about the dimensions but I would like to correctly identify the chip on the Arduino board to be able to know what power I can draw from it before it shuts itself down.

The Arduno UNO SMD R2 uses an MCP33269 not an LM1117.What you have is probably some cheap Chinese clone of the Arduino, and in that case the regulator will be the cheapest Chinese copy of the LM1117 available. Impossible to tell what the specs of that specific chip are.Suffice it to say, though, that the specs of the chip are pretty much irrelevant since they rely on good heatsinking, which you most certainly don't have on a little Arduino board.500mA though is a lot to push through a linear regulator like that (depending of course on your unspecified input voltage which is a critical factor).

Better to get a proper switching regulator that can cope with the current without melting.

Thank you very much @Majenko .  It makes sense now that this is a clone (I got it from a friend who would have just ordered it from the cheapest place)... that's what was tripping me up.
Input voltage is 4 x 1.5V AA so ~6V.
I will get a proper step down converter.  Please add as an answer if you wish.

If you're running from batteries then you definitely want the added efficiency of a switching regulator.

@Majenko, OP has in Question NCP1117 not LM1117. According to schematics orginal Uno R3 uses NCP1117ST50T3G

@Juraj I know. The NCP1117 is NCP's copy of the LM1117. The two are one and the same. But that's a moot point since The OP has an R2 not an R3!

ON RUR 117-5 is made by Chinese "ON Semiconductor" :-)

It's definitely ON RUX 177-5 but maybe they made a typo ;P @Juraj

The Arduno UNO SMD R2 uses an MCP33269 not an LM1117.  What you have is probably some cheap Chinese clone of the Arduino, and in that case the regulator will be the cheapest Chinese copy of the LM1117 available.  It's impossible to tell what the specs of that specific chip are.  Suffice it to say, though, that the specs of the chip are pretty much irrelevant since they rely on good heatsinking, which you most certainly don't have on a little Arduino board.
500mA, though, is a lot to push through a linear regulator like that, and when running from batteries the excess power loss imposed by the regulator will be a major factor in longevity.
You are better off investing in a proper switching regulator (such as a UBEC from a model aircraft supplier like Hobbyking).

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


text:
Is there an Arduino motor shield library?
I have an old motor shield but can see the revision 3 is still being sold: https://store.arduino.cc/arduino-motor-shield-rev3
When I follow the link for "Getting Started section" the page lists a lot of shields but not the motor shield.  I must be missing something really obviously but I can't find a library for the motor board.
I'm trying to drive 2 DC motors.

Have you googled this, before asking here? I googled "Arduino motor shield rev3 library" and directly found this library on github. Have you tried it or any other library?

Yes for the last 90 minutes: https://www.ecosia.org/search?q=arduino+motor+shield+library&addon=opensearch https://www.ecosia.org/search?q=arduino+motor+shield+library+-adafruit https://www.google.com/search?q=site%3Ahttps%3A%2F%2Fwww.arduino.cc%2Fen%2FGuide%2F+motor+shield&addon=opensearch https://www.google.com/search?q=arduino+motor+shield+library+example Granted that for me: https://www.google.com/search?q=arduino+motor+shield+library shows your link as the fifth result down for but then it's followed by Adafruit Motor Shield again... their SEO is too good.

Ok so using Ecosia is part of the "problem", along with Adafruit's SEO... but I just realised Ecosia is powered by bing.com  and the extreme irony is that this question is already indexed as result number 7 but the library you helpfully provided is not! https://www.bing.com/search?q=arduino+motor+shield+library  LOL

Often it is helpful to add the term github to your search, since almost every Arduino library is hosted there.

Thanks @chrisl something seriously weird is going on with all my filter bubbles because your result now isn't shown in my google search after being shown in it minutes before... * so confused *.  Adding github just shows the Adafruit barrage, at least on page 1.

From Chrisl's comment: https://github.com/gallingern/arduino-motor-shield-r3
You don't really need a library though as the code is simple enough:
void setup() {

  //Setup Channel A
  pinMode(12, OUTPUT); //Initiates Motor Channel A pin
  pinMode(9, OUTPUT); //Initiates Brake Channel A pin

}

void loop(){

  //forward @ full speed
  digitalWrite(12, HIGH); //Establishes forward direction of Channel A
  digitalWrite(9, LOW);   //Disengage the Brake for Channel A
  analogWrite(3, 255);   //Spins the motor on Channel A at full speed

  delay(3000);

  digitalWrite(9, HIGH); //Engage the Brake for Channel A
}

From here.


text:
How can I connect multiple MCP23017's to an arduino?
I am working on a project and I am trying to figure out how to connect multiple MCP23017 IO Expanders to one arduino. All of the guides that I have found in my quest for information only explain how to connect one MCP chip or how to address multiple MCP chips. None seem to explain how to connect them physically. BTW, I am talking about the I2C version of the chip.

If you know how to connect one chip you know how to connect many chips.  One or eight it's the same.
All the SCL pins connect to the SCL pin of the Arduino. All the SDA pins connect to SDA on the Arduino.
Just make sure that each chip is given a unique address using the A0-A2 pins as detailed in the datasheet.

One to eight is the same, ten is too much with three address bits.

You can also address them all with the same address, and use the A0-A2 pins as a chip select.  For example, have discrete pins connected to A0s, and have A1, A2 connected to Gnd. Have A0 held high in the code.  When you want to talk to a device, bring A0 for that device low, use the I2C address for A0-A1-A2 =0, then bring A0 for that device back high.  Next device, use the next A0 line, and so on.  You could expand even further, with A1/A2 = 0,0,  and 0,1, and 1,0, and 1,1, with 32 slave select lines (fed by 4 shift registers even, with just 3 control lines needed to load the shift registers).


text:
HX711 arduino Scale offset drift
I am working around with HX711 ADC and a 5kg load cell, it seems the HX711 library is some sort of mystery no one wants to reveal!
Please someone explain me, I promise to keep the secret ;)
Anyone here can suggest a coding trick to compensate drifting in the reading values?
Actually the slope is ok, but the offset is not stable, also I don't know the difference between these two:
scale.set_offset();
scale.get_offset();

How these two actually do the job and shall I use them in the void loop() function?
Also that would be really helpful to suggest me a code for averaging readings beside what the library pre-used, like scale.get_units()
Thanks

Have you tried auto zero, that works very well if the circuit is stable.

@Gil can you please explain more, no I don't know what is auto zero

Zero the reading when there is no load on the scale. this goes into great detail: https://www.analog.com/en/analog-dialogue/articles/demystifying-auto-zero-amplifiers-part-1.html I do not know your system but a guess would be a low reading would be no load, save that and use it when you get a quick increase in weight use that as your correction factor.

@Gil thanks man you helped a lot

You are welcome!


text:
Cannot import library file from ESP32 sdk library in "Eclipse C++ IDE for Arduino" project
I have successfully installed "Eclipse C++ IDE for Arduino" and the Plugin works fine. Now I installed a custom board (ESP32) by adding package_index.json URL in windows>prefrences>C/C++>Arduino. The board installed and also work fine.
The only problem I'm facing is that I'm unable to import platform SDKs and libraries.(e.g. #include "driver/adc.h") which are present in the path: G:\program\eclipse.arduinocdt\packages\esp32\hardware\esp32\1.0.2\tools\sdk\include
I just want to import files just like in the Arduino IDE.
Eclispse version :
Eclipse IDE for C/C++ Developers
Version: 2019-03 (4.11.0)
Build id: 20190314-1200
Thank You

what Eclipse Arduino plugin? Sloeber? you don't need to import them. they are part of the esp32 Arduino core

I'm using  Eclipse C++ IDE for Arduino, that is included in Eclipse CDT tools, when I import "driver/adc.h" i get build error. here is the link of the plugin: https://marketplace.eclipse.org/content/eclipse-c-ide-arduino


text:
Can I use an ESP8266 as a replacement for an original Arduino?
I want to learn Arduino, but I'd like to use the ESP8266 as it has built in wifi. I understand that I can use the Arduino IDE for this board.
However, what about books and resources out there? Are these two boards so similar that I can follow original Arduino examples? I'm primarily thinking in terms of connectivity to, say, sensors.
I'm a beginner at this and will not be able to figure out how to bridge compatibility gaps.

Neither "ESP8266" nor "Arduino" is a board.

Well, no, because there are dozens of boards that use the ESP8266 microcontroller and fall under the Arduino brand. You can't just mix-and-match between them.

No, it works with a wide range of boards that use the ESP8266, but they vary wildly with respect to the number and placement of external connections.

Which "original Arduino" do you have in mind? There are a lot of Arduino types (boards).

Firstly, there are no ESP8266 "boards" that fall under the "Arduino brand" that I'm aware of - secondly, most common ESP8266 have 11 available GPIO's, far less than most common Arduino boards (some as few as 4) - depending on how many and what type of sensors you wish to use at any one time is a major factor in your decision making

@JaromandaX - Sorry but all ESP8266 processors have the same number of GPIO connections.  The boards that use ESP8266 processors have varying numbers of those GPIO connections taken to the edge.

In my comment. Take esp8266 to mean esp8266 board

Yes, No and Maybe is the best answer :)
Assuming that you want to replace a Arduino Uno board with an ESP8266 based board.  Your best choice at the moment would be a Wemos D1.  It has the same form factor as the UNO, but it has less pins, 9 digital and 1 analog.
If you are not bothered about the form factor, you could also try a Node-LUA, or a Wemos D1 Mini.  If you have steady hands you could try just using the heart of these three boards directly, which is usually called an ESP8266-12E, but it has 1mm pitch and no voltage regulation.
There are a lot of sites around that have tutorials on using ESPs.  They are mostly interchangeable with Arduino boards from a software perspective, they have more memory and a faster clock speed.
The biggest difference between an Arduino based board and an ESP board is most Arduino use 5v and most ESP based boards use 3.3v.  Make sure you read the datasheet before you hook up you sensors.
There is an ESP-32 as well.  This is not interchangeable with an Arduino Uno at the moment.

Thanks - I appreciate your answer even though my question was not all that clear. I'll be looking into the boards you've mentioned. Thanks!

Are these two boards so similar that I can follow original Arduino examples?

for most applications, an mcu is useful not because of its core - which is almost fully transparent to a high level language programmer - but because of its peripherals: timers, serial comms, interrupts, adc/dac, ...
sure, there are applications that don't require those functionalities; or those functionalities could be emulated. but you will find it much easier if the mcu does have those functionalities.
so all it takes is to take a look at the datasheet of your esp and ask yourself if you see those peripherals. after that, the answer is clear.

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


text:
Arduino: Connect UNO to A7 AI Thinker
I just cannot connect or send AT command from my UNO to A7 AI Thinker module. This is the connection:
UNO    ->    A7
TX     ->    RX
RX     ->    TX
USB    ||    5V    -> External Power Supply
GND    ->    GND

Without any sketch, I tried to send AT command from serial monitor, and nothing happened.
Different case if I use USB TTL to A7
USB TTL   ->   A7
VCC (5v)  ->   5V
GND       ->   GND
TX        ->   RX
RX        ->   TX

Then it is OK, I can send all AT command, SMS, Call, etc from the serial monitor.
Just what is happening with UNO? Does my UNO RX TX Faulty? How to check it?

What pins on the Arduino are you calling TX and RX?  The normal ones are already in use for the USB-serial, so if you try to use those for something else at the same time, at least one of the two links will fail and you won't be able to tell what is going on.  The Uno is poorly suited to use with serial interfaced add-ons, you typically have to use a bitbanged "software serial".

The pins are 0 and 1 on Arduino. I do not try to use sketch, I just want to make sure that the A7 got the AT commands. If I use SoftwareSerial and connect the tx rx on pin 2 and 3, I should upload the sketch first right?

I think I am a I'll so facing similar issues with you.
I tried sending AT commands to my board and nothing is coming up
Could it be that I have done something wrong?

Without any sketch, I tried to send AT command from serial monitor, and nothing happened.

The problem is with your connections to the Uno. Although it seems wrong, the correct connection when you're using the Uno as a USB-serial adapter to communicate with the A7 AI Thinker module from Serial Monitor is:
Uno                A7
TX (pin 1)   ->    TX
RX (pin 0)   ->    RX

The RX and TX markings on the Uno refer to the pins on the ATmega328P microcontroller. But you're not using that microcontroller, you're communicating between the USB-serial chip on the Uno and the A7. The RX line of the USB-serial chip is connected to the TX pin of the ATmega328P and thus to pin 1, the TX pin of the USB-serial chip is connected to the RX pin of the ATmega328P and thus to pin 0. For this reason the connection between the Uno and A7 shown above are actually an RX-TX, TX-RX connection between the USB-serial chip and the A7.
If you were communicating between the ATmega328P on your Uno and the A7 then the connections you used would have been correct.

This is make sense. I tried to connect TX->TX and RX->RX but this error came out: Invalid or no response from the device. Please check the modem port and the baud rate.Disconnecting port COM3.. I set the baud rate to 115200. What is happening here?

Are you communicating with your computer over Serial e.g. Serial Monitor) and also communicating with the A7 module over Serial at the same time? That is problematic. It may be better to communicate with the module via software serial and leave Serial to be used only for uploading and communicating with the computer. Keep in mind that software serial doesn't work reliably at 115200 baud.


text:
Arduino Uno + Sim808: Using HTTP client for GPRS GSM
My problem is that I do not want to use AT commands everywhere to get/post data to my web server because it is brainstorming with all the delay and anything. I want to use library like gsm.h or something similar. Is there simple libraries which I can use to do the HTTP/HTTPS request (get/post) to my web server?
This code is my attempt with gsm.h, but it does not work. I suppose it only works with Arduino + Telefonica GSM/GPRS shield, not Sim808:
/*
 Web client

This sketch connects to a website through a GSM shield. Specifically,
this example downloads the URL "http://www.arduino.cc/asciilogo.txt" and
prints it to the Serial monitor.

Circuit:
* GSM shield attached to an Arduino
* SIM card with a data plan

created 8 Mar 2012
by Tom Igoe

http://www.arduino.cc/en/Tutorial/GSMExamplesWebClient

*/

// libraries
#include <GSM.h>

// PIN Number
#define PINNUMBER ""

// APN data
#define GPRS_APN       "GPRS_APN" // replace your GPRS APN
#define GPRS_LOGIN     "login"    // replace with your GPRS login
#define GPRS_PASSWORD  "password" // replace with your GPRS password

// initialize the library instance
GSMClient client;
GPRS gprs;
GSM gsmAccess;

// URL, path & port (for example: arduino.cc)
char server[] = "arduino.cc";
char path[] = "/asciilogo.txt";
int port = 80; // port 80 is the default for HTTP

void setup() {
// initialize serial communications and wait for port to open:
    Serial.begin(9600);
    while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
    }

    Serial.println("Starting Arduino web client.");
    // connection state
    boolean notConnected = true;

    // After starting the modem with GSM.begin()
    // attach the shield to the GPRS network with the APN, login and password
    while (notConnected) {
       if ((gsmAccess.begin(PINNUMBER) == GSM_READY) &
       (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY)) {
          notConnected = false;
       } else {
          Serial.println("Not connected");
          delay(1000);
       }
    }

    Serial.println("connecting...");

    // if you get a connection, report back via serial:
    if (client.connect(server, port)) {
       Serial.println("connected");
       // Make a HTTP request:
       client.print("GET ");
       client.print(path);
       client.println(" HTTP/1.1");
       client.print("Host: ");
       client.println(server);
       client.println("Connection: close");
       client.println();
    } else {
      // if you didn't get a connection to the server:
      Serial.println("connection failed");
    }
}

void loop() {
     // if there are incoming bytes available
     // from the server, read them and print them:
     if (client.available()) {
        char c = client.read();
        Serial.print(c);
     }

     // if the server's disconnected, stop the client:
     if (!client.available() && !client.connected()) {
        Serial.println();
        Serial.println("disconnecting.");
        client.stop();

        // do nothing forevermore:
        for (;;)
        ;
     }
 }

Is there GSM/GPRS library that I can use with Sim808?

What does Google tell you?

Start Arduino IDE, open the Library manager, search for SIM800 and there is 3 libraries available there that you can install. The advantage is that this libraries is kept up to date and when a new version is available you will get a notice to upgrade.
There is a HTTP PUT/GET library "HttpClient" that can be installed the same way as above.
Or
If you googlem using "sim800 library arduino" you will find several libraries like:
https://cristiansteib.github.io/Sim800l
or on github:
https://github.com/search?l=Arduino&q=sim800&type=Repositories&utf8=%E2%9C%93
And as I understand it the 808 is GSM/GPRS + GPS, so the GPS features isn't normally covered by these libraries.


text:
AT+HTTPACTION: What is status 606 means?
I use Sim808 gprs/gsm/gps module and call these:
AT+SAPBR=3,1,"Contype","GPRS"
AT+SAPBR=3,1,"APN","internet"
AT+SAPBR=1,1
AT+SAPBR=2,1
AT+HTTPINIT
AT+HTTPSSL=1
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","https://www.mywebsite.com/getTime?token=jsdaljdaskl"
AT+HTTPPARA="REDIR",1
AT+HTTPACTION=0

I always get +HTTPACTION: 0,606,0 as the result.
What does 606 mean? I cannot find it everywhere in the documentation.

The only 606 I can see is an SSL error. Maybe you have an invalid certificate on your site. Try with other sites.

"606 SSL  alert  message  with  a  level  of  fatal  result  in
the immediate termination of the connection" https://cdn-shop.adafruit.com/datasheets/SIM800+Series_SSL_Application+Note_V1.00.pdf

Read here pdf file, exist thi error 606 and error 605 [https://cdn-shop.adafruit.com/datasheets/SIM800+Series_SSL_Application+Note_V1.00.pdf][1]

I am having the same issue. I have tried days with everything I could find on the internet, but it seems like it doesn't work at all. It works fine for HTTP but https always fail with 606 status.


text:
Sim808: Is My GPS Module Broken?
Is my GPS module broken?
My GPS returns $GPGGA,000250.262,,,,,210,,2,700,,*4C as NMEA. Why there is no latitude longitude? the first value is the UTC time, but there are so many null values ,,,,, Is my GPS module broken?

Edited
My Sim808 model is SIM808 Module GPRS SMS Development Board IPX SMA with GSM GPS Antenna

What makes me think why is this broken is because the day before, the module keep giving me location for every second. The lock was almost instant. I use the module at the same place like before. It is weird because the module is so unstable, yesterday was fine but the next day it takes forever to lock location.

More likely it just hasn't got a lock on any satellites. What antenna do you have and where is it all situated?

Many fields will empty until the unit can get a lock. $GPGSV messages will tell you how many satellites it currently sees, and how strong the transmissions are. The first lock can take several minutes, and it can be very difficult to get a lock indoors.


text:
Powering Sim808 + Arduino UNO
I am currently making a GPS tracker with UNO and SIM808 (this is the model.
It says The range of voltage of Lithium battery input power is 3.5 - 4.2V. for the module. I am aware that UNO needs 5V to power.
I want to make it compact as possible so it can be placed within the dashboard of a car or motorcycle.
How do I power both of this using just one battery holder?

Use an Arduino running at 8MHz - it can then run with anywhere from 2.8V to 5.5V reliably.

Can UNO running at 8MHz? Or should I buy another arduino? I heard there is a dissadvantage of running at 8MHz, which is slower. Do you have any links for the solid answer? I have been googling arround, but did not find the solid one. All discussions makes me confused.

No, buy a 3.3v pro mini. The only disadvantage of running slower is you are running slower.

One more thing, if I burn bootloader on UNO to 8 MHz and using 3.7v and 2A battery, will it damage the UNO? Because UNO can only hold 20 or 40 mA. If you put the answer, I will mark it

You will need to make hardware modifications for 8MHz. I.e., change the resonator for an 8MHz one.  And what do you mean the Arduino can only hold 20mA? That makes no sense whatsoever.


text:
(Advice) Home Automation Project (Domotic mobile home)
I have a project that I hope to accomplish in the near future.
I want to transform a mobile home into automation mobile home.
The elements that make up my project are the following:

My idea is to supply the home with a solar installation, disregarding their potential (we can discuss the autonomy of the system later, uses and consumptions).
The idea is to keep an Arduino always running in order to monitorize the home and provide remote administration.(like geolocation, camera and sensors control,power management for hardware ...)
The laptop can be out of the system (when I take it with me). It could be connected to a secondary monitor.
The docker provide an easy way to charge the laptop, connect devices and provide a WOL utility.
The Arduino could have differents components like Ethernet, own battery, gps... And It could switch on/off the camera and sensors.
The laptop could be powered on/off by WOL and administrate remotely.
The camera could have a microSD to save media and it can be manipulated with Arduino by a remote connection.
Arduino could get info about sensors too(as proximity).
I have some doubts:

Instead of using WOL , we could use Arduino to wake up the laptop?
It's possible to connect the laptop and the arduino by wlan or ethernet interface? or we need to wire it (usb...)?

Thanks for the attention, I await your answer.

no because you only show a network connection between the arduino and the laptop .... 2. yes and no

https://arduino.stackexchange.com/tour

@jsotola Well technically arduino can send WOL packet to the laptop.

Cool ! What have you done do far, and which bit of it are you having difficulty with?

Dou you really want to use an Arduino for this? At least the Atmega based arduinos are not capable of handling any "media".  Why not using a raspberry Pi or similar. I think that would make much more sense

If i can use Arduino than other powerful devices better ,  in order to save battery.

The Arduino is not built or powerful enough to handle things like cameras and high-speed 4g connections for remote administration. I would suggest using something like a Raspberry PI 3 as it would be much better suited to the job.
I would recommend asking this question again on the raspberry pi exchange.

But I only would use it for power on/off devices, move the point of view of the camera , and detect activation of sensors like proximity (Boolean) and thinks like that. Not processing video or these heavy tasks. I suppose the ip camera has the capacity to record video and so on. And if the PC is on the system could do other heavy tasks. I thought that with Arduino was enough for these uses.

It would be fine for the uses you just stated but configuring the arduino and the PC to work together would be quite difficult. (Like how would you get the recorded video to the computer?) Also, your computer would need to always be there so if you wanted to use your laptop in your house and moniter the sensors, there would be a problem. I think a single one board computer like a PI would be easier and more effective.

Okei thanks, I will study use PI.

If you want to save battery, you can also use a smaller Pi board, like the Raspberry Pi Zero W. Though it has no LAN, but WLAN.

Yep, under clocking the raspberry pi is also an option but you can discuss those details on the pi stack exchange/forum


text:
Communication using two HC05 modules
I'm working on a project that consists of sending data from flex sensors from a master Arduino to a slave arduino that uses that data to control servo-motors. I am trying to start slow and just control an LED using a button.
I have gone through all AT commands, have set both a master and a slave and binded the addresses but when I try to light the LED on it for some reason doesn't work. My serial monitor keeps printing the letter "d" over and over again and I don't know what this is. Code is below:
int val=0; //Master code
#define button 3
void setup() {
Serial.begin(38400);
pinMode(button,HIGH);
}
void loop(){
val=digitalRead(HIGH);
if(val==HIGH){
Serial.write(100);
delay(500);
}
delay(50);
}
}

#define led2
int pos=0;
int val;

void setup(){
Serial.begin(38400);
pinMode(led,OUTPUT);
}
void loop(){
if(Serial.available()>0){
val=Serial.read();
if(val==100 && pos==0)
{
digitalWrite(led,HIGH);
pos=1;
}
else if(val==100 && pos==1)
{
digitalWrite(led,LOW);
pos=0;
}
}
}

If anyone can help i'd appreciate

that is what you are sending ... look at lower case d on this page  ... http://www.asciitable.com/mobile/

How can I convert that value 100 to the actual decimal value? I want to send a number not an ASCII code

Currently you are sending a number. The serial monitor is just interpreting it as ASCII (since that is what the serial monitor is supposed to do). Other serial terminal programs can also shoe you the byte data, where you could see the value 100. If you want to see it in serial monitor, you have to send ASCII encoded data with Serial.print()


text:
Arduino Libraries: Declaring variables as public?
How come I never see any Arduino Library expose some of it's internal variables as public in the header file? I only see functions which are declared as public, while every variable is declared private.
Background: I want to write my first Arduino library. And I thought of making some variables of this library public, so that I don't have to call a function later on when I import the library.
E.g. I want:
#include MyLibrary
...
MyLibrary instance();
instance.avariable = 12345;

instead of:
#include MyLibrary
...
MyLibrary instance();
instance.setVariable(12345);

Sometimes setting a variable isn't enough, as the library might have to do some additional thing with that new value. E.g. when setting the size of a buffer object, that object would also need to allocate memory for this (new) size. As far as I can see C++ doesn't have true getters and setters like other programming languages. getters and setters would make it seem like you are setting a variable, but will actually call a function.

I'd like to challenge the premise of this question.
Some Arduino classes do expose their member variables as public.
For example EERef exposes index, as does EEPtr.
Additonally, some classes declare their member variables as protectedso that inheriting clases can make use of them. The main reason though is usually because functions allow side effects to happen.

Classes are used to hide away the complexity of a certain task. The user of the class should not worry about how the library exactly works in the inside, but instead only worry about how it should be used. In many cases directly writing to a member variable can be not only convenient, but hurtful if a wrong value is set. If you instead use a function to set the variable, the author can add code to prevent wrong values from actually being written to the variable. Also there might be some other logic involved, that is not triggered, if you write directly to the variable. So - for the ease of use - the users might want the library to be responsible for this, not themselves.
If you write a library, you have thought about how it should be used. Hiding other ways away is a common way of leading the user through the usage. Ways of usage, that don't go along with the purpose of the library can be hided away to make the correct way clearer. A manufacturer of a saw doesn't give the user instructions how to use the wrong side of the blade, because it doesn't help you with sawing.
This does not mean, that you shouldn't make variables public at all, but only if it makes sense. For example: If you are defining a class, that just represents a point in a coordinate system without hooks to other code, it is totally OK to make the coordinates public. But if you defined the class, so that the point is directly shown on a display, you might want to change the position on the display, whenever one of the coordinates is changed. In this case you can use a set-function to trigger the display update, when a new value was given for the variable.

The Arduino ecosystem is meant mostly for beginners. This often means that people with very little knowledge will be using it and will often try random things to make stuff work. (and once they found something that works will teach it to the next guy that has the dame problem).
Disallowing things that would easily break the invariants of the library from the outset reduces the amount of support you need to give to people that inadvertently break the library by randomly changing some variable.


text:
Strage delay needed after Serial.read()
I'm using a RedBear Duo to read the Serial writes from a RedBear Nano v2. Basically, I use a digital pin of the Duo to raise an interrupt on the Nano. Once, the nano catches the interrupt it writes on its Serial.
You can find a minimum working example below:
RedBear Duo
#include <Wire.h>

/*BLE and WiFi setup*/
#if defined(ARDUINO)
SYSTEM_MODE(MANUAL);
#endif

char incomingByte;   // for incoming serial data

void setup() {
    Serial1.begin(115200);     // opens serial port, sets data rate to 9600 bps
    delay(500);
    Serial1.println("Begin!");
    Serial2.begin(115200);

    pinMode(D5, OUTPUT);
}

void readSerial() {
    while (Serial2.available() > 0) {
        incomingByte = Serial2.read();
        Serial1.print(incomingByte);
    }
    Serial1.println(" ");

}

void loop() {
    digitalWrite(D5, HIGH);
    readSerial();
    delay(2);     // Here's the delay I'm talking about
    digitalWrite(D5, LOW);
    delay(1000);
}

RedBear Nano
uint8_t fire;
void task_handle(void) {
    fire = 1;
}

void setup() {
    Serial.begin(115200);
    fire = 0;
    pinMode(D4, INPUT);
    attachInterrupt(D4, task_handle, RISING);
}

void loop() {
    if (fire == 1) {
        fire = 0;
        Serial.write("hello ");
        // Serial.println("fire");
        digitalWrite(D13, HIGH);
    }
    delay(150);
}

I found this question (https://electronics.stackexchange.com/questions/28739/arduino-delay-of-1ms-necessary-between-serial-read-and-serial-write), and I understood that the problem might be the fact that it takes a while to empty the Serial buffer.
However, I tried to bring the baudrate at 500000 (more than 3x) and still if I change the delay to delay(1), the code is not printing what it has received on the Serial.
I'm trying to understand what is really going on and why I need this delay(2).
Thanks a lot in advance!

declare the variable fire as volatile

Try this code: first delay produces 1ms pulse on pin D5. Without this delay the pulse could be too short for the nano to catch it (you can use delayUs and try finding the shortest interval that produces reliable result). We know that after this pulse, nano sends some data. So wait 100ms to collect it. If you call readSerial right after the pulse was sent, you won't get anything, because you need to wait at least for single byte transmission
void loop() {
    digitalWrite(D5, HIGH);
    delay(1);
    digitalWrite(D5, LOW);

    delay(100);
    readSerial();

    delay(1000);
}

This line is wrong:
attachInterrupt(D4, task_handle, RISING);

It should be:
attachInterrupt (digitalPinToInterrupt (4), task_handle, RISING);

In any case, attachInterrupt does not apply to D4, it is for D2 and D3 on the Atmega328P.
Note that the pin number is 4, not D4.


text:
Arduino: Digitally Muti-Switch - What is the proper term for hardware?
I have recently purchased a RoboMower. Like most of the automated mowers these use electric-fence wiring to mark the borders of the property and keep a small charge on those wires so that the mower can tell where the borders are. The  RoboMower I purchased is rated for 3/4 of an acre and I have 2.25 acres to mow.
As a result I was thinking of breaking my yard into multiple 3/4 or less acre zones and using an Arduino to shift which zone is active/has current in it so that the mower would follow those boundaries. The base station would be in a place where all zones overlapped slightly. Based on what day of the week it was, the Arduino would activate the proper zone, and the mower would go out and mow in that zone because it was active. I'd clearly have to schedule this so that the switch did not happen when the RoboMower was actively mowing or it would cause all sorts of issues.
In any case, my question is: What is the hardware called that I would need in order to activate one zone or the other? Is that called a digital switch or something else? Is there such a thing of one switch that would be able to switch multiple zones, or would I basically need a bunch of switches to individually control each zone?
Each zone is a loop of wire and therefore there would not be any shared wires between the zones.

The technical term of what you're looking for is demultiplexer. Note that the demux itself will not be enough to activate the zone, it will simply allow you to choose between different zones based on its input. It is still up to you to provide any further electronics required to enable the appropriate zone.


text:
Arduino Leonardo as keyboard for an iPad
I'm trying to make a Arduino Leonardo as a Keyboard for an iPad. I was successful with an Arduino UNO. However I'm hoping to use an ATmega 32U4 because of the better HID functionalities and smaller boards like the Beetle.
The problem I'm having is that when I connect the Leonardo to my iPad, the iPad shows an alert saying that the Leonardo is using too much power.

Tried running the board with an external power source. Then I get a different alert: Device not Supported.

At this point I believe that the problem is not necessarily power, but the fact that the Leonardo is announcing itself to the iPad and the iPad does not like it. In the UNO project, through re-flashing, the board acts only as a HID.
Is there a way to make the Leonardo (or other ATmega 32U4 based board) to not advertise itself on the USB port while allowing the HID functionality to operate?

If indeed the descriptor is the problem then yes you can change it.
In the core file USBCore.h is the line:
#define D_CONFIG(_totalLength,_interfaces) \
    { 9, 2, _totalLength,_interfaces, 1, 0, USB_CONFIG_BUS_POWERED | USB_CONFIG_REMOTE_WAKEUP, USB_CONFIG_POWER_MA(500) }

Just change the 500 to something smaller (it has to be an even number).
However it may be that the Leonardo isn't programmed to support the Boot Protocol for HID. In which case that would require bigger changes to the USB and HID stacks in the core.

Thanks! To deploy that change into a board, do I need to reprogram the bootlode

No, just reupload your sketch.

So when reduced from 500 to 100, the iPad does not complain about too much power anymore. Also, now it works like a keyboard!  But still will say 'device not supported' alert.

Probably needs a boot protocol compatible device then.

I'm considering just disabling the "Arduino Leonardo" USB device and just keeping the HID. If possible,

Not sure it'd be that easy to disable the CDC/ACM function of the device.

I am trying to get this to work on my iPhone with a adapter that supports both data and power. But the chip don’t even start up

i will stress now that i haven't tested this, and if it doesn't work you may have to reflash the bootloader in order to program the arduino again.
in the arduino install directory we are looking for the following file:
Arduino\hardware\arduino\avr\cores\arduino\main.cpp

at line 40 (i'm using 1.6.9) we have:
#if defined(USBCON)
    USBDevice.attach();
#endif

in theory if you comment this out the serial port may not be ennumerated, however i don't know if the keyboard functions will still work.
if it does work you should wrap it in an if block so that the serial port shows if a certain pin is pulled high/low whatever your preference. this would enable you to program it as normal.

Commenting that line did stop the device from enumerating the Arduino, but the Keyboard does not work anymore. And as you mentioned, the Arduino  needs re-flashing after to come back to life. Thanks!

I have found the solution - your USB > Lightning adapter must has the option for charging.
For example i use Arduino Leonardo connected to IPhone 6 by USB to adapter who has USB nest and charging nest. IPhone shows me info that "This device is not supported.", but all works fine and I can control IPhone by Arduino Leonardo.

@Majenko's solves the power issue. For me the "This device is not supported" is still a problem. That alter interrupts the initial Keyboard-iPad communication.


text:
Purpose of extra pin slots on Pololu DRV8835
I have a Pololu DRV8835 motor controller. I managed to properly solder and connect it and it actually works, however I've been wondering about the purpose of the extra pin slots - especially the ones without pins headers soldered to them on the right side of the picture below, but also the ones marked A and B (I assume these ones are an alternative way to connect to motors, though). I wasn't able to find anything about them, so I assumed that it may be obvious to someone who is not a complete beginner (like me). What, if anything, could I use them for if I soldered pin headers there?

A and B are the same as the A and B screw terminals.
The pins on the right, if you use your eyes and follow the traces, are the same as the pins that plug into the Arduino. I guess they are intended to be used to isolate the existing pin assignments (cut tracks on the underside between adjacent holes with a knife) and solder wires to other pins so you aren't limited to just using the pins they have assigned.

Thanks! What about the five pins next to the five you explained (the ones separated by white lines)?

They are all the same. Turn the board over and look at the traces. You can see they are joined. You can cut those traces that join them if you want to wire it to other pins on the Arduino instead, then when you want to undo it you can solder a wire between the holes to replace the track you cut.

The A and B through-holes are intended to let you connect the two motor channels together in parallel (M1A to M2A and M1B and M2B) to drive a single higher-current motor. See the section "Configuring the board for single-channel mode (parallel outputs)" on the product page (https://www.pololu.com/product/2511); there is a lot of other usage information there too.


text:
XBee s6b internet
For my project i need to send some data logged into a SD card to a remote server.
For this im using an XBee S6b wifi module connected to an arduino. ive had trouble connecting the xbee module to wifi. and also how can i set the ssid and other information through arduino?

You configure the XBee with AT commands. However there is one important thing to know about the XBee: it loves to be in "data" mode and won't stay in command mode while you play with it.
You need to first get into command mode by sending +++ with a delay each side of it:
delay(1000);
xBeeSerial.print(F("+++"));
delay(1000);

Then you can send commands:
// Set the SSID:
xBeeSerial.println(F("ATIDThis Is My SSID"));
// Set the wireless key:
xBeeSerial.println(F("ATPKTh!sI5mYk3Y"));

Once you have set the details you need to write the settings to flash and reset the XBee for the changes to take effect:
xBeeSerial.println(F("ATWR"));
xBeeSerial.println(F("ATFR"));

After each command you should really be looking for the "OK" response.
If at any time you don't sent anything for more than a few seconds the XBee will exit command mode and go back to data mode - at which point you will have to go back to command mode with the delays and +++.
It's easiest to configure the XBee using your computer and an XBee Explorer.
All the AT commands are detailed here.

thank you very much. so once i set the ssid and key and write them to the flash then how can i send the data that i want to a particular server over the internet. for example say that i have a server running and it waits for some POST data.

The X6B doesn't work like that. It is designed to create a virtual serial connection to another X6B. When not in command mode any data sent to it is sent to the destination IP and port. If it is in TCP mode and the connection isn't open it will open the connection and it will remain open until closed by the remote end. It is possible, if you are very careful, to get it to connect to a website to allow you to send a request, but it's not easy.

ok so can you suggest me something other than the xbee which i could use in my project. what i want is to send the data that i logged to a remote server over the internet

The most popular small module is the ESP-8266.

thank you very much i will look into it, if you know any place where i could quick start with a code please let me know.

There are examples all over the place, and hundreds of questions and answers on this site.


text:
arduino send logged data over wifi
I am working on air quality measuring project. it should be able to record gps and air quality data into a SD card and then when wifi is available it should send it to a server. Please help me decide the required hardware for this.
Can i use ESP8266 module to send this data

You need:

SD card + reader
GPS module
Air sensor
WIFI ESP 8266 should be ok
Arduino Uno or Mega, depending on if everything fits and calculations to be performed

Start with finding each component, read examples how to use them, than combine them.
Looks like a big project to start with if you are new to Arduino.

will i be able to send the data when ever a wifi is detected and while the data is being logged ?

@Yomal If you program it to do that, sure.


text:
Powering Uno with 9v battery makes it "freak out"
I encountered an odd problem with my Uno, it works completely fine through USB on the PC or when powered by a power bank, but as soon as I connect it on a 9v battery it just freaks out. I have a relay connected to it that is connected to a switch, works fine, but on the battery it keeps turning on and off super fast, like so fast that the relay doesn't even show it's doing it, I noticed because of the noise it makes. I even tried to slow it down with a delay but nothing changed.
Anyone have any idea why the battery would make this happen?

Use the battery in a smoke detector, but not for an arduino project. It is too weak for a relay.

Not enough current available from the battery, relays take quite a lot. As soon as the relay tries to switch the voltage drops and the Uno resets due to brownout (low voltage)

It's actually not just the relay that takes up a lot of current. The 9V-port on your arduino uno is actually not meant for a 9V block, because the arduino uno needs a higher current than your 9V block can deliver. You can put 6 1.5V battery cells (AA batteries) in series, they will deliver the current you'll need.

Really? I'm able to run my Arduino-based power control box just fine from a 9V battery, and it has a LCD display, piezo buzzer, 2 temp/humidity sensors, LEDs, a motion sensor, and various other components. (It drives power relays, but those are only powered when it's plugged into mains power.) Granted, the LCD backlight starts to dim when the 9V battery starts to run out of gas, and eventually the voltage droops to the point where it doesn't work any more, but it will run the whole project for a couple of hours.

Doesn't a fresh 9V have about 500mAh capacity? Should be enough for an hour if the Arduino draws 1/2 amp, which is enough for quite a few low power accessories on top of the Arduino itself.

@DuncanC the problem is that if someone grabs just any 9v battery, it might not be fresh and it might not be a good brand. The main problem is the maximum current that a 9v battery can deliver. A 9v battery with lithium is 1200mAh, that would be better (for a few hours).


text:
Best way to store files on Arduino
I was wondering what is the best way to store files on Arduino, I've seen that is possible using the SD Card module but I only want like 2/3 file texts so having a whole SD Card for that sounds a bit overkill, is there any other way to store files like that?
Cheers!

How much data are we talking about? How is the sketch using the data? Read every startup, read on processing input, write on..., etc.

If you want files, then you need a filesystem. The only simple to use and reliable things on an Arduino that have a filesystem are SD cards or USB memory sticks through the USB Host Shield.
However, most of what people think they want to store in "text files" is actually data that can better be stored in other ways. Using text to store numeric values that only the Arduino will ever see is pointless - store it as numeric values.
The most convenient place to store such values (if you don't have lots of them) is in the internal EEPROM.
If you have more than a few values you can use an external EEPROM or serial Flash chip to store larger amounts of data.
Anything more than that, though, and SD card rapidly becomes the most cost effective method.

Thanks for the answer!
Is it a read only memory or can it be changed multiple times? For example I just want to store things like settings and variables like time, but I need it to be able to be edited after, like changing the time when ever needed.

@Matthew it is possible to read and write multiple times on the eeprom, but as far as I know there is a relatively low physical write cycles limit, i.e. you can change the value of a given bit only say 10.000 times. This is not a problem if you store settings, but you must avoid things like writing the eeprom in a frequently repeated loop. That said, it is quite simple to use it, I think there is even a dedicated library which comes with the Arduino IDE.

Microchip have invented what they call "EERAM" - an SRAM with EEPROM backup that saves its settings using energy stored in a capacitor when the power is lost. Infinite write cycles to the SRAM portion and EEPROM rated at 100,000 backups. Look for the 47C16.

There's nothing that says you can't have a filesystem on a serial flash chip - or for that matter, there is no requirement that you use a filesystem with an SD card or a USB stick.  If doing a lot of operations, the typical fact that one tends to be a fixed mapping of blocks and the other has a wear leveling algorithm does need to be considered, but at a simple level the same storage schemes can work.

@ChrisStratton Yes, I know. I have written block device drivers for flash chips, internal flash, SRAM chips, etc for chipKIT's implementation of sdfat. The biggest negative point to using an FS on a flash chip is that of wear levelling. You tend to get a disproportionate number of writes to a small number of blocks prematurely ageing the flash chip. An SD card is easy to swap when it dies, a flash chip isn't.

Best way to store files on Arduino

what's best (or not) depends on your criteria, which you didn't articulate.
The simplest (and dumbest) way is to use a sd card. generally a waste of space and pins for small files.
the 2nd best is to use flash or eeprom: limited space and potentially risky. this can be partially addressed via out-board storage devices.
the best is to not store files on arduino: transmit the content away and let more capable devices to handle that.

The Arduino Uno uses the ATmega328P microcontroller. That microcontroller is able to write the EEPROM 100,000 times. As far as I know, that is 100,000 times per EEPROM location.
Suppose you want to run it for 10 years, then 10 years / 100k is about 1 hour. That means you can write to EEPROM every hour.
Storing settings is no problem. There is even a EEPROM.update function that only writes the data when the data has changed.
If you want to store the latest settings every second, then you need to look for something else.
Important note: When storing settings (in EEPROM or SD memory card) the Arduino could be powered off while it is busy writing. Those settings will not be valid. Therefor you might have to add a checksum, store a copy of the settings, and keep default settings in the code in case both the settings and its copy are not valid.


text:
Clear Timer on Compare or CTC in ATmega328P, Toggle OC0A on Compare Match
I want to use the CTC on the ATmega328P to play same notes with a speaker, a project that I find in this book.
In the data sheet I read:

For generating a waveform output in CTC mode, the OC0A output can be set to toggle its logical level on each compare match by setting the Compare Output mode bits to toggle mode (COM0A1:0 = 1). The OC0A value will not be visible on the port pin unless the data direction for the pin is set to output.

So I suppose that after I initialize the CTC and set as output the PIN PD5 (where I connected the speaker) the TCNT0 will change as a sawtooth wave (during time) and the PIN PD5 will be or 0V or 5V depending on the TCNT0 value. Is it correct?
So I change a little bit the code that is in the book:
#include <avr/io.h>
#include <util/delay.h>
#include "scale8.h" //Use to convert C2,C3 ... in numbers, for instance C2 = 100

static inline void initTimer(void) {         //Inializzazione del timer
    TCCR0A |= (1 << WGM01);                  /* CTC mode */
    TCCR0A |= (1 << COM0A0);                 /* Toggles pin each cycle through */
    TCCR0B |= (1 << CS00) | (1 << CS01);     /* CPU clock / 64 */
}

static inline void playNote(uint8_t period, uint16_t duration) {

    TCNT0 = 0;                                 /* reset the counter */
    OCR0A = period;                            /* set pitch */
    DDRD |= (1 << PD5);                        /* enable output on speaker */

    for(int i=0; i<duration; i++){             /* Variable delay */
        _delay_ms(1);
    }

    DDRD &= ~(1 << PD5);                        /* turn speaker off */
}

int main(void) {
    // -------- Inits --------- //
    initTimer();

    // ------ Event loop ------ //
    while (1) {
                                                    /* Play some notes */
        playNote(C2, 200);
        playNote(E2, 200);
        playNote(G2, 200);
        playNote(C3, 400);

        _delay_ms(1000);
        _delay_ms(1000);
        _delay_ms(1000);

    }
    return 0;
}

The problem is that the voltage of the PIN PD5 doesn't change! I try to print the voltage using serial but it's always 0V.

How are you measuring pin PD5? (PS I'd change TCCR0B |= (1 << CS00) | (1 << CS01);  to TCCR0B = (1 << CS00) | (1 << CS01);, so it doesn't depend on TCCR0B being zero.)

@Gerben Now I can't measure it directly, so I simple print PORTD and see the corresponding value of PD5. It's always 0.

The timer doesn't manipulate the port registers. It directly controls the physical port. PORTD doesn't get touched.

But reading PIND should reflect the actual values on the pins, no mater if it's alternate output (or even shorted output to the rail, you'll get that shorted level).


text:
Flow meter using Wemos Mini - ISR not in IRAM!
I'm trying to use a flow meter with Wemos Mini.
Most tutorials are using Arduino boards ( which code and HW work OK ), but since I want this device to send alerts over the internet when abnormal usage/leakage is detected, I want to use Wemos Mini using How to Use Water Flow Sensor - Arduino Tutorial. On top of if will add my code for notifications using Telegram.
BUT - after uploading the original code (before adding Telegram changes ), an error occurs during code run : ISR not in IRAM!
I tried to change Pin - but still getting this error,

Hve you seen this issue on github? They state, that you can avoid this error by prepending ICACHE_RAM_ATTR to ISR functions. Maybe you can try this.

this is an error in the original code and new versions of core check if the ISR handler is in IRAM, because without ICACHE_RAM_ATTR  the handler sometimes worked and sometimes not

This happens because of conflicts between Serial and external interrupts
Put ICACHE_RAM_ATTR before your interrupt function, like this  ICACHE_RAM_ATTR void ISR()

For WEMOS or NODEMCU you must predefine  interupt routine for example
void ICACHE_RAM_ATTR ServiceLimitSwitchUpperShield_12_D6();
//it is solve problem for ATTACHINTERRUPT - you must predefine this method before use setup (very important )
Then this message error ISR not IRAM will be not displayed .
In a setup you can for example define
attachInterrupt(digitalPinToInterrupt(12), ServiceLimitSwitchUpperShield_12_D6 , FALLING );
Look for page
https://community.blynk.cc/t/error-isr-not-in-iram/37426/23

this is not true


text:
EspMQTTClient inside a class
I'm trying to use EspMQTTClient inside a class, called myIOT32.
An error, which I don't find the reason for is generated.
/home/guy/Documents/git/Arduino/libraries/myIOTesp32/myIOTesp32.cpp: In lambda function:
/home/guy/Documents/git/Arduino/libraries/myIOTesp32/myIOTesp32.cpp:25:5: error: 'this' was not captured for this lambda function
     client.publish("mytopic/test", "This is a message sent 5 seconds later");
     ^
/home/guy/Documents/git/Arduino/libraries/myIOTesp32/myIOTesp32.cpp:25:5: error: invalid use of non-static data member 'myIOT32::client'
In file included from /home/guy/Documents/git/Arduino/libraries/myIOTesp32/myIOTesp32.cpp:1:0:
/home/guy/Documents/git/Arduino/libraries/myIOTesp32/myIOTesp32.h:20:19: note: declared here
     EspMQTTClient client;
                   ^
Multiple libraries were found for "WiFi.h"
 Used: /home/guy/.arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WiFi
 Not used: /home/guy/arduino-1.8.12/libraries/WiFi
exit status 1
Error compiling for board LOLIN D32.

.h file:
#ifndef myIOT32_h
#define myIOT32_h

// OTA libraries
#include <WiFi.h>
#include <ESPmDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>

#include "secrets.h"
#include "EspMQTTClient.h"
#include "Arduino.h"

class myIOT32
{
private:
    void onConnectionEstablished();  // <--- this is a must have function ( was taken as is from lib's built-in example

public:
    EspMQTTClient client;
    myIOT32(char *ssid, char *wifi_p, char *mqtt_broker, char *mqttU, char *mqttP, char *devTopic, int port = 1883);
};

#endif

.cpp file:
#include "myIOTesp32.h"

myIOT32::myIOT32(char *ssid, char *wifi_p, char *mqtt_broker, char *mqttU, char *mqttP, char *devTopic, int port)
    : client(ssid, wifi_p, mqtt_broker, mqttU, mqttP, devTopic, port)
{
}

void myIOT32::onConnectionEstablished()
{
  // Subscribe to "mytopic/test" and display received message to Serial
  client.subscribe("mytopic/test", [](const String & payload) {
    Serial.println(payload);
  });

  // Subscribe to "mytopic/wildcardtest/#" and display received message to Serial
  client.subscribe("mytopic/wildcardtest/#", [](const String & topic, const String & payload) {
    Serial.println(topic + ": " + payload);
  });

  // Publish a message to "mytopic/test"
  client.publish("mytopic/test", "This is a message"); // You can activate the retain flag by setting the third parameter to true

  // Execute delayed instructions
  client.executeDelayed(5 * 1000, []() {
    client.publish("mytopic/test", "This is a message sent 5 seconds later");
  });
}

Appreciate any help in constructing such a class

reordering Arduino.h did not solve.

For the fix, just add the reference capture and it should compile fine:
   // Execute delayed instructions
  client.executeDelayed(5 * 1000, [&]() {   // [&] instead []
    client.publish("mytopic/test", "This is a message sent 5 seconds later");
  });

I could not test, but you will have to apply to other functions as well.
[] Capture nothing
[&] Capture any referenced variable by reference
[=] Capture any referenced variable by making a copy


text:
How to create jumping wire using fritzing tool
I am tying to design my circuit diagram with the help of http://fritzing.org/home/ I designed like below circuit where wires are simply straight.

I want some kinda jumping wires with this tool. Does anyone know how to create these jumping wires ?

Draw the wires
press and hold control button (mouse pointer will appear with a curve symbol)
drag the wire using mouse

authors: Дмитрий Чикинев


text:
How to select which resistor is required for my curcuit to reduce voltage
I am trying to connect arduino and esp8266 as like this

I know arduino runs at 5V and RX of ESP8266 should not have voltage more than 3.5V. If you see my diagram there voltage is large than need on RX of ESP8266. I know resistor can help me for this and ohm law.
V = R.I => R = V/I

So I want to understand how should I select what ohm resistor for this cuicuit ? Can anyone explain with some calculation using ohm law ?

A voltage divider made with a 4.7KOhm between your +5V and input and a 10Kohm between your input and ground will result in a 10/14.7 ratio, giving you 3.4V on your input.
If you use a 5.6KOhm to +5V instead, your voltage will be 3.2V which may be a bit easier on the ESP8266.
The trick here is not the specific value of any resistor, but the relationship between two resistors.  You need to find a divider that will change 5 into 3.3 volts, a ratio of 0.66.  Thus, any resistor values where the value of the bottom one in the diagram below divided by the value of both resistors is close to 0.66 will work.  My suggestion would work equally well if you chose 1K Ohm and 470 Ohm.

Note that a voltage divider should only be used for signals and not for powering the ESP.

Well, yes this is my question how to decide what ohm is best for my circuit ? how did you decide 10Kohm will give 3.4 V ?

For a voltage divider, the trick is to find the right ratio between the two resistors.  In your case, the 5V potential to ground is split between the two resistors, let's call the one between 5V and your input R1, and the one between your input and ground R2.  The current reaching your input has passed through R1, so the potential between your input and ground is determined by the resistance of R2 divided by the sum of R1 and R2.  The Wikipedia page explains it better than what I can: https://en.wikipedia.org/wiki/Voltage_divider

To follow on from my other reply (ran out of space), you need to find a combination of resistor values that gives you R2/(R1+R2) similar to the ratio of your desired voltage (3.3V) and your original voltage (5V)  3.3/5 is 0.66.
any combination of resistors that give this ratio will give you 3.3V, given 5V in.

Well. "A voltage divider made with a 4.7KOhm between your +5V and input" - Do you mean "input" as RX of ESP8266 ?

Alright "ratio of your desired voltage (3.3V) and your original voltage (5V) 3.3/5 is 0.66." what .66 ? Do I need .66Kohm resitor ?

Yes that would be it.  (RX)
As for the resistor value, no, 0.66 is the ratio of the value of one resistor and both resistors.  Have a look at the Wikipedia page I linked to, it may be clearer then.

Let us continue this discussion in chat.

A resistor can only drop a certain voltage when there is a certain current - as you know from Ohm's Law.  If you have resistance R and current I the voltage dropped is R×I.
So if the current changes the voltage changes - and if the voltage changes the current changes.
So what do we do? Well, we have one known fixed value, and that is the 5V from the GPIO pin. And since that is fixed (at least when HIGH) we could add a fixed resistance to it to give a fixed current, right?
So let's do that. Pick a random value. Experience teaches you that certain values are better than others, but the actual value doesn't matter too much, as long as:

It's not so small that too much current flows out of the GPIO pin, thus damaging it, and
It doesn't create too high an output impedance, which we will come on to later.

10kΩ is a good figure to start with. Not only does it keep the current low enough, but it's pretty much guaranteed that you'll have one in your bits box somewhere. And we connect it to the GPIO like this (we completely ignore the ESP8266 for the moment):

simulate this circuit – Schematic created using CircuitLab
When TX is HIGH it's at 5V. It's connected directly across a 10kΩ resistor, so therefore we can use Ohm's Law to calculate the current - I=V÷R = 5 ÷ 10,000 = 0.0005, or 0.5mA. (Another useful thing with 10kΩ resistors is it makes calculations nice and easy).
Now, what if we were to split that resistor in half, so it was two 5kΩ resistors in series? The circuit would look like this:

simulate this circuit
Resistors in series add together, so those two 5kΩ resistors are the same as one 10kΩ resistor. We know that 0.5mA flows through 10kΩ at 5V, so the same must run through 5+5kΩ at 5V. But now we have two fixed value resistors. Because of that we can now apply Ohm's Law to each one to find the voltage drop across it.
So with 0.5mA flowing through a 5kΩ resistor we get V=I×R = 0.0005 × 5000 = 2.5V.  That's 2.5V across R1 and 2.5V across R2, since they are both the same. That's exactly 50% of the 5V across each one. At the point in the middle, point "A" on the schematic, you can see that the voltage has been cut in half. Once the current has gone through one resistor the voltage has halved (dropped by 2.5V), and when it goes through the other resistor it drops the rest to 0V, which is the other 2.5V.
If we were then to connect something to point A it would see a logic signal of 0V (LOW) and 2.5V (HIGH) from our 0V (LOW) and 5V (HIGH) signal.
But 2.5V is too low for the ESP8266 to read. Well, the answer is simple. We see that if we use two resistors we divide the voltage into two. The same applies for dividing it into three. For instance:

simulate this circuit
The sum is 10kΩ (well, 9.9kΩ but we'll call it 10kΩ for simplicity - a third each resistor, 3333.33Ω). 0.5mA through 3.3kΩ would be 0.0005 × 3333 = 1.66V. Funnily enough, 5 ÷ 3 = 1.66, so we have proved that it splits it into a third. That means at point A 1.66V of our 5V has been dropped (across R1), so 5V is now (5-1.66) 3.33V. Perfect for the ESP8266. Incidentally, point B would be 1.66V (3.33 - 1.66).
So now we have three resistors and the result we desire. However it's a little messy still. Remember that resistors in series add together? So why not add R2 and R3 together into a single resistor? That would be 6.6kΩ. Now I don't know of a 6.6kΩ resistor that's easily available, but 6.8kΩ ones are, though chances are you may not have one. If you did then a 3.3kΩ and a 6.8kΩ would net us near enough 3.3V to be usable.
But as I say you may not have one. So you pick resistor values that you do have. For instance you could use a 2.2kΩ and a 4.7kΩ, or a 10kΩ and a 22kΩ - anything that gives a roughly 1:2 ratio of value (the "upper" R1 resistor about half the value of the lower "R2" resistor).
Now - we get onto that mysterious phrase I mentioned earlier: Output Impedance. You recall we calculated the current that flows through the resistors - 0.5mA. The higher the value of resistors we use the lower the current. Well, that current not only flows through the resistors - a small amount also heads off into the ESP8266. The more that the ESP8266 wants for its RX pin the less there will be available for the R2 resistor. The result? Less current through the resistor = less voltage dropped across it.
The current drawn by the pin attached to point A on our circuit affects the voltage dropped across the resistors.
Too much current drawn and the voltage at point A will droop. Less will be dropped across the (current starved) R2, which means more must be dropped across R1. So point A is now a lower voltage. If that gets too low (too much current is drawn) then the RX pin can't read it properly.
Increasing the resistances decreases the current, but also decreasing the resistances increases the current. If the current is increased then the fraction of the current needed by the RX pin becomes reduced compared to what is available, so the output voltage drops less.
This output impedance, in case you're interested, is measured in Ohms, and is the same as the value of the two resistors in parallel - so (R1×R2)÷(R1+R2).
For instance, I tried connecting an ESP8266 the other day using 3 10kΩ resistors - R1 = 10K, R2 = 20K. It didn't work. You'd expect it to, given the ratios involved, however the output impedance (6.66kΩ) was too high for the ESP8266 I was using. Replacing them for 1kΩ resistors, so it was 666Ω output impedance, made it work straight away.
You can understand it easier if you think of the ESP8266 as just another resistor (it's actually more complex than that - it's also like a capacitor, so it forms a low pass filter which limits the frequency of, and deforms the shape of, the incoming digital waveform). For example:

simulate this circuit
I have deliberately shown the ESP8266 as a lower resistance that it would really be (you can expect MΩ) so as to illustrate the problem clearer.
Your R2 now has R(esp) in parallel with it. So the nice clean 20kΩ is now actually (20,000 × 100,000) ÷ (20,000 + 100,000) = 16.66kΩ. That gives us a total of 26.66kΩ, and at 5V that means a current of 0.188mA. Through the 10kΩ resistor we end up with (10,000 * 0.000188) 1.875V dropped. Take that from 5V and you can see that the ESP8266 would only be getting 3.125V.
By reducing the resistors in our network the difference that R(esp) makes to R2 reduces. For instance, reducing it to 1kΩ + 2kΩ gives us an R2 total of (2,000 * 100,000) ÷ (2,000 + 100,000) = 1.96kΩ - hardly any different from the 2kΩ we started with, so the voltage difference will be minimal (3.31 as opposed to the ideal 3.33).
The simple formula for calculating the output voltage from an input voltage and pair of resistors, so you don't have to go long-hand through Ohm's Law every time (though it is useful for understanding exactly what is happening) is:
Vout = R2 ÷ (R1 + R2) × Vin
I can never remember it, though, and usually use an online voltage divider calculator.

Bravo.  If only I was able to explain as clearly I would have been happy as can be.

@ErikHB The trick is to read the question on your phone in bed when you wake up, then get up (a while later), have bacon and eggs, followed by a big mug of strong black coffee, and then write an answer ;)

@Majenko Awesome!! Thanks a lot :) +1

You made my day @Majenko :) Too much useful I went to have cofee and read it while have it :) I will try it once I resolve some issues which I am facing right now.

This is the best anwer I've seen in a long time. With this simple and easily explained example, we went through many of the basic concepts of the electronics. Super helpful.


text:
How to connect arduino with local network
I am trying to connect Arduino with local network. This will act as a web server, client would be android mobile app or web browser. These are on same local network.
Do I need Ethernet Shield or ESP8266 to make Arduino accessible with local network IP ? Is there any way to connect without Ethernet Shield ?

To connect to a network you need a network interface.  This could be an Ethernet interface, a Wifi interface or something that supports TCP/IP.  The easiest way of doing this is with ether an Ethernet 'shield' of a WIFI 'shield'.
In either case there are a range of options, from full shields to smaller boards that connect via jumper wires.  One important consideration is the longer the wires the more chance for signal degradation and loss of comms.  So direct plug in boards are probably better.
Probably the easiest way to do it is to use a ESP8266-??, but using an ESP as a network interface is like only using your PC for email.  The ESP is faster and has more memory than the Arduino, so it would be better to program that as the web-server and get the Arduino to feed it the data.
You could use Bluetooth, radio, etc, but that's just making life hard for yourself.
You could also look at the Arduinos that have networking built in.

If I deploy my web services code on IBM Bluemix or AWS then Can ESP8266 communicate with those servers ?

If they support raw TCP/IP communications yes.  If they support HTTP, REST or SOAP, yes.  If they need web-sockets, maybe if you can find a WS library for the ESP8266.

Thanks. Do you have any links which can help me to connect Arduino with ESP8266 on network ?

@Williams - The best place to look is the examples that come with the ESP extensions for the IDE.  Go to board manager, download the ESP stuff and have a look.

If you get yourself a board with an ESP8266 (say, Wemos D1, NodeMCU etc) this will allow you to do what you require and connect wirelessly to a local network. You can do this either with the Arduino using the ESP8266 as a shield or alternatively you can use the 8266 board on its own (it's a more powerful MCU than the Arduino!!)
Hope this helps.


text:
Can the 'Adafruit Non-Latching Mini Relay FeatherWing' be used with an Arduino microcontroller such as an Arduino Mega 2560?
Can this relay found here:
https://www.adafruit.com/product/2895
Be used with an Arduino Mega? The description given seems to specify that you should hook it up to their dedicated 'Featherwing Board' but it's the only relay available on their site. Looking at the pins it has it seems it should hook up to an Arduino with no problems. Has anyone here had the chance to use this relay with an Arduino microcontroller? I asked them about this on their forum but I haven't received a reply yet.
PS: I want to use it to connect a 'Strobe Siren 12VDC' and the relay I was looking to get is out of stock at my local shop.
https://store.nerokas.co.ke/index.php?route=product/product&product_id=1398
https://store.nerokas.co.ke/index.php?route=product/product&product_id=1679

Yes.
There's not a lot more to be said really.
It's a relay, and they provide a MOSFET and associated circuitry to drive it cleanly.
Just connect power and ground to the Arduino, along with the "Signal" pin to the GPIO pin of your choice, and away you go.
Note that the relay is a 3.3V relay, so you must power it by the 3.3V pin, not the 5V pin.

That relay draws way, WAAAY more power than the 3.3V line on and Arduino puts out. The data sheet says it draws 100-200mW. That's just the relay. The logic circuitry and LED will probably draw 20-50mW more than that. As I recall the 3.3V line on most Arduinos only provides ≈50mA of 3.3V, which is completely inadequate.

@DuncanC That was the case 10 years ago. Back then the 3.3V pin was powered by the internal 3.3V regulator in the FT232R chip. That is no longer the case, and hasn't been for many years (since the Uno R2). Now it has a dedicated 3.3V regulator that can provide a few hundred mA (LP2985 - 150mA).

At 3.3V, 200mW is 60mA. The LED has a 1k resistor, so would be around 3mA.  That's 63mA - less than half what the regulator can provide.

Ok, that relay quotes 200 mW, not 200mA. That isn't quite as bad as I thought. However, the Arduino store says the current limit of the 3.3V line is 50mA, and that's still over the limit: https://store.arduino.cc/usa/arduino-uno-rev3

To quote the specs tab on that page: "DC Current for 3.3V Pin 50 mA". And that's from the page for the current Rev3 board.

@DuncanC Never trust anything Arduino say.  Those specs are for the original R1 UNO and have never been updated.

@DuncanC If you don't believe me, then get the schematic from the same page, find the 3.3V regulator, and then download the datasheet from TI.

@DuncanC The hardware design branch of Arduino is "ok". The website management team are a bunch of useless faggots. You just have to look at some of their "tutorials" to realise that...

The regulator might be up to more current than that, but I don't think they are adequately heat-sinked for that. (In fact I don't think the regulators on Arduinos have any heat sinks at all.)

@DuncanC The LP2985 is perfectly fine running at those levels. It's only got to drop down from 5V (less sometimes if it's powered from USB...), and they can handle that kind of curent quite well. I use them all the time.

@DuncanC By the way - you don't heat sink an SOT23. They're designed to heat sink just through the pins. They don't generate enough heat to need more than that.

@DuncanC By the way II - Microchip do a pin-compatible device that is rated to 300mA. They rate it double because the input voltage is limited to 5V (or just over) unlike the 16V of the LP2985.

That is a 3.3V device. you'll need to give it a separate 3.3V power input, and it needs much higher current at 3.3V than the Arduino can supply.
I don't know if you can feed it a 5V logic signal or not. (If it needs 3.3 V control signals as well, and it's current needs are modest you could step down the voltage from an Arduino 5V digital output to 3.3 with a simple voltage divider circuit.)
You'd be better off getting a 5V relay. If you do a Google search on "Arduino Relay" you'll find tons of them. You can get 1 relay, 2 relay, 4 relay, and more on a board. Many have optical isolation to make sure the relay coils don't add noise to the logic lines.
In general it's a good idea to use a separate power supply for the relay, or at least use a power supply with plenty of current to spare, and add filtering capacitors between the 5V rail and ground right next to both the relay and the Arduino. These capacitors serve to filter out variations in voltage as the relay coils are powered on and off.
(Even "digital" relays draw a large amount of current from their power source when they first turn on, and abruptly stop drawing current when they turn off, which introduces a lot of noise on the power line. "Naked" relays need "flyback diodes" to avoid reverse currents that will destroy transistors, but the "digital ready" relays I'm talking about have those built in.)
Here is one such relay I found from Googling "Arduino relay".
https://vetco.net/products/single-relay-module-for-arduino?gclid=EAIaIQobChMI8Ye70K-e4QIVBkSGCh2EBgEiEAQYAyABEgIxpvD_BwE


text:
Low Level programming - MKR Fox1200
I'm working on a project using this board and wish to do so on a low level ,as in enabling certain registers to enable interrupts etc.
I can't seem to find the correct header files to support programming in this manner (Can't recognise the register names), I've tried using both Atmel Studio and the Arduino IDE but can't seem to get it to work.
Any help would be greatly appreciated

What kind of "low level" do you mean?  Why not look up the chip data sheet?  For example: https://www.mouser.com/ds/2/268/atmel-42181-sam-d21_datasheet-1065532.pdf

If you have installed the MKL Fox 1200 on your computer, then the needed header files are also installed.  They can be rather difficult to find, however the find command works well for this job

I programming from the datasheet, I have the header files imported manually but it doesn't seem to work correctly


text:
Trying to save .wav files with new name every loop
I have built a set up with an Arduino UNO hooked up to a switch, so that whenever the switch goes from HIGH to LOW it saves audio to an SD card. I am using the TMRpcm Library. The problem is the current code will only be able to record 1 audio file; I want to the Arduino to run for a long period of time collecting multiple audio files as the switch is turned on and off. I need a way that will allow it so everytime the switch is pushed back down the next file saved will have a different name than the one previously saved (preferably by an increased numeric value eg "1.wav" & "2.wav"). I have tried audio.startRecording(audiofile+".wav", 16000, A0); and it makes it so no files save to the SD card accept an empty file simple titled 'WAV'. I have tried using a switch case but it will not allow me to reach a case over 10, without running out of RAM. Currently, my code can save 1 audio file but I want it to reach a point where it can save as many as the SD card can hold, without having to restart the software.
My current code is here. Any help would be greatly appreciated
//////////////////////////////////////// SD CARD
#include <SD.h>
#include <SPI.h>
#include <TMRpcm.h>
#define SD_ChipSelectPin 10
TMRpcm audio;
//////////////////////////////////////// SWITCH CASE
int audiofile = 0;     // # of recording
unsigned long i = 0;
bool recmode = 0;      // recording state
//////////////////////////////////////// SWITCH
int inPin = 2;         // input Switch Pin
int state = HIGH;      // the current state switch
int reading;           // the current reading from the switch

void setup() {
  Serial.begin(9600);
  pinMode(A0, INPUT);  // Microphone
  pinMode(inPin, INPUT_PULLUP); // Switch
  //////////////////////////////////////// SD CARD
  SD.begin(SD_ChipSelectPin);
  audio.CSPin = SD_ChipSelectPin;
}

void loop() {

  reading = digitalRead(inPin);
  ////////////////////////////////////////
  while (i < 300000) {
    i++;
  }
  i = 0;
  ////////////////////////////////////////
  if (reading == LOW) {
    if (recmode == 0) {
      recmode = 1;

      Serial.println("Recording");

      audiofile++; // To move case
      audio.startRecording("1.wav", 16000, A0);
    }
  }
  ////////////////////////////////////////
  else if (reading == HIGH) {
    recmode = 0;

    Serial.println("Hung-Up");
    audio.stopRecording("1.wav");
  }
}

You cannot simply add an integer to a string literal with audiofile + ".WAV", because of the different types. But you can use a char buffer and sprintf("%i.WAV",audiofile);

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

@chrisl Thank you very much, this almost solved all my issues!

@per1234 my apologies. I am new to forums as of today and am learning the ground rules on how to properly use them. Thank you for the heads up!

I would (and do) use snprintf to format a string as a filename:
// Global scope, or local static
uint32_t myFileNumber = 1;
char filename[12];

// in your function - results in 00000001.WAV
snprintf(filename, 12, "%08d.WAV", myFileNumber);

%08d will allow between 00000000.WAV and 99999999.WAV and always with 8 digits. Any more and it will get truncated and corrupted (100000000.WA) but won't cause a buffer overrun. You will have to take precautions that you never have more than 100 million files ;)


text:
Motor unexpectedly moving at reset
I'm playing with the standard L298N motor board and Arduino MKR 1000. However something strange happens: when I upload a new firmware and when I turn on the Arduino power supply (every time Arduino resets) the motors unexpectedly move for 2 seconds.

From what I've seen in other questions, it should be enough to pull down the pwm signal (in fact it seems that the floating status of these pin in the reset procedure produces this problem). I used a 10k resistor as suggested, but with no effect.
I've tried also a 100 ohm resistor: in this case the motor makes some noise but it doesn't move. However, it won't move when it is supposed to in the loop section.
I've also tried to pull down all the three signals (enable, in1, in2) of the motor but with no difference. I've also tried to pull up to 5V, instead of pulling down: same issue at reset, but the motor spinning in the other direction.
I've also tried to put a relay controlling the motor external supply. However the reset procedure also turn 'on' the relay (no progress on the problem).
It isn't a software issue because it happens with an almost empty sketch. Same software+circuit on Arduino UNO doesn't cause the problem.
What should I do?

standard L298N motor board ... there is no such thing as standard board

https://arduino.stackexchange.com/questions/16438/when-the-arduino-is-in-reset-mode-are-the-digital-pins-high-impedance

@jsotola thanks for the link.. I've tried lots of different pins so I don't think it's something strictly related to a particular pin, but more of a general issue with high impedance state in MKR1000... so I can't understand how should I fix it..

put 1k resistors between the arduino output pin and ground .... if it works, increase the resistance until it fails again

@jsotola I tried 1k but with no result. When I put a 100 ohm resistor then it can't move at reset, but it also won't move when I want to!

i just noticed that you are using the Arduino MKR 1000 which uses the ATSAMW25H18-MR510PB microcontroller, therefore the link that I posted does not apply ....... do not use low value pulldown resistors

try posting at this website  .... https://community.atmel.com/forum/atsamw25h18-inconsistent-results

maybe something can be found here about the initial state of I/O pins ....   http://ww1.microchip.com/downloads/en/DeviceDoc/40001882A.pdf  ........ http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-42436-SAMW25-MR210PA-HW-Design-Guidelines_UserGuide.pdf

something may be here .... https://github.com/arduino/ArduinoCore-samd/tree/master/bootloaders/zero

@jsotola I'm sorry but I don't have an in-depth knowledge in this field, so I still don't know what could I do..

Try to add an capacitor between reset and GND https://goo.gl/images/rFMyho

@Coder_fox I don't want to prevent reset when I open the COM port.. In fact the problem is related to microcontroller initialization and of course happens also when I plug in the power supply..

@Surferonthefall ok but than the board woun't reset at all


text:
I need to restart Arduino IDE after each compilations
I'm using the Arduino Due and testing an I2C Scanner, the I2C Scanner works correctly but each time I want to upload a newer version of the code I get this error message :
No device found on COM11
Send auto-baud
Set binary mode

What I need to do in this case is : remove USB, restart the Arduino IDE, reconnect USB, then it works again, one time...
It seems related to this problem : Serial port on mac only works after restarting arduino IDE
I'm not sure but What's maybe also symptomatic is I need to systematically push the restart Button of my board in order to receive something in the Serial Monitor, could it be related ?
Here is the I2C Scanner code I'm using :
// --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// Version 6, November 27, 2015.
//    Added waiting for the Leonardo serial communication.
//
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#include <Wire.h>

void setup()
{
  Wire.begin();

  Serial.begin(9600);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}

void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknown error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(1000);           // wait 5 seconds for next scan
}

IDE version? Native or UART port?

IDE is 1.6.12, I use the Native port

And if you try the current version, 1.8.2?

I finally solved the problem, but it's really specific and I don't know if should be on Stack Exchange. Maybe it could give some clues if someone has a similar problem one day...
I was using pin 20 and 21 on my Arduino Due which are supposed to have built-in pull-up resistor. That's what I've read everywhere and it has been said again recently in the answer of an another question I've asked : How to chooce SDA/SCL pair on Arduino Due ?.
Solution : Since I'm using SDA1 / SCL1 with Wire1 everything works like a charm. The value I get from the device are correct, no need anymore to restart the board and I can recompile again and again without any problems.
Edit : In fact, it work significantly better but I still had to use pullup resistors with these inputs. The goal was to use the MPU 9250 and it seems more stable now.


text:
Can I call functions from a different sketch?
I am a beginner at programming with Arduino and I am unsure on how can I call functions (such as, getData()) for the touchscreen LCD to display that data. The purpose of my device would be to listen to data communications between sensors and a controller and thus I have one RedBoard with CAN-BUS shield with a dataComms.ino sketch, which initialises getting data functions from received data packets and parses them.
Do I need to create another sketch for the display? If so, how can I call functions from another sketch, so that display.ino would have access to received values? Or are there some better ways of displaying data?

You can only use one sketch at a time, meaning one sketch can be stored inside an Arduino to be executed.
This means all your code (and functionality for all devices you want to access) needs to be within that single sketch.
So what you mostly need to do is:

Add a library for every device that you want to use.
Call functions from that library in your .ino file.
If you want to add functions which are not part of a library, you add both the function code and the call (where you need it) in your .ino file.

Also if you are new, don't start with everything at the same time.

First find an example how to control the display (that's probably easier than the CAN shield).
Add the library for the display
Change (or copy from an example) code for the display
Run and debug it until it works.
Create a new sketch for the CAN shield.
Add the library for the CAN shield.
Call functions from that library (or use an example if available).
Once you are convinced you know how to use both devices (display + CAN), combine the sketches (create a new sketch, add both libraries, copy code and make it one sketch).

Thanks a TON! Does it mean that my .ino file acts as a main, through which I need to setup CAN Shield and LCD? Also, I suppose I will need to create .cpp and .h files to create libraries for both of the devices as well, won't I? (For prototypes and variable declarations)

I hope you already have the libraries (or they are existing).. Creating a library for a beginner is far from easy. The Arduino IDE has a mechanism already to add libraries (Manage/Add libraries or something, I don't have the IDE at hand). Your .ino file has two functions: setup (initializing) and loop (run continously). Main is hidden in the framework that Arduino IDE generates and it calls the setup and loop. Check for some basic examples.