ESP8266 Wemos D1 Retrieving Wrong AP Mac Address

This seems wrong, you are trying to get String to interpret a byte, but are passing in a pointer to a byte:

String digit = String(*mac, HEX);

Try changing your example to:

uint8_t* mac=WiFi.BSSID();              // Gather the byte array
String APmac;
for (int i=0; i<6;i++) {
   String digit = String(mac[i], HEX);  // String() should see an int, not a pointer to a byte, with the directive to print it in HEX format
   if (digit.length() <2)
     APmac += String("0")+digit;        // Corrected capitalization error
   else
     APmac +=digit;                     // Corrected capitalization error
   //mac++;                             // Not necessary
   Serial.print("["); Serial.print(i); Serial.print("]");
   Serial.println(mac[i], HEX);
}
Serial.println(APmac);                  // Print the constructed String
Serial.println(WiFi.BSSIDstr());        // Print the pre-formatted string

Consider not using the String object, which may help condense the code a bit:

uint8_t* mac=WiFi.BSSID();
char APmac[13];
APmac[0]=0;
for (int i=0; i<6;i++) {
   char buffer[3];
   sprintf(buffer, "%02x", mac[i]);
   strncpy((char *)(APmac+(i*2)), buffer, 3);
   Serial.print("["); Serial.print(i); Serial.print("]"); Serial.println(buffer);
}
Serial.println(APmac);
Serial.println(WiFi.BSSIDstr());


What is the type parameter on the NRF24NetworkHeader member

It's to identify the type of packet.  Apparently that code supports types of 0-127, and I guess (impossible to tell without digging into the code) that what you use them for is entirely up to you.  Basically it would typically define what is in the rest of the packet - again something which is up to you.


Battery voltage monitor right after deep sleep

Using "battery level" (voltage)  is poor way to monitor its useful life. Battery discharge  characteristic varies with its technology.
On the other hand many electronics devices are very tolerable as far as "supply level " AKA voltage.

RGB LED light intensity can be made to monitor different voltage, however, I fail to see how you propose to send the LED intensity level /state to other device.

Addendum

As I pointed out - the battery useful life depends on technology.
You mentioned AAA , hence I assume alkaline battery.
Then I would suggest software solution.
Let the server monitor the actual running time of your device.Then measure or calculate the load your device is drawing from the battery.
Then determine or calculate the discharge curve of your battery and let the server "output" the battery life / discharged level in relation to time. Perhaps I misunderstood and you actually wanted the RGB LED to be connected to the server. Then you can display green LED up to 80% of battery life and so on ...Keep in mind that the discharge curve is pretty abrupt at the end of battery useful life,


This line is where you are reading the data and printing it:

Serial.print(scale.get_units(), 1);

The 1 on the end of the line defines how many digits you are displaying from your reading. I have a similar setup to yours and I have it set to 5 which shows up to +/-0.00001kg. (Obviously, the accuracy will be different depending on which load cell you have)


SoftwareSerial returns garbage when powered externally

If you check the specifications they stat 12VDC is the max.  Your on board regulator is probably very hot and either shutting down or allowing the voltage to sag.  You can get a 9V wall Wart for under $5.  the 9V will keep the on-board regulator much cooler and add reliability.


If any kind of character gets loaded into a string, what do I use for an end-of-line character?

Framing binary messages is not as simple as choosing a delimiter.
Counting the characters could be an option, but you need some way to
check that your reception has not gotten out of sync. You could for
example send messages that looks like:

struct Message {
    uint32_t magic;
    uint8_t data[MEM_LEN];
    uint16_t crc;
};

Where magic in a magic number, i.e. a random but fixed value that
is very unlikely to happen by accident, and you end the message with a
CRC. On the Python side, you check that both the magic number and
the CRC are OK. If they are not, you have a communication error, but you
can re-synchronize by looking for the next occurrence of the magic
number.
Another option is to choose both a delimiter (say, ASCII 10 = LF =
'\n') and an escape character (say, ASCII 92 = backslash = '\\'). On
the sending side, you prefix by the escape character every accidental
occurrence of either the escape character or the delimiter:
void send_byte(uint8_t c)
{
    if (c == '\\' || c == '\n')
        Serial.write('\\');  // prefix by escape character
    Serial.write(c);
}

and on the Python side you do the reverse operation. The only issue with
this approach is that your messages are not constant size anymore.


Trying to verify that Arduino Pro Micro ISP is working

As Mikael Patel notes, pin 10 on the programmer Pro Micro should run to RST on the target.

That might or might not fix the problem.  In some previous instances of the “Yikes! Invalid device signature” [1,2] bad breadboard connections turned out to be the problem.  I suggest you run a second (or even a third) set of jumpers in parallel with the first set.  Of course use matching colors to avoid confusion.


What does serial monitor send with 'Both NL & CR'

Newline is \n

Carriage Return is \r

Both NL & CR is \r\n


Diode lights generate false interruptions

Aaaaah, ok, now I see...

You put

  +5V - Reed - LED - input pin - 1k resistor - ground

right?

If so the problem is that a red led has (usually) a voltage drop of about 1.5V, while the green one has a voltage drop of 1.8V-2.0V. The Atmega 328P has a Vih (i.e. the minimum voltage needed for a reliable high) of 0.6*Vcc, so for a 5V supply this value is 3V.

Consequently with a green LED you will have a value TOO CLOSE to the minimum acceptable value for the input pin. Note that the 2.0V value is an usual one, but different leds have different voltages.

Moreover the so-called high-brightness leds (the ones with a transparent case) have a more-than-3V voltage drop, so if you put for instance a blue led you will never receive a signal.

To solve the problem, you have three solutions:

1) use a (low brightness) red led also for the green path
2) remove the led from that path and drive it directly with the arduino (you will have also the notification that arduino has understood the command)
3) change the path to

  +5V - Reed - input pin - LED - 1k resistor - ground

(i.e. take the voltage BEFORE the led, not after)

I think it'll work then :)

EDIT: according to the data I found on the internet the red led is usually 1.8V, while the green one is usually 2.1V. This does not change my answer, anyway.

And... You won't "fry" your pins with the 5V you are prividing to the circuit....


This probe has the Dallas (now Maxim) DS18b20 sensor in it so you're already on the right track. Search for DS18b20 at arduino.cc. You'll find libraries and lots of forum discussions about using these sensors.
Also see page 6 of the DS18b20 datasheet; there are two schematics for wiring the device.

I'm using the parasitic mode (Figure 4 on that page) except I eliminated the transistor switch and connected the MCU pin for the strong-pullup directly to the one-wire bus.


You've got two possibilities:

You can't have full off in "non-inverting PWM" mode
You can't have full on in "inverting PWM" mode

In the Arduino core it's solved by turning off the PWM output and setting logical 0 or 1 for corner values.

And if you need full off but you don't need full on, you can use inverted PWM mode.


I suggest you look into using a hardware timer rather than using delay(), I suspect it will give you more accurate timing.

Timer configuration is not as straight forwards as using delay - they don't work in milliseconds or microseconds, but instead in multiples of clock cycles, which (I find) makes configuring them a little difficult to understand, but it is possible to set the interval of a timer within its own interrupt routine.

Another advantage to using timers is that your code can do other things whilst waiting between interrupts.

Have a read here for more information and simple examples:
http://playground.arduino.cc/code/timer1
or just Google "Arduino timers" for other examples and explanations.


Powering Arduino Uno, CAN Crocodile and NeoPixels from Car

A reasonable estimate for current consumption of 5V NeoPixels is 60mA per pixel. For 186 pixels, that means about 11.16A at 5V; well over the 2.4A of the adapter being used for your other components.

There exist modules called "DC-to-DC Buck Converters", which can step down the 12-14V of your automobile to pretty much any voltage under the input voltage. To be safe, look for a buck converter of at least a 75W rating, and which meets your criteria for input and output range (minimum of 12V input, could be rated higher; output range inclusive of 5V.)

Be sure that the Ground connections for the NeoPixel power supply and the other supply are shared/connected, but don't share the +5V line between supplies.


There were a couple of comments that both led to the solution.

For me the most important was Nick's that the board pretends to have a USB interface for a couple of seconds, and then runs the sketch.  It stopped me tearing my hair out over why the board didn't show up as a port.

Ignacio suggested using Micronucleus.  I did this having installed the Digistump drivers and selecting them.

After compiling I was prompted to plug in the board, voila, it uploaded.

Thanks Stack Exchange!


How to burn a firmware to ESP32 Devkit V1 by using MacBook Pro with USB Type C Adapter?

My problem is solved. Finally, I found out my Micro-USB cable doesn't support date transfer/sync function.


Value of joystick reduces when I send it over serial

A fundamental lack of understanding of how serial communications works is what you have.

Serial sends bytes. You are attempting to read an int. The two don't match. Not only that, but you are sending the value as text, not a number, so you're interpreting it as gibberish.

My suggestion: do the map on the master not the slave, and send a raw byte between 0 and 255 not a string of text between "0" and "1023".

bluetooth.write(map(yVal, 0, 1023, 0, 255));


strtok() command with Serial communicaton

only a syntax typo. the condition should be if ( i == 46 ) {

if this is not only a strtok test, the you do not need strtok. read in char c, and if c == ' ', print vD and reset i to 0

and I do not see where you set the terminating 0 of vD a.k.a. a


My Ruggeduino stopped showing up as a serial device under El Capitan (10.11.6). I was able to fix this by installing/updating the VCP drivers for Silicon Labs USB devices available here:

https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx

After installing the Mac driver the Ruggeduino shows up as SLAB_USBtoUART and works fine with the Arduino GUI.


Can I use the same Data Registry for both input and output pins?

Assuming the button is connected between GND and pin 10, without any pull-ups or pull-downs.

void setup () {
    //For the led output I know that I would do this
    DDRB = 0;             // set all pins on port B to INPUT
    DDRB |= _BV(DDB7);   // set PB7 to OUTPUT
    PORTB = 0;            // set all pins on port B to LOW
    PORTB |= _BV(PORTB4); // enable the pull-up resistor on PB4
}

void loop () {
    if( PINB & _BV(PINB4) )
    {
        // if bit PINB4 is set, the button is not pressed
        PORTB &= ~_BV(PORTB7); // turn off led
    }
    else
    {
        PORTB |= _BV(PORTB7); // turn off led
    }
}


Power on reset with arduino uno can never happen. Can this be fixed?

See 'DTR-reset' circuit of Arduino Uno below.

After powering-on, when DTR is set low (because a sketch is coming in) the falling edge causes a negative pulse on the 328P's external reset pin of ca. 3 ms (see here). The width of this reset pulse is independent of the time that DTR stays low.

During powering-on the 328P's reset pin is low until the capacitor C5 is sufficiently charged. How long this takes depends mainly on the start-up behavior of Vcc. When DTR is low the capacitor will charge faster because RN2D (from capacitor C5 to ground) is bypassed.

But the main thing is that the power-on reset and the external reset have the same effect (see datasheet): when the rising voltage passes a certain threshold a timer is started and after it times out program execution starts at 0x0000 or at the Boot Reset Address (depending on the setting of the fuses). So, in the powering-on situation it makes no sense to differentiate between Power On Reset and External Reset.


portd not writing on digital ports 5 and 7

This is because on ATmega 32u4, which is used in Arduino Leonardo,  pins 5 and 7 are not mapped to port D but to port C and E respectively, as you can see in the ATmega 32u4 - Arduino Pin Mapping.

So you will have to:

either find another port where all 8 bits are available as digital outputs (note that I'm not sure one such port exists)
or split each sine[i] in 2 parts because you will have to work with 2 ports at the same time.


Your UID has 4 bytes, which correspond to 32 bits. To get a decimal value from these bytes, you have to put them together in one variable. For this you can use an unsigned long. To put the bytes together, you can shift the values to the byte boundaries:

unsigned long dec_value = (D << 24) | (C << 16) | (B << 8) | A;

<< shifts the bits of the byte by the specified amount of bits to the left; The bitwise OR | puts the now not overlapping bytes together in one value. I have reversed the order of the bytes in this code, as you wrote, that this is necessary.

To convert this unsigned long to a string you can use the function ltoa():

char buf[50];
ltoa(dec_value, buf, 10);  // 10 is the base value not the size - look up ltoa for avr

If you want to use a String object (which should be avoided because of heap fragmentation), you can contruct the String directly from the long value:

String my_UID = String(dec_value);


You could use https://en.wikipedia.org/wiki/Ngspice.
From what is written there, the Xspice part could be used for creating a simple model of the Arduino, for checking how the analog part of your circuit interacts with the uC.
Unfortunately the main site () is down, atm, as many other projects hosted on SourceForge. But it might be worth having a look, once it's back online.


as @Andre said on comment, you give variable 'Timer' a new value each loop. One of the solution is putting Timer = millis(); on the void setup instead on void loop


WiFi101 Client HTTP POST fails after 3rd request

I tried changing the strings to char's, that didn't work.
Verified that it was closing connections with the server, check.

Was reading around and saw someone who tried a soft reset of the wifi client here. I added the following to the end of my httpRequest() method

client.stop();
WiFi.end();
delay(10);
WiFi.begin(ssid, pass);

And now it's working just fine. I'm going to have it run all night and see if there are any issues, but it's definitely an improvement as I can make more than 3 requests :|

This seems like a terrible work around. Clearly something isn't getting reset after each HTTP request on the wifi client, and this (right now) is the only way to solve it. I'd really love any other feedback on a better ways to solve it. Seems like some issues with the WiFi101 Library.


Include Git tag (or SVN revision) in Arduino sketch?

I struggled with Arduino (ESP32) versioning also.
To make it somewhat more practical and less error prone I made some scripts to assist this process.

Using these scripts is as easy as adding them to your sketch folder and adding

#include "gitTagVersion.h"
...
Serial.println( sketchVersion );

to your Arduino sketch.
That is all that is needed.

The output in the example above will be something like v1.0.0-3-gab3fb04.
That breaks down to tag v1.0.0, we had 3 commits since that tag, at commit ab3fb04.

HOW TO INSTALL AND USE?

There are 2 scripts involved, the first script is a replacement for the Arduino  Verify button.
Save it as verify.sh:

echo "const char * sketchVersion = \"$(git describe --tags --always --dirty)\";" > gitTagVersion.h
~/arduino-1.8.5/arduino --verify test.ino
rm gitTagVersion.h

And the second script replaces the Upload button.
Save it as upload.sh:

echo "const char * sketchVersion = \"$(git describe --tags --always --dirty)\";" > gitTagVersion.h
~/arduino-1.8.5/arduino --upload test.ino --pref custom_DebugLevel=esp32_none
rm gitTagVersion.h

Some things to note about these scripts:

The scripts REPLACE the buttons.
You won’t be able to use the buttons anymore, as these buttons don’t
generate the necessary version info from git.

Using them will result in this error:

  fatal error: gitTagVersion.h:    No such file or directory

The scripts are hardcoded to use Arduino 1.8.5 and have to be updated
if you update your Arduino IDE.
These script only work in Linux with a vanilla Arduino install.
If you use Windows, or are on a Mac the scripts will not work.
To change the debug output (using the LOGx_ESP macros) on ESP32
builds, change the custom_DebugLevel in the Upload script to
esp32_xxxx, where xxxx is none, info, error, debug or verbose.

I posted this also on my blog and esp32.com


Does the tone() generates unwanted signal?

I could reproduce the problem with the posted code. This will be caused by the fact that the tone library uses interrupts and has to manually toggle pins, which will always have a bit of jitter. You are better off setting up a hardware timer to generate the tones, this does not require interrupts.

For example:

#include <TonePlayer.h>

TonePlayer tone1 (TCCR1A, TCCR1B, OCR1AH, OCR1AL, TCNT1H, TCNT1L);  // pin D9 (Uno), D11 (Mega)

void setup()
  {
  pinMode (9, OUTPUT);  // output pin is fixed (OC1A)

  tone1.tone (10000);  // 10 kHz
  }

void loop() { }

This uses a fairly small library I wrote, which you can download from http://www.gammon.com.au/Arduino/TonePlayer.zip

Library code

If you don't want to trust some zip file from a random web site, here is TonePlayer.h:

/*
 Play tones with hardware timers
 Author: Nick Gammon
 Date:   1 April 2013
*/

#include <Arduino.h>

class TonePlayer
  {
  // addresses of output ports - NULL if not applicable
  volatile byte * const timerRegA_;
  volatile byte * const timerRegB_;
  volatile byte * const timerOCRH_;
  volatile byte * const timerOCRL_;
  volatile byte * const timerTCNTH_;
  volatile byte * const timerTCNTL_;

  public:
    // constructor
    TonePlayer (
          // ports
          volatile byte & timerRegA,
          volatile byte & timerRegB,
          volatile byte & timerOCRH,
          volatile byte & timerOCRL,
          volatile byte & timerTCNTH,
          volatile byte & timerTCNTL)
       :
         timerRegA_  (&timerRegA),
         timerRegB_  (&timerRegB),
         timerOCRH_  (&timerOCRH),
         timerOCRL_  (&timerOCRL),
         timerTCNTH_ (&timerTCNTH),
         timerTCNTL_ (&timerTCNTH)
  { }

    void tone (const unsigned int Hz);
    void noTone ();

  };  // end of TonePlayer

/*

 PERMISSION TO DISTRIBUTE

 Permission is hereby granted, free of charge, to any person obtaining a copy of this software
 and associated documentation files (the "Software"), to deal in the Software without restriction,
 including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
 and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
 subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 LIMITATION OF LIABILITY

 The software is provided "as is", without warranty of any kind, express or implied,
 including but not limited to the warranties of merchantability, fitness for a particular
 purpose and noninfringement. In no event shall the authors or copyright holders be liable
 for any claim, damages or other liability, whether in an action of contract,
 tort or otherwise, arising from, out of or in connection with the software
 or the use or other dealings in the software.

 */

And here is TonePlayer.cpp:

/*
 Play tones with hardware timers
 Author: Nick Gammon
 Date:   1 April 2013
 */

#include <TonePlayer.h>

void TonePlayer::tone (const unsigned int Hz)
{
  // it takes two toggles for one "cycle"
  unsigned long ocr = F_CPU / Hz / 2;
  byte prescaler = _BV (CS10);  // start with prescaler of 1  (bits are the same for all timers)

  // too large? prescale it
  if (ocr > 0xFFFF)
    {
    prescaler |= _BV (CS11);    // now prescaler of 64
    ocr /= 64;
    }

  // stop timer
  *timerRegA_ = 0;
  *timerRegB_ = 0;

  // reset counter
  *timerTCNTH_ = 0;
  *timerTCNTL_ = 0;

  // what to count up to
  *timerOCRH_ = highByte (ocr);
  *timerOCRL_ = lowByte (ocr);

  *timerRegA_ = _BV (COM1A0);             // toggle output pin
  *timerRegB_ = _BV (WGM12) | prescaler;  // CTC
  }  // end of TonePlayer::tone

void TonePlayer::noTone ()
  {
  // stop timer
  *timerRegA_ = 0;
  *timerRegB_ = 0;
  } // end of TonePlayer::noTone

/*
 PERMISSION TO DISTRIBUTE

 Permission is hereby granted, free of charge, to any person obtaining a copy of this software
 and associated documentation files (the "Software"), to deal in the Software without restriction,
 including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
 and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
 subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 LIMITATION OF LIABILITY

 The software is provided "as is", without warranty of any kind, express or implied,
 including but not limited to the warranties of merchantability, fitness for a particular
 purpose and noninfringement. In no event shall the authors or copyright holders be liable
 for any claim, damages or other liability, whether in an action of contract,
 tort or otherwise, arising from, out of or in connection with the software
 or the use or other dealings in the software.

 Example of use:

 #include <TonePlayer.h>

 ...

 TonePlayer tone1 (TCCR1A, TCCR1B, OCR1AH, OCR1AL, TCNT1H, TCNT1L);  // pin D9 (Uno), D11 (Mega)

 or, on the Mega 2560:

 TonePlayer tone3 (TCCR3A, TCCR3B, OCR3AH, OCR3AL, TCNT3H, TCNT3L);  // pin D5
 TonePlayer tone4 (TCCR4A, TCCR4B, OCR4AH, OCR4AL, TCNT4H, TCNT4L);  // pin D6
 TonePlayer tone5 (TCCR5A, TCCR5B, OCR5AH, OCR5AL, TCNT5H, TCNT5L);  // pin D46

 ...

 pinMode (9, OUTPUT);  // D9 on Uno, D11 on Mega 2560
 tone1.tone (440);     // play 440 Hz
 delay (500);          // wait half a second
 tone1.noTone ();      // stop playing

 or, on the Mega 2560:

 pinMode (46, OUTPUT);
 tone5.tone (440);

*/

Just put those two files inside a folder "TonePlayer" inside the libraries folder inside your sketches folder, and it should all work.

The library is written for the 16-bit timers, and supports Timer 1 on the Atmega328, and Timers 1, 3, 4, 5 on the Atmega2560. Comments inside the library show how to set up the other timers.


If you add a debugging print you will see what is happening:

void setup() {
  Serial.begin (115200);
  Serial.println ();

  pinMode(13, OUTPUT);

  int len = 5000;
  byte *data = (byte *)malloc(len * sizeof(*data));

  Serial.print ("data = ");
  Serial.println ((int) data);
}

Output:

data = 0

The malloc failed, it returned NULL, the rest of the program proceeded normally.

  once malloc has allocated 5000 bytes (or as many as it could of the 5000 bytes)

malloc does not return with a partial allocation. It either allocates the amount you requested or none at all.


Molex power with USB serial Communication from the same PSU

Two important things first:

The Uno 5 V pin and power bus must never be supplied more than 5.5 V or the MCU may die. The DC power input jack (the barrel jack) and the Vin pin, which are connected together, are not directly connected this bus, which is why you can supply higher voltages to that (see below).
You can not simultaneously supply power via both the USB cable and a power supply to the 5V pin/5 V bus because that would directly connect the two power supplies. That's a very bad thing, and probably not just for the Uno. (But there is a trick you can use here to still connect USB data when you are supplying power to 5V; see below.)

Now on to the details.

You can safely connect Vin (the pin or the barrel jack; they are directly connected) and USB at the same time because there's a switch (T1 on the schematic) on the board that will disconnect the USB power line from the Arduino 5V bus if more than 3.3 V is being supplied to Vin.

However, Vin goes through a regulator which, while it has the advantage of safely handling voltages much higher than 5 V, also causes some voltage drop, so you need to supply it with a minimum of 7 V. (6 V might work if there's very little power draw; 5 V almost certainly will not.) The maximum voltage you should supply is 20 V, but it's recommended that you stick to 12 V or less, since higher voltages mean that the regulator can get rather hot.

Unfortunately for you, this doesn't really help with your problem. While you could take the 12 V power off the molex connector, supply it to Vin and run the Arduino itself quite happily with the USB cable also connected, the regulator on Vin is rated for only 1 A, which is considerably less than you need for the entire system.

There are ways to have some parts of the system powered by one power supply and other parts powered by a separate power supply, but they're not trivial (and also beyond my expertise at the moment :-)).

Probably the easiest solution is to connect the 5 V output from the molex connector to your system power bus, which would be supplying both the 5V pin on the Arduino and your external components, and then build a custom USB cable with only the D+ and D- pins connected, dropping the power and ground pins. (You don't need the ground pin because the USB data signal is actually a differential signal: the difference or similarity in the voltage between D+ and D- pins is what determines whether the signal is a 1 or a 0.)

By the way, just to make sure, you do have some separate switching for all those LEDs, right? You're not trying to provide all their power via the Arduino digital outputs? Because, as per section 32.1 of the ATmega328P datasheet, while you are allowed to sink up to 40 mA from any individual data pin, you cannot sink more than 200 mA in total from the chip.


Arduino Nano Fried on Music Reactive Led Strip

I assume you are powering the Nano through VIN or USB, and you are then powering the LED strip from the Nano's 5V pin.

From the 12V battery the current flows through an LM1117 linear voltage regulator. Draw too much current (>800mA) and it will overheat and either shut down (if it's a good one) or melt (if it's an inferior Chinese clone).
From USB the current flows through an SS1P3L diode with a maximum rating of 1.5A. If you draw more than that you will blow the diode and the board will appear dead.

So basically you're drawing too much current.

The proper way of powering a setup like this is:

USB connection to power the Arduino only
12V into a 5V switching ("buck") regulator rated for at least the maximum current the LED strip needs
5V switching regulator into the LED strip directly
Connect the ground of the 5V to the ground of the Arduino

or

12V into a 5V switching ("buck") regulator rated for at least the maximum current the LED strip needs
5V switching regulator into the LED strip directly
5V switching regulator also to the 5V (and ground) pin of the Arduino to power the Arduino

or

As above but with a 5V power supply instead of the 12V and switching regulator

Note that it is important that your supply can provide you with at least as much current as the peak current your system will need.  If that is a problem then you can split the LED strip into chunks and power each chunk separately from a lower current supply.


In your slave, you've declared com as an int, so Serial.println() interprets it that way. If you want to keep it as int except for printing, cast Serial.println()'s argument to char:
Serial.println((char)com);


How to use printf with Arduino's serial ports without an intermediary buffer?

Sure - here's a Hello, World program that uses printf(). Everything that mentions "uart" is what connects printf() to your output stream. uart_putchar() does the actual outputting to ... someplace. That's what you'd modify to direct the C standard output to a different device - SofwareSerial, for instance:

// Hello, World program using printf()

#include <Arduino.h>

static FILE uartout = { 0 };   // FILE struct
static int uart_putchar(char c, FILE *stream);

void setup() {
   // For printf: fills in the UART file descriptor with pointer to putchar func.
   fdev_setup_stream(&uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE);
   stdout = &uartout;

   Serial.begin(9600);
   printf("Hello, World!\n");
}

void loop( void ){
   printf("Elapsed time: %ld\n", millis());
}

// uart_putchar - char output function for printf
static int uart_putchar (char c, FILE *stream)
{
   if( c == '\n' )
      Serial.write('\r');
   Serial.write(c) ;
   return 0 ;
}


Measuring car speed between two points: What sensor to use and how to cover the distance?

Why 25meters? If you place the two sensors 1 meter apart, you only need 1ms accuracy to get km/h (assuming a 50km/h speed limit). The Arduino can handle 1ms resolution with ease.
I'd probably go with 3-5 meters, so you don't need your setup to be that precise (i.e. distance and alignment of the two sensors). Lowering the distance also makes it less likely for two cars, from both directions, to simultaneously be inside your sensor area.
For the sensors, the biggest problem is the legal one. Having objects on/near the road could cause some liability issues. The laser solution is probably the least likely to cause this issue. Though I'm unsure about having a display next to the road.
You could go with laser and photo-transistor on one side of the road. And a reflector/mirror on the other side. I'd probably go with an IR laser, so it's invisible. You'd have to shield the photo-transistor as much as possible from ambient light, so a sudden cloud won't trigger it. You probably still need to do some filtering in software.
There are radar modules available, but I think they are pretty expensive.
Another option is a Laser range sensor, like this one from sparkfun


Error: 'SofwareSerial' does not name a type

You forgot the quotation marks, try

#include "SoftwareSerial.h"


It depends on what voltage the devices run at and what their current draw is from the power supply versus what voltage & current your power supply provides.

If everything runs at 3.3V or 5V and minimal amps then you're good to go.

Read the datasheet for each device and for your power supply.


How to connect a Pressure Sensor-MPX10DP to an Arduino?

The MPX10DP does not have an amplifier inside. The output is the output of the internal wheatstone bridge. It is not even compensated for temperature.

This is the manufacturers page about the MPX10 series: nxp.com MPX10 series.

You need an instrumentation amplifier and perhaps a temperature compensation. The INA125 is an instrumentation amplifier. It was used in the past with the Arduino a lot. Nowadays, most sensors are digital, and the bare sensors with wheatstone bridge output are not used that often anymore.

When you connect both sensor outputs to two Arduino inputs (without amplifier), then the difference is 35mV for 10kPa. The resolution is in theory 5V / 1024. The overall accuracy for two analog inputs perhaps 9 bits, then you can measure the 10kPa in 3.5 steps (about 2 or 3 kPa resolution).
If you seriously want to use this specific sensor, and don't want to use extra hardware, then you might have a look at my question about the differential mode and gain that is possible with the Arduino Mega 2560 and Leonardo.

Or you could buy a pressure sensor with 0...5V output, that can be connected to the Arduino analog input. The tutorial you mentioned uses the MPX5010. That sensor has a amplifier inside and is temperature compensated. They are reliable and ratiometric with the 5V, therefor super easy to use. With a lot of averaging in the code, you can get a high (relative) accuracy.


ESP Web Server calling javascript function

If you want server-push, you can use Server Sent Events or a Websocket instead of polling with XMLHttpRequest.

So yes, it can be done, and I have implemented both using a Nano 33 IoT at one end and Javascript in a browser on the other. Some example code is here: https://github.com/ocrdu/arduino-webinterface-sse and here: https://github.com/ocrdu/arduino-webinterface-websocket.

I don't know if there are convenient libraries for the ESPs to do this, though.


Differences between Arduino IDE versions

Debian is always somewhat behind the latest software

No, when it comes to the Arduino IDE Debian is frozen on an ancient version.

1.0.5 is considered to be too old to use. Many many things have changed since then - bug fixes, optimisations, new API components. And not least the implementation of the Board Manager for installing support for more boards, both by Arduino and other makers, and support for multi-arch libraries (which your SdFat library is with a src folder in it).

You should never install the Arduino IDE from the Debian repositories. Instead you should download the current version of the Arduino website (http://arduino.cc/download) as a tar.\z file and extract it into a folder and run it from there.


How to extract latitude and longitude from GPS

First rather than just dumping it to the screen store the data in a char array

char dataBuffer[64];
int dataCount=0;

while ( (mySerial.available()!=0) && (dataCount<63) ) {
    dataBuffer[dataCount] = mySerial.read());
    dataCount++;
}
dataBuffer[dataCount] = 0;

then use strtok to split the string on the : and , characters

char *output;
output = strtok(dataBuffer,":");
// output will now point to everything up to the first : so "CGPSINF" for gps
int field = 0;
while (output != null) {
  field++;
  output = strtok(null,",");
// output will now point to each value in turn
// for CGPSINF:0,6.823375,80.001038,36.300000,
// when field == 1 output=="0"
// when field == 2 output=="6.823375" etc...
}


Why can't I print boolean variable values (0 and 1) through println function?

First, you are not supposed to use boolean with digitalRead.

The function prototype in Arduino.h is:

int digitalRead(uint8_t);

Thus, the correct data type for buttonState in your code is int. Then your other problem goes away. What I am guessing is happening is that the version of the IDE you are using does not have an overloaded function for Serial.println that takes a boolean argument, and the compiler is casting it to byte, in which case it would print as 0x00 (LOW) or 0x01 (HIGH) which are not printable characters.

Unfortunately the documentation for digitalRead on the Arduino site does not mention the datatype, it just mentions that it returns HIGH or LOW which isn't very helpful to help you work out what data type to use. BTW, neither of those values are, per se, booleans. If they had said it returns true or false you might reasonably put the result into a boolean field.

I have tried to get the Arduino developers to improve the documentation in this respect, something they have declined to do. I raised the issue almost 4 years ago, and no-one is even assigned to this particular task.

If you insist on using the boolean type, then a reasonable way of printing would be:

Serial.println(buttonState ? "HIGH" : "LOW");

In response to some comments ...

  Works fine for me. – Majenko

...

  boolean is a typedef for bool. bool gets promoted to int, not byte - Majenko

What you mean by "is a typedef for bool" is in some (later) versions of the IDE.

Looking at, for example, Arduino pre-release version 0023 I see in the file wiring.h:

typedef uint8_t boolean;
typedef uint8_t byte;

So you can clearly see that boolean and byte are the same, and therefore that using boolean would be treated as byte. Now if you look at the Print class in that release:

class Print
{
  private:
    void printNumber(unsigned long, uint8_t);
    void printFloat(double, uint8_t);
  public:
    virtual void write(uint8_t) = 0;
    virtual void write(const char *str);
    virtual void write(const uint8_t *buffer, size_t size);

    void print(const String &);
    void print(const char[]);
    void print(char, int = BYTE);
    void print(unsigned char, int = BYTE);
    void print(int, int = DEC);
    void print(unsigned int, int = DEC);
    void print(long, int = DEC);
    void print(unsigned long, int = DEC);
    void print(double, int = 2);

    void println(const String &s);
    void println(const char[]);
    void println(char, int = BYTE);
    void println(unsigned char, int = BYTE);
    void println(int, int = DEC);
    void println(unsigned int, int = DEC);
    void println(long, int = DEC);
    void println(unsigned long, int = DEC);
    void println(double, int = 2);
    void println(void);
};

So you can see that the overload for print and println treats an unsigned char (effectively uint8_t) to be printed with BYTE default treatment and not DEC treatment.

BYTE is declared:

#define BYTE 0

And the writing is done thus:

void Print::print(unsigned long n, int base)
{
  if (base == 0) write(n);
  else printNumber(n, base);
}

What this boils down to is that both byte and boolean will be written as "binary" bytes, not converted into decimal.

As Majenko says, things are different today, and boolean is now equivalent to bool which is promoted to int.

ElectroManiac did not respond to a question about what version of the IDE s/he is using, however my point is that for some versions of the IDE my explanation is true.

  Oh, and assigning the return of digitalRead to a bool is perfectly valid ...

Yes, for bool, but the question was about boolean. Whilst we know, by reading the code and reading the documentation, that digitalRead will return a 0 or 1, the fact that the return type is int means that the compiler can potentially see that you are stuffing a 16-bit return value into a 8-bit variable which will possibly lead to data truncation.

I must admit I don't get a warning when compiling with the Arduino IDE, however there is certainly the potential for truncation. A test program written in C++ and compiled with the -Wconversion flag gives a suitable warning:

warning: conversion to ‘uint8_t {aka unsigned char}’ from ‘int’ may alter its value [-Wconversion]

(There is no warning if you are placing the result into bool, however that is not the version of the IDE that the OP is using).


I just encountered this.  After looking at other examples in the compiler command line options, it looks like it should be $(LinkerScript) instead of ($LinkerScript).

In Atmel Studio, go to project properties, toolchain, ARM/GNU Linker, Miscellaneous to find the option to change.


It depends
This may not have been the answer the question was originally asked, but now it appears to be: it depends on which revision of the Due you have.
The V03 schematics on the website show a 74LVC1G125DCK part designated IC10 that is being used to translate the 5V TXD signal from the ATMega16u2 (being used as a serial transceiver) to the 3.3V logic needed for the ATSAM3X8.  As drawn the TXD line is connected to the buffer/level converter input but it is also connected to its active-low output-enable line.  In effect, they're not just using it to convert logic levels, they are also converting the signal to a kind of open collector signal.  Looking at the ATSAM3X8 datasheet shows that, yes, there is an internal pullup in the pin receiving the signal.
If your Due is of this design, then yes, you can program the chip by attaching a USB->logic-level-serial adapter to D0 and D1 (USART) pins and program using the SAM-BA protocol. You need to make sure you are not sending over the on-board serial transceiver while this is happening so as to not have it wired-ORing its data with your adapter. The ATMega16U2 has code in it that controls the ATSAM3X8's erase pin, as well as reset pin, by request of the PC via serial-over-USB's DTR and RTS.  Since the erase signal is not routed to outside of the Due (on its headers), you would need to use the erase button, barring some modification to the board.
However, not all Due are of this design. Some DUE boards have the output-enable of 74LVC1G125DCK hard-wired active rather than connected to the transceiver TXD; so on these designs it does not behave as open-collector, and the ATMega16u2 serial transceiver is actively driving the line when idle.  This destroys the ability to program the board over UART via pins D0 and D1.  It does however make cleaner rising edges.  Without modifying the board, no, you can't do it with this design.
Identification
So far as I can tell, whether or not your ATMega16U2->ATSAM3X8 connection is open collector/UART-programming-friendly follows the location of the buffer part.  The chip is an SC70 package, a small 5-pin thing that looks a bit like SOT23-5.  If it is located off the ATMega16U2 itself it seems you have a open-collector configuration, again so far as I've been able to tell.  If it is located next to D0, between D0 and the "COMMUNICATION" header, then you have one that drives-high.
If you have a scope, you can put it on D0 and watch the edges generated when you send traffic from the PC over the ATMega16U2 at higher baud rates.  You will either see characteristic open-collector rising edges or you won't and that will answer the question.


Can an Arduino power itself off [not low power mode] via software?

In general, an Arduino by itself has no control over its power input.  It can, of course, enter various Sleep modes, such as the Power-down mode with watch-dog-timer off, which uses 0.1  μA.

It isn't clear from the question what will turn the Arduino back on after it is off for a while, but if you have either a push-button or a signal to turn it back on, the Pololu 2808 Mini Pushbutton Power Switch will work as an Arduino-controlled off switch.  This board has On, Off, Ctrl, and button-contacts inputs.  If your Arduino raises the Off input, power shuts off cleanly.  To turn it back on, either connect the  button-contacts inputs together, or raise the On input, or pulse the Ctrl input.


Lighting 5 leds...the last one lit is always dim

I found the problem, it was a bug in my code. I had found code to read the array size online but it was off by 1.

Instead of:

for (int thisPin = 0; thisPin < (sizeof(ledPins)/sizeof(int)) - 1; thisPin++)  {
    pinMode(ledPins[thisPin], OUTPUT);
  }

When I changed it to thisPin < numLeds, it worked correctly. The last pin was simply set to be an input pin instead of an output pin.


Internal volts in arduino for percent battery

map()

unsigned char level = map(readVcc(), 3000, 4200, 0, 100);


Several Arduinos and Arduino-compatible boards use the ATmega32U4.
Many of them have published open-source plans that show exactly what components are used and how they are connected. They may not be the absolute minimal number of components, but it seems clear that you don't need more components than a known-working board:

1 ATmega32u4
1 16 MHz crystal
2 22pF ceramic caps (for crystal)
1 uF decoupling cap
1 pushbutton
1 10 KOhm pull-up resistor (for pushbutton)
1 LED
1 220 Ohm resistor (for LED)
1 USB socket
2 22 Ohm resistors (between USB socket and ATmega32u4)

Alas, there are two unnecessarily difficult hurdles between newbies and getting a new ATmega32u4 device connected over USB to a computer:

The ATmega32u4 and nearly every other device that communicates over USB is only available in SMT packages with pins at 0.8 mm pitch or even closer together.
Most people find packages with pins at 2.54 mm pitch easier to handle and plug into a breadboard.
Installing a bootloader into any new processor chip is often tricky.

As Russel already pointed out, you can save a lot of time by starting out with an Arduino or Arduino-compatible board that already has the chip soldered on and the bootloader programmed in, bypassing the above unnecessarily difficult hurdles.

A few Arduinos and Arduino-compatibles (with links to schematics, etc.) that use the ATmega32u4:

Bootloading an ATmega32u4 with Arduino
Teensy 2.0 (ATmega32u4 USB dev board)
Arduino Leonardo; Arduino Leonardo
Arduino MICRO
SparkFun Pro Micro (Arduino-compatible)
FLORA - Wearable electronic platform: Arduino-compatible
Adafruit Feather 32u4 Basic Proto
Installing Arduino Bootloader on an ATmega32u4; Installing Arduino Bootloader on an ATmega32u4


Dynamic SSID + Password from ESP8266WiFi

The const keyword there does not force the data you call it to be constant, it only forbids certain assignments with the parameters inside that function but it's just superfluous in most cases. Meaning you can call it with input you got from serial or some other source (for ex. setup page accessible from hotspot->Store in EEPROM->Next boot connect to set WiFi AP). There's also a nice StackOverflow thread about this here and why it's not actually a good idea in many cases.


There's an attempt to get the Atmel XMEGA boards working in Arduino IDE.

https://github.com/akafugu/Xmegaduino

It's not fully featured yet but appears to have to features to allow you to start hacking with this board.


First, I'm a bit surprised you use analog pins for button checks, instead of digital pins.

About the code, without analyzing it completely, the easiest way is to make a state diagram in pseudo code first.

E.g.suppose you want to have the following screens(a screen 'title/content' is shown in[], a button transition with ---(key)-->

InitScreen--- (right)--> MenuOption1Highlight---(right)-->MenuOption1Items
                              |       ^     \---(left)----+
                           (down)    (up)
                              v       |
                           MenuOption2Highlight---(right)-->MenuOption2Items
                                              \---(left)----+

To program this (roughly), create an enumeration for each menu page :

enum EMenuPage
{
        None,
    InitScreen,
    MenuOption1Highlight,
    MenuOption1Items,
    MenuOption2Highlight,
    MenuOption2Items
};

Than create a current state for it as global variable:

EMenuPage _eMenuPage;

And initialize it in Setup:

_eMenuPage = None;

Create an enum for the keys :

enum EKey
{
    None,
    Up,
    Down,
    Right,
    Left
};

It is easier to create a function that reads keys, and returns one key, maybe one key has priority over another,
or you can combine keys (in that case add in EKey e.g. UpAndDown). If no key has been pressed, None is selected.

In the loop, use a state transition diagram to program out the options :

EKey pressedKey = GetPressedKey(); // This is for yourself to implement, it updates _pressedKey;

switch (_eMenuPage)
{
case None:
    InitScreen();
    break;

case InitScreen:
    ProcessInitScreenKeys();
    break;

case MenuOptions1HighLighted:
    ProcessMenuOptions1HighLightedKeys();
    break;

...
default:
    // Illegal key
    break;
}

For each page you make a function (e.g. InitScreen) which updates the state and shows the content on the display:

void InitScreen()
{
    _eMenuPage = InitScreen;

    // Show content on display.
}

Also, you create a Process...Keys function to handle the keys. Like:

void InitScreen()
{
    EKey pressedKey = GetPressedKey();
    switch (pressedKey)
    {
    case Right:
        MenuOptions1HighLighted();
        break;

    default:
        // Ignore other keys
        break;
    }
}

For another function it would look like:

void ProcessMenuOptions1HighLightedKeys()
{
    EKey pressedKey = GetPressedKey();
    switch (pressedKey)
    {
    case Down:
        MenuOptions1HighLighted();
        break;

    case Right:
        MenuOption1Items();
        break;

    default:
        // Ignore other keys
        break;
    }
}

(Btw I did not check neither compiled the code).

Probably there is a nicer more object oriented way to do this, but it costs more memory and is more advanced. This is to create an abstract Page class, which has two virtual methods (one to show and one to handle keys), and create a derived class for each page implementing the two functions from the base class.


From an L298N datasheet:

TOTAL DC CURRENT UP TO 4 A

From motor's "datasheet":

I'm no expert in electric motors and driving them, not even sure I'm novice level, but I just don't see you driving a motor anything near this current draw with this part.  If by some miracle you can, it will be horribly inefficient owing to the losses associated with the voltage drops that Gil mentions.
For a motor that operates with this much current I would expect a practical h-bridge setup to have discrete mosfets, perhaps mounted to a heatsink.


It's not that big of deal. The ATmega 328p datasheet states this:

  Temperature range: -40 to 85 degrees celsius.

The same goes for the USB chip on the Uno (ATmega 16u2 for UNO R3).

That's inside your limits. It probably could go a bit colder than mentioned, but it'll shorten the length of the board a little bit.

However, there are some things that may go wrong:

EEPROM might not be stored as long in extreme temperatures. Keep this in mind if you're storing critical data.
The voltage regulator may not perform as well in hot conditions
The crystal oscillator may not produce exact values. However, I would imagine that a few hertz more or less wouldn't affect a 16 MHz processor. The tolerance is actually a little less than 1%. You may have some issues with serial (baud rate not correct). I would look into any communications like I2C also. (I don't know exactly how the clock line works... it might be fine for I2C.)
Resistors/capacitors may not produce the exact values. I'd imagine that the tolerance won't be more than 8% on resistors: most resistors are rated at 5% for normal temperatures. It does depend on the manufacturer. Capacitors do have a bigger tolerance, but their main purpose is to "smooth" a signal.
Extreme cooling/warming may cause minor expansion problems. (Note: it's fine once in a while, but not on an hourly basis of dropping 30 degrees.)
Other components (LCDs, etc.) should be kept in mind also when looking at the viability of keeping it outdoors.

So as long as all the other components not on the board will happily run in the temperatures that you need, you should be fine. Also, as with all engineering, values often have added "padding" built in. (i.e. 5% tolerance is often 3-4%, maximum 12V it can run on 12.5V, etc.)*

*What I mean by that is your Arduino won't explode when it's -41 degrees C. It's not great for it, but most likely you should be fine as long is it isn't a regular occurrence.


How to change colors and theme settings in 'Windows Store app' version of Arduino IDE?

I think rrz0's answer skipped the part of the question:
"For the Windows Store app version of the IDE the theme files are stored in protected app storage space."

The only way is to take control of the windows app folder but I believe this is risky and M$ suggests that this can brick your pc (take that with a grain of salt).

There is an offline windows installer and zip link on the downloads page which I used to replace the windows store version. I see no advantage to the store version.


Just to complement Michel Keijzers’ answer: sprintf() or snprintf()
are normally the right solution. On the AVR platform, however, float
conversions are left out of their default implementation, because they
take quite a lot of flash space, even when not used. On the other hand,
the avr-libc provides the non-standard function dtostrf()
for doing this conversion. The program

void setup() {
    float f = 3.877;
    char str[35];
    dtostrf(f, 0, 3, str);
    Serial.begin(9600);
    Serial.println(str);
}

void loop(){}

outputs

3.877


How to send int array with ESP8266 http post request?

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

http.POST(payload);

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


Where are the digital and analog pins for the adafruit atmega 32u4 breakout board?

The information is right there on the product page for you. It took be a total of about 4 seconds to find it.

http://ladyada.net/products/atmega32u4breakout/


arduino mega overheat when connected to TFT 7" and TFT shield

7" LCDs need a lot of current. They need it for the back light.

That current comes from the 5V pin.  That 5V pin is supplied by a linear regulator that has limited current capacity.  As you draw more current it gets hotter and hotter and eventually shuts down.

You will need to power your LCD screen with another external 5V source. The best solution may be a powerful (2A) phone charger (USB) which you then plug direct into the USB port of the board thus bypassing the weak regulator.


Can a Ethernet USB Dongle be instead of ethernet shield for arduino?


On the Arduino UNO and Wifi shield websites in the Documentation section you can download the Schematic (PDF) and PCB layout (Eagle) files. The page already says

  The Uno is open-source hardware! You can build your own board using
  the follwing files

With the free version of Eagle, you can open it and export to gerber file format.


Can the ESP-1 use SPI to communicate with sensors?

ESP-01 was designed as WiFi network adapter, not as a controller board. The are 4 pins on esp-01. RX (io 3), TX (io 1), io 0 and io 2.

SPI requires 3 pins: clock, MISO, MOSI plus one pin for every device connected to the bus. So you could in theory use one SPI device on this 4 pins. The esp8266 Arduino SPI library works only with hardware SPI on esp8266 pins io 12, 13, 14 so you would have to use some software SPI implementation for esp8266.

To connect sensors, actuators or display to the esp-01, I2C is a feasible option. It requires only two digital pins and the esp8266 Arduino Wire library can work on any pair of io pins.

To use esp8266 as MCU with Arduino, there are many development boards with all usable pins broken out (9 pins) and USB chip for simple connection to computer and flashing (Wemos, NodeMCU). Or you can use an esp8266 module with more or all pins of the esp8266 (esp-07, esp-12).


Remote temperature sensor system without slave board

As @Majenko said on comment, its possible. One of the choice is ESP8266. Your project has been successfully accomplished, you can check here, here, or here. NSP8266 only needs 3-3.6V (low current) supply voltage.


7-Segment, 3-digit display not displaying correctly

I have three recommendations for you. @Gerben was correct as to your problem, but doing the following three steps will improve the speed of your code:

Change your definition for NumberSegments to be [10][8], and put the number of active segments as the first number of each array:

 ...[10][8] = {{6,a,b,c,d,e,g},     // ...
               {2,b,c},
               {5,a,b,d,e,g}, // etcetera

Change your for loop as follows:

for (int i = 1; i <= NumberSegments[Number][0]; i++) { // ...
   digitalWrite(NumberSegments[Number][i], HIGH); // ...
}

This will only turn on the minimum number of segments required. Note the loop now starts at 1, and uses <= instead of <.
Put the keyword static in front of NumberSegments:

static int NumberSegments[10][8] = {{ // ...

This last one is a language nicety. Every time the function WriteNum is called, the poor thing has to re-create the (large) NumberSegments array - and it’s the same every time! The keyword static means “only create this variable once”. Next time into the function, it’ll already be available: no processing required!

You might also consider moving int position; below NumberSegments, since it’s convention to put static variables first in a function.

You can also use the keyword const on NumberSegments, since its values never change:

static const int NumberSegments[10][8] = {{ // ...


How to Compile Different Sketches in Different Visual Studio Code Workspaces

The first time you verify your sketch you are confronted with a list of available sketches (INO's). As soon as you select one of these it gets stored under "sketch" in .vscode/arduino.json.
If you zero this, "", you'll once again be asked which sketch to set as "main sketch".

This "device context" is stored per workspace so you might consider narrowing your scope when opening a folder. I know this is no fun when exploring, and the will to switch and try different examples is big, but currently there are nothing that facilitates a smoother alternative.


How to change the baud rate of ESP8266 (12E) using an Arduino Uno?

You can use this block of code in Arduino to set baud rate...

void setup()
{
  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}

void loop() {}

Change value in serial.begin() as per your value.


Tried to fix ports on Mac OS X Yosemite. Now nothing works

I solved this issue by deleting all of the Arduino files and the Arduino app. I put my sketched folder aside but deleted all libraries.

Restarted the computer.

Installed Arduino fresh.

Restarted the computer.

Installed the drivers.

Ran the command.

Restarted the computer.

Restarted the computer.

Restarted the computer.

Then it worked.


How reliable is Arduino Uno Serial, via USB (ATmega16U2), CRC needed?

If you use the appropriate buffering of the 0/5V signal over the long wires, case A, no error detection and correction is needed. RS232, RS485, your data will be just fine (can be up to thousands of feet).

Shorter wires, from Atmega device to Atmega device, I've neved had to use anything, even at 115200 speeds, case B, case C.

16U2 to PC, that will depend on the quality of the USB cable. The +/-3V differential signal (similar to RS485 levels) is quite high speed, like 4 Mbits/second, so you want a good cable with good shielding.


I couldn't understand what the problem is, since you already managed to connect an LCD to it... Anyway...

To run a stepper motor you have to first define the control technique. AFAIK there are a few, but the ones I know are

full step
rotated full step
half step
microstep

Your motor is a unipolar motor. You have to connect the common wire to +5V, the other ones to one transistor of the ULN2003, and each transistor should be directly controlled by one pin. These are called phases (and let's call these PH1, PH2, PH3 and PH4).

Now for the explanation I'll use some tables. In these tables, each row is a step, each column a pin, and if there is a X the transistor should be on during that step.

Now, the full step technique is the simplest one. It consists of four phases:

Step PH1 PH2 PH3 PH4
  1   X
  2       X
  3           X
  4               X

As you can see, you just have to power each phase through each step. Cycling the steps as 1-2-3-4-1-2-3... will rotate in one sense, 4-3-2-1-4-3-2... in the other.

The rotated full step technique powers two phases at each step:

Step PH1 PH2 PH3 PH4
  1   X   X
  2       X   X
  3           X   X
  4   X           X

This usually gives a higher current consumption, but also higher torque.

The half step is a mix of the two:

Step PH1 PH2 PH3 PH4
  1   X
  2   X   X
  3       X
  4       X   X
  5           X
  6           X   X
  7               X
  8   X           X

As you can see, the number of steps per cycle is twice as much. This means that you can increase the accuracy (since a 32 steps/rev motor will now require 64 steps to perform a complete revolution).

The microstepping technique requires a different hardware, since it better controls the current in the phases to further divide each step in different steps.

Anyway, a basic implementation using the MCP23017 and the full step technique can be this one. I used Adafruit's library, but you can change using whatever library you chose or the direct calls you used for the LCD.

#include <Wire.h>
#include "Adafruit_MCP23017.h"
Adafruit_MCP23017 mcp1;

const byte PH1 = 0, PH2 = 1, PH2 = 3, PH3 = 4;

const byte phasesTable[][] = {
    { HIGH, LOW,  LOW,  LOW  },
    { LOW,  HIGH, LOW,  LOW  },
    { LOW,  LOW,  HIGH, LOW  },
    { LOW,  LOW,  LOW,  HIGH }
    };

int currentPosition, targetPosition;
unsigned long previousMillis;
const int StepDelayMs = 100; // delay between steps

void setup()
{
    mcp1.begin(0);
    mcp1.pinMode(PH1, OUTPUT);
    mcp1.pinMode(PH2, OUTPUT);
    mcp1.pinMode(PH3, OUTPUT);
    mcp1.pinMode(PH4, OUTPUT);
    currentPosition = -1; // force first update
    targetPosition = 0;
}

void loop()
{
    void updatePosition(); // function prototype
    updatePosition(); // execute the update

    // ----------------------
    // Functional part
    // ----------------------
    // Edit this code according to your application
    // changing the targetPosition variable (DON'T CHANGE
    // the currentPosition variable

    if (currentPosition == targetPosition)
    {
        if (targetPosition == 50)
            targetPosition = 0;
        else
            targetPosition = 50;
    }
}

void updatePosition()
{
    if ((millis() - previousMillis) > StepDelayMs)
    {
        previousMillis += StepDelayMs;

        if (targetPosition != currentPosition)
        {
            if (targetPosition < currentPosition)
                currentPosition--;
            else
                currentPosition++;

            byte phIdx = currentPosition % (sizeof(phasesTable) / sizeof(phasesTable[0]));

            mcp1.digitalWrite(PH1, phasesTable[phIdx][0]);
            mcp1.digitalWrite(PH2, phasesTable[phIdx][1]);
            mcp1.digitalWrite(PH3, phasesTable[phIdx][2]);
            mcp1.digitalWrite(PH4, phasesTable[phIdx][3]);
        }
    }
}

NOTE: I did not test this code, but I'm pretty confident it should work. Maybe there are some bugs left, however, but you should be able to correct them yourself.

The program behaves this way: every 100ms (you can go a bit faster, but sometimes you can lose steps, so you have to test it) it checks if the motor has reached the final position he needs to reach (targetPosition). If it has, the program does nothing. Otherwise it moves one step towards the target. All this is managed in the updatePosition function.

You have to call this in the loop (and make a NON BLOCKING loop, otherwise also the motor will block). In the loop, modify the target position that you need to reach (the part I called Functional part). In the example, the program moves the motor 50 steps back and forth (so 50 steps in one direction, then back to the origin, then to 50 and so on).

The control technique used is the full step. If you want to use another, change the phasesTable constant variable.

If you need more functionalities, there are a lot of libraries for the steppers. Just use the proper commands to edit the pins on the MCP rather than the ones on the board.


Fetching txt file's contents from a webhost using esp8266

Your connection to the web server is through a Squid caching proxy.  It is delivering a cached version of the file:

X-Cache: HIT from localhost
X-Cache-Lookup: HIT from localhost:3128

The Age header shows you how long the page has been in the cache:

Age: 10203

That's been cached for about 2.8 hours.

You need to tell the cache not to get a cached version, but instead to always go to the server to get the latest copy.  To do that you should be able to include a "no-cache" header in your request:

Cache-Control: no-cache

That should tell squid "Don't cache this page - get the real one".

You can also add the HTTP/1.0 version of the same thing:

Pragma: no-cache

That way if one doesn't work on that version of squid the other one should.


The signals had looked good, but I did not examine them closely enough.  When I removed extra pullup resistors I had added on SCL and SDA, I2C worked.


SOLVED: Soft Power On SIM900 module - JP pads missing!

OK for anyone who has the same problem. I solved this by soldering a cable on the underside of the board on this pin (see image) on power button. Then I connect the cable to pin 9 on Arduino and run this on sketch:

  pinMode(9, OUTPUT);
  digitalWrite(9,LOW);
  delay(1000);
  digitalWrite(9,HIGH);
  delay(2000);
  pinMode(9, INPUT);

I don't know how it works, but it solves my problem.


Advice needed, commercializing an Arduino Due project

There's two routes you can take.

First route:

Get the Due schematics.
Remove the parts you don't need.
Add to it the new components for your product.
Lay out the PCB design.
Get the PCB manufactured.
Solder all the components on.
Test it and go back to step 2/3 as required.

Second route:

Hire a contractor that knows the SAM3X and can do it all for you.


This website in Arduino lists language references like functions and structures. What makes structures there different from functions?

What the website names "Structures" are code building-blocks for the programs you write. The main part there are conditional (if-else) and loop instructions (for, while) as well as mathematical operators. You use these constructs within your functions to control program flow or compute results. Functions, on the other hand, are sub-programs you can call to have certain tasks done. They might be pre-defined (such as the ones described on the language reference page) or written by yourself.
Now there are two exceptions to this rule, and maybe that's what's a bit confusing in the documentation: The functions setup() and loop(). These are functions, but make up the structure of your program. They are the main building blocks of an Arduino sketch, and that's probably why they're mentioned under "Structures".


Connecting via serial with Arduino comand line

If you are using linux, as I guess, you can look at this archwiki page. Even if is a wiki relative to archlinux OS some informations explained are LinuxOS independendent.

For your needs, you can use screen command. Here is an example: remember to substitute the serial port with the one wich arduino is connected (usually /dev/ttyACM* or /dev/ttyUSB*) and to specify the right baud rate.

screen /dev/ttyACM0 9600


Lag in fetching serial data from Arduino


How long does it takes for arduino to reach main()?

The ATtiny85 has a built-in delay counter that keeps the MCU in reset
mode for some time after the power is applied. This seems to be intended
as a wait for the clock and power to be stabilized. The length of this
delay depends on your selected clock source, and is somewhat
configurable with the fuses.

According to your code, your MCU is clocked at 8 MHz. I assume you
are then using the internal RC oscillator as a clock source. If this is
the case, you have three choices for the startup delay:

20 CPU cycles
20 CPU cycles + 4 ms
20 CPU cycles + 64 ms

The latter is recommended if your power rises slowly, and is the default
configuration in which these MCUs are shipped. If you power level rises
fast, you may want to select a shorter delay by programming the SUT
fuses. See the datasheet for details (section System Clock and Clock
Options → Clock Sources → Calibrated Internal Oscillator).


passing arrays via function returns wrong values

Your arrays are declared locally to the functions. You cannot return local arrays from a function - as soon as you return the arrays no longer exist.


According to the source code:

const static unsigned int max_frame_payload_size = MAX_FRAME_SIZE-sizeof(RF24NetworkHeader);

that would be 24 bytes. Maximum lenght of payload for NRF24L01+ is 32 bytes and the RF24NetworkHeader seem to be 8 bytes long. So you can send up to 24 bytes in one package.

EDIT:
Here is the stripped RF24NetworkHeader declaration code from which can be seen sizeof(RF24NetworkHeader) is 8 bytes.

struct RF24NetworkHeader {
  uint16_t from_node;           // 2 bytes
  uint16_t to_node;             // 2 bytes
  uint16_t id;                  // 2 bytes
  unsigned char type;           // 1 byte
  unsigned char reserved;       // 1 byte
  static uint16_t next_id;      // static member doesn't count for sizeof()
  RF24NetworkHeader() {}
  RF24NetworkHeader(uint16_t _to, unsigned char _type = 0): to_node(_to), id(next_id++), type(_type) {}
  const char* toString(void) const;
};


As jsotola already suggested in the comments, using interrupts for driving the motors does not make sense. With a L298N you simply set the outputs and then leave them alone until you think they should stop.

Instead you could use interrupts for your sensors.

Though I would argue, that using interrupts would not be really necessary, when you implement your code the right way, means non-blocking. You use a lot of delay() calls. where the Arduino does not do anything, just twiddling thumbs. Instead you could use the principle from the BlinkWithoutDelay example, that comes with the Arduino IDE, to write the code non-blocking. In that case every bit of code would only do something, if it needs to, and otherwise return fast. That would make your code run way faster. You would also need to set a lower timeout for the pulseIn() function, as it's standard timeout is 1s (ultrasonic sensors like you are using one normally can only sense up to 3m, would would correspond to 20ms max pulse duration, if I'm doing the math correctly).

If using interrupts is a mandatory part of your excercise, you can decide, where to use interrupts:

The simplest way would be for the IR sensors. You could use the attachInterrupt() function to set up an Interrupt Service Routine (ISR) for the corresponding pin. If you want the interrupt to trigger, when the IR sensors go HIGH, you can use RISING, otherwise you can use FALLING. Keep in mind, that ISRs should be as small and fast as possible. You cannot use delay() there. Normally one would only set simple (1 byte) variables in the ISR, and then react with longer actions in the main code by checking these variables. You have you set every variable, that can be changed in an ISR, as volatile:

volatile byte flag;

For the ultrasonic sensor, you have more than one way to go. I will outline 2 ways. For both of them you need to either directly manipulate the Special Function Registers of the microcontroller, or find a library, that does that for you (don't know, if such libraries exist, but you can search for them):

You could use the Pin Change Interrupt. It triggers everytime, when a pin from a full pin port (group of up to 8 pins) changes it's state. You can mask away unused pins, so that they will not influence the interrupt. In the ISR you can check the state of the pin. If it is high, the start of the pulse just happened. Save a timestamp of that moment with the micros() function. The next ISR (where the pin will be LOW) will mark the end of the pulse. Now you can calculate the time difference between the timestamp and the current micros() value. You should use a 1-byte variable as flag, to trigger the processing the the pulse duration in the main function (or, if you want to directly use the time difference variable, you need to turn of the interrupt, while you are using the variable).
If you want to show off, you could use a hardware Timer in Input Capture mode (this is the more complex, then the other possibilities). The timer is a counter, that is connected to the system clock (through a prescaler, where you can change the count frequency in a coarse way). The timer starts and when the Input Capture pin ICP1 (in case of Timer1) changes it's state, the current value of the timer will be saved in an extra register and an interrupt is fired. This timer value is like a timestamp. If you record the timestamps for the rising and the falling edge of the pulse, you can take the difference and calculate the time difference/distance from this. This part works similar to the first way above. The notes about interrupts also apply here.


Unable to obtain pulse train at 32Hz with 20us pulse width with Uno

For this kind of problems, the first thing to do is convert the two
relevant times (the signal period and the duration of the HIGH state)
into a number of CPU cycles. With a 16 MHz clock that gives:

HIGH time: 20 µs =    320 CPU cycles
period: 31.25 ms = 500000 cycles (±7%)

Then divide those numbers by the available prescaler values, to get the
corresponding number of prescaled clock cycles:

prescaler       1      8    64     256      ...
HIGH time     320     40     5       1.25   ...
period     500000  62500  7812.5  1953.125  ...

Ideally, you want a prescaler that gives you integer numbers, in order
to avoid rounding errors. And since you are using a 16-bit timer, you
want these numbers to be no larger than 216. Or twice that if
you use a phase-correct PWM mode, but I prefer to avoid that
complication if possible.

From the table above, it appears that a prescaler of 8 is ideal. 64
would be practically as good, with a frequency error of only
64 ppm, which is less than the frequency tolerance of the ceramic
resonator clocking your Uno.

Then you use either OCR1A or OCR1B to set the high time, depending
on whether you are outputting to pin OC1A (digital 9) or OC1B (digital
10). An you use either OCR1A or ICR1 to set the period. Since you
are outputting on pin 9, the OCR1A register will be used to set the
high time, thus you have to use ICR1 to set the period. Then you
search the table of modes in the datasheet and find the one relevant to
this mode of operation is mode 14: fast PWM with the TOP value
defined by ICR1. This gives the following configuration:

void configure_timer_1()
{
    DDRB  |= _BV(PB1);    // set pin 9 = PB1 = OC1A as output
    TCCR1A = 0;           // reset timer
    TCCR1B = 0;           // ditto
    OCR1A  = 40 - 1;      // HIGH for 40 * 8 CPU cycles
    ICR1   = 62500 - 1;   // period = 62500 * 8 CPU cycles
    TCCR1A = _BV(COM1A1)  // non inverting PWM on pin OC1A
           | _BV(WGM11);  // mode 14: fast PWM, TOP = ICR1
    TCCR1B = _BV(WGM12)   // ditto
           | _BV(WGM13)   // ditto
           | _BV(CS11);   // clock at F_CPU/8
}

Note that OCR1A and OCR1B have to be set to desired number of cycles
minus one.


attachInterrupt for mega 2560 not triggering

//create interrupt for button
attachInterrupt(digitalPinToInterrupt(5),count,CHANGE);

The code does not match the comment.

attachInterrupt(digitalPinToInterrupt(buttonPin),count,CHANGE);


Problems running Arduino project off a 9V battery

As soon as I connect up the battery, I loose the Serial Monitor connection (even though the USB cable is still connected). So I can no longer see what's going on inside the Arduino for debugging purposes. Why? How can I continue to see the Serial Monitor? Is there a way to see the serial output from somewhere other than the USB jack?

Probably because although the voltage is high enough to cut off the power from the USB port it's not got enough current to run the main MCU properly.

  I can tell by the lights on the board and by the behavior of the outputs that the software is malfunctioning. But I can't tell exactly why (because of #1). Why would changing the power source cause this?

Because 9V batteries can't provide enough current.

  I know that the VIN pin needs 7-12 volts. The battery I plugged in is a new 9V battery. But what happens as it wears down? Does it still push 9 volts? Or does the voltage drop? Can I tell my Arduino to stop functioning if the voltage drops below acceptable levels? Because ceasing altogether is better than malfunctioning.

No. The voltage drops rapidly to about 8V then down and down and down until it's below what the regulator can regulate. You can see this curve in any battery datasheet.

  I have read that I need to ensure that the current from the battery remains around 500mA. But how can I measure that in hardware/software? This ties back into question #3.

That's nonsense. The current demands will be whatever the circuit needs at any moment in time. There will be an upper limit to that demand (defined by your circuit and what you are doing at any one time - the peak current draw) and your power source has to be able to provide at least that amount of current.  If you try to draw more current than the battery can handle then the output voltage will drop to a level where it can no longer power the circuit properly. It is at this point you get "brownouts" and the board resets randomly and strange unpredictable things happen.

In short: never use a 9V battery for an Arduino project. It's fine for vert low power operations, which take careful design, but for general use stay away from them. Also the Arduino's built-in regulator is a very inefficient and will waste about 25%-40% of a 9V batteries power before you even begin. Instead you should use a more efficient switching regulator to provide 5V directly to the 5V pin (or USB port) from suitable higher capacity batteries (such as AA cells).

As a comparison here's some typical battery discharge graphs comparing alkeline AA to PP3 (9V). These are both Duracell Ultra.

As you can see the PP3 drops its voltage very rapidly even under a light load. Under a "heavy" load (what would be considered a very light load to an AA) it tumbles away to next to nothing in no time at all.


Are the Arduino Micro, Mini, etc plug'n play?

The ones that have a USB connector are plug-and-play with a USB host. The ones that don't need a USB-to-UART bridge.


Extract .hex from ATtiny45 using Arduino

Assuming the lock bits on the device haven't been set, sure. Simply prepare the Arduino for ArduinoISP, hook up the ATtiny45, and perform a read using AVRDUDE instead of a write (-U flash:r:foo.hex:i).


Mapping values from analog input giving unexpected values?

Note that the Arduino function "map" is really this:

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

...so, if you pass a "minimum from" value which is less than the actual value you are mapping from you will get a negative number given your "minimum out" is zero.

In several of your examples you have set the minimum to 20 but pass a value of 19.  If your program is intolerant of negative numbers (for instance, how would a negative number effect the PWM hardware), consider testing for lower than minimum and higher than maximum values before using the map function.


Connecting Arduino to internet through HC-06 and then smartphone

Yes, but not in quite the way you think.

In this case the smartphone is acting exactly like the PC when you have the Arduino plugged in to it. You have a serial connection. Theoretically you can:

Send a request to the smartphone over the serial bluetooth connection
Write some software on the smartphone to interpret that request and perform some action depending on what the request is

That way the smartphone is then acting like an incredibly expensive and bulky ESP8266.


A function-definition is not allowed here before '{' token

You are missing a "}" just before loop

  void is_astuon() {
    digitalWrite (astuonetas[0], LOW);
    digitalWrite (astuonetas[1], LOW);
    digitalWrite (astuonetas[2], LOW);
    digitalWrite (astuonetas[3], LOW);
    digitalWrite (astuonetas[4], LOW);
    digitalWrite (astuonetas[5], LOW);
    digitalWrite (astuonetas[6], LOW);
   } // <- missing here.
  void loop() {


Can SPI and serial.begin be used at the same time?

Yes. UART and SPI are completely different things.  One uses pins 0/1, the other uses pins 11/12/13, and they use separate hardware and control registers inside the chip.


POST request on Arduino MKR1400 GSM not working

The problem most likely stems from your Content-Length header.  You are using sizeof(postData) as the length of your content - however postData is a 200 byte array which is not used for anything. sizeof() will always return 200 for that regardless of what the rest of your program is doing.

Content-Length must be equal to the number of bytes after the second of the two \n separating the header from the body.  The best way to calculate that is up add up the length of all the strings that get inserted into the body formatting (using strlen() not sizeof()), and then add to that a constant value which is equal to the number of static characters (including \n) in the body (I make that 108 possibly?).

int dataLen = 108;
dataLen += strlen(resp);
dataLen += strlen(userid);
dataLen += strlen(location);
dataLen += strlen(toolName);
dataLen += strlen(toolid);
dataLen += strlen(toolState);
dataLen += strlen(timeStamp);
dataLen += strlen(notes);

Alternatively you pre-format the body into a separate string and use strlen() on that to get the length before starting to send data.  Of course, you don't need to store all the header in the string, since you can just send that line-by-line...

sprintf(packetData,"{\n\"responsable\":\"%s\",\n\"user_id\":%lu,\n\"loc\":\"%s\",\n\"tool\":\"%s\",\n\"tool_id\":%lu,\n\"tool_state\":\"%s\",\n\"timestamp\":%lu,\n\"note\":\"%s\"\n}\n",resp,userid,location,toolName,toolid,toolState,timeStamp,notes);
client.beginWrite();
client.print(F("POST "));
client.print(path);
client.println(F(" HTTP/1.1"));

client.print(F("Host: "));
client.println(ipstring);

client.println(F("User-Agent: Arduino/1.0"));
client.println(F("Connection: close"));
client.print(F("Content-Length: "));
client.println(strlen(packetData));
client.println(F("Content-Type: application/json"));
client.println(F("Cache-Control: no-cache"));
client.println();

client.print(packetData);

client.endWrite();

Note the use of F() around your static text to save copious amounts of RAM on AVR-based boards. Not really necessary on an ARM-based board, but a good thing to get into the habit of to keep things portable.

If you want to debug what is being sent I would suggest making a "debug" wrapper class that comprises both client and Serial:

class TwinPrint : public Print {
    private:
        Print *_ch1;
        Print *_ch2;

    public:
        TwinPrint(Print &ch1, Print &ch2) : _ch1(&ch1), _ch2(&ch2) {}
        size_t write(uint8_t c) {
            _ch1->write(c);
            _ch2->write(c);
            return 1;
        }
};

You can then construct a new object:

TwinPrint debug(client, Serial);

and do your writing to that and it will come out on both client and Serial at once:

debug.print(F("POST "));
debug.print(path);
debug.println(F(" HTTP/1.1"));

debug.print(F("Host: "));
debug.println(ipstring);

debug.println(F("User-Agent: Arduino/1.0"));
debug.println(F("Connection: close"));
debug.print(F("Content-Length: "));
debug.println(strlen(packetData));
debug.println(F("Content-Type: application/json"));
debug.println(F("Cache-Control: no-cache"));
debug.println();

debug.print(packetData);


How does Arduino decide when to go into flashing mode and normal mode?

It first runs the bootloader. If there is no data coming into the serial connection within a certain amount, i.e. it's not being programmed, it will exit the bootloader and start the actual sketch.

In the UNO you will notice a 3 second delay between providing power, and your sketch starting.


Switch between timer2 and manually setting output of pin 3

If you clear the clock select bits in TCCR2B, then the PWM stops and you can control the port normally. To re-start the PWM, set the CS20 bit just as you did in setup().


The basic technique is as you have tried to program. The time between stepper pulses if shortened to cause acceleration and lengthened to slow down. A real solution typically uses an "S" curve type acceleration profile that starts out with a slow ramp up to the acceleration rate and then as it nears the target rotational speed it slows the acceleration rate back down.

In your case you may be getting to the point where you have increased the acceleration rate too much and the motor cannot respond to it.


How to connect an ESP8266 using an ESP-01 adapter to an Arduino Uno?

Recommended tutorial

you can't flash an esp-01 module with this adapter, unless you find a way to connect io 0 to ground in this setup

I have this type of adapter with esp8266 glued. I can't recommend this type of adapter boards. Easier is to use a development board like Wemos or NodeMCU with on-board USB adapter. And they are cheap.

The adapter has the esp-01 2x6 header J2 but the io 0 and io 2 pins were not connected on my version. I patched io 0 to JP2 header to be able to flash the module. On the picture you see a paperclip jumper connecting GPIO0 to ground.


How would I go about measuring an analog signal on my arduino mega that has both positive and negative voltages

Here is my try at this: if your voltage source doesn't mind sinking
something like 150 µA, you could try something like this:

simulate this circuit – Schematic created using CircuitLab

This should map the input range [−70 mV, +50 mV] to
[0.04 V, 4.06 V].


The dimming problem was found to be the shift register IC not connected to Ground (dumb me).

However, there is still problem with LED's on and off pattern. Sometimes two LEDs turn on at the same time and all previous LEDS turning off before the last or second last LED is turned on. It turns out Pin 10 (SRCLR Bar) needs to be pulled to high to solve that pattern discrepancy.


Why can't I switch off the LED immediately using this sketch?

I can't see anywhere where you are assigning fadingState as true.I can't understand this part

if (fadingState == false) {
      // turn on the LED
        for (int i = 255; i >= 0; i -= 5) {
          if (buttonState == HIGH && fadingState == true) {
          analogWrite(ledPin, 0); //immediately off
          i=-1;
          }
    analogWrite(ledPin, i);
    delay(fadingDelay);
    }

If you are entering in a if condition with statement fadingState as false. Then in for loop you are having a if condition in which statement is fadingState == true.If you are entering in as a False then why are you looking for True Condition.

Then if you manage to sort that add break; in that if condition so that when LED turns OFF you will exit that for Loop.

And Here you are setting the button state as low buttonState = LOW if first If condition, then in that nested if without reading the buttonState you still looking for it as HIGH.


Arduino Interface with Serial device and LCD display

If the device is serial and you want to connect it to the Arduino serial port, why would you use a usb-to-serial converter?
For a serial to serial connection, you have to connect TX, RX and GND.
This is the bare minimum for bidirectional communication, if your device is really read only, you can use just the TX and GND.
it depends how you receive data from your "serial device" - btw, what is it? If the data comes as either ascii or individual characters, then it's easy: treat them as strings and display them separately. If the numbers arrive in binary format, you have to perform the conversion to string.

Questions like this should have attached at least a snippet, if not all, of code.


Teensy not pulling down despite digitalWrite(x,LOW)

You forgot to set the IO pin to OUTPUT. Unless you do so all you are doing (if the Teensy core follows the Arduino API to the letter) is controlling the internal pullup.

pinMode(PIN_LOW_FOR_POWER, OUTPUT);


wire up usb to pins rather than on board usb socket

You will have to (optionally) desolder the existing USB socket and solder the wires to the pins where that socket was on the board. It connects directly to the pins of the CH340G surface mount chip (rectangular one by the USB socket) and soldering wires to those pins would be tricky.


This logic level converter does not want to work

The TSX0108 doesn't magically provide you with a regulated voltage. You have to provide the voltage, the TSX0108 merely switches it.

As you can see from the datasheet, the basic wiring is:

In the circuit above the 1.8V connection is your 3.3V connection, and the 3.3V is your 5V connection.

You must provide both the 3.3V and 5V power sources.


Why do i get additional characters when reading a file through a buffer if buffer size > 15?

Try recording the actual number of bytes read and only write that number of bytes:

size_t nr = file.read(buffer, bufferSize);
client.write(buffer, nr);


You have to edit the programmers.txt file. (The one in ~/.arduino15/packages/arduino/hardware/avr/1.6.21/, not the one in arduino-1.8.x/hardware/arduino/avr/)

avrisp.name=AVR ISP
avrisp.communication=serial
avrisp.protocol=stk500v1
avrisp.program.protocol=stk500v1
avrisp.program.speed=115200
avrisp.program.tool=avrdude
avrisp.program.extra_params=-P{serial.port} -b{program.speed}

Add a avrisp.program.speed option, and pass this option as one of the extra_params to the command line call of avrdude.
It is then used on line 112 of platform.txt:

tools.avrdude.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} {program.verify} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i"

You could of course also make a copy of that avrisp entry, and add your own programmer, just give it a different name.


Arduino Uno with Kubuntu 16.04: Unable to enumerate device

You should solder the resistor (in case you do not have the skills I reccomend doing into a proffessional, a professional close to me managed to solder it with a cost about 5 euros) and then hardware reset the atmega8u2 the documentation mentions. For quick reference just look over in this image:

In the dmesg you will see similar the same or message:

[ 1544.679504] usb 1-6: new full-speed USB device number 42 using xhci_hcd
[ 1544.808341] usb 1-6: New USB device found, idVendor=03eb, idProduct=2ff7
[ 1544.808350] usb 1-6: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[ 1544.808356] usb 1-6: Product: Arduino Uno DFU

Then look on the similar question for R1 boards or in case you have a newer board then follow the instructions mentiones to the documentation.


UART communication issue on Arduino Mega

Serial.flush() only empties the output buffer, so that won't achieve anything. Reading exactly 9 bytes and hoping they match the input stream is not very effective, as you found. If you are out of sync with the incoming bytes, you will stay out of sync.

It would be better to keep reading (single bytes) until you get 0xFF or 0x86 and then read the rest.


Minimum number of Pins to use for multiplexing LEDs

It depends on the style of multiplexing.

For basic Row-Column multiplexing you have N=RC - the number of LEDs is the number of rows multiplied by the number of columns. The LEDs, of course, don't have to be arranged physically in rows and columns, those are purely logical wiring concepts.

For Charlieplexing (used by the LOL shield) it's slightly more complex. The formula is: N = n² - n, where n is the number of pins, and N is the number of LEDs they can drive.

Charlieplexing can multiplex far more LEDs than traditional R/C multiplexing, but is harder to program for and wire up.


Connect 4 HC-12 transmitters to 1 HC-12 receiver

When a HC-12 is transmiting all other HC-12 in his range (using same frequency) are receiving. So if you want your transmiter to talk to one specific HC-12 then to an other and so on, you have to create a kind of "message protocol".
Let's say you have an Arduino with a HC-12 and 4 buttons and want to turn on-off 4 lights, each connected to a HC-12. You can use a binary representation, so a byte, on which each bit as a meaning.
Bit 0 -> at 1 -> turn on the light at 0 turn off
Bit 1-2 -> give the number of the HC-12
So 00000111 -> message for HC12 number 4, tell it to turn on the light.
ALL HC-12 will receive the message. So each has to check the incoming byte to see if "it's for me" or nor.
If you want one HC-12 to receive from many HC-12, that's the same: the message must contain the "id" of "who is sending".


SoftSerial freezes on comparing getInt to int

There is no point in using SoftwareSerial on pins 0 and 1, as you have HardwareSerial for that. Whatever the sketch does once it starts will not affect whether or not it uploads. If you have something connected to pins 0 and 1, during the upload, that may well stop the upload working, but what the sketch does afterwards does not.

It is hard to tell from your snippet, but if you also have activated HardwareSerial - eg. Serial.begin(9600); - then the hardware takes over those two pins and SoftwareSerial won't work anyway.


So. You say you have build an Arduino on a breadboard, is that right?

Have you checked all the pins, so they are all connected up properly? Can you post some pictures of the protoboard? Maybe you missed something, didn't connect all GND pins to each other if there are more on the arduino or something.
You can power the Arduino using a 3.7 Lion or Lipol battery using a boost-converter, here is a great video explaining how you can build your own (https://www.youtube.com/watch?v=QnUhjnbZ0T8), or you can just order one from Ebay.

Great Scott (the author of the video) also made a video on how to create a standalone Arduino: https://www.youtube.com/watch?v=J3DYgzRvLT8 . Check the videos out! Hope I helped you.


I was just able to send an SMS (even with the 1A supply). Here the answers to my questions.

No, it is not necessary to flash the SIM900 board
I was not connected, because I didn't insert the SIM card properly on the shield.
No it does not necessarily need 2A for logging into network and obviously not for sending SMS though there might be reasons for the board consuming 2A during SMS sending, e.g. bad network connection.
If you want to use Sotware Serial, you need certain digital lines allowing software interrupts. In the case of the MEGA board, e.g. D10, D11 or for the UNO D7,D8.
I was using this tutorial to get communication via SoftwareSerial working. Afterwards I added the code for sending SMS.

I hope I can help some others who are looking for a low level description of how to get started with MEGA and SIM900.


Connect a USB slave into Arduino using FTDI

No, that is completely wrong.

In USB you have hosts and devices. A device has to connect to a host. Your FT232 is a device. The barcode scanner is a device. Both of them need to be connected to a host for them to do anything.

So you need a USB host shield to act as that host.

However - check the manual for your barcode scanner: it may well have a RS-232 mode that it can be switched into (may need a different cable attached).


Reading from SPIFFS - What's the best way to deal with a string (or char) array with undefined length?

Well, you cannot use more memory than you have. If the length of file names is (probably/possibly) too much, you just cannot store it in memory. Some alternatives:

Use some compression... This will save you a bit, but at the end if you don't know how much the maximum bytes you need to store is, it will not help much
Use external SRAM memory... You need to write your own memory functions. Also a slight performance hit.
Use SD card memory... As SRAM, but much slower. Also not sure if you can use the same SD card to write on.
The best solution, but could be a big performance hit, is not to store at all the file names, but go through the file names and process what you need along the way. This is not always possible or feasible though. In your solution you can print the file names directly without storing (but I guess you want to do some additional processing).


What is the purpose of Galileo (or other unremovable chips)

Edit: As Chris points out, this answer is more about the simple AVR Arduinos. For comment on the Galileo and other more complex MCUs, please refer to Chris' answer.

For Arduino compatibility you can program the Arduino boot loader into the microcontroller using the ICSP pins. You do not need a chip from an Arduino board, you just solder a blank one in. Once the boot loader is on there you can use the Arduino IDE to upload sketches via the UART.

It is not necessary to use the Arduino system to write programs. You include the Arduino library files in a normal C++ project in many different IDEs and use the avr toolchain to compile and avrdude to upload.

Update:

Here is an example of a board I just got back from PCBA. (The picture was sent by the PCB company for checking). Initially I made the board using an Arduino Pro Mini 3.3V, SD card breakout board, LSM303DHLC accelerometer breakout from Pololu, and Real Time Clock (RTC) breakout. Once everything was working I drew up a PCB in Eagle CAD, using the core of Arduino Pro Mini board plus the individual SD card, LSM303DLHC and RTC chips. I also added a 3.3V boost converter so I could get a constant 3.3V off 2 AA batteries.

The board has the ICSP pins broken out. Actually, you will find they are broken out on most Arduino boards. Using another Arduino as ISP I can program the Arduino boot loader via the ICSP pins, and then sketches can be uploaded via the UART using the Arduino IDE. In the IDE the board that is selected is "Arduino Pro Mini 3.3V 8MHz".

The Arduino boot loader is a small piece of firmware that runs on startup. It allows you to send a program over the UART which it stores into FLASH memory itself. It is not absolutely necessary. You can program the chip using the ICSP as well. It is really convenient however. Using software like xloader you can upload Arduino programs without the IDE. Really handy when other people are using the board and you don't want to share your code. Alternatively, you can write a script for avrdude to do it.

This project is for a university so I'm leaving it as Arduino compatible. In a commercial engineering environment, I would choose a more appropriate MCU (one with lower power consumption for a battery device) and rewrite the program to be more efficient and not rely on the Arduino and third-party libraries.