text:
AD7768-1 library " Arduino "
I am working on a project and I need an AD7768-1 library to make this analog-digital-converter talk to my Arduino using SPI.
" The AD7768-1" doesn't exist in Arduino's library.
Thanks in advance.

There doesn't seem to be a ready to use Arduino library for this part. Though I found one for AD7705/6. If the parts are similar enough you might be able to make this library work with AD7768 with only few changes. Also AnalogDevices provides a no-OS code (general code for devices without an OS like microcontrollers), though you would need to find out how to use it and how to provide it with its needed SPI hardware routines. And depending on your project it might be easier to just write your own SPI code for it without a thirdparty library

please add a clear, answerable question to your post

At present, there is no Arduino library available for this device. As suggested by @chrisl, the easiest way to proceed would be to develop your own driver. However, if you wish to leverage all the advanced features of the device, you could use the drivers provided by Analog Devices. The AD7768-1 differs significantly from the AD7705/6!!!. Having personally interfaced with this device (and AD7768/AD7768-4) using STM32 microcontrollers and Xilinx FPGAs, I would recommend using the no-OS drivers provided by Analog Devices. This approach has worked well for me using an STM32:

Please read this article first: Understanding and Using the No-OS and Platform Drivers.
And this one:No-OS Overview.
Gather all the necessary files you would need from the Analog Devices Github repository no-OS:
Get AD7768-1 drivers from the "/drivers" folder.
Get Platform Drivers from "drivers/platform/". Since we are using STM32, then pick one of these three (STM32, MBED or Generic):/STM32: suitable for STM32CubeIDE or similar. I will use this one. MBED: for MBED platforms. Check this out AD7768-1 IIO Application. Generic: With this one, you need to fill-in platform peripheral calls manually (in the case of Arduino platforms, this would be something like SPI.beginTransaction, etc.).
All the associated source and header files are available in the same repository.
To simplify, I would assume you are using STM32CubeIDE and you just want to configure and read data from the device. Then,
Configure the STM32 Microcontroller as an SPI Master-Full-Duplex MODE 3 [MOSI, MISO, CLK].
Slave select PIN software-controlled [SS].
[Optional] One Pin for data-ready interrupts [DRDY].
Place the required source and header files in their respective
folders. At a minimum, you need (ad77681.c/h, no_os_spi.c,
stm32_spi.c, no_os_gpio.c, stm32_gpio.c) and all their linked header
files.
Initialize No-OS drivers and platform drivers. It would be
something like this:

struct stm32_spi_init_param stm32_init = {
      .chip_select_port = 1,
      .get_input_clock = &HAL_RCC_GetPCLK1Freq
  };

struct no_os_spi_init_param spi_init_param = {
      .device_id = 1,
      .max_speed_hz = 64000000,
      .chip_select = 6,
      .mode = NO_OS_SPI_MODE_3,
      .bit_order = NO_OS_SPI_BIT_ORDER_MSB_FIRST,
      .platform_ops = &stm32_spi_ops,
      .extra = &stm32_init ,
      .parent = NULL
  };

 struct ad77681_init_param ad77681_init = {
      .spi_eng_dev_init = spi_init_param,
      .power_mode = AD77681_MEDIAN,
      .mclk_div = AD77681_MCLK_DIV_8,
      .conv_mode = AD77681_CONV_CONTINUOUS,
      .diag_mux_sel = AD77681_AIN_SHORT,
      .conv_diag_sel = false,
      .conv_len = AD77681_CONV_24BIT,
      .crc_sel = AD77681_NO_CRC,
      .status_bit = 0,
      .VCM_out = AD77681_VCM_2_05V,
      .AINn = AD77681_AINn_ENABLED,
      .AINp = AD77681_AINp_ENABLED,
      .REFn = AD77681_BUFn_ENABLED,
      .REFp = AD77681_BUFp_ENABLED,
      .filter = AD77681_SINC5,
      .decimate = AD77681_SINC5_FIR_DECx32,
      .sinc3_osr = 0,
      .vref = AD77681_VOLTAGE_REF,
      .mclk = AD77681_MCLK,
      .sample_rate = AD77681_DEFAULT_SAMPLING_FREQ,
      .data_frame_byte = AD77681_DECIMATION_RATE,
  };

Finally setup the Device like this:

struct ad77681_dev *device = NULL;
struct ad77681_status_registers *status = NULL;
int32_t init_status = ad77681_setup(&device, ad77681_init, &status);

If the init_status is 0 then you’ve successfully initialized the device!! You would read data like this:

ad77681_spi_read_adc_data(device, data_buffer, AD77681_REGISTER_DATA_READ);

I hope this is helpful.


text:
Converting code for driver IC IL0373 to SSD1680
I'm working on epaper display, and writing code in Segger embedded studio for nRF52840DK.
Below is code for Driver IC IL0373 epaper display, has no response on paper display as it have driver IC SSD1680 here
Below paper.c
#include "paper.h"
#include <string.h>

#include "nrf_gpio.h"
#include "nrf_delay.h"
#include "nrf_drv_spi.h"

#define PAPER_RST_PIN 13
#define PAPER_DC_PIN  14

#define PAPER_SPI_INSTANCE 0
#define PAPER_SPI_SS_PIN   29
#define PAPER_SPI_MOSI_PIN 4
#define PAPER_SPI_SCK_PIN  3

#define PAPER_BYTE_WIDTH ((PAPER_PIXEL_WIDTH % 8 == 0) ? PAPER_PIXEL_WIDTH / 8 : PAPER_PIXEL_WIDTH / 8 + 1)
#define PAPER_BYTE_HEIGHT PAPER_PIXEL_HEIGHT
#define PAPER_BUFLEN PAPER_BYTE_WIDTH * PAPER_BYTE_HEIGHT

#define PAPER_CMD_PWR  0x01
#define PAPER_CMD_BTST 0x06
#define PAPER_CMD_PON  0x04
#define PAPER_CMD_PSR  0x00
#define PAPER_CMD_PLL  0x30
#define PAPER_CMD_TRES 0x61
#define PAPER_CMD_VDCD 0x82
#define PAPER_CMD_VCOM 0x50
#define PAPER_CMD_LUT_VCDC 0x20
#define PAPER_CMD_LUT_WW 0x21
#define PAPER_CMD_LUT_BW 0x22
#define PAPER_CMD_LUT_WB 0x23
#define PAPER_CMD_LUT_BB 0x24
#define PAPER_CMD_DISP 0x12

static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(PAPER_SPI_INSTANCE);

static uint8_t paper_cmd_pwr[] = {
  PAPER_CMD_PWR,
  0x03, 0x00, 0x2b, 0x2b, 0x03,
};

static uint8_t paper_cmd_btst[] = {
  PAPER_CMD_BTST,
  0x17, 0x17, 0x17,
};

static uint8_t paper_cmd_pon[] = {
  PAPER_CMD_PON,
};

static uint8_t paper_cmd_psr[] = {
  PAPER_CMD_PSR,
  0xbf, 0x0d,
};

static uint8_t paper_cmd_pll[] = {
  PAPER_CMD_PLL,
  0x3a,
};

static uint8_t paper_cmd_tres[] = {
  PAPER_CMD_TRES,
  PAPER_PIXEL_WIDTH,
  (PAPER_PIXEL_HEIGHT >> 8) & 0xff,
  PAPER_PIXEL_HEIGHT & 0xff,
};

static uint8_t paper_cmd_vdcd[] = {
  PAPER_CMD_VDCD,
  0x28,
};

static uint8_t paper_cmd_vcom[] = {
  PAPER_CMD_VCOM,
  0x97
};

static uint8_t paper_cmd_lut_vcdc[] = {
  PAPER_CMD_LUT_VCDC,
  0x00, 0x08, 0x00, 0x00, 0x00, 0x02,
  0x60, 0x28, 0x28, 0x00, 0x00, 0x01,
  0x00, 0x14, 0x00, 0x00, 0x00, 0x01,
  0x00, 0x12, 0x12, 0x00, 0x00, 0x01,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00,
};

static uint8_t paper_cmd_lut_ww[] = {
  PAPER_CMD_LUT_WW,
  0x40, 0x08, 0x00, 0x00, 0x00, 0x02,
  0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
  0x40, 0x14, 0x00, 0x00, 0x00, 0x01,
  0xA0, 0x12, 0x12, 0x00, 0x00, 0x01,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

static uint8_t paper_cmd_lut_bw[] = {
  PAPER_CMD_LUT_BW,
  0x40, 0x17, 0x00, 0x00, 0x00, 0x02,
  0x90, 0x0F, 0x0F, 0x00, 0x00, 0x03,
  0x40, 0x0A, 0x01, 0x00, 0x00, 0x01,
  0xA0, 0x0E, 0x0E, 0x00, 0x00, 0x02,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

static uint8_t paper_cmd_lut_wb[] = {
  PAPER_CMD_LUT_WB,
  0x80, 0x08, 0x00, 0x00, 0x00, 0x02,
  0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
  0x80, 0x14, 0x00, 0x00, 0x00, 0x01,
  0x50, 0x12, 0x12, 0x00, 0x00, 0x01,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

static uint8_t paper_cmd_lut_bb[] = {
  PAPER_CMD_LUT_BB,
  0x80, 0x08, 0x00, 0x00, 0x00, 0x02,
  0x90, 0x28, 0x28, 0x00, 0x00, 0x01,
  0x80, 0x14, 0x00, 0x00, 0x00, 0x01,
  0x50, 0x12, 0x12, 0x00, 0x00, 0x01,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

static uint8_t paper_cmd_disp[] = {
  PAPER_CMD_DISP,
};

static uint8_t paper_buffer[PAPER_BUFLEN];
static uint8_t paper_prev_buffer[PAPER_BUFLEN];

static void paper_begin_command(void) {
  nrf_gpio_pin_clear(PAPER_DC_PIN);
}

static void paper_begin_data(void) {
  nrf_gpio_pin_set(PAPER_DC_PIN);
}

static ret_code_t paper_tx_cmd(uint8_t *cmd, uint8_t length) {
  ret_code_t ret;

  paper_begin_command();
  ret = nrf_drv_spi_transfer(&spi, cmd, 1, NULL, 0);
  if (ret != NRF_SUCCESS) return ret;

  if (length - 1 > 0) {
    paper_begin_data();
    ret = nrf_drv_spi_transfer(&spi, cmd + 1, length - 1, NULL, 0);
    if (ret != NRF_SUCCESS) return ret;
  }

  return ret;
}

static void paper_reset(void) {
  nrf_gpio_pin_clear(PAPER_RST_PIN);
  nrf_delay_ms(200);
  nrf_gpio_pin_set(PAPER_RST_PIN);
  nrf_delay_ms(200);
}

static ret_code_t paper_tx_lut(void) {
  ret_code_t ret;

  ret = paper_tx_cmd(paper_cmd_vcom, sizeof(paper_cmd_vcom));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_lut_vcdc, sizeof(paper_cmd_lut_vcdc));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_lut_ww, sizeof(paper_cmd_lut_ww));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_lut_bw, sizeof(paper_cmd_lut_bw));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_lut_wb, sizeof(paper_cmd_lut_wb));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_lut_bb, sizeof(paper_cmd_lut_bb));
  if (ret != NRF_SUCCESS) return ret;

  return ret;
}

static ret_code_t _paper_display(void) {
  ret_code_t ret;

  /*
   * TODO transfer chunks of 256 bytes rather than calling nrf_drv_spi_transfer
   * for each byte.
   */

  uint8_t command[1];

  command[0] = 0x10;
  ret = paper_tx_cmd(command, 1);
  if (ret != NRF_SUCCESS) return ret;

  paper_begin_data();
  for (int i = 0; i < PAPER_BUFLEN; i++) {
    ret = nrf_drv_spi_transfer(&spi, paper_prev_buffer + i, 1, NULL, 0);
    if (ret != NRF_SUCCESS) return ret;
  }

  nrf_delay_ms(10);

  /*
   * TODO i'm not yet sure about the purpose of sending the previous buffer too.
   * just sending 0x00s works pretty good. when sending the actual previous
   * image buffer, it looks like sections that have not changed become kinda
   * dirty / greyish (which could be useful because one can use three colors).
   */

  // memcpy(paper_prev_buffer, paper_buffer, PAPER_BUFLEN);

  command[0] = 0x13;
  ret = paper_tx_cmd(command, 1);
  if (ret != NRF_SUCCESS) return ret;

  paper_begin_data();
  for (int i = 0; i < PAPER_BUFLEN; i++) {
    ret = nrf_drv_spi_transfer(&spi, paper_buffer + i, 1, NULL, 0);
    if (ret != NRF_SUCCESS) return ret;
  }

  nrf_delay_ms(10);

  ret = paper_tx_lut();
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_disp, sizeof(paper_cmd_disp));
  if (ret != NRF_SUCCESS) return ret;

  nrf_delay_ms(100); // TODO use busy pin rather than arbitrary delays

  return ret;
}

ret_code_t paper_init(void) {
  ret_code_t ret;

  nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
  spi_config.ss_pin   = PAPER_SPI_SS_PIN;
  spi_config.mosi_pin = PAPER_SPI_MOSI_PIN;
  spi_config.sck_pin  = PAPER_SPI_SCK_PIN;

  ret = nrf_drv_spi_init(&spi, &spi_config, NULL, NULL);
  if (ret != NRF_SUCCESS) return ret;

  nrf_gpio_cfg_output(PAPER_RST_PIN);
  nrf_gpio_cfg_output(PAPER_DC_PIN);

  paper_reset();

  ret = paper_tx_cmd(paper_cmd_pwr, sizeof(paper_cmd_pwr));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_btst, sizeof(paper_cmd_btst));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_pon, sizeof(paper_cmd_pon));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_psr, sizeof(paper_cmd_psr));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_pll, sizeof(paper_cmd_pll));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_tres, sizeof(paper_cmd_tres));
  if (ret != NRF_SUCCESS) return ret;

  ret = paper_tx_cmd(paper_cmd_vdcd, sizeof(paper_cmd_vdcd));
  if (ret != NRF_SUCCESS) return ret;

  memset(paper_buffer, 0xff, PAPER_BUFLEN);
  memset(paper_prev_buffer, 0x00, PAPER_BUFLEN);

  return ret;
}

void paper_uninit(void) {
  // TODO uninit spi and free buffers
}

void paper_pixel_draw(uint16_t x, uint16_t y, uint32_t color) {
  ASSERT(x < PAPER_PIXEL_WIDTH);
  ASSERT(y < PAPER_PIXEL_HEIGHT);

  int bitn = y * PAPER_PIXEL_WIDTH + x;
  int byten = bitn / 8;
  bitn = 8 - bitn % 8 - 1;

  if (color == 0) paper_buffer[byten] |= 1UL << (bitn);
  else paper_buffer[byten] &= ~(1UL << (bitn));
}

void paper_rect_draw(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint32_t color) {
  ASSERT(x + width < PAPER_PIXEL_WIDTH);
  ASSERT(y + height < PAPER_PIXEL_HEIGHT);

  for (uint16_t _x = x; _x < x + width; _x++)
    for (uint16_t _y = y; _y < y + height; _y++)
      paper_pixel_draw(_x, _y, color);
}

void paper_display(void) {
  APP_ERROR_CHECK(_paper_display());
}

void paper_rotation_set(nrf_lcd_rotation_t rotation) {
  UNUSED_PARAMETER(rotation);

  // TODO
}

void paper_display_invert(bool invert) {
  UNUSED_PARAMETER(invert);

  // TODO
}

The e-paper display I have are with SSD1680 IC, here
In Adafruit Library I found the following parameters
For SSD1680, here
#define SSD1680_DRIVER_CONTROL 0x01
#define SSD1680_GATE_VOLTAGE 0x03
#define SSD1680_SOURCE_VOLTAGE 0x04
#define SSD1680_PROGOTP_INITIAL 0x08
#define SSD1680_PROGREG_INITIAL 0x09
#define SSD1680_READREG_INITIAL 0x0A
#define SSD1680_BOOST_SOFTSTART 0x0C
#define SSD1680_DEEP_SLEEP 0x10
#define SSD1680_DATA_MODE 0x11
#define SSD1680_SW_RESET 0x12
#define SSD1680_TEMP_CONTROL 0x18
#define SSD1680_TEMP_WRITE 0x1A
#define SSD1680_MASTER_ACTIVATE 0x20
#define SSD1680_DISP_CTRL1 0x21
#define SSD1680_DISP_CTRL2 0x22
#define SSD1680_WRITE_RAM1 0x24
#define SSD1680_WRITE_RAM2 0x26
#define SSD1680_WRITE_VCOM 0x2C
#define SSD1680_READ_OTP 0x2D
#define SSD1680_READ_STATUS 0x2F
#define SSD1680_WRITE_LUT 0x32
#define SSD1680_WRITE_BORDER 0x3C
#define SSD1680_SET_RAMXPOS 0x44
#define SSD1680_SET_RAMYPOS 0x45
#define SSD1680_SET_RAMXCOUNT 0x4E
#define SSD1680_SET_RAMYCOUNT 0x4F

For IL0373, here
#define IL0373_PANEL_SETTING 0x00
#define IL0373_POWER_SETTING 0x01
#define IL0373_POWER_OFF 0x02
#define IL0373_POWER_OFF_SEQUENCE 0x03
#define IL0373_POWER_ON 0x04
#define IL0373_POWER_ON_MEASURE 0x05
#define IL0373_BOOSTER_SOFT_START 0x06
#define IL0373_DEEP_SLEEP 0x07
#define IL0373_DTM1 0x10
#define IL0373_DATA_STOP 0x11
#define IL0373_DISPLAY_REFRESH 0x12
#define IL0373_DTM2 0x13
#define IL0373_PDTM1 0x14
#define IL0373_PDTM2 0x15
#define IL0373_PDRF 0x16
#define IL0373_LUT1 0x20
#define IL0373_LUTWW 0x21
#define IL0373_LUTBW 0x22
#define IL0373_LUTWB 0x23
#define IL0373_LUTBB 0x24
#define IL0373_PLL 0x30
#define IL0373_CDI 0x50
#define IL0373_RESOLUTION 0x61
#define IL0373_VCM_DC_SETTING 0x82
#define IL0373_PARTIAL_WINDOW 0x90
#define IL0373_PARTIAL_ENTER 0x91
#define IL0373_PARTIAL_EXIT 0x92

I need help with how to convert the use of IL0373 in paper.c to SSD1680, or is it even possible to do so?

source: Stack Exchange

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

sort: votes


text:
What may have happend to this arduino NANO?
Accidentally I just short circuit my arduino nano, using a led neopixel, between the 5vOutput with one of the data pins.
Now the pc doesnt recognize the device when I connect it.
In the device (a NANOV3.0).

Only the PWR(POWER/ON) led is light up, while L light doesn't. Using the multimeter VoltsDC(20), between the ground (USB) and the pin 5v it just give me 2 Volts
What may it be? How should I chek it? It is possible to fix changing a microcomponent?
Thank you

Before tearing your hair out much about this further I would disconnect it. Shut the machine off, wait a while, turn it on, and see if the voltage is more normal (well above 2V) again.

@timemage thank you for your suggestion, I checked out again and is still in 2 volts (1.99 to be more accurate) Do you have another idea? Or at least do you know any video tutorial which show how to test with a multimeter with section may be malfunctioning?. The led in the power it isn't at the full original brighness tho, it is like, 50%.

Nothing coming to mind that I can turn into an answer. I just wanted to make sure your was not effectively self healing.

the device is double sided ... you posted a picture of only one side

Seems like there is damage. You might want to compare with a working Nano. What voltage is at the "3V3" pin? Did you look up the schematic to get ideas what could be dead?

There is stepdown chip and diode on the other side. Most time diode is blown and shorting VCC. Or maybe stepdown is blown as well. Show us picture from bottom side

Tell in more detail please how the Neopixel was connected, and for how long, and what else happened. Also measure all supply voltage pins (5V, 3.3V, Vin) against GND pin and tell us.

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


text:
How does the compiler/assembler work wrt bootloader?
I realized that on the atmega boards the bootloader is programmed into the chip.
I'm curious, when compiling a sketch how does the compiler/assembler differ from compiling a standard C program for a chip without a bootloader?
Is there still a main? Does the linker put the startup code in a different area? Obviously with the bootloader you're no longer compiling a program which places code at the reset address.

https://stackoverflow.com/questions/919781/how-can-i-get-an-assembly-language-listing-of-my-arduino-sketches-on-windows#930855

On the Uno and similar AVR-based boards, the compiler and assembler are
not aware of the bootloader. The compiled program starts at address
zero. There you have the interrupt vector table, starting with the reset
vector. That vector is a jump to the C runtime startup code, which does
some low-level initialization, then calls main() from the Arduino core
library, which calls setup() and loop() from your sketch.
The bootloader lives at the end of the flash. The AVR chip has a few
bytes of non-volatile configuration memory called “fuses”. These bytes
are configured by the Arduino board maker to dedicate the last
512 bytes of flash to the bootloader, and to start executing the
code at the start of the bootloader on power up and on reset events. It
is then the bootloader's responsibility to jump to address zero in order
to start the user's program.

So I can write standard programs with avr studio and not change anything and have them loaded?

@FourierFlux: I have never used AVR Studio, but I do occasionally write regular AVR programs using avr-libc, compile them with avr-gcc, and upload them to an Uno using avrdude.

Ok but the point is you just compile a standard C program.

warning for future readers. the answer really only applies to AVR architecture. it doesn't carry over to other architectures


text:
How to use arduino to run .exe file in a windows computer
Is there a way to run .exe file on a windows computer that connected to arduino? (I want to create some sort of stream deck, but it will be used for running Google Chrome and other .exe file on a windows computer)
Can someone explain how to run it using arduino uno by taking input from the user?

how do you normally run  microsoft edge?

double clicking the shortcut, or using cmd

don't forget that the subject of your question is about an external device that is connected to a computer ... so double clicking the shortcut, or using cmd does not answer the question I asked ... anyway, program the arduino to be one of the external devices that you use to control your computer

Ah I see, but I only find some tutorials on how to use the arduino as an automated keyboard, is there a way I use it to open microsoft edge without using my arduino as an automated keyboard?

Maybe use a script (say Powershell) running on the PC. It constantly checks a Serial port for any commands the arduino may send it. The script interprets such commands and initiatives an appropriate action. In your case this would be opening Microsoft Edge.

Thanks for the answer, I will try!

setup keyboard shortcuts in Windows to run the programs. then if you still need it, you can use an Arduino Leonardo or Arduino Micro to send this keyboard shortcuts.

Ah I just figured out that there is Arduino Leonardo, I will try using that one

@Juraj: I believe your comment would make a perfectly good answer.

As mentioned in comments, one way to do this would be to bind a windows shortcut key to do the action you desire and then have the arduino send that as a keystroke.  This would only be possible on devices (like the leonardo) that have native usb device support rather than a serial to usb converter chip.
An alternate (and more secure and reliable) approach would be to create a windows service that looks for the arduino and monitors it and runs actions when the arduino generates specific events.
The easiest way to get events would be to read incoming serial data from the arduino and parse it; this would work on all arduinos.  A more complex approach (only available on arduinos with native usb device support) would be to create a special USB device profile that generated the events, and a corresponding windows service or driver to recognize and use that custom device.
I've done things like this with my own projects, although in linux, not in windows.


text:
Wemos C3 Mini (ESP32-C3) does not run firmware unless connected to pc
I've been using ESP32s and ESP8266 for a few years now and I thought I'd give these little boards a shot, they were cheaper for Bluetooth/WiFi combo, and I don't need all the bells and whistles of a full ESP32.
I have my firmware all debugged and working, it's been stable for a few months now. All it does is read a temperature from an Inkbird Bluetooth temperature sensor and log that info into a spreadsheet online for me via WiFi.
Up until this point I had the board connected via usb cable to my PC. Well I got a new PC and wanted to save a usb port so I moved it to a usb cable with an Apple AC wall adapter (5V 500mA). The board now never powers on.
Does anyone know what's happening here? It seems to not like booting unless it has a serial connection with the PC??? It doesn't like to power on if the PC is off either even though the usb port has power still.
I thought maybe this weird usb C port doesn't like 5V. So, I got it 3.3V via a breadboard power adapter rig. Nothing...

Does anyone know what's happening here? ... no ... you are the only one in a position to know ... we can guess that your code has a bug ... possibly something to do with waiting for a serial port connection

Well there you have it. That's exactly what was happening! Thank you!

next time, if you have a question, please include all info ... do not withhold important things like the code

Your program could be busy, waiting for the com port to open.


text:
Cannot instantiate a parameterized object inside of another class
I'm having troubles understanding the inner workings of classes and such.
I have a class called Attributes that contains parameters. In my .ino, I can simply instantiate an object with Attributes greenBark(1, 2); and everything is hunkey dorey.
Problem: Now I need to create a Attributes object in my other class, called Tree. I figured out if my constructor doesn't have parameters, I can create an object within another class just fine. However, my attributes class constructor has parameters. When I try to create an parameterized object within another class, the compiler tosses an error. How can I create an attributes object within my tree class? I'm sorry if I got some of these terms mixed up, I'm trying to keep up!
Here are my current files (made for this example:)
The .ino file
#include "attributes.h"
#include "tree.h"

Attributes greenBark(1, 2);

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

void loop()

{
  greenBark.printAttributes();
}

attributes.cpp
#include "attributes.h"
Attributes::Attributes(int size, int texture)

{
  _size = size;
  _texture = texture;
}

void Attributes::printAttributes()
{
  Serial.print("GreenBark Attributes: ");
  Serial.print("Size = ");
  Serial.print(_size);
  Serial.print(" Texure = ");
  Serial.print(_texture);
  Serial.println();
}

attributes.h
#pragma once
#include <Arduino.h>

class Attributes
{
  public:
    Attributes(int size, int texture); // constructor
    void printAttributes(); // method

  private:
    int _size = 0;
    int _texture = 0;
};

tree.cpp
#include "attributes.h"
#include "tree.h"

Tree::Tree()
{

}

tree.h
#pragma once
#include <Arduino.h>
#include "attributes.h"

class Tree
{
  public:

    Tree(); // constructor

    void makeTree(); // method

    // I want to create an attributes class object in my current class, so naturally I'd try to
    // create the object just like I did in my .ino sketch, but the below line doesn't work.

    //Attributes redBark(1, 2);

  private:
};

The error provided is this:
In file included from C:\Users\ajrob\Dropbox\Projects\Electronics\Arduino Sketchbook\ParameterizedConstructor\ParameterizedConstructor.ino:2:0:
C:\Users\ajrob\Dropbox\Projects\Electronics\Arduino Sketchbook\ParameterizedConstructor\tree.h:16:24: error: expected identifier before numeric constant
     Attributes redBark(1, 2);
                        ^
C:\Users\ajrob\Dropbox\Projects\Electronics\Arduino Sketchbook\ParameterizedConstructor\tree.h:16:24: error: expected ',' or '...' before numeric constant
In file included from C:\Users\ajrob\Dropbox\Projects\Electronics\Arduino Sketchbook\ParameterizedConstructor\tree.cpp:2:0:
C:\Users\ajrob\Dropbox\Projects\Electronics\Arduino Sketchbook\ParameterizedConstructor\tree.h:16:24: error: expected identifier before numeric constant
     Attributes redBark(1, 2);
                        ^
C:\Users\ajrob\Dropbox\Projects\Electronics\Arduino Sketchbook\ParameterizedConstructor\tree.h:16:24: error: expected ',' or '...' before numeric constant

exit status 1

Compilation error: expected identifier before numeric constant

https://en.cppreference.com/w/cpp/language/constructor

@Juraj I read that page over a few times understanding what I could and I'm not seeing how it helps my situation

I don't understand much of it either, so I tried Attributes redBark {1, 2}; and it did not throw an error ... I have no idea if it does what you are expecting ... Attributes redBark {1}; and Attributes redBark {1, 2, 3}; both throw an error, so it might be what you want

@AJ_Smoothie your post is not Arduino specific, and really is a general programming question ... it belongs at https://stackoverflow.com/questions

@jsotola I tried the braces in my actual code (the parameters are input pins and default pin states) and it worked out just great. Thank you

I see two options here:
You might follow jsotola's comment and initialize redBark with braces:
Attributes redBark{1, 2};

For some reason, the syntax with parentheses is not allowed when
initializing an object in a class declaration, but the syntax with
braces is OK.
The other option is to initialize redBark in the Tree's constructor
(and not in the class declaration) using an initializer list:
// In the class declaration:
Attributes redBark;

// The constructor:
Tree::Tree() : redBark(1, 2) {}

Using the curly braces worked out just fine! Thank you!


text:
why the p-mos is acting as a constant switch when the source is connect to any port in the circuit iam not able find the solution ?i

if my circuit has mistake please refer me the proper image.
#define pwm 6
void setup() {
  // initialize serial communication at 9600 bits per second:
  pinMode(6,OUTPUT);
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  //Serial.println(sensorValue);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = sensorValue * (5.0 / 1023.0);
  //Serial.println(voltage);
  float vol1=voltage*11;
  Serial.print("convertd voltageg ");
  Serial.println(vol1);
  int s=0;
  if (vol1>24){
  float duty=(24)/(vol1);
  Serial.print("Duty cycle ");
  duty=duty*100;
  Serial.println(duty);
   s=map(duty,0,100,0,255);
  Serial.print("maped values");
  Serial.println(s);
    analogWrite(6,s);}
  else if(vol1>18 && vol1<25){
    s=255;
    analogWrite(6,s);
    Serial.println(s);
  }
  //Serial.println(x);
}

Read MOSFET as a switch.

DV & VTC. Your question is not about Arduino, and should be moved to EE.

Is it standard practice here to down vote an answer simply because it is deemed that the question belongs elsewhere? I'd have thought that any down voting of an answer should be accompanied by a specific comment stating how the answer is factually, or otherwise, incorrect.

You have to be careful with such a circuit because you risk applying 12 volts to an arduino pin. To switch that P channel mosfet off, 12 volts has to be applied to the gate. Search for "mosfet high side switch". Usual solutions use both a P channel  mosfet and either an npn transistor or an N channel mosfet. A simpler alternative is to switch the motor using an N channel mosfet (low side switch). See https://gammon.com.au/motors for a full description.
Note: that circuit you have used appears to have come from here https://circuitjournal.com/how-to-use-a-p-channel-mosfet-with-an-arduino and is particularly risky because it relies on the grounds between the 5 volt and 12 volt circuits not being interconnected. It may work as shown, however not recommended for the reasons stated above, but your simulation does not appear to have the 12 volt power supply sharing a common positive rail with the 5 volt supply.

The Arduino when the output is High is ~5V referencing. The MOSFET gate sees it as -7V referencing the source. It is always best to use the source as the reference point for a MOSFET. Look at the data sheet and it shows it is doing what it is doing. The gate needs to about 0V referencing the source to be off. The exact value is dependent on the MOSFET used.You will need to add a transistor or mosfet to drive the P-Channel MOSFET with the Arduino. You could also use a opto isolator to switch the mosfet.


text:
AsyncMqttclient publish affects accelerometer readings
Using M5StickC ESP32 with built-in MPU6886 accelerometer to read vibrations. In the loop() section the code gets 10 readings per second and if the readings exceed a threshold, it starts publishing the results in a JSON MQTT message on asyncmqttclient, again 10 publishes per second. The period of full publishing continues on until the readings fall back under the threshold+5 seconds.
However,when it starts publishing 10 messages per second, the accelerometer readings go haywire and the values are higher than they should be in reality. This is the results under asyncmqttclient publish:

The blue ellipse is just one knock. Goes up and down, and the vibration ends there. However the green ellipse part is the period where the code sends the publish messages, they should normally be down and silent like this:

This second graph values are from the same code, the only difference is i commented out the asyncmqttclient publish mqtt command. If i use pubsubclient it also gives the correct values.
if (eq_status) { // Earthquake still happening
  eq_time_count++ ;

  if (((slta && !staLta.checkTrigger()) || (!slta && eq_time_count > eq_pet)) || (master && !slave_eq_state)) { // EQ Ends...
      eq_status = false;
      eq_time_count = 0;

      updateState("LISTENING");

      publish_mqtt(MQTT_PUB_EVENT, updateEvent(ax,ay,az,pga).c_str(), 0, true);

      digitalWrite(M5_LED, HIGH);
      if (SPK_HAT) ledcWriteTone(spkChannel, 0);
      lcd.set_brightness(lcd_brightness);
  } else {
    /* THIS IS THE PROBLEMATIC PART */
    publish_mqtt(MQTT_PUB_EVENT, updateEvent(ax,ay,az,pga).c_str(), 0, true);
    /*client.publish(MQTT_PUB_EVENT,updateEvent(ax,ay,az,pga).c_str());*/

  }
} else {
    if (flush_update) { // Send periodic event update message
    flush_event++;
    if (flush_event > (flush_period*10)) {
      publish_mqtt(MQTT_PUB_EVENT, updateEvent(ax,ay,az,pga).c_str(), 0, true);
      flush_event = 0;
    }
  }
}

I think there could be something wrong with either asyncmqttclient or espasyncTCP, or could there be any other cause?

Decreasing 10 publishes per second to 5 publishes helps a lot. Is it a problem of message buffer?

I could be missing something. But this might be viewed as too general a question. Perhaps if you broke it down more and tested those smaller aspects of the project before coming here we could better help.  In the mean time, the MPU-6886 can be I2C or SPI.  Have you tried both?  And the async-mqtt-client has its own web page.  Have you looked there for answers ... through the open issues?

"Is it a problem of message buffer?"  Maybe.  I am not familiar with ESP32 I2C HW.  Or, if you are using a SW implemented I2C (or SPI, you didn't say which mode you set the MPU-6886 to) to talk to the MPU-6886 it may be adversely affected by the async-mqtt-client SW.  This is an embedded environment, not a real OS.  If async-mqtt-client is using a lot of the CPUs time, this may impact the expected operation of your code or features (like I2C) your code is depending on.

I am using I2C, couldn't find the SPI library of it. asyncmqttclient has no information in this kind of problem. I heavily suspect that the problem may be about the TCP buffer since decreasing the publishes per second helped. But I still don't have any clue how it can affect the accelerometer read values.


text:
ESP32 HTTP Request handles Go webserver response, but fails on node JS servers
I've set up an esp32 board (wemos d1 r32) to send a request to a server hosted on my local network. If I set up a very basic go server, the board handles the response fine (200 with the appropriate body content). Once I switch to a Node JS Server, it only responds with a 400 status code. Weirdest of all none of the console.log calls in the route handlers get called, which indicates that it quits before it even gets to the express server. I've tested that the server returns the body & status code I want using postman, all looks good.
I've tried different frameworks (Koa) to see if this is related to Express, but it doesn't work with that either. I assume its something to do with NodeJS?
Express server
import express from "express";

const app = express();
app.use(express.json());
app.post("/", (req, res) => {
  console.log(req.body);
  req.statusCode = 200;
  res.send("200");
});

app.get("/hello", (req, res) => {
  res.setTimeout(50000);
  console.log(req.body);
  res.setHeader("Location", "123");
  res.setHeader("Server", "123");
  req.statusCode = 200;
  res.send("200");
});

app.listen(8090, () => {
  console.log(`Example app listening on port ${8090}`);
});

Go server
package main

import (
    "fmt"
    "net/http"
)

func hello(w http.ResponseWriter, req *http.Request) {
    for name, headers := range w.Header() {
        for _, h := range headers {
            fmt.Fprintf(w, "%v: %v\n", name, h)
        }
    }
    fmt.Fprintf(w, "hello\n")
}

func headers(w http.ResponseWriter, req *http.Request) {

    for name, headers := range req.Header {
        for _, h := range headers {
            fmt.Fprintf(w, "%v: %v\n", name, h)
        }
    }
}

func main() {
    fmt.Println("?")

    http.HandleFunc("/hello", hello)
    http.HandleFunc("/headers", headers)

    http.ListenAndServe(":8090", nil)
}

Arduino script
#include <HTTPClient.h>
#include <WiFi.h>

// #define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE
#include "esp_log.h"

const char* ssid = "xxx";
const char* password = "xxx";

String webserver = "http://192.168.0.19:8090/hello";

String qrCode;

void WiFiStationConnected(WiFiEvent_t event, WiFiEventInfo_t info){
  Serial.println("Connected to AP successfully!");
}

void WiFiGotIP(WiFiEvent_t event, WiFiEventInfo_t info){
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void WiFiStationDisconnected(WiFiEvent_t event, WiFiEventInfo_t info){

  WiFi.disconnect(true);
  delay(1000);
  WiFi.mode(WIFI_STA);
  delay(1000);
  Serial.println("Disconnected from WiFi access point");
  Serial.print("WiFi lost connection. Reason: ");
  Serial.println(info.disconnected.reason);
  Serial.println("Trying to Reconnect");
  WiFi.begin(ssid, password);
  delay(5000);
}

void setup() {
  esp_log_level_set("*", ESP_LOG_VERBOSE);
  Serial.begin(9600);
  Serial2.begin(9600);
  Serial.println("Hello, ESP32!");
  Serial.println(WiFi.getMode());
  Serial.println(WiFi.macAddress());

  WiFi.onEvent(WiFiStationConnected, WiFiEvent_t::SYSTEM_EVENT_STA_CONNECTED);
  WiFi.onEvent(WiFiGotIP, WiFiEvent_t::SYSTEM_EVENT_STA_GOT_IP);
  WiFi.onEvent(WiFiStationDisconnected, WiFiEvent_t::SYSTEM_EVENT_STA_DISCONNECTED);

  WiFi.begin(ssid, password);
}

int cnt = 0;

void loop() {
  while (Serial2.available()) {
    int  ch = Serial2.read();
    char character = ch;
    Serial.print(ch);

    // end char
    if(character == 13){
      Serial.print("\n");
      Serial.println(qrCode);
      Serial.println(cnt);
      qrCode = "";
      cnt = 0;
      send(qrCode);
    } else {
      cnt = ch + cnt;
      qrCode = qrCode + character;
    }
  }
}

void tryWifi() {
  WiFi.begin(ssid, password);
  int status = WiFi.status();
  while (status == 6 || status == 4 || status == 5 || status == 1) {
    Serial.print("Failed to connect:");
    Serial.print(status);
    Serial.print("\n");
    delay(1500);
    WiFi.begin(ssid, password);
  }
}

void send(String json) {
  HTTPClient http;

  if(http.begin(webserver)){

      int httpCode = http.GET();
      http.addHeader("Content-Type", "application/json");
      http.addHeader("Host", "something");
      // client.print("Content-Length: ");
      delay(1500);

      Serial.println(httpCode);
      Serial.println(http.getString());
      if (httpCode > 0) {
      Serial.printf("[HTTP] GET... code: %d\n", httpCode);
        if(httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
          String payload = http.getString();
          if (payload != "false"){
            Serial.println(payload);
            delay(1500);
          } else {
          Serial.println("Bad Playload");
          }
        } else {

        }
      } else {
      Serial.println("Error sending to HTTP");
      }
      http.end();
    } else {
      Serial.println("?");
    }
}

Your Arduino code reads like this:
  int httpCode = http.GET();
  http.addHeader("Content-Type", "application/json");
  http.addHeader("Host", "something");
  // client.print("Content-Length: ");
  delay(1500);

  Serial.println(httpCode);
  Serial.println(http.getString());
  if (httpCode > 0) {

The call http.GET() actually performs the HTTP request. You're adding headers after you perform the request. They need to be added before it. So your code should read:
  // http.addHeader("Content-Type", "application/json");
  int httpCode = http.GET();

  // delay(1500);   -- there's no need to call delay() here

  Serial.println(httpCode);
  Serial.println(http.getString());
  if (httpCode > 0) {

HTTP status code 400 means "bad request". Some web servers will return this code if headers that they expect to see are missing or have non-sensical values. The Go and Javascript web servers are different implementations and may behave differently with malformed requests.
I've removed "Host" header as HTTPClient does this for you. And there's no need for the delay() call after calling http.GET().
Edit: I also commented out the "Content-Type" header as it makes no sense on a GET request, thanks to @EdgarBonet for mentioning that. I'm leaving it there as a comment to make it clear that that any headers should be added before the request is performed.

Note also that "Content-Type" does not make sense on an HTTP request. The OP probably means "Accept".

@EdgarBonet  Thanks, good point. It does actually make sense on a PUT or POST request that has a body, but not on a GET, which should never have a body. I've edited the answer. I suspect OP was just throwing in random lines of code to see if they fixed their problem.

Thanks for the comments. I had the Content-Type header there as I intend to use a POST request w/ a json body. I've moved the call to set the header before the request is fired, nice catch!

I've figured out after an unreasonable amount of time that the request fails with a 400 as it doesn't have a slash at the end of the URL (http://192.168.1.208:8090 -> http://192.168.1.208:8090/). This must be something specific to NodeJS, as it works ok on a go server.


text:
strange behaviour with a single 7seg display
I'd like to display a sentence character by character on a single seven-segment display. What happens is that if my sentence is longer than 48 characters the central segment doesn't light up.
It works properly if I take out a letter from my string.
I have an Elegoo Uno R3, and am working on Windows, on the last version (2.0.3) of the Arduino IDE.
Is there a way to solve this issue?
Here's my code:
# include "SevSeg.h"

SevSeg  sevseg;
char    *str = "Per colpa di qualcuno non si fa credito a nessuno";
int     len = 50;

void setup(){
    byte numDigits = 1;
    byte digitPins[] = {};
    byte segmentPins[] = {6, 5, 2, 3, 4, 7, 8, 9};
    bool resistorsOnSegments = true;

    byte hardwareConfig = COMMON_CATHODE;
    sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
    sevseg.setBrightness(90);
}

void loop(){
  int i = 0;

  while (i < len)
  {
    sevseg.setChars(&(str[i]));
    delay(1000);
    sevseg.refreshDisplay();
    ++i;
  }
}

Thanx in advance,
Fab

Why is digitPins an empty array? You have numDigits as 1, not zero.

The tutorial states that it should be left empty for a single digit display. This is the tutorial:
circuitbasics.com/arduino-7-segment-display-tutorial
I'm gonna follow the official Arduino tutorial to see if the problem comes from the way I connected the wires to the pins:  https://arduino-france.site/7-segments/

OK. It works properly if I take out a letter from my string. - what happens if you put a lot of spaces in the string? Is something possibly overheating?

I didn't try honestly, I tried with an English sentence like "We are such stuff As dreams are made on, And our little life Is rounded with a sleep." and all worked fine.
I started anew. Thanx a lot for your support

It looks like setChars is expecting a string, not a single character.
So I would be doing something like:
  while (int i = 0; i < len; i++)
  {
    char buf [2];
    buf [0] = str[i];
    buf [1] = 0;  // null terminator
    sevseg.setChars(buf);
    sevseg.refreshDisplay();
    delay(1000);
  }

See: https://github.com/DeanIsMe/SevSeg/blob/master/SevSeg.cpp

but a pointer to char is same as pointer to c-ctring. and the setChar function uses only numDigits chars from the input string. and numDigits is 1 in this case

@NickGammon Thanx for your help, but It didn't solve the problem, or at least both approaches print the same thing, as if the problem came from the location in memory where the string is stored.

@juraj what's numDigits eactly? I found it in the setChars() function in the library but can't understand where it comes from

it is the count of seven-segment modules. the count of digits.

@Juraj thanx, I get it now.

This is the tutorial I followed:
https://www.circuitbasics.com/arduino-7-segment-display-tutorial
My wires are connected in the same way


text:
ESP32 failing to read from DHT11, MH-Z19C sensors
I got MH-Z19C (CO2 ppm) (datasheet), and DHT11 (temperature) sensors from Ebay and followed instructions online to set it up with my ESP32 board (ESP32).
I'm using a breadboard and 5V/3.3V power supply to power the sensors, while the ESP32 is linked to my PC with USB.
I'm struggling to understand the reason why I can't get a reading from my sensors. I tried countless guides online and double-checked everything multiple times.
I also tried connecting DHT11 to my board's 3.3V directly but it didn't change anything.
How do you "debug" hardware? Is there no way to know what you're doing wrong?
You have to get it exactly right or nothing works?
Serial monitor logs:
0 ppm
Failed to read from DHT sensor

MH-Z19C connections:

VIN/GND <-> Power Supply 5V +/- respectively
TX <-> ESP32 RX2
RX <-> ESP32 TX2

DHT11 connections:

Pin 1 <-> Power supply 3.3V
Pin 2 <-> 10k Ohm pull-up <-> ESP32 D2
Pin 4 <-> GND

Reference:

https://randomnerdtutorials.com/esp32-dht11-dht22-temperature-humidity-sensor-arduino-ide/
https://www.electroniclinic.com/mh-z19b-ndir-co2-sensor-with-arduino-mhz19b/
ESP32 Pinout

Libraries installed:

DHT sensor library by Adafruit
MH-Z19 by Jonathan Dempsey

// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain

// REQUIRES the following Arduino libraries:
// - DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library
// - Adafruit Unified Sensor Lib: https://github.com/adafruit/Adafruit_Sensor

#include "DHT.h"
#include <SoftwareSerial.h>
#include <MHZ19.h>
#include <Wire.h>

// pin for uart reading
#define RX_PIN 16  // Rx pin which the MHZ19 Tx pin is attached to.
#define TX_PIN 17 // Tx pin which the MHZ19 Rx pin is attached to.

#define DHTPIN 2     // Digital pin connected to the DHT sensor
// Feather HUZZAH ESP8266 note: use pins 3, 4, 5, 12, 13 or 14 --
// Pin 15 can work but DHT must be disconnected during program upload.

#define DHTTYPE DHT11   // DHT 11

// Initialize DHT sensor.
// Note that older versions of this library took an optional third parameter to
// tweak the timings for faster processors.  This parameter is no longer needed
// as the current DHT reading algorithm adjusts itself to work on faster procs.
DHT dht(DHTPIN, DHTTYPE);
MHZ19 myMHZ19;
SoftwareSerial mySerial(RX_PIN, TX_PIN);

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

  // Start Co2 sensor
  mySerial.begin(9600);                               // (Uno example) device to MH-Z19 serial start
  myMHZ19.begin(mySerial);                                // *Serial(Stream) refence must be passed to library begin().
  myMHZ19.autoCalibration();                              // Turn auto calibration ON (OFF autoCalibration(false))
}

void read_dht() {

  /////// DHT SENSOR \\\\\\
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  float f = dht.readTemperature(true);

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
  }

  // Compute heat index in Fahrenheit (the default)
  float hif = dht.computeHeatIndex(f, h);
  // Compute heat index in Celsius (isFahreheit = false)
  float hic = dht.computeHeatIndex(t, h, false);

  Serial.print(F("Humidity: "));
  Serial.print(h);
  Serial.print(F("%  Temperature: "));
  Serial.print(t);
  Serial.print(F("C "));
  Serial.print(f);
  Serial.print(F("F  Heat index: "));
  Serial.print(hic);
  Serial.print(F("C "));
  Serial.print(hif);
  Serial.println(F("F"));

}

void loop() {
  // Wait a few seconds between measurements.
  delay(5000);

  int CO2;
  // Request CO2 (as ppm)
  CO2 = myMHZ19.getCO2();
  Serial.println(String(CO2) + " ppm");

  read_dht();
}

test only one sensor at a time ... use the example code in the library

I did try one sensor at a time. I'll have a look at the library example.

You don't need to use SoftwareSerial for the MH-Z19. You can use the Serial2 second builtin hardware serial port.

There's no dht.begin() in your setup() so your DHT11 never properly initializes. Look at some example code, like here: https://github.com/adafruit/DHT-sensor-library/blob/master/examples/DHTtester/DHTtester.ino.

Actually I am using dht.begin() currently but when copying/editing the code to SO, it got lost. I also tried with HardwareSerial without luck unfortunately.

You did a good job of giving links. You could have improved your question by showing, not just telling us, how you connected the sensors.
How do you "debug" hardware? Is there no way to know what you're doing wrong? You have to get it exactly right or nothing works?
No, that is too hard. I like to divide and conquer and test sequentially.
As already mentioned, test one sensor at a time.
To illustrate, I broke out an old ESP32 and a DHT22 and went about hooking them up as per your example.
Here are the connections:

Then I dowload the library that you had mentioned and I load their simplest example, DHTtester. If I am relying heavily on Arduino Libraries, I am relying on someone else's code, so I need to look through it so I am sure I am using it correctly.
Looking through the code, I make sure it specifies:
#define DHTPIN 2     // Digital pin connected to the DHT sensor.
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321

and I double check that I have it connected correctly . As you can see, I have the pull-up resistor on the dataline....+3.3v to one side of the resistor and the other side goes to the DHT data pin and to the ESP GPIO2 pin (see the pics?).
I double check and then run the code and the serial monitor reveals...
Humidity: 32.40%  Temperature: 23.40°C 74.12°F  Heat index: 22.64°C 72.75°F
Humidity: 32.70%  Temperature: 23.30°C 73.94°F  Heat index: 22.54°C 72.57°F
Humidity: 33.30%  Temperature: 23.30°C 73.94°F  Heat index: 22.55°C 72.60°F
Humidity: 34.10%  Temperature: 23.30°C 73.94°F  Heat index: 22.58°C 72.64°F
Humidity: 34.30%  Temperature: 23.30°C 73.94°F  Heat index: 22.58°C 72.65°F

...and if I breathe on the sensor, the RH jumps up....looks good.
If it had not have worked AND I was sure I had connected things correctly, I would have started going backwards....Can I get any program to work on the ESP, like a simple blink, there are lots of configuration options and it is easy to mess it up.
If I can get something to run, then I have to start to suspect the DHT - do I have another to test?...and so on and so forth.
Then I would repeat the same process with the CO2 sensor.
Then I would try to use them both at the same time.
Hope it helps.

So I basically replicated your setup exactly as it is with DHT and the resistor linking PIN to 3.3V in the same way you did. I'm still getting Temperature 0.00C and Humidity 0.00% so it is getting a reading, not failing, but the reading is always 0, very strange. I know that because if I disconnect the wires, then I get "error when reading temperature", "error when reading humidity". also followed this example to get info on sensors and it prints the driver version and range ok.

I'll post a picture with the wirings tomorrow.

Ok I added a photo.

I wonder if your dht11 got damaged earlier. If you had a known good one, it would be very helpful.

Not to my knowledge. I never used it before. To be honest, I'm more interested in the MH-Z19C sensor. I did some troubleshooting by following this "error codes" example from the library and it seems like the error code is  3 which stands for "Received data does not match the usual syntax expected".


text:
ATTiny88 missing pulses - maybe
I have been given to understand the ATTiny88 is very similar to the Arduino Uno / ATMega328 MCU.  There does not seem to be a tag for the ATTiny88, so that is why I chose the tags I did.  I do not have a high enough reputation to create a tag, yet.  Thanks to the generous help of timemage, Edgar Bonet, and others, my MCU board is now responding, albeit very erratically, to pulses on pins 12 and 13, designated Phase_B and Phase_A, respectively, in the code below.  I have not yet entirely ruled out a hardware issue (I will do so), but a software issue is still likely.  I don't quite know what.  The MCU is registering pulses, but it very often misses large numbers of turns in either direction.  What's more, it frequently reports the wrong direction, strongly favoring a CW rotation, but sometimes reporting a CCW rotation when the knob is turned CW.  It is definitely not an overflow issue, as the anomalous effects are seen in abundance when in the mid range of the variables.
#include <Arduino.h>
#include <TM1637Display.h>
#include "PinChangeInterrupt.h"

volatile uint8_t counter = 0;
volatile bool Update = false;
volatile int currentStatePhase_B;
volatile int lastStatePhase_B;
volatile int pulses = 0;

// Shutdown Output
#define SW 11

// Rotary Encoder Inputs
#define Phase_A 13
#define Phase_B 12
// TM1637 I/O ports
#define DIO 3
#define CLK 4
TM1637Display display(CLK, DIO);

void setup() {

  // Set encoder pins as inputs
  pinMode(Phase_A,INPUT);
  pinMode(Phase_B,INPUT);
  pinMode(SW, OUTPUT);

    // Read the initial state of Phase_B
    lastStatePhase_B = digitalRead(Phase_B);

    // Call updateEncoder() when any high/low changed seen
    // on interrupt 0 (pin 2), or interrupt 1 (pin 3)
    attachPCINT(digitalPinToPCINT(Phase_A), updateEncoder, RISING);
    attachPCINT(digitalPinToPCINT(Phase_B), updateEncoder, RISING);

  display.setBrightness(0x0f);
  display.clear();
  display.showNumberDec(0, false);
}

void loop() {
    if (Update){
        // Show decimal numbers with/without leading zeros
    display.showNumberDec(pulses, false);
    delay(1000);
    display.showNumberDec(counter, false);
        Update = false;
    }
}

void updateEncoder(){
    // Read the current state of Phase_B
    currentStatePhase_B = digitalRead(Phase_B);

    // If last and current state of Phase_B are different, then pulse occurred
    // React to only 1 state change to avoid double count
    if (currentStatePhase_B != lastStatePhase_B  && currentStatePhase_B == 1){
        // If the Phase_A state is different than the Phase_B state then
        // the encoder is rotating CCW so decrement
        if (digitalRead(Phase_A) != currentStatePhase_B) {
            counter --;
        } else {
            // Encoder is rotating CW so increment
            counter ++;
        }
    }
    if (counter > 1023){
      counter = 1023;
    }
    if (counter < 0){
      counter = 0;
    }
    pulses ++;
    // Remember last Phase_B state
    lastStatePhase_B = currentStatePhase_B;
    Update = true;
}

try this ... use interrupt on only phase_A ... when interrupt fires, increment or decrement counter depending on the state of phase_B ... also set Update flag

For answers to most of these questions, see https://arduino.stackexchange.com/questions/92354/change-interrupts-on-the-attiny-88

@jsotola It's an EC11 on a board I created myself.  I don't know what sort of encoder you might be imagining, but this is as basic as it gets.  What do you suggest for debouncing?  Note (I have tried a number of things, including polling rather than employing interrupts.

I've seen an encoder that clicks repeatedly on one contact when turned in one direction, and clicks repeatedly on the second contact when turned in the other direction ... I think that EC11E0B is like that

OK, this is definitely not that.  Actually, it would be great if it were.

https://www.arduino.cc/reference/en/libraries/rotaryencoder/

It does not like that library, at all.  It spits out more than a dozen errors of all sorts with all the examples.

Rotary encoders with Gray encoding or quadrature encoding are by their encoding immune against bouncing. Would you mind to [edit] your question and provide a link to the encoder's data sheet?

No, they definitely are not.   See https://www.pinteric.com/rotary.html  It is true bouncing can be readily detected and perforce ignored, but no mechanical switch is immune.  I just bought these off Amazon:  https://www.amazon.com/gp/product/B07DM2YMT4/ref=ppx_yo_dt_b_asin_title_o08_s02?ie=UTF8&psc=1

I did not say "they do not bounce". I claim the the encoding is immune in the sense that you will always have correct rotation angles. I should have added this. Your referenced paper backs my claim.

Do you have the required pull-up/pull-down resistors on pins 12 and 13?

Yes, of course, but I need to put a scope on the encoder to confirm it id bouncing, and of course then add a couple of capacitors

OK, I have an answer.  The MCU is still missing a lot of pulses, but I am fairly certain this is a hardware issue, or at least mostly so.  I found some code by Ralph S. Bacon and Marko Pinteric.  The YouTube video can be found here
As should always be the case, the ISR is brief.  Here it is a single line that merely sets a Boolean variable true.  In the loop section, the code repeatedly checks to see if the interrupt has occurred.  The checkRotaryEncoder function then verifies the pin values to make sure the encoder is in a valid state (not bouncing).  If so, then the counter value is updated with the result.
#include <Arduino.h>
#include <TM1637Display.h>
#include "PinChangeInterrupt.h"

uint8_t lrmem = 3;
int lrsum = 0;
int num = 0;
unsigned int counter = 0;

// Shutdown Output
#define SW 11
// Rotary Encoder Inputs
#define Phase_A 12
#define Phase_B 13
// TM1637 Display I/O
#define DIO 3
#define CLK 4
TM1637Display display(CLK, DIO);

// A turn counter for the rotary encoder (negative = anti-clockwise)
int rotationCounter = 200;
// Flag from interrupt routine (moved=true)
volatile bool rotaryEncoder = false;

// Rotary encoder has moved (interrupt tells us) but what happened?
// See https://www.pinteric.com/rotary.html
int8_t checkRotaryEncoder()
{
    // Reset the flag that brought us here (from ISR)
    rotaryEncoder = false;

    static uint8_t lrmem = 3;
    static int lrsum = 0;
    static int8_t TRANS[] = {0, -1, 1, 14, 1, 0, 14, -1, -1, 14, 0, 1, 14, 1, -1, 0};

    // Read BOTH pin states to deterimine validity of rotation (ie not just switch bounce)
    int8_t l = digitalRead(Phase_A);
    int8_t r = digitalRead(Phase_B);

    // Move previous value 2 bits to the left and add in our new values
    lrmem = ((lrmem & 0x03) << 2) + 2 * l + r;
    // Convert the bit pattern to a movement indicator (14 = impossible, ie switch bounce)
    lrsum += TRANS[lrmem];
    /* encoder not in the neutral (detent) state */
    if (lrsum % 4 != 0)
    {
        return 0;
    }
    /* encoder in the neutral state - clockwise rotation*/
    if (lrsum == 4)
    {
        lrsum = 0;
        return 1;
    }
    /* encoder in the neutral state - anti-clockwise rotation*/
    if (lrsum == -4)
    {
        lrsum = 0;
        return -1;
    }
    // An impossible rotation has been detected - ignore the movement
    lrsum = 0;
    return 0;
}

void setup() {
  // Set encoder pins as inputs
  pinMode(Phase_A,INPUT);
  pinMode(Phase_B,INPUT);
  // Set Power Switch as output
  pinMode(SW, OUTPUT);
  // Initialize display
  display.setBrightness(0x0f);
  display.clear();
  display.showNumberDec(0, false);
  // Set up interrupt pins and vector
  attachPCINT(digitalPinToPCINT(Phase_A), rotary, CHANGE);
  attachPCINT(digitalPinToPCINT(Phase_B), rotary, CHANGE);
}

void loop()
{
  // Has rotary encoder moved?
  if (rotaryEncoder) {
    // Get the movement (if valid)
    int8_t rotationValue = checkRotaryEncoder();
    // If valid movement, do something
    if (rotationValue != 0) {
      counter += rotationValue;
      if (counter > 1023){
        counter = 1023;
      }
      else if (counter < 0){
        counter = 0;
      }
      display.showNumberDec(counter, false);
    }
  }
}

// Interrupt routine just sets a flag when rotation is detected
void rotary()
{
    rotaryEncoder = true;
}

Any comments are welcom.  In addition, Ralph Bacon used the IRAM_ATTR directive to create the rotary() ISR.  My understanding of this directive is it is not necessary in most cases.  On the other hand, presumably the code will execute faster if it is pushed into flash RAM.  I could not make this work.  The compiler complains, "expected initializer before 'rotary'"  Is this by chance because the ATTiny88 does not have flash RAM?  If not, then what?


text:
DS1302 RTC module running too fast
I am using a DS1302 RTC module with an Arduino Mega 2560 Rev 3. I follow steps on this website since I have no experience with RTC module before. Here are the outputs I am getting.
17:15:21.835 -> Current Date / Time: 26/2/2023 17:15:44
17:15:26.830 -> Current Date / Time: 26/2/2023 17:16:13
17:15:31.856 -> Current Date / Time: 26/2/2023 17:16:42
17:15:36.853 -> Current Date / Time: 26/2/2023 17:17:11

As you can see from the above output, the DS1302 is running five times faster than the real time (output past 30 seconds as real word past 5 seconds). Same thing happened if use different codes with different libraries.
Does this mean the RTC module itself is broken, or I can modify RTC module's speed with code?
//This code is to use with DS1302 RTC module, it permits you to setup the actual time and date
//And you can visualize them on the serial monitor
//This code is a modified version of the code provided in virtuabotixRTC library
//Refer to https://Surtrtech.com for more information

#include <virtuabotixRTC.h> //Library used

//Wiring SCLK -> 6, I/O -> 7, CE -> 8
//Or CLK -> 6 , DAT -> 7, Reset -> 8

virtuabotixRTC myRTC(6, 7, 8); //If you change the wiring change the pins here also

void setup() {
  Serial.begin(9600);
  // Set the current date, and time in the following format:
  // seconds, minutes, hours, day of the week, day of the month, month, year
  myRTC.setDS1302Time(15, 15, 17, 7, 26, 2, 2023); //Here you write your actual time/date as shown above
  //but remember to "comment/remove" this function once you're done
  //The setup is done only one time and the module will continue counting it automatically
}

void loop() {
  // This allows for the update of variables for time or accessing the individual elements.
  myRTC.updateTime();

  // Start printing elements as individuals
  Serial.print("Current Date / Time: ");
  Serial.print(myRTC.dayofmonth); //You can switch between day and month if you're using American system
  Serial.print("/");
  Serial.print(myRTC.month);
  Serial.print("/");
  Serial.print(myRTC.year);
  Serial.print(" ");
  Serial.print(myRTC.hours);
  Serial.print(":");
  Serial.print(myRTC.minutes);
  Serial.print(":");
  Serial.println(myRTC.seconds);

  // Delay so the program doesn't print non-stop
  delay(5000);
}

There is a crystal (a metallic cylinder) on the RTC clock module. Can you please report what is written on it?

Is the backup battery installed?

The crystal is 32.768kHz and I think it has a specific load capacitance of 6 pF. The backup battery was installed and it was also connected to the 5V rail from the Arduino.

If I change delay(5000); to delay(1000);, it is still running 5 times faster.

This electrical stack exchange answer covers the problems, theory of design & testing of such crystal oscillators.  It's likely more then you want to know.  These things are cheap. Less than $10 from reputable suppliers and only a few from questionable sources.  If you bought it from the likes of Adafruit, they might replace it. If I buy it from a questionable source I usually buy a few just in case one doesn't work.

I stumbled over the exact same issue today (using Arduino Uno/atmega328) and a module/board like this:
https://surtrtech.com/2018/01/27/how-to-simply-use-ds1302-rtc-module-with-arduino-board-and-lcd-screen/
When reading out time after setting it, it runs 5-6 times too fast.
I found some hint here regarding precision:
https://forum.arduino.cc/t/ds1302-drift/327796/7
However, they were talking about a 2 minutes of drift every 24 hours which for sure is a totally different thing.
One comment there was to pay special attention to the ground as noise there might be interpreted as additional clock signals and speed up the clock. So I played with the grounds on the board and disconnected everything else connected so far to pins of the Arduino board, but that did not change anything, still 5-6 times faster.
I also played with and without CR2032 battery and 5V and 3.3V input to the clock board's VCC input pin and ...suddenly... it worked ok.
I think with 3.3V input on VCC and no battery, it initially had the "normal" precision but now I can again connect it to 5V input and it still runs normal...
I also kept it a while disconnected from external power source (only running on battery), then connecting it back to the Laptop and reading out date/time values and still it worked ok.
It is totally weird.
Regards, Dan


text:
Using 1.1Vf to read stable battery voltage and sensor voltage
After several tries, i was successful with reading stable battery voltage using internal voltage reference of 1.1v, now the issue i face is that i cannot read stable sensor voltage, could you please let me know how can i read my sensor voltage? or do i need additional voltage divider (my sensor goes directly to A0 and GND pin).
  void setup(){
  Serial.begin(9600);
}

void loop() {
  //REFS1 AND REFS0 to 1 1 -> internal 1.1V refference
  ADMUX |= B11000000;
  //We read A1 (MUX0) for battery voltage
  ADMUX |= B00000001;
    //We read A0 for sensor voltage
  ADMUX |= B00000000;                // for my sensor
  // Start AD conversion
  ADCSRA |= B11000000;
  // Detect end-of-conversion
  while (bit_is_set(ADCSRA,ADSC));
  float val = ADCL | (ADCH << 8);
  val = val * 5.7; // Using 4.7k and 1k voltage divider
  Serial.println(val);
}

Something like the code below must workout but unfortunately it does not help!
  int sensorValue = analogRead(A0);
  voltage =  ((sensorValue/ val) * 1023.);
  delay(1000);
  Serial.println("voltage:  ");
  Serial.print(voltage);
  if (voltage<=215){
  digitalWrite (led, HIGH);
  }
  else if (voltage>=215){
  digitalWrite (led, LOW);
  }

I cannot find the issue, it should work, i believe.
//////////////////////new edit/////////////////////////////////////
const long internalReference = 1078L; //measured AREF to be 1.078 ~ 1.078*1000= 1078V

void setup() {
  // put your setup code here, to run once:
Serial.begin (115200);
}

void loop() {
 analogReference (INTERNAL);
 ADMUX |= B00000000;
 ADCSRA |= B11000000;    //ADEN and ADSC equal to 1   (Start conversion)
  while(bit_is_set(ADCSRA, ADSC));    //Wait for conversion to end
  long val = ADCL | (ADCH << 8);   //Get analog read value
  float voltage = (val/internalReference)*1024;
 Serial.println (voltage);

 }

Looking at your past posts, you are repeatedly using the wrong code and then asking why it doesn't work. Maybe you should search how the ADC work. The reading from sensorValue = analogRead(A0) is a value ranging from 0 to 1023, to convert it to a voltage, the formula is voltage = (sensorValue/Vref) * 1023, where Vref is the reference Voltage you are using, in this case, it is 1.1v. Furthermore, you can't get a correct sensorValue if your input at A0 is HIGHER than the Vref, you will get the wrong value!

@hcheung ok,understood. i will change now and update. before i do so please ans my question:    1) if i use vref as 1.1v, do i need to measure my battery voltage, will it affect the code in any way? because my system only requires sensor measurement that's it.  i am following this link (http://electronoobs.com/eng_arduino_tut156.php) that says we need to measure battery voltage then we can use it with the sensor code. i will update you with the results please stay connected

Whether you want to measure and calibrate the Vref, it is +/-10% differences according to datasheet (I mentioned this already on my prefer answer, please read them). so that means the Vref could be in the range of 0.99 - 1.21v.

@hcheung Hi, please check the code above it displayed constant 0.00V. i have connected solar to a voltage divider that drops the voltage down to 0.85V.

In the schematic above the LDR has been used in place solar panel due to the unavailability of the component in the software.

internalReference should be '1.1` or the voltage you actually measured with a volt meter at Vref. What is the resistance of the LDR?

Let us continue this discussion in chat.

To measure the voltage at A0 with an internal reference of 1.1v, the formula is float voltage = 1.1 * analogRed(A0) / 1023;. Your code can be simplified as
float Vref = 1.1;

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

void loop() {
  analogReference (INTERNAL);
  float voltage = Vref * analogRead(A0) / 1023;
  Serial.print (“voltage at A0:”);
  Serial.println(voltage);
  Serial.print (“Solar panel voltage:”);
  Serial.println(voltage * 5.7);
  delay(1000);
}


text:
Programming ESP32-S3 WROOM with a flexy pin board
I am using ESP32-S3-WROOM-1-N8 module https://www.digikey.de/de/products/detail/espressif-systems/ESP32-S3-WROOM-1-N8/15200089 .
I have compared pinout of all Wroom modules ESP32 ESP32-S3 as well as ESP32-WROVER have all the programming pins in exactly same positions so I was expecting this programmer to work for any of these modules. I am looking at GND, 3v3, EN, RX, TX, GPIO0.
I am using this flexy pin board from aliexpress https://de.aliexpress.com/item/1005004605613498.html?spm=a2g0o.order_list.order_list_main.91.21ef5c5f6R74vM&gatewayAdapt=glo2deu
When Uploading sketch I am getting following error:
StopIteration
[6848] Failed to execute script 'esptool' due to unhandled exception!

Chip is ESP32-S3
Features: WiFi, BLE
Crystal is 40MHz
MAC: 7c:df:a1:ec:d1:f0
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Failed uploading: uploading error: exit status 1

Looks like it failed while configuring flash memory, I have gone through esptool's codebase on Github it seems to fail at this function https://github.com/espressif/esptool/blob/master/esptool/loader.py#L1167
I am not experienced with all this so can't figure out what is the issue.
On board config, I have set
Flash mode: QIO 80MHz
Flash size: 8MB

I have selected ESP32S3 Dev Module as the board
ESP32 Library v2.0.6
Update: When I opened the serial monitor, it is showing following
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x7 (TG0WDT_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x40049b21
invalid header: 0xa5ff005a

Am I wrong in assuming all these modules can be programmed with this programmer?
Thanks in advance
Update 2:
Changing upload speed from 921600 to 115200 fixed it, but the module still errored when running it.
Serial monitor shows following:
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x44c
load:0x403c9700,len:0xbec
load:0x403cc700,len:0x2920
entry 0x403c98d8
[    81][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): XTAL: 40 / 1 = 40 Mhz, APB: 80000000 Hz
E (491) psram: PSRAM ID read error: 0x00ffffff
[    83][W][esp32-hal-psram.c:71] psramInit(): PSRAM init failed!
[   120][D][esp32-hal-rmt.c:615] rmtInit():  -- TX RMT - CH 0 - 1 RAM Blocks - pin 48

Which went away after I disabled PSRAM in upload setting.
Now I seem to be able to program and run it but the serial monitor is only showing debug messages, the message I am trying to print to serial is not showing up.
Also blink sketch is also not working for BUILTIN_LED as well as GPIO1

try lower baud rate

I've never used these programming adapters, but to me it looks like the ESP32 module is supposed to be placed with the WiFi antenna to the left. What does the documentation say?

There is no documentation. That WIFI antenna is from ESP-12 module socket. I have checked continuity for few pins and they confirm that is the way the module is mounted.

@Juraj that actually helped, though it was already in lowest 921600 I increased it to 115200
Now I was able to upload the sketch but it failed while running it. I ll update the Question

921600 is almost 1 mega

did you select S3 version in Tools menu?

Yes. and the PSRAM error went away when I disable the PSRAM option in the upload config.

ever get this working @AnilMaharjan

@NightWolf yes I did.


text:
CircuitPython - how to connect Adafruit esp32 AirLift with Adafuit HttpServer - incompatible socket object
I am building a CircuitPython weather station based on Adafruit M4 board stacked with Adafruit ESP32 AirLift module. Both work fine together when it comes to making http calls (via Adafruit_requests library). However I would like to build a HTTP server serving weather measures instead.
And here is a problem: all Adafuit examples are based on ESP32 or Raspberry Pico boards natively fitted with WIFI. Adafuit M4 board doesn't have the same core python packages since it doesn't sport WIFI.
So example written for Pico doesn't work on M4 with ESP AirLift, there are a number of packages missing to do so (like wifi and socket), adafuit_esp package has to be used instead.
This package however seems to be incompatible with Adafuit HTTPServer:
https://docs.circuitpython.org/projects/httpserver/en/stable/index.html
HttpServer requires socket object as a parameter to be initialized:
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
socket.set_interface(esp)
server = HTTPServer(socket)

this code fails when I'm trying to start the server:
try:
    server.start(esp.pretty_ip(esp.ip_address))
    print("Listening on http://%s:80" % esp.pretty_ip(esp.ip_address))
#  if the server fails to begin, restart the pico w
except OSError:
    time.sleep(5)
    print("restarting..")
    microcontroller.reset()

and the error is:
>>> %Run -c $EDITOR_CONTENT
Creating display
Creating server socket
ESP32 found and in idle mode
Firmware vers. bytearray(b'1.2.2\x00')
MAC addr: ...
...
Connecting to AP...
Connected to jama   RSSI: -27
My IP address is 192.168.0.24
Creating HTTP Server...
starting server..
Traceback (most recent call last):
  File "<stdin>", line 175, in <module>
  File "adafruit_httpserver/server.py", line 91, in start
AttributeError: 'socket' object has no attribute 'bind'
>>>

So it looks like that's not the right socket ?
it works for ESP and Requests libs but not for HTTPServer.
Here are imports:
from adafruit_esp32spi import adafruit_esp32spi
import adafruit_esp32spi.adafruit_esp32spi_socket as socket

My question then (or two) is if anyone know a workaround for this issue
and/or a different socket or server packages I can use instead ?
Here is the full code for the reference, it is not finished and contains more stuff that described here but unrelated to the issue:
import os
import time
import busio
import board
import microcontroller
from digitalio import DigitalInOut, Direction
import adafruit_bh1750
# import adafruit_requests as requests
from adafruit_bme280 import basic as adafruit_bme280
from adafruit_httpserver.server import HTTPServer
from adafruit_httpserver.request import HTTPRequest
from adafruit_httpserver.response import HTTPResponse
from adafruit_httpserver.methods import HTTPMethod
from adafruit_httpserver.mime_type import MIMEType
from adafruit_epd.epd import Adafruit_EPD
from adafruit_epd.il0373 import Adafruit_IL0373
from adafruit_esp32spi import adafruit_esp32spi
import adafruit_esp32spi.adafruit_esp32spi_socket as socket

try:
    from secrets import secrets
except ImportError:
    print("WiFi secrets are kept in secrets.py, please add them there!")
    raise

#  onboard LED setup
# led = DigitalInOut(board.LED)
# led.direction = Direction.OUTPUT
# led.value = False

i2c = board.I2C()  # uses board.SCL and board.SDA
bh1750 = adafruit_bh1750.BH1750(i2c)
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c, 0x76)
bme280.sea_level_pressure = 1012.50

spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
ecs = DigitalInOut(board.D9)
dc = DigitalInOut(board.D10)
srcs = DigitalInOut(board.D6)  # can be None to use internal memory
rst = None #DigitalInOut(board.D1)  # can be None to not use this pin
busy = None #DigitalInOut(board.D5)  # can be None to not use this pin

esp32_cs = DigitalInOut(board.D13)
esp32_ready = DigitalInOut(board.D11)
esp32_reset = DigitalInOut(board.D12)

print("Creating display")
display = Adafruit_IL0373(
    128,
    296,  # 2.9" Tri-color display
    spi,
    cs_pin=ecs,
    dc_pin=dc,
    sramcs_pin=srcs,
    rst_pin=rst,
    busy_pin=busy,
)

display.set_black_buffer(1, True)
display.set_color_buffer(1, True)
display.rotation = 1
display.fill(Adafruit_EPD.WHITE)
# display.display()
# display.text(splash, 12, 12, Adafruit_EPD.BLACK, size=1)

#  connect to network
print("Creating server socket")
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
socket.set_interface(esp)

if esp.status == adafruit_esp32spi.WL_IDLE_STATUS:
    print("ESP32 found and in idle mode")
print("Firmware vers.", esp.firmware_version)
print("MAC addr:", [hex(i) for i in esp.MAC_address])

for ap in esp.scan_networks():
    print("\t%s\t\tRSSI: %d" % (str(ap["ssid"], "utf-8"), ap["rssi"]))

print("Connecting to AP...")
while not esp.is_connected:
    try:
        esp.connect_AP(secrets["ssid"], secrets["password"])
    except OSError as e:
        print("could not connect to AP, retrying: ", e)
        continue
print("Connected to", str(esp.ssid, "utf-8"), "\tRSSI:", esp.rssi)
print("My IP address is", esp.pretty_ip(esp.ip_address))

print("Creating HTTP Server...")
server = HTTPServer(socket)

#  font for HTML
font_family = "monospace"

#  the HTML script
#  setup as an f string
#  this way, can insert string variables from code.py directly
#  of note, use {{ and }} if something from html *actually* needs to be in brackets
#  i.e. CSS style formatting
def webpage():
    html = f"""
    <!DOCTYPE html>

    <meta http-equiv="Content-type" content="text/html;charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Pico W HTTP Server</title>

Pico W HTTP Server

This is a Pico W running an HTTP server with CircuitPython.

The current ambient temperature near the Pico W is
    {temp_test}°{unit}

Control the LED on the Pico W with these buttons:

    <form accept-charset="utf-8" method="POST">
    <button class="button" name="LED ON" value="ON" type="submit">LED ON</button>
</form>

<form accept-charset="utf-8" method="POST">
    <button class="button" name="LED OFF" value="OFF" type="submit">LED OFF</button>
</form>

Party?</h>

<form accept-charset="utf-8" method="POST">
    <button class="button" name="party" value="party" type="submit">PARTY!</button>
</form>

    """
    return html

#  route default static IP
@server.route("/")
def base(request: HTTPRequest):  # pylint: disable=unused-argument
    #  serve the HTML f string
    #  with content type text/html
    with HTTPResponse(request, content_type=MIMEType.TYPE_HTML) as response:
        response.send(f"{webpage()}")

#  if a button is pressed on the site
@server.route("/", method=HTTPMethod.POST)
def buttonpress(request: HTTPRequest):
    #  get the raw text
    raw_text = request.raw_request.decode("utf8")
    print(raw_text)
    #  if the led on button was pressed
    if "ON" in raw_text:
        #  turn on the onboard LED
        led.value = True
    #  if the led off button was pressed
    if "OFF" in raw_text:
        #  turn the onboard LED off
        led.value = False

    #  reload site
    with HTTPResponse(request, content_type=MIMEType.TYPE_HTML) as response:
        response.send(f"{webpage()}")

print("starting server..")
# startup the server
try:
    server.start(esp.pretty_ip(esp.ip_address))
    print("Listening on http://%s:80" % esp.pretty_ip(esp.ip_address))
#  if the server fails to begin, restart the pico w
except OSError:
    time.sleep(5)
    print("restarting..")
    microcontroller.reset()

#  text objects for screen
#  connected to SSID text
connect_text_area.text = "Connected to:"
ssid_text = "%s" % secrets('ssid')
# ssid_text_area = label.Label(terminalio.FONT, text=ssid_text, color=0xFFFFFF, x=0, y=offset_y+15)
#splash.append(ssid_text_area)
#  display ip address
ip_text = "IP: %s" % wifi.radio.ipv4_address
# ip_text_area = label.Label(terminalio.FONT, text=ip_text, color=0xFFFFFF, x=0, y=offset_y+30)
#splash.append(ip_text_area)
#  display temp reading
temp_text = "Temperature: %.02f F" % float(temp_test)
# temp_text_area = label.Label(terminalio.FONT, text=temp_text, color=0xFFFFFF, x=0, y=offset_y+45)
#splash.append(temp_text_area)

def get_weather_conditions():
    temp = bme280.temperature
    print("\nTemperature: %0.1f C" % temp)
    hum = bme280.relative_humidity
    print("Humidity: %0.1f %%" % hum)
    pres = bme280.pressure
    print("Pressure: %0.1f hPa" % pres)
    alt = bme280.altitude
    print("Altitude: %0.2f meters" % alt)
    light = bh1750.lux
    print("Light: %.2f Lux" % light)
    return [temp, hum, pres, alt, light]

clock = time.monotonic() #  time.monotonic() holder for server ping

while True:
    try:
        #  every 30 seconds, ping server & update temp reading
        if (clock + 30) < time.monotonic():
            if wifi.radio.ping(ping_address) is None:
                connect_text_area.text = "Disconnected!"
                ssid_text_area.text = None
                print("lost connection")
            else:
                connect_text_area.text = "Connected to:"
                ssid_text_area.text = "%s" % secrets('ssid')
                print("connected")
            clock = time.monotonic()
            #  comment/uncomment for desired units
            #  temp_test = str(ds18.temperature)
            temp_test = str(c_to_f(19.45))
            temp_text_area.text = "Temperature: %s F" % temp_test

#         display.show(splash)
        #  poll the server for incoming/outgoing requests
        server.poll()
    # pylint: disable=broad-except
    except Exception as e:
        print(e)
        continue

Official answer from Adafuit for this question is that HTTPServer lib is created for Raspeberry PICO and do not work on other boards like Feather M4 express indeed. Different set of libraries needs to be used instead, here is the relevant example:
https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI/tree/main/examples/server


text:
Stepper motor not working with A4988 driver
I have been trying to run stepper motor via Arduino Uno and A4988 motor driver via this tutorial: https://howtomechatronics.com/tutorials/arduino/how-to-control-stepper-motor-with-a4988-driver-and-arduino/
The schematic for my wiring:
So far I have checked the connections multiple times, tried different Arduino boards and A4988 drivers, even tried using a DRV8825 driver, manually declaring HIGH for SLEEP and RESET pins and LOW for ENABLE via arduino. Checked with several batteries which show no problem, even had a friend check the motors via other different driver(YS-DIV268n) he had and the motors worked fine.
I even tried increasing the current from driver via the potentiometer on it but none of these worked.
All this time I observed that the driver got hot quite a lot and that's it.
The arduino code is as follows:
 *
 *  by Dejan Nedelkovski, www.HowToMechatronics.com
 *
 */

// defines pins numbers
const int stepPin = 3;
const int dirPin = 4;

void setup() {
  // Sets the two pins as Outputs
  pinMode(stepPin,OUTPUT);
  pinMode(dirPin,OUTPUT);
}
void loop() {
  digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
  // Makes 200 pulses for making one full cycle rotation
  for(int x = 0; x < 200; x++) {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(500);
  }
  delay(1000); // One second delay

  digitalWrite(dirPin,LOW); //Changes the rotations direction
  // Makes 400 pulses for making two full cycle rotation
  for(int x = 0; x < 400; x++) {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(500);
  }
  delay(1000);
}```

In your for loops you have 2 delays each 500us, so 1ms per step. You are doing this for 200 steps, so each for loop would take 200ms, so only 1/5 of a second (ignoring the execution time of digitalwrite). Have you tried changing the numbers a bit? Using higher delays and doing more steps?

test the driver standalone ... remove the arduino ... use switches to control STEP and DIR


text:
Poor Contact and Low Current Issues with Microswitches in Arduino USB Game Controller
I have made a USB game controller using the Arduino Micro and Omron microswitches (VX-01-1A3) for the buttons. The switch is wired with one end connected to a digital pin and the other end connected to GND. However, I am experiencing issues such as double-clicking, poor contact, and disconnection while using the microswitch. I have tried implementing debounce code, replacing the switch and cables, but the problem persists and often returns after only a few weeks of normal operation.
In the datasheet for the Omron VX series,  I came across a diagram:

which prompted me to measure the current through the switch when pressed, which was only about 0.3mA. Since the digital pin voltage of the Arduino Micro is 5V, this state is not within the normal operating range shown in the diagram.
Could this be the reason for the poor contact of my microswitch?
If so, how can I increase the current through the switch to bring it within the normal operating range? Would adjusting the pull-up resistor (using an external pull-up resistor instead of the Arduino's built-in pull-up resistor) be a feasible solution?
Thank you for your help.

I'm not sure, if this is really the problem, but  yes, using an external pullup resistor with a value small enough will get you a higher current through the switch. Using a 4.7kOhm resistor will give you just above 1mA.


text:
ESPAsyncWebServer code not compiling
Error messages
    Arduino: 1.8.14 Hourly Build 2020/12/15 11:33 (Windows 10), Board: "Generic ESP8266 Module, 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, dtr (aka nodemcu), 26 MHz, 40MHz, DOUT (compatible), 1MB (FS:64KB OTA:~470KB), 2, nonos-sdk 2.2.1+100 (190703), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

In file included from C:\Users\JUNAID\Documents\Arduino\iot_project_4\iot_project_4.ino:4:

    C:\Users\JUNAID\Documents\Arduino\libraries\ESPAsyncWebServer-master\src/ESPAsyncWebServer.h:62:18: error: 'HTTP_GET' conflicts with a previous declaration

       62 |   HTTP_GET     = 0b00000001,

          |                  ^~~~~~~~~~

    In file included from C:\Users\JUNAID\Documents\Arduino\iot_project_4\iot_project_4.ino:2:

    C:\Users\JUNAID\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\libraries\ESP8266WebServer\src/ESP8266WebServer.h:47:29: note: previous declaration 'HTTPMethod HTTP_GET'

       47 | enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };

          |                             ^~~~~~~~

    In file included from C:\Users\JUNAID\Documents\Arduino\iot_project_4\iot_project_4.ino:4:

    C:\Users\JUNAID\Documents\Arduino\libraries\ESPAsyncWebServer-master\src/ESPAsyncWebServer.h:63:18: error: 'HTTP_POST' conflicts with a previous declaration

       63 |   HTTP_POST    = 0b00000010,

          |                  ^~~~~~~~~~

    In file included from C:\Users\JUNAID\Documents\Arduino\iot_project_4\iot_project_4.ino:2:

    C:\Users\JUNAID\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\libraries\ESP8266WebServer\src/ESP8266WebServer.h:47:50: note: previous declaration 'HTTPMethod HTTP_POST'

       47 | enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };

          |                                                  ^~~~~~~~~

    In file included from C:\Users\JUNAID\Documents\Arduino\iot_project_4\iot_project_4.ino:4:

    C:\Users\JUNAID\Documents\Arduino\libraries\ESPAsyncWebServer-master\src/ESPAsyncWebServer.h:64:18: error: 'HTTP_DELETE' conflicts with a previous declaration

       64 |   HTTP_DELETE  = 0b00000100,

          |                  ^~~~~~~~~~

    In file included from C:\Users\JUNAID\Documents\Arduino\iot_project_4\iot_project_4.ino:2:

    C:\Users\JUNAID\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\libraries\ESP8266WebServer\src/ESP8266WebServer.h:47:83: note: previous declaration 'HTTPMethod HTTP_DELETE'

       47 | enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };

          |                                                                                ^~~~~~~~~~~

    In file included from C:\Users\JUNAID\Documents\Arduino\iot_project_4\iot_project_4.ino:4:

    C:\Users\JUNAID\Documents\Arduino\libraries\ESPAsyncWebServer-master\src/ESPAsyncWebServer.h:65:18: error: 'HTTP_PUT' conflicts with a previous declaration

       65 |   HTTP_PUT     = 0b00001000,

          |                  ^~~~~~~~~~

    In file included from C:\Users\JUNAID\Documents\Arduino\iot_project_4\iot_project_4.ino:2:

    C:\Users\JUNAID\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\libraries\ESP8266WebServer\src/ESP8266WebServer.h:47:61: note: previous declaration 'HTTPMethod HTTP_PUT'

       47 | enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };

          |                                                             ^~~~~~~~

    In file included from C:\Users\JUNAID\Documents\Arduino\iot_project_4\iot_project_4.ino:4:

    C:\Users\JUNAID\Documents\Arduino\libraries\ESPAsyncWebServer-master\src/ESPAsyncWebServer.h:66:18: error: 'HTTP_PATCH' conflicts with a previous declaration

       66 |   HTTP_PATCH   = 0b00010000,

          |                  ^~~~~~~~~~

    In file included from C:\Users\JUNAID\Documents\Arduino\iot_project_4\iot_project_4.ino:2:

    C:\Users\JUNAID\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\libraries\ESP8266WebServer\src/ESP8266WebServer.h:47:71: note: previous declaration 'HTTPMethod HTTP_PATCH'

       47 | enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };

          |                                                                       ^~~~~~~~~~

    In file included from C:\Users\JUNAID\Documents\Arduino\iot_project_4\iot_project_4.ino:4:

    C:\Users\JUNAID\Documents\Arduino\libraries\ESPAsyncWebServer-master\src/ESPAsyncWebServer.h:67:18: error: 'HTTP_HEAD' conflicts with a previous declaration

       67 |   HTTP_HEAD    = 0b00100000,

          |                  ^~~~~~~~~~

    In file included from C:\Users\JUNAID\Documents\Arduino\iot_project_4\iot_project_4.ino:2:

    C:\Users\JUNAID\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\libraries\ESP8266WebServer\src/ESP8266WebServer.h:47:39: note: previous declaration 'HTTPMethod HTTP_HEAD'

       47 | enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };

          |                                       ^~~~~~~~~

    In file included from C:\Users\JUNAID\Documents\Arduino\iot_project_4\iot_project_4.ino:4:

    C:\Users\JUNAID\Documents\Arduino\libraries\ESPAsyncWebServer-master\src/ESPAsyncWebServer.h:68:18: error: 'HTTP_OPTIONS' conflicts with a previous declaration

       68 |   HTTP_OPTIONS = 0b01000000,

          |                  ^~~~~~~~~~

    In file included from C:\Users\JUNAID\Documents\Arduino\iot_project_4\iot_project_4.ino:2:

    C:\Users\JUNAID\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\libraries\ESP8266WebServer\src/ESP8266WebServer.h:47:96: note: previous declaration 'HTTPMethod HTTP_OPTIONS'

       47 | enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };

          |                                                                                ^~~~~~~~~~~~

    In file included from C:\Users\JUNAID\Documents\Arduino\iot_project_4\iot_project_4.ino:4:

    C:\Users\JUNAID\Documents\Arduino\libraries\ESPAsyncWebServer-master\src/ESPAsyncWebServer.h:69:18: error: 'HTTP_ANY' conflicts with a previous declaration

       69 |   HTTP_ANY     = 0b01111111,

          |                  ^~~~~~~~~~

    In file included from C:\Users\JUNAID\Documents\Arduino\iot_project_4\iot_project_4.ino:2:

    C:\Users\JUNAID\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\libraries\ESP8266WebServer\src/ESP8266WebServer.h:47:19: note: previous declaration 'HTTPMethod HTTP_ANY'

       47 | enum HTTPMethod { HTTP_ANY, HTTP_GET, HTTP_HEAD, HTTP_POST, HTTP_PUT, HTTP_PATCH, HTTP_DELETE, HTTP_OPTIONS };

          |                   ^~~~~~~~

    Multiple libraries were found for "ESPAsyncTCP.h"

     Used: C:\Users\JUNAID\Documents\Arduino\libraries\ESPAsyncTCP

     Not used: C:\Users\JUNAID\Documents\Arduino\libraries\ESPAsyncTCP-master

    exit status 1

    Error compiling for board Generic ESP8266 Module.

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

Code
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>
int Wifiled = 15;

ESP8266WebServer esp(80);

String HTML = "";

String FORM = "testing the second website";

void setup()
{
       HTML +="";
       HTML +=  "";
       HTML +=    "<title>MY SMART HOME</title>";
       HTML +="";

       HTML +=  "";
       HTML +=  "";
       HTML +=  "
";
       HTML +=    "
WELCOME TO MY SMART SENSOR DATA
";
       HTML +=    "
PH SENSOR DATA
";
       HTML +=    "Serial.monitor";
       HTML +=    "
EC SENSOR DATA
";
       HTML +=  "
";
       HTML +=  "";
       HTML +="";
    pinMode(Wifiled,OUTPUT);
    delay(1000);
    Serial.begin(115200);
    WiFi.begin("LAPTOP","123456789");
    while(WiFi.status() != WL_CONNECTED)
    {
          Serial.print(".");
          digitalWrite(Wifiled,HIGH);
          delay(250);
          digitalWrite(Wifiled,LOW);
          delay(250);
    }
        digitalWrite(Wifiled,HIGH);
        Serial.println("wifi connected");
        Serial.println(WiFi.localIP());

        esp.on("/",sendHtml);
        esp.on("/process",sendform);
        esp.begin();
}
void sendform()
{
  esp.send(200,"text/html;",FORM);
}

void sendHtml()
{
  esp.send(200,"text/html;",HTML);

}

void loop()
{
   esp.handleClient();
   delay(200);
   char buffer[20]="";
   if(Serial.available()>0){
  //  char data=Serial.read();
   Serial.readBytesUntil('\n',buffer,20);
   Serial.println(buffer);
   }
}

ESP8266WebServer conflicts with ESPAsyncWebServer. Both cannot be used in the same program. Your code does not seem to use make use ESPAsyncWebServer or its features, so you could remove the lines #include <ESPAsyncTCP.h> and #include <ESPAsyncWebServer.h> from your code.

please add a clear, answerable question to your post

You've included <ESP8266WebServer.h> and <ESPAsyncWebServer.h>, it's one or the other, you can't have both. Hence you're getting error: 'HTTP_GET' conflicts with a previous declaration


text:
Esp32 fails to read MH-Z19C sensor
I'm trying to read CO2 data from a MH-Z19C sensor with an ESP32 board but I'm not getting anything. The error code from the library is 2 indicating a timeout (no data received).
Did I get the wiring wrong?
I wonder if the sensor is fried ?
Library: MH-Z19 by Jonathan Dempsey
Connections:

MH-Z19C RX to TX2 (17)
MH-Z19C TX to RX2 (16)
MH-Z19C VIN to Power Supply 5V
MH-Z19C GND to Power Supply 3V

Code:
#include <SoftwareSerial.h>
#include <MHZ19.h>
#include <Wire.h>

// pin for uart reading
#define RX_PIN 16  // Rx pin which the MHZ19 Tx pin is attached to.
#define TX_PIN 17 // Tx pin which the MHZ19 Rx pin is attached to.

MHZ19 myMHZ19;
SoftwareSerial mySerial(RX_PIN, TX_PIN);

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

  // Start Co2 sensor
  mySerial.begin(9600);                               // (Uno example) device to MH-Z19 serial start
  myMHZ19.begin(mySerial);                                // *Serial(Stream) refence must be passed to library begin().
  myMHZ19.autoCalibration();                              // Turn auto calibration ON (OFF autoCalibration(false))
}

void loop() {
  // Wait a few seconds between measurements.
  delay(5000);

  int CO2;
  // Request CO2 (as ppm)
  CO2 = myMHZ19.getCO2();
  Serial.println(String(CO2) + " ppm");

  if (myMHZ19.errorCode != RESULT_OK) {
    Serial.print("Failed to receive CO2 value: ");
    Serial.println(myMHZ19.errorCode);
  }
}

It is too difficult to follow your wiring in those pictures. A schematic diagram would be much better. You have mentioned a 3.3v and a 5v supply.  Do these share a common ground?

It is unclear how the GND are connected between the boards. It will be better to have a schematic than those pictures.

ok edited. note that the board is powered with USB while the sensor is powered by a power supply module.

I would connect the esp gnd to the z19c gnd.

Do you mean I should power the sensor with esp's GND/VIN? The issue is that the sensor needs 5v and the board only delivers 3.3V if I'm correct

It means connect PIN1 of ESP32S(GND) to pin2 of of Z19C(GND), basic 101 electronics.

Ok I connected GND of ESP32 to Power Supply GND to which PIN2 of Z19C is also connected. Is that correct? I'm still not receiving any data.

This is not a Winsen Mh-z19 sensor (or any clone following it's specs) so you won't be able to read data using a mhz19 library.
Most probably it's a HC8 sensor and someone would have to rewrite library to get data from it.
Here are specs: https://pcus.ru/download/hc8.pdf and some more info:
https://spezifisch.codeberg.page/posts/2022-08-23/co2-sensor-reverse-engineering/

how do you know it's not mh-z19?