body:
I have a simple arduino project with 5 leds, the project should start with led 1 fade through 50 millisec to reach full brightness, then led 2 and so on until led 5 then turn them all off and loop.

here is an image for the circuit (pardon the messy look my first time):
[![leds connected to the first 5 pwm pins 3-10][1]][1]

  [1]: https://i.stack.imgur.com/3qjhw.png

"all leds cathod are connected"
and here is the code :

     int led[5]={3,5,6,9,10};
    // led pins array (pwm)
    void setup() {
      // put your setup code here, to run once:
      for (int i = 0; i < 5; i++){
        pinMode(led[i], OUTPUT);
        }
        // set each pin as an output
    }

    void loop() {
      for (int i = 0; i < 5; i++){
        int pin = led[i];
        // storing the value of the current pin in a variable
        int j = 0;
        while(j <= 50){
          j++;
          delay(1);
          analogWrite(pin,j*2);
        }
        /* the while loop is used to make the fade effect
        by increasing the duty cycle by 2% each millisec
        over 50 millisec */
      }
      delay(200);

      for (int z = 5; z > -1; z--){
        int pin = led[z];
        analogWrite(pin,0);
        }
        // turning off all leds
        delay(50);
    }

the problem is as follows :
the first round of the loop the circuit acts as expected led 1 on then 2 etc then they all turn off and loops again, on loop 16 led 1 turns off and the loop continues only with leds from 2-5 and on loop 31 led 4 and 5 turns off and only led 2 and 3 keep on going.

Edit 1 : i just found something interesting on arduino's official page
(pins supporting pwm 3, 5, 6, 9, 10, 11 )
pwm frequency 490 Hz (pins 5 and 6: 980 Hz)
so could the frequency result in this error?

Edit 2 : the issue was resolved with a really wierd change in the code
the very first line of code " int led[5]={3,5,6,9,10};" i changed the size of the array from 5 to 6 like this " int led[6]={3,5,6,9,10};" and the issue was resolved, I discovered this while i was trying to use 4 leds and i forgot to change the size, if anyone could explain how did this change helped solve the problem ?

title: Arduino fade in/out 5 leds circuit acting wierd

Answers: 2

body:
Your problem may be in your count down code. Specifically this loop:

    for (int z = 5; z > -1; z--){

Z starts at 5, and you then try and access element 5 of a 5-element array. That sounds reasonable until you remember arrays are 0-based, so there is no element 5, only elements 0-4.

So you're reading data that you shouldn't be reading. Just reading shouldn't have any effect though, so :shrug:...

Anyway, there's some "best practice" things you should do to improve your code:

1. Use 8-bit values to store your pins (`uint8_t`)
2. Make your pins array `const` so it's never modifyable
3. Replace your `while` loop with a simpler to understand and follow `for` loop
4. Keep your loops as simple count-up and use math to work out which array entry you want.
5. Keep variables to the smallest storage size needed for the values you're working with.

For example (untested):

```c++
const uint8_t led[5] = { 3,5,6,9,10 };
// led pins array (pwm)

void setup() {
  for (uint8_t i = 0; i < 5; i++) {
    pinMode(led[i], OUTPUT);
  }
}

void loop() {
  for (uint8_t i = 0; i < 5; i++){
    int pin = led[i];
    for (uint8_t j = 0; j < 50; j++) {
      delay(1);
      analogWrite(pin, j * 2);
    }
  }

  delay(200);

  for (int z = 0; z < 5; z++) {
    int pin = led[4 - z];
    analogWrite(pin, 0);
  }

  delay(50);
}
```

Also as noted in the comments you *must* have one resistor *per LED* and *never* connect all the cathodes together like that. The brightness of each LED is determined by the current flowing through it. That current is the current through the resistor, which is determined by the forward volgage of the LEDs. The more LEDs you have on the more that current is split between the LEDs. And different LEDs will have different forward voltages, and the lowest one will "win" affecting the current that the resistor allows. It's all a horrible mess and must be avoided at all costs. The only times you can have just one resistor for multiple LEDs are a) if you have a series chain of LEDs making them in effect just one LED with a higher forward voltage, or b) can absolutely guarantee that one and only one LED will ever be turned on at a time.

body:
Here is the @Majenko code output

[![enter image description here][1]][1]

The code same as the one posted in the other answer. You can find the simulation link here --> https://wokwi.com/arduino/projects/318609194610590292

I also hooked up a logic analyser and here is how it looks :) You can look how the Duty cyle is becoming larger afer every cycle.
[![enter image description here][2]][2]

  [1]: https://i.stack.imgur.com/Bvzfo.gif
  [2]: https://i.stack.imgur.com/1Ljwo.png


body:
I have a small project that i want to show my keypad pressed on my GLCD but when i pressed keypad, even on serial it is fines but on GLCD it can't show my characters. Could you tell me what the problem and what should i do to solve!.  my GLCD library is BasicGLCD!

#include <Keypad.h>
#include <EEPROM.h>
#include <basicGLCD.h>
basicGLCD GLCD;
/*long four = 0;
long three = 0;
long two = 0;
long one = 0;
*/
int adress = 0; // gia tri dia chi luu du lieu
const byte rows = 4; //so hang
const byte columns = 4; // so cot

int holdDelay = 100; // thoi gian tre de xem la nhan 1 nut de tranh nhieu~
int n = 3; //
int state = 0; // neu state=0 khong nhan, state=1 nhan thoi gian nho , state = 2 nhan giu lau
char key = 0;
int i=1;
//dinh nghia cac gia tri tra ve
char hexaKeys[rows][columns] =
{
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'},
};

byte rowPins[rows] = {4, 5, 6, 7}; // cách nói chan Arduino
byte columnPins[columns] = {12, 13, 2, 3};// cách nói chan Arduino

//cài đặt thư viện keypad
Keypad keypad = Keypad(makeKeymap(hexaKeys), rowPins, columnPins, rows, columns);
//////////////////////////////////////////////////////
void setup() {
  Serial.begin(9600);//bật serial, baudrate 9600

 // GLCD.setCursor(4, 0);
  //GLCD.sendString("WELCOME....");

  //////
  GLCD.setDataPins(23,25,27,29,31,33,35,37);
  GLCD.setRSPin(A2);
  GLCD.setCSPins(A0, A1);
  GLCD.setENPin(A4);
  GLCD.setRWPin(A3);
  if(GLCD.init() != 1) {
    Serial.println("You have to set all pins");
    return 0;
  }
  else {
  GLCD.sendString("   WELCOME  ");
  GLCD.setCursor(10, 0);
  delay(500);
  GLCD.clear();}
  //////////////////////////////////////////

 GLCD.setCursor(0, 1);
 GLCD.sendString("Loai IVT: ");
 GLCD.setCursor(0, 2);
 GLCD.sendString("TG mau : ");
 GLCD.setCursor(0, 3);
 GLCD.sendString("CSCD :");

}
//////////////////////////////////////////
void loop()
{
  char temp = keypad.getKey();
  if ((int)keypad.getState() ==  PRESSED) {
    if (temp != 0) {
      key = temp;
    }

    //xem kq
  if(temp)
    {if(temp == '+')
    {GLCD.clear();}
    if(temp == '=')
    {i=i+1;}
    GLCD.setPage(RIGHT);
    GLCD.setCursor(5,i);
    GLCD.sendData(temp);
    ;
    }
 delay(500);
}
}

title: I can't show the button pressed on the GLCD ST7920?

Answers: 0


body:
I have a NodeMCU 1.0 ESP-12E development board.  Trying to hook up a LM35 to measure temperature.  For that I need to use the analog pin A0. However it seems my sensor is out by about 4C.  I traced this to an offset error - when the board is connected via USB to the PC, and I connect analog pin A0 to analog ground with a jumper on the board, I read 13 from analogRead(A0).  I should be getting 0.  I confirmed with a voltmeter that A0 is at ground potential.  I have nothing else connected to the board.  When I feed in 3.3V to A0, I get 1024.  When I hook up the LM35 which outputs 210mV, I get a reading of 81 which is 13 off (based on the standard analogValue / 1024 * 3300 calculation).

What am I doing wrong?

title: NodeMCU dev board shows 13 for ADC when grounded - why?

Answers: 1

body:
The input A0 is not actually an ADC input. Instead it's the input to a voltage divider which *then* goes to the ADC input. The ESP8266's ADC is only capable of reading up to about 1.1V, so the makers of the NodeMCU helpfully created a small voltage divider (two resistors) to drop the input voltage to the range the ADC can cope with.

Except it's not perfect.

The resistors used aren't 100% precise, so the actual values you get from the ADC vary slightly from board to board. To get more precise readings you will have to first calibrate your ADC by providing known stable voltages to the ADC and logging the read values. Or you can measure the resistors used on your board and use those in the calculation to determine actually what value is being seen by the ADC.

Or you can use an external ADC that doesn't require the voltage divider circuit to function, which would be my preferred method, since the internal ADC is not great.


body:
I know the whole controlling a fan with an arduino thing is getting old, but somehow I still don't get it to work. Tried to answer it based on other questions but I am too much of a newbie to extrapolate the info there to my specific problem.

For my project of building an arduino-controlled mushroom grow box, I need to control a PC fan and ultrasonic fogger. I chose these two products:

[DC 3-12V Ultrasonic Fogger](https://www.amazon.de/gp/product/B07V72T1T9/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1),
[DC 5V Fan](https://www.amazon.de/gp/product/B07X93XGBD/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1)

I hoped that by using 5V devices, I could connect them to the 5V pin of the arduino to power them. However, with the whole setup (see circuit and photo), they don't run. I'm using a BC337 transistor. I tried them both separately, but nothing.

[![Circuit of the fan connected to arduino. Fogger was hooked up the same way][1]][1]

I know that there is a resistor missing in the photo, I forgot to put it back in when I took it.

[![How it actually looked - but missing a resistor which I forgot to add in this (Refer to circuit)][2]][2]

The fan works if I just insert it between 5V and GND but the fogger doesn't do anything.

The code works (and is fairly hard to mess up) but I'm including it anyway.

    const int fan = 3;

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

    void loop() {
      digitalWrite(fan, HIGH);
    }

**Do I need a higher voltage power supply or is something wrong with my transistor choice? Which parts would be a better fit? Or am I entirely on the wrong track?**

In the end the full thing should also contain an LCD display and a SCD41 sensor, both connected via I2C.

[![enter image description here][3]][3]

Thanks in advance!

  [1]: https://i.stack.imgur.com/z19Rm.jpg
  [2]: https://i.stack.imgur.com/qUO6i.jpg
  [3]: https://i.stack.imgur.com/gEGh4.jpg

title: Controlling a 5V fan and ultrasonic fogger with an arduino - do I need an external power supply?

Answers: 2

body:
**About the ultrasonic fogger:**

The product description is misleading. This is a pure transducer. That means it does **not** generate its own ultrasonic frequency and is thus not DC. You need to provide an AC voltage at the frequency of 113kHz (though one reviewer states to have received products with a resonance frequency of 108kHz. Maybe just try out what you have). You can use utilize Timer1 to generate a fitting square wave at one of its output compare pins.

Note: Since you are more at the lower end of the foggers voltage rating you might see a bad performance when you get it to work. For it to work with its full power you should probably drive it with 12V, utilizing its full range.

**About the fan:**

As jsotola already stated in the comments, the red wire of the fan is not connected to the circuit. If you look at your breadboard you will see that the blue and red lines are interrupted in the middle of the breadboard. This means, that the rails are disconnected here (divided into the left and the right part of the breadboard). Move the red fan cable to the left of the red LED jumper wire. Then you should be connected.

body:
In regards with your schematics

1. Are you sure you want your stuff working only when both D3 and D5 are up? Because it seems to me you connected them in series, so if one transistor is down, nothing's gonna work.

2. check the power rating of the ultrasonic transducer, if you get your power source from the computer USB port, you will get at best [about 2.2W from the 5V pin](https://arduino.stackexchange.com/questions/35121/max-current-of-vin-and-5v-pin-on-arduino-nano). It may turn out that it may be insufficient to produce any notable effect from the transducer with that, especially if you have the fan powered too.


body:
I'm trying to run the "DemoReel 100" code from FastLED.

Out of the box, it can be verified.  But when I switch from `#define LED_TYPE    WS2811` to `#define LED_TYPE    WS2801`, I get the error:

> error: static assertion failed: Invalid pin specified
  static_assert(validpin(), "Invalid pin specified");

the line this error originates from is:

```
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
```

I can't think of any reason that the LED_TYPE argument should change whether or not a data-pin is valid.  What's going on?

title: FastLED: "Invalid pin specified" when specifying LED_TYPE from WS2811 to WS2801

Answers: 1

body:
I figured it out.  There's two lines for `FastLED.addLeds`, and one needed to be commented out and the other enabled in order have a clock pin work.

```
//  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
```


body:
I am trying to record the pulses from a water flow sensor using a state machine. My goal is to count the pulses until the flow stops (i.e. the rotor inside comes to rest). This will constitute a single reading. if there is no new pulse/interrupt 5 seconds after the rotor is stopped, the total pulse count is printed and pulse count is reset to zero for the subsequent readings.

However, in practice, I get a pulse count even when the sensor rotor is moving. The pulse count gets resets after 5 sec but the pulses between the new reading and until the rotor is stopped are somehow missed.

Could you please help me figure what am I doing wrong?

    #include <Arduino.h>
    #include <TelnetStream.h>

    const byte pulsePin = 22;
    byte volatile triggerCounter = 0;

    byte newState = 0;

    unsigned long newTime = 0;
    unsigned long oldTime = 0;

    unsigned long pulseCountNew = 0;

    portMUX_TYPE mux = portMUX_INITIALIZER_UNLOCKED;

    void IRAM_ATTR handleInterrupt()
    {
      portENTER_CRITICAL_ISR(&mux);
      triggerCounter++;
      portEXIT_CRITICAL_ISR(&mux);
    }

    void stateMachine()
    {

      switch (newState)
      {

      case 0 /* Reset */:
        newState = 1;

        break;

      case 1 /* Start */:

        if (triggerCounter > 0)
        {
          newState = 2;
        }
        break;

      case 2 /* Pulse count start */:

        pulseCountNew++;
        triggerCounter--;
        newTime = millis();
        newState = 3;

        break;

      case 3 /* Pulse count stop */:

        if (triggerCounter > 0)
        {
          newState = 2;
        }

        if (newTime - oldTime >= 5000)
        {
          oldTime = newTime;
          newState = 4;
        }
        break;

      case 4 /* Cycle complete */:
        newState = 0;
        TelnetStream.println("State 4");

        break;
      }
    }

    void setup()
    {
      pinMode(pulsePin, INPUT_PULLUP);
      attachInterrupt(digitalPinToInterrupt(pulsePin), handleInterrupt, FALLING);
      TelnetStream.begin();
    }

    void loop()
    {

      if (newState == 4)
      {

        TelnetStream.println(pulseCountNew);
        pulseCountNew = 0;
      }

      stateMachine();
    }

title: State machine problem

Answers: 1

body:
I do this usually without an extra state variable.

```
unsigned long readSensor() {
  const unsigned long READING_TIMEOUT_MILLIS = 5000;
  static unsigned long lastReadingMillis;
  static unsigned long lastCounterValue;

  noInterrupts();
  unsigned long counter = triggerCounter;
  interrupts();

  if (counter != lastCounterValue) { // if new reading
    lastReadingMillis = millis(); // reset timout timer
    lastCounterValue = counter;
  } else if (counter > 0 && (millis() - lastReadingMillis) > READING_TIMEOUT_MILLIS) { // if something was counted and is timeout
    noInterrupts();
    triggerCounter = 0;
    interrupts();
    lastCounterValue = 0;
    lastReadingMillis = 0;
    return counter;
  }
  return 0;
}

void loop() {
  unsigned long value = readSensor();
  if (value) {
    Serial.println(value);
  }
}
```

sorry, the code is not tested.


body:
I build my ESP32 project from platformio and I'd like to change CONFIG_MBEDTLS_DYNAMIC_FREE_PEER_CERT in order to reduce the RAM footprint.
I don't get how to do that: should I modify my platformio.ini?

title: How to use ESP32 ESP32 config flag in platformio?

Answers: 1

body:
Simply put, you have to update your platformio.ini as assumed in the question as follows (see last line):

```ini
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
lib_deps =
 adafruit/Adafruit NeoPixel@^1.10.0
 plerup/EspSoftwareSerial@^6.13.2
 miwagner/ESP32CAN@^0.0.1
 nilsminor/TMP117-Arduino@^1.0.2
 lbernstone/Tone32@^1.0.0
board_build.partitions = no_ota.csv
build_flags = -DCONFIG_MBEDTLS_DYNAMIC_BUFFER
```


body:
As soon as I include keyboard.h my pro micros LED starts flashing (as far as I know this indicates a serial connection is stablished or so.)

But it's really annoying having a flashing led on my desk all the time.

Is there an option to disable this 'debugging' behaviour from the keyboard.h libary?

title: Disable Keyboard.h status LED

Answers: 2

body:
Those LEDs are controlled by the USB Core code, and are defined in the board variant.  For the pro micro that's the [`pins_arduino.h`](https://github.com/arduino/ArduinoCore-avr/blob/master/variants/micro/pins_arduino.h#L31) file in the `micro` variant:

```c++
#define TXLED0   PORTD &= ~(1<<5)
#define TXLED1   PORTD |= (1<<5)
#define RXLED0   PORTB &= ~(1<<0)
#define RXLED1   PORTB |= (1<<0)
#define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0), TXLED0, RXLED0
```

If you edit that file and remove everything after the macro name, so you have 5 empty macros, it should disable the LEDs completely.

```c++
#define TXLED0
#define TXLED1
#define RXLED0
#define RXLED1
#define TX_RX_LED_INIT
```
----

**Edit:**
For the **Sparkfun Pro Micro**, edit the file at

    ...\AppData\Local\Arduino15\packages\SparkFun\hardware\avr\1.1.13\variants\promicro

This is because it has an extra package that is not installed by default.

body:
> **it's really annoying having a flashing led on my desk all the time.**

As a software engineer I know we often fall into the trap of thinking that all problems must have a software solution. Try thinking of this as a hardware problem.

- Cut out a small piece of a sticky label and stick it over that annoying LED.
- Use a soldering iron to remove the offending LED.
- Use needle-nosed pliers to crush the offending LED.

The more destructive solutions can be reversed with a soldering iron and maybe a new SMD LED. For Arduinos with female or stacking headers you could instead reinstate the feature by plugging a thru-hole LED and resistor into the appropriate positions in the Arduino's header sockets. E.g. D13 and GND. For other Arduinos by adding LED and resistor in adjacent positions in a breadboard.

There might be a good software solution but it can be worth considering other approaches.


body:
I'm working on a project, where I need to run several high-torque servos. For that I bought come of these [PCA9685][1] boards.

I hooked everything up with my arduino and connected an external 5V - max 3A power supply for driving the servos. After some succesful tests, the board seems to be broken as no servo move anymore.
With my multimeter I looked for the broken component and found the following - in front of the transistor is, in my opinion, a ten diode with label Y4 installed - At the input (right) are still 5 V, but no longer at the output and accordingly not at the V+ pins of the servo connectors.

[![enter image description here][2]][2]

According to the internet, a ten diode has a maximum of 300mW, which for 5V results in 60mA, which of course is less then my servos require.

Do you agree with me? Could this be the problem?
If so, do you know the "correct" PCA board that is able to power high torque servos?

  [1]: https://www.amazon.de/dp/B093LB85QK/ref=cm_sw_r_wa_apanp_DWVjpjgucRLvc
  [2]: https://i.stack.imgur.com/Bxhs9.png

title: PCA9685 - Hardware problem with diode?

Answers: 0


body:
I want to use 1X4 membrane keypad to enter  3 working parameters for LED string controlled by  Arduino mini. Keypad is attached to D2-D5 pins and LED is attached to pin 12. My objective is to set the following parameters:
frequency (4 values),
duty cycle (4 values),
run time 4 (values).
I need  Arduino to read keypad 3 times so I can enter  3 parameters. "Run time" In the sketch below has not been set. I want to use “while” to force Arduino to read the keys but arduino reads it once.  Only first “while” is working in the code and I can set cycle period. Second “while” does not work because the key has been already pressed and Arduino does not read keypad second time. Are there any means to use more than 1 "while" in the code or to use one while to read keypad 3 times?

Thank you.

       #define Key1 3 // key 1 attached to pin 3
        #define Key2 2 // key 2 attached to pin 2
        #define Key3 5 // key 3 attached to pin 5
        #define Key4 4 // key 4 attached to pin 4
        float period; // cycle time
        float power; // duty cycle
        float ontime; // ontime  time LED is on
        float rest;  // rest time LED is off
        const int ledPin =  12;      // the number of the LED pin

        void setup()
        {
          pinMode(Key1, INPUT_PULLUP);
          pinMode(Key2, INPUT_PULLUP);
          pinMode(Key3, INPUT_PULLUP);
          pinMode(Key4, INPUT_PULLUP);
          pinMode(ledPin, OUTPUT);
        }
        void loop() {
          digitalWrite(ledPin, LOW);
          while (digitalRead(Key1) == HIGH && digitalRead(Key2) == HIGH && digitalRead(Key3) == HIGH && digitalRead(Key4) == HIGH) {};

          int key1a = digitalRead(Key1);
          int key2a = digitalRead(Key2);
          int key3a = digitalRead(Key3);
          int key4a = digitalRead(Key4);

          if (!key1a) {
            period = 1000;
          }
          if (!key2a) {
            period = 2000;
          }
          if (!key3a) {
            period = 3000;
          }
          if (!key4a) {
            period = 4000;
          }

          while (digitalRead(Key1) == HIGH && digitalRead(Key2) == HIGH && digitalRead(Key3) == HIGH && digitalRead(Key4) == HIGH) {};

          int key1b = digitalRead(Key1);
          int key2b = digitalRead(Key2);
          int key3b = digitalRead(Key3);
          int key4b = digitalRead(Key4  );

          if (!key1b) {
            power = 10;
          }
          if (!key2b) {
            power = 20;
          }
          if (!key3b) {
            power = 50;
          }
          if (!key4b) {
            power = 80;
          }

          ontime = period * power / 100;
          rest = period - ontime;

          digitalWrite(ledPin, HIGH);
          delay(ontime);
          digitalWrite(ledPin, LOW);
          delay(rest);
        }

title: How to make Arduino to read 1X4 keypad multiple times?

Answers: 1

body: Do something to wait until a key is released before advancing to the next section. It would be wise to structure your program to have only one function that processes key presses, and then call it for each key. (Pass key identification, pin number, into the function.)


body:
Code 1 (here `unsigned long currentmillis = millis()` is in loop area):

```c++
const int LED = 2;
unsigned long previousmillis = 0 ;
const long delaytime = 1500;
int ledstate = HIGH;

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

void loop() {
  unsigned long currentmillis = millis();
  if (currentmillis - previousmillis >= delaytime) {
    previousmillis = currentmillis;
    if (ledstate == HIGH) {
      ledstate = LOW;
    } else{
      ledstate = HIGH;
    }
    digitalWrite(LED,ledstate);
  }
}
```

Code 2 (here `unsigned long currentmillis = millis()` is above `void setup()`):

```c++
const int LED = 2;
unsigned long previousmillis = 0 ;
unsigned long currentmillis = millis();
const long delaytime = 1500;
int ledstate = HIGH;

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

void loop() {
  if (currentmillis - previousmillis >= delaytime) {
    previousmillis = currentmillis;
    if (ledstate == HIGH) {
      ledstate = LOW;
    } else {
      ledstate = HIGH;
    }
    digitalWrite(LED,ledstate);
  }
}
```

Code 1 is working and Code 2 is not working. What is the significance of the position of `unsigned long currentmillis = millis()` here and why?

title: Doubt in coding part in blink without delay

Answers: 1

body:
This is a common misunderstanding for Arduino beginners.

In the second code you do

    unsigned long currentmillis = millis();

outside of any function, meaning at global scope. These variables are declared at the very start of the program, even before the initial Arduino stuff is configured (like the configuration of Timer0 for getting `millis()` to work). The variable will have the value zero. And variables are not magically tied to a source. What you are doing there is a one-time assignment. `currentmillis` will not have future values of `millis()`. It will stay the same until you change it in your code. In your second code you do not ever change `currentmillis`, thus is will stay at the same value forever, preventing the code from working correctly.

In the first code the value is assigned at every `loop()` iteration, so you can be sure that it has a very up-to-date value of `millis()` when you use it afterwards.

This coding principle works exactly like you would bake a pizza, regularly looking at the clock to check the time while you are doing other things. With your first code you look very regularly at the clock to not miss the time to get the pizza out of the oven. With the second code you only look once at the clock, even before you have put the pizza in the oven, and then never again; so your pizza will burn.


body:
For a larger sketch, I have separated a chunk of code in a separate .cpp file

    #include "msg.h"
    #include <Arduino.h>
    #include <HTTPClient.h>
    #include <ArduinoJson.h>

    void parseResponse(String &payload, float &temp, float &wind, int &pressure, int &humid, float &feel, int &uv)
    {

        String json = payload;

        // Serial.println(json); // enable to debug

        StaticJsonDocument<128> filter;

        JsonObject filter_current = filter.createNestedObject("current");
        filter_current["temp_c"] = true;
        filter_current["wind_mph"] = true;
        filter_current["pressure_mb"] = true;
        filter_current["precip_in"] = true;
        filter_current["humidity"] = true;
        filter_current["feelslike_c"] = true;
        filter_current["uv"] = true;

        StaticJsonDocument<256> doc;

        // Deseriliaze and display error description if there is any
        DeserializationError error = deserializeJson(doc, json, DeserializationOption::Filter(filter));

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

        JsonObject current = doc["current"];
        temp = current["temp_c"];          // 80
        wind = current["wind_mph"];        // 5.6
        pressure = current["pressure_mb"]; // 1005
        humid = current["humidity"];       // 93
        feel = current["feelslike_c"];     // 6.9
        uv = current["uv"];                // 1
    }

 together with its header file as below:

    #ifndef MSG_H
    #define MSG_H

    void parseResponse(String &payload, float &temp, float &wind, int &pressure, int &humid, float &feel, int &uv);

    #endif

 I have included all the relevant libraries in the .cpp files. However, when I try to compile the code I get multiple errors such as

    In file included from src/weatherapi.cpp:1:0:
    include/weatherapi.h:4:17: error: variable or field 'getRequest' declared void
     void getRequest(String &payload);
                     ^
    include/weatherapi.h:4:17: error: 'String' was not declared in this scope
    include/weatherapi.h:4:25: error: 'payload' was not declared in this scope
     void getRequest(String &payload);
                             ^
    Archiving .pio\build\lolin32\liba47\libPubSubClient.a
    In file included from src/msg.cpp:1:0:
    include/msg.h:4:20: error: variable or field 'parseResponse' declared void
     void parseResponse(String &payload, float &temp, float &wind, int &pressure, int &humid, float &feel, int &uv);
                        ^
    include/msg.h:4:20: error: 'String' was not declared in this scope
    include/msg.h:4:28: error: 'payload' was not declared in this scope
     void parseResponse(String &payload, float &temp, float &wind, int &pressure, int &humid, float &feel, int &uv);
                                ^
    include/msg.h:4:37: error: expected primary-expression before 'float'
     void parseResponse(String &payload, float &temp, float &wind, int &pressure, int &humid, float &feel, int &uv);
                                         ^
    include/msg.h:4:50: error: expected primary-expression before 'float'
     void parseResponse(String &payload, float &temp, float &wind, int &pressure, int &humid, float &feel, int &uv);
                                                      ^
    include/msg.h:4:63: error: expected primary-expression before 'int'
     void parseResponse(String &payload, float &temp, float &wind, int &pressure, int &humid, float &feel, int &uv);
                                                                   ^
    include/msg.h:4:78: error: expected primary-expression before 'int'
     void parseResponse(String &payload, float &temp, float &wind, int &pressure, int &humid, float &feel, int &uv);
                                                                                ^
    include/msg.h:4:90: error: expected primary-expression before 'float'
     void parseResponse(String &payload, float &temp, float &wind, int &pressure, int &humid, float &feel, int &uv);
                                                                                ^
    include/msg.h:4:103: error: expected primary-expression before 'int'
     void parseResponse(String &payload, float &temp, float &wind, int &pressure, int &humid, float &feel, int &uv);

The function parseResponse doesn't return anything so I don't know why it's complaining about being declared as void. Same is true for the function getRequest. Also, is there something wrong in the function prototype as I am passing references?

Edit: Here is the weatherapi.cpp & .h file

    #include "weatherapi.h"
    #include <HTTPClient.h>
    #include <Arduino.h>

    const char url[] = "http://api.weatherapi.com/v1/current.json?key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

    void getRequest(String &payload)
    {

         HTTPClient getClient;

        getClient.begin(url);

        int httpCode = getClient.GET();

        //get response and check HTTP status code returned
        if (httpCode > 0)
        {
            payload = getClient.getString();
            Serial.print("HTTP Status: ");
            Serial.println(httpCode);
        }
        else
        {
            Serial.println("Error on HTTP request");
        }

        getClient.end();
    }

weatherapi.h file

    #ifndef WEATHERAPI_H
    #define WEATHERAPI_H

    void getRequest(String &payload);
    #endif

title: variable or field declared void Error

Answers: 1

body:
In C order is important. Everything is parsed sequentially, and header file inclusions are replaced literally with the header contents at compile time.

Things *must* be defined before they can be used, and that includes anything that is defined in the `Arudino.h` header file - that file *must* be included *before* anything that uses it - and of course that means that it must come before any headers that use things from `Arduino.h`

To be safer it's good to include `Arduino.h` in *every* file that uses anything from it so you don't run into these problems in future.


body:
I am attempting to control the position of my computer's cursor using a potentiometer hooked up to my arduino nano. The arduino is running the following code:

```c++
int potPin = 3;    // select the input pin for the potentiometer
int val = 0;       // variable to store the value coming from the sensor

void setup() {
  Serial.begin(9600);
}

void loop() {
  val = analogRead(potPin);    // read the value from the sensor
  Serial.println(val);
}
```

When I ran the following python script, it worked properly and the sensor values were printing out in my terminal.
```python
import serial
import pyautogui

ser = serial.Serial("/dev/cu.usbserial-141220", 9600, timeout=0.1)

while True:
    data = ser.readline().decode("UTF-8").strip()
    if data:
        print(data)
```

However, when I added a small time delay in the while loop, the output would either get stuck on a single value or take multiple seconds to reflect a change to the potentiometer.
```python
import serial
import pyautogui
import time

ser = serial.Serial("/dev/cu.usbserial-141220", 9600, timeout=0.1)

while True:
    data = ser.readline().decode("UTF-8").strip()
    if data:
        print(data)
    time.sleep(0.01)
```

I'd appreciate any help fixing this issue.

title: `time.sleep` in python script reading serial output causes erratic behavior

Answers: 1

body: Thanks to chrisl and timemage's comments, I figured out the issue: the Arduino was sending the data too fast and the bytes were piling up in the computer's inbound buffer. I solved this by adding a delay to the `loop()` function of the Arduino code.


body:
I want to parse JSON response from a GET Request. I do this usually by using a String variable to store the response and later parse this string using ArduinoJSON library like shown below:

    #include <Arduino.h>
    #include "OTA.h"
    #include "Credentials.h"
    #include <HTTPClient.h>
    #include <ArduinoJson.h>

    const char url[] = "http://date.jsontest.com/";

    HTTPClient getClient;

    void getRequest(String &payload)
    {
      getClient.begin(url);

      int httpCode = getClient.GET();

      if (httpCode > 0)
      {
        payload = getClient.getString();
        // Serial.print("HTTP Status: ");
        // Serial.println(httpCode);
      }
      else
      {
        Serial.println("Error on HTTP request");
      }
      getClient.end();
    }

    void parseResponse(String &payload)
    {

      StaticJsonDocument<128> doc;

      DeserializationError error = deserializeJson(doc, payload);

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

      const char *time = doc["time"]; // "03:53:25 AM"
      // unsigned long *epoch = doc["milliseconds_since_epoch"]; // 1362196405309
      const char *date = doc["date"]; // "03-02-2013"

      Serial.println(date);
    }

    void setup()
    {
      setupOTA("ESP-N2", mySSID, myPASSWORD);

      Serial.begin(115200);
    }

    void loop()
    {
      ArduinoOTA.handle();

      unsigned long newTime = millis();
      static unsigned long oldTime = 0;
      String payload;

      if (newTime - oldTime >= 5000)
      {
        oldTime = newTime;
        getRequest(payload);
        parseResponse(payload);
        Serial.println();
      }
    }

I want to avoid using String and [ArduinoJSON offician reference][1] page mentions that it's possible to deserialize directly from input Stream e.g. wifiClient, ethernetclient or serial but I couldn't find any example showing it's usage. So I am curious to learn how to use it.

From my basic understanding of a Stream, I suppose I need define a buffer or memory location that will hold the incoming bytes and using the address of this buffer need to read data bit by bit. So  do I need to do something like this:

    char buffer[]= httpClient.getStream();

and then pass this buffer as input to deserialize function? or have I gotten it completely wrong?

  [1]: https://arduinojson.org/

title: Parsing JSON response from Stream

Answers: 1

body:
`httpClient.getStream()` returns an instance of [`Stream`](https://www.arduino.cc/reference/en/language/functions/communication/stream/) that you can pass to [`deserializeJson()`](https://arduinojson.org/v6/api/json/deserializejson/), like so:

```c++
deserializeJson(doc, httpClient.getStream());
```

However, by doing so, you bypass the code in `HTTPClient` that handles [chunked transfer encoding](https://en.wikipedia.org/wiki/Chunked_transfer_encoding), so you must call `httpClient.useHTTP10(true)` before calling `GET` to make sure the server won't return a chunked response.

See [How to use ArduinoJson with HTTPClient?](https://arduinojson.org/v6/how-to/use-arduinojson-with-httpclient/)


body: I am wondering if an Arduino Uno can go in and out of deep sleep automatically with some sort of cue such as a certain time. In my case I have a small light connected to my Arduino Uno as well as a DS1302 clock module which is being powered via a phone charger but overnight the light will be off and I do not want the Arduino idling overnight. So can it be programmed to turn on/off based on the time being read from the clock which would be the same time as the light turning on? I have seen many videos of entering/exiting deep sleep but they all require a manual input such as a button. If not possible are there any other power saving options out there?

title: Can Arduino go in and out of Sleep or Deep Sleep Automatically?

Answers: 1

body:
The Arduino goes into deep sleep when you tell it to. It wakes up when it gets an interrupt. What that interrupt is is (pretty much) up to you.

If you are using an RTC most will have an alarm function that will trigger an IO pin which can be used as an input (like a button) to the Arduino. Or you can use a timer (the watchdog is common for that) to wake up periodically and check the time, then go back to sleep again.

The datasheet for the MCU on your chosen Arduino will tell you all you need to know about sleep modes and what interrupts can be used to wake from which modes.


body:
I am building esp-now gateway with mqtt but need long distance (200 meters).
I try to use LR mode but when I enable de LR mode I lost connection with WiFi.

Is licit to make use of LR and STA at the same time?

title: Is possible to use ESP-NOW in LR mode (long range) simultaneously with WIFI STA (to connect to internet over wifi)

Answers: 1

body:
you can easily use both ESPnow and WiFi - you just configure it as WiFi.mode(WIFI_MODE_APSTA);
no need to switch between AP and STA
And I have not experienced any delays for my gateway - sending MQTT message over WiFi to MQTT broker takes 6ms


body:
I want to blink a led using assembly language and arduino
I want the circuit to have a normal state of 5 hz blinking frequency
Then use two push buttons to increase or decrease the blinking frequency
The up button will increment the blinking frequency by 5 hz step until the led seems to be continuously on
While the down button will decrement the blinking frequency by 5 hz step until the normal state again
Is this achievable ?
And if any one can point me where to start as this the first time i am using assembly language but i am familiar with arduino

title: Blinking a led using assembly language at different frequencies using two push buttons

Answers: 1

body:
Here is one example of how to blink an LED in assembly coding on an Arduino UNO. You can attempt to solve your challenge. If you are stuck, please post the code and the connections and I am sure, you will get help again.

The code is here

    #define __SFR_OFFSET 0

    #include "avr/io.h"

    .global main

    main:
      sbi   DDRB, 5     ; Set PB5 as output

    blink:
      sbi   PINB, 5     ; Toggle PINB
      ldi   r25, hi8(1000)
      ldi   r24, lo8(1000)
      call  delay_ms
      jmp   blink

    delay_ms:
      ; Delay about (r25:r24)*ms. Clobbers r30, and r31.
      ; One millisecond is about 16000 cycles at 16MHz.
      ; The inner loop takes 4 cycles, so we repeat it 3000 times
      ldi   r31, hi8(4000)
      ldi   r30, lo8(4000)
    1:
      sbiw    r30, 1
      brne    1b
      sbiw    r24, 1
      brne    delay_ms
      ret

Link to the project: https://wokwi.com/arduino/projects/290348681199092237
[![enter image description here][1]][1]

  [1]: https://i.stack.imgur.com/GQdKY.png


body:
I am working with a 312 PIR sensor with an Arduino Uno Nano.

When sensing motion Port 13 goes High for Time_A (10 minutes). If I then press a push button on the Arduino board it takes Port D2 LOW, then Port A will be on for Time 2 (A quick 30 second test cycle for testing and/or troubleshooting the code and equipment and a second LED (Port 12 goes high).

So, the sensor turns on the light relay for 10 minutes and the push button makes the light and the LED stay on for only 30 seconds so I can quickly test the system.
                                                                                I have all the above working perfectly, but I have having difficulty adding another section of code that will turn all of the above off after either the 10 minutes, or the 30 second cycle. Now the lights stay on until I reset and start the cycle over for one of the times determined by the button, or the sensor.

Below is the code :

```c++
//Serial.println("TOP OF PROGRAM");
float pressLength_milliSeconds = 0; // value will be recorded in seconds. Define minimum time, in milli-seconds
int optionOne_milliSeconds = 100;
int optionTwo_milliSeconds = 2000;  // the pin your button is attached to
int buttonPin = 2; // pin your LEDs are attached to
int ledPin_Option_1 = 13;
int ledPin_Option_2 = 12;

void setup() {   // initialize pushbutton input pullup. Keep in mind, pin2 has ground voltage applied, we
  Serial.println("Top of SKETCH");
  pinMode(buttonPin, INPUT_PULLUP); // set the LEDS pins as outputs
  pinMode(ledPin_Option_1, OUTPUT);
  pinMode(ledPin_Option_2, OUTPUT); // start serial communications - for debutting   purposes or
  Serial.begin(9600);
} // close set up

void loop() { // record roughly the of tenths of seconds the button is being pressed
  while (digitalRead(buttonPin) == LOW ) {
    delay(5); // if you want more resolution, lower this number
    pressLength_milliSeconds = pressLength_milliSeconds + 100;   //display how long button is has been held
    Serial.print("ms =  ");
    Serial.println("pressLength_milliSeconds");
  } // close while     //Option 2 - Execute the second option if the button is held for the correct amount of time
  if (pressLength_milliSeconds >= optionTwo_milliSeconds) {
    digitalWrite(ledPin_Option_2, HIGH);
  }  // option 1 - Execute the first option if the  button is held long enough
  else if (pressLength_milliSeconds >= optionOne_milliSeconds) {
    digitalWrite(ledPin_Option_1, HIGH);
  } // close if options. every loop - reset  pressLength_Seconds counter
  //if (optionTwo_milliSeconds >= 10000)
  //  delay(10000);
  //digitalWrite(ledPin_Option_1, LOW);
  //digitalWrite(ledPin_Option_2, LOW);
  pressLength_milliSeconds = 0;
}
```

title: Relay switch problem: Arduino Nano with a 312 PIR sensor

Answers: 0


body:
I would like to save my Circular Buffer in the RTC memory of my ESP32 when I use deep sleep. So I have initialized it with RTC_DATA_ATTR but when I go into Deep Sleep I lose the data I've saved. Is there  a way to do this?

Here is my function:
```c++
RTC_DATA_ATTR CircularBuffer<Datas, 178> test_SensorsDatas;

void test_RTC_memory(){

    for(int i=1; i<=20; i++){
        test_SensorsDatas.push(Datas);
        ID_msg.value++;
    }

    for(int i=0; i<test_SensorsDatas.size(); i++){
        Serial.println(String(Datas.value));
    }

    esp_deep_sleep_start();
}
```

Thank you very much! Ask me questions if something isn't clear ;)

**EDIT:** I tried something much simplier:
```c++
RTC_DATA_ATTR sensorsRecord newrecord{20, ID_sensor, ID_msg, epochUnion, ValueUnion, intValue, 30};
RTC_DATA_ATTR CircularBuffer<sensorsRecord, 50> test_SensorsDatas;

void test_RTC_memory2(){
    newrecord.ID_msg.value++;
    ID_msg.value++;
    Serial.println(String(newrecord.ID_msg.value));
    test_SensorsDatas.push(newrecord);
    Serial.println("buffer size: " + String(test_SensorsDatas.size()));
    esp_deep_sleep_start();
}```

But still not working, the ID_msg is incrementing well but not the buffer size even if I push a new value at every wake up.
Any suggestion?

title: Save Circularbuffer in RTC memory of ESP32

Answers: 0


body:
I am trying to get 2 rf24 modules talking to each other. This is my first real arduino project so bear with my ignorance please.  I could get them to work with 2 arduino nano but, when trying to upload the same sketch to a seeduino xiao it won't compile. Not sure how to format this better (please intstruct) sorry<-- Here is a copy of the error message:

```
Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Seeeduino XIAO, Arduino, On"

In file included from C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:9:0:

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:33:21: error: expected unqualified-id before numeric constant

 #define STATUS      0x07

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/adc.h:684:34: note: in expansion of macro 'STATUS'

   __I  ADC_STATUS_Type           STATUS;      /**< \brief Offset: 0x19 (R/   8) Status */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:33:21: error: expected unqualified-id before numeric constant

 #define STATUS      0x07

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/dac.h:277:34: note: in expansion of macro 'STATUS'

   __I  DAC_STATUS_Type           STATUS;      /**< \brief Offset: 0x7 (R/   8) Status */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:33:21: error: expected unqualified-id before numeric constant

 #define STATUS      0x07

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/eic.h:667:34: note: in expansion of macro 'STATUS'

   __I  EIC_STATUS_Type           STATUS;      /**< \brief Offset: 0x01 (R/   8) Status */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:26:21: error: expected unqualified-id before numeric constant

 #define CONFIG      0x00

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/eic.h:675:34: note: in expansion of macro 'CONFIG'

   __IO EIC_CONFIG_Type           CONFIG[2];   /**< \brief Offset: 0x18 (R/W 32) Configuration n */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:33:21: error: expected unqualified-id before numeric constant

 #define STATUS      0x07

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/gclk.h:301:34: note: in expansion of macro 'STATUS'

   __I  GCLK_STATUS_Type          STATUS;      /**< \brief Offset: 0x1 (R/   8) Status */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:33:21: error: expected unqualified-id before numeric constant

 #define STATUS      0x07

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/nvmctrl.h:346:34: note: in expansion of macro 'STATUS'

   __IO NVMCTRL_STATUS_Type       STATUS;      /**< \brief Offset: 0x18 (R/W 16) Status */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:33:21: error: expected unqualified-id before numeric constant

 #define STATUS      0x07

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/rtc.h:1000:34: note: in expansion of macro 'STATUS'

   __IO RTC_STATUS_Type           STATUS;      /**< \brief Offset: 0x0A (R/W  8) Status */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:33:21: error: expected unqualified-id before numeric constant

 #define STATUS      0x07

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/rtc.h:1020:34: note: in expansion of macro 'STATUS'

   __IO RTC_STATUS_Type           STATUS;      /**< \brief Offset: 0x0A (R/W  8) Status */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:33:21: error: expected unqualified-id before numeric constant

 #define STATUS      0x07

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/rtc.h:1042:34: note: in expansion of macro 'STATUS'

   __IO RTC_STATUS_Type           STATUS;      /**< \brief Offset: 0x0A (R/W  8) Status */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:33:21: error: expected unqualified-id before numeric constant

 #define STATUS      0x07

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/sercom.h:1419:34: note: in expansion of macro 'STATUS'

   __IO SERCOM_I2CM_STATUS_Type   STATUS;      /**< \brief Offset: 0x1A (R/W 16) I2CM Status */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:33:21: error: expected unqualified-id before numeric constant

 #define STATUS      0x07

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/sercom.h:1441:34: note: in expansion of macro 'STATUS'

   __IO SERCOM_I2CS_STATUS_Type   STATUS;      /**< \brief Offset: 0x1A (R/W 16) I2CS Status */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:33:21: error: expected unqualified-id before numeric constant

 #define STATUS      0x07

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/sercom.h:1463:34: note: in expansion of macro 'STATUS'

   __IO SERCOM_SPI_STATUS_Type    STATUS;      /**< \brief Offset: 0x1A (R/W 16) SPI Status */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:33:21: error: expected unqualified-id before numeric constant

 #define STATUS      0x07

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/sercom.h:1488:34: note: in expansion of macro 'STATUS'

   __IO SERCOM_USART_STATUS_Type  STATUS;      /**< \brief Offset: 0x1A (R/W 16) USART Status */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:33:21: error: expected unqualified-id before numeric constant

 #define STATUS      0x07

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/tc.h:621:34: note: in expansion of macro 'STATUS'

   __I  TC_STATUS_Type            STATUS;      /**< \brief Offset: 0x0F (R/   8) Status */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:33:21: error: expected unqualified-id before numeric constant

 #define STATUS      0x07

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/tc.h:645:34: note: in expansion of macro 'STATUS'

   __I  TC_STATUS_Type            STATUS;      /**< \brief Offset: 0x0F (R/   8) Status */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:33:21: error: expected unqualified-id before numeric constant

 #define STATUS      0x07

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/tc.h:667:34: note: in expansion of macro 'STATUS'

   __I  TC_STATUS_Type            STATUS;      /**< \brief Offset: 0x0F (R/   8) Status */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:33:21: error: expected unqualified-id before numeric constant

 #define STATUS      0x07

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/tcc.h:253:14: note: in expansion of macro 'STATUS'

     uint32_t STATUS:1;         /*!< bit:      3  Status Busy                        */

              ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:33:21: error: expected unqualified-id before numeric constant

 #define STATUS      0x07

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/tcc.h:1799:34: note: in expansion of macro 'STATUS'

   __IO TCC_STATUS_Type           STATUS;      /**< \brief Offset: 0x30 (R/W 32) Status */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:33:21: error: expected unqualified-id before numeric constant

 #define STATUS      0x07

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/usb.h:1728:34: note: in expansion of macro 'STATUS'

   __I  USB_DEVICE_STATUS_Type    STATUS;      /**< \brief Offset: 0x00C (R/   8) DEVICE Status */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:33:21: error: expected unqualified-id before numeric constant

 #define STATUS      0x07

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/usb.h:1759:34: note: in expansion of macro 'STATUS'

   __IO USB_HOST_STATUS_Type      STATUS;      /**< \brief Offset: 0x00C (R/W  8) HOST Status */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:26:21: error: expected unqualified-id before numeric constant

 #define CONFIG      0x00

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/wdt.h:290:34: note: in expansion of macro 'CONFIG'

   __IO WDT_CONFIG_Type           CONFIG;      /**< \brief Offset: 0x1 (R/W  8) Configuration */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\nRF24L01.h:33:21: error: expected unqualified-id before numeric constant

 #define STATUS      0x07

                     ^

C:\Users\User\Documents\ArduinoData\packages\Seeeduino\tools\CMSIS-Atmel\1.2.1/CMSIS-Atmel/CMSIS/Device/ATMEL/samd21/include/component/wdt.h:296:34: note: in expansion of macro 'STATUS'

   __I  WDT_STATUS_Type           STATUS;      /**< \brief Offset: 0x7 (R/   8) Status */

                                  ^~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'void RF24::print_status(uint8_t)':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:188:22: error: '_BV' was not declared in this scope

            (status & _BV(RX_DR))?1:0,

                      ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:188:22: note: suggested alternative: '_B'

            (status & _BV(RX_DR))?1:0,

                      ^~~

                      _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:186:3: error: 'printf_P' was not declared in this scope

   printf_P(PSTR("STATUS\t\t = 0xx RX_DR=%x TX_DS=%x MAX_RT=%x RX_P_NO=%x TX_FULL=%x\r\n"),

   ^~~~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:186:3: note: suggested alternative: 'sprintf_P'

   printf_P(PSTR("STATUS\t\t = 0xx RX_DR=%x TX_DS=%x MAX_RT=%x RX_P_NO=%x TX_FULL=%x\r\n"),

   ^~~~~~~~

   sprintf_P

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'void RF24::print_observe_tx(uint8_t)':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:200:3: error: 'printf_P' was not declared in this scope

   printf_P(PSTR("OBSERVE_TX=x: POLS_CNT=%x ARC_CNT=%x\r\n"),

   ^~~~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:200:3: note: suggested alternative: 'sprintf_P'

   printf_P(PSTR("OBSERVE_TX=x: POLS_CNT=%x ARC_CNT=%x\r\n"),

   ^~~~~~~~

   sprintf_P

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'void RF24::print_byte_register(const char*, uint8_t, uint8_t)':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:212:3: error: 'printf_P' was not declared in this scope

   printf_P(PSTR(PRIPSTR"\t%c ="),name,extra_tab);

   ^~~~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:212:3: note: suggested alternative: 'sprintf_P'

   printf_P(PSTR(PRIPSTR"\t%c ="),name,extra_tab);

   ^~~~~~~~

   sprintf_P

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'void RF24::print_address_register(const char*, uint8_t, uint8_t)':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:223:3: error: 'printf_P' was not declared in this scope

   printf_P(PSTR(PRIPSTR"\t%c ="),name,extra_tab);

   ^~~~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:223:3: note: suggested alternative: 'sprintf_P'

   printf_P(PSTR(PRIPSTR"\t%c ="),name,extra_tab);

   ^~~~~~~~

   sprintf_P

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'void RF24::printDetails()':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:325:3: error: 'printf_P' was not declared in this scope

   printf_P(PSTR("Data Rate\t = %S\r\n"),pgm_read_word(&rf24_datarate_e_str_P[getDataRate()]));

   ^~~~~~~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:325:3: note: suggested alternative: 'sprintf_P'

   printf_P(PSTR("Data Rate\t = %S\r\n"),pgm_read_word(&rf24_datarate_e_str_P[getDataRate()]));

   ^~~~~~~~

   sprintf_P

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'void RF24::begin()':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:382:25: error: '_BV' was not declared in this scope

   write_register(STATUS,_BV(RX_DR) | _BV(TX_DS) | _BV(MAX_RT) );

                         ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:382:25: note: suggested alternative: '_B'

   write_register(STATUS,_BV(RX_DR) | _BV(TX_DS) | _BV(MAX_RT) );

                         ^~~

                         _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'void RF24::startListening()':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:398:50: error: '_BV' was not declared in this scope

   write_register(CONFIG, read_register(CONFIG) | _BV(PWR_UP) | _BV(PRIM_RX));

                                                  ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:398:50: note: suggested alternative: '_B'

   write_register(CONFIG, read_register(CONFIG) | _BV(PWR_UP) | _BV(PRIM_RX));

                                                  ^~~

                                                  _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'void RF24::powerDown()':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:429:50: error: '_BV' was not declared in this scope

   write_register(CONFIG,read_register(CONFIG) & ~_BV(PWR_UP));

                                                  ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:429:50: note: suggested alternative: '_B'

   write_register(CONFIG,read_register(CONFIG) & ~_BV(PWR_UP));

                                                  ^~~

                                                  _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'void RF24::powerUp()':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:436:49: error: '_BV' was not declared in this scope

   write_register(CONFIG,read_register(CONFIG) | _BV(PWR_UP));

                                                 ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:436:49: note: suggested alternative: '_B'

   write_register(CONFIG,read_register(CONFIG) | _BV(PWR_UP));

                                                 ^~~

                                                 _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'bool RF24::write(const void*, uint8_t)':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:468:25: error: '_BV' was not declared in this scope

   while( ! ( status & ( _BV(TX_DS) | _BV(MAX_RT) ) ) && ( millis() - sent_at < timeout ) );

                         ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:468:25: note: suggested alternative: '_B'

   while( ! ( status & ( _BV(TX_DS) | _BV(MAX_RT) ) ) && ( millis() - sent_at < timeout ) );

                         ^~~

                         _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'void RF24::startWrite(const void*, uint8_t)':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:510:52: error: '_BV' was not declared in this scope

   write_register(CONFIG, ( read_register(CONFIG) | _BV(PWR_UP) ) & ~_BV(PRIM_RX) );

                                                    ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:510:52: note: suggested alternative: '_B'

   write_register(CONFIG, ( read_register(CONFIG) | _BV(PWR_UP) ) & ~_BV(PRIM_RX) );

                                                    ^~~

                                                    _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'bool RF24::available(uint8_t*)':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:552:28: error: '_BV' was not declared in this scope

   bool result = ( status & _BV(RX_DR) );

                            ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:552:28: note: suggested alternative: '_B'

   bool result = ( status & _BV(RX_DR) );

                            ^~~

                            _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'bool RF24::read(void*, uint8_t)':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:585:39: error: '_BV' was not declared in this scope

   return read_register(FIFO_STATUS) & _BV(RX_EMPTY);

                                       ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:585:39: note: suggested alternative: '_B'

   return read_register(FIFO_STATUS) & _BV(RX_EMPTY);

                                       ^~~

                                       _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'void RF24::whatHappened(bool&, bool&, bool&)':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:594:42: error: '_BV' was not declared in this scope

   uint8_t status = write_register(STATUS,_BV(RX_DR) | _BV(TX_DS) | _BV(MAX_RT) );

                                          ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:594:42: note: suggested alternative: '_B'

   uint8_t status = write_register(STATUS,_BV(RX_DR) | _BV(TX_DS) | _BV(MAX_RT) );

                                          ^~~

                                          _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'void RF24::openReadingPipe(uint8_t, uint64_t)':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:652:57: error: '_BV' was not declared in this scope

     write_register(EN_RXADDR,read_register(EN_RXADDR) | _BV(pgm_read_byte(&child_pipe_enable[child])));

                                                         ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:652:57: note: suggested alternative: '_B'

     write_register(EN_RXADDR,read_register(EN_RXADDR) | _BV(pgm_read_byte(&child_pipe_enable[child])));

                                                         ^~~

                                                         _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'void RF24::enableDynamicPayloads()':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:671:51: error: '_BV' was not declared in this scope

   write_register(FEATURE,read_register(FEATURE) | _BV(EN_DPL) );

                                                   ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:671:51: note: suggested alternative: '_B'

   write_register(FEATURE,read_register(FEATURE) | _BV(EN_DPL) );

                                                   ^~~

                                                   _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'void RF24::enableAckPayload()':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:700:51: error: '_BV' was not declared in this scope

   write_register(FEATURE,read_register(FEATURE) | _BV(EN_ACK_PAY) | _BV(EN_DPL) );

                                                   ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:700:51: note: suggested alternative: '_B'

   write_register(FEATURE,read_register(FEATURE) | _BV(EN_ACK_PAY) | _BV(EN_DPL) );

                                                   ^~~

                                                   _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'void RF24::setAutoAck(uint8_t, bool)':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:770:16: error: '_BV' was not declared in this scope

       en_aa |= _BV(pipe) ;

                ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:770:16: note: suggested alternative: '_B'

       en_aa |= _BV(pipe) ;

                ^~~

                _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:774:17: error: '_BV' was not declared in this scope

       en_aa &= ~_BV(pipe) ;

                 ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:774:17: note: suggested alternative: '_B'

       en_aa &= ~_BV(pipe) ;

                 ^~~

                 _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'void RF24::setPALevel(rf24_pa_dbm_e)':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:799:14: error: '_BV' was not declared in this scope

   setup &= ~(_BV(RF_PWR_LOW) | _BV(RF_PWR_HIGH)) ;

              ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:799:14: note: suggested alternative: '_B'

   setup &= ~(_BV(RF_PWR_LOW) | _BV(RF_PWR_HIGH)) ;

              ^~~

              _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'rf24_pa_dbm_e RF24::getPALevel()':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:832:46: error: '_BV' was not declared in this scope

   uint8_t power = read_register(RF_SETUP) & (_BV(RF_PWR_LOW) | _BV(RF_PWR_HIGH)) ;

                                              ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:832:46: note: suggested alternative: '_B'

   uint8_t power = read_register(RF_SETUP) & (_BV(RF_PWR_LOW) | _BV(RF_PWR_HIGH)) ;

                                              ^~~

                                              _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'bool RF24::setDataRate(rf24_datarate_e)':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:864:14: error: '_BV' was not declared in this scope

   setup &= ~(_BV(RF_DR_LOW) | _BV(RF_DR_HIGH)) ;

              ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:864:14: note: suggested alternative: '_B'

   setup &= ~(_BV(RF_DR_LOW) | _BV(RF_DR_HIGH)) ;

              ^~~

              _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'rf24_datarate_e RF24::getDataRate()':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:907:43: error: '_BV' was not declared in this scope

   uint8_t dr = read_register(RF_SETUP) & (_BV(RF_DR_LOW) | _BV(RF_DR_HIGH));

                                           ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:907:43: note: suggested alternative: '_B'

   uint8_t dr = read_register(RF_SETUP) & (_BV(RF_DR_LOW) | _BV(RF_DR_HIGH));

                                           ^~~

                                           _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'void RF24::setCRCLength(rf24_crclength_e)':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:933:47: error: '_BV' was not declared in this scope

   uint8_t config = read_register(CONFIG) & ~( _BV(CRCO) | _BV(EN_CRC)) ;

                                               ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:933:47: note: suggested alternative: '_B'

   uint8_t config = read_register(CONFIG) & ~( _BV(CRCO) | _BV(EN_CRC)) ;

                                               ^~~

                                               _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'rf24_crclength_e RF24::getCRCLength()':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:957:46: error: '_BV' was not declared in this scope

   uint8_t config = read_register(CONFIG) & ( _BV(CRCO) | _BV(EN_CRC)) ;

                                              ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:957:46: note: suggested alternative: '_B'

   uint8_t config = read_register(CONFIG) & ( _BV(CRCO) | _BV(EN_CRC)) ;

                                              ^~~

                                              _B

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp: In member function 'void RF24::disableCRC()':

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:974:46: error: '_BV' was not declared in this scope

   uint8_t disable = read_register(CONFIG) & ~_BV(EN_CRC) ;

                                              ^~~

C:\Users\User\Documents\Arduino\libraries\RF24-master\RF24.cpp:974:46: note: suggested alternative: '_B'

   uint8_t disable = read_register(CONFIG) & ~_BV(EN_CRC) ;

                                              ^~~

                                              _B

Multiple libraries were found for "nRF24L01.h"

 Used: C:\Users\User\Documents\Arduino\libraries\RF24-master

 Not used: C:\Users\User\Documents\Arduino\libraries\NRFLite

exit status 1

Error compiling for board Seeeduino XIAO.

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

I suspect I have multiple problems as it took a lot of playing around with the libraries to get the RF24-Master library to work. I may have messed that up somehow (but it was working with the Nano...so...??).

Here is a copy of the sketch being loaded:

[code]

#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"

int DataMgs[1];
RF24 radio(9,10);
const uint64_t pipe = 0xE14BC8F482LL;
int Relay1 = 5;

void setup()
{
  pinMode(Relay1, OUTPUT);
  Serial.begin(57600);
  radio.begin();
  radio.openReadingPipe(1,pipe);
  radio.startListening();
}

void loop()
{
  if (radio.available())
  {
    bool done = false;
    while (!done)
    {
      done = radio.read(DataMgs, 1);
      Serial.print("NRF24L01 Receiver: ");
      Serial.println(DataMgs[0]);

      if (DataMgs[0] == 1)
      {
        delay(10);
        digitalWrite(Relay1, HIGH);
      }

      if (DataMgs[0] == 2)
      {
        delay(10);digitalWrite(Relay1, LOW);
      }
      delay(100);
    }
  }
  else
  {
  Serial.println("Waiting for signal...");
  }
}
[/code]

Any guidance would be greatly appreciated. Thanks

P.S. If anyone can guide me through this issue I can send some crypto your way- thanks again.

title: Error compiling arduino sketch to seeduino xiao for RF24 Module

Answers: 0


body:
Ussing popular library https://github.com/plerup/espsoftwareserial/ can I have multiple softwareSerial ports (for example 6 ports).

I’m the readme say  “ several instances can be active at the same time” but don’t answer a quantity just say several.
Also don’t say if the instances will operate normal or will have some issue.
Ref: https://github.com/plerup/espsoftwareserial/#readme

Will be great to read an answer from someone with experience with the this specific library and arduino framework.

title: Using arduino framework how many instances of SoftwareSerial can use simultaneously with esp32

Answers: 1

body:
This is not a question that has an answer. There are far too many variables to say "You can have X ports at once".

How many you can have depends on such things as:

* **The baud rates you are using:** faster baud rates will mean more processing and thus less processing for other ports to run.
* **How often data is received:** A port that's not receiving anything isn't using any processing. You could have lots and lots of ports, but if only one is receiving anything it's not much different to only having one port.
* **What else your program is doing:** You have finite resources. The more you use in your program the less are available for other things. You're running an RTOS, and resources and processing are time-sliced between tasks.

You can maximise your port availability by being crafty and careful with executing certain things on each core - for example if you have two heavily used ports it could be good to have one bound to each of your two cores (assuming a dual core ESP32) so they don't interfere with each other as much.

So a quantity cannot be given. Nor can a prediction about how reliable they would be. From the way it's purported to operate, though, the quantity is likely to be "quite a few" and there should be no problems, as long as you don't have too many.


body:
While learning more about Servos, the main thing i have learned is that, Servos (SG90) need PWM signal with the frequency of 50Hz. And the duty cycle of the frequency is used to rotate the angle of the motor.

I know generating PWM with variable duty cycle is possible in PWM pins using Timers but i don't understand how the arduino Servo.h library makes digital pins act like PWM too , whenever i connect the servo to any one of the digital pins of the arduino and code accordingly.

So how does Arduino 'Servo.h' Library manage to make a digital pin act like a PWM and what should the native AVR C code for this action look like?

 I am trying to avoid third party libraries as much as possible and trying to learn Embedded systems thoroughly.

Please do not suggest big banging PWM method.

Thanks...

title: How does Arduino Servo.h library manage to output PWM when a Servo motor is connected to a non-PWM pin?

Answers: 1

body:
I believe the [servo library][1] uses one (or more depending on board architecture) inbuilt 16 bit timers (timer1 on the UNO) to produce PWM  directly on a *digital* pin using a low level equivalent of a digital write. The direct use of the timer prevents the use of that timer for other purposes like analogWrite().

In comparison a frequently used, more user-friendly method of producing PWM on Arduino is to use [analogWrite()][2] on designated *PWM* pins only.

The servo library source code is on github [here][3].

You may have already answered your own question, as you did mention the [bit-banging][4] PWM method. That's what it looks like to me, but I'm not an expert on lower level programming.

See also: https://arduino.stackexchange.com/questions/1348/how-can-the-arduino-uno-support-up-to-12-servos-if-it-only-has-6-digital-pwm-pin

  [1]: https://www.arduino.cc/reference/en/libraries/servo/
  [2]: https://www.arduino.cc/reference/en/language/functions/analog-io/analogwrite/
  [3]: https://github.com/arduino-libraries/Servo
  [4]: https://en.wikipedia.org/wiki/Bit_banging


body:
the project requires a automated parking lot, I have been able to connect and function the sensor and button for exit and enter, and the led(red lights when parking is full, green when there is spots). the maximum cars are 5. and the lcd prints the spots available and the spaces taken. the keypad is also connected. now what I need is to make a code that times each car that enters in the order that they enter in and for each car that leaves it has to enter its order of entering to calculate the price it has to pay with this equation: Parking Fee (fils) = time(sec) x 0.29fils
here is the code i have at the moment:

    #include <Servo.h>
    #include <LiquidCrystal.h>
    #include <Keypad.h>
    LiquidCrystal lcd(12,11,5,4,3,2);
    Servo myservo;

    #define Servo 7
    #define exit SDA
    #define power 6 // extra
    #define ground 10 // extra
    #define capacity 5
    #define R_led SCL
    #define G_led 13
    int val;
    int n = 5;
    int s = 0;

    const byte ROWS = 4; //four rows
    const byte COLS = 3; //three columns
    char keys[ROWS][COLS] = {
     {'1','2','3'},
     {'4','5','6'},
     {'7','8','9'},
     {'*','0','#'}
    };
    byte rowPins[ROWS] = {A4, A3, A2, A1}; //Arduino Pins
    byte colPins[COLS] = {8, 9, 10}; //Arduino Pins

    void setup(){
      for(int i=0;i<4;i++){
        pinMode(rowPins[i],INPUT);  //set row pins as inputs
        pinMode(colPins[i],OUTPUT); //set column pins as outputs
      }
      Serial.begin(9600);
      myservo.attach(Servo);
      lcd.begin(16,2);
      pinMode(power,OUTPUT);
      pinMode(ground,OUTPUT);
      pinMode(exit,INPUT);
      pinMode(G_led,OUTPUT);
      pinMode(R_led,OUTPUT);
      digitalWrite(ground,LOW);
      digitalWrite(power,HIGH);
      myservo.write(0);
      digitalWrite(R_led,LOW);
      digitalWrite(G_led,LOW);
    }

    void loop(){
      if (n>=1){
        lcd.clear();
        lcd.setCursor(1,0);
        lcd.print("Spots left: ");
        lcd.print(n);
        lcd.setCursor(1,1);
        lcd.print("Cars inside: ");
        lcd.print(s);
        digitalWrite(G_led,HIGH);
        digitalWrite(R_led,LOW);
        delay(30);

      }
      else {
        lcd.clear();
        lcd.setCursor(1,0);
        lcd.print("The parking is");
        lcd.setCursor(0,1);
        lcd.print("full!");
        digitalWrite(G_led,LOW);
        digitalWrite(R_led,HIGH);
        delay(30);
      }
    val = analogRead(A0);
    // Serial.println(val);
    if (val>950)
    {
      if (n!=0){
        n--;
        s++;
        myservo.write(90);
        delay(3000);
        myservo.write(0);
      }
    }
    if (digitalRead(exit)==1)
    {
      if (n!=capacity){
        n++;
        s--;
          myservo.write(90);
        delay(3000);
        myservo.write(0);
      }
    }
    delay(20);
      int keyValue=0;
        digitalWrite(colPins[0],HIGH); //Set column1 as high
        digitalWrite(colPins[1],LOW);
        digitalWrite(colPins[2],LOW);
        digitalWrite(colPins[3],LOW);
        for(int i=0;i<4;i++){             //iterate over rows to find if key is pressed
          keyValue = digitalRead(rowPins[i]);
          if(keyValue== 1){
                //display either 1,4,7 or *
            Serial.println(keys[i][0]); //display key pressed
           delay(500);
          }
        }

        digitalWrite(colPins[0],LOW);
        digitalWrite(colPins[1],HIGH); //Set column2 as high
        digitalWrite(colPins[2],LOW);
        digitalWrite(colPins[3],LOW);
        for(int i=0;i<4;i++){              //iterate over rows to find if key is pressed
          keyValue = digitalRead(rowPins[i]);
          if(keyValue== 1){
            //display either 2,5,8,0
             Serial.println(keys[i][1]); //display key pressed
           delay(500);
          }
        }
        digitalWrite(colPins[0],LOW);
        digitalWrite(colPins[1],LOW);
        digitalWrite(colPins[2],HIGH);//Set column3 as high
        digitalWrite(colPins[3],LOW);
        for(int i=0;i<4;i++){
          keyValue = digitalRead(rowPins[i]);
          if(keyValue== 1){               //iterate over rows to find if key is pressed
            //display either 3,6,9,#
             Serial.println(keys[i][2]); //display key pressed
           delay(500);
          }
        }
        digitalWrite(colPins[0],LOW);
        digitalWrite(colPins[1],LOW);
        digitalWrite(colPins[2],LOW);
        digitalWrite(colPins[3],HIGH);//Set column4 as high
        for(int i=0;i<4;i++){
          keyValue = digitalRead(rowPins[i]);
          if(keyValue== 1){               //iterate over rows to find if key is pressed
            //display either A,B,C,D
             Serial.println(keys[i][3]); //display key pressed
           delay(500);
          }
        }
    }

title: i am tying to make a automated parking lot with a gate, sensor, button, keypad, how can i time how long has each car spent inside?

Answers: 1

body:
For measuring the time for each parking lot:

Declare an array of `unsigned long` with one element per parking lot (so 5 in this case) and initialize it with zeros:

    #define N_PARKING_LOTS 5
    unsigned long timestamps[N_PARKING_LOTS] = {0};

Then go to the place in your code where a new car arrives in its parking lot. You need the number of the used parking lot. Set the corresponding element in the array to `millis()` (for example here element 3, so the 4th parking lot):

    timestamps[3] = millis();

When the corresponding car leaves you can get the time by calculating the difference and by that calculate the price:

    unsigned long park_duration = millis() - timestamp[3];
    float price = (park_duration/1000)*0.29;

How you know the parking lot depends on your actual process. It is difficult to understand what you want to say in your question. You could guide the arriving car to a parking spot chosen by you.

Btw: The code will get much easier for you when you actually use the `Keypad` library, instead of just including it. Then your current code will get way shorter.


body:
I'm having an issue where an arduino Mega has been used to communicate with an RS485 bus, using an MKR shield [1] as a breakout board. When I build it with a Mega, the system works fine. I've torn down and rebuilt multiple times, and it works every time, no troubles.

However when I build it with a nano it does not work - rx is faulty. Devices on the bus can hear the nano, and a response pulse train is sent back correctly, so outgoing communication is fine.  However at the RX pin on the nano, the serial signal is present when viewed on an oscilloscope, but ranges between +5V and 4.5V, and the RX LED never flashes.

The layout is a simple wiring, there are no (relevant) external components (there is an LCD, but this works fine), just pin-pin connections.

Why is it the mega seems to work, but the nano not? I'm currently guessing that the /RE pin on the MKR RS485 device (MAX3157 [2]) is not being powered properly, and I am seeing the un-amplified serial output? I can't understand why this would be, though, as both the mega and the nano have the same rated max current per-pin.

I've checked the /RE line alone when disconnected, and it is correctly at 5V when not driven, and drives to 0V when the pin is pulled low.

Is there an alternative fix I could use to bring the +5V-4.5V to +5V-0V ? Do I need to have the

[1] MKR Shield schematic : https://www.jameco.com/Jameco/Products/ProdDS/2294031Schematic.pdf

[2] Max datasheet : https://datasheets.maximintegrated.com/en/ds/MAX3157.pdf

title: Insufficient RX signal delta when using MKR RS485 + Nano, but not Mega

Answers: 1

body:
OK, answering myself here. It looks like the output of the shield is unable to drive hard enough against the internal pullups of the nano, for some reason. (Yes, its definitely in input mode, you check check the port values, and it is correct)

Leaving the RX output from the shield to float, it works fine, but if connected to an external pullup resistor, then it does not - and I get the same behaviour as when the RX is tied to the nano.

I've been unable to disable the nano's internal pullups in software for some reason. It looks like I will need to add a buffer to increase the drive current. This is a little irritating as it means another breakout board!


body:
So I own an AS608 fingerprint scanner, and I've been looking everywhere for information on how to get the fingerprint data (raw, processed, or binary) from the scanner itself to use with a database but to no luck.

I've seen some answers on here, but they don't point to anything specific, so I am bubbling asking again. I have intentions of using this with Atmega MCUs, I just need to get any form of data that I can then tie to a user for a system. Thank you!

This is the [datasheet][2], but it doesn't really say if it can do that or not. The datasheet doesn't really talk about its applications.

So this is the fingerprint sensor I have, here is [a link][3] to it on a store. It is based on AS608 as RowanP pointed out in the comments.

[![enter image description here][4]][4]
[![enter image description here][1]][1]

  [1]: https://i.stack.imgur.com/PhmFN.jpg
  [2]: https://server4.eca.ir/eshop/000/AS608/Synochip-AS608.pdf
  [3]: https://makersportal.com/shop/optical-fingerprint-sensor-as608
  [4]: https://i.stack.imgur.com/Gdhf0.png

title: Can I get the actual fingerprint data from AS608?

Answers: 0


body:
I tried various method from YouTube and also debugged it. It shows that ps3 controller address was set to local Bluetooth address, after that when I try to connect, it shows that it is receiving request from controller but however the request isn't getting completed

    PS3 Bluetooth Library Started
    PS3 Bluetooth Library Started
    Bluetooth Dongle Initialized
    HCI Reset complete
    Write class of device
    Local Bluetooth Address: 00:1A:7D:DA:71:10
    Wait For Incoming Connection Request
    Incoming Connection Request
    Remote Name: Pro Controller
    Connection Failed: 08
    Connection Failed: 08
    Connection Failed: 08
    Connection Failed: 08
    Connection Failed: 08
    Wait For Incoming Connection Request
    HCI Disconnected from Device
    Wait For Incoming Connection Request
    Connection Failed: 13
    Connection Failed: 13

when I try to reset ps3 controller address, it shows that address was reset.

    PS3 Bluetooth Library Started
    Bluetooth Dongle Initialized
    HCI Reset complete
    Write class of device
    Local Bluetooth Address: 00:1A:7D:DA:71:10
    Wait For Incoming Connection Request
    PS3 Bluetooth Library Started
    PS3 Bluetooth Library Started
    Bluetooth Dongle Initialized
    HCI Reset complete
    Write class of device
    Local Bluetooth Address: 00:1A:7D:DA:71:10
    Wait For Incoming Connection Request
    setAddr: 0E
    BTD Init Failed, error code: 0E

    Dualshock 3 Controller Connected
    Bluetooth Address was set to: 00:1A:7D:DA:71:10
    Bluetooth Dongle Initialized
    HCI Reset complete
    Write class of device
    Local Bluetooth Address: 00:1A:7D:DA:71:10
    Wait For Incoming Connection Request
    PS3 Bluetooth Library Started
    PS3 Bluetooth Library Started
    Bluetooth Dongle Initialized
    HCI Reset complete
    Write class of device
    Local Bluetooth Address: 00:1A:7D:DA:71:10
    Wait For Incoming Connection Request
    Incoming Connection Request
    Remote Name: Pro Controller
    Connection Failed: 08
    Connection Failed: 08

title: I am trying to connect ps3 controller to Arduino mega using usb host shield, but it isn't getting?

Answers: 0


body:
I started using an Arduino Uno days ago. I'm an experienced C++ dev and I'm kind of confused.

Is the Arduino compiler different than a C++ one? What C++ version does Aruidno Uno use? Why it doesn't it support STL? Is it possible to use STL?

Also, can I configure their cpp file and use my own main function? The loop / setup thing really does annoy me. Thanks!

title: Can I use STL on an Arduino Uno?

Answers: 1

body:
Yes, there are STL implementations for the Arduino Uno (check the library manager). Note that some of them are unsupported and/or outdated quite a bit. The downside of using STL on the Arduino is also that these classes may use to much memory. Because of it's very limited memory (only 2kb), dynamic memory allocation is quite risky, as memory fragmentation will quickly cause the program to crash.

The Arduino build system uses a pre-build step around the ino files that remove a lot of pain locating header files and setting up build paths from the user. This is a bit confusing at first for an experienced C++ programmer, but it simplifies things a lot, particularly when it comes to using different libraries. This build step automatically locates the include paths for all .h files referenced in the .ino. The system requires that you declare the `loop()` and `setup()` methods, but what you do with them is up to you. You can leave either of them empty, or never return from the loop function, calling into whatever main function you want to use.

As a side note: There are other C++ compiler features that are disabled or unsupported on the Uno because they would make the code to big. These include dynamic type casting using `dynamic_cast<>` and exception handling.


body:
~~~
Arduino: 1.8.7 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"

Executable segment sizes:

ICACHE : 32768           - flash instruction cache

IROM   : 425200          - code in flash         (default or ICACHE_FLASH_ATTR)

IRAM   : 29829   / 32768 - code in IRAM          (IRAM_ATTR, ISRs...)

DATA   : 1664  )         - initialized variables (global, static) in RAM/HEAP

RODATA : 7200  ) / 81920 - constants             (global, static) in RAM/HEAP

BSS    : 28472 )         - zeroed variables      (global, static) in RAM/HEAP

Sketch uses 463893 bytes (44%) of program storage space. Maximum is 1044464 bytes.
Global variables use 37336 bytes (45%) of dynamic memory, leaving 44584 bytes for local variables. Maximum is 81920 bytes.
esptool.py v3.0
Serial port COM6
Connecting....
Chip is ESP8266EX
Features: WiFi
WARNING: Detected crystal freq 255.46MHz is quite different to normalized freq 40MHz. Unsupported crystal in use?
Crystal is 40MHz
MAC: 44:17:93:11:8c:e4
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 468048 bytes to 339496...
Writing at 0x00000000... (4 %)
Writing at 0x00004000... (9 %)
Writing at 0x00008000... (14 %)
Writing at 0x0000c000... (19 %)
Writing at 0x00010000... (23 %)
Writing at 0x00014000... (28 %)
Writing at 0x00018000... (33 %)
Writing at 0x0001c000... (38 %)
Writing at 0x00020000... (42 %)
Writing at 0x00024000... (47 %)
Writing at 0x00028000... (52 %)
Writing at 0x0002c000... (57 %)
Writing at 0x00030000... (61 %)
Writing at 0x00034000... (66 %)
Writing at 0x00038000... (71 %)
Writing at 0x0003c000... (76 %)
Writing at 0x00040000... (80 %)
Writing at 0x00044000... (85 %)
Writing at 0x00048000... (90 %)
Writing at 0x0004c000... (95 %)
Writing at 0x00050000... (100 %)
An error occurred while uploading the sketch

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

title: When i upload the code to nodeMCU this error comes I have checked libraries ,ports made enviroment for nodemcu but error always come to screen

Answers: 0


body:
I wrote a simple C++ program (just main.cpp and corresponding platform.io files & libraries) to get BME280 sensor readings. It worked fine until I decided to use good programming practices, using header files and separating the read function from main.cpp, I get a heap error, stated below:
~~~
CORRUPT HEAP: Bad head at 0x3ffb8444. Expected 0xabba1234 got 0x3ffb84c4
abort() was called at PC 0x40083b99 on core 1

ELF file SHA256: 0000000000000000

Backtrace:
0x400857f0:0x3ffb1aa0
0x40085a65:0x3ffb1ac0
0x40083b99:0x3ffb1ae0
0x40083cc5:0x3ffb1b10
0x400d90a3:0x3ffb1b30
0x400d55bd:0x3ffb1df0
0x400d5558:0x3ffb1e40
0x4008a0f1:0x3ffb1e70
0x40081dee:0x3ffb1e90
0x40083a91:0x3ffb1eb0
0x4000bec7:0x3ffb1ed0
0x400e89b5:0x3ffb1ef0
0x400d13ab:0x3ffb1f10
0x400d0f75:0x3ffb1f30
0x400d3ba9:0x3ffb1fb0
0x40086a75:0x3ffb1fd0

Rebooting...
~~~
Any ideas on that?

By the way, I also used pointers for both the function and the variable passed to it, to no avail.

I also tried a series of combinations with the libraries I am using - Adafruit BME280 and Adafruit Unified Sensor.

Going back to having all the code in one file works...

Thanks

My code:

<!-- language: lang-cxx -->

    //main.cpp
    #include <sensor_readings.h>
    #include <settings.h>

    void refresh_readings();  // Declare in the header so that the compiler knows about it before it is called in loop()

    Adafruit_BME280 bme; // I2C

    void setup() {
      pinMode(LED_BUILTIN,OUTPUT);
      Serial.begin(9600);
      bool status;

      // (you can also pass in a Wire library object like &Wire2)
      status = bme.begin(0x76);
      if (!status) {
        Serial.println("Could not find a valid BME280 sensor, check wiring!");
        while (1);
      }
    }

    void loop() {
      void (*fcnPtr)(Adafruit_BME280){ &refresh_readings };
      (*fcnPtr)(bme);
      //refresh_readings(bme);
      delay(4000);
    }

    ;platformio.ini
    [env:esp32dev]
    platform = espressif32
    board = esp32dev
    framework = arduino
    lib_deps =
     Adafruit_Sensor
     adafruit/Adafruit Unified Sensor@1.1.4
     adafruit/Adafruit BME280 Library@^2.2.2
    upload_port = /dev/cu.SLAB_USBtoUART
    monitor_port = /dev/cu.SLAB_USBtoUART
    monitor_speed = 9600

    //sensor_readings.cpp
    #include <sensor_readings.h>
    #include <settings.h>

    void refresh_readings(Adafruit_BME280 bme) {
      float f_temperature;
      float f_humidity;
      float f_pressure;
      float f_altitude;

      digitalWrite(LED_BUILTIN, HIGH);

      f_temperature = bme.readTemperature();
      f_humidity = bme.readHumidity();
      f_pressure = bme.readPressure() / 100.0F;
      f_altitude = bme.readAltitude(SEALEVELPRESSURE_HPA);

      // Temperature

      Serial.print(f_temperature);
      Serial.println(" °C");

      // Humidity
      Serial.print(f_humidity);
      Serial.println(" %");

      // Pressure
      Serial.print(f_pressure);
      Serial.println(" hPa");

      // Appx altitude
      Serial.print(f_altitude);
      Serial.println(" m");

      digitalWrite(LED_BUILTIN, LOW);
      Serial.println("------------");
    }

    //sensor_readings.h
    #ifndef SENSOR_READINGS_H

        #define SENSOR_READINGS_H

        #include <Arduino.h>
        #include <Adafruit_Sensor.h>
        #include <Adafruit_BME280.h>

        #define SEALEVELPRESSURE_HPA (1013.25)

        void refresh_readings(Adafruit_BME280 bme);

    #endif

    //settings.h
    #ifndef SETTINGS_H
        #define SETTINGS_H
        #define LED_BUILTIN 2   // This is valid for my devkit
    #endif

title: ESP32 heap problem

Answers: 1

body:
There's a couple problems with your code.

    void refresh_readings();  // Declare in the header so that
                              // the compiler knows about it
                              // before it is called in loop()

This is a lie! Don't tell your compiler there's a `refresh_readings` function that takes no arguments when you haven't defined one. Remove that line, you already have the function declaration in your header.

    void (*fcnPtr)(Adafruit_BME280){ &refresh_readings };
    (*fcnPtr)(bme);

This is just a very convoluted way of typing:

    refresh_readings(bme);

So just use the normal function call syntax.

The main issue as far as I can tell though is that you are copying the `bme` object when passing it to the readings function, which is not advisable in general for this sort of object (they represent a piece of hardware that you can't really copy). That class in particular has a bunch of pointer members, a destructor that deletes them, but no copy constructor as far as I can tell, which [is a bad thing][1].

Change your function to this signature (both in the header and the C++ file):

    void refresh_readings(Adafruit_BME280& bme);
    //                 pass by reference ^

And use the normal call syntax (`refresh_readings(bme);`).

[1]: https://en.cppreference.com/w/cpp/language/rule_of_three