text:
ld.exe:linker_script.ld:138 cannot move location counter backwards | ArduinoFFT Error
Board: Arduino Nano 33 BLE Sense
I'm pulling PCM data from an onboard microphone and running it through the arduinoFFT library (version 1.5.6) to obtain a spectrogram. Since the arduinoFFT library requires the data be an array of doubles, I've converted the data from short to double, and started the FFT process. The FFT.Windowing() function worked fine, but I get the error at the FFT.Compute() function call (line 77). The error goes away when I remove the function call. The error:
Found 25 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <arduinoFFT> 1.5.6
|-- <PDM> 1.0
Building in release mode
Linking .pio\build\nano33ble\firmware.elf
c:/users/benlu/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-
eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe:linker_script.ld:138 cannot move location counter
backwards (from 000000002004a470 t
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\nano33ble\firmware.elf] Error 1

And the code:
#include "Mic.h"
#include <arduinoFFT.h>

// FFT

arduinoFFT FFT = arduinoFFT(); /* Create FFT object */
/*
These values can be changed in order to evaluate the functions
*/
const uint16_t samples = 16128; //This value MUST ALWAYS be a power of 2
const double signalFrequency = 16000;
const double samplingFrequency = 16000;
const uint8_t amplitude = 100;
/*
These are the input and output vectors
Input vectors receive computed results from FFT
*/
double vImag[samples] = {0};

// buffer to read samples into, each sample is 16-bits
short* sample_buffer;

// number of samples read, read from Mic class on loop
volatile int samples_read;

// The length of the buffer to use. Currently set to 4 seconds.
int buffer_size = 16000;
double double_buffer[16384] = {};

// Instantiate
Mic mic;

// DO NOT PRINT INSIDE THIS FUNCTION - Causes it to hang.
void onPDMdata() {
  mic.sample();
}

void setup() {
  Serial.begin(115200);
  while (!Serial);
  PDM.onReceive(onPDMdata);
  PDM.setBufferSize(16128);

  Serial.println("3...");
  delay(1000);
  Serial.println("2...");
  delay(1000);
  Serial.println("1...");
  delay(1000);
  Serial.println("Listening!");

  mic.begin();
}

void loop() {

  // wait for samples to be read
  samples_read = mic.samples_read();

  // If desired buffer size is reached.
  if (samples_read >= buffer_size) {
    // Retrieves audio buffer
    sample_buffer = mic.sample_buffer();

      // print samples to the serial monitor or plotter
      for (int i = 0; i < samples_read; i++) {
        double_buffer[i] = (double)(sample_buffer[i]);
        Serial.println(double_buffer[i]);
      }

    Serial.println("---------- SAMPLE BREAK ----------");

    FFT.Windowing(double_buffer, samples, FFT_WIN_TYP_HAMMING, FFT_FORWARD);
    FFT.Compute(double_buffer, vImag, samples, FFT_FORWARD); /* Compute FFT <--------------------- THIS LINE */
    // FFT.ComplexToMagnitude(double_buffer, vImag, samples); /* Compute magnitudes */

    // delay for data collection only, comment when not collecting
    delay(1000);
    Serial.println("Listening!");

    // clear the read count and resume recording
    mic.clear_buffer();
  }
}

Where can I start to troubleshoot this issue? I've not had to deal with linker errors before, so any pointers would be greatly appreciated. Thanks in advanced!

c:/users/benlu/.platformio From that I gather that you're using platformio, which may be significant.  Have you tried building this with the the official arduino-builder/arduino-cli tools (or you know, using the IDE)?

samples = 16128; //This value MUST ALWAYS be a power of 2 - 16128 is not a power of two. (probably irrelevant)

@Mat Haha you're right! I had that set correctly, but I went on a renumbering spree trying to fix another problem... thanks for the catch!

@timemage I just gave it a try in the Arduino IDE and encountered the same exact error.

Short Version
The short answer is that you've exhausted RAM.
These two arrays alone:
const uint16_t samples = 16128;
double vImag[samples] = {0};
double double_buffer[16384] = {};

...are occupying (16128 + 16384) * 8 == 260096 bytes of memory.  There's only 262144 bytes of RAM in entirety.
The way the linker script is set up at least 1024 bytes are reserved for the stack, and there is no doubt at least another kByte in use somewhere.  In the Mbed OS and Arduino core files if nothing else.
As for why it fails only when you call Compute, that comes down to the compiler optimizer discovering that one (perhaps both) of your arrays are not actually used and so not entering into the mix when the linker is run.
Details
In theory, you should have gotten a somewhat nicer and easier to understand message from an ASSERT in the linker script:
ASSERT(. <= (ORIGIN(RAM) + LENGTH(RAM) - 1024), "heap region overflowed into stack");

So, you should have seen an error "heap region overflowed into stack" on your screen instead, which is maybe not the easiest thing for an Arduino user to decipher, but heap and stack are terms likely to be recognizable as memory-related sooner or later.
However, the linker executable shipped with the current version 1.3.2 of the Arduino core for Mbed ignores ASSERT statements completely; I have tested this (and tested my understanding of my test using an amd64 linker).  Presumably, there's a build option for the linker or a command-line or configuration file option that controls that, but I haven't found it yet.  In any case, it ignores a helpful ASSERT and instead proceeds to fail on line 138 mentioned in the error message:
 . = ORIGIN(RAM) + LENGTH(RAM) - 1024;

You can see it involves the same expression, just without a useful message if something goes wrong.  The "location counter" in the message is a linker related term that roughly means "where the next thing will be placed in memory" as it cobbles together your final executable from separately compiled chunks.  You've used so much RAM in your program that the location counter has been pushed past where the linker script wants to place the __HeapLimit symbol, 1K from the end of the MCU's RAM.  The location counter is supposed to increase monotonically.  So, evaluating this expression results in an erroneous attempt to "move location counter backwards".

Wow, thank you for the thorough answer! I tried to upvote but I don't have enough rep for it to show haha, I wanted to let you know I really, really appreciate your answer! So it sounds like I've used far too much memory, and I need to find a new approach. Thanks!

Good deal. I was going to just say "that's alright" or that you could come back if you remember. I'd forgotten there was a threshold for that but I also hadn't upvoted you're question yet.   Having done so, you should be able to upvote whatever you like.


text:
Arduino with bmp280 sensor not entering void loop
I've been working on a project in which I need to know my altitude. For this purpose I've been using the BMP280 sensor. But I have an issue.
I've been trying to test if the sensor works with the program "bmp280_sensortest.ino", already included in the library. When I open the serial monitor the message "BMP280 Sensor event test" is displayed, indicating that there is a valid sensor on board. Below that the temperature, pressure and altitude data should be displayed, but nothing happens.
I've added a simple Serial.print("hello") at the start of void loop(), but not even that is displayed. The program doesn't seem to enter void loop() and I don't know why.
Here is the code:
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>

Adafruit_BMP280 bmp; // use I2C interface
Adafruit_Sensor *bmp_temp = bmp.getTemperatureSensor();
Adafruit_Sensor *bmp_pressure = bmp.getPressureSensor();

void setup() {
  Serial.begin(9600);
  Serial.println(F("BMP280 Sensor event test"));

  if (!bmp.begin()) {
    Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
    while (1) delay(10);
  }

  /* Default settings from datasheet. */
  bmp.setSampling(Adafruit_BMP280::MODE_NORMAL,     /* Operating Mode. */
                  Adafruit_BMP280::SAMPLING_X2,     /* Temp. oversampling */
                  Adafruit_BMP280::SAMPLING_X16,    /* Pressure oversampling */
                  Adafruit_BMP280::FILTER_X16,      /* Filtering. */
                  Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */

  bmp_temp->printSensorDetails();
}

void loop() {
  sensors_event_t temp_event, pressure_event;
  bmp_temp->getEvent(&temp_event);
  bmp_pressure->getEvent(&pressure_event);

  Serial.print("hello");
  Serial.print(F("Temperature = "));
  Serial.print(temp_event.temperature);
  Serial.println(" *C");

  Serial.print(F("Pressure = "));
  Serial.print(pressure_event.pressure);
  Serial.println(" hPa");

  Serial.println();
  delay(2000);
}

Any reply is greatly appreciated.
edit:
if I remove
!bmp.begin()
from the if statement and replace it with a 1 it enters the void loop but it displays 0°C and 0pa

If you are using Serial.print("hello"); to test the entering of void loop(), you should follow it with Serial.flush(); so that you know your message has been sent before your code has an opportunity to lock up, because if that happens the absence of the "Hello" message might lead you to believe that you didn't make it to that line when you in fact did.

put print statements throughout setup()

But you don't get the "check wiring" message? ;)

Add prints after every call in setup to pin down which of those calls does not return...

Does your BMP280 show up if you run the I2C scanner sketch? Does that sketch fail to run to completion?

@timemage the I2C scanner sketch is stuck at 'scanning...'

There is something fundamental going on then and not enough information to provide a proper answer that matches your question.  It may be as @SimSon suggested, wiring.  It may be that your pull-up resistors are too weak or non-existent.  A simple way to lock up the AVR Wire implementation is to hold SCL LOW indefinitely.  But it could be any number of other things.

What you might do is delete this question before it is "answered".  Work on your wiring, and if you're still having trouble with it start a new question to the effect "why is my bme280 connected to nano ble etc etc not show up in the i2c scanner" and provide details needed to trouble shoot that.  E.g. link to the bme280 breakout used.  Pictures of wiring, etc.  Then whatever answer that results will match the question.  Though, you'll probably figure it out on your own.

"replace it with a 1 it enters the void loop" - in this case the sketch is not supposed to enter the loop, instead it will get stuck in the while(1) loop. Please clarify this point. An all time classic is missing pullup resistors, do you have those attached?

It could be a faulty library/sensor, most likely the sensor, sometimes sensors can begin but then another connection could be faulty or the chip itself is faulty and so the Arduino might just be waiting forever for a response that will never come.
To see where it gets stuck, you can add Serial.println(F("1")); after bmp.setsampling then Serial.println(F("2"));  after bmp_temp->printSensorDetails to see where exactly it's getting stuck
One thing I also like to do is to buy two/three of a sensor, so that I can replace a sensor with another one. That way if a piece of code doesn't work for all three sensors then I can pretty sure it's a problem with the code and not the device. Not sure if you have a spare sensor to try that but I would recommend it in future

source: Stack Exchange

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

sort: votes


text:
How to close humidity sensor at specific humidity
I am using dht humidity and temperature sensor on arduino and i would like to add relay and buzzer on the system. What I would like to do is to close it via buzzer and on 65% humidity run buzzer. The code i use is:
/* DHT-22 sensor with 12c 16x2 LCD with Arduino uno
   Temperature and humidity sensor displayed in LCD
   based on: http://www.ardumotive.com/how-to-use-dht-22-sensor-en.html and
   https://www.ardumotive.com/i2clcden.html for the i2c LCD library by Michalis Vasilakis
   Recompile by adhitadhitadhit
   Notes: use LCD i2c Library from link above, i'm not sure why but new Liquidcristal library from Francisco Malpartida  isn't working for me
   other thing, check your */

//Libraries
#include <dht.h> // sensor library using lib from https://www.ardumotive.com/how-to-use-dht-22-sensor-en.html
#include <LiquidCrystal_I2C.h> // LCD library using from  https://www.ardumotive.com/i2clcden.html for the i2c LCD library
#include <Wire.h>
dht DHT;

//Constants
#define DHT22_PIN 2     // DHT 22  (AM2302) - pin used for DHT22
LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 after finding it from serial monitor (see comment above) for a 16 chars and 2 line display

//Variables
float hum;  //Stores humidity value
float temp; //Stores temperature value

void setup()
{
    Serial.begin(9600);
    lcd.init();                      // initialize the lcd
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setBacklight(HIGH);
}

void loop()
{
    int chk = DHT.read22(DHT22_PIN);
    //Read data and store it to variables hum and temp
    hum = DHT.humidity;
    temp= DHT.temperature;
    //Print temp and humidity values to LCD
    lcd.setCursor(0,0);
    lcd.print("Humidity: ");
    lcd.print(hum);
    lcd.print("%");
    if (humidity <= 50)
{
   digitalWrite(ledPin, HIGH);
   digitalWrite(buzzer, HIGH);

 }

 else

 {

 digitalWrite(ledPin, LOW); digitalWrite(buzzer, LOW);

    lcd.setCursor(0,1);
    lcd.print("Temp: ");
    lcd.print(temp);
    lcd.println("Celcius");
    delay(2000); //Delay 2 sec between temperature/humidity check.
}

How to add relay and buzzer to close it with buzzer run on 65% humidity value?

Do you know how to implement the required subtasks (control relay/buzzer, compare values)? If yes, where exactly do you have problems?

Yes i did it once but this time i changed my LCD connection with socket. Defining buzzer and relay it gives error on ide. I have follewed arduino official code. So i need to adapt it to above code which provides humidity and temperature on LCD

Hmm, we need to see the code that doesn't work and which you have problems with... how do you actually "define" a relay/buzzer? You just need to set the desired pins to outputs and control them with digitalWrite() and tone() corresponding to some logic you have to implement. Without seeing what you do we can't know what you're doing wrong.

you don't have any code that says if humidity is equal to 65%, then sound a buzzer

I would also suggest you include your schematic, not a fuzzy drawing, that will help a lot.

For ther buzzer I have added if (humidity <= 50) {
digitalWrite(ledPin, HIGH);
digitalWrite(buzzer, HIGH); }
else {
digitalWrite(ledPin, LOW);
digitalWrite(buzzer, LOW); } But it provides error.  My connection is as follow: LCD: SCL to A5
CDA to A4
GND to GND
VCC to 5V
DHT Data to D2
VCC to 5V
GND to GND
Buzzer: Data to 7
GND to GND

A) edit the code in the question instead of posting snippets in comments. B) which error?! C) though it's probably not related to hardware, if you want to inform us about your circuit you should draw circuit diagram.

I have uploaded the infos you asked for. I couldn't decide the relay connection so I need your help on relay connection and code.

Is it a relay module or a standalone relay?

It is external 12V relay. I will feed it seperately out of arduino. What I want is to run the buzzer at 65% humidity and close the system via relay around 80% huımidity. I know that I didn't add relay code and buzzer library because that side is completely the part I need the halp.

ledPin and buzzer are neither declared/defined, nor are the corresponding pins configured as outputs. I assume the black dot in the drawing is the buzzer. The problem here is that you must not connect the buzzer between Vin (connected to 9V battery) and a GPIO - this will fry the arduino! What kind of buzzer is it (datasheet)?

Did you actually google for "arduino buzzer"/"arduino relay"? There are tons of tutorials out there... those also show you how to wire everything up

https://components101.com/misc/buzzer-pinout-working-datasheet

yes I did. But it didn't work. As I mentioned I did the same system once before but I wouldn't use IC12 LCD and It corrupted everything :)

Normally I am python developer and I haven't been using C# for years. It seems totlly bunk to me at tyhe moment.

yes I googled it BTW. I have problem where i should add the buzzer and relay lines.

Currently I am able to show temperature and humidity values on LCD. Other sides I corrupted.

Can you recommend your solution on draft and code if possible?

Consider upgrading your power supply, a 9V battery will not cut it. Also a Schematic would be a big help, the frizzy thing is difficult to interpret. You can get KiCad free but it is nice to leave a donation.

yes I am using external 12V adapter instead.

In this code:
void loop()
{
   sample temp and humidity;
   display temp;
   display humidity;

   if humidity <= 50
      LED on;
      buzzer on;
   else
      display temp
      wait 2 sec
   end

There is a missing '}' to to close the if/else.
Why do you display temp twice within the loop?
Where is the logic for the relay and the buzzer at 65%?
Pin numbers for the LED and the buzzer are undefined.
The LED and buzzer pins need to be set to OUTPUT mode in your setup() function.

If I understand your description, you probably need somethng like the following, in your loop function:
   if humidity <= 50
      LED on;
      buzzer on;
   else if hum >= 65%m
      close relay;
      buzzer on;
   end

When I have a problem with program logic that isn't obvious to me, I write it out in pseudo-code as I did above. Once I figure out the logic, then I'll type in C++ with proper syntax.
If I haven't understood your intentions in the above pseudo-code, I'd suggest you do the same thing, until you believe what you've written. Only then try to make it into working code.

What I missed was seems to be added humidity function into void main function. By checking c# I solved it. Now the system works fine thank you.

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


text:
Driving 5V relay with ESP-01
I'm trying to drive a 5V relay with 3.3V ESP-01 with schematic below. I programmed the ESP to start a portal through which I can derive the relay by triggering GPIO-0 & GPIO-2. However when I power on the circuit I encounter the following scenarios:

IF wire is plugged in to GPIO-2

ESP blue led turned on forever
Relay started buzzing sound forever
No WIFI network appears thus not working

IF wire is plugged in to GPIO-0

No WIFI network appears thus not working

IF I only plug the wire after powering on the circuit then it works just fine as intended.

Would you please explain what is happening and how to fix it

#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>

const byte DNS_PORT = 53;
IPAddress apIP(172, 217, 28, 1);
DNSServer dnsServer;
ESP8266WebServer webServer(80);

//int ledPin = 2;
#define ledPin0 0
#define ledPin2 2

int ledStatus0;
int ledStatus2;

void setup() {
//  Serial.begin(9600);         // Start the Serial communication to send messages to the computer
//  delay(10);
//  Serial.println('\n');

  pinMode(ledPin0, OUTPUT);  ledStatus0 = digitalRead(ledPin0);  digitalWrite(ledPin0, HIGH); ledStatus0 = 1;
  pinMode(ledPin2, OUTPUT);  ledStatus2 = digitalRead(ledPin2);  digitalWrite(ledPin2, HIGH); ledStatus2 = 1;

  WiFi.mode(WIFI_AP);
  WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
  WiFi.softAP("Toggle Portal");

  // if DNSServer is started with "*" for domain name, it will reply with
  // provided IP to all DNS request
  dnsServer.start(DNS_PORT, "*", apIP);

  // replay to all requests with same HTML
  webServer.onNotFound([]() {

    if (webServer.hasArg("led0")) {
      String status = webServer.arg("led0");
      if (status == "off") { digitalWrite(ledPin0, LOW); ledStatus0 = 1;  switchRelayOff(); }
      else if (status == "on") { digitalWrite(ledPin0, HIGH); ledStatus0 = 0; switchRelayOn(); }
    }
    if (webServer.hasArg("led2")) {
      String status = webServer.arg("led2");
      if (status == "off") { digitalWrite(ledPin2, LOW); ledStatus2 = 1;  switchRelayOff(); }
      else if (status == "on") { digitalWrite(ledPin2, HIGH); ledStatus2 = 0; switchRelayOn(); }
    }

    String content = "<!DOCTYPE HTML>";
    content += "";
    content += "";
    content += "  <title>ESP Web Server</title>";
    content += "  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">";
    content += "  <link rel=\"icon\" href=\"data:,\">";
    content += "  ";
    content += "";
    content += "";
    content += "
ESP Web Server
";

    content += "
Output - GPIO 0
";
    if ( ledStatus0 == 0 ) {      content += "  <input type=\"checkbox\" onchange=\"toggleCheckbox(this)\" id=\"0\" >";
    } else {      content += "  <input type=\"checkbox\" checked onchange=\"toggleCheckbox(this)\" id=\"0\" >";    }

    content += "
Output - GPIO 2
";
    if ( ledStatus2 == 0 ) {      content += "  <input type=\"checkbox\" onchange=\"toggleCheckbox2(this)\" id=\"2\" >";
    } else {      content += "  <input type=\"checkbox\" checked onchange=\"toggleCheckbox2(this)\" id=\"2\" >";    }

    content += "";
    content += "";
    content += "";
    webServer.send(200, "text/html", content);
  });
  webServer.begin();
}

void loop() {
  dnsServer.processNextRequest();
  webServer.handleClient();
}

GPIOs 0 and 2 have a special purpose (https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/), I believe it's possible to use at least one of them as outputs. The relay module already has a transistor included, so the 2N2222 might not be required (do you have a datasheet for the module?)...

@SimSon this is the question, how to use them? it is not practical to attach them only after power up.

"Boot fails if pulled LOW" - this applies to both GPIO 0 and 2. The 2N2222 pulls the GPIO down to one diode drop (0.7V) above GND, which actually is LOW. Instead of using a BJT, you need to control the relay module with a mosfet. Its high gate resistance will have negligible effect compared to the internal pullup resistor.
Chances are that the transistor on the relay module itself is a mosfet. If that's the case and if this mosfet works with 3.3V you can get rid of the 2N2222 at all. In general, using two transistors for this task does not make much sense, but in your case a BJT at the GPIO does not work.
You may notice that the onboard led is connected to GPIO 2, which is high at boot. So if you pull down GPIO 0 somehow, booting fails and GPIO 2 gets pulled HIGH (ref) - the onboard led will light up.
"the question, how to use them?" - once the ESP has booted into your sketch you should be fine to use the GPIOs like you would normaly do.


text:
Compiling Assembly Script in External EEPROM to Arduino Code
I'm working on a simple game console, and I'm planning to use a cartridge system using an EEPROM. I know that you can read and write data from an EEPROM, but can you compile the data into executable Arduino code, and vice versa? If the Arduino can do it, we can probably too, right?
Thanks in advance!

there is no such thing as "arduino code" when the microcontroller executes it

have a look at forth programming language

@jsotola so is there some sort of compiler that turns arduino code into EEPROM code, and vice versa?

the microcontroller executes machine code ... in simple terms, the machine code is generated by the C++ compiler and loaded into the arduino ... the reason that i suggested forth is because forth is an interpretter that runs on the arduino ... it could possibly execute code originating from an EEPROM

@jsotola I see. I would use that, but I am using libraries to control the screen. I doubt that be converted into Forth, so that's my issue. I suppose I could control the screen manually, but it seems like a lot of work.

yes it would be a learning curve ... you did not describe your project, so it was unclear what component would need to be controlled

My project is basically a joystick connected to an LCD screen. So far I've just gotten a square to move around.
Here is the LCD screen I am using:
LCD Screen

I would suggest you investigate a different micro with external addressing or one that loads its code from an external memory such as flash like the ESP32s do.


text:
converting an unsigned integer into a const char pointer
I know this is simple basic C stuff, but I can't quite figure it out or find a solution when searching and reading.
I have a method I want to call from a library that wants a const char pointer
someclass::send(const char *data)

And the value I want to send is actually an unsigned integer:
enum messageTypeEnum
{
  REGISTER_CLIENT = 0x04,
  CLIENT_REGISTERED,
  UPDATE_CREDENTIALS,
  ADD_BRICK,
  GAME_FRAME,
  ERROR
};

enum clientTypeEnum
{
  GAMEBOARD = 0x01,
  BRICK_CONTROLLER,
  PLAYER_CONTROLLER,
  TOUCH_CONTROLLER
};

uint16_t message = GAMEBOARD;
message <<= 8;
message += REGISTER_CLIENT;

So I want to convert it, but I can't quite figure it out.
I know fundamentally the char pointer is just a pointer to a memory address and that c strings are null terminated, so I should be able to create the pointer, add the enum's underlying bytes to the pointer array, and then add a 0 at the end to terminate it, but I don't know how I would do that exactly.
I tried doing it via casting:
const char *data = (char *)&message;

So here I'm saying (if I'm thinking about it correctly), is:

&message take the memory address of message, our uint16
`(char *) interpret it as a pointer for a character string
const char * store that address in this const pointer

Even typing that out I feel like I'm misunderstanding parts.
This compiles, but it crashes my esp32 and I'm sure it's because I don't have a null terminator at the end, but I'm not sure how to add it (I tried to add it via array index but that failed).
What's the proper way of doing this (I'm sure there's a non-casting way that's probably easier)?
Update
More detail re: PMF and Edgar's comments.
I definitely want to send the binary numbers behind the enums up. I'm building a websocket based interactive project where "controller" websocket clients can drive interactions on "gameboards". Websockets don't have a concept of differentiating between client types (I know socket.io does, but I'm wanting to write it all with regular websockets), so I built a registration system into the server that looks at the first two bytes of an array buffer or blob message to determine the client and message type (it seems overly complicated, but I'm building this to give a talk on binary operations and I'm doing it give functional examples of data parsing).
So yeah, all of that to say I definitely want to send the underlying number values from the enums.
The library I'm using is ArduinoWebsockets and they do have a client method called sendBinary that does have a signature like the Serial.write:

Though when I tried this with a non-null terminated c-string my esp32 crashed. That said, I was fumbling around in the code so it may have been something else that caused the crash.
When I follow the method calls down, the library ultimately uses std::string to pull the data out of the passed in c string and takes in the length (meaning it doesn't need to be null terminated(?)):

So maybe I can use the casting to turn my two byte number into a c string and pass in the length of 16?

Are you sure you want to send a binary 0x01 value? I guess that it's rather your library that crashes because of this instead of the calling function. Although it is incorrect (as you're correctly assuming) the message is actually binary 0x01 0x00 (the esp32 is little endian) and so it does have a terminating 0 as long as the value is smaller than 256.

Serial.write() has the overload write(const uint8_t *buffer, size_t size) which lets you output an arbitrary array of bytes and doesn't require a NUL terminator (0 is a valid value to output). I have seen this kind of overload in other libraries. Your someclass may offer something similar for sending binary data. If it doesn't, it's probably not meant to send anything but text, in which case you have to serialize your data as text.

I do want to send the binary values up because I'm parsing the messages on the server as 8 bit array buffers or blobs and I have the same enums on the server and other clients to coordinate the message and client identification.

Ah @EdgarBonet  yeah the library does have a sendBinary method that takes a c string and a length, though I ran into issues when trying to use it. That said, I'm probably understanding it wrong. I'll update my question with more detail.

CORRECTED ANSWER
I dug back into my code after a comment from  Edgar and figured out some needed adjustments. My original solution was mostly correct, but there were some inaccuracies that I want to correct so I'm not goofing up anyone else in the future that may find this answer useful.

So I was overthinking things a bit. I still don't know that this is the best way of handling it, but it is working on the client side.
So, c-strings are just arrays of 8bit values with a null terminator at the end.
I want to end up my enum values, and my enums are define with byte enum-bases:
enum messageTypeEnum
{
  REGISTER_CLIENT = 0x04,
  CLIENT_REGISTERED,
  UPDATE_CREDENTIALS,
  ADD_BRICK,
  GAME_FRAME,
  ERROR
};

enum clientTypeEnum
{
  GAMEBOARD = 0x01,
  BRICK_CONTROLLER,
  PLAYER_CONTROLLER,
  TOUCH_CONTROLLER
};

So, to send up my bytes, I can just build a character array, set each byte in little endian order, and manually terminate it:
NOTE: this is the original assembly that was incorrect.
I put the null terminator at the beginning of the buffer thinking "oh, it's little endian so the terminator needs to be at the beginning". Classic sleepy brain mistake :|

void registerAsAGameBoard()
{
  char buffer[3] = {0, GAMEBOARD, REGISTER_CLIENT};
client.sendBinary((const char *)buffer, 3);
}

void registerAsAGameBoard()
{
  char data[3] = {GAMEBOARD, REGISTER_CLIENT, 0};

  const char *buffer = data;
  size_t size = strlen(buffer);

  client.sendBinary(buffer, size);
}

Now when I call sendBinary with my byte array and the length of the buffer my esp32 doesn't crash (hurray!) and the server receives the buffer correctly!!

I need to make a couple of adjustments on either the client and/or server side to account for the fact that the ESP32 is little endian and the server is already coded to receive payloads in big endian, but that shouldn't be too much of a lift.

Note that in char buffer[3] = {0, GAMEBOARD, REGISTER_CLIENT};, the 0 byte is not a “null terminator”: It's the first byte of the buffer, whereas a “terminator” is by definition at the end.

@EdgarBonet, you are correct, and I'm glad you pointed that out. I didn't understand why this particular setup prevented the crash. I dug in further and found that when put the null terminator in the correct place the controller still crashed, but it crashed in a different portion of the code where we handle different messages from the server. I commented that part out and the controller stopped crashing at both spots. I then updated the code with the correct null terminator and got everything ironed out. I'm updating my answer.


text:
Arduino Pico doesn't work with ST7735 screen
I am attempting to get the graphicstest example bundled with the Adafruit ST7735 library for the 0.96 inch LCD screen.
The example runs fine and serial communication is up and running. However, nothing outputs on the screen. I verified that the code works with other Arduino boards and that I have it properly wired -> SCK to SCL, MOSI to SDA, etc.
I'm not sure if I am doing something wrong, or if this is a limitation of the board.
Edit: I added the modified graphicstest code to the Internet, it can be found here: https://drive.google.com/file/d/1cFOgQXhhH1vou0KUrFzBDMp0iiIp1Yuy/view?usp=sharing
I also added a crude diagram of how the screen is wired up to the Pico. Note that the LCD is powered externally since the Pico cannot handle the current draw of powering the LCD.
https://drive.google.com/file/d/1RmZSHBcelwC9caLoQC9iE5Lb4eHG9S2O/view?usp=sharing

Does your Arduino Pico have the chip atmega32u4? If yes, you could have issue with the library. Most of the standard arduino libraries are for atmega328 or atmega2560 (UNO and Mega). You will find that most of the libraries, that work for UNO or Mega, don't usually work for Arduino Leonardo (atmega32u4).

Show your wiring and any modifications you made to the graphicstest code.

@SimonVu14 I had a feeling that was the case. I'll try to see if there's another library out there other than the Adafruit one.

@timemage I only changed the pin outs to pins that were available on the Pico.
RST was 4, CS was 3, and DC was 2.

Until I can see everything you can see I'm unlikely to be of any help.

@timemage Apologies for it taking a long time to respond. I added the modified graphicstest along with a crude diagram to the question.

The diagram seems at odds with what is shown here where SCK is shown closest the diode.  In your diagram SCK is shown furthest from the diode.

@timemage I am going directly off of what's on their website. https://mellbell.cc/products/pico
What they show on the link you provided is a prototype. Additional research also shows that the SCK and MISO pins I'm connected to seem to be for programming only.

I found out the problem. I was trying to connect to the SCK and MOSI pins on the back of the Pico. Later research shows that these are meant for programming and burning a bootloader onto the microprocessor.
The Adafruit library allowed me to define my own pins for SCK and MOSI.
Once I switched to using the Adafruit_ST7735(int8_t cs, int8_t dc, int8_t mosi, int8_t sclk, int8_t rst) constructor, it worked after that.

Well, it's nice that you got it working, but there really isn't any reason why you shouldn't be able to use those pins.  As you say, they are used for ISP programming, the bootloader or whatever else.  But, they're also just SPI pins and beyond that just "digital" pins.

From a comment on the question:

I am going directly off of what's on their website.
mellbell.cc/products/pico What they show on the link you provided is a
prototype.

The "link you provided" refers to this, which despite being described as for a "prototype", shows correct information with regard to the SPI related pins.
As it turns out the documentation in the images you referenced at mellbell.cc/products/pico is incorrect, both under the product shots and in the pin-outs section under "Documentation".  You can tell this by looking right at their image of their board and their diagram, and comparing that with the pinout of the ATMega32U4 itself:

Interestingly, in the pinout on 8 of their PDF in the documentation section, they have it correct again and closer to the prototype:

Or at least it is with respect to the SPI signals.  The diode is in the wrong and orientation. In fact, the whole board seems to be left-right reversed.
Again, from the same comment:

Additional research also shows that the SCK and MISO pins
I'm connected to seem to be for programming only

It is true that these pins are used for ISP programming.  However, they also carry the data for the SPI bus peripheral when you're not doing ISP programming.  So they are "for programming" just not "only" for programming.  This is down to how the ATMega32U4 is, and not something tha the Pico makers have much control over.
This is also the case for UNO and basically all of the other popular AVR based Arduinos that can be programmed using the ISP method, as opposed to uPDI and others.  What slightly less common is to have these pins only available as unpopulated pads or only available on the ISP header.
I can see why you might want to not deal with those contacts because of the form factor of the Pico board.  However, because those pins are actually 32u4's SPI interface, and they should perform better than the bit-banging that Adafruit library would need to resort to in order to use other (non-SPI) pins.  So there is an incentive to use them.
So, your solution is a solution, but not for the reasons you think.  The pins you were previously trying to use will work when your efforts aren't being undermined by bad documentation, and you get them in the right order.


text:
Message parsing from MQTT server
I'm making a NodeMCU based home automation. I adapted code I found on internet for controlling a device (say LED) via MQTT broker hosted on a Raspberry Pi. It works fine. But when I try to scale it up for more than one device, I'm hitting a wall.
void callback(char* topic, byte* payload, unsigned int length)
{

  const char* t_bedroom_light1 = "/home/bedroom/light1";

  Serial.print("Topic from MQTT broker is : ");
  Serial.print(topic);
  char p = payload[0];

  // if MQTT comes a 0 turn OFF pin D4
  if (topic == "/home/bedroom/light1" && p == '0')
  {
    digitalWrite(LIGHT_PIN, LOW);
    Serial.println(" Turn Light Off! ");
  }

  // if MQTT comes a 1, turn ON pin D4
  if (topic == "/home/bedroom/light1" && p == '1')
  {
    digitalWrite(LIGHT_PIN, HIGH);
    Serial.println(" Turn Light On! " );
  }
}

Serial monitor receives and prints the topic correctly from MQTT server. But topic == "/home/bedroom/light1" never returns true. If I delete that part then p =='0' or p=='1' works fine by itself. I've tried comparing the topic with the locally declared char array, tried converting it into String and doing strcmp. Nothing. What am I doing wrong? Here is the Serial monitor output
12:43:20.346 -> .......
12:43:24.187 -> WiFi connected
12:43:24.187 -> IP address:
12:43:24.187 -> 192.168.1.5
12:43:24.187 -> Attempting MQTT connection...connected
12:43:30.752 -> Topic from MQTT broker is : /home/bedroom/light1

That's not how you compare C strings.
When you write
if (topic == "/home/bedroom/light1")

you're comparing whether the character pointer topic is the same value as the address of the string "/home/bedroom/light1", which of course it is not in this case.
To compare C strings, use the strcmp() function, which returns 0 if they're identical.
if (strcmp(topic, "/home/bedroom/light1") == 0 && p == '0')

Ty, that worked! The noob in me didn't know char arrays were Strings. I had actually tried casting the char array to a new String and used strcmp on that but for some reasons that didn't work.

Actually, char arrays are not Strings (note the capital S), but c-strings, which is a significant difference. Strings shouldonly not be used in devices, with limited memory (or only verys sparingly) while c-strings (char arrays) do not exhibit the same problems.

What @StarCat said. Unfortunately C strings also let you shoot yourself in the foot very easily. It's definitely one of the less intuitive parts of C unless you're coming to C from assembly language programming :)


text:
Upload of software working unreliably
I've got a new Keyestudio ATmega2560 (compatible with Arduino Mega 2560) board and was trying to upload a simple sketch. I noticed that both the Arduino IDE and PlatformIO were unable to do so, they detected the device but at various points during the upload stage they encountered a timeout.
After dozens of failed attempts I was already concluding that the serial interface must be broken so I created a serial loopback (grounded RESET and connected TX and RX) and opened it in the serial monitor of the Arduino IDE. I noticed that it works perfect, whatever I type gets sent back.
After trying some more and experimenting with different programmers in Arduino IDE I managed to get it to write the software once (write completed but subsequent verifying of the flash memory failed) and opening the serial monitor now it really shows the output I had in my program.
I am wondering, what can I do to isolate further where the problem could be? It seems in theory it is working as expected since I was able to upload the code once, but it is clearly not doing so all the time...
Some outputs:
avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM3
         Using Programmer              : wiring
         Overriding Baud Rate          : 115200
         AVR Part                      : ATmega2560
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
           flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Wiring
         Description     : Wiring
         Programmer Model: AVRISP
         Hardware Version: 15
         Firmware Version Master : 2.10
         Vtarget         : 0.0 V
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout

And one that probably got the furthest:
avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM3
         Using Programmer              : wiring
         Overriding Baud Rate          : 115200
         AVR Part                      : ATmega2560
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
           flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Wiring
         Description     : Wiring
         Programmer Model: AVRISP
         Hardware Version: 15
         Firmware Version Master : 2.10
         Vtarget         : 0.0 V
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: reading input file "C:\Users\yanic\AppData\Local\Temp\arduino_build_482951/sketch_feb19a.ino.hex"
avrdude: writing flash (2012 bytes):

Writing | #####################################avrdude: stk500v2_ReceiveMessage(): timeout
############# | 100% 10.31s

avrdude: 2012 bytes of flash written
avrdude: verifying flash memory against C:\Users\yanic\AppData\Local\Temp\arduino_build_482951/sketch_feb19a.ino.hex:
avrdude: load data flash data from input file C:\Users\yanic\AppData\Local\Temp\arduino_build_482951/sketch_feb19a.ino.hex:
avrdude: input file C:\Users\yanic\AppData\Local\Temp\arduino_build_482951/sketch_feb19a.ino.hex contains 2012 bytes
avrdude: reading on-chip flash data:

Reading | avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port

Have you tried a dedicated ISP programmer, like USBasp or USBtinyISP, to upload firmware directly to the mcu? Just to check if the mcu still alive? I think there is a chance they overcooked the mcu why reflowed it. For me, I just don't trust made in china arduino clones in general.

the USBtinyISP is actually the one that worked once. I guess it might be the board, too bad, never had problems with keyestudio before... I typcially go for the original one as well, but they fixed so many of the things I hate about the Arduino :)

Not helpful to solve your problem, but I suggest you move on to a different electronic platform, like ARM 32-bit mcu. This 8-bit ATmega family is like a relic of the past, still good for simple applications though.

What error message do you get? Enable "verbose" output in the settings to get a more details. Please edit your question to include the output you get when trying to upload.

PS programming the board via ISP will overwrite the bootloader, making it impossible to upload over serial(, without first restoring the bootloader)

I've added two sample outputs

This may sound like a dumb question, but there is a theory behind it: What happens if you upload a blank sketch, just void setup(){} void loop(){}  Does it do that reliably?

Two suggestions, first try a slower baud rate, if that does not fix it try a different USB cable.


text:
HobbyTronics UNO PRO Board Definition does not work in newer IDE versions
I have a HobbyTronics UNO PRO that replaces the UNO's 328P in DIP with an ATMega1284 on an adapter board:

I cannot link to the original page since it does not exist anymore.  But, it is available through archive.org.
The original board definition, supplied by the distributor, stopped working after 1.8.10 and throws errors in 1.9.
The particular error when trying to compile:
recipe.preproc.macros pattern is missing

It is not about a particular library or similar; I cannot compile at all (even an empty sketch).
How can I migrate this board? I'd really like to use a current version of the compiler & IDE.

Can you link to this "replacement chip" that you have?  Because, as is, that doesn't completely make sense to me, unless you're using a term in an unusual way.  A Link to "the original board" may also be helpful.

so the mysterious board definition, needs a fix

what happens if you add the missing entry?

please post a link to the library

@timemage The Board is not a default "uno", since its cpu was swapped to an 1284 (which has way more ram etc.) How it should be used with the IDE is on the product page which i added to the question

The link to the archive.org was helpful.  That it was swapped from a 328p to a PCB that adapts 1284 to a 328p pinout was the critical part not conveyed by "replacement chip" or "swapped" chips etc.

Making your board definition work
What I did was slightly different from their directions, but:
Close any instances of the IDE you have running.
Create the directories along this path:
<sketchbook>/hardware/uno_pro/avr/variants/uno_pro

Where <sketchbook> refers to to where your IDE is saving sketches by default.
Place the following slightly modified boards.txt at <sketchbook>/hardware/uno_pro/avr/boards.txt:
uno_pro.name=Arduino Uno*Pro

uno_pro.upload.tool=avrdude
uno_pro.upload.protocol=arduino
uno_pro.upload.maximum_size=130048
uno_pro.upload.maximum_data_size=16384
uno_pro.upload.speed=115200

uno_pro.bootloader.tool=avrdude
uno_pro.bootloader.low_fuses=0xFF
uno_pro.bootloader.high_fuses=0xDE
uno_pro.bootloader.extended_fuses=0xFD
uno_pro.bootloader.unlock_bits=0x3F
uno_pro.bootloader.lock_bits=0x0F
uno_pro.bootloader.file=optiboot/optiboot_atmega1284p.hex

uno_pro.build.mcu=atmega1284p
uno_pro.build.f_cpu=16000000L
uno_pro.build.board=AVR_UNO_PRO
uno_pro.build.core=arduino:arduino
uno_pro.build.variant=uno_pro

This is the original file with one important modification, and that's the addition of arduino: in the second to last line reading uno_pro.build.core=arduino:arduino
Place the following (unmodified from original) pins_arduino.h at <sketchbook>/hardware/uno_pro/avr/variants/uno_pro/pins_arduino.h:
#ifndef Pins_Arduino_h
#define Pins_Arduino_h

#include <avr/pgmspace.h>

// ATMEL ATMEGA1284 on Hobbytronics UNO*Pro
//
//
// 2014-01-24 - Modified for Software Serial Library to work
//
//   ATMEGA1284 Pin     Arduino Mapping    Features
//     PA0                   D21  A7
//    PA1                   D20  A6
//     PA2                   D19  A5
//    PA3                   D18  A4
//     PA4                   D17  A3
//    PA5                   D16  A2
//     PA6                   D15  A1
//    PA7                   D14  A0
//
//     PB0                   D4
//    PB1                   D5
//     PB2                   D2
//    PB3                   D3               PWM
//     PB4                   D10                    PWM  SS
//    PB5                   D11                   MOSI
//     PB6                   D12              PWM  MISO
//    PB7                   D13              PWM  SCK
//
//     PC0                   D22                   SCL
//    PC1                   D23                   SDA
//     PC2                   D24
//    PC3                   D25
//     PC4                   D26
//    PC5                   D27
//     PC6                   D28
//    PC7                   D29
//
//     PD0                   D0                    RX
//    PD1                   D1                    TX
//     PD2                   D6                    RX1
//    PD3                   D7                    TX1
//     PD4                   D30              PWM
//    PD5                   D8               PWM
//     PD6                   D9               PWM
//    PD7                   D31              PWM
//

static const uint8_t SS   = 10;
static const uint8_t MOSI = 11;
static const uint8_t MISO = 12;
static const uint8_t SCK  = 13;

static const uint8_t SDA = 23;
static const uint8_t SCL = 22;
static const uint8_t LED = 13;

static const uint8_t A0 = 0;
static const uint8_t A1 = 1;
static const uint8_t A2 = 2;
static const uint8_t A3 = 3;
static const uint8_t A4 = 4;
static const uint8_t A5 = 5;
static const uint8_t A6 = 6;
static const uint8_t A7 = 7;

#define NUM_DIGITAL_PINS            32
#define NUM_ANALOG_INPUTS           8

// Macros
#define analogInputToDigitalPin(p)  ((p < NUM_ANALOG_INPUTS) ? (p) + 14 : -1)
#define digitalPinToAnalogPin(p)    ((p) >= 14 && (p) <= 21 ? (p) - 14 : -1 )
#define analogPinToChannel(p)         ((p) < NUM_ANALOG_INPUTS ? NUM_ANALOG_INPUTS - (p) - 1: -1 )
#define digitalPinHasPWM(p)         ((p) == 3 || (p) == 8 || (p) == 9 || (p) == 10 || (p) == 12 || (p) == 13 || (p) == 30 || (p) == 31 )

#define ifpin(p,what,ifnot)     (((p) >= 0 && (p) < NUM_DIGITAL_PINS) ? (what) : (ifnot))

extern const uint8_t digital_pin_to_pcint[NUM_DIGITAL_PINS];

#define digitalPinToPCICR(p)    ifpin(p,(&PCICR),(uint8_t *)0)
#define digitalPinToPCICRbit(p) ifpin(p,(digital_pin_to_pcint[p] >> 3),0)
#define digitalPinToPCMSK(p)    (((p) <= 1) ? (&PCMSK3) : (((p) <= 5) ? (&PCMSK1) : (((p) <= 9) ? (&PCMSK3) : (((p) <= 13) ? (&PCMSK1) : (((p) <= 21) ? (&PCMSK0) : (((p) <= 29) ? (&PCMSK2) : (((p) <= 31) ? (&PCMSK3) : ((uint8_t *)0))))))))
#define digitalPinToPCMSKbit(p) ifpin(p,digital_pin_to_pcint[p] & 0x7,0)

#define digitalPinToInterrupt(p)  ((p) == 6 ? 0 : ((p) == 7 ? 1 : ((p) == 2 ? 2 : NOT_AN_INTERRUPT)))

#ifdef ARDUINO_MAIN

#define PA 1
#define PB 2
#define PC 3
#define PD 4

const uint8_t digital_pin_to_pcint[NUM_DIGITAL_PINS] =
{
  24, // D0  PD0
  25, // D1  PD1 1
  10, // D2  PB2
  11, // D3  PB3
  8,  // D4  PB0
  9,  // D5  PB1 5
  26, // D6  PD2
  27, // D7  PD3
  29, // D8  PD5
  30, // D9  PD6 9
  12, // D10 PB4
  13, // D11 PB5
  14, // D12 PB6
  15, // D13 PB7 13
  7,  // D14 PA7
  6,  // D15 PA6
  5,  // D16 PA5
  4,  // D17 PA4
  3,  // D18 PA3
  2,  // D19 PA2
  1,  // D20 PA1
  0,  // D21 PA0 21
  16, // D22 PC0
  17, // D23 PC1
  18, // D24 PC2
  19, // D25 PC3
  20, // D26 PC4
  21, // D27 PC5
  22, // D28 PC6
  23, // D29 PC7 29
  28, // D30 PD4
  31  // D31 PD7 31
};

// these arrays map port names (e.g. port B) to the
// appropriate addresses for various functions (e.g. reading
// and writing)
const uint16_t PROGMEM port_to_mode_PGM[] =
{
    NOT_A_PORT,
    (uint16_t) &DDRA,
    (uint16_t) &DDRB,
    (uint16_t) &DDRC,
    (uint16_t) &DDRD,
};

const uint16_t PROGMEM port_to_output_PGM[] =
{
    NOT_A_PORT,
    (uint16_t) &PORTA,
    (uint16_t) &PORTB,
    (uint16_t) &PORTC,
    (uint16_t) &PORTD,
};

const uint16_t PROGMEM port_to_input_PGM[] =
{
    NOT_A_PORT,
    (uint16_t) &PINA,
    (uint16_t) &PINB,
    (uint16_t) &PINC,
    (uint16_t) &PIND,
};

const uint8_t PROGMEM digital_pin_to_port_PGM[] =
{
  PD, // D0
  PD, // D1
  PB, // D2
  PB, // D3
  PB, // D4
  PB, // D5
  PD, // D6
  PD, // D7
  PD, // D8
  PD, // D9
  PB, // D10
  PB, // D11
  PB, // D12
  PB, // D13
  PA, // D14
  PA, // D15
  PA, // D16
  PA, // D17
  PA, // D18
  PA, // D19
  PA, // D20
  PA, // D21
  PC, // D22
  PC, // D23
  PC, // D24
  PC, // D25
  PC, // D26
  PC, // D27
  PC, // D28
  PC, // D29
  PD, // D30
  PD, // D31
};

const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
{
  _BV(0), // D0  PD0
  _BV(1), // D1  PD1
  _BV(2), // D2  PB2
  _BV(3), // D3  PB3
  _BV(0), // D4  PB0
  _BV(1), // D5  PB1
  _BV(2), // D6  PD2
  _BV(3), // D7  PD3
  _BV(5), // D8  PD5
  _BV(6), // D9  PD6
  _BV(4), // D10 PB4
  _BV(5), // D11 PB5
  _BV(6), // D12 PB6
  _BV(7), // D13 PB7
  _BV(7), // D14 PA7 (A0)
  _BV(6), // D15 PA6 (A1)
  _BV(5), // D16 PA5 (A2)
  _BV(4), // D17 PA4 (A3)
  _BV(3), // D18 PA3 (A4)
  _BV(2), // D19 PA2 (A5)
  _BV(1), // D20 PA1 (A6)
  _BV(0), // D21 PA0 (A7)
  _BV(0), // D22 PC0
  _BV(1), // D23 PC1
  _BV(2), // D24 PC2
  _BV(3), // D25 PC3
  _BV(4), // D26 PC4
  _BV(5), // D27 PC5
  _BV(6), // D28 PC6
  _BV(7), // D29 PC7
  _BV(4), // D30 PD4
  _BV(7), // D31 PD7
};

const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
{
  NOT_ON_TIMER, // D0  PD0
  NOT_ON_TIMER, // D1  PD1
  NOT_ON_TIMER, // D3  PB2
  TIMER0A,      // D3  PB3
  NOT_ON_TIMER, // D4  PB0
  NOT_ON_TIMER, // D5  PB1
  NOT_ON_TIMER, // D6  PD2
  NOT_ON_TIMER, // D7  PD3
  TIMER1A,      // D8  PD5
  TIMER2B,      // D9  PD6
  TIMER0B,      // D10 PB4
  NOT_ON_TIMER, // D11 PB5
  TIMER3A,      // D12 PB6
  TIMER3B,      // D13 PB7
  NOT_ON_TIMER, // D14 PA0
  NOT_ON_TIMER, // D15 PA1
  NOT_ON_TIMER, // D16 PA2
  NOT_ON_TIMER, // D17 PA3
  NOT_ON_TIMER, // D18 PA4
  NOT_ON_TIMER, // D19 PA5
  NOT_ON_TIMER, // D20 PA6
  NOT_ON_TIMER, // D21 PA7
  NOT_ON_TIMER, // D22 PC0
  NOT_ON_TIMER, // D23 PC1
  NOT_ON_TIMER, // D24 PC2
  NOT_ON_TIMER, // D25 PC3
  NOT_ON_TIMER, // D26 PC4
  NOT_ON_TIMER, // D27 PC5
  NOT_ON_TIMER, // D28 PC6
  NOT_ON_TIMER, // D29 PC7
  TIMER1B,      // D30 PD4
  TIMER2A,      // D31 PD7
};

#endif // ARDUINO_MAIN

#endif // Pins_Arduino_h
// vim:ai:cin:sts=2 sw=2 ft=cpp

Open the IDE and your board should be listed.  It should compile with a blank sketch.  I did not test further than that.
MCUDude MightyCore
Your board could also likely be made to work with MCUdude MightyCore.  However, MightyCore will not have your pin mapping.  So, although you could use it, you would need to ignore the normal UNO pin labeling and instead of work out which pin number used by the chosen MightyCore variant routes to which pin on the UNO headers.  It would be annoying to do, but you could do that by comparing entries in your adapter's pins_arduino.h file with the entries in the chosen variant from the MightCore package.  But, the modifications above seem to work fine.  So, I don't necessarily suggest that route; I'm just saying it could be used that way also.
MightyCore could also be modified, but that works out to the same or more work than just using your board definition, I think.


text:
ESP32 and the Microsoft Azure Device Provisioning Service
I am currently experimenting the the ESP32. In general connecting to WLAN and also to the Microsoft Azure IoT Hub works fine. But unfortunately i coulnt find any information on using the ESP32 with the Microsoft Azure Device Provisioning Service. That means connecting and registering an ESP32 to the Microsoft Azure IoT Hub with a certificate.
Has anyone did this before? Maybe some guiding links etc.?

a Google search returns what appear to be valid examples ... what search terms did you use?

"esp32 azure device provisioning service" was my search

that's close to what i searched and found this https://docs.microsoft.com/en-us/samples/azure-samples/esp32-iot-devkit-get-started/sample/

Thank you, but i know this page and this is only about "Starting with ESP32 and the IoT Hub" in VS Code. Thats not what i am looking for. Sorry.

You can open an issue in https://github.com/Azure/azure-iot-arduino to ask I guess, if that's the ilbrary you're using for connecting. Microsoft people should know their products best.


text:
Having trouble with MPU6050 and AFE4404 printing together, potential conflict?
I am having trouble getting the two sensors to work together. There are a total of four sensors connected to the Arduino, and while the MPU and AFE individually work fine with the other two sensors, when the two are put together only the Serial Plotter for the AFE shows up while the MPU stays at zero. I initially assumed that there were address conflicts with the two, but their i2c addresses are different: the AFE at 0x58 and the MPU at 0x68 or 0x69. How can I resolve the issue so that I can get all four sensors' graphs printing?
Below is my Arduino code:
#include "I2Cdev.h"
#include "MPU6050.h"
#include "Wire.h"

//int preValue = 0;
String str = "0, 0, 0, 0";
int mic = A0;
MPU6050 mpu;
int16_t ax, ay, az;

//PPG Stuff
#define NUM_REGISTERS       40
/* Pinbelegung */

int RESETZ = 4;
int CLK = 5;
int INT = 6;
//const int ocr1aval = 1; //||0 = 8MHz|| 1 = 4MHz|| 3 = 2MHZ ||7 = 1MHz||
const byte interruptPin = 2;

char LED2 = 0x2A; // LED2 on AFE4404

struct Register {
  uint8_t addr;
  uint32_t val;
};
/* Variablendeklaration */

//float befehl = 0;
bool Ready = 1;
int AFE_ADDR = 0x58;

unsigned long counter = 0;

/* AFE440X registers */

#define AFE_CONTROL0                0x00
#define AFE_LED2STC                 0x01
#define AFE_LED2ENDC                0x02
#define AFE_LED1LEDSTC              0x03
#define AFE_LED1LEDENDC             0x04
#define AFE_ALED2STC                0x05
#define AFE_ALED2ENDC               0x06
#define AFE_LED1STC                 0x07
#define AFE_LED1ENDC                0x08
#define AFE_LED2LEDSTC              0x09
#define AFE_LED2LEDENDC             0x0A
#define AFE_ALED1STC                0x0B
#define AFE_ALED1ENDC               0x0C
#define AFE_LED2CONVST              0x0D
#define AFE_LED2CONVEND             0x0E
#define AFE_ALED2CONVST             0x0F
#define AFE_ALED2CONVEND            0x10
#define AFE_LED1CONVST              0x11
#define AFE_LED1CONVEND             0x12
#define AFE_ALED1CONVST             0x13
#define AFE_ALED1CONVEND            0x14
#define AFE_ADCRSTSTCT0             0x15
#define AFE_ADCRSTENDCT0            0x16
#define AFE_ADCRSTSTCT1             0x17
#define AFE_ADCRSTENDCT1            0x18
#define AFE_ADCRSTSTCT2             0x19
#define AFE_ADCRSTENDCT2            0x1A
#define AFE_ADCRSTSTCT3             0x1B
#define AFE_ADCRSTENDCT3            0x1C
#define AFE_PRPCOUNT                0x1D
#define AFE_CONTROL1                0x1E
#define AFE_TIA_GAIN_SEP            0x20
#define AFE_TIA_GAIN                0x21
#define AFE_LEDCNTRL                0x22
#define AFE_CONTROL2                0x23
#define AFE_ALARM                   0x29
#define AFE_LED2VAL                 0x2A
#define AFE_ALED2VAL                0x2B
#define AFE_LED1VAL                 0x2C
#define AFE_ALED1VAL                0x2D
#define AFE_LED2_ALED2VAL           0x2E
#define AFE_LED1_ALED1VAL           0x2F
#define AFE_CONTROL3                0x31
#define AFE_PDNCYCLESTC             0x32
#define AFE_PDNCYCLEENDC            0x33
#define AFE_PROG_TG_STC             0x34
#define AFE_PROG_TG_ENDC            0x35
#define AFE_LED3LEDSTC              0x36
#define AFE_LED3LEDENDC             0x37
#define AFE_CLKDIV_PRF              0x39
#define AFE_OFFDAC                  0x3A
#define AFE_DEC                     0x3D
#define AFE_AVG_LED2_ALED2VAL       0x3F
#define AFE_AVG_LED1_ALED1VAL       0x40

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

  //ECG
  pinMode(10, INPUT); // Setup for leads off detection LO +
  pinMode(11, INPUT); // Setup for leads off detection LO -

  //PCG
  /*none needed*/

  //PPG
  pinMode(RESETZ, OUTPUT);
  pinMode(CLK, OUTPUT);
  pinMode(INT, INPUT);
  AFE_Init();

  //SCG
  #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
        Wire.begin();
  #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
        Fastwire::setup(400, true);
  #endif
  // initialize device
  mpu.initialize();
}

void PCG_Init()
{
  double micOut;
  const int sampleTime = 50;
  double preValue = 0;
}

void loop() {
  // put your main code here, to run repeatedly:
  String ECG = "0";
  //String SCG = "0";

  int PCG_val;
  String PCG;
  PCG_val = PCG_loop();
  PCG = String(PCG_val);

  int PPG_val;
  String PPG;
  PPG_val = PPG_loop() * -1;
  PPG = String(PPG_val);

//  int ECG_val;
//  String ECG;
//  ECG_val = ECG_loop();
//  ECG = String(ECG_val);

  int SCG_val;
  String SCG;
  SCG_val = SCG_loop();
  SCG = String(SCG_val);

  str = PCG + "," + PPG + "," + ECG + "," + SCG;
  Serial.println(str);
  delay(10);
}

//ECG Loop
int ECG_loop() {
  // put your main code here, to run repeatedly:
  if((digitalRead(10) == 1)||(digitalRead(11) == 1)){
  Serial.println('!');
  }
  else{
  // send the value of analog input 0:
  Serial.println(analogRead(A1));
  }
  //Wait for a bit to keep serial data from saturating
  delay(1);
  //delay (30);
}

//SCG Loop
int SCG_loop() {
    mpu.getAcceleration(&ax, &ay, &az);
    Serial.println(az/(pow(2,9)*1.0));
}

//PCG Loop
int PCG_loop() {
  //switch
  //case 1:
  int returnfill;
   double micOutput = findPTPAmp();
   returnfill = VUMeter(micOutput);
   return returnfill;
}

// Find the Peak-to-Peak Amplitude Function
double findPTPAmp(){
// Time variables to find the peak-to-peak amplitude
   unsigned long startTime= millis();  // Start of sample window
   /*unsigned int*/ double PTPAmp = 0;

// Signal variables to find the peak-to-peak amplitude
   /*unsigned int*/ double maxAmp = 0;
   /*unsigned int*/ double minAmp = 1023;

// Find the max and min of the mic output within the 50 ms timeframe
   while(millis() - startTime < sampleTime)
   {
      micOut = analogRead(mic);
      if( micOut < 1023) //prevent erroneous readings
      {
        if (micOut > maxAmp)
        {
          maxAmp = micOut; //save only the max reading
        }
        else if (micOut < minAmp)
        {
          minAmp = micOut; //save only the min reading
        }
      }
   }

  PTPAmp = maxAmp - minAmp; // (max amp) - (min amp) = peak-to-peak amplitude
  double micOut_Volts = (PTPAmp * 3.3) / 1024; // Convert ADC into voltage
  return PTPAmp;
}

// Volume Unit Meter function: map the PTP amplitude to a volume unit between 0 and 10.
int VUMeter(double micAmp){
  double fill = map(micAmp, 23, 750, 0, 10);
  while(fill != preValue)
  {
    preValue = fill;
  }
  return fill;
}

//PPG Loop
signed long val = 0;
void readADC()
{
  {
    val = AFE_Reg_Read(LED2);
    Ready = 1;
  }
}

int PPG_loop() {
  if (digitalRead(INT))
  {
    val = AFE_Reg_Read(LED2);
  }
  return val;
}

//More PPG Stuff
void AFE_Init()
{
  AFE_RESETZ_Init();
  AFE_Enable_HWPDN();
  AFE_Disable_HWPDN();
  AFE_Trigger_HWReset();
  Wire.begin();
  Wire.beginTransmission (AFE_ADDR);
  Serial.println("Initializing AFE4404...");
  if (Wire.endTransmission () == 0)
  {
    AFE_Enable_Write (); // enable to writting to registers
    AFE_Reg_Init();
    AFE_CLK_Init();
    AFE_Enable_Read ();  // enable to reading from registers
    Serial.println("Initialized Success!");
  }
  else
    Serial.println("Initialized Fail!");

}

/**********************************************************************************************************/
/*                              AFE4404_Registerinitialisierung                                           */
/**********************************************************************************************************/
void AFE_Reg_Init()
{
  //AFE_Reg_Write(34, 0x0033C3);
  AFEinitRegisters();
}

/**********************************************************************************************************/
/*                              AFE4404_Enable_Read                                                       */
/**********************************************************************************************************/
void AFE_Enable_Read ()         //Prohibit writing to registers
{
  byte configData[3];
  configData[0] = 0x00;
  configData[1] = 0x00;
  configData[2] = 0x01;// 0x01
  I2C_write (AFE_ADDR, AFE_CONTROL0, configData, 3);
}

/**********************************************************************************************************/
/*                              AFE4404_Disable_Read                                                      */
/**********************************************************************************************************/
void AFE_Enable_Write ()        //Permitt writing to registers
{
  byte configData[3];
  configData[0] = 0x00;
  configData[1] = 0x00;
  configData[2] = 0x00; //0x00
  I2C_write (AFE_ADDR, AFE_CONTROL0, configData, 3);
}

/**********************************************************************************************************/
/*                  RESETZ des AFE4404 wird Initialisiert                                                 */
/**********************************************************************************************************/
void AFE_RESETZ_Init()
{
  digitalWrite(RESETZ, HIGH);
  delayMicroseconds(30);
}

/**********************************************************************************************************/
/*                  Reset internal registers by setting RESETZ = LOW for 25 - 50 us                       */
/**********************************************************************************************************/
void AFE_Trigger_HWReset()
{
  digitalWrite(RESETZ, LOW);              //Sets Arduino pins 22-29 LOW
  delayMicroseconds(30); //30
  digitalWrite(RESETZ, HIGH);              //Sets Arduino pins 22-29 HIGH
  delay(10); // 10
}

/**********************************************************************************************************/
/*                             AFE4404 Power Down                                                         */
/**********************************************************************************************************/
void  AFE_Enable_HWPDN()
{
  digitalWrite(RESETZ, LOW);                  //Power Down by setting the RESETZ pin to LOW for more than 200 us
  delay(10);
}

/**********************************************************************************************************/
/*                                AFE4404 Power Up                                                        */
/**********************************************************************************************************/
void  AFE_Disable_HWPDN()
{
  digitalWrite(RESETZ, HIGH);                  //Power Up the AFE by setting the RESETZ pin to HIGH
  delay(10);
}

/**********************************************************************************************************/
/*                                AFE4404 Set Clock Mode to Internal                                      */
/**********************************************************************************************************/

void AFE_CLK_Init()
{
  AFE_Reg_Write(35, 0x104218);        //Set CLK Mode to internal clock (default Wert: 124218 mit interner CLK)
  AFE_Reg_Write(41, 0x2);             //Don´t set the internal clock to the CLK pin for outside usage
  AFE_Reg_Write(49, 0x000021);        //Division ratio for external clock mode set to fit the Arduino Mega 16MHz
  AFE_Reg_Write(57, 0);               //Set the lowes sampling rate to 61Hz (~17 ms)
}

/*********************************************************************************************************/
/*                                   AFE4404_Reg_Write                                                   */
/*********************************************************************************************************/
void AFE_Reg_Write (int reg_address, unsigned long data)
{
  byte configData[3];
  configData[0] = (byte)(data >> 16);
  configData[1] = (byte)(((data & 0x00FFFF) >> 8));
  configData[2] = (byte)(((data & 0x0000FF)));
  I2C_write(AFE_ADDR, reg_address, configData, 3);
}

/*********************************************************************************************************/
/*                                   AFE4404_Reg_Read                                                    */
/*********************************************************************************************************/
signed long AFE_Reg_Read(int reg_address)
{
  byte configData[3];
  signed long retVal;
  I2C_read (AFE_ADDR, reg_address, configData, 3);
  retVal = configData[0];
  retVal = (retVal << 8) | configData[1];
  retVal = (retVal << 8) | configData[2];
  if (reg_address >= 0x2A && reg_address <= 0x2F)
  {
    if (retVal & 0x00200000)  // check if the ADC value is positive or negative
    {
      retVal &= 0x003FFFFF;   // convert it to a 22 bit value
      return (retVal ^ 0xFFC00000);
    }
  }
  return retVal;
}

/**********************************************************************************************************/
/*                              Write to AFE on I2C                                                       */
/**********************************************************************************************************/
char I2C_write (int slave_address, int reg_address, byte configData[], int byteCount)
{
  int trans_end = 0;
  signed long retVal;

  Wire.beginTransmission(slave_address);
  Wire.write(reg_address);
  Serial.print(configData[0]);
  Serial.print(",");
  Serial.print(configData[1]);
  Serial.print(",");
  Serial.println(configData[2]);
  retVal = configData[0];
  retVal = (retVal << 8) | configData[1];
  retVal = (retVal << 8) | configData[2];
  Serial.println(retVal);
  Serial.println(reg_address);
  Wire.write(configData, 3);
  Serial.println("test");
  Wire.endTransmission();
  return (trans_end);

  /* while(1)
    {
     if(byteCount == 0)
     {
       Wire.endTransmission();
       Serial.println("test");
       return (trans_end);
     }else{
       //unsigned int reg_data = (unsigned int) *write_data++;
       Wire.write(configData, 3);
       byteCount--;
     }
    }*/
}

/**********************************************************************************************************/
/*                              Read Data of AFE on I2C                                                   */
/**********************************************************************************************************/
char I2C_read(int slave_address, int reg_address, byte *read_Data, int byteCount)
{
  int trans_end = 0;

  Wire.beginTransmission(slave_address);
  Wire.write(reg_address);
  Wire.endTransmission();
  Wire.requestFrom(slave_address, 3);
  while (Wire.available() && (byteCount != 0))
  {
    *read_Data++ = Wire.read();
    byteCount--;
  }
  return (trans_end);
}

void AFEinitRegisters(void) {

  unsigned char i;
  struct Register reg[NUM_REGISTERS];
  reg[0].addr = 0x01; reg[0].val = 0x000050;
  reg[1].addr = 0x02; reg[1].val = 0x00018F;
  reg[2].addr = 0x03; reg[2].val = 0x000320;
  reg[3].addr = 0x04; reg[3].val = 0x0004AF;
  reg[4].addr = 0x05; reg[4].val = 0x0001E0;
  reg[5].addr = 0x06; reg[5].val = 0x00031F;
  reg[6].addr = 0x07; reg[6].val = 0x000370;
  reg[7].addr = 0x08; reg[7].val = 0x0004AF;
  reg[8].addr = 0x09; reg[8].val = 0x000000;
  reg[9].addr = 0x0A; reg[9].val = 0x00018F;
  reg[10].addr = 0x0B; reg[10].val = 0x0004FF;
  reg[11].addr = 0x0C; reg[11].val = 0x00063E;
  reg[12].addr = 0x0D; reg[12].val = 0x000198;
  reg[13].addr = 0x0E; reg[13].val = 0x0005BB;
  reg[14].addr = 0x0F; reg[14].val = 0x0005C4;
  reg[15].addr = 0x10; reg[15].val = 0x0009E7;
  reg[16].addr = 0x11; reg[16].val = 0x0009F0;
  reg[17].addr = 0x12; reg[17].val = 0x000E13;
  reg[18].addr = 0x13; reg[18].val = 0x000E1C;
  reg[19].addr = 0x14; reg[19].val = 0x00123F;
  reg[20].addr = 0x15; reg[20].val = 0x000191;
  reg[21].addr = 0x16; reg[21].val = 0x000197;
  reg[22].addr = 0x17; reg[22].val = 0x0005BD;
  reg[23].addr = 0x18; reg[23].val = 0x0005C3;
  reg[24].addr = 0x19; reg[24].val = 0x0009E9;
  reg[25].addr = 0x1A; reg[25].val = 0x0009EF;
  reg[26].addr = 0x1B; reg[26].val = 0x000E15;
  reg[27].addr = 0x1C; reg[27].val = 0x000E1B;
  reg[28].addr = 0x1D; reg[28].val = 0x009C3F;
  reg[29].addr = 0x1E; reg[29].val = 0x000103;
  reg[30].addr = 0x20; reg[30].val = 0x008025; //0x008003
  reg[31].addr = 0x21; reg[31].val = 0x000125;//0x000003 //bit8: PROG_TG_EN
  reg[32].addr = 0x22; reg[32].val = 0x000100;//ILED2 = 32
  reg[33].addr = 0x23; reg[33].val = 0x000000;
  reg[34].addr = 0x32; reg[34].val = 0x00155F;
  reg[35].addr = 0x33; reg[35].val = 0x00991F;
  reg[36].addr = 0x36; reg[36].val = 0x000190;
  reg[37].addr = 0x37; reg[37].val = 0x00031F;
  reg[38].addr = 0x34; reg[38].val = 0x001563;
  reg[39].addr = 0x35; reg[39].val = 0x00991F;

  for (i = 0; i < NUM_REGISTERS; i++)
    AFE_Reg_Write(reg[i].addr, reg[i].val);

}

I am plotting each of the four sensors on LabView. Any help would be much appreciated!

You never change ECG to anything from 0, so of course it's always zero.

I don't even know where to begin with this program. It's such a mess I don't think it's salvageable. You should learn some basic C syntax before you start programming.

Troubleshooting I2C issues can be frustrating.  In order to figure out the problem, I recommend you construct the simplest possible Arduino sketch, using just the two sensors that seem to have a problem working together.  You should be able to write a very simple program that does nothing but acquire a simple value from each sensor, say 2 times/second.
Once you have the simplest possible program running, you should be able to figure it out.  Right now all your program complexity is making it harder than it needs to be.
Good luck!
Frank


text:
Arduino Ultrasonic Sensor AnalogRead
i have an ultrasonic sensor. The sensor normally works stably. But I have to carry the data cables of this sensor for 50 meters and take reading. When i do this, when I extend the cable, the values I get from the sensor are not read stably.
I need to raise the sensor voltage so I can fix this problem, how can you help me?

Can you put another Arduino next to the Ultrasonic Sensor and connect them both over WiFi/BT or a radio module?

you'll need an interconnection designed to span such distances, like ethernet, wifi,  rs485, etc.

I take a value between 0-5 Volts according to the distance. I want to increase these values from 0-5 Volts linearly to 10-15 Volts. How can I do that?

Sounds like an XY problem: increasing the voltage will not "fix" the problem, it will only slightly improve performance. But only if you amplify the signal. Shifting 0-5V to 10-15V will do nothing! You just shouldn't transmit an analog voltage over such a long distance. You'd better transmit a 4-20mA signal or even better choose a suitable digital interface

All ultrasonic distance sensors, that I have seen so far, don't output an analog voltage. What sensor do you have?

What kind of sensor ? Pulse output ? Serial output ? Only extend data cables ?


text:
esp32s: error: 'WDT_TIMEOUT' was not declared in this scope
I am trying to initialize the watchdog timer.
I have installed
arduino-esp32-master.zip

I have
#include <esp_task_wdt.h>

set but it is not highlighted red indicating the IDE knows about it.
The error indicates that a major function is not present.
full error:
Arduino: 1.8.13 (Linux), TD: 1.53, Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 115200, None"

/home/brad/Documents/bradcode/Arduino/esp32s-infrared-ac-wifi-server-v4/esp32s-infrared-ac-wifi-server-v4.ino: In function 'void setup()':
esp32s-infrared-ac-wifi-server-v4:229:23: error: 'WDT_TIMEOUT' was not declared in this scope
     esp_task_wdt_init(WDT_TIMEOUT, true); //enable panic so ESP32 restarts
                       ^
Multiple libraries were found for "IRremote.h"
 Used: /home/brad/Documents/bradcode/Arduino/libraries/IRremote
 Not used: /home/brad/Documents/bradcode/Arduino/libraries/Arduino-IRremote-master
 Not used: /home/brad/Documents/bradcode/Arduino/libraries/IRremote-2.8.1
Multiple libraries were found for "WiFi.h"
 Used: /home/brad/.arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WiFi
 Not used: /home/brad/Downloads/arduino-1.8.13/libraries/WiFi
 Not used: /home/brad/Documents/bradcode/Arduino/libraries/WiFiEspAT
exit status 1
'WDT_TIMEOUT' was not declared in this scope

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

What library did I fail to install to get the watchdog timer initialized?
UPDATE:
My additional boards URLs
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json,http://arduino.esp8266.com/stable/package_esp8266com_index.json

After following recommendations for poster, I got past that error and hit another one right away.
Arduino: 1.8.13 (Linux), TD: 1.53, Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 115200, None"

In file included from /home/brad/Documents/bradcode/Arduino/esp32s-infrared-ac-wifi-server-v4/esp32s-infrared-ac-wifi-server-v4.ino:24:0:
/home/brad/.arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WebServer/src/WebServer.h: In member function 'virtual size_t WebServer::_currentClientWrite_P(const char*, size_t)':
/home/brad/.arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WebServer/src/WebServer.h:144:83: error: 'class WiFiClient' has no member named 'write_P'
   virtual size_t _currentClientWrite_P(PGM_P b, size_t l) { return _currentClient.write_P( b, l ); }
                                                                                ^
/home/brad/Documents/bradcode/Arduino/esp32s-infrared-ac-wifi-server-v4/esp32s-infrared-ac-wifi-server-v4.ino: In function 'void setup()':
esp32s-infrared-ac-wifi-server-v4:246:10: error: 'class WiFiClass' has no member named 'mode'
     WiFi.mode(WIFI_STA);
          ^
esp32s-infrared-ac-wifi-server-v4:246:15: error: 'WIFI_STA' was not declared in this scope
     WiFi.mode(WIFI_STA);
               ^
esp32s-infrared-ac-wifi-server-v4:251:73: error: no matching function for call to 'WiFiClass::config(IPAddress&, IPAddress&, IPAddress&, IPAddress&, IPAddress&)'
     if (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS)) {
                                                                         ^
In file included from /home/brad/Documents/bradcode/Arduino/esp32s-infrared-ac-wifi-server-v4/esp32s-infrared-ac-wifi-server-v4.ino:22:0:
/home/brad/Documents/bradcode/Arduino/libraries/WiFiEspAT/src/WiFi.h:72:8: note: candidate: bool WiFiClass::config(IPAddress, IPAddress, IPAddress, IPAddress)
   bool config(IPAddress local_ip, IPAddress dns_server = INADDR_NONE, IPAddress gateway = INADDR_NONE, IPAddress subnet = INADDR_NONE);
        ^
/home/brad/Documents/bradcode/Arduino/libraries/WiFiEspAT/src/WiFi.h:72:8: note:   candidate expects 4 arguments, 5 provided
Multiple libraries were found for "IRremote.h"
 Used: /home/brad/Documents/bradcode/Arduino/libraries/IRremote
 Not used: /home/brad/Documents/bradcode/Arduino/libraries/IRremote-2.8.1
 Not used: /home/brad/Documents/bradcode/Arduino/libraries/Arduino-IRremote-master
exit status 1
'class WiFiClass' has no member named 'mode'

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

I have some library mixed up still

What do you mean you have "installed" arduino-esp32-master.zip? You don't install these things - you put the JSON URL in the preferences and install the board definitions using the boards manager.

@Majenko
I updated the post with my URLs. I should have the correct ones already loaded.

There is no such macro in the ESP32 core. That parameter is just the number of seconds before a timeout occurs. Just pick a reasonable value. 5 seconds seems to be a commonly used (and appears to be used in the core) value.

setting the variable the line above caused the same error. So I deleted the variable all together and just plugged in the number 5. Now I am at a new error.  'class WiFiClass' has no member named 'mode'. I still have some library all messed up.

I have multiple wifi.h libraries as indicated in the errors posted. I just tried a different one and got past that other new error. Now I'm golden.


text:
MAX471 giving too high current readings
I want to measure current using the MAX471 sensor that outputs voltage proportional to the current (1V/A according to the datasheet). To test the module, I connected a 330 ohm resistor to the sensor and powered it from 3.3V arduino. Using ohms law, I was expecting an output voltage of around 10 mV (for ~ 10 mA) in my circuit. However, I am getting an output of around 2.17 volts which seems wrong.
Does anyone see any mistake in my circuit or how I am trying to measure the current?
Here is my circuit:

My Code:
#include <Arduino.h>

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

void loop()
{
  int adc_val = analogRead(A5);
  float vol = 3.2 / 4095 * adc_val; // using a 12 bit adc

  Serial.println(vol);
  delay(3000);
}

Where is your current shunt resistor?

@timemage inside the MAX471: "The MAX471 has an internal 35mΩ current-sense resistor and measures battery currents up to ±3A. "

@dandavis, interesting.  I've not seen that done before with these.

@dandavis it's actually an ESP32 but I only found arduino uno as the only microcontroller in the schematic software. That's why it says 12 bit ADC

That's actually a completely different beast, and make sure you compensate for YOUR ESP32's ADC's unique response curves. If you have a SMU you can easily calibrate this, but you can also do it using a reliable current source, a high-precision resistor, and a pair of off-the-shelf DMMs.

@dandavis you are right about the nonlinearity in ESP32's response so I have also compared it to ADS1115 which is 16 bit ADC. I still get around 2.2V as output. This is too high i.e. 2.2 A of current (considering 1A/V as stated in the datasheet)

the ADS1115 measures voltage, not current. 2.2 makes no sense, it should be dang close (~1%) to 0 or 3.3v. Are you really omitting the 2k output pulldown shown in the MAX471's datasheet?

It's not a bare sensor rather it's a module [like this] (https://www.aliexpress.com/item/4000045481675.html?spm=a2g0o.productlist.0.0.1c3718b2OUADuF&algo_pvid=e642e394-a894-4408-a48a-fcb926c21c51&algo_expid=e642e394-a894-4408-a48a-fcb926c21c51-0&btsid=0b0a556616139293222028857e2f2a&ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_). There is a 2k resistor which I suppose serves as a pulldown resistor for Vout.

According to the datasheet " In the MAX471, the current-gain ratio has been preset to 500µA/A so that an output resistor (ROUT) of 2kΩ yields 1V/A for a full-scale value of +3V at ±3A." So I believe I don't need to divide the Vout by anything. Whatever the Vout is it will be equal to current in the circuit. Are you also suggesting to divide by 2000 in my calculations?

Do you have the same operating circuit that is shown on page 1 of the datasheet? do you have the 2K resistor they specifically from OUT to ground? Also, it may be worth adding the 1 uF capacitor they recommend from OUT to ground too
The other thing to consider is the actual voltage over the resistor. Check an see if the voltage over the resistor is 3.3 and that there isn't a voltage drop from the chip
If the voltage is fine, there may be a problem with the chip or the arduino

I've got a few MAX471 modules and instead of current readings i get around 90% of input voltage on all of them.
With increasing load the output voltage decreases a bit and the MAX471 chip gets very hot (for example 12V 0mAh = 10V, 12V 200mAh = 9,6V).
I guess we are just "lucky" to get a bad batch or counterfeit chips...


text:
Stepper motor won't change directions!
I am driving a bipolar stepper motor with an a4988 driver using the AccelStepper library. My goal is to press a button and the motor moves CW, then another button for CCW.
I have looked at another post with a very similar issue, but the solution does not seem to apply well to the AccelStepper library, which I would really like to use given its versatility.
Currently, whichever button I press, the motor moves CCW. Any help would be greatly appreciated!
#include <AccelStepper.h>
AccelStepper stepperX(1, 3, 2);

void setup() {
  pinMode(8, INPUT)
  pinMode(9, INPUT);

  stepperX.setMaxSpeed(100.0);
  stepperX.setAcceleration(100.0);
}

int moveRight = 1000;              //arbitrarily high number
int moveLeft = -1000;              //arbitrarily low number

void loop() {
  while (digitalRead(8) == HIGH) { //when d8 button is pressed move left
    stepperX.moveTo(moveLeft);     //set move
    if (digitalRead(8) == LOW) {   //if not pressed, kill loop
      stepperX.stop();
      break;
    }
    stepperX.run();
  }

  while (digitalRead(9) == HIGH) { //when d9 button is pressed move right
    stepperX.moveTo(moveRight);    //set move
    if (digitalRead(9) == LOW) {   //if not pressed, kill loop
      stepperX.stop();
      break;
    }
    stepperX.run();
  }
}

start debugging by reducing you code to moving CW for one second ... stop for one second ... move CCW for one second ... stop for one second

You work with accelleration and absolute positions. Are you aware of that?
This Library is not made for running permanently in the same direction. It let you define a position where the movement should end, an acceleration or speed and the controller moves the motor to that position.
The run method must be called permanently, It triggers the steps. So, I put it directly into the loop() method.
The following prog should hopefully move the motor towards position 1000 if you press the 8-button, towards position -1000 if you press the 9-button and stops if both buttons are off. I have not the hardware available at the moment, you it's just blind programming. Use it as an idea.
#include <AccelStepper.h>
AccelStepper stepperX(1, 3, 2);

void setup()
{
  pinMode(8, INPUT)
  pinMode(9, INPUT);

  stepperX.setMaxSpeed(100.0);
  stepperX.setAcceleration(3.0);
}

int positivePosition = 1000;
int negativePosition = -1000;

void loop()
{
  if ( digitalRead(8) == HIGH )
  {
    stepperX.moveTo(positivePosition);
  }
  else if (digitalRead(9) == HIGH)
  {
    stepperX.moveTo(negativePosition);
  }
  else
  {
    stepperX.stop();
  }
  stepperX.run();
}


text:
Convert a char array to Flash string
I would like to pass a formatted string to a method that accepts a __FlashStringHelper. Here is the method signature:
void myMethod(const __FlashStringHelper *str);

I have been using snprintf to format my string:
char cmd[30];
snprintf(cmd, 30, "There are %d seconds in a minute", 60);
myMethod(F(&cmd[0]));

Clearly the above doesn't work but how can I format a Flash String?
EDIT: I need to include an integer variable in my flash string. In the example above, '60' is a variable.
uint8_t nSeconds = 60;
char cmd[30];
snprintf(cmd, 30, "There are %d seconds in a minute", nSeconds);
myMethod(F(&cmd[0]));

Doesn't this method have an overload that accepts a const char*?

Direct answer
F() takes immutable string literals, that are known at compile time, and places them into flash ("PROGMEM") instead of RAM.  snprintf() creates strings at runtime and places them into a mutable array.  The two things are fundamentally incompatible.
Limited compile-time concatenation
A very limited form of what you're trying to do could probably done like this:
#define MY_STRINGIZE(x) #x

myMethod(F("There are " MY_STRINGIZE(60) " seconds in a minute"));

This expands to:
myMethod(F("There are " "60" " seconds in a minute"));

Adjacent string literals are concatenated together, which makes this:
myMethod(F("There are 60 seconds in a minute"));

All that said, you could just write 60 in there directly.  And there's none of snprintf's formatting capabilities possible here.
There is not a compile-time version of snprintf available in Arduino.  And I don't think the features of the C++ (or C) language are there to support the creation of one either.  Odds are there is a better way of achieving what you really want to do.
Working around this altogether
Often it's not necessary to concatenate strings at all, particularly if you're just to turn around and write them to a Stream, or more generally Print subclass, e.g. Serial, LCD, SDFile, SoftwareSerial, etc.  Concatenating things for you is a large part of what these do.  It is not necessarily to do it yourself in advance.
If you have a string literal and constant (or variable) and want to keep as much of it out of RAM as possible, using two separate .print()/.println() helps you do this:
printCapableThing.print(F("AT+CIPSTAT="));
printCapableThing.println(index);

F() places "AT+CIPSTAT=" into flash.
If index is a constant it will also wind not being resident in RAM.

Side note
I realize you're asking about, getting as much into flash as possible, but I also can't help but point out this same basic technique applies to this otherwise awful idea, for somewhat different reasons:
Serial.println(String(F("Key ")) + keyname + " : " + value);

This creates a horrific mess of allocations and deallocations and unnecessary copying, where if you just let the Stream/Print object do its job by calling print()/println() multiple times.  The result code is more reliable, smaller, and where not I/O-bound, faster when you do.

I guess what he really needs is not a compile-time version of snprintf (that would be quite useless), but a myMethod that takes a const char*.

I can absolutely see uses for compile-time string formatting.  Though yes, it probably will come down to the latter.

I mean you could be writing an implementation for snprintf(cmd, 30, F("There are %d seconds in a minute"), 60); (not hard to do with a temporary copy). But something like snprintf(F("..."), 30, F("Result is %d"), 60); cannot work, because the result of snprintf can certainly not be in flash.

You could, but you needn't.  There already exists an snprintf_P variant capable of taking the format string from PROGMEM.  You'd probably use PSTR there instead though. I'm not seeing the relevance of this though.

Thank you all for you responses!
@timemage: The '60 seconds in a minute' isn't my exact use case, my use case requires context which I tried to omit.
Mostly, I am trying to understand how I can format a string in program memory.

I can amend the answer if you have add more details to your question.  But, if I'm taking the question fairly literally, knowing that it is an example, is that there isn't a way to do that.  You can source parts of your ultimately cobbled-together string from flash/progmem.  But the result of formating will need to wind up in RAM.  Often it's not necessary to concatonate strings at all, particular if you're just to turn around and write them to a Stream (e.g. Serial, LCD, SDFile etc).

@timemage How can I use a variable inside a flash string? I added comments above. I need to issue an AT command to a GSM shield. The command requires an index variable. I could literally write out numerous methods to handle this, but for the sake of understanding how, I would prefer to write one method that accepts as input an integer (index) and issues the following command: AT+CIPSTAT={index}.
mySoftwareSerial->println(F("AT+CIPSTAT={index}"));

I could answer that, but there's something better which I alluded to above.  I'll amend the answer to what I'd suggest there instead.

Great answer, thanks @timemage!