Super slow serial (UART) communication on Arduino

I think the problem is not so much in the update speed, but in the fact that you loose accuracy in your calculation. The following lines are the culprit:

int kphValue = 0;  // [-32768:32767]
int mphValue = 0;
mphValue = kphValue * 0.621371;

Make sure the calculation will be entirely in integers to prevent calculation errors:

uint16_t kphValue = 0;  // [0:65535]
uint16_t mphValue = 0;
mphValue = ( kphValue * 621 ) / 1000;

This limits kphValue to just over 100, if you want to go higher than that there are two option:

multiply by 62 and divide by 100;
use longer integers int32_t [-2147483648:2147483647], which comes with enough room for multiplying by 621371 and dividing by 1000000, but will perform slower and with a larger memory footprint. Do you really need that accuracy?


How to store u-blox coordinates (lat, lng) values in doubles? [TinyGps++]

You forgot the , 8 from your println that specifies that it should print 8 decimal places. Instead you seem to have added it to the end of an assignment which makes absolutely no sense whatsoever.

double latcord = gps.location.lat();
double lngcord = gps.location.lng();

Serial.println(latcord, 8);
Serial.println(lngcord, 8);


Sending struct from Arduino to Raspberry Pi - wrong types

It is not a size problem: uint32_t is always 32 bits. Converting the
numbers to hex gives:

Raspberry to Raspberry: 0x00000000, 0x00000016, 0x0000002c
Arduino to Raspberry: 0x14000000, 0x2d000000, 0x00000000

There seems to be an offset between the two. You may just have lost one
byte when the Arduino is the sender. There may be also a byte order
issue, but your test is not sufficient to say. You can, e.g., send a
series of 0x12345678 to know for sure.

You need to devise a way of synchronizing the communication, i.e. to
identify, in the byte stream, which is the first byte of the packet.

Edit: Let me illustrate how this can happen both with and without
and endianness issue. I'll assume you are transmitting
{status: 0, temperature: 20, humidity: 45} and the first byte(s) of
the first packet are lost. On the receiving side, you combine the
remaining bytes of the first packet with the first byte(s) of the second
packet, and interpret the whole as a single packet. You get:
{status: 335544320, temperature: 754974720, humidity: 0}.

In a little endian to little endian scenario, you only need to loose one
byte:

original data:     0x00000000, 0x00000014, 0x0000002d
transmitted bytes: 00 00 00 00 14 00 00 00 2d 00 00 00
received bytes:    00 00 00 14 00 00 00 2d 00 00 00 00
received data:     0x14000000, 0x2d000000, 0x00000000

In a big endian to little endian scenario, you get the exact same result
if you loose 4 bytes:

original data:     0x00000000, 0x00000014, 0x0000002d
transmitted bytes: 00 00 00 00 00 00 00 14 00 00 00 2d
received bytes:    00 00 00 14 00 00 00 2d 00 00 00 00
interpreted data:  0x14000000, 0x2d000000, 0x00000000


Powering an Arduino Pro Mini directly from a LiPo

The only thing about the 3.3V Pro Mini that is actually 3.3V is the 3.3V regulator.  The main chip (pretty much the only other component) is good for anything from 1.8V up to 5.5V.

Running direct from a 3.7V LiPo or Li-Ion will be perfectly fine.  You might want to disconnect or otherwise disable the regulator though to reduce current consumption - the latest Minis have a solder jumper SJ1 for doing just that, but older versions you may want to actually cut the 3.3V OUT pin of the regulator or de-solder it entirely.


One way to clean that up is to create a "Globals.inc" file and cut and paste all of your globals into there.  After that's done, simply include the globals file from your main .ino file with #include "Globals.inc"

(Main.ino)

#include <Wire.h>
// For LED Backpack
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
// For LCD Shield
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>

// For pixel Units, such as hero
#include <Unit.h>

#include "Globals.inc"

void setup() {
  /* Important Setup Routine */
}

void loop() {
  /* Important Main Loop Routine */
}

(Globals.inc)

Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();

Unit *hero;
boolean doesNeedRedraw = true;
boolean textNeedsRedraw = true;
int8_t lastButtonPress = 0;
// 0-255
uint8_t frame = 0;

static const uint8_t PROGMEM
  smile_bmp[] =
  { B00111100,
    B01000010,
    B10100101,
    B10000001,
    B10100101,
    B10011001,
    B01000010,
    B00111100 },
  neutral_bmp[] =
  { B00111100,
    B01000010,
    B10100101,
    B10000001,
    B10111101,
    B10000001,
    B01000010,
    B00111100 },
  frown_bmp[] =
  { B00111100,
    B01000010,
    B10100101,
    B10000001,
    B10011001,
    B10100101,
    B01000010,
    B00111100 },
  walls_bmp[] =
  { B10100000,
    B10110000,
    B10010000,
    B11011100,
    B01000100,
    B01110100,
    B00010100,
    B00011100 };


How to correctly use functions that return pointers to multiple typedef'ed types in Arduino IDE?

The Arduino IDE, rather annoyingly, tries to "help" you by generating function prototypes for functions, something it sometimes fails to do.

You can make your code compile by adding one yourself:

typedef struct {
  int x1;
} x;

x *a;

x *f(void) {
  return a;
}

typedef struct {
    int  y1;
} y;

y *b;

y *g(void);    // <------------------ ADD THIS
y *g(void) {
  return b;
}

void loop(void) {

}

void setup(void) {

}

I have a post about how to avoid the quirks in the IDE which may help you.

If you just move your code into a separate .CPP file and leave the main sketch blank, it will compile, if you add this line to the start of the .CPP file:

#include <Arduino.h>

The Arduino IDE uses gcc, so it isn't a problem with the compiler exactly, it is a problem with how it "helps" you.


UART communication, is it possible to use only the TX line?

Yes.

You can connect only the the line with which the ESP-01 transmits to the Arduino's receiver, and accomplish one-way data transfer.

However, the ESP will have to be willing to transmit without prompting, and you will not be able to use the Arduino to setup or configure it.  Further, you will not be able to use any in-band signalling to ask the ESP to refrain from sending, so you will have to be sure that your Arduino sketch is generally ready to claim any input which may arrive, and that if there are periods when it is not, the behind-the-scenes serial buffer is large enough.

There's also the question if it is safe to connect the ESP transmit pin directly to the Arduino receive.  In the intended direction of operation, it is.  But should you ever load code on the Arduino which uses that pin as a GPIO output, there is some risk of damage to the ESP.  It's up to you to decide if careful usage will be enough to prevent that; if not, you may want to try something like a 1K series resistor and a schottky diode to clamp the line to the ESP's 3.3v supply, in a way that diverts the current from any accidental 5v output around any internal protection diode that may have more limited power handling.


No, you can't use a NodeMCU for this.

To emulate a USB keyboard you have to have a device with a main MCU on it which is directly connected to USB. The ESP8266 on the NodeMCU is not a USB-capable MCU, and so it uses a USB to UART bridge chip to connect the ESP8266 to the USB of your computer.

You can't program that bridge chip, so you can't make it anything other than a serial port.

Common devices that are directly USB connected and can emulate a keyboard include:

Arduino Micro
Teensy 3.X
Fubarino Mini / SD
Arduino Leonardo
chipKIT Lenny

And there are many more.

For 8-bit Arduino boards you need to look at the MCU it uses. If it's an ATMega32U4 as the main MCU then you can program it to be a keyboard.

Addendum: There are ways of making non-USB boards work as a keyboard. For ATMega328P based Arduinos and similar that use an ATMega16U2 chip as the USB to UART bridge, that bridge chip can be reprogrammed to appear as a keyboard.  For other MCUs there may be software "bit-banged" USB implementations available (such as V-USB), though YMMV with those implementations, and they require building extra hardware to interface the chip to the USB port.


Connecting two Arduinos via I2C while I2C Pins A4/A5 are already in use

Use the ADDR pin as a chip select. Pull both pins high normally. When you want to talk to one, pull the ADDR pin low and use the ADDR = 0 address to talk to the selected device. Then you can have all 6 connected to one Arduino.


The answer to no ouput, and suspecting your data source is to replace the data source with a constant value or a string until you get that problem sorted, and then go back to your data source and debug that if necessary.

That said, I don't see any issue with you trying to print the output of an analog read. Obviously you should get something, even if it's just a single zero on each line, twice a second.

Is your monitor the Arduino built-in monitor?
Is it set to 9600 baud, as you've set your output rate in the program?
Is there anything else connected to the Tx pin, Pin-1 (Arduino numbering, not chip numbering)?
There were no error messages from the compiler or loader, right? (The libraries, bless-'em, always get a few warnings; unfortunately we have to ignore those).
You've no reason to believe the Arduino is other than 100% good?


When using a cheap knockoff Nano, it seems that in the newer versions of the Arduino IDE (at least in 1.8.8), you may need to select "ATmega328P (Old bootloader)" from the Processor options under the Tools menu in order to upload sketches.


Unable to alter SPI speed on Arduino Micro

As was pointed out in the question comments, your use of unsigned int is the problem. The prototype for SPISettings is:

SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) {

The comments in spi.h say:

// We find the fastest clock that is less than or equal to the
// given clock rate. The clock divider that results in clock_setting
// is 2 ^^ (clock_div + 1). If nothing is slow enough, we'll use the
// slowest (128 == 2 ^^ 7, so clock_div = 6).

So your SPI speed will be the processor speed divided by 128, which is 16 MHz divided by 128, being 125000 Hz, which is your observed result (since unsigned int cannot possibly hold more than 65535 on this platform).


how to set the pin 13 only HIGH for 1 minute if sensor at pin 8 give HIGH?

Just add delay after you turn on pin 13. So it would be:

int PUMP = 13;
int sensor = 8;
int val;

void setup() {
  pinMode(13, OUTPUT);
  pinMode(8, INPUT);
}

void loop() {

  val = digitalRead(8);

  if (val == HIGH)
  {
    digitalWrite(13, HIGH);
    delay(60000); //60000ms is 1 minute
  }
  else
  {
    digitalWrite(13, LOW);
  }
}


Making HTTPS requests using ESP8266 AT commands

HTTPS requires that you make an SSL connection not a TCP connection.  To do that you need to use
AT+CIPSTART="SSL","54.166.71.140 ",443

You also need to configure SSL itself.
However the SSL support is not great and struggles with some sites (no SNI support by all accounts).
So you're better off programming the ESP8266 directly with your own sketch to make any HTTPS requests and process the data for you.


Can I use GPS sensors in a country (India) that doesn't have its own GPS Sattelites?

Each of the countries listed has their own satnav system. GPS satellites cover the entire world and the US government allows anyone with a GPS receiver to use it, regardless of where on or above the surface they are located.


file directory for saving .cpp & .h for the Arduino IDE for short #include statement

If you think you will be reusing this code frequently, you might want to make a library as suggested by Joachim. Your library can then be added to any sketch you write using a #include statement.

The arduino website has a nice guide on writing libraries, check it out here.

If you would just like to include your header file in a sketch without writing a library, placing the header file in the same directory as your sketch should compile if you use #include "header_file_name.h".


VGAX library only allows 4 colors, library or hardware limitation?

It's a memory limitation. The ATmega328 has 2 KB of RAM, and a 120x60 framebuffer at two bits per pixel (four colors) uses 1.8 KB. There's no room for more.


Is my code triggering the N-Channel MOSFET as I have intended to

The code is as follows: After 10 seconds following Arduino power up, burn the nichrome for 60 seconds, after which do nothing. I just tested it on my UNO and it works fine, so it must be your circuit. Post your nichrome question in the EE forums for help on that.

P.S. This code is kinda silly tho there's no trigger event!


Making pushbutton behave as a toggle switch with ezButton - do I have to use ledstate with =! operator

I've been looking through the source code for ezButton.c
The function isPressed() is something of a misnomer and is only meaningful for a push-to-make button on the low side of a pull-up resistor. It actually detects falling edges of the signal, so it should be called isFallingEdge(), but the code itself is good.
Similarly for isReleased() which detects rising edges of the signal, so should be called isRisingEdge().
The constructor defaults to INPUT_PULLUP which may (or may not) be what you want for your buttons and toggle switches, so it's something to bear in mind especially for low-side push-to-break buttons or high-side push-to-make buttons which will generate rising edges when pressed and falling edges when released thus reversing the meanings of isPressed() and isReleased(), hence why they really should be called isFallingEdge() and isRisingEdge().
The algorithm in ezButton::loop() could be optimised a bit by getting rid of previousSteadyState and nesting the final if statement within the second if statement.
Other than that, it's quite a good algorithm that makes use of hysteresis to reset the debounce timer.
For comparison you could take a look at my algorithm in this simple debouncer for Arduino that simply detects rising edges, falling edges or both edges without regard to whether a button was pressed or released, and can be used in a polling loop or with interrupts. Here's the essence of the algorithm:
    bool input_state = digitalRead(INPUT_PIN);
    unsigned long current_ms = millis();

    edge = rise = fall = false;

    // Hysteresis:
    //   If there is no change, reset the debounce timer.
    //   Else, compare the time difference with the debounce delay.
    if (input_state == output_state)
    {
      last_ms = current_ms;
    }
    else if ((current_ms - last_ms) >= DEBOUNCE_DELAY_ms)
    {
      // Successfully debounced, so update the outputs.
      rise = input_state && !output_state;
      fall = !input_state && output_state;
      edge = rise || fall;
      output_state = input_state;
    }

And ledState = !ledState; simple toggles the value of ledState which is what you write to your LED with digitalWrite(led1, ledState); each time a falling edge is detected in the input signal.


Failed to read DHT22 sensor using Arduino Uno

I suggest you to modify the following lines of code to check which reading has issue.

if (isnan(h) || isnan(t) || isnan(f)) {
   Serial.println("Failed to read from DHT sensor!");
   return;
}


This is a symptom of the arduino IDE. libraries can't add other libraries to the include path, but the can use other libs if they have already been included. you can use an error directive so your compiler output is more informative at least

#ifndef Servo_h
    #error "ServoMotorController Lib requires Servo.h to be included first to function"
#else

Arduino 1.5.6 beta's new library format has a section for dependencies in the new library.properties file that should allow one library to add another to the include path, but I'm not entirely sure if the functionality is fully implemented yet (its beta after all).


If you want to do it manually, rather than using the standard tools (dtostrf() for example) then you need to think mathematically.

A floating point number is made up of two distinct parts - the integer part and the decimal part.

For instance the number 123.4567 is made up of the integer part 123 and the decimal part 4567.  Chopping off the integer portion is simple to do, and if that happens to be just one digit then you can simply add that as the first digit of your output.  In this case, though, it isn't.

So what to do?  Simple: keep dividing the number by 10 until it is just one digit.  But be sure to count the number of times you divide by 10.  So the example above would end up as 1.234567 with a divide count of 2.  This is the same as the scientific representation, 1.234567×10².

So now you have it divided you can chop off the integer (just cast it to an int), add that integer part to your string, then remove it from the source number.  So you end up with "1" and 0.234567 and a count of 2.

Now multiply by 10 and subtract one from your count, so you get 2.34567 and a count of 1.  Grab the integer portion and add it to your string, then remove it from your number.

Keep repeating until your count is 0, at which point you have now done all the integer portion - so you can now add a "." to your string.

You now just keep repeating the same process again and again until the absolute value of the count equals the number of decimal places you want to print.

For negative numbers you should start by placing a "-" in your string, then taking the absolute value of the number (the number as a positive).

Or you just use the standard library function dtostrf().


If you are still searching for a lib check out:
https://github.com/adafruit/Adafruit_Python_BluefruitLE

Its specifically made for BLE communication on OS X or Linux by wrapping the corebluetooth and its Linux equivalent bluez in a python lib. Windows is not supported at this moment.

Unfortunately there is no documentation to it. You will have to read the examples and search for specific functions in the lib manually.


Use Arduino Yun Shield as ISP for bootloaded ATMega328-PU

It's highly unlikely you will be able to do it from the IDE. Instead you will have to do it from the Yun's command line (SSH) using avrdude and the linuxgpio driver, or the handy run-avrdude script.

$ sudo run-avrdude bootloader.hex

where bootloader.hex is the bootloader file found somewhere in the IDE that you need to copy over to the Yun with scp.

You may find you need to tweak the fuse settings in the script to get the bootloader to work. I am not familiar with AVR fuses, but IIRC there is one that tells it to run the bootloader instead of the sketch. Just copy the values out of the boards.txt in the IDE and place them into a copy of /usr/bin/run-avrdude in your home directory.


ESP8266 still connects to wifi even after flashed with empty sketch

The Espressif esp8266 SDK remembers the SSID and password on flash to start connecting immediately after boot. The WiFi channel is stored in the RTC memory (cleared on power down)

You can control this with WiFi.persistent() and WiFi.setAutoConnect().


Upload already compiled code on Linux CLI without arduino-cli

Use avrdude.

The command format is simple, assuming you have installed it from the Linux repositories:

avrdude -carduino -patmega328p -P/dev/ttyUSB0 -b115200 -Uflash:w:/path/to/project.bin.hex:i

Depending on what bootloader is installed in your nano you may need to change the  baud rate (-b115200) to 57600. Also, of course, the USB device should be set to what your board actually identifies as.

The breakdown of the command is:

-c<programmer type>
-p<part name>
-P<port>
-b<baud rate>
-U<instruction>

The programmer type, part name and baud rate can all be gleaned from the boards.txt file in the AVR core files.  For example, for the Nano:

nano.upload.protocol=arduino
nano.menu.cpu.atmega328.upload.speed=115200
nano.menu.cpu.atmega328.build.mcu=atmega328p

relate to -c -b and -p respectively.  The instruction will always be the same, and means "Write to flash the following file in IHEX8 format".  "flash" is the destination memory, "w" is the write command, and ":i" at the end defines the expected file format.

On a Linux computer with avrdude installed you can find much more information with man avrdude.


Options for communicating between Arduinos

There are a number of concepts that can help you realize your dream. I can't, in the space of this answer, tell you exactly how to implement what you want, but I can show you the concepts that will help you to implement it.

First off there's the concept of the bus master.  This isn't necessarily the device that instantiates communication - instead this is the device that owns and controls the bus.

When a device that isn't the bus master wants to communicate on the bus it first asks permission from the bus master.  The old Z80 (well, I say "old", but they are still in use in many forms today) used this concept to allow other chips to use the data and address buses. It consists of two signals - BUSRQ and BUSACK.  A device first looks to see if either of BUSRQ or BUSACK are active, and if neither are it then activates BUSRQ. If the bus master is willing to give up the bus to the other device (it's not using it at that moment) it activates BUSACK and the other device then knows that it can use the bus.  Nothing else can use it until BUSRQ and BUSACK have both been released.  Nice and simple and elegant.

But not perfect. If two devices both decide to ask for the bus at the very same instant you get a collision.  This is a common problem amongst shared bus systems like this, and causes untold problems unless you know how to handle it properly.

Enter the concept of listen-while-you-talk.  This involves the device that is sending on the bus also listening to what is being sent on the bus through a separate receiver.  It then can know if what it sent on the bus is what actually ended up on the bus.  For instance if two devices talk at the same time and one sends 10011001 and the other sends 11001100 the result that appears on the bus might actually end up as something else, such as 11011101 or maybe 10001000 depending on how the bus signals are created.  So if you know what you sent got corrupted you can now do something about it.

Next concept: backing off.  This is where both the senders wait for a short period and try and send again. As long as they both delay for a different amount of time the first one to try will get the bus and be able to communicate. But how do you guarantee that they will both delay for different times?  You may think the answer is simple: use a random number, like rand() or random().  But that is also problematic:

Another concept: The pseudo random number generator

The Arduino doesn't generate random numbers.  It just uses a complex mathematical formula to create a sequence of numbers that, to us, look random.  They aren't though.  Write a small program to print 10 random numbers through serial and run it multiple times (press the reset button).  You will find the same "random" numbers in the same order every time.  Try it on another Arduino and you get the same numbers again. Always the same.

So what to do?  The answer is called seeding the random number generator.  The next number generated by rand() et al depend on the number that had been generated last.  So change the first number and all the rest of the numbers will change.  However, you have a catch-22 situation. You need a random number to seed the random number generator to make it random to be able to generate a random number to seed the random number generator... ad infinitum.  You see where that's going? You can't seed from rand() since rand() isn't random until you have seeded from a random source. So you need to find a random source.

And that's not an easy task.  The best source of entropy as it's known is white noise. This can be generated in a number of ways with a number of different circuits - from the breakdown of a diode junction to very high gain amplification of the thermal fluctuations in a resistor.

All are quite complex for what you want really, but there is a simpler, if slightly less random, method - read an analog input that isn't connected to anything.  It won't have as much of a range as a proper entropy generator, but it should provide enough randomness to give a reasonable chance of each device getting a different seed.

Another useful concept is the interrupt.

This is good in a situation where you don't want the complexity of a multi-master bus with all the collisions etc. You have a single master that does all the work on the bus, and when a slave device has something important to say it nudges the master with an interrupt. The master then goes "Yes? What do you want?" to which the slave replies "Someone pressed my button".

That way the master isn't constantly polling the slave to see if the button has been pressed.  It is often used in bus arrangements like SPI and there are many chips, such as IO expander chips, that can assert an interrupt when one of their input pins changes state.

But if you have 20 devices does that mean you have 20 interrupt pins?  Not necessarily. New concept: wired OR.

It's perfectly possible to have multiple different slaves all using the same interrupt pin.  The pin is normally held HIGH with a resistor (it could be an internal pullup resistor) and each slave has an open drain output connected to that pin.  An open drain output, when "off", is not connected to anything - it's like the pin is in input mode (in fact it can be emulated on chips that don't have open drain by switching between input and output mode).  When the output is "on" it connects the pin to ground, pulling down the IO pin, just like a button would.

It's then up to the master to make its way round the slaves that it knows are attached to that interrupt to see who needs attention.  You can of course implement a number of different interrupt pins with different groups of slaves on each one - maybe a high priority one with just one device, and lower priority ones with multiple devices on each, for example.

The same concept of wired OR and open drain can be used for allowing multiple devices to all share the same physical wires.  That is exactly how I2C works - the two bus lines are pulled up by resistors and the devices on it use open drain outputs to pull the line low to release it back to high to create the different logic levels. If two devices both pull it low together it will just be low.  Without the open drain method if you had one device outputting a 1 and another outputting a 0 you would basically get a short circuit between the two and you would end up damaging chips.

And then of course you have the concept of synchronous versus asynchronous communication, but that is an entirely different kettle of fish. Simply said though, protocols with a clock, like SPI and I2C, which have a master generating that clock, are synchronous. Protocols like the UART and RS-232, RS-485, etc are asynchronous - they rely on both ends agreeing on how fast data is being sent (baud rate) so they know how to interpret the signals as they arrive.


Can anyone explain how this code can be converted to work on a Arduino Uno

This should help get you started but don't expect it to actually work as it is. Note that i did not test this at all, it's for example purposes.  if there is a specific programming problem it should be addressed separately instead of handing out working code.

const int CALIBRATION = 0.200;   //Calibration Constant
int pin = 2;                     //Pin it's on, this is int0 for uno.
volatile int rain = 0;           //Used in interrupt routine

void setup() {
    Serial.begin(9600);
    pinMode(pin, INPUT);
    attachInterrupt(digitalPinToInterrupt(pin), cn, FALLING);
}

void loop() {

     /* Output OR LOG DATA HERE
        Also You need a Time Library and RTC (Real Time CLock) the above
        code is for a raspberry pi that has all that. */

}

void cb() {
    rain = rain + CALIBRATION;
}


You can't determine if there is a valid USB source on the UNO without modifications, because the Atmega328P just receives serial data when the host sends some data. Some approaches that you can keep in mind.

If you want to determine whether you are connected through the USB or barrel connector, you can connect an analog pin to the Vin pin through a voltage divider (you should calculate the values so that you do not exceed 5V on the analog pin). This way if you detect a voltage greater than 6.6V you will know that you are being powered from the barrel jack.
If you want to detect a particular PC, you can write a SW in the PC which scans for new ports, then opens them and sends a particular string. If you receive that within X seconds, you know that you are connected to the PC
If you want to determine if you are connected to any valid PC, then I think you will need to modify the program in the Atmega16u2 which is used as a serial bridge between the two. I'm not sure whether it is possible or not, but I think that the Atmega16u2 knows when a valid USB session is started, and so can tell the Atmega328 this information (through the serial interface)


Arduino losing connection to Serial port after running function

Your str variable in function Sendsignals is short. sprintf writes 5 bytes to it, 3 digits, the \n and terminating zero. The terminating zero is written outside of the allocated array and causes the crash.


Is there a way to "list" (in BASIC, or "cat" in LINUX) the current sketch loaded in my xxxDUINO?

No. the code burned in an Arduino is compiled not interpreted like Basic.

Basically your C language sketch is compiled into AVR assembly language. The resulting hexadecimal is what is burned to the Arduino.

Yes you could disassemble the hex like we used to do in the good old days, but as before it is highly unpredictable and most of the time not very useful.

Just a quick example. The following simple Arduino sketch that just sets a pin in output and then sets it HIGH:

void setup() {
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);
}

void loop() {
}

The resulting hex file is 3.5Kb.This include various sections of data and code. One would have to analyse the section, convert the hex (op-code) to assembly language and find which part correspond to the C code.

It is possible, and there are probably tools that do a fairly good job. Would the C language generated by the decompilation once recompile perform exactly like the original compiled cole. I doubt it.


What are the steps involved in porting an Arduino library?

I did essentially the same thing with getting the Adafruit ST7735 library working in chipKIT. I started a support thread here which can lead you through my process.

I tackled it the same way I do general programming:
1-» Copy over Libraries, get it so your compiler can actually SEE them.
2-» Start trying to compile and then triage errors from the "top level" down:
3-» Look for stlib functions you recognize as should be working and fix those.
4-» Look for AVR specific code and comment those out. I normally also add my initials and a comment: ckck - bitbanging SPI, so I can search for these later.
Repeat 3 and 4 until it works or you quit. :)

Reach out to the forums for your target; they might have been there done that -- or like in my case, you introduce them to something that they want, so they dive in and help.


RFID/NFC Tag get data from wordpress MySQL

From what I can tell it's absolutely possible but will take some considerable development time and around $30-$70 of hardware per NFC terminal. Please note I would strongly not recommend this as a first project as it has a lot of individual components that all have to work together flawlessly and each is different. Properly done this will be complex software and hardware wise although more so from the hardware side of things.

Hardware wise you need/terminal:

LCD display (I would recommend segmented for simplicity and cost)
Wifi or ethernet shield/breakout and ethernet cable if the board is not wifi compatible
Arduino (MKR1000 has wifi built in), Feather (Adafruit's boards that are frequently Arduino software compatible and have many shields available and guides written on how to use them), or cheap Arduino knock off (preferably not this option as giving money to arduino.cc, Adafruit, or other designers is important if we want new boards regularly)
NFC breakout or shield (Google/DuckDuckGo/Bing RFID-RC52 for an economical option, they're ~$4 on Ebay)
Power supply corresponding to the requirements of the chosen board + shields + breakouts
NFC tags
Lock able to be unlocked by a servo. If you expect security in absence of supervising shop manager (aka just to be safe, assume dishonesty in people using the shop) from this system, the locks need to be better than a Masterlock as those are insecure to even simple soda can shims. The rotary masterlocks can also be reduced to 100 possible combinations and then the combo can be brute forced easily from there so if you get a rotary based lock system make sure the assembly covering the dial is not easily removed.
Servo or stepper powerful enough to actuate locks
Servo or stepper driver breakout board

Then you'd just want to have the public key (note I don't mean a "public key" in the general cryptography sense but on that subject, you do want the key encrypted) to the user stored on the NFC tag and then use the arduinos+electronics to read the tags and see point values. User data from wordpress could be downloaded periodically to the boards so the individual checks don't use network resources and the system works offline.


Does old/low charge battery affects internal clock?

Let's assume by "internal clock" you mean the internal oscillator, as the arduino's processor does not have a built-in real-time clock (something that is meant to keep track of real time like seconds/minutes/hours.)

The arduino is not like a motor where it runs slower if a lower voltage is applied. If the voltage goes too low, the arduino will just reset. Once it resets, the program running in it just starts over again, unless the battery voltage is so low it can't even start up.

If you're feeding it with a 9V battery, you're going through the 5V linear regulator on-board, which is not very energy efficient. Keep that in mind if your goal is to create a project that is meant to run a long time on the 9V battery. See the notes at http://www.gammon.com.au/power for tips on reducing the power used by an arduino and/or ATMega-based project.


How can I easily see which COM port is used by Arduino?

Start | Control Panel | System | Device Manager | Ports (COM & LTP).

Watch the list change as you plug / unplug the Arduino. The new port is the Arduino.


You have selected a number of things that don't go well together. It is possible to use relays or mosfets to switch between batteries, and the Arduino could be used to measure a voltage. Or you can make a circuit with a few electronic components (e.g. a comparator). However, no one does it like that. It would be unreliable.

Every solar power charging module can handle darkness as well. Some modules will also create 5V.

This Adafruit module has no 5V output, it only contains the charging part: Adafruit:USB / DC / Solar Lithium Ion/Polymer charger - v2
It is out of stock at the moment, and you need solar cells, battery, a cable, and a DC-DC converter to make 5V.
When it is dark and the battery is empty, I assume the output drops and the Arduino stops working. Adafruit made a tutorial for it that shows the DC-DC converter and also Collin shows a DC-DC converter: Youtube, Collin's Lab: Solar

There are other modules like that. For example the Sparkfun Sunny Buddy.

Take care that the batteries don't get too hot.
It is possible to run some Arduino boards directly from a battery (3.1 to 4.2V). Then you would not need the DC-DC converter.
Buy solar cells that are the best in low light conditions. With enough sunlight, the power is no problem. It is the dark winter days that could be a problem.


Connect bluetooth module when no pins free

The code you're using for the atmega88 should be almost directly compatible with an ATmega328P, I suggest you pick one of those up.

Also you can try to:

Multiplex pins:

http://users.ece.gatech.edu/~sudha/academic/class/ece2030/Lectures/blocks/examples-5.gif

OR

Use shift registers/IO expanders:

http://tronixstuff.com/2011/08/26/tutorial-maximising-your-arduinos-io-ports/


I am not a SWD expert; it is several years since I read the spec. So I apologise if you are way ahead of me.

I believe ARM's SWD documentation, e.g. "ARM® Debug Interface v5 Architecture Specification" (ARM IHI 0031A) says that transfers are fixed length, starting with an 8 bits request.

The code:

void clockOut(int x, int bits) {
  pinMode(swdio, OUTPUT);
  while (bits > 0) {
    ...
    bits--;
    ...
  }
  ...
}

is invoked with clockOut(0xE79E, 16)

A packet request is 8 bits, followed by a response from the target. So this doesn't appear to follow the protocol.

Similarly clockOut(0x25, 7) appears to send 7 bits, which also looks wrong, and may explain why the read fails.

Further, there should be a 'turnaround bit' after sending the packet.

This code:

void clockOut(int x, int bits) {
  pinMode(swdio, OUTPUT);
  ...
  pinMode(swdio, INPUT);
  digitalWrite(swdio, HIGH);
}

looks like it is setting up to do that, however, it also needs to signal another clock pulse, e.g.:

void clockOut(int x, int bits) {
  pinMode(swdio, OUTPUT);
  ...
  pinMode(swdio, INPUT);
  digitalWrite(swdio, HIGH);
  /* signal a clock pulse */
  digitalWrite(swdck, LOW);
  delay(1);
  digitalWrite(swdck, HIGH);
  delay(1);
 }

A SWD read should return 33 bits, so x = clockIn(5); looks a bit fragile.

Even so, it should get the three ACK bits. It should leave another pile of bits unread, which is what I mean by fragile.

However, x = clockIn(5); might be incorrect because of the short clockOut(0x25, 7) and lack of a turnaround bit.

Small points:

I'd change that clockOut while loop to be a for loop like clockIn to make it clear that it is running for a specific 'count' (bits) of bits to be transferred.
delay(1) seems to be a long time between bits. I don't remember any
timing restrictions. However, I would expect the transfers to run
10-100x faster.
IMHO clockIn(26); clockIn(26); seems to be an unnecessarily obscure way
to generate the 50 cycle connection/reset sequence. I'd probably have
a slightly simpler function than clockIn which only generates the
connection/reset sequence.

Edit:
The statement res += (1 << i); in clockIn works.

However, I had to read it a couple of times to recognise that it is assembling a binary value, and not doing some tricky arithmetic. It is more common to use bitwise operators to assemble a binary value. It is only a small point of style, however res |= (1 << i); might be more clearly constructing a binary value, than res += (1 << i); because it can only ever effect one bit, and never many bits.


The Wemos D1 Mini is a 3.3V device. With a 1k base resistor, the most base current you're going to get is (3.3V / 1k ohm) = 3.3mA.

Looking at the datasheet, the current gain (h_FE) for the TIP31 transistor is no more than 50. So the maximum current you will pass from collector to emitter is 50*3.3mA = 165mA.

Your base resistor is too large and is limiting the current to your LED strip to no more than 165mA per channel. Try reducing the base resistor to 150 ohm. The TIP31 can handle continuous collector current of 3A, so you ought to be safe with a 1A power supply, and 150 ohm resistor.

UPDATE:

Per @Gerben's comment, the ESP8266 can source a maximum of 12mA from a GPIO pin, so you should not use lower than a 225 ohm base resistor on the initial TIP31. A Darlington pair would look something like:

simulate this circuit – Schematic created using CircuitLab


Arduino + CO2 + humidity + noise + temperature sensors on one board

For humidity and temperature you can plug the DHT11 or DHT22 to your arduino. DHT11 is cheaper but you'll get a more precise value with DHT22.

For noise you have ready made PCB like these : here
You'll only have to plug it to GND, 5V and analog input.

For CO2 this is more complicate. There is a cheap but very unprecise option, using a MQ135 sensor, here is a tutorial: here
Otherwise there are better sensors like the K30 but they are much more expensive.


Why is one LED more luminous (brighter) than the other?

Just like men, all LEDs have been made different.

Practically, that means two different LEDs (one green and one yellow for instance) will have different brightnesses (more precisely, luminous intensities) when they are traversed by the same current (forward current).

LED luminous intensity is a function of the current that traverses it (among other factors).

If you want the same brightness for those 2 LEDs, then you'll have to:

Get both LEDs datasheets (should be a couple of A4 pages for each)
Find the luminous intensity/forward current function curve in each
Determine which brightness you want for both
Deduce the current for each
Calculate the resistor value to get that current for each

Then you will have to use two different resistors values in your wiring, based on calculations of step 5.

Simpler, you could just replace one of your 2 resistors with one small pot that you can use to tune brightness of the second LED until it fits brightness of the first one.

Be careful with pot manipulation though, as a 0 resistance would probably grill your LED (and potentially the Arduino pin it is wired to).


How to combine two different sensor sketches to one complete sketch?

I will leave a simplified answer and I would recommend to read https://www.makeuseof.com/tag/getting-started-with-arduino-a-beginners-guide/ or similar to get a understanding of how to code.

An Arduino sketch has a structure.

Initialising values
A void setup() this code only run once the MCU is started
A void loop() and this code runs continuously.

So to merge two sketches you need to combine the code that is in the same sections and of course avoid duplicate code and ensure that you have unique variable names

Sharp Dust Sensor

int measurePin = A0; // Connect dust sensor to Arduino A0 pin
int ledPower = D8;   // Connect 3 led driver pins of dust sensor to Arduino D2

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

MQ-135 Sensor

int airquality = A2;
void setup()
{
  Serial.begin(9600);
}

Combined code

int measurePin = A0; // Connect dust sensor to Arduino A0 pin
int ledPower = D8;   // Connect 3 led driver pins of dust sensor to Arduino D2
int airquality = A2;

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


Using SoftwareSerial to send data to itself

If you are hoping to see the results in the serial monitor, you need to read it in and send it back (so it ends up on the USB port). Like this:

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  Serial.begin(4800);

  // starting the software serial
  mySerial.begin(4800);
}

void loop() {
  for (int i = 0; i <= 10; i++) {
    delay(10);
    mySerial.println(i);

    while (Serial.available ())
      Serial.write (Serial.read ());
  }
}

Now you have to connect pin 11 to pin 0 (not pin 1) because that will now be the Serial Rx pin.

I think your method failed because with Serial active the Serial hardware was trying to drive pin 1 high (ie. idle) which was conflicting with the data from pin 11.

An alternative is to not do a Serial.begin() - which therefore does not initialize the serial hardware and it doesn't conflict any more. This also works:

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  // starting the software serial
  mySerial.begin(4800);
}

void loop() {
  for (int i = 0; i <= 10; i++) {
    delay(10);
    mySerial.println(i);
  }
}

Now you connect pin 11 to pin 1 as you originally wanted.

Notice I changed your mySerial.write(i); to mySerial.println(i); so you get correct data output (numbers, not control characters).


Leonardo keypresses not working with OBS

Warning: the below is all supposition.
When the OBS window is focused the OS can send keyboard events to the window. That means that it gets "The button has been pressed" messages. These are generated when the "press" events are sent from the Leonardo.
When the OBS window isn't focused it can't be sent those messages - so it has to manually poll the state of the keyboard to see what buttons are pressed at any one time. It can't be doing this all the time, so it does it periodically (but still pretty fast).
The knock-on effect is, though, that when not focused it can only see buttons that have been pressed for at least enough time for it to poll the state.
If you add a delay into your routine between the last "press" and the "release all" commands that is longer than the period between polling (no idea what that is - you'll have to experiment, but starting at around 50ms to 100ms should be adequate) you should give OBS enough time to see that the buttons are pressed before you then release them.


How do I (easily) power a 5 V 3-pin fan?

You are correct in your assumption that you can not power a fan from an Arduino directly.

Use a transistor, for example 2N2222 or BC548, which is switched by the Arduino, using a single pin, in order to provide sufficient current to the fan.

Such as this simple circuit (note that the 12V supply would be 5V in your case):

Source: Driving a PC fan - transistor with or without an optocoupler?1

However, as chrisl has pointed out, you fan has three pins and not two. The above circuit will only work for a two pin fan. In your case, for the reasons stated in Chrisl's answer, one pin goes to 5 V supply, one to GND and then third goes directly to the Arduino - let's say pin 3. Then you can use the code below.

Assuming that the fan is connected to pin 3, then the code will look like this:

const int fan = 3;

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

void loop() {
  int fanSpeed = 255;
  analogWrite(fan, fanSpeed);
}

This will run the fan at full blast. However, you can thereafter modify your code to vary the value of fanSpeed.

Furthermore, by reading an analog input pin (let's assume that you have a potentiometer hanging off A0), using analogRead(), you can use the read value to modify the value of fanSpeed directly (by dividing the value returned from analogRead() by four2 and then sending to analogWrite(), like so:

  int potPin = A0;
  fanSpeed = analogRead(potPin)/4;
  analogWrite(fan, fanSpeed);

or even more succinctly, do away with fanSpeed completely and use:

  int potPin = A0;
  analogWrite(fan,analogRead(potPin)/4);

1 Note that the code in the link in incorrect as it attempts to write values greater than 255 using analogWrite(). As stated here, Arduino reference - analogWrite(), analogWrite() takes values of 0-255, whereas analogRead() returns values of 0-1023

2 See the loop() function in Arduino reference - analogWrite() for another example.


Always 255-response in I2C between ATTiny85 (8MHz) and Arduino Uno

It may seem that the current commit of January 2018 from the TinyWire library is corrupt. Try using an older version from 2017, for example this one: https://github.com/rambo/TinyWire/tr...72a13504bbfc4e

This solves the problem for me as well.

Source: Teensy 3.5 - I2C - ATTiny85-20PU (TinyWireS.OnRequest not triggering!) - Post #11


Not detecting Arduino Mega 2560. It worked before but now not detecting

What you said has happened to me before.This happened to me as I supplied over 20v to the arduino.Did you supply a higher voltage than recommended or pull too many amps from the board?If you did so,it is almost futile to try to repair it.


Beginner here. Which arduino revision should i buy?

That looks like an UNO R2, the type with DIP micro controller (you can extract it and replace it with another one, in case of problems).
The R3 version is probably the best choice to get started.
You might want one that has a connector where this one has only the 3x2 empty pads on the top left (close to the vertical writing AREF).
Have a look on ebay/aliexpress/amazon. You can find it for as little as $5-$6. Just search for UNOR3, if you elect to buy this type.


It looks like the server is down.  Isitdownrightnow reports that it's been down for almost 4 days: http://www.isitdownrightnow.com/arduino.esp8266.com.html

There is a discussion about it over on the ESP8266 forums: http://www.esp8266.com/viewtopic.php?f=26&t=3134&start=8

Let's hope it will be back again soon.


Is it possible to count rising edges of a 4 MHz clock on an Arduino Due and trigger an interrupt like all 4'000'000 edges?

First of all excuse my inactivity but as you know it's crazy times right now. However I finally figured it out, it's for sure not the most elegant solution but it meets my requirements. Thanks for your help @KamilCuk.

Here is my code if anyone may ever have the same problem as I did. External signal goes on Digital Pin 2. Works fine with a 4.2 MHz external clock.

// define capture channels
#define CAPTURE_TC TC0
#define CAPTURE_CHANNEL 0
#define CAPTURE_IRQn TC0_IRQn
#define CAPTURE_Handler TC0_Handler
#define CAPTURE_ID ID_TC0
#define CAPTURE_PIN 2
#define CAPTURE_CLOCK_SELECTION TC_CMR_TCCLKS_TIMER_CLOCK3

/*
* Function:  setup
* ------------------------------------------------------------------------------
* Setup code. Will be executed once.
*/
void setup() {

  // init serial connection
  Serial.begin(115200);
  Serial.print("Initializing...");

  // configure the PIO pin as peripheral
  const PinDescription *config = &g_APinDescription[CAPTURE_PIN];
  PIO_Configure(config->pPort, config->ulPinType, config->ulPin, config->ulPinConfiguration);

  // enable timer peripheral clock
  pmc_enable_periph_clk(CAPTURE_ID);

  // configure the timer
  TC_Configure(CAPTURE_TC, CAPTURE_CHANNEL,
    CAPTURE_CLOCK_SELECTION   // Clock Selection
    | TC_CMR_LDRA_RISING      // RA Loading: rising edge of TIOA
    | TC_CMR_ABETRG           // External Trigger: TIOA
    | TC_CMR_CPCTRG           // RC Compare
  );

  // configure TC interrupts
  NVIC_DisableIRQ(CAPTURE_IRQn);
  NVIC_ClearPendingIRQ(CAPTURE_IRQn);
  NVIC_SetPriority(CAPTURE_IRQn, 0);

  // enable interrupts and start counter
  CAPTURE_TC->TC_CHANNEL[CAPTURE_CHANNEL].TC_IER = TC_IER_CPCS;                  // enable RC Compare Interrupt
  CAPTURE_TC->TC_CHANNEL[CAPTURE_CHANNEL].TC_CCR = TC_CCR_CLKEN | TC_CCR_SWTRG;  // the datasheet said I need this
  NVIC_EnableIRQ(CAPTURE_IRQn);                                                  // enable interrupts

  // set the trigger value for RC_Compare
  CAPTURE_TC->TC_CHANNEL[CAPTURE_CHANNEL].TC_RC = 4164303;

  Serial.println("ready!");

} // setup

/*
* Function:  loop
* ------------------------------------------------------------------------------
* Main code. Will be executed repeatedly.
*/
void loop() {

} // loop

/*
* Function:  CAPTURE_Handler respectively TC0_Handler
* ------------------------------------------------------------------------------
* Timer capture trigger. Will be executed if TC0_RA == TC0_RC
*/
void CAPTURE_Handler() {
  // reset status register
  TC_GetStatus(CAPTURE_TC, CAPTURE_CHANNEL);

  // do something
  Serial.println("Trigger");
  // function_call()
}


You cannot use the + operator for that.

However, since EEPROM.read only returns one byte and not a string, you can do a much easier implementation:

void loop()
{
  char result[] = "1:2:3";
  for (int item = 0; item < 3; item++)
  {
    result[item * 2] = EEPROM.read(1 + item);
  }
}

This first create a string "1:2:3", where the digits are overwritten in the for loop by that item. Note that the digits in the string do not matter, it's just some free 'comment', it also should work when using "x:x:x".


Without the center part of the USB plug, it should be possible to make some deformations of that shield without damaging rest of the usb connector and pull it out. Aim for the weakest spot - seam (usually in the middle of bottom).
But even if you damage on board connector, it can be replaced (but it might be better to give it to someone with soldering experience - at least for unsoldering it)
And as noted in comments, even without working usb connector it can be programmed either by connecting USB-TTL serial converter to D0/D1 (but without auto-reset, unless you provide 100nF capacitor between reset and RTS), or it can be programmed by another Arduino as SPI (it needs bit more wires, and by default it doesn't burn bootloader, so if you fix USB, you'll have to burn bootloader).
Easier might be swapping Atmega328p between boards, however it needs some practice, so you won't bend or rip pins)


Using a SPI based ADC (ADE7912) with Arduino

I have not written a full library, but I have recently been using the ADE7913 (same as ADE7912 but with an extra voltage channel) with an Arduino MEGA.

The basic sketch located here talks to the ADE7913 over SPI, and then prints the results of the measurement registers over serial (so you can see them using a serial monitor).

I have not yet done much measurement testing, so can't comment on the negative voltage issue you have seen, but the sketch sets up the ADE7913 to use the V2WV register for monitoring temperature, and converts the result into degrees C, so you should be able to tell if its working properly.

In terms of the issues you have been having with the SPI comms, I can offer the following suggestions based on my troubleshooting experience (I also had glitchy comms initially):

I'm pretty new to SPI, but my interpretation of the data-sheet is that the ADE791X chips use SPI_MODE3 (i.e. SCLK is normally high, and samples are read on the trailing clock edge). I have found SPI_MODE1 also works, but unless others can correct me would suggest using 3.
I found having physically long jumper wires (my prototyping is still on a bread-board) caused issues. I have read elsewhere that at frequencies in the ones of MHz, distances less than tens of meters shouldn't be an issue; but I shortened / tidied my wiring and it seemed to help.
I would run everything at lowest possible speeds to troubleshoot, i.e. set the ADC sampling rate to 1kHz (set CONFIG bits 5:4 to 11), and set the SCLK at 250kHz.
In the attached sketch, I am reading the register values based on an interrupt from the CLKOUT\!DREADY pin. You have to be careful that this reading routine takes less than one ADC sampling time to read all the registers. There is a good explanation of this timing constraint in Figure 8 of this application note. The attached sketch also reports some timing information over serial to help with this.

Hope that helps,

Khalid.


Reading RFID tags with Arduino IDE, not using Arduino

Short answer:
NO

Long Answer:

Option 1:
 Use a USB RFID reader and create a basic processing/python/ app to read from the USB RFID reader and post it where ever you want it to

Option 2:
Use the arduino to read from the ID-20LA and send the data via UART to your computer and then create a windows app using processing/python/ to send it to your API endpoint

Option 3:
Use the arduino YUN to read from the ID-20LA and then create a basic python program to run on the YUN itself. Such that it will read data from the atmel microcontroller (on the YUN) and post it to your API endpoint. This is a much cleaner yet slightly more expensive way of doing this.


Will this AC-DC converter chip really work with arduino?

What do you think about it ?

If you have to ask, don't do it. Mains voltage can be dangerous and should only be done if you know what you are doing and how to be safe. The best choice is to just use pre-built adapters from reputable sources.


Regular sound files will have an even amount of time spend energizing the coil positive and negative, so the motor will not spin around in the normal sense. With a strong enough amplifier it will produce the sounds in the file like a speaker, but it will not noticeably turn.

Actual PWM varies the percentage of the time the signal is HIGH in a fixed frequency square wave, thus all the different values are the same "pitch". Audio varies amplitude and frequency, but the cumulative effect of audio waves is neutral, it spends half of the time below neutral and half above neutral voltage. The simplest analogy I can think of is audio being itself, even vibrations in air, and motor PWM being wind.

I am not sure if it possible to generate a sound file that would turn the motor, it probably depends on the file type. In any case, you would be better off with a far simpler amplifier like a transistor, MOSFET, or H-Bridge on one of your nano's actual PWM pins.

As to whether or not you could analyse the file on arduino, it also depends on file type. The code for the arduino WAV sheild I've seen does not have the arduino actually processing data, but It should be possible with a simple enough file type for arduino to decompress. WAV is not normally compressed, just raw data, so your limits are the RAM and if you can code something to glean volume from the raw data. I don't have much experience in that kind of file processing on AVR so I'm not going to call it either way.


ESP8266-01 Wifi module + Wifi shield not present + ESP8266-01 libraries not working?

Can you please include some explanation of how the Arduino Uno and ESP8266-01 are connected. You will need to program for the ESP8266 ESP-01 module like shown below,

You will need to write code for the ESP module to connect to the WIFI and listen to its Serial Com Port. The ESP will need to handle the message interpretation & WIFI updating.
The Arduino Uni will not be capable of directly using the ESP-01 module as a WIFI shield. It will need to communicate with the ESP via a serial coms link, you will need to send commands that include instructions & a Message to the ESP from the Arduino.

https://create.arduino.cc/projecthub/jeffpar0721/add-wifi-to-arduino-uno-663b9e - Link to the above image document, this should help explain my concept in more detail
I apologies if my comments above miss the point but with the amount of information provided I don't think I can help further.


int oldValue;
void setup()
{
    oldValue = analogRead(A1);
}

void loop()
{
    int value = analogRead(A1);
    while( abs(value-oldValue)<300 )
        delay(1);
    oldValue = value;

    // start blinking lights here, as the value has changed by at least 300

}


You are trying to use a mix of delay and  millis

Instead you will want a proper state machine:

void loop(){

    switch (state){
    case GOING: go();
       state = WAIT_FOR_COAST;
       transition = millis();break;

    case WAIT_FOR_COAST: if(millis()-transition > 1000){
            allStop(false);
            state = WAIT_FOR_STOP; transition = millis();
        }
        break;
    case WAIT_FOR_STOP: if(millis()-transition > 250){
            allStop(true);
            state = WAIT_FOR_GO; transition = millis();
        }
        break;
    case WAIT_FOR_GO: if(millis()-transition > 1000){
            allStop(true);
            state = WAIT_FOR_GO; transition = millis();
        }
        break;

    }

}

Remove the delay in go and use a simple if-else in the allStop where parameter == true means hard stop and false means coast.

Another option is to use a extra mosfet to put a resistor across the motor instead of shorting it out (which is what the hard stop will do). That will reduce the breaking torque but defeats the isolation of the board.


The problem: after connecting Arduino to PC via USB in 5-7 seconds IDE says that connection is losted.

Yes, that's normal. That's the bootloader running, and it's during that 5-7 second window that you can upload a new sketch.

Under normal circumstances the IDE will automatically reboot the board for you so the upload time window coincides with the IDE's attempt to upload a new sketch. However under some circumstances it can't, so you have to do it manually by pressing the reset button at the right time.

Also on Windows you may find that you have a different COM port for programming as you do when a sketch is running (Windows is retarded like that, you see). The IDE tries to do some magic to identify the correct COM port to use, but you have to first have the correct "sketch mode" COM port selected so it can first reboot the board into the bootloader, at which point it tries to do its magic to work out the correct COM port to use by looking to see which COM port (if any) has just appeared since rebooting.

So, in short: if the IDE can't reboot the board for you then do it manually, but note that timing is vital. Press the reset button a few moments before avrdude runs. It may take practice.


Atmega328 and ADXL335 - is the right choice for vibration analysis?

First of all, 3000 RPM is only 50 Hz, so sampling is not a problem for the fundamental frequency.  But you usually want to see harmonics, to pick up gear tooth issues, etc.
I suggest using my Daqarta software with a sound card to do your initial testing.  It already does everything you need, including waveform, spectrum, and spectrogram displays plus a lot more.  You can use it free for 30 sessions or 30 days, then the sound card inputs are no longer supported.  By that time you should have a good idea about what you need.  As it turns out, Daqarta also supports Arduino, and that does not end with the trial period.  So you may be able to do everything with an Arduino, for free.  The Daqarta site also has a contact page, and I am glad to answer questions and provide specific help for any issues that arise.  That include free users.


You have to do it inside of function:

Sensor *sensors[2];

UltraSonicSensor uSensor;

void setup(){
  Serial.begin(9600);
  sensors[0] = &uSensor;
}

Or directly:

UltraSonicSensor uSensor;

Sensor *sensors[] = {&uSensor};

Don't forget to make method Sense() virtual in the base class and in the inherited classes. Otherwise you'll have to also find out the type of the object and typecast it to correct class pointer before it's use.

class Sensor
{
  public:
    virtual int Sense() = 0; // pure virtual base class
};

// and inherited class:

class UltraSonicSensor: public Sensor {
  public:
    // ...

    // Prototype must be exactly the same, by using override
    // is ensured it actually overrides something from the parent class.
    virtual int Sense() override {
        // ...
    }
    // ...
}

Also the last versions of Arduino IDE supports C++11 standard so you can use range based for loop:

for (Sensor * sensor : sensors) {
    int val = sensor->Sense();
    // ...
}


Machine installed with arduino suddenly turns on when usb is unplugged

Do not call loop from loop. You will quickly run out of RAM and the sketch will crash:

void loop(){

  int recipe;
  //Serial.print("Enter recipe number: ");

  while(Serial.available()==0){    // Waits for data from serial port
  }

  while(Serial.available() > 0){
...

  }
  else
    loop();

}

For the pins that are supposed to be high, I suggest pull-up resistors:

  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  pinMode(8,OUTPUT);
  pinMode(9,OUTPUT);
  pinMode(10,OUTPUT);
  pinMode(11,OUTPUT);   // for start of program operation

  digitalWrite(6,HIGH);
  digitalWrite(7,HIGH);
  digitalWrite(8,HIGH);
  digitalWrite(9,HIGH);
  digitalWrite(10,HIGH);

When the Arduino powers up it enters the bootloader for a second or so. Those pins won't be set high yet. A pull-up resistor would make sure they are high until such time as you want to drive them low.

If you are saying that the machine powers up when you disconnect the power to the Arduino, that is still a good reason for using pull-up resistors, to make sure that it does not operated until commanded to do so.

  where will i connect the pull up resistors and how?

Typically pull-up resistors will be around 10k, and are connected from the pin to +5V. Of course, if the Arduino is not powered, then you need another source of the +5V.

  please to clarify the "do not call from loop to loop"

Remove these two lines:

else
    loop();

When loop exits, is it immediately re-called. You don't need to do it that way, in fact it is a Bad Idea.


I can think of a number of ways of doing this:

Multiplexing -- Employ a (large) number of analog MUX chips to expand the number of analog inputs you have available. That would get messy very quickly.
External ADC Chips -- Add more real analog inputs over SPI or I2C. For 50 inputs that would be quite a lot of extra chips.
Use Op-Amps -- Each input can be converted into a pair of digital inputs using two op-amps to compare the voltage of the input against two thresholds, which would give you an "active" and a "fault" signal. That would be 100 digital inputs needed (and 100 op-amps, which could be done with 25 quad op-amp chips).
Distributed processing -- Don't try and do it all with one device. Split your system into zones with far less inputs then get the zones to communicate with each other.

Of course, you can combine any of those - you could have analog MUX chips fanning out a number of external ADC chips inputs. You could MUX the inputs to the op-amps. You could have external ADC chips on multiple zone systems. Etc.

Personally, on a system of this size, I would certainly consider distributing the inputs across multiple processors even if they are all in the same physical control unit. However, distributing nodes across the building (it sounds like it's quite a large building for 50 inputs) would reduce the amount of cable needed to implement those inputs, and some industry standard bus snaking its way around the building connecting all the nodes up to a master unit would, if implemented correctly, be robust. CAN is a popular protocol for interconnecting control systems (it's used in modern lifts, and those are life critical... you don't want a lift to fail...) so could be a good choice for this.


How can I assign a variable to a function output in Arduino?

The setVoltage method has the following prototype:

void setVoltage( uint16_t output, bool writeEEPROM );

This means it does not return a value.

If you expect to return 1095, why not write:

volza = 1095;
setVoltage(volza, 1);
Serial.println(volza);

Some background information:

Assume you want to have the library a getVoltage method, than this is possible (you have to make a copy in your own project of the file and add the method. However, I'm not sure how easy it is to get the value from the EEPROM. If it is not easy, there is some programming work to do. Another solution is to store the value in memory, but that means some extra bytes from the scarce free SRAM. Also, in theory the content could be changed already (if another MCU would have access to the EEPROM too).


Is it possible to send data from internet server to ESP8266 behind proxy or regular requests from ESP8266 are required?

It seems evident that you don't want your ESP8266 running as a server of any kind. That's understandable given that server programs consume a fair amount of system resources (CPU, RAM, etc.) that are in short supply. That means you'll have to use your ESP8266 as a client and this means either

Polling - where the ESP8266 repeatedly connects to your "internet server" to explicitly ask for information at frequent intervals. Your internet server would have to be able to collect information in batches and hang onto it until your ESP8266 connects again to request the information.

Socket connections - where your ESP8266 maintains a consistent socket connection to your "internet server." Note that the HTTP protocol relies on socket connections, but clients open a socket connection, request a web page and its images, CSS, etc., then disconnects the socket. You can also use sockets at a more basic level as a bytestream. This programming can be tricky, but ESP8266 does have examples of TCP socket communication like WiFiClient and ethernet client.

Client approaches have a variety of headaches:

server has to hang on to information until the client comes back to retrieve it
you have to work up some kind of data structure to track which information has been handled and which work must still be done
latency issues -- i.e., what happens when there's a delay in processing information.

Server approaches also have challenges:

server programs can be tricky to write so that they keep running. a single exception or fatal error can crash the program
server programs are vulnerable to DDoS or other attacks, and can easily overwhelm a small device like ESP8266
firewall and networking issues -- depending on how this device connects to the internet, it may or may not have a consistent IP address where it can be found, the ISP that connects it may not allow incoming connections for the ports that it listens on, etc.


Arduino receives HIGH when the button is LOW

You will need a pushbutton connected as follows:

The signal labeled Vout will connect to digital pin 4.

Explanation:

When the pushbutton is NOT pressed, no current flows through the resistor, and Vout = 0V. When the pushbutton IS pressed, current flows through the resistor, and Vout = 5V.

This resistor is called a pull-down resistor, because it pulls the signal down to ground. A pull-up resistor would reverse the operation of the pushbutton (i.e. Vout = 5V when not pressed, and 0V when pressed.)


Finding connectors for push button component

Go down to your local (decently-stocked) hardware store and ask for "quick connect terminals". From the dimensional drawing you'll need 2mm or 5/64" terminals.


problem uploading arduino sketch on esp8266-12e

I installed another version of the driver from silabs' website and now it's working.


On page 4 of the datasheet,

  Left side value of detection range (zero point) is corresponding to left side value of voltage output range,but right side value of detection(max detection value) is not corresponding to the right side value of voltage output range.

Thus, 0ppm would correspond to 0.6V, for CO. And 1000ppm does not necessarily correspond to 3V.

Assuming that 500ppm = 1.52V was obtained from the "inspection report", you now have two reference points, (0, 0.6) and (500, 1.52).

Further below on the same page, a formula for N is given, which, points towards a linear response of Vo with respect to ppm. Thus, you can use the map() function to do the linear mapping from voltage to ppm.

Note that map() only works with integers, so instead of mapping voltage (0.6 - 1.52) to ppm, you should directly map the analogRead value (123 - 311) to ppm to get better accuracy. Other wise, implement your own mapping using floats.


Better way for connecting to Arduino pins to a sensor than jumper cable

Remember the Arduino is a prototyping system and it should be easy to plug, unplug and move around connectors.
If you want a permanent solution, you should make your own PCB and you will have a huge choice of connectors suited for all imaginable purposes (for example the JST family of connectors).
There are some connectivity systems like the Grove connector that have attempted to standardize connectivity on Arduino and related platforms.


WifiClient and aREST on esp32 - loop until new instructions recieved?

server.available() doesn't return an already 'claimed' connection again. It returns a new connection or an empty WiFiClient object.

The esp8266 and esp32 Arduino core WiFi library close the underlying connection if the last referring WiFiClient instance is freed. The assignment of empty WiFiClient object frees the previous reference to underlying socket and if it was the last referrence, the library closes the socket.

You get a client with server.available() in checkForTask() and then you call server.available() again. It returns an empty WiFiClient object and you assign it to your WiFiClient object. The library closes the referred connection.

The solution is not to check server.available until WiFiClient is valid.

if (!client) {
  client = server.available();
}


Forward kinematics of a differential drive robot

From your use of the number 360 at the end of the Encoders() function, I am thinking that you are using degrees for the angles.  That won't work with sin and cos.  The trig functions all expect angles in radians.  To convert degrees to radians, multiply by PI/180.


Should be.  Googling the words "Arduino ESP Ubidots" gave many, many useful resources.


EDITED

The Arduino loop() function makes the use of a while loop redundant in this case. Even worse: the way you've implemented that while loop prevents buttonState from being updated, thus getting stuck in the loop.

What you actually need is to use timers to blink the LED, and a 2-state machine driven by HIGH to LOW button transitions.

Try this instead:

#include "Timer.h"

// Pin 13 has a LED connected on most Arduino boards.
// give it a name:
const int led = 13;
const int buttonPin = 2;

// declare state variables as global
bool buttonState = LOW;
bool buttonState_prev = LOW;
bool toggleBlinking;
bool blinkState;

// declare a Timer object so blinking can be done without loosing button presses
Timer timer_b;
int blink_id;

// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
  pinMode(buttonPin, INPUT_PULLUP);

  // initial state: toggle led each 1000 ms
  blink_id = timer_b.oscillate(led, 1000, HIGH);
  blinkState = true;
  toggleBlinking = false;
}

// the loop routine runs over and over again forever:
void loop() {
  // Update the timer (required)
  timer_b.update();

  // check if button has been pressed (HIGH to LOW),
  // then debounce it and raise toggle flag
  buttonState = digitalRead(buttonPin);
  if ((buttonState != buttonState_prev) && (buttonState_prev == HIGH)) {
    // simple button debounce (confirm press after some ms)
    delay (50);
    buttonState = digitalRead(buttonPin);
    if (buttonState != buttonState_prev) toggleBlinking = true;
  }

  // keep current LED state unless the button has been pushed
  switch (blinkState) {
    case true:
      // if button has been pushed, stop blinking and change LED state
      if (toggleBlinking == true) {
        timer_b.stop (blink_id);
        blinkState = false;
      }
      break;
    case false:
      digitalWrite(led, LOW);
      // if button has been pushed, start blinking and change LED state
      if (toggleBlinking == true) {
        blink_id = timer_b.oscillate(led, 1000, HIGH);
        blinkState = true;
      }
      break;
  }

  buttonState_prev = buttonState;
  toggleBlinking = false;
}

NOTE: You'll need to install the Timer.h library. I'VE TESTED MY CODE AND IT WORKS.


How to Work Two Linear Actuator Synchronously by Using Arduino and VNH5019 Motor Driver?

It sounds like you need to watch both encoder outputs and don't let one get ahead of the other. Naturally, they won't sync exactly (i.e., pulse simultaneously) but you can set a limit on how many counts to let them differ by, before pausing the faster actuator while the slower one catches up.

If you need to save positions across a power failure, you'll need to 1) provide enough backup power to keep the system alive past the supply failure to give you time to stop both actuators and store both of their positions in EEPROM; and 2) provide a signal to the Arduino that the supplied power (not the backup) is going down, so it can begin its orderly shutdown.


You could use a MCP23017 or similar.  Its an IC that provides 16 IO ports via I2C, I think you can have 4 of them so that should be enough for both hands.

Or you could use resistors.  All the buttons are connected to a single analogue port.  The resistors are chosen so that when you press any combination of buttons you will get a unique reading at the port. So if you press button one and get a reading of 100, press 2 and get 150, press 3 and get 200, etc.  So buttons 1+2 give you 250, 2+3 gives you 350 and 1+2+3 gives you 450.  The problem with this is the maths get out of hand very quickly and the IC is < $1.


Some of the Freeduino boards use crystals although the newer ones now use a cheaper USB to serial chip (the CH340) instead of the Atmel chip used on the Arduino Uno.

The diavolino is another build-it-yourself board that has a crystal. I am sure there are many others. The ruggeduino is another that uses a crystal and also markets itself as being practically indestructible. Their "How to Destroy an Arduino" is well worth a read for things to avoid doing to your Uno.


CH34x board fails with avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00 Atemel Mega328P AU1640

You have an Arduino nano clone using a CH340G chip for serial communication. You to down load and install a driver for your computer to recognize it. I don't use OSX, so there's not one I can recommend.


I think it's worth noting that the three 255 values for RGB colour space is just one way to encode the 255^3 (16,581,375) colours. These include each and every brightness level too.

If you are trying to get a rainbow effect, you may have more success or find it easier to use a HSL or HSV colour space.

HSV uses Hue, Saturation and Value instead of RGB. FastLED has optimized it's implementation of HSV to use a 0-255 addressing for Hue (instead of 360), keeping it fast for animations run on microcontrollers:

https://github.com/FastLED/FastLED/wiki/FastLED-HSV-Colors


When i used digitalread(button) instead of introducing variable i.e
  current. LED shows abnormal behavior. Why ?

Likely this is because of switch bounce.  The processor is very fast compared to the bounces a mechanical switch makes when operated.  So the results can be unexpected.  You can get around this problem in software by using a state machine.  Or in hardware by using capacitors to filter out bouncing.

  What is the purpose of current = previous expression. Whats its
  significance?

The program is tracking the state of the switch.  So you need to know the previous state of the switch to know if the state of the switch has changed.

  Also please explain the working of a code in a brief manner in a loop.

The two fixed or reserved function names in an Arduino sketch are "setup" and "loop".  "setup" is called only once on boot up.  And "loop" is called over and over again after "setup"is called.  In "loop" the code reads that state of the button, then tests to see if the state of the button is true and the previous state is false.  If it is, then toggle the variable which tracks the state of the LED.  Then the code will always save the current state as the past state and turns on / off the LED according to the value tracking the state of the LED.

Now comes the tricky part.  Assume the switch is perfect and does not bounce.  The toggling only occurs when the switch is 1st pressed.  That is because the next time through "loop" both trigger & previous are true and the test will then be false and the LED will not be toggled.  Not until after the switch is released does the code reset previous to false.  Now if the switch is pressed again, for only 1 iteration through "loop", the test will be true and the LED will be toggled.

This approach depends on the switch not to bounce.  And is difficult to understand.  Consider using a 4 state machine (button up / LED off, button down / LED on, button up / LED on, button down/ LED off) rather than this 2 state machine (button down / LED toggle, button up / LED steady).

  Why I should use Boolean instead of int?

Bools only have two states.  Integers can have many states.  It is less confusing and less error prone to use a variable that only has two states if that is the intent of the program.


Manchester Library Won't Compile for Attiny85

attiny is missing an option required to allow the Manchester library to function properly on ATtinyX5 devices, specifically definition of __AVR_ATtinyX5__ when a device is selected. In fact, it's missing quite a few things.

The package I use for ATtinyX5 support is arduino-tiny. I have verified that it defines that symbol properly. I recommend that you dump your current support package and install arduino-tiny instead.


How to connect naked camera from mobile phone to Arduino Uno

You need either a memory extension for your UNO - projects like Arducam did this way back 2016 and then used an OV2640 module. If you want to develop something yourself these are the steps (hurdles) to take:

Get a datasheet of the camera
Design a circuit including

plug for Camera and a
memory module (min 512Kb)

Attach it to the UNO
Write a library/function module (see datasheet for details) and
bring it to life

My tip save ca. two years of your life and get for 6-8$ an ESP32cam
This will cost you enough of your time, but be much more rewarding


Two 300RPM 12V DC motors connected to arduino motor shield r3 power supply

The external power of the shield is connected to the VIN pin, so it will power the Arduino via that. (vin goes to the voltage regulator that will provide the 5v the arduino needs).

You can connect two batteries in parallel to provide mode current.

But since they are 12v motors, they would need 12v to run at maximum power. 9v is a lot less than that.


Arduino Uno wiring and code with Parallax PMB-688

The following link was suggested in the comments by user PhillyNJ. Adding it here as a community wiki answer:

http://playground.arduino.cc/Tutorials/GPS


Function pointers that call one function

bb_perip is a function that returns a pointer to a bit from a register that is related to a specific timer peripheral (there's more than one).  That pointer is then dereferenced with the * operator to make *bb_perip(...).

What bb_perip returns is dependent on what timer you are using and what value you are interested in.

bb_perip is not a pointer to a function, it is a normal function that happens to return a pointer.


redefining delay and delaymicros as personal function

Not exactly like that. You will have to manage the different sets of
parameters, i.e. convert the incoming ms into the top and
storageVar that would be appropriate for calling countMicros().
Maybe something like this:

#define delay(ms) mydelay(ms)

void mydelay(unisgned long ms) {
    uint16_t top = some expression;
    uint16_t storageVar = another expression;
    countMicros(top, storageVar);
}

where both expressions are a function of ms.

If the expressions are really simple, you could even put the whole thing
inside a single macro, as in

#define delay(ms) countMicros(some expression, another expression)


The first slaves will be plugged in and will send to the master his
  default address

If this happens while the master is talking to one of the other slaves,
you risk a collision.

I suggest a very small variation on your scheme. Each slave has a
default address (0xff). When you turn it on, it doesn't say anything.
The slaves only talk when they are addressed.

Every now and then, the master sends a “ping” message to 0xff. The newly
installed slave responds, then the master gives it a real address, and
goes back to its business of collecting sensor data. If no response is
received for the ping within some specified timeout, the master assumes
there is no unconfigured slave.

Since no slave ever sends unsolicited messages, this should avoid any
kind of collision. You just have to make sure that new slaves are added
at a slow rate: after connecting a slave, you wait for slightly more
than the ping period before connecting another one.


To burn a bootloader from source Nano to target Uno make the following connections:

Nano.Pin   Uno.Pin

10         Reset

11         11

12         12

13         13

GND        GND

See here for more details: https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard


Don't do serial prints inside an ISR.

Your variable enable should be declared volatile as it changes inside an ISR. The compiler is entitled to cache the variable value if you don't do that.

You are inconsistent in your use of enable. You test for LOW or HIGH but set it to 0 or 1. Now they happen to be the same, but someone might wonder. If you are going to test for LOW or HIGH, then assign LOW or HIGH to it.

See my reference question How do interrupts work on the Arduino Uno and similar boards?.

I thought 0 and 1 were serial pins. I'm using digital pin 2

Not in the code you are not:
attachInterrupt(digitalPinToInterrupt(1), Wakeup, RISING);

Do you mean:
attachInterrupt(digitalPinToInterrupt(wakeup), Wakeup, RISING);

It's kind of confusing to have two names which differ only in case.


I'd suggest you use a power-source that delivers you 8V. Your Arduino takes anything from 7-12V to power it and it regulates it down to 5V. But you still can access the 8V from the RAW pins. Use a MOSFET like D1703L to control the 8V with an 5V Arduino digital pin.

You just connect Drain (D) to GND and Source (S) to your RAW 8V (don't forget to put your device between the Source and RAW 8V). Your Arduino digital pin goes to Gate (G), but to not draw to much current from the pin you might want to use a resistor of roughly 1kΩ.

This is the safest way that also allows for much higher voltage and also current for up to a few amps.

EDIT

You should not connect the PWM pin to Ground on your Arduino. But you have to connect both grounds together. I'm not sure where your 8V comes from so I made a sketch where the 8V is an external source and powers your device along with the MOSFET.


First, if you cannot connect to arduino by ethernet, use Serial Monitor and add some Serial.println to your code to log what is going - what part of program Arduino is executing.

W5100 module has no automatic reset module as opposed to Ethernet shield.
So try to connect W5100 RST pin to for example D8 and reset module in setup.

Here you are example from my (working) project:

const int W5100_RESET_PIN = 8;

void setup() {
  Serial.begin(SERIAL_SPEED);
  Serial.println();
  Serial.println(F("node starting..."));
  pinMode(W5100_RESET_PIN, OUTPUT);
  digitalWrite(W5100_RESET_PIN, LOW);
  delay(100);
  digitalWrite(W5100_RESET_PIN, HIGH);
  // give the Ethernet shield a second to initialize:
  delay(3000);
#ifdef USE_DHCP
  Serial.println(F("DHCP..."));
  while (Ethernet.begin(mac) == 0) {
    Serial.println(F("DHCP failed."));
    delay(10000);
  }
#else
  Serial.print(F("static IP..."));
  Ethernet.begin(mac, IPAddress(MY_IP));
#endif
  Serial.print(F("local IP:"));
  Serial.println(Ethernet.localIP());
  Serial.println(F("node started."));
}

Also after setup if your arduino lost ethernet connection and cannot get it again, you can try to reset w5100 and initialize Ethernet again.


I have a page about a tiny web server for the Arduino Uno or similar boards. It simply isn't true that you can't make one, or that a much more powerful processor would be better. There are some limitations imposed by small amounts of RAM, but the library described there decodes incoming HTTP information "on the fly" so it can handle a reasonably large page.

You could put the data to be display into PROGMEM (more information here) or onto an SD card as someone suggested.

The login and password could be stored in EEPROM.


switching two relays without delay using millis

this is a typical application for Blink Without Delay


Arduino nano & pro micro SPI simple communication

void setup() {
// put your setup code here, to run once:
 Serial.begin(9600);//start Serial
 Serial.println("Setting Up");
 void SPI_Init(void);   // <---------------- this is wrong!
 delay(100);
 Serial.println("SPI intialization is complete");
 }

That isn't how you call a function.

It should read:

SPI_Init ();


Is there a way to get my MacBook's date and time into Arduino IDE?

You can use __DATE__ and __TIME__ compiler time constants in IDE and do check inside of your setup() function if the RTC clock is zeroed then parse and set compile time values.

char cr[] = __DATE__;
char ct[] = __TIME__;

At the compile time these macros will be replaced with text constants "Apr  4 2019" and "10:35:22" respectively.


How to learn enough C++ to program Arduino?

If I were you I'd take the high road.

I was in your shoes a while ago and I didn't know how to approach Arduino. I was very lucky that I came across a book written by the famous Jack Purdum, "Learn C programming for the Arduino". It is written by a retired Purdue University professor who is well known for his extremely easy to learn teaching method. He has another

I only knew MATLAB and Simulink before starting this book. This book is amazing. It was extremely easy to follow. I now have no difficulty programming Arduino in the correct way. This book trains you to optimize everything which is very crucial with the limited resources on Arduino boards.

I suggest C instead of C++. It is the language of choice for programming embedded system. It is said to be low level, but as a MATLAB user I should tell you that syntaxes are extremely easy and intuitive. I didn't find anything hard about them.

Remember:

There isn't any problem to use C in Arduino IDE.
You don't need to worry about libraries. You only need to load them in the beginning of the code. You do not need to know how was the code written in the library.
Check the comments about the book on Amazon if you are not convinced.

Good Luck


How to call URL with Arduino Ethernet shield?

You need to use the EthernetClient. link

The exemple using your API call is:

if (client.connect(server, 80)) {
    Serial.println("connected");
    // Make your API request:
    client.println("GET /sendmsg?user=mohammed.atha&password=********&api_id=3539384&to=********&text=hello HTTP/1.1");
    client.println("Host: api.clickatell.com/http/sendmsg");
    client.println("Connection: close");
    client.println();
}

Full example from Arduino.cc docs:

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128);  // numeric IP for Google (no DNS)
char server[] = "www.google.com";    // name address for Google (using DNS)

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192,168,0,177);

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

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

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    Serial.println("connected");
    // Make your API request:
    client.println("GET /sendmsg?user=mohammed.atha&password=********&api_id=3539384&to=********&text=hello HTTP/1.1");
    client.println("Host: api.clickatell.com/http/sendmsg");
    client.println("Connection: close");
    client.println();
  }
  else {
    // kf you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}

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

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

    // do nothing forevermore:
    while(true);
  }
}


In the Arduino IDE check for the available ports. Be sure that the COM Port on Windows or ACMO port on Linux based OS is selected.

If the problem continues then check if the port is allowed in Windows and Linux.


So according to your comments this should be the code if no mistake was made

#include <IRremote.h>
#define irPin 8
IRrecv irrecv(irPin);
decode_results results;
const int buttonPin = 2;
const int relay1 = 13;
const int relay2 = 12;
int relay1State = 0;
int relay2State = 0;
int masterState = 0;
int buttonState;
int lastButtonState;
long lastDebounceTime = 0;
long debounceDelay = 50;

void setup() {
  Serial.begin(9600);
  irrecv.enableIRIn();
  pinMode(buttonPin, INPUT);
  pinMode(relay1, OUTPUT);
  pinMode(relay2, OUTPUT);
  digitalWrite(relay1, relay1State);
  digitalWrite(relay2, relay2State);
}

void loop() {
  if (irrecv.decode(&results)) {
    switch (results.value) {
      case 0xFF30CF:
        Serial.println("Button 1 Pressed");
        relay1State = !relay1State;
        digitalWrite(relay1, relay1State);
        delay(250);
        break;
      case 0xFF18E7:
        Serial.println("button 2 pressed");
        relay2State = !relay2State;
        digitalWrite(relay2, relay2State);
        delay(250);
        break;
    }
    irrecv.resume();
  }

  int reading = digitalRead(buttonPin);
  if (reading != lastButtonState) {
    lastDebounceTime = millis();
  }
  if ((millis() - lastDebounceTime) > debounceDelay) {

    if (reading != buttonState) {
      buttonState = reading;

      if (buttonState == HIGH) {
        masterState = !masterState;
        relay1State = masterState;
        relay2State = masterState;
      }
    }
  }

  digitalWrite(relay1, relay1State);
  digitalWrite(relay2, relay2State);
  lastButtonState = reading;
}

what I've done is create a masterState that only changes whenever you press the buttonPin and by pressing it will also change both relays to the value of new masterState independently of their actual state.

Another advice: is a bad practice to not initialize variables before use, because when you declare it is not granted that they are automatically equal to zero.


Unable to perform write operation while esp8266 flash operation

Maybe you can try to use ESP Flash Download Tool from here