text:
Why are there no clear types given on the Arduino API docs?
For exmaple, I look at the page for digitalWrite and all I get is this for the signature:
digitalWrite(pin, value)

No return value type, no paramater type, nothing.
Instead, in a seperate section it says
Returns
Nothing

And then it says
Parameters
pin: the Arduino pin number.
value: HIGH or LOW.

What is "value"? An int? uint8_t? bool? Why is the API written in such a weird ambigious way?
I would expect something like
void digitalWrite(uint8_t pin, uint8_t value)

Like I am used to from other "proper" API documentations.

Because it's written for novices by novices

I found void digitalWrite(pin_size_t pinNumber, PinStatus status);. that is why.

Most pages in Language/Functions do document the data types (I count 74 out of 137). This is more than it used to be, as documenting the types is an ongoing effort. You may participate by sending pull requests to arduino/reference-en.

See Specify data types in function definitions. I raised this issue in 2015 - that issue is still open 7 years later.

Try going to that Github page and supporting my request that the documentation be improved. Good luck!

re:"What is "value"? An int? uint8_t? bool?": all of those work in that context, so I don't see an issue.


text:
Is it legal to "simulate" Yubikey OTP autentication with an Arduino in own product?
I found the following Github Repo that makes it possible to build your own Yubikey with an Arduino Leonardo device.
https://github.com/pagong/arduino-yksim
Pretty cool. However I am wondering if using this is legal at all?
YubiCo is a company and they sell sticks with the YubiKey OTP feature. The verification process happens through their servers. Somehow I can't quite imagine that the company YubiCo tolerates that their processes and products could be easily replaced by open source products? Maybe they have any patents or utility models? And I was not able to find any licensing information which makes sense since official firmware seems to be closed source. So I guess it makes sense that no licensing information is available since the yksim project is a reverse engineered thing?! But I'll admit quite frankly: I have no idea of all this.
I would also like to use this library and possibly also for my customer projects, but I need to know whether this is really allowed.
Hope someone can help me here and I know that the internet is no source for a 100% sure legal advice. But maybe someone has a clue or a hint for me.

This is the wrong forum, go to https://law.stackexchange.com/

https://opensource.stackexchange.com/ would be another place that might have good insight into this.

According to https://www.yubico.com/blog/secure-hardware-vs-open-source/

The YubiKey hardware with its integral firmware has never been open sourced, whereas almost all of the supporting applications are open source.

I am not a lawyer, however it would seem that providing you aren't copying their (non open source) hardware, but are merely replicating the functionality, then this would appear to be OK. Disclaimer: I may be wrong.
Having said that, I agree with the comment under the question, you should probably ask at https://law.stackexchange.com/
Questions about the legality of an Arduino application really are legal questions, not technical ones.

source: Stack Exchange

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

sort: votes


text:
Arduino Micro digital output pins floating / high Z
so i recently got an arduino micro for a project needing the control of two stepper motors with the A4988 driver. previously i was prototyping on an arduino uno and everything was working fine, but on the switch to the micro the motors started behaving erratically such as random step direction and a random number of steps being taken. i've pretty confidently narrowed it down to the output pins floating, i've recorded the direction pin on the micro floating with ~2v being "off" and ~3v being "on" with a multimeter.
the thing is is that i can't find anything about fixing this other than doing.
pinMode(DIR, OUTPUT);
digitalWrite(DIR, HIGH);

or external pull resistors and i've tried both pull up and down resistors at 100k and 330 ohm with no luck.
right now i have one motor connected to uno and one to the micro, the motor on the uno still runs fine with no external pull resistors. the below schematic shows a simplified version of how both the uno and the micro are wired.

simulate this circuit – Schematic created using CircuitLab
and here is the code both arduinos are running.
#include "A4988.h"

#define MOTOR_STEPS 200
#define DIR 10
#define STEP 9

A4988 stepper(MOTOR_STEPS, DIR, STEP);

void setup() {
    pinMode(DIR, OUTPUT);
    digitalWrite(DIR, HIGH);

    pinMode(STEP, OUTPUT);
    digitalWrite(STEP, HIGH);

    stepper.setRPM(100);
}

void loop() {
    stepper.rotate(360);
    delay(1000);

    stepper.rotate(-360);
    delay(1000);
}

here are some links to other related post
https://stackoverflow.com/questions/14174162/arduino-micro-triggering-with-no-contact
https://forum.arduino.cc/t/high-impedance-output-pin/655236

the arduino is plugged in with usb and im using the 5v output on the micro (and i can confirm its 5v), and im also lead to believe that the digital pins operate at 5v

Ah, sorry, mistook it for the Pro Micro.

When you measure such voltages on the digital output of the Arduino there is something electrically wrong. Do these voltages persist, when you are not connecting the stepper driver (only the Arduino without anything connected)? Is the 5V pin staying at 5V when you have the stepper driver connected?

ok after waking up and taking a second look at it it appears to be a wiring mistake on my part, instead of being wired to pins 10 and 9 dir and step where on 9 and 8 and i feel a bit silly, but before moving to 10 and 9 the driver was connected to pins 3 and 2 and was still having the same erratic behavior. and the motor simply wont turn if plugged into the adjacent pins ((2 & gnd) / (4 & 3)) and the program adjusted. so i guess problem solved for me at least

You could write an answer to your own question

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


text:
Can't get input from 4x4 keyboard
I'd like to make some basic calculator. Currently, I'm struggling with inputs. I wanted to get from user some numerical input, then, I'd like to have an information, which type of calculation he is about to do. I'm not sure why, but I can't get any numerical input from user, because the program "jumps" ahead to the operation type. Here's some code:
void loop(){
int a = getNumber();

if(a != NO_KEY){
    do{
    operationType = getOperationType();
    }while(!operationType);
  }

}
getNumber
  int getNumber(){
  char userInput = customKeypad.getKey();
  int value;

  if (userInput == '0' || userInput == '1' || userInput == '2' || userInput == '3' || userInput == '4' || userInput == '5' ||
  userInput == '6' || userInput == '7' || userInput == '8' || userInput == '9'){
      value = userInput - '0';
      Serial.println("value");
      Serial.println(value);

    }
  return value;
  }

getOperationType
char getOperationType(){
char userInput = customKeypad.getKey();

  switch (userInput){

      case '+':
//      add(a , b);
        Serial.println("add");
        break;
      case '-':
//      subtract(a , b);
        Serial.println("subtract");
        break;
      case '*':
//      multiply(a , b);
        Serial.println("multiply");
        break;
      case '/':
//      divide(a , b);
        Serial.println("Divide");
        break;
      case 'C':
//      TODO
        break;
    }
    return userInput;
  }

Can I have any hint, why I can't just get simple inputs from the keyboard?

your program logic assumes that your program waits for a key to be pressed .... reduce your code to get keypress, print value of keypress ... that will show you what you are dealing with

You need to watch out for what you return and if your variables are initialized. So, what happens here:
In loop() you call getNumber(). There you declare two variables:

userInput, which you initialize to the return value of customKeypad.getKey(). So this variable will have the value NO_KEY if no key is pressed.
value, which you don't initialize. Thus its value is whatever was there in the variables memory space before it was allocated. This can be anything, but it is not random in most cases. It depends on what your program does prior to this, but you don't have any control over it.

Then you check for userInput being an ASCI digit. As you didn't press a key this obviously is false, so the variable value gets never written. And then you return that variable.
In loop() you check if the return value of getNumber() is unequal to NO_KEY. And since you didn't initialize value, it probably is. Thus the program goes directly to the operation type part.

What to do now?
First: Always initialize every variable that you declare in a function. Global variables get initialized implicitly, but not local variables. To be sure that I don't make an error, I just always initialize ALL my variables when declaring them.
Second: Currently value will not be NO_KEY since you don't assign that value to the variable. But doing so wouldn't fit with your program logic. value is the real numeric value, not the ASCI representation of it. And NO_KEY is defined in the Keypad library as \0 (the null character, with numeric value zero). So NO_KEY is actually equal to 0. And zero is also a valid input to your calculator.
Instead I would suggest returning -1 if no key was pressed and then in loop() checking for that. So something like this:
int getNumber(){
  char userInput = customKeypad.getKey();
  int value;

  if (userInput == '0' || userInput == '1' || userInput == '2' || userInput == '3' || userInput == '4' || userInput == '5' || userInput == '6' || userInput == '7' || userInput == '8' || userInput == '9'){
    value = userInput - '0';
    Serial.println("value");
    Serial.println(value);
  } else {
    return -1;
  }
  return value;
}

void loop(){
  int a = getNumber();

  if(a != -1){
    do{
      operationType = getOperationType();
    }while(!operationType);
  }
}

That said, I have some suggestions for you for going further:

For checking if the returned key is an ASCII digit there is actually a simple function for that: isDigit(). So instead of your chained equal conditions you can just use
  if(isDigit(userInput))

If you go on in this style you will find yourself wrapping multiple loops in one another as you need to loop for waiting on a keypress. That can get rather messy and it gets difficult to add additional functionality. Instead you could implement a Finite State Machine (FSM). Here the code in loop() consists mainly out of a switch case structure, where every case is one state of your program. For example you could have the states NUMBER1_INPUT, OPERATION_INPUT, NUMBER2_INPUT, DISPLAY_RESULT. The switch structure uses a single int variable as a state marker. For example when you set that state variable to NUMBER1_INPUT it will stay there and loop. When the user as done the number input you can change the state variable to OPERATION_INPUT and let it continue there. It is an important concept and it will change your way of Arduino coding for the better.
There are many resource for learning how to program a FSM. I've once written a longer answer about this, but you can search for something like "Finite State Machine" on this site or the web to find out more.

Thank you so much for such explanation. I will take a look on your answer about FSM. I really appreciate your effort.


text:
How do you deal with balancing the limited storage of Arduino with the decrease in speed if you just print everything as it gets measured?
I am working on a simple data acquisition system based on an Arduino Uno. Each run would ideally collect up to 10k data points (all doubles). Obviously, the Arduino doesn't have the capacity to hold all that at once. However, as one would expect, printing out the data as its being acquired significantly slows the process down (by about a factor of 7). I have looked around to find if there's a standard way to deal with this issue in the world of Arduinos, but have come up short. I come from a background where memory is never an issue, so I'm not as well versed in this side of things.
Obviously I don't expect perfection, but any insight or sources would be helpful.

Have you tried a higher baudrate? And transmitting binary data instead of ASCII text? Without code there isn't much else to say besides getting a microcontroller with more memory

I have maxed out the baud, but I'm unfamiliar with the idea of sending binary data instead of ASCII. I'll look that up. Is the idea there that it's sending bits rather than bytes?
And I was afraid you were going to say that last part.

it sounds like you need something newer/better than an Uno. I like the esp8266, even w/o wifi enabled.

You are still sending bytes. But 1 byte can hold a number between 0 to 255. If you want to send 255 in ASCII text you already need 3 bytes for that. Though I would second dandavis with that you will be way better off with a better microcontroller

This is all about choosing the right tool for the job.
At the moment you're trying to fit 50 clowns into a mini. While there are ways of doing it (by extending the "mini" outwards with extra "room") it's not what you'd normally do.
Instead you'd hire a coach.
If you have a scenario whereby you need to store more data than an Uno can store then you would typically use a different board with a more powerful chip.
There's plenty out there, many that are cheaper than the Uno...
If you desperately do want to use the Uno then:

Reduce your data size: consider using smaller variables, such as 16 bit integers and fixed point arithmetic instead of floating point values.
Improve your data transmission: send binary data instead of ASCII data, and increase your baud rate to the highest that can be reliably achieved
Consider adding external storage, such as an SPI SRAM chip or an SD card.

My solution is to use FRAM, it is much faster then printing and has almost unlimited read and write cycles. It is also non volatile so if power fails the data does not. They can be gotten I2C or SPI your preference. I purchased 32K x 8 devices for well under $6.00 last year from my favorite china supplier. You can treat it as one big ring buffer and print from it while you load data into it.

Don't use String and others dynamic allocated object in your code. There is not any reason for slow down serial output, only inefficient memory management.

What do you mean by your second sentence? Why exactly is there no reason that the Serial output slows things down?

I'm not actually using Strings, and all the variables I have are allocated in stack. I'm inclined to disagree with you that printing doesn't slow programs down; that's always been my experience.

Serial use ring input and output buffer. Its mean that you can output some count of characters to this buffer. If you send 10k double you overfill this buffer. Then you must wait for transfer chars by UART. Maybe this you consider as slow down printing. But transfer speed for serial line is baudrate/10 bytes per second (one char consist from 1 start bit, 8 data bits and one stop bit) This speed is guaranteed by hw UART and not change in time.

Si transferring over Serial does slow the code down, since it has to wait for the data to be actually send. Sorry, your answer doesn't make much sense to me in this context


text:
How to append to array of Strings in arduino?
Here is my code:
char *StrAB[] = {"29 EC C7 C1", "69 5B C9 C2", "22 3B 83 34",  "12 BF BF 34", "C6 78 8E 2C" };
void setup() {
  Serial.begin(9600);
}
void loop() {
  for (int i = 0; i < sizeof(*StrAB)+1; i++)
  {
    Serial.println(StrAB[i]);
    delay(1000);
  }
  Serial.println(sizeof(*StrAB)+1);
  StrAB[sizeof(*StrAB)+1]= "00 00 00 00";
}

I'm trying to append to the end of array of strings but it doesn't work? How can I delete a string from the array?

You can't append to an array as they have a fix size. You need to know how many entries are expectable at max and define the array's size accordingly. You also better use char arrays instead of your Strings, they appear to have a fixed size anyway.

Tnx Sim.  do you how can I delete  a string from the array ?

All you can do is to assign an empty string to an areay element. It not possible to append/add/remove an element of a C array, you can only change an element's value.

thank you so much that was so helpful.

Note that sizeof(*StrAB) is not the length of the string, nor the length of the array (that's why you apparently tried to fix it by adding 1). The type of *StrAB is char[], which is equivalent to char*, so sizeof(*strAB) returns the same as sizeof(void*).

thanks PMF, so how should I determine the length of this array ?

As stated by Sim Son in a comment, an array is a fixed-size data
structure in C++. You thus have to choose beforehand a suitable size,
and then keep track of how much of the array is actually used. For
example:
const int AB_max = 10;  // array capacity
const char *AB_str[AB_max] = {"29 EC C7 C1", "69 5B C9 C2",
    "22 3B 83 34",  "12 BF BF 34", "C6 78 8E 2C"};
int AB_count = 5;  // used slots

To add a string to this array, you write it to the next available slot.
But you have first to make sure there is still room available:
void AB_add(const char *s) {
    if (AB_count < AB_max)
        AB_str[AB_count++] = s;
}

If you want to remove an item (other than the last one), you will have
to shift all the following items down the array. The memmove()
function comes handy for this:
void AB_remove(const char *s) {
    // Find the index of s.
    int i;
    for (i = 0; i < AB_count; i++)
        if (strcmp(s, AB_str[i]) == 0) break;

    // Do nothing if not found.
    if (i == AB_count) return;

    // Move subsequent items down the array.
    memmove(&AB_str[i], &AB_str[i+1],
            (AB_count - (i + 1)) * sizeof *AB_str);
    AB_count--;
}

Note that moving these items down can be costly if the array is pretty
long. An array may then not be the best data structure for you. I
wouldn't worry though if it's just a dozen items or so.
Here is now a small test for all of the above:
void AB_print() {
    Serial.print("AB: ");
    Serial.print(AB_count);
    Serial.println(" items");
    for (int i = 0; i < AB_count; i++) {
        Serial.print("    ");
        Serial.println(AB_str[i]);
    }
    Serial.println();
}

void setup() {
    Serial.begin(9600);
    AB_print();
    AB_add("00 00 00 00");
    AB_print();
    AB_remove("12 BF BF 34");
    AB_print();
}

void loop() {}

Note that this is a very “C” style of doing things. If you want to go to
more idiomatic C++, you can start by putting everything that is named
with the prefix AB_ inside a class.
If you really want an array where you can vary the length, you may
allocate it with malloc() and resize it with realloc(). These
functions, however, are not very friendly to memory-constrained devices.
They are thus often avoided in the embedded world. They may also not
play well with code that uses new and delete, including library code
that you may not be aware of.


text:
Can a three wire Electrical conductivity sensor (Sensorex CS 150) be used directly with arduino?
I am having an electrical conductivity sensor (Sensorex CS150 with three tinned wires Red, Black and white https://sensorex.com/product/sensorex-cs150-12-mm-graphite-contacting-conductivity-sensor/ ). I want to measure EC of nutrient soultion used in aquaponics. I have searched on internet for connection setup and everywhere sensor (with BNC connector) is connected to arduino via expansion board. Do I require this type of expansion board or can I directly connect sensor to analog pin of arduino.

unfortunately the product page doesn't state anything about what exactly each wire is for, nor how it would be connected. Can you link to the sites you found, where a connection to the Arduino is descriped?

EC electrodes is an active sensor that requires an excitation voltage to be applied to get the result. When A DC voltage is apply to the two conductors, it caused iron to be flow from one conductor to another, causing polarisation and chemical reaction. Therefore you can't use it directly with Arduino.
To measure EC you need a Wien bridge oscillator which is used to generate an alternative current(AC) waveform for the excitation of the EC electrode. In order to avoid polarization, an alternative current (AC) typically ranging from 1kHz to 20kHz is used to provide the exitation of the electrode. The AC current is read and converted back to a DC voltage as the measurement result.
You also need a precision amplifier in order to get a meaningful measurement.
The EC value is also subject to temperature changes, so it may also requires to measure the temperature of the liquid and adjust the result for temperature compensation.
I have an product review article where it describe how EC measurement works and what is required (both hardware and software) to measure EC, you might want to further read to understand more.
Other reference:
Conductive of a solution - Andy Connelly.
Conductivity Measurement Theory Guide - .
One-chip conductivity meter monitors salt concentration - Michael Ahmon Electronics/Sept 15, 1977.

Product Manual
Seem to be a simple conductivity measurement so applying a voltage direct from the Arduino via a suitable resistor and using an analog input to measure the voltage drop should work OK. You may need to experiment with the resistor value to get a good range of readings depending on the conductivity of the solution you are measuring


text:
Code explanation when pH sensor is connected to Arduino
I have to measure the pH value for some experiment. I have checked various codes and all include the average of pH values.
#define SensorPin 0          // the pH meter Analog output is connected with the Arduino’s Analog
unsigned long int avgValue;  //Store the average value of the sensor feedback
float b;
int buf[10],temp;

void setup()
{
  Serial.begin(9600);
  Serial.println("Ready");    //Test the serial monitor
}
void loop()
{
  for(int i=0;i<10;i++)       //Get 10 sample value from the sensor for smooth the value
  {
    buf[i]=analogRead(SensorPin);
    delay(10);
  }
  for(int i=0;i<9;i++)        //sort the analog from small to large
  {
    for(int j=i+1;j<10;j++)
    {
      if(buf[i]>buf[j])
      {
        temp=buf[i];
        buf[i]=buf[j];
        buf[j]=temp;
      }
    }
  }
  avgValue=0;
  for(int i=2;i<8;i++)                      //take the average value of 6 center sample
  avgValue+=buf[i];
  float phValue=(float)avgValue*5.0/1024/6; //convert the analog into millivolt
  phValue=3.5*phValue;                      //convert the millivolt into pH value
  Serial.print("pH:");
  Serial.println(phValue,2);
  delay(5000);
}

Kindly explain the meaning of these two lines. Why take constant values as in bold (5/1024/6) and (3.5*pH)? Can I use some other value instead of these?
float phValue=(float)avgValue*5.0/1024/6; //convert the analog into millivolt
  phValue=3.5*phValue;                      //convert the millivolt into pH value

This is a fine example why magic numbers are bad. Always use symbolic constants.
Concerning the first line:

The "5.0" is the reference voltage of the ADC, apparently 5.0 volts.

The "1024" is the width of the range of values returned by the ADC.

The "6" is the number of samples summed up in the two lines before.

The ADC returns values in the range from 0 to 1023, giving you 1024 different values. If it measures 0% of its references voltage, it returns 0. If it measures 100% of its references voltage, it returns 1023. Actually the value "1024" should be "1023", but considering the accuracy it does not really matter.
By dividing the measured value by 1024, a single ADC value ranges from 0.0 (0%) to 0.999 (nearly 100%).
Multiplication by "5.0" gives the voltage, if we suppose that the reference voltage is 5.0 volts.
As 6 samples are summed up, another division by 6 is necessary to obtain the average.
In contrary to the comment the result of the first line is the measured and averaged voltage in volts, not in millivolts.
If the author had used smybolic constants, no comment would have been necessary and thus could not become erroneous.
Concerning the second line:
Apparently this is the factor of the sensor between voltage and pH value. A voltage of 0 volts means a pH value of 0, and a voltage of 4 volts means a pH value of 14. Note: pH can only range from 0 to 14.
Since you did not post a link to the data sheet of the used sensor, we cannot check this. But you can.
A first approach with symbolic constants:
static const int FIRST_INDEX_FOR_AVERAGE = 2;
static const int NUMBER_OF_VALUES_TO_AVERAGE = 6;

static const float FULL_SCALE_IN_VOLTS = 5.0;
static const int ADC_MAXIMUM = 1023; // was 1024

static const float PH_PER_VOLT = 3.5; // or even better 14.0 / 4.0

// ...

avgValue = 0;
for (int i = FIRST_INDEX_FOR_AVERAGE;
     i < FIRST_INDEX_FOR_AVERAGE + NUMBER_OF_VALUES_TO_AVERAGE;
     i++)
{
    avgValue += buf[i];
}

float phValue = avgValue * FULL_SCALE_IN_VOLTS / ADC_MAXIMUM / NUMBER_OF_VALUES_TO_AVERAGE;

phValue = phValue * PH_PER_VOLT;

There is no need to cast avgValue to float since FULL_SCALE_IN_VOLTS is float and so the calculations are done in floating point.

PH values follows a linear equation, y = mx + b, the 3.5 is the slope of the linear line. Typically a PH probe need to be calibrated with two buffer solutions, for example, at PH4 and another at PH9 or PH7, the line can then be draw and the slope can be determined.

A voltage of 0 volts means a pH value of 0, and a voltage of 4 volts means a pH value of 14. Not exactly, the measurement of PH value usually required to be amplified via an OP AMP, and since PH value can't be a negative value, the OP AMP is usually "raise" the reference voltage, say, to 2.5V, and then calibrate the probe for the OP Amp to output 0 voltage when PH is at 7.0 (Center of the PH range), so the PH value swing between +/-2.5V.

As I wrote, we have no information what sensor and external circuitry the OP uses. Therefore, I simply explained the factor. Anyway, your comments are welcome, as an potential edition of my answer. Just keep the meaning, please.

Re “the value ‘1024’ should be ‘1023’”: In theory, it should be 1024. This is clearly stated in the datasheet of the microcontroller: the value 1023 “represents the selected reference voltage minus one LSB”. In practice, you have to calibrate the ADC if you need this level of accuracy. I have measured a slope of ≈1026 on three Arduinos.

@EdgarBonet Thanks for this valuable insight!


text:
Carbon dioxide sensor MG 811
I am using MG811 carbon dioxide sensor with ESP8266 module. CO2 values is being read inside closed room. The value comes around 400 ppm. Using CO2 generator does not make increase in reading. Checked with pSense RH co2 Temp handheld meter. It shows around 750-800 ppm. But ESP8266 still shows around 420 ppm on oled display.
#include "CO2Sensor.h"
CO2Sensor co2Sensor(A0, 0.99, 100);

void setup() {
Serial.begin(9600);
Serial.println("=== Initialized ===");
co2Sensor.calibrate();
}

void loop() {
int val = co2Sensor.read();
Serial.print("CO2 value: ");
Serial.println(val);
delay(1000);
}

What is the meaning of (A0, 0.99, 100) in second line of code. Is any calibration needs to be done for correct value ?

You will probably need to show this thing is wired and what source you are using to power the heating element.

check the library documentation

Your code appears to come from an example in the library you are using https://github.com/solvek/CO2Sensor/blob/master/examples/ReadCO2/ReadCO2.ino
To answer your questions:
What is the meaning of (A0, 0.99, 100) in second line of code.
Inspection of the library source code shows:
CO2Sensor::CO2Sensor(int analogPin, float inertia, int tries)
Of course, if you don't understand how the library is using the variables inertia and tries, this alone will make no sense to you.
Is any calibration needs to be done for correct value ?
In my opinion, the answer is YES. Furthermore, I think that calibration is necessary but not sufficient to appropriately use the sensor to the extent that you can have a good idea about what a "correct value" means.
I like that you get the fundamental idea of testing, or validating, a sensor. I like the idea that you are using another monitor (assuming it is a good one) as a "standard" and I like that you use a CO2 generator - assuming you are doing that safely.
What is lacking, again, in my opinion, is any understanding of how the sensor works. It is not that I am an expert on this particular sensor, but even a brief look at what passes as a data sheet https://sandboxelectronics.com/files/SEN-000007/MG811.pdf and the text of the library usage https://github.com/solvek/CO2Sensor and a few other sources that are freely available; makes it clear to me that you need to dig into this much more before you will have success understanding and appropriately using this sensor.
It is complicated. I hope that my response is not off putting and instead points you in the right direction.


text:
How to perform multitask using arduino such as update data as well as check condition?
Here data is updated after every 2 seconds. But when the condition is true then the valve and motor process starts and data is updated only after completion of that part (i.e., data is updated after 25 seconds). I want data updation and condition checking simultaneously.
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define ONE_WIRE_BUS 4
#define TEMPERATURE_PRECISION 9

#define motor 6
#define valve 7

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

const float thld = 35;

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
  Serial.begin (115200);
  pinMode(motor, OUTPUT);
  pinMode(valve, OUTPUT);
  delay(10);

    if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
    delay(2000);

  display.setTextColor(WHITE);
}
 void loop() {
 sensors.requestTemperatures();
  float temp = sensors.getTempCByIndex(0);
  Serial.println(temp);
  Serial.println((char)176);
  Serial.println("C  |  ");
    if ( temp > thld)
  {
  digitalWrite (valve, LOW);
  delay (5000);
  digitalWrite (motor, LOW);
  delay (10000);

  digitalWrite (motor, HIGH);
  delay (6000);
    digitalWrite (valve, HIGH);
  delay (2000);
  }
  else
  {
    digitalWrite (motor, HIGH);
    digitalWrite (valve, HIGH);
  }

   display.clearDisplay();
   display.setCursor(0, 0);
   display.setTextSize(1);
   display.println("Temperature");
   display.setCursor(0, 30);
   display.println("Soil & Water Engg.");
   display.setTextSize(2);
   display.setCursor(0,10);
   display.println(temp);
   display.setCursor(75, 10);
   display.println("C");
   display.setCursor(0,40);
     display.display();

delay (2000);
 }

Don't use delay()...?

There is a tutorial for this: Blink Without Delay.

You need to think about this with a real-world analogue.
I like to use boiling an egg...
There are three ways you can boil an egg:
Blocking operation

Put the egg in the boiling water
Stand there staring at it for three minutes or so
Take the egg out of the water and eat it

Timer operation

Put the egg in the boiling water
Set a timer for 3 minutes time
Go off and do something else
When the alarm goes off take the egg out and eat it

Time polling

Put the egg in the boiling water and record the current time
Go off and do something else, every so often glancing at your watch and comparing the time to the time you started
When three minutes have passed take the egg out and eat it

Currently you are using the blocking operation where you're stood staring at the egg until it's time to do something.  You need to change your code to use one of the other methods.
Most times the time polling method is good enough. You may get some jitter where whatever else it is you are doing causes a delay before you get to glance at your watch, but that is rarely an issue. For greater precision (better for higher frequency checking) you use a timer which triggers an interrupt so you always do things at more precise intervals.
There is an example in the IDE called BlinkWithoutDelay which implements the time polling in a very simplistic way - record the time, then compare that time and the current time, and when it's elapsed change the LED's state, recording a new time.

The general approach for non-blocking code is to use millis() and compare durations:
bool active = false;
unsigned long start = 0;
const unsigned long duration = 25000; // 25 seconds

void loop() {
    unsigned long now = millis();
    if (start_condition) {
        active = true;
        start = now;
        turn_on();
    }
    if (active && now - start >= duration) {
        active = false;
        turn_off();
    }
}

Properly written non-blocking code never uses delay() but instead records time stamps and
compares durations to see when to do something.
One trap for beginners: Never compare times, only durations!
Because millis() wraps around (after 2^32 msec which is ~49.7 days) you can have a start time
that is greater than the current time, but if you subtract 2 times it always gives a proper
duration (as long as the duration is itself less than 50 days)
So the only correct way to do time checks with millis is:
(later_time - earlier_time) compared-with duration

There is a library I like that makes all of this so easy: "Ticker"

https://www.arduino.cc/reference/en/libraries/ticker/
Documentation: https://github.com/sstaub/Ticker

One subtlety with Ticker is the resolution - it can use milliseconds or microseconds, and the time can be specified in milliseconds or microsecoonds.
The default is to use microsecond resolution with millisecond specification:
Ticker x(callback, time_in_millisec); // repeat defaults to 0 (continuous), resolution to MICROS

This only works for durations up to 70 minutes, for longer durations you have to use milliseconds:
Ticker x(callback, time_in_millisec, /*repeat=*/0, /*resolution=*/MILLIS);

When specifying a callback for ticker you can use a function that takes no args and no return value:
void mycallback() {dostuff();}
Ticker x(mycallback, ....);

Or you can use a C++ lambda expression to create an unnamed function that does the same thing.
Ticker x([](){dostuff();}, ....);

Here is your code rewritten with Ticker with some assumptions on my part about what you intend, you should be able to adapt the ideas
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Ticker.h>

#define ONE_WIRE_BUS 4
#define TEMPERATURE_PRECISION 9

#define motor 6
#define valve 7

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

// use a separatethreshold for on/off to give some hysteresis
const float on_thld = 36;
const float off_thld = 35;

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void check_sensors();

// This Ticker will call check_sensors every 2seconds
Ticker ticker_sensors(check_sensors, 2000, 0);

// When we turn on the valves, we'll use this to schedule turning on the motor 5 seconds later (a 1-time event each time we do start())
Ticker ticker_motor_start([](){ digitalWrite(motor, LOW); }, 5000, 1);
// if you dislike this syntax, you could use:
//    void turn_on_motor() {digitalWrite(motor, LOW);}
//    Ticker ticker_motor_start(turn_on_motor, 500, 1);

// When we turn off the motor, we'll use this to schedule turning off the valve 5 seconds later (a 1-time event each time we do start())
Ticker ticker_valve_off([](){ digitalWrite(valve, HIGH); }, 5000, 1);

void check_sensors() {
    sensors.requestTemperatures();
    float temp = sensors.getTempCByIndex(0);
    Serial.println(temp);
    Serial.println((char)176);
    Serial.println("C  |  ");
    if (temp > on_thld) {
        if (ticker_motor_start.state() != RUNNING) {
            // cancel any pending valve turn-off
            ticker_valve_off.stop();

            // turn on valve and schedule motor turn-on
            digitalWrite(valve, HIGH);
            ticker_motor_start.start();
        }
    } else if (temp < off_thld) {
        if (ticker_motor_start.state() == RUNNING) {
            // turn off motor and schedule valves to turn off
            digitalWrite(motor, HIGH);
            ticker_valve_off.start();
        }
    }

    display.clearDisplay();
    display.setCursor(0, 0);
    display.setTextSize(1);
    display.println("Temperature");
    display.setCursor(0, 30);
    display.println("Soil & Water Engg.");
    display.setTextSize(2);
    display.setCursor(0,10);
    display.println(temp);
    display.setCursor(75, 10);
    display.println("C");
    display.setCursor(0,40);
    display.display();
}

void setup() {
    Serial.begin(115200);
    digitalWrite(motor, HIGH); // set value before enabling output
    digitalWrite(valve, HIGH); // set value before enabling output
    pinMode(motor, OUTPUT);
    pinMode(valve, OUTPUT);

    if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
        Serial.println(F("SSD1306 allocation failed"));
        for(;;);
    }

    display.setTextColor(WHITE);
    ticker_sensors.start();
}

void loop() {
    // update all the tickers - if they're not running it's a no-op
    // They only check times and decide when to call their callbacks during update()
    ticker_sensors.update();
    ticker_motor_start.update();
    ticker_valve_off.update();
}

Not all processes are time-based, so for completeness
loop:
  read the time;
  if time to run process1,
    process1();
  if time to run process2,
    process2();
  poll external event1;
  if event1 completed,
     external1();
  poll external event2;
  if event2 completed,
     external2();
end;


text:
Calibration of pH sensor
I am working with pH sensor (https://wiki.seeedstudio.com/Grove-PH-Sensor-kit/ ) and arduino. The board provided with sensor is not having any potentiometer to set the voltage value when dipped in known buffer solution. I have read that when BNC connector is short then voltage value should be 2.5 V. But when I do the same voltage comes out to be 1.9 V. Also sensor gives wrong readings when put in known buffer solutions of 4.0pH, 7.0pH and 9.2 pH. I am not getting how to calibrate the sensor without having potentiometer on board.
I have already done as per mentioned on website (in link given above).

"I have read that when BNC connector is short then voltage value should be 2.5 V", that may apply to this poorly-designed PH sensor board but certainly does not apply to Grove PH Sensor board as the board is using a single 3.3v power supply with an external reference voltage of 1.8v. You may want to read my review about the Grove PH board to understand how it work and how to use it.

You probably need to do that in software. That is supported by step 7 in the chapter Software on your linked site.
In step 4 we see the proposed demo code, which contains the calculation of pH based on the read voltage:
pHValue = -19.18518519 * voltage + Offset;

The first number is probably k, so the calculation is
pHValue = k * voltage + Offset;

For the calibration you need to find the values for k and Offset. This is done with 2 buffer solutions with known pH. Step 7 shows the formulas for calculating these values based on the known pH values (removed the dollar signs):
k= (PH2-PH1)/(V2-V1)
Offset=[(PH2+PH1)-k*(V1+V2)]/2

And they even provide a link to an Excel sheet, which helps you with the calculation: https://files.seeedstudio.com/wiki/Grove-PH_Sensor_kit/Calibration_for_k&offset.xlsx
Here is an image of that sheet:

In column B behind PH1 and PH2 you can input the known pH values for your buffer solutions. In column E behind V1 and V2 you can input the resulting sensor voltages (! voltages, not wrongly calculated pH values) for each solution. Then you will get your values of k and Offset in the cells B4 and B5.
Input those values into the calculation for phValue in the code and you should get correct values.

I have done as per mentioned. But when I put sensor in 9.2 buffer it gives ph= 2.62 and voltage =2.02. Similarly in buffer 4.0 it gives some other pH value. It leads to wrong calculation of k and offset value.

@JashanjotKaur Please add your calculation and the resulting values to your question.


text:
Unpredictable behavior of a 74HC595, Q0 has no output and LED flickering
Below is my schematics:
I am using a 74HC595 shift register and to test my connections, I have placed 8 LEDs to the output and shifted 0xFF into the shift register (1111 1111), this should light up all the LEDs. However, Q1 to Q7 lit up, but Q0 didn't, it is very dim and flickering,
After doing some research and came across the decoupling capacitor and I have place a 10uF capacitor between the 5V and GND rail on the breadboard. However, the problem still persists, Am I missing something?
thanks!
Here is my code:
int data_pin = 8;
int latch_pin = 9;
int clock_pin = 10;
int reset_pin = 11;

void setup() {
  pinMode(latch_pin, OUTPUT);
  pinMode(data_pin, OUTPUT);
  pinMode(clock_pin, OUTPUT);
  pinMode(reset_pin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  reset_SIPO_register();
  shift_SIPO(0xFF);
}

void reset_SIPO_register() {
  digitalWrite(reset_pin, LOW);
  digitalWrite(reset_pin, HIGH);
}

void shift_SIPO(byte sequence) {
  digitalWrite(latch_pin, LOW);
  shiftOut(data_pin, clock_pin, MSBFIRST, sequence);
  digitalWrite(latch_pin, HIGH);
}

the power rails are separated in the middle on those long breadboards

@Juraj I have several long breadboards, and the ones that are separated also have the red/blue lines interrupted in the middle to show. But Brendon: it's worth checking anyway.

It sounds like a loose connection. Try using a different part of the breadboard - the metal clips in the breadboard sometimes bend and fail causing bad connections.

So, green wire is 5V and is connected to the top red power rail and bottom blue... I wouldn't be surprised if you have LED cathodes on 5V, instead of 0V :D

There is a maximum current the 74HC595 can deliver. Probably you are using more than this current.
See e.g. https://electronics.stackexchange.com/questions/77841/how-much-current-can-my-74hc595-handle-on-each-output-pin
Some easy checks:

Increase the resistor value so the total current is lowered
Temporarily remove some LEDs, to see if the others behave like expected.
Use other LEDs with a higher forward voltage to reduce the current.
Changing the sketch to light one LED at a time to see if all outputs work.

I have tried removing 2 LEDs and Q0 still off,

How much current is going through the total LEDs? I read there is a max of 70 mA and if you put 7 x 20 mA = 140 mA it's double it can handle.

I haven’t done the analysis yet, but what makes me think that the current is okay is because sometimes the leds do light up but for some reason, sometimes it doesnt


text:
Connect to 8Base API with TLS on Arduino Uno Wifi Rev2
I'm trying hit some endpoints on the 8Base API with the Arduino Uno Wifi Rev2. I was able to get this API call to work with Postman, but I've had no luck once I convert it to my Arduino code. In Postman, clicking the "Code" button reveals that this is what the successful Postman request looks like:
POST /MY_PATH HTTP/1.1
Host: api.8base.com
Authorization: Bearer MY_TOKEN
Content-Type: application/json
Content-Length: 64

{
    "query": "{ listOfMachinesList { items{ machineID } } }"
}

Here's what the relevant parts of my Arduino code look like after translating this API call into my Arduino:
#include <ArduinoJson.h>
#include <SPI.h>
#include <WiFiNINA.h>
#include <Arduino.h>

WiFiSSLClient client;
char server[] = "api.8base.com";

const String requestBody = "{\"query\": \"{ listOfMachinesList { items{ machineID } } }\"}";
int status = WL_IDLE_STATUS;

void setup(){
  Serial.begin(9600);
  Serial.println("Starting");
  status = WiFi.begin(WifiSSID, WifiPassword);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.println("Waiting for connection");
  }

  Serial.println("Connected to wifi");
  attemptConnect();

}

void attemptConnect() {

  Serial.println("\nStarting connection to server...");

  if (client.connectSSL(server, 443)) {
    Serial.println("connected to server");
    // Make a HTTP request:
    client.print("POST /MY_PATH HTTP/1.1");
    client.println("User-Agent: Arduino/2.2.0");
    client.print("Authorization: Bearer ");
    client.println(String(APIKey));
    client.println("Content-type: application/json");
    client.print("Host: ");
    client.println(server);
    client.println("Connection: keep-alive");
    client.println();
    Serial.println("finished POST request");
  } else {
    Serial.println("didn't connect");
  }

}

The connection appears to fail on"client.connectSSL(server, 443)" before it can get inside the "if". My Serial Monitor shows the "didn't connect" message. Further, I added some additional Serial.println statements inside the connectSSL function. It looks like the connection fails in a function called void ServerDrv::startClient'", specifically here:
 if (!SpiDrv::waitResponseCmd(START_CLIENT_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
 {
        WARN("error waitResponse");
 }

I added the certificates from both api.8base.com and 8base.com following the instructions here: https://support.arduino.cc/hc/en-us/articles/360016119219-How-to-add-certificates-to-Wifi-Nina-Wifi-101-Modules-
Using this code and the certificate instructions above, I was able to connect to google.com on port 443, but no luck with 8base. I know that 8base uses GraphQL for their connections, but I was able to hit another GraphQL endpoint on a different, non-SSL server. I also checked to see if 8base was using a non-standard port, but, according to Postman, it is using 443. I'm a little confused why I can't get past the connectSSL function. On the surface, it seems like it should behave the same way as it does when I connect to Google, but there must be something else going on that I'm missing. Any help would be greatly appreciated!

I am passing this along to our support team to take a look. Please send me an email so we can be in touch at albert@8base.com. Thanks and best of luck! Albert

Thanks, Albert! I'll reach out over email

Unfortunately, our 8base team doesn't have much knowledge/content around C++. That said, I'd check out the following.

Here's a high-level HTTP client for Arduino that's modeled after the browser fetch API: https://github.com/instanceofMA/arduino-fetch

You wrote the API string as "api.8base.com". Try it with the full API endpoint; "https://api.8base.com/WORKSPACE_ID" (where is your workspace ID?)

LMK if this helps.

Thanks for the reply! Unfortunately, it looks like that library is only for ESP8266 and ESP32 modules. I was using the Arduino Uno Wifi Rev 2. I tried adding the workspaceID and got the same result. I was adding the workspaceID    in the client.print("POST /MY_PATH HTTP/1.1"); line. That seemed to work with another GraphQL request. Maybe I'm missing something important about how the 8base API is setup, though

Hmmm...yeah the 8base API is a very standard implementation of a GraphQL API. We didn't implement anything funky as far as I know! Would you be able to try deploying a webhook function and seeing if you're able to get a response from a HTTPS GET request?

I gave that a shot, as well. I also tried with a new free-tier account to make sure that it wasn't simply an issue with that account. I still can't get past the client.connectSSL(server, 443) line, unfortunately. Do you know if any other customers have connected to their endpoints with an Arduino?

Unfortunately, I don't. We do not have a way of determining what devices incoming traffic to workspaces originates from. Also, even if we did, we couldn't share it lol! You're the first to reach out regarding this. So please keep us informed on the process and I'll keep digging as well.


text:
Will the atmega8-U2 work with Arduino IDE
I use a homemade board that hosts a PIC16F1829 and an ATmega328P on the same board.  We use the ATmega328P with the Arduino IDE and the PIC with the MPLABX IDE for about 100 EE students a semester at UTSA.  I have 100 pic chips but no ATmega328P chips, I can re-spin the board and adapt it to the ATmega8-U2, since right now I can by 250 ATmega8-U2 chips that are in stock but there are no ATmega328P chips available anywhere and I need 100 at least. I am currently using a different UART to TTL adapter, the CP2102 to connect the ATmega328P to the Arduino IDE.  I have the 2 chips talk via a shared I2C line. How difficult will it be to use the Arduino IDE with the ATmega8-U2?  (Again, not as the UART to USB interface but as the main processor.  Thanks,

ATMega8 can be supported and used as an Arduino, all you need is to add the MCUDude's MiniCore to the IDE instead of using the default Arduino S.A.'s arduinocore-avr.

I never tried, but it seems to me it should work without issues.
In the Arduino IDE, Menu Tools → Board, you can select “Arduino NG or
older”. You then have a menu Tools → Processor where you can select
either “ATmega168” or “ATmega8”. These options don't require you to
install any extra board support package: they come with the default
“classic” AVR core, which does support the ATmega8.


text:
Connect an MPX10DP Pressure Sensor to an Arduino Mega 2560
I'm literally new to using Arduino, i am trying to build a Pitot Tube to measure airspeed using an MPX10DP differential pressure sensor and i am working with an Arduino Mega 2560.
Honestly, i have studied some tutorials of people building a Pitot Tube but the pressure sensors they use are not available in my region, the only pressure that i could afford is the MPX10DP but i am not sure of how to connect it to my arduino and make it get values.
Can someone help me or guide me a bit?

start by determining what type of output the sensor provides ... when you know that, then ask how to measure it using an Arduino ... as it stands, your question is not about arduino

That part was originally introduced by Motorola many years ago. It is a silicon strain gauge in a bridge configuration. You need an external amplifier as it only has maybe 50 mVdc output depending on your circuit. It is a relative output voltage depending on how you excite it. The one you have is a differential unit, they also made absolute and gauge units as well.  There were many application notes published on the MPX family of pressure transducers. You may have to look in the Motorola archives to find them. The voltage will be either + or - from your reference point depending on what the differential pressure is. They are not temperature compensated so you need to design that into your circuit as well.

Thanks for the answer Gil, do you know what kind of amplifier do i need? and also how do I know what resistance band I need?

Simply look for "application note MPX10DP" there are many, AN840 comes to mind but it has been a lot of years probably in the mid 1990s.


text:
Voltage drop when power from AA batteries
I am using a Arduino MKR 1010 Wifi board to control 4 servo (PS-1109MG). All the circuit is powered by 4 AA rechargeable batteries (1.2V * 4). Arduino is powered through the Vin port.
Below is a circuit just to show how they are connected (board type and other details is not correct).

When all the servos move, the arduino's LED oscillates in intensity. I deduced that the servos have a high instantaneous current consumption and the voltage of the batteries drops too much. I measured this with an oscilloscope.

The voltage drops to around 4V when the servos try to move. When the Arduino MKR is powered from the usb port and the servos from the batteries, everything works fine.
How can I reduce the voltage drop on the batteries, to use them as the only power source?
Could I use some electrolytic capacitors to reduce the voltage drop?

AA is too little for your current needs.  Use more in parallel or get bigger batteries.

Why does this question have a down vote?

You have a 1V drop from about 5V or a 25% load regulation error you know that you have excessive load and for active servos this is a result of the DC coil resistance of the motors that are active.

If you knew the motor coil resistance then for a transient servo seek, the surge voltage drop can be predicted from the ratio of the load to total resistance (Load+Rs of batteries)
the main Rule of Thumb to learn is the series resistance adds with batteries in series and reduces with batteries in parallel and thus larger capacity. So you expect the product or Rs and Ah to be constant within some family of same chemistry and brand name.

But there may be sources of deviations to test results so the method must be specified or the same to compare.

the Rs of batteries rises sharply as state of charge SoC drops below 10%  and gradually with repeated sweep tests but lowers gradually with rising temperature.

Let's compare different brands of NiMH (AA vs C) and see how close this is.  You can try your own plots to measure the slope of bulk resistance from the VI plots  ΔV / ΔI = Rs [Ω]

https://eneloop101.com/batteries/eneloop-test-results/
https://lygte-info.dk/review/batteries2012/Enesense%20C%204300mAh%20%28White%29%20UK.html
http://lygte-info.dk/review/batteries2012/Eneloop%20AA%20BK-3MCCE%201900mAh%20(White)%20UK.html

This means changing these products from AA to C results in 31% Rs which equates to a voltage drop and 226% of the AA's Ah capacity.
Eneloop is known to be a reliable high-performance NiMH brand.
Your batteries may have less performance.  You can measure your motor resistance and see if upgrading size or quality and/or cost of batteries to get the performance you need.
The LED fluctuation is a different problem from not using a constant current driver.

Thank you for suggestions. I will try to use a different battery for Arduino, so signal generated board is not affected by voltage drop. I will also consider to use a 2S LiPo with DC DC step down module.

Do not use a SMPS  unless it can handle the surge current of X Amps. It is always better to match the battery and motor voltage. Even 2 LiPo in parallel is better than using a buck regulator for burst current with undervoltage cut-out . OR Use better NiMH like Enerloop might be best if your ESR is much higher meaning lower Ah capacity like 800 mAh

Welcome! You picked a good place to connect the batteries when fully charged but it is the wrong place. You can use the Vin pin to Power your Arduino with an regulated or unregulated 7 to 12-volt power source. Like several AA batteries in series or a wall adapter that is in the range of 7 to 12 volts. Alternatively, you can power your Arduino through the 5V pin with an external regulated 5V power supply. Leave the 9V batteries for the smoke detectors they do not work very well.

Consider several options:

Larger batteries.  The type of battery was not specified.  For comparison a NiMH AA is on average about 800 mAh where a NiMH D is on average about 6600 mAh.
Use two sets of batteries.  Connect both battery grounds, all the servo grounds and the Arduino ground together.  Only connect the positive of one set of batteries to the Arduino.  Only connect the positive of the other set of batteries to the servos.  Do not connect the positive Arduino terminal with the positive servo terminals!
Using software, only operate one servo at a time.  Some (most) servos will stop moving if the position pulse is not seen by the servo.

Thank you for suggestions. I use GP ReCyko Pro Photoflash 2000mAh.

Two Amp Hours does sound good.  Still, your problems does sound like you are exceeding the capacity of your power source.  At such a point, I usually try to verify this by using a ridiculously large power source.  The advantage of going this route ... if the problem still exists ... then you are fairly sure the power source is not the problem.


text:
Are intel hex files converted into a binary format before they are written to Atmega's flash?
I have been going through some resources on bootloaders, programmers, etc (I'm very new to this specific subject) and how they work with the Atmega chips and Arduino board programming. My research may have been shallow but none of the online articles/blogs/forum posts that I have been through mentioned that the .hex file (in intel hex ASCII format) needs to be converted to any other kind of binary format. It did seem odd to me though that one would directly write ASCII plain text into an MCU's flash. Also, when using AVR Burn-o-Mat (a GUI front end for avrdude) I did notice a couple of times that the number of bytes being flashed was significantly less than the actual size of the hex file. Most recently I went through this library on github which converts intel hex into a binary format. So am I right in saying that the hex file needs to be converted to binary? So for instance, does avrdude basically do this before sending the binary stream to the bootloader (when uploading a sketch via the IDE)?

I use that library in a sketch which reads hex from SD card and writes it as binary to flash on Arduino Mega. https://github.com/JAndrassy/ArduinoOTA/blob/master/examples/Advanced/SD2Flash2BootAVRHex/SD2Flash2BootAVRHex.ino

If you read the documentation of Avrdude, you will find that it is able to use different formats of the binary to flash, including binary. The command line argument includes the specifier.

Yes, the hex codes in the .hex file are read in by avrdude (or other programs) and written to the MCU in binary. A small microprocessor would not be able to read ASCII format commands.
See my answer about What happens when code is uploaded using the bootloader?

(Following on from some comments)

I did notice a couple of times that the number of bytes being flashed was significantly less than the actual size of the hex file

I think there is some confusion here, because of the different way numbers can be represented, or stored. Just for example, the number which we know as "twenty" could be written (in a file) as:

20 (decimal)
00020 (decimal with leading zeroes)
0014  (hex)
0024 (octal)
10100 (binary digits)

Now a program like Avrdude could read numbers in any of those formats, internally convert them to "binary" and send a single byte, being that binary number, to the MCU for placing into a program memory byte.
The .hex format, which the Arduino system produces as part of the compilation process, uses lines in this format:
Line format:
  :nnaaaatt(data)ss
  Where:
  :      = a colon
  (All of below in hex format)
  nn     = length of data part
  aaaa   = address (eg. where to write data)
  tt     = transaction type
           00 = data
           01 = end of file
           02 = extended segment address (changes high-order byte of the address)
           03 = start segment address *
           04 = linear address *
           05 = start linear address *
  (data) = variable length data
  ss     = sumcheck
            * We don't use these

The above from comments in my file https://github.com/nickgammon/arduino_sketches/blob/master/Atmega_Hex_Uploader/File_Utils.ino
Example: Optiboot in all its glory (only 512 bytes):
:107E0000112484B714BE81FFF0D085E080938100F7
:107E100082E08093C00088E18093C10086E0809377
:107E2000C20080E18093C4008EE0C9D0259A86E02C
:107E300020E33CEF91E0309385002093840096BBD3
:107E4000B09BFECF1D9AA8958150A9F7CC24DD24C4
:107E500088248394B5E0AB2EA1E19A2EF3E0BF2EE7
:107E6000A2D0813461F49FD0082FAFD0023811F036
:107E7000013811F484E001C083E08DD089C08234E0
:107E800011F484E103C0853419F485E0A6D080C0E4
:107E9000853579F488D0E82EFF2485D0082F10E0AE
:107EA000102F00270E291F29000F111F8ED06801E7
:107EB0006FC0863521F484E090D080E0DECF843638
:107EC00009F040C070D06FD0082F6DD080E0C81688
:107ED00080E7D80618F4F601B7BEE895C0E0D1E017
:107EE00062D089930C17E1F7F0E0CF16F0E7DF06D8
:107EF00018F0F601B7BEE89568D007B600FCFDCFD4
:107F0000A601A0E0B1E02C9130E011968C91119780
:107F100090E0982F8827822B932B1296FA010C0160
:107F200087BEE89511244E5F5F4FF1E0A038BF0790
:107F300051F7F601A7BEE89507B600FCFDCF97BE46
:107F4000E89526C08437B1F42ED02DD0F82E2BD052
:107F50003CD0F601EF2C8F010F5F1F4F84911BD097
:107F6000EA94F801C1F70894C11CD11CFA94CF0C13
:107F7000D11C0EC0853739F428D08EE10CD085E9AC
:107F80000AD08FE07ACF813511F488E018D01DD067
:107F900080E101D065CF982F8091C00085FFFCCF94
:107FA0009093C60008958091C00087FFFCCF809118
:107FB000C00084FD01C0A8958091C6000895E0E648
:107FC000F0E098E1908380830895EDDF803219F02E
:107FD00088E0F5DFFFCF84E1DECF1F93182FE3DFCA
:107FE0001150E9F7F2DF1F91089580E0E8DFEE27F6
:047FF000FF270994CA
:027FFE00040479
:0400000300007E007B
:00000001FF

So, a line in the .hex file will start with a colon, then a length, then an address, then a transaction type, then some variable amount of data, and then a sumcheck. These are stored in the file in hexadecimal notation.
The very first thing we can deduce from this is that the file size will be over double the amount of memory that is programmed. For example, to program "AB" in hex, this would take two bytes in the .hex file ("A" followed by "B") but these would be converted into the equivalent one-byte "binary" number, which would end up in the MCU memory.
Then, because of the colon, the transaction type, the line length, and the sumcheck, the file will be somewhat longer still, than double the number of bytes to be programmed into the MCU. That is the file layout overhead.

"[...] would not be able [...]" is not correct as a general statement. The authors of the bootloader deliberately decided to use only binary data. ;-) You might also want to add that Avrdude is able to read multiple formats of the binary to flash, including binary.

I wrote that in the context of the question "It did seem odd to me though that one would directly write ASCII plain text into an MCU's flash - the ASCII plain text file is not written into flash memory and then executed. Certainly a microprocessor could read ASCII text and interpret it under program control, but the ASCII text is not itself loaded into flash and executed.

I see, so it is the wording of "to read". You mean "to read for execution" and I understood "to read for programming the flash". As there might be more like me, would you mind to enhance the answer? -- Because it were a waste of space to store programs in ASCII coded hex, I did not think of this.

I have attempted to explain it better.

:-D Wow. Yes, it's cool to explain Intelhex, and a good thing in the context. -- Please don't get it wrong, my humble issue targets just the "to read" in the second sentence, and it can be clarified satisfyingly with the content of your first comment.

"Because it were a waste of space to store programs in ASCII coded hex" - the use of sumchecks helps verify that the data has been read correctly, so it isn't a total waste of space.

Also the use of the address bytes means the hex file can be more compact. It means you can write 100 bytes here and then 50 bytes there without having to pad out the difference with thousands of zeroes.

That's all correct, and therefore formats like Intelhex have their share and advantages. Anyway, we were talking about storing a program on-chip. And because it complicates things a lot if machine code were stored in Intelhex for execution, I had no idea that you meant that.


text:
Turn ESP8266 into an Arduino IDE-like "sketch uploader" (over hardware serial)
I have an ESP8266 module which has downloaded a hex file for an Arduino Mega2560. This hex file (call it mega2560.hex) is sitting in the ESP's SPIFFS file system. What I want to do is basically emulate the behavior of the Arduino IDE when we press the upload button on a sketch (except in my case here, the sketch is already compiled and ready for transfer). What I need is some library or small code example that can steer me in the right direction. On the Mega's end, the processor will be restarted, and the bootloader will wait for the hex file, receive it from the ESP and flash it to application memory.
Here is the basic structure:
// Code for ESP8266

SoftwareSerial mega(D1, D2); // since hardware serial is occupied for serial monitor
// Mega will use its hardware serial (Tx1, Rx1)

void setup()
{
    Serial.begin(115200); // use up hardware serial
    mega.begin(115200); // connect to mega

    SPIFFS.begin();
    File hexfile = SPIFFS.open("mega2560.hex", "r");

    // IDE-like "upload"
    upload(mega, hexfile);
    Serial.println("Done uploading.");

    hexfile.close();
}

// emulate Arduino IDE-like upload behavior
void upload(SoftwareSerial& mega, File& hexfile)
{
    // reset Mega to start bootloader which will first wait to accept new hex file
    reset(mega);

    // send out the hex file for the bootloader to accept and store to Mega's flash
    send(mega, hexfile);

    // reset Mega to start bootloader again, this time so that previously uploaded hex file can be run
    reset(mega);
}

I am fairly new to working with bootloaders and would like to know if the above top-down code is correct in trying to achieve what I have in mind. Can I simply reset the Mega and transfer it as per usual via Serial within the bootloader's "waiting window" ? or are there more considerations that I am missing.
I am trying to avoid using ISP or SPI because that would erase the Mega's bootloader as well and I want to keep the bootloader preserved.

Yes, you are thinking in the right direction. You can simply reset the mega to get the mega bootloader started, but you can not just send the bytes through the serial port. Arduino bootloader uses STK500 commands for reliable handshaking. AVRdude uses the same protocol to talk to an Arduino. Here is a link that might give you some direction: https://www.electronicwings.com/arduino/basics-to-developing-bootloader-for-arduino

other option https://github.com/JAndrassy/lab/blob/master/AvrDudeTelnet/AvrDudeTelnet.ino


text:
ArduinoJson library: how much space to allocate for serialized buffer?
I am using the fantastic ArduinoJson library for working with JSON data on my ESP8266. I have been facing issues with random software wdt resets and have been investigating memory leaks wherever I can. I want to trim down my use of Strings and DynamicJsonDocuments as much as possible. So I thought of using automatic variables: char buffers: char[N] and StatitcJsonDocuments instead.
I am using the ArduinoJson assitant service to help me figure out how many bytes I should reserve. The following is one response payload, I am expecting to receive:
// char input[MAX_INPUT_LENGTH];

StaticJsonDocument<128> doc;

DeserializationError error = deserializeJson(doc, input, MAX_INPUT_LENGTH);

if (error) {
  Serial.print(F("deserializeJson() failed: "));
  Serial.println(error.f_str());
  return;
}

int statusCode = doc["statusCode"]; // 200
bool needUpdate = doc["needUpdate"]; // true
const char* message = doc["message"]; // "update required"

JsonObject data = doc["data"];
const char* data_deviceId = data["deviceId"]; // "DLD00005"
const char* data_user_fw_version = data["user_fw_version"]; // "0.0.0"
const char* data_new_fw_version = data["new_fw_version"]; // "0.0.5"

As you can see I am using a char [N] type as the input, which is in fact being copied using strncpy() from the https.getString().c_str() from the response of a previous https.POST() request. My issue is that I do not know how much memory I should reserve for the char[N] array, ie what should be the value of N? The reasons I ask is that I am getting a deserialization() failed: IncompleteInput error, which I'm pretty sure is because the char[N] buffer is not large enough. So my question is if the StaticJsonDocument object is 128 bytes, then how big should I make the char[N] buffer (is there any relation between the sizes)? Or should I just go with an arbitrarily large value like char[512] which I want to avoid to avoid stack overflows?
StaticJsonDocument<128> payload;
char payloadSerial[???];
...
int status = https.POST(payloadSerial);
strncpy(payloadSerial, https.getString().c_str(), sizeof(payloadSerial));
DeserializationError error = deserializeJson(payload, payloadSerial, sizeof(payloadSerial));
if (error) {
    Monitor.print(F("DeserializeJson() failed: "));
    Monitor.println(error.f_str());
}

You're asking about code that looks like this:
StaticJsonDocument<128> payload;
char payloadSerial[???];
...
int status = https.POST(payloadSerial);
strncpy(payloadSerial, https.getString().c_str(), sizeof(payloadSerial));
DeserializationError error = deserializeJson(payload, payloadSerial, sizeof(payloadSerial));

The documentation for deserializeJson() shows that it can accept a String directly:
DeserializationError deserializeJson(JsonDocument& doc, const String& input);

So there's no need to copy https.getString().c_str() into payloadSerial. You can just pass the String that https.getString() returns:
StaticJsonDocument<128> payload;

int status = https.POST(request_body);

DeserializationError error = deserializeJson(payload, https.getString());

You were using the same character array here for both the body of the request that you passed to POST() and for deserializing the JSON response. While this is okay, for clarity I changed the POST call to use something else as the character array is completely unnecessary for processing the response.
Even if deserializeJson() didn't accept a String type as an argument, you still wouldn't need to copy the response into a buffer. You could just pass https.getString().c_str():
StaticJsonDocument<128> payload;

int status = https.POST(request_body);

DeserializationError error = deserializeJson(payload, https.getString().c_str());

You really should check the value of status. It indicates whether the POST succeeded or not. If it failed, you should report that and the reason for the failure, and not attempt to process the returned payload as there is no returned payload.


text:
ESP32 wifi server with multiple clients
I have a program where I configure my ESP32 as a server and it sent randomly generated data, the problem is that I can only connect 1 client at a time, what I want is that multiple clients can connect and they all receive the same information,
I put the code that I have in my ESP32 as a server
#include <WiFi.h>

const char* ssid = "SSID";
const char* password =  "Password";

char data[9];

WiFiServer wifiServer(80);

void setup() {

  Serial.begin(115200);

  delay(1000);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Conectando a WiFi..");
  }

  Serial.println("Conectado a la red WiFi network");
  Serial.println(WiFi.localIP());

  wifiServer.begin();
}

void loop() {

  WiFiClient client = wifiServer.available();

  if (client) {

    while(client.connected()) {
      //Serial.println("Client Connected");

        data[0] = random(30,50);
        data[1] = random(30,50);
        data[2] = random(30,50);
        data[3] = random(30,50);
        data[4] = random(30,50);
        data[5] = random(30,50);
        data[6] = random(30,50);
        data[7] = random(30,50);
        data[8] = random(30,50);

        client.write(data,9);
        Serial.println(int(data[0]));
        Serial.println(int(data[1]));
        Serial.println(int(data[2]));
        Serial.println(int(data[3]));
        Serial.println(int(data[4]));
        Serial.println(int(data[5]));
        Serial.println(int(data[6]));
        Serial.println(int(data[7]));
        Serial.println(int(data[8]));
        delay(1000);
    }
  }
}

I am managing the clients with python
the client code is as follows
import socket

sock = socket.socket()

host = "192.168.1.68" #ESP32 IP in local network
port = 80             #ESP32 Server Port

sock.connect((host, port))

data = ""
lista = [0,0,0,0,0,0,0,0,0]
x = 0

while True:

    data = sock.recv(1)
    #x = data.decode()
    #y = x.split("p")
    buffer = int.from_bytes(data,"big")
    lista[x] = buffer
    x = x + 1
    if x >=9:
        print(lista)
        x=0

the idea is that all clients have the same code and receive the same data
but it only allows me to connect 1 client at a time

research multicast

the esp32 Arduino WiFi library doesn't implement the print-to-all-clients functionality as other Arduino WiFi libraries do. maybe my TelnetStream library can help you.


text:
Need help with calling an API using an Arduino system
As stated in the title, I need help with calling an API. I'm trying to integrate make a call using the Verkada API but it seems to be using a cURL library that I'm not entirely certain I can get to work with my Arduino Mega2560 and an ethernet shield. The API documentation gives this C/C++ code shown below but with no guidance on how to use it
CURL *hnd = curl_easy_init();

curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.verkada.com/cameras/v1/alerts?org_id=ORGANIZATION_ID&include_image_url=false&page_size=100");

struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "accept: application/json");
headers = curl_slist_append(headers, "x-api-key: API_KEY");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);

CURLcode ret = curl_easy_perform(hnd);

This code and the documentation can be found here: https://apidocs.verkada.com/reference/getnotificationsviewv1
If there's any more necessary information I haven't I'm happy to look more and provide it. If I need to be taking a different approach I would also really appreciate some advice on that.
Thank you so much!

you can use the ArduinoHttpClient library

I've been looking at the HTTPClient Library. Is there a  good way to think about translating the above code in a way that would work how it expects it to work? Verkada expects an organization ID and API Key and I don't know if that translates direct into the functions included in the library or works like a standard authorization

use a web browser, such as Chrome to retrieve the data ... use the development tools in Chrome to see what data is passed back and forth between the browser and the server ... your question is not related to Arduino

Do you know whether this API can be accessed through unencrypted HTTP? @Juraj: Seems to me that the HTTPClient library does not support HTTPS.

@EdgarBonet, you are right. then it is not possible with Ethernet shield on Mega. OP has to change to a 32-bit board with SSLClient library with Ethernet library. or instead of Ethernet shield use a WiFi shield or module which provides SSL (WiFi101, esp8266).


text:
ATTiny85 pin definitions
I have been tearing my hair out on and off for two weeks trying to figure out pin definitions for the ATTiny85 in PlatformIO. My wiring is basically this:

My sketch:
#include <Arduino.h>
#include <avr/io.h>

#define WIPER PB2

void setup()
{
  pinMode(WIPER, INPUT);
}

void loop()
{
  int wiper_raw = analogRead(WIPER);
  int wiper = map(wiper_raw, 13, 1024, 0, 255);
  // show the actual value, probably not relevant to the question

  delay(100);
}

(Showing the actual value is done by sending the mapped value over to a neopixel stick on the red channel, so basically turning the knob turns the stick from all the way off to brighter and brighter output of red.) The pot is connected to what should be physical pin 3, also known as PB4, also known as Arduino Pin 4, also known as ADC2, etc etc. (Using https://nerdytechy.com/wp-content/uploads/2021/01/attiny85-guide-pinout.png as a guide but it's not any different from any other pinout listing I've seen.)
In the sketch I'm referencing PB2, which VSCode tells me evaluates to 2. That's physical pin 7. When I plugged the pot signal pin into pin 7, I got no response when manipulating the dial. So I started plugging it into all the other pins (except VCC, GND, and RESET) and the very last one I tried, pin 3, was the one that reacted to the changes on the pot.
No pinout guide I've ever seen lists PB2 on physical pin 3. What am I doing wrong?

The very image you are linking to shows PB4 on physical pin 3.

Right. What I'm saying though is that the code has PB2 but the pot is responding on pin 3. The code that you see there works with the wiring that you see, even though it shouldn't because if the pin definitions were right, that green wire should be connected next to VCC, not GND.

The macros such as PB2 are defined in the avr-libc for accessing the
bits of the raw I/O ports, with statements such as
PORTB |= _BV(PB2);  // set PB2 as HIGH

They do not uniquely identify as pin: if you have more than one port
(say, on an Uno), both PB2 and PC2 are equal to 2.
If you use the Arduino core functions, you should not use these macros.
Instead, use the plain numbers 0, 1... with digitalRead() and
digitalWrite(), and the macros A0, A1... with analogRead().
Alternatively, with analogRead(), you can use the raw analog pin
numbers 0, 1, which are interpreted as synonyms of A0, A1...
Writing something like
analogRead(PB2);

is confusing, because you are using the avr-libc macro PB2 in the
wrong context. Furthermore, since this is the same as analogRead(2);,
the Arduino core interprets it as equivalent to
analogRead(A2);

As the pinout image shows, Arduino pin A2 is the same as ADC2, PB4 and
physical pin 3.

Perfect, that did it. So basically in the pinout image I linked above, I should have been using the blue "Arduino Pin" labels (ie. "4/A2"). Changed the code to use A2 and it worked just fine. Thanks!

Does this help at all? - I constructed this graphic from a number of sources:


text:
No matching function for call to'DS3231 (const uint8_t &, const uint8_t &)
This was supposed to be the code for automatic pet feeder
Got it from here1
The problem is that I always got a "No matching function for call to'DS3231 (const uint8_t &, const uint8_t &)"
Here's the error code
Arduino: 1.8.19 (Windows 10), Board: "Arduino Uno"

ANA_FEEDER_PROJECT:53:18: error: no matching function for call to 'DS3231::DS3231(const uint8_t&, const uint8_t&)'

 DS3231 rtc(A4, A5);

                  ^

In file included from C:\Users\SERIES\Desktop\ANA_FEEDER_PROJECT\ANA_FEEDER_PROJECT.ino:1:0:

D:\Documents\Arduino\libraries\DS3231/DS3231.h:67:3: note: candidate: DS3231::DS3231(TwoWire&)

   DS3231(TwoWire & w);

   ^~~~~~

D:\Documents\Arduino\libraries\DS3231/DS3231.h:67:3: note:   candidate expects 1 argument, 2 provided

D:\Documents\Arduino\libraries\DS3231/DS3231.h:66:3: note: candidate: DS3231::DS3231()

   DS3231();

   ^~~~~~

D:\Documents\Arduino\libraries\DS3231/DS3231.h:66:3: note:   candidate expects 0 arguments, 2 provided

D:\Documents\Arduino\libraries\DS3231/DS3231.h:62:7: note: candidate: constexpr DS3231::DS3231(const DS3231&)

 class DS3231 {

       ^~~~~~

D:\Documents\Arduino\libraries\DS3231/DS3231.h:62:7: note:   candidate expects 1 argument, 2 provided

D:\Documents\Arduino\libraries\DS3231/DS3231.h:62:7: note: candidate: constexpr DS3231::DS3231(DS3231&&)

D:\Documents\Arduino\libraries\DS3231/DS3231.h:62:7: note:   candidate expects 1 argument, 2 provided

C:\Users\SERIES\Desktop\ANA_FEEDER_PROJECT\ANA_FEEDER_PROJECT.ino: In function 'void setup()':

ANA_FEEDER_PROJECT:84:7: error: 'class DS3231' has no member named 'begin'

   rtc.begin();

       ^~~~~

C:\Users\SERIES\Desktop\ANA_FEEDER_PROJECT\ANA_FEEDER_PROJECT.ino: In function 'void loop()':

ANA_FEEDER_PROJECT:130:10: error: 'class DS3231' has no member named 'getTimeStr'; did you mean 'getMinute'?

  t = rtc.getTimeStr();

          ^~~~~~~~~~

          getMinute

ANA_FEEDER_PROJECT:146:16: error: 'class DS3231' has no member named 'getTimeStr'; did you mean 'getMinute'?

  lcd.print(rtc.getTimeStr());

                ^~~~~~~~~~

                getMinute

ANA_FEEDER_PROJECT:152:16: error: 'class DS3231' has no member named 'getDateStr'; did you mean 'getDate'?

  lcd.print(rtc.getDateStr());

                ^~~~~~~~~~

                getDate

exit status 1

no matching function for call to 'DS3231::DS3231(const uint8_t&, const uint8_t&)'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

The problem is that I always got a "No matching function for call to'DS3231 (const uint8_t &, const uint8_t &)"
Here's the error code

please read what you wrote ... there is no reason to repeat sentences

You are using the wrong DS3231 library. Unfortunately, you can often find incompatible libraries that share the same name. The sketch you downloaded has been written for a specific version of the DS3231 library. Thus your choices are:

either you use that specific version (linked to in the page you gave as reference)
or you adapt the code to work with the version you have installed.


text:
Issues Uploading Code to ATTiny84 with Sparkfun AVR Pocket Programmer and ATTinyCore
I am getting back into programming with Arduino and built a POV fidget spinner inspired by an instructable by MakersBox. I am using the SparkFun AVR Pocket Programmer and an ATTiny84 (8MHz internal clock) with ATTinyCore as the board manager.
I was able to upload the code without error a few days ago using the 'USBTinyISP (ATTinyCore) FAST, for parts running >= 2MHz' programmer selection but it stopped working. Now the below error shows:
avrdude: Version 6.3-20201216
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\Franklin Marquette\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.5.2/avrdude.conf"

         Using Port                    : usb
         Using Programmer              : usbtiny
         Setting bit clk period        : 0.3
avrdude: usbdev_open(): Found USBtinyISP, bus:device: bus-0:\\.\libusb0-0001--0x1781-0x0c9f
         AVR Part                      : ATtiny84
         Chip Erase delay              : 15000 us
         PAGEL                         : P00
         BS2                           : P00
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     6     4    0 no        512    4      0  4000  4500 0xff 0xff
           flash         65     6    32    0 yes      8192   64    128  4500  4500 0xff 0xff
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00

         Programmer Type : USBtiny
         Description     : USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
avrdude: programmer operation not supported

avrdude: Setting SCK period to 1 usec
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude done.  Thank you.

Failed programming: uploading error: exit status 1

NOW if I upload using the "USBtinyISP (ATtinyCore) SLOW, for new or 1 MHz parts" programmer option, the code does upload. It is 8x slower though. I uploaded the Blink sketch to a separate ATTiny84 on a breadboard and the connected LED stayed on for ~7.75s when it was programmed to stay on for 1s.
I have no idea what is going on and would really appreciate any help that I can get. Thank you!
For reference, the code is below.
/*

Not all Attiny cores support the tone() function. Try this one
https://github.com/SpenceKonde/ATTinyCore

// ATMEL ATTINY84 / ARDUINO
//
//                           +-\/-+
//                     VCC  1|    |14  GND
//             (D  0)  PB0  2|    |13  AREF (D 10)
//             (D  1)  PB1  3|    |12  PA1  (D  9)
//                     PB3  4|    |11  PA2  (D  8)
//  PWM  INT0  (D  2)  PB2  5|    |10  PA3  (D  7)
//  PWM        (D  3)  PA7  6|    |9   PA4  (D  6)
//  PWM        (D  4)  PA6  7|    |8   PA5  (D  5)        PWM

*/

#include <EEPROMex.h>
#include <avr/pgmspace.h>
#include "font.h"
#include "textAndShapes.h"

const int charHeight = 8;
const int charWidth = 5;
int rows= 8;                // Total LED's in a row
int LEDS[] = {0, 1, 2, 3, 4, 5, 7, 6};
bool STATES[] = {LOW, LOW, LOW, LOW, LOW, LOW, LOW, LOW};

char charArray[6];              // holds characters to display
unsigned long lastTimeUs;                // time (us) magnet sensed
unsigned long revTimeUs;                 // time (us) of last full rotation
unsigned long dwellTimeUs;               // time (us) between LED changes (based on rotation speed)
volatile unsigned long revolutions = 0;  // track number of revolutions since last start
long totalRevolutions;          // track total number of revolutions (stored in EEPROM)
bool spinning = true;          // track reset of time & counts
unsigned long startTimeUs;               // time (us) current spinning started

int mode;                       // current operating mode, stored in EEPROM
int modes = 8;                  // number of modes available
  // 0 -> text "Hello World!"
  // 1 -> RPM
  // 2 -> time in seconds
  // 3 -> spin count
  // 4 -> spin count (total)
  // 5 -> "lilly pad" pattern
  // 6 -> shape 1 (heart)
  // 7 -> shape 2 (smile)

byte ledPin = 0;
byte magPin = 0;                // Hall effect sensor, pulled-up, goes low when magnet passes
byte magPullUp = 10;            // Pin A0 / D10
byte touchPin = 1;              // Push button A1 / D9
byte touchPullUp = 9;

volatile boolean rotationFlag = false;  // modified by ISR

void setup(){
  // setup inputs
  pinMode(touchPin, INPUT);
  digitalWrite(touchPullUp, HIGH);
  pinMode(magPin, INPUT);
  digitalWrite(magPullUp, HIGH);

  // setup other LEDs
  for(int LED=0; LED<(sizeof(LEDS)/sizeof(int)); LED++){
    pinMode(LEDS[LED], OUTPUT);
    digitalWrite(LEDS[LED], STATES[LED]);
  }

  // Interupt setting
  GIMSK  = bit (PCIE0);  // Pin change interrupt enable
  PCMSK0 = bit (PCINT0); // Enable interupt on PCINT0 (D10)
  sei();                 // enables interrupts

  // get saved mode from eeprom
  mode = EEPROM.read(0);
  if (mode >= modes) {
    mode = 0; // may be very large first time
  }

  // get saved revolution total from eeprom
  totalRevolutions = EEPROMReadlong(1);
  if (totalRevolutions < 0 || totalRevolutions > 999999UL){ // will be -1 first time.
    totalRevolutions = 0;
    EEPROMWritelong(1, 0);
  }

  // show we are alive and what mode is active
  blipLEDs();

  lastTimeUs = micros();
}

void loop(){
  int sigFigs = 6;               // number of significant figures to deplay
  unsigned long curTimeUs;
  int seconds;
  unsigned int rpm;

  checkButton();
  if (((micros() - lastTimeUs) > 1000000UL)){ // less than 1 rev / sec
    if (spinning){
      spinning = false;
      totalRevolutions = totalRevolutions + revolutions;
      EEPROMWritelong(1, totalRevolutions);
      revolutions = 0;
      clearArray();
      blipLEDs();
    }
    else {
      //digitalWrite(LEDS[mode], LOW);
    }
  }

  if (mode == 5){  // lilly pad pattern, show regardles of magnet.
    for(int LED=0; LED<(sizeof(LEDS)/sizeof(int)); LED++){
       digitalWrite(LEDS[LED], HIGH);
       delay(1);
       digitalWrite(LEDS[LED], LOW);
    }
    for(int LED=(sizeof(LEDS)/sizeof(int))-1; LED >= 0; LED--){
       digitalWrite(LEDS[LED], HIGH);
       delay(1);
       digitalWrite(LEDS[LED], LOW);
    }
  }

  else if (rotationFlag){ // we are spinning!
    rotationFlag = false;
    if (!spinning){
      spinning = true;
      startTimeUs = micros();
    }
    curTimeUs = micros();
    revTimeUs = curTimeUs - lastTimeUs;
    dwellTimeUs = revTimeUs * 3UL / 360UL;   // 3 degrees
    seconds = (curTimeUs - startTimeUs) / 1000000UL;
    rpm = 60000 * 1000 / revTimeUs;
    lastTimeUs = curTimeUs;
    clearArray();
    if (mode == 0){
      strcpy (charArray, text);
      //sprintf(charArray, "%lu", dwellTimeUs);
    }
    else if (mode == 1){
      sprintf(charArray, "%d", rpm);
      sigFigs = 2;
    }
    else if (mode == 2){
      sprintf(charArray, "%d", seconds);
    }
    else if (mode == 3){
      sprintf(charArray, "%lu", revolutions);
    }
    else if (mode == 4){
      sprintf(charArray, "%lu", totalRevolutions + revolutions);
    }
    else if (mode == 6){ // shape 1 (heart)
      for(int k=0; k< sizeof(shape_1);k++){
        if (rotationFlag){
          break;
        }
        char b = pgm_read_byte_near(&(shape_1[k]));
        for (int j=0; j<charHeight; j++) {
          digitalWrite(LEDS[j], bitRead(b, 7-j));
        }
        dwellTimeUs = revTimeUs * 4UL / 360UL;   // 5 degrees
        delayMicroseconds(dwellTimeUs);
      }
    }
    else if (mode == 7){ // shape 2 (smile)
      for(int k=0; k< sizeof(shape_2);k++){
        if (rotationFlag){
          break;
        }
        char b = pgm_read_byte_near(&(shape_2[k]));
        for (int j=0; j<charHeight; j++) {
          digitalWrite(LEDS[j], bitRead(b, 7-j));
        }
        dwellTimeUs = revTimeUs * 4UL / 360UL;   // 5 degrees
        delayMicroseconds(dwellTimeUs);
      }
    }

    // Text in top half
    if (mode < 5) {
      int digits = 0;
      for(int k=0; k< sizeof(charArray);k++){
        char c = charArray[k];
        if (rotationFlag){
          break;
        }
        if(c){
          if (digits < sigFigs){
            printLetter(c);
            //digits += 1;
          }
          else{
            printLetter('0');
          }
          digits += 1;
        }
      }

      // Handle display in lower section
      clearArray();
      if(1 && (revTimeUs < 200000)){
        char * ptr = (char *) pgm_read_word (&string_table[mode]);
        //char buffer [6]; // must be large enough!
        strcpy_P (charArray, ptr);

        // wait for it . . .
        while((micros() < (lastTimeUs + revTimeUs / 2)) && !rotationFlag){};

        // show it
        for (int k=sizeof(charArray)-1; k>=0; k--){
          if (rotationFlag){
            break;
          }
          printLetterLower(charArray[k]);;
        }
      }
    }
  }
}

ISR(PCINT0_vect){  // Magnet sensed
  if (!digitalRead(magPullUp)){
    rotationFlag = true;             // Increment volatile variables
    revolutions += 1;
  }
}

void dwellDelay(){ // avoid glitch on first rotation having erronious value
  if (dwellTimeUs > 2000){
    dwellTimeUs = 2000;
  }
  if (dwellTimeUs < 100){
    dwellTimeUs = 100;
  }
  delayMicroseconds(dwellTimeUs);
}

void printLetter(char ch){
// https://github.com/reger-men/Arduion-POV-clock/blob/master/clock.ino
  // make sure the character is within the alphabet bounds (defined by the font.h file)
  // if it's not, make it a blank character
  if (ch < 32 || ch > 126){
    ch = 32;
    }
  // subtract the space character (converts the ASCII number to the font index number)
  ch -= 32;
  // step through each byte of the character array
  for (int i=0; i<charWidth; i++) {
    char b = pgm_read_byte_near(&(font[ch][i]));

    for (int j=0; j<charHeight; j++) {
      digitalWrite(LEDS[j], bitRead(b, 7-j));
    }
    dwellDelay();
  }

  //clear the LEDs
  for (int i = 0; i < rows; i++)
    digitalWrite(LEDS[i] , LOW);
  dwellDelay();
}

void printLetterLower(char ch){
  // make sure the character is within the alphabet bounds (defined by the font.h file)
  // if it's not, make it a blank character
  if (ch < 32 || ch > 126){
    ch = 32;
    }
  // subtract the space character (converts the ASCII number to the font index number)
  ch -= 32;
  // step through each byte of the character array
  for (int i=charWidth-1; i>-1; i--) {
    char b = pgm_read_byte_near(&(font[ch][i]));
    for (int j=0; j<charHeight; j++) {
      digitalWrite(LEDS[j+1], bitRead(b,j));
    }
    dwellDelay();
  }
  //clear the LEDs
  for (int i = 0; i < rows; i++)
    digitalWrite(LEDS[i] , LOW);

  // space between letters
  dwellDelay();
}

bool touched(){
  // returns true if touched, false if not.  Light LED until touch released
  bool touchVal = digitalRead(touchPullUp);
  if (!touchVal){
    while(!digitalRead(touchPullUp)){ // wait till touch release
      delay(10);
      digitalWrite(LEDS[mode], LOW);
    }
    //digitalWrite(LEDS[0], LOW);
    return (true);
  }
  else{
    return (false);
  }
}

void checkButton(){
  // check button for mode change and display current mode
  if (touched()){
    mode += 1;
    if (mode >= modes){
      mode = 0;
    }
    EEPROM.write(0, mode);
    blipLEDs();
  }
}

void blipLEDs(){
  // something to show we are alive
  for(int LED=0; LED<(sizeof(LEDS)/sizeof(int)); LED++){
    digitalWrite(LEDS[LED], HIGH);
    delay(10);
    digitalWrite(LEDS[LED], LOW);
  }
  for(int LED=sizeof(LEDS)/sizeof(int); LED>mode; LED--){
    digitalWrite(LEDS[LED], HIGH);
    delay(10);
    digitalWrite(LEDS[LED], LOW);
  }
  digitalWrite(LEDS[mode], HIGH);
}

void EEPROMWritelong(int address, long value)  {
  //This function will write a 4 byte (32bit) long to the eeprom at
  //the specified address to address + 3.
  //https://playground.arduino.cc/Code/EEPROMReadWriteLong

  //Decomposition from a long to 4 bytes by using bitshift.
  //One = Most significant -> Four = Least significant byte
  byte four = (value & 0xFF);
  byte three = ((value >> 8) & 0xFF);
  byte two = ((value >> 16) & 0xFF);
  byte one = ((value >> 24) & 0xFF);

  //Write the 4 bytes into the eeprom memory.
  EEPROM.write(address, four);
  EEPROM.write(address + 1, three);
  EEPROM.write(address + 2, two);
  EEPROM.write(address + 3, one);
}

long EEPROMReadlong(long address){
  //Read the 4 bytes from the eeprom memory.
  long four = EEPROM.read(address);
  long three = EEPROM.read(address + 1);
  long two = EEPROM.read(address + 2);
  long one = EEPROM.read(address + 3);

  //Return the recomposed long by using bitshift.
  return ((four << 0) & 0xFF) + ((three << 8) & 0xFFFF) + ((two << 16) & 0xFFFFFF) + ((one << 24) & 0xFFFFFFFF);
}

void clearArray(){
  for(int i=0; i<sizeof(charArray); i++){      // clear array
    charArray[i] = 0;
  }
}

I'm probably missing something. I'll just point out that the selection of the board/options sets the IDEs expectations for compiling the code and it sets the configuration that it would burn if you did "burn bootloader". If you tell the IDE that you have an 8mhz configuration when you in fact have a 1mhz configuration, your delays will be 8 times longer and your serial rates 1/8th.  I don't know what that has to do with failing to upload though. Max ISP rate is either 1/4 so 1/6 actual clock rate. You can't use a 1mhz isp bitclock with a 1mhz clocked chip. Are you doing that? no idea.


text:
Does ADXL 345 accelerometer not wirk with Arduino Uno without soldering?
I followed the Adafruit tutorials to wire the ADXL 345 with Ardiuno Uno, but it is not able to detect the sensor.  It did not mention that I need to solder the ADXL 345.  Is soldering necessary?

The ADXL345 is a chip. Did you buy a chip, or did you buy a module with the chip on? Are you referring to the header pins that some modules come with? If so then yes of course they need to be soldered in.

If you could follow completely through the adafruit tutorial, then most likely that is not the problem. This sounds like an X-Y problem. You are asking about soldering because you think that might be a problem. Though the real problem might be somewhere else. Please include a wiring diagram of your real setup (not the tutorial), your code, a description of what behavior you expected vs what actually happened and a description, of what you have tried to track down the problem.

Some boards and wires are built so that plugging them together should work fine.  For example the following picture from embedded.com of an Arduino, ready made wires with pins at the ends and a bread board should connect with no soldering:

And if your Analog Devices ADXL-350 chip is already soldered onto a PCB with 1/10 inch headers as in this picture from Adafruit.com:

... you should be able to connect the Arduino to the accelerometer with out soldering.
However, if the header and ADXL-450 PCB from Adafruit are not soldered together, as is the case in this picture:

... you will have to solder them as outlined on this Adafruit web page.