body:
I'm revisiting my Arduino stuff (I want to revive Teleinfo shield to monitor closely my power consumption). I just cannot get the thing to work ([Teleinfo Shield][1] + Uno Wifi).

When trying to check what's happening this is the kind of Serial Monitor screens that I get.

Any hints on how to solve? It happens with other Uno as well and different versions of IDE.

Thank for any help, the answers I found in different places didn't lead me to a solution.

I tried several baud settings, (same for port and monitor, each time) and sometimes nothing was written, sometimes complete garbage, sometimes as illustrated

The code is the following Teleinfo_Arduino_V0_3E.ino (just added some lines writing to serial to follow progress; and modified `Serial.begin` accordingly and "shortened" to stay within size limits but it's sending wrong characters ate beginning))

```c++
/*
              Datalogger Téléinfo 2 compteurs sur Arduino

              Compteur 1: consommation
              Compteur 2: production solaire en tarif BASE

              Juin 2011:
              v0.2  * passage automatique à l'heure d'été
                      correctif erreur abo BBR
                      modification ecriture sur SD (utilisation de teleinfoFile.print à la place s'une variable STRING
                      qui plante l'Arduino avec les abonnements BBR
              v0.2a * ajout mode sans puissance apparente pour ancien compteur et calcul de celle-ci pour les logiciels d'analyse
              v0.2b * pour Arduino 1.0 (mise à jour de la RTC et utilisation de la librairie SD livrée avec la 1.0)
              v0.2c * modif type de variable pour éviter d'avoir 2 enregistrements à la même minute (surtout sur des proc + rapide)
              v0.3  * détection automatique du type d'abonnement sur le compteur 1
              v0.3a * Fonction de mise à l'heure par l'usb (interface série) en 1200 bauds 7 bits parité pair
                      Procédure:
                      1- carte débranchée, enlevez la pile de son support (pour réinitialiser l'horloge)
                      2- enlevez le cavalier du shield téléinfo
                      3- configurer votre logiciel émulateur de terminal (termite,Hyperterminale...) en 1200 bauds 7 bits parité pair
                      4- mettre sous tension la carte.
                      -- Le programme détectera le reset de l'horloge et vous demandera de rentrer l'heure et la date. --

              v0.3b * Correction bug calcul PAP compteur 2, enregistrement journalier compteur 2
              v0.3c * Triphasé sur compteur 2
              v0.3d * correction bug retour ligne sur compteur 2 (entête fichier)
              v0.3e * Correction bug si pas de compteur 2
*/

#include <SD.h>
#include <SPI.h>
#include <Wire.h>
#include <RTClib.h>

const char version_logiciel[6] = "V0.3e";

// #define echo_USB            //envoie toutes les trames téléinfo sur l'USB
#define message_systeme_USB  //envoie des messages sur l'USB (init SD, heure au demarrage, et echo des erreures)

//*****************************************************************************************
byte inByte = 0;  // caractère entrant téléinfo
char buffteleinfo[21] = "";
byte bufflen = 0;
byte mem_sauv_minute = 1;
byte mem_sauv_journee = 1;
byte num_abo = 0;
byte type_mono_tri[2] = { 0, 0 };
uint8_t presence_teleinfo = 0;  // si signal teleinfo présent
byte presence_PAP = 0;          // si PAP présent
boolean cpt2_present = true;    // mémorisation de la présence du compteur 2
boolean compteursluOK = false;  // pour autoriser l'écriture de valeur sur la SD
boolean mem_affichage_cpt2_present = true;

int ReceptionOctet = 0;            // variable de stockage des octets reçus par port série
unsigned int ReceptionNombre = 0;  // variable de calcul du nombre reçu par port série
byte reg_horloge = 1;
boolean mem_reg_horloge = false;
const uint8_t val_max[6] = { 24, 59, 59, 31, 12, 99 };

// declarations Teleinfo
unsigned int papp = 0;  // Puissance apparente, VA

uint8_t IINST[2][3] = { { 0, 0, 0 }, { 0, 0, 0 } };  // Intensité Instantanée Phase 1, A  (intensité efficace instantanée) ou 1 phase en monophasé

unsigned long INDEX1 = 0;  // Index option Tempo - Heures Creuses Jours Bleus, Wh
unsigned long INDEX2 = 0;  // Index option Tempo - Heures Pleines Jours Bleus, Wh
unsigned long INDEX3 = 0;  // Index option Tempo - Heures Creuses Jours Blancs, Wh
unsigned long INDEX4 = 0;  // Index option Tempo - Heures Pleines Jours Blancs, Wh
unsigned long INDEX5 = 0;  // Index option Tempo - Heures Creuses Jours Rouges, Wh
unsigned long INDEX6 = 0;  // Index option Tempo - Heures Pleines Jours Rouges, Wh

// compteur 2 (solaire configuré en tarif BASE par ERDF)
unsigned long cpt2index = 0;     // Index option Base compteur production solaire, Wh
unsigned int cpt2puissance = 0;  // Puissance apparente compteur production solaire, VA

#define debtrame 0x02
#define debligne 0x0A
#define finligne 0x0D

// *************** déclaration carte micro SD ******************
const byte chipSelect = 4;

// *************** déclaration activation compteur 1 ou 2 ******
#define LEC_CPT1 5  // lecture compteur 1
#define LEC_CPT2 6  // lecture compteur 2
//
byte verif_cpt_lu = 0;
//

byte compteur_actif = 1;           // numero du compteur en cours de lecture
byte donnee_ok_cpt[2] = { 0, 0 };  // pour vérifier que les donnees sont bien en memoire avant ecriture dans fichier
byte donnee_ok_cpt_ph[2] = { 0, 0 };

// *************** variables RTC ************************************
byte minute, heure, seconde, jour, mois, jour_semaine;
unsigned int annee;
char date_heure[18];
char mois_jour[7];
byte mem_chg_heure = 0;  //pour pas passer perpetuellement de 3h à 2h du matin le dernier dimanche d'octobre
RTC_DS1307 RTC;

// ************** initialisation *******************************
void setup() {
  // initialisation du port 0-1 lecture Téléinfo
  Serial.begin(1200);
  // parité paire E
  // 7 bits data
  UCSR0C = B00100100;
#ifdef message_systeme_USB
  Serial.print(F("-- Teleinfo USB Arduino "));
  Serial.print(version_logiciel);
  Serial.println(F(" --"));
#endif
  // initialisation des sorties selection compteur
  pinMode(LEC_CPT1, OUTPUT);
  pinMode(LEC_CPT2, OUTPUT);
  digitalWrite(LEC_CPT1, HIGH);
  digitalWrite(LEC_CPT2, LOW);

  // verification de la présence de la microSD et si elle est initialisée:
#ifdef message_systeme_USB
  if (!SD.begin(chipSelect)) {
    Serial.println(F("> Erreur carte, ou carte absente !"));
    return;
  }
  Serial.println(F("> microSD initialisee !"));
#endif

  // initialisation RTC16

  Wire.begin();
  RTC.begin();

  if (!RTC.isrunning()) {
#ifdef message_systeme_USB
    Serial.println(F("RTC non configure !"));
#endif
  }

  DateTime now = RTC.now();  // lecture de l'horloge
  annee = now.year();
  mois = now.month();
  jour = now.day();
  heure = now.hour();
  minute = now.minute();
  jour_semaine = now.dayOfTheWeek();

  format_date_heure();
#ifdef message_systeme_USB
  Serial.println(date_heure);
#endif
}

// ************** boucle principale *******************************

void loop()  // Programme en boucle
{

  if (!(RTC.isrunning()) && (reg_horloge < 7)) {  // si l'horloge n'est pas configurée
    digitalWrite(LEC_CPT1, LOW);

    if (!mem_reg_horloge) {
      switch (reg_horloge) {  // debut de la structure
        case 1:
          Serial.print(F("Entrer Heure: "));
          break;
        case 2:
          Serial.print(F("Entrer Minute: "));
          break;
        case 3:
          Serial.print(F("Entrer Seconde: "));
          break;
        case 4:
          Serial.print(F("Entrer Jour: "));
          break;
        case 5:
          Serial.print(F("Entrer Mois: "));
          break;
        case 6:
          Serial.print(F("Entrer Annee 20xx: "));
          break;
      }
      mem_reg_horloge = true;
    }
    if (Serial.available() > 0) {  // si caractère dans la file d'attente

      Serial.print(F("un nombre a ete recu")); //---- lecture du nombre reçu
      while (Serial.available() > 0) {
        // tant que buffer pas vide pour lire d'une traite tous les caractères reçus
        inByte = Serial.read();         // renvoie le 1er octet présent dans la file attente série (-1 si aucun)
        Serial.println(inByte);
        if (((inByte > 47) && (inByte < 58)) || (inByte == 13)) {
          ReceptionOctet = inByte - 48;  // transforme valeur ASCII en valeur décimale
          if ((ReceptionOctet >= 0) && (ReceptionOctet <= 9)) ReceptionNombre = (ReceptionNombre * 10) + ReceptionOctet;
          // si valeur reçue correspond à un chiffre on calcule nombre
          Serial.print(ReceptionNombre);
          Serial.print(reg_horloge);
        } else
          presence_teleinfo = -1;
      }  // fin while
      if (inByte == 13) {
        if ((ReceptionNombre > val_max[reg_horloge - 1]) || (ReceptionNombre == -1)) {
          Serial.println(F("Erreur horaire"));
          ReceptionNombre = 0;
          mem_reg_horloge = true;
        } else {
          Serial.print("cela bugge");
          switch (reg_horloge) {  // debut de la structure
            case 1:
              heure = ReceptionNombre;
              Serial.print("heure:");
              Serial.println(heure);
            case 2:
              minute = ReceptionNombre;
              break;
            case 3:
              seconde = ReceptionNombre;
              break;
            case 4:
              jour = ReceptionNombre;
              break;
            case 5:
              mois = ReceptionNombre;
              break;
            case 6:
              annee = 2000 + ReceptionNombre;
              break;
          }

          mem_reg_horloge = false;
          ReceptionNombre = 0;
          ++reg_horloge;

          if (reg_horloge > 6) {
            RTCsetTime();
            Serial.println(F("Reglage heure OK - installer le cavalier pour la teleinfo"));
            digitalWrite(LEC_CPT1, HIGH);
          }
        }
      }
    }
  }

  else {

    DateTime now = RTC.now();  // lecture de l'horloge
    minute = now.minute();
    heure = now.hour();
    seconde = now.second();

    if ((heure == 0) && (minute == 0) && (seconde == 0)) {
      annee = now.year();
      mois = now.month();
      jour = now.day();
      jour_semaine = now.dayOfTheWeek();
    }

    // passage à l'heure d'été +1 heure
    // la lib RTC a une fonction: dayOfWeek qui donne le jour de la semaine (la DS1307 se charge de tout !)
    // réponse: 0 -> dimanche, 1 -> lundi etc...
    //
    if ((heure == 2) && (minute == 0) && (seconde == 0) && (jour_semaine == 0) && (mois == 3) && (jour > 24)) {
      heure = 3;
      RTCsetTime();
    }

    // passage à l'heure d'hiver -1 heure
    if ((heure == 3) && (minute == 0) && (seconde == 0) && (jour_semaine == 0) && (mois == 10) && (jour > 24) && (mem_chg_heure == 0)) {
      heure = 2;
      RTCsetTime();
      mem_chg_heure = 1;
    }

    if ((heure == 23) && (minute == 59) && (seconde == 10))  // pour être sur de pas tomber pendant l'enregistrement toutes les minutes
    {
      if ((mem_sauv_journee == 0) && (compteursluOK))  // un seul enregistrement par jour !
      {
        fichier_annee();
        mem_sauv_journee = 1;
        mem_chg_heure = 0;
      }
    } else
      mem_sauv_journee = 0;

    if (seconde == 1) {
      if ((mem_sauv_minute == 0) && (compteursluOK))  // un seul enregistrement par minute !
      {
        enregistre();
        mem_sauv_minute = 1;
      }
    } else
      mem_sauv_minute = 0;

#ifdef message_systeme_USB
    if ((donnee_ok_cpt[1] == B00000111) && (mem_affichage_cpt2_present)) {
      if (mem_affichage_cpt2_present) Serial.println(F("- Compteur 2 detecte"));
      mem_affichage_cpt2_present = false;
    } else if ((!cpt2_present) && (mem_affichage_cpt2_present)) {
      if (mem_affichage_cpt2_present) Serial.println(F("- Compteur 2 non present !"));
      mem_affichage_cpt2_present = false;
    }
#endif

    if ((donnee_ok_cpt[0] == verif_cpt_lu) and (cpt2_present)) {
      if ((type_mono_tri[0] == 1) && (donnee_ok_cpt_ph[0] == B10000001)) bascule_compteur();
      else if ((type_mono_tri[0] == 3) && (donnee_ok_cpt_ph[0] == B10000111))
        bascule_compteur();
    } else if ((donnee_ok_cpt[1] == B00000001) or ((compteur_actif == 2) and (!cpt2_present))) {
      if ((type_mono_tri[1] == 1) && (donnee_ok_cpt_ph[1] == B10000001)) bascule_compteur();
      else if ((type_mono_tri[1] == 3) && (donnee_ok_cpt_ph[1] == B10000111))
        bascule_compteur();
      compteursluOK = true;
    }

    if (compteur_actif == 2) {
      if (presence_teleinfo > 200) {
        cpt2_present = false;
        compteursluOK = true;
        bascule_compteur();
      } else
        cpt2_present = true;
    }

    read_teleinfo();
  }
}

///////////////////////////////////////////////////////////////////
// Calcul Checksum teleinfo
///////////////////////////////////////////////////////////////////
char chksum(char *buff, uint8_t len) {
  int i;
  char sum = 0;
  for (i = 1; i < (len - 2); i++) sum = sum + buff[i];
  sum = (sum & 0x3F) + 0x20;
  return (sum);
}

///////////////////////////////////////////////////////////////////
// mise en forme Date & heure pour affichage ou enregistrement
///////////////////////////////////////////////////////////////////
void format_mois_jour() {
  sprintf(mois_jour, "d,d,", mois, jour);
}

// Convert normal decimal numbers to binary coded decimal
static uint8_t bin2bcd(uint8_t val) {
  return val + 6 * (val / 10);
}

///////////////////////////////////////////////////////////////////
// mise à l'heure de la RTC (DS1307)
///////////////////////////////////////////////////////////////////
void RTCsetTime(void) {
  Wire.beginTransmission(104);  // 104 is DS1307 device address (0x68)
  Wire.write(bin2bcd(0));       // start at register 0

  Wire.write(bin2bcd(seconde));       //Send seconds as BCD
  Wire.write(bin2bcd(minute));        //Send minutes as BCD
  Wire.write(bin2bcd(heure));         //Send hours as BCD
  Wire.write(bin2bcd(jour_semaine));  // dow
  Wire.write(bin2bcd(jour));          //Send day as BCD
  Wire.write(bin2bcd(mois));          //Send month as BCD
  Wire.write(bin2bcd(annee % 1000));  //Send year as BCD

  Wire.endTransmission();
}
```

MacBookPro 2018 runnning Monterey

[![Example output on Serial Monitor][2]][2]

  [1]: https://www.cartelectronic.fr/teleinfo-compteur-enedis/11-shield-teleinfo-arduino-3760313520202.html
  [2]: https://i.stack.imgur.com/Qv9ty.png

title: Garbage in serial monitor

Answers: 1

body:
## Parity mismatch
The essence of the seems to be this:
```c++
Serial.begin(1200);
// parité paire E
// 7 bits data
UCSR0C = B00100100;
```

The code changes the USART to operate with **EVEN** parity and **1** stop bits, or 7E1 [for short][1]. The Arduino serial monitor uses the more common NO parity 1 stop bit configuration (8N1). I did a small hello world type test to confirm that the kind of output you're getting on the Serial Monitor is about like expected for this mismatch.

## Resolving

So, you need them to match. You can:

* Either remove/comment out `UCSR0C = B00100100;` to go with the normal 8N1 configuration.

* Or use a serial [terminal emulator][2] or other software capable of configuring for the port for even parity and 1 stop bits (7E1).

Incidentally, if you have good cause to use 7E1, [the conventional way][3] to do it is `Serial.begin(1200, SERIAL_7E1);` I don't know why they manually manipulated the hardware registers, perhaps the code predates support for this form of `begin()`.

## Serial Monitor Support

The IDE's Serial Monitor is [reportedly capable of being configured][4] for something other than 8N1 via `preferences.txt`. <s>I did not get it working, but I also didn't spend that long trying. Perhaps I will again and update this.</s> I think I didn't close all instances of the IDE. I've now verified that the Serial Monitor can be operated in 7E1 making the following changes to the [arduino15 directory's][5] `preferences.txt` file:

| Old line reading  | New line reading  |
|-------------------|-------------------|
|`serial.databits=8`|`serial.databits=7`|
|`serial.parity=N`  |`serial.parity=E`  |

That said, it is *probably a mistake* to have a change like that hidden away where it will cause lots of confusion later when 8N1 is needed. So, a terminal emulator is still probably a better choice if you actually want or need even parity and 1 stop bits. I in fact I'm going to change mine back now, just so this doesn't catch me. I'd use a regular software [terminal emulator][2] instead of messing with these, but it's to know that you *can* use Serial Monitor if you're forced to do that for whatever reason.

  [1]: https://en.wikipedia.org/wiki/Serial_port#Conventional_notation
  [2]: https://en.wikipedia.org/wiki/List_of_terminal_emulators
  [3]: https://www.arduino.cc/reference/en/language/functions/communication/serial/begin/
  [4]: https://github.com/arduino/Arduino/blob/1.8.19/build/shared/lib/preferences.txt#L274,L276
  [5]: https://docs.arduino.cc/hacking/software/Preferences


body: I am working on a battle bot type of project where their will be 4 transmitters communicating with 4 receivers attached to the robots in the 4 foot x 4 foot playing field. Are their any complications that will arise when trying to run many radio modules at the same time? Like relating to interference or noise? If so, what solutions or work-arounds exist for this problem?

title: Will many nrf24L01 radio modules running at the same time cause interference?

Answers: 2

body: Welcome Rishikesh, there is a great possibility they will have problems. Because I do not know the environment or what the hardware is configured I cannot properly answer your question without a lot more information. I can suggest Look here for some information: https://forum.arduino.cc/t/nrf24l01-transmission-problem/526158/3 Here is another link that will help: https://devzone.nordicsemi.com/f/nordic-q-a/38005/nrf24l01-communication-is-interfered-by-wifi I hope this helps.

body:
According to [HowToMechatronics][1], the NRF24L01 module can use 125 different channels which gives a possibility to have a network of 125 independently working modems in one place. Each channel can have up to 6 addresses.

I believe that as long as you agree a channel allocation amongst competitors there shouldn’t be problems.

For more information on channel setting see https://arduino.stackexchange.com/questions/79452/nrf24l01-channel-switching

  [1]: https://howtomechatronics.com/tutorials/arduino/arduino-wireless-communication-nrf24l01-tutorial/


body:
I have a Bluetooth project for an ESP32 devkit and want to compile it for an ESP32-C3. I use the newest ESP32 Arduino core as a component with esp-idf and the following configuration for `PlatformIO`:

    [platformio]
    src_dir = src
    default_envs = debug

    # Common build environment that is used for each of the tasks
    [env]
    platform = espressif32
    framework = espidf

    board = esp32-c3-devkitm-1

    # 4 MB module version
    board_upload.flash_size = 4MB
    board_upload.maximum_size = 4194304
    board_build.partitions = partitions.csv

    # Settings for serial upload
    upload_speed = 921600
    upload_port = COM2

    # Settings for serial console
    monitor_speed = 115200
    monitor_port = COM2
    monitor_filters = esp32_exception_decoder

    # Additional packages
    platform_packages =

    # Aditional build scripts for all environments to run before (`pre`) and after (`post`) the main build script
    extra_scripts =

    # Common build flags for all environments
    build_flags =

    lib_deps =
        bblanchon/ArduinoJson@^6.18.0

    [env:debug]
    build_type = debug

    build_flags =
        ${env.build_flags}
        -D DEBUG
        -D APP_VERSION_POST='debug'

    lib_deps =
        ${env.lib_deps}

    extra_scripts =
        ${env.extra_scripts}

    [env:release]
    build_type = debug

    build_flags =
        ${env.build_flags}
        -D RELEASE

    lib_deps =
        ${env.lib_deps}

    extra_scripts =
        ${env.extra_scripts}

I use the following toolchain:

     - framework-espidf @ 3.40401.0 (4.4.1)
     - tool-cmake @ 3.16.4
     - tool-esptoolpy @ 1.30300.0 (3.3.0)
     - tool-idf @ 1.0.1
     - tool-mconf @ 1.4060000.20190628 (406.0.0)
     - tool-ninja @ 1.9.0
     - toolchain-riscv32-esp @ 8.4.0+2021r2-patch3

But I got the following error during the linking:

    .platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: .pio\build\debug\esp-idf\arduino-esp32\libarduino-esp32.a(BLEAdvertising.o): in function `BLEAdvertising::start()':
    components/arduino-esp32/libraries/BLE/src/BLEAdvertising.cpp:247: undefined reference to `esp_ble_gap_start_advertising'
    .platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: components/arduino-esp32/libraries/BLE/src/BLEAdvertising.cpp:214: undefined reference to `esp_ble_gap_config_adv_data'
    .platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld.exe: components/arduino-esp32/libraries/BLE/src/BLEAdvertising.cpp:225: undefined reference to `esp_ble_gap_config_adv_data'

**Update 1**

A verbose build outputs the following command before the error appears:

    riscv32-esp-elf-g++ -o .pio\build\debug\firmware.elf -T memory.ld -u esp_app_desc -u pthread_include_pthread_impl -u pthread_include_pthread_cond_impl -u pthread_include_pthread_local_storage_impl -u pthread_include_pthread_rwlock_impl -u include_esp_phy_override -u start_app -T sections.ld
    -u __ubsan_include -T esp32c3.rom.ld -T esp32c3.rom.api.ld -T esp32c3.rom.libgcc.ld -T esp32c3.rom.newlib.ld -T esp32c3.rom.version.ld -T esp32c3.rom.newlib-time.ld -T esp32c3.rom.eco3.ld -u __assert_func -u vfs_include_syscalls_impl -T esp32c3.peripherals.ld -u app_main -u newlib_include_heap_impl -u newlib_include_syscalls_impl -u newlib_include_pthread_impl -u newlib_include_assert_impl -u __cxa_guard_dummy -u __cxx_fatal_exception --specs=nosys.specs -Wl,--Map=C:/Projects/firmware-loader/.pio/build/debug/Firmware-Loader.map -Wl,--cref -Wl,--gc-sections -Wl,--undefined=uxTopUsedPriority -Wl,--wrap=_Unwind_Backtrace -Wl,--wrap=_Unwind_DeleteException -Wl,--wrap=_Unwind_FindEnclosingFunction -Wl,--wrap=_Unwind_Find_FDE
    -Wl,--wrap=_Unwind_ForcedUnwind -Wl,--wrap=_Unwind_GetCFA -Wl,--wrap=_Unwind_GetDataRelBase -Wl,--wrap=_Unwind_GetGR -Wl,--wrap=_Unwind_GetIP -Wl,--wrap=_Unwind_GetIPInfo -Wl,--wrap=_Unwind_GetLanguageSpecificData -Wl,--wrap=_Unwind_GetRegionStart -Wl,--wrap=_Unwind_GetTextRelBase -Wl,--wrap=_Unwind_RaiseException -Wl,--wrap=_Unwind_Resume -Wl,--wrap=_Unwind_Resume_or_Rethrow -Wl,--wrap=_Unwind_SetEnableExceptionFdeSorting -Wl,--wrap=_Unwind_SetGR -Wl,--wrap=_Unwind_SetIP -Wl,--wrap=__cxa_call_unexpected -Wl,--wrap=__deregister_frame_info -Wl,--wrap=__deregister_frame_info_bases -Wl,--wrap=__gxx_personality_v0 -Wl,--wrap=__register_frame -Wl,--wrap=__register_frame_info -Wl,--wrap=__register_frame_info_bases -Wl,--wrap=__register_frame_info_table -Wl,--wrap=__register_frame_info_table_bases -Wl,--wrap=__register_frame_table -fno-lto -fno-rtti -march=rv32imc -nostartfiles -Og -g2 -ggdb2 .pio\build\debug\src\Devices\JERRY\jerry.o .pio\build\debug\src\Devices\Memory\memory.o .pio\build\debug\src\Devices\TOM\I2CM.o .pio\build\debug\src\Devices\TOM\tom.o .pio\build\debug\src\Loader\loader.o .pio\build\debug\src\Version\version.o .pio\build\debug\src\main.o -L.pio\build\debug -LC:\.platformio\packages\framework-espidf\components\bt\controller\lib_esp32c3_family\esp32c3 -LC:\.platformio\packages\framework-espidf\components\esp_wifi\lib\esp32c3 -LC:\.platformio\packages\framework-espidf\components\esp_phy\lib\esp32c3 -L.pio\build\debug\esp-idf\esp_system\ld -LC:\.platformio\packages\framework-espidf\components\esp_rom\esp32c3\ld -LC:\.platformio\packages\framework-espidf\components\esp_wifi\lib\esp32c3 -LC:\.platformio\packages\framework-espidf\components\soc\esp32c3\ld -Wl,--start-group .pio\build\debug\esp-idf\esp_ringbuf\libesp_ringbuf.a .pio\build\debug\esp-idf\asio\libasio.a .pio\build\debug\esp-idf\protobuf-c\libprotobuf-c.a .pio\build\debug\esp-idf\esp_lcd\libesp_lcd.a .pio\build\debug\esp-idf\mdns\libmdns.a .pio\build\debug\esp-idf\protocomm\libprotocomm.a .pio\build\debug\esp-idf\cbor\libcbor.a .pio\build\debug\esp-idf\cmock\libcmock.a .pio\build\debug\esp-idf\unity\libunity.a .pio\build\debug\esp-idf\bt\libbt.a .pio\build\debug\esp-idf\coap\libcoap.a .pio\build\debug\esp-idf\esp_adc_cal\libesp_adc_cal.a .pio\build\debug\esp-idf\esp_hid\libesp_hid.a .pio\build\debug\esp-idf\wear_levelling\libwear_levelling.a .pio\build\debug\esp-idf\esp_local_ctrl\libesp_local_ctrl.a .pio\build\debug\esp-idf\esp_websocket_client\libesp_websocket_client.a .pio\build\debug\esp-idf\expat\libexpat.a .pio\build\debug\esp-idf\fatfs\libfatfs.a .pio\build\debug\esp-idf\freemodbus\libfreemodbus.a .pio\build\debug\esp-idf\spiffs\libspiffs.a .pio\build\debug\esp-idf\openssl\libopenssl.a .pio\build\debug\esp-idf\libsodium\liblibsodium.a .pio\build\debug\esp-idf\jsmn\libjsmn.a .pio\build\debug\esp-idf\mqtt\libmqtt.a .pio\build\debug\esp-idf\json\libjson.a .pio\build\debug\esp-idf\wifi_provisioning\libwifi_provisioning.a .pio\build\debug\esp-idf\arduino-esp32\libarduino-esp32.a .pio\build\debug\esp-idf\RAK3172\libRAK3172.a .pio\build\debug\esp-idf\app_trace\libapp_trace.a .pio\build\debug\esp-idf\app_update\libapp_update.a .pio\build\debug\esp-idf\bootloader_support\libbootloader_support.a .pio\build\debug\esp-idf\console\libconsole.a .pio\build\debug\esp-idf\cxx\libcxx.a .pio\build\debug\esp-idf\driver\libdriver.a .pio\build\debug\esp-idf\efuse\libefuse.a .pio\build\debug\esp-idf\esp-tls\libesp-tls.a .pio\build\debug\esp-idf\esp_common\libesp_common.a .pio\build\debug\esp-idf\esp_event\libesp_event.a .pio\build\debug\esp-idf\esp_gdbstub\libesp_gdbstub.a .pio\build\debug\esp-idf\esp_http_client\libesp_http_client.a .pio\build\debug\esp-idf\esp_http_server\libesp_http_server.a .pio\build\debug\esp-idf\esp_https_ota\libesp_https_ota.a .pio\build\debug\esp-idf\esp_hw_support\libesp_hw_support.a .pio\build\debug\esp-idf\esp_ipc\libesp_ipc.a .pio\build\debug\esp-idf\esp_netif\libesp_netif.a .pio\build\debug\esp-idf\esp_phy\libesp_phy.a .pio\build\debug\esp-idf\esp_pm\libesp_pm.a .pio\build\debug\esp-idf\esp_rom\libesp_rom.a .pio\build\debug\esp-idf\esp_serial_slave_link\libesp_serial_slave_link.a .pio\build\debug\esp-idf\esp_system\libesp_system.a .pio\build\debug\esp-idf\esp_timer\libesp_timer.a .pio\build\debug\esp-idf\esp_wifi\libesp_wifi.a .pio\build\debug\esp-idf\espcoredump\libespcoredump.a .pio\build\debug\esp-idf\freertos\libfreertos.a .pio\build\debug\esp-idf\hal\libhal.a .pio\build\debug\esp-idf\heap\libheap.a .pio\build\debug\esp-idf\log\liblog.a .pio\build\debug\esp-idf\lwip\liblwip.a .pio\build\debug\esp-idf\mbedtls\libmbedtls.a .pio\build\debug\esp-idf\newlib\libnewlib.a .pio\build\debug\esp-idf\nghttp\libnghttp.a .pio\build\debug\esp-idf\nvs_flash\libnvs_flash.a .pio\build\debug\esp-idf\pthread\libpthread.a .pio\build\debug\esp-idf\riscv\libriscv.a .pio\build\debug\esp-idf\sdmmc\libsdmmc.a .pio\build\debug\esp-idf\soc\libsoc.a .pio\build\debug\esp-idf\spi_flash\libspi_flash.a .pio\build\debug\esp-idf\tcp_transport\libtcp_transport.a .pio\build\debug\esp-idf\tcpip_adapter\libtcpip_adapter.a .pio\build\debug\esp-idf\vfs\libvfs.a .pio\build\debug\esp-idf\wpa_supplicant\libwpa_supplicant.a .pio\build\debug\esp-idf\mbedtls\mbedtls\library\libmbedcrypto.a .pio\build\debug\esp-idf\mbedtls\mbedtls\library\libmbedtls.a .pio\build\debug\esp-idf\mbedtls\mbedtls\library\libmbedx509.a -lbtdm_app -lcoexist -lcore -lespnow -lmesh -lnet80211 -lpp -lsmartconfig -lwapi -lphy -lbtbb -lgcov -lc -lm -lstdc++ -lgcc -Wl,--end-group

**Update 2**

It looks like `libbt.a` isn´t linked. May this cause this issue? How can I fix it or where do I find the required part in the build system of pio?

title: ESP32-C3 - undefined reference to `esp_ble_gap_start_advertising'

Answers: 1

body:
I have had a very similar issue just now. In short, the solution was to rename library file from .c to .cpp

Extended explanation. My platformio.ini:
```
[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
```

I am using third-party library which I build from source. This library is provided by two  "lib_name.c" and "lib_name.h" files, which I have put into a lib/lib_name/ directory according to Platformio [README](https://github.com/platformio/platform-ststm32/blob/develop/examples/arduino-blink/lib/README) file.

It was failing during linkage until I renamed "lib_name.c" to "lib_name.cpp", header file remained untouched.


body:
I am making a project where if the push button is pressed, the LCD screen will show a message. But with many trial and errors, it doesn't give the right result.

Here is the circuit:
[![][1]][1]

Here is the code:
```
#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
#define BUTTON 7
void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  pinMode(BUTTON, INPUT);
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 0);
  // print the number of seconds since reset:
  lcd.print("Press Button");
  lcd.setCursor(0,1);
  lcd.print("to make COFFEE");
  if (digitalRead(BUTTON) == HIGH) {
    lcd.clear();
    lcd.print("SENT TO MACHINE");
  }
}
```

  [1]: https://i.stack.imgur.com/zhv7W.jpg

title: Problem with push button

Answers: 2

body:
you should implement debouncing because when you press the button with your hand it will bounce and make the signal instable so no High/Low, here's the doc from Arduino:

https://www.arduino.cc/en/Tutorial/BuiltInExamples/Debounce

body:
It looks like you have several issues.

1. The positive and negative supply "rails" on your prototyping board are not connected together internally. You should add a positive jumper wire.

2. You are trying to detect when the button provides a `HIGH` logic level, but there is no possibility of doing so with the current "wiring".

One more thing that could help to determine this, or another possible issue, is a picture of your setup from a different angle so we can see exactly how that button, capacitor, and resistor are connected.

This is the area which would be nice to see from a different angle.

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

  [1]: https://i.stack.imgur.com/Vq3G8.jpg


body:
I've been looking around for a solution, but couldn't manage to find one. I'm looking to send a post request from an ESP8266 on a local API.
Here is my code :
```
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>

String ssid = "HUAWEI P30 lite";
String password = "testazerty";
String serverName = "http://192.168.56.1:3030/drink/voltron";

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  Serial.println("Connecting");
  while(WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to WiFi network with IP Address: ");
  Serial.println(WiFi.localIP());
}

void loop() {

    if(WiFi.status()== WL_CONNECTED){
      WiFiClient client;
      HTTPClient http;

      http.begin(client, serverName);

      http.addHeader("Content-Type", "application/json");
      int httpResponseCode = http.POST("{\"city\":\"toronto\"}");

      Serial.print("HTTP Response code: ");
      Serial.println(httpResponseCode);

      http.end();
  }
}
```

Both my computer and ESP8266 are connected to my phone network (HUAWEI).

192.168.56.1 is the IP of my computer.

API is running, and I can successfully make the request from postman (see image below).

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

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

It always return -1 as http code. I activated debug level HTTP_CLIENT, here is what I have on the serial monitor :

```
11:07:41.645 -> SDK:2.2.2-dev(38a443e)/Core:3.0.2=30002000/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-48-g7421258/BearSSL:6105635
11:07:41.645 -> fpm close 1
11:07:41.645 -> mode : sta(30:83:98:b1:da:62)
11:07:41.645 -> add if0
11:07:41.645 -> Connecting
11:07:42.160 -> .....scandone
11:07:45.348 -> state: 0 -> 2 (b0)
11:07:45.348 -> .state: 2 -> 3 (0)
11:07:45.441 -> state: 3 -> 5 (10)
11:07:45.441 -> add 0
11:07:45.441 -> aid 6
11:07:45.441 -> cnt
11:07:45.441 ->
11:07:45.441 -> connected with HUAWEI P30 lite, channel 6
11:07:45.441 -> dhcp client start...
11:07:45.864 -> ....ip:192.168.43.88,mask:255.255.255.0,gw:192.168.43.1
11:07:47.870 -> .
11:07:47.870 -> Connected to WiFi network with IP Address: 192.168.43.88
11:07:47.870 -> [HTTP-Client][begin] url: http://192.168.56.1:3030/drink/voltron
11:07:47.870 -> [HTTP-Client][begin] host: 192.168.56.1 port: 3030 url: /drink/voltron
11:07:47.870 -> [HTTP-Client][sendRequest] type: 'POST' redirCount: 0
11:07:53.021 -> [HTTP-Client] failed connect to 192.168.56.1:3030
11:07:53.021 -> [HTTP-Client][returnError] error(-1): connection failed
11:07:53.021 -> HTTP Response code: -1
11:07:53.021 -> [HTTP-Client][end] tcp is closed
```

title: POST request (HTTPClient) with ESP8266 not working on localhost (http code = -1)

Answers: 1

body:
**TLDR**:

This is a networking problem, not a programming problem. Try changing your subnet mask to 255.255.0.0 on your router/network configuration, or make sure they're actually connected to the same router. If different routers, try to change one to a "Wireless Access Point" configuration. If you can't get them on the same network, you will have to expose your API to the Internet.

**Long version:**

You are on different subnets. Your API IP address is 192.168.56.1 and your device IP address is 192.168.43.88, but your subnet mask is 255.255.255.0. That puts these devices on separate subnets within the network.

There are a lot of complicated explanations of subnets and subnet masks on the internet. I linked one of the better ones below. Technically, you are not just on different subnets but on different networks entirely. You have a 192.x.x.x IP address, making it a Class C network. That makes your address pattern one of "network.network.network.node". Depending on your router configuration or other network hardware, you can upgrade it to a Class B network by customizing your subnet mask as 255.255.0.0 ("network.network.node.node"). Class B addresses might require a lot of customization on your end depending on your specific circumstances. By using a subnet mask of 255.255.0.0 on a Class B address, you classify the IP address parts .56.1 and .43.88 as being on the same network AND subnet. If you change it to Class B addressing without changing the subnet, the .56 will be one subnet and .43 will be a different subnet.

Sometimes this addressing is done automatically based on the installed hardware. This is especially problematic in home networks containing multiple wireless routers but connected to the same modem. Many home routers have a "Wireless Access Point" setting that removes a lot of the more complex router configuration. This _might_ convince your router(s) to put you onto the same subnet. If that works, you now have your devices able to connect locally! Additional router configuration might be required to expose ports for your API to incoming requests across subnets.

If your network class is being determined by your ISP and you can't get your devices onto the same network, you have to expose your API to the Wild Wild Web :D There are many services which allow for Dynamic DNS, but I'd suggest reading through https://www.ionos.com/digitalguide/server/tools/free-dynamic-dns-providers-an-overview/ and selecting one that meets your needs. This WILL require advanced router configuration to expose ports to the internet. *Please select a Dynamic DNS services that provides DDOS protection.* Once it is exposed, your ESP8266 can hit your API as it would any public API. *Please put authentication on your API.*

References:

 - Subnet explanation -
   http://www.steves-internet-guide.com/subnetting-subnet-masks-explained/
 - Dynamic DNS providers -
   https://www.ionos.com/digitalguide/server/tools/free-dynamic-dns-providers-an-overview/


body:
I'm working on RF transmitter and receiver modules using two Arduino UNOs. I'm getting an additional noise on the receiver side in serial.println.
To be more clear about the question. Hre is my transmitter code
```
// Include RadioHead Amplitude Shift Keying Library
#include <RH_ASK.h>
// Include dependant SPI Library
#include <SPI.h>

// Create Amplitude Shift Keying Object
RH_ASK rf_driver;

void setup()
{
    // Initialize ASK Object
    rf_driver.init();
    Serial.begin(9600);
}

void loop()
{

    const char *msg = "Hello World";
    rf_driver.send((uint8_t *)msg, strlen(msg));
    rf_driver.waitPacketSent();
    Serial.println((char *)msg);
    delay(1000);
}
```
Here is my receiver code

```
// Include RadioHead Amplitude Shift Keying Library
#include <RH_ASK.h>
// Include dependant SPI Library
#include <SPI.h>

// Create Amplitude Shift Keying Object
RH_ASK rf_driver;

void setup()
{
    // Initialize ASK Object
    rf_driver.init();
    // Setup Serial Monitor
    Serial.begin(9600);
}

void loop()
{
    // Set buffer to size of expected message
    uint8_t buf[11];
    uint8_t buflen = sizeof(buf);
    // Check if received packet is correct size
    if (rf_driver.recv(buf, &buflen))
    {

      // Message received with valid checksum
      Serial.print("Message Received: ");
      Serial.println((char*)buf);
    }
}
```
And here is my Serial monitor in receiver side
[![enter image description here][1]][1]

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

So, can somebody help me to sort out this issue

title: Noise in RF 434 transmitter and receiver

Answers: 1

body:
You're treating a raw buffer as a string.

In C a string is an array of characters (11 in your case) terminated by a NULL character.  You receive 11 bytes into an 11 byte array and then try and print it - without any terminating character - so the output "overruns" into the memory following your array.

You need a buffer of 12 bytes not 11, and you have to make sure that the 12th byte (byte number 11) is zero.

Or use `Serial.write(buf, buflen);` function to write exactly 11 bytes to the serial.


body:
I have the [LiquidCrystal][1] library installed but all the examples are for 4bit connection, I want to drive the LCD with 8bit.

In [LiquidCrystal.cpp][2] file it says;

> When the display powers up, it is configured as follows:
>
> DL = 1;  8-bit interface data

But what's is the function, should it be like this: `LiquidCrystal DL(1);`? where and how should I call `DL = 1;`?

  [1]: https://github.com/arduino-libraries/LiquidCrystal
  [2]: https://github.com/arduino-libraries/LiquidCrystal/blob/master/src/LiquidCrystal.cpp

title: How to configure 16x2 character LCD to work with 8bit?

Answers: 1

body:
You don't "do" anything to enable 8 bit. As it says *when the device powers up the DL bit in the configuration is already set, enabling 8 bit*.

You just need to wire it for 8 bit and specify all 8 bits of wiring in the constructor.

The manual entry for the constructor shows you what parameters you can specify:

* https://www.arduino.cc/reference/en/libraries/liquidcrystal/liquidcrystal/


body:
I have a micro turbojet engine (JetCat P100-RX) which is operated through an Electronic Control Unit (ECU).

The ECU has a lot of information about the engine. I want to access that information and also send commands to the ECU to control the engine.

The ECU connects to a Mini I/O device. This connection is shown in the following image:

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

The details of both the ECU serial connection and the Mini I/O Board are given in this [manual page 4](https://drive.google.com/drive/folders/1jYtRedA0ksGDQHBmZBbjBBeUp2QfvV8y?usp=sharing). (What I understand here is that the data stream from the Mini Board follows a RS232 protocol.) It looks as shown:

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

I would like to collect the information from the Tx, Rx and GND pins using the Arduino Uno.
How can I do this? The Arduino is connected to my PC through the USB port.

**EDIT1:** What I tried doing:

I connected the Tx, Rx and GND of the Mini Board to pins 10 and 11 of the Arduino and configured 10 and 11 as serial pins and GND to Arduino GND (Rx anf Tx respectively) using SerialSoftware as follows:

```c++
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

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

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600); // Set to 9600 as the manual says (link above)
}

void loop() {
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
}
```

My circuit diagram:

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

**But I don't get any output on the Serial Monitor.**

While reading online I found out that I need some converter. Following these posts, I have bought a MAX3232. Do I need to use that? How do I use that and what changes do I make in my code?

  [1]: https://i.stack.imgur.com/uvdkF.jpg
  [2]: https://i.stack.imgur.com/PrHtl.png
  [3]: https://i.stack.imgur.com/3ha00.png

title: Using Arduino to read and write data to RS232 device

Answers: 1

body:
That is relatively easy to do.  If you have a Mega or another Arduino that has more than one serial port, great. If not, then softwareserial is what you need. For this to work all grounds must be connected.

Softwareserial can only receive on one channel at a time. On the hardware level you should use a high-impedance receiver to monitor both the RX and TX signals. I use a 74HC14 (74C914 is rated at +- 25 V on its input) or similar device. Place a 50 kΩ resistor from the RX to an input on the IC, do the same with the TX to another input on the IC. The input protection diodes of the 74HC will limit the current, at 50 kΩ 50 V gives 1 mA.

Connect the outputs of the IC to inputs of the Arduino. Each input needs to be configured to receive ASYNC input at the correct baud and other parameters. I have done this many times and it works great. I always did it with UARTs, not software. Note the 74HC device inverts the signal as is normal with RS232. There are various modules available for the Arduino that have a USART, UART or similar serial device on them.


body:
I'm literally new to using Arduino, i am trying to build a Pitot Tube to measure airspeed using an MPX10DP differential pressure sensor and i am working with an Arduino Mega 2560.

Honestly, i have studied some tutorials of people building a Pitot Tube but the pressure sensors they use are not available in my region, the only pressure that i could afford is the MPX10DP but i am not sure of how to connect it to my arduino and make it get values.

Can someone help me or guide me a bit?

title: Connect an MPX10DP Pressure Sensor to an Arduino Mega 2560

Answers: 1

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


body: I successfully uploaded a sketch to my Arduino Micro using the USB serial port but if I try to change the sketch that port is not available. The sketch I uploaded on the Micro runs fine when I plug in the USB cable. The ports shown are /dev/cu.Bluetooth-Incoming-Port and /dev/cu.wlan-debug. If I plug in a different chip the port is there. What would cause it to disappear for the Micro?

title: USB serial port no longer detected after successful upload

Answers: 1

body: Problem fixed by following suggestion from namakada81 "Open an empty arduino sketch, select the pro micro and no port, click upload and as soon as the ide says "uploading" reset the arduino


body:
I am using a custom Arduino Nano compatible board with an Atmel 328P.  I am externally changing the values applied to several pins on PORTB.  I expect to be able to read the values of these pins (low or high) but I always read zeroes.  However, the pin change interrupt is called.  What do I need to do to read values from PORTB?

Supply voltage is 5 volts.  Pin applied high voltage is 3.3 volts.

With the below code, when I change the voltage applied to a pin, LED1 flashes but LED2 does not.

```#include <avr/io.h>
#include <avr/interrupt.h>

#define LED1_PORT                           (PORTD)
#define LED1_PIN_bm                         (_BV(4))         //D1, white

#define LED2_PORT                           (PORTD)
#define LED2_PIN_bm                         (_BV(3))         //D2, red

volatile bool g_bValueChanged = 0;

void setup()
{
  DDRB = 0;                     //set all as inputs
  PCMSK0 = 0xfb;                //exclude 1 pin because of noise
  PCICR |= (1 << PCIE0);        //enable pin change interrupt 0 (for pins PB0..7)

  sei();
}

uint8_t g_valuePrevious = 0;

void loop()
{
  if (g_bValueChanged)
  {
    g_bValueChanged = false;

    LED1_PORT |= LED1_PIN_bm;
    delay(40);
    LED1_PORT &= ~LED1_PIN_bm;
    delay(40);
  }

  uint8_t value = PORTB;
  if (value != g_valuePrevious)
  {
    g_valuePrevious = value;

    LED2_PORT |= LED2_PIN_bm;
    delay(40);
    LED2_PORT &= ~LED2_PIN_bm;
    delay(40);
  }
}

ISR(PCINT0_vect)
{
    g_bValueChanged = true;
}
```

title: Why am I reading only zeroes from PORTB?

Answers: 1

body:
The `PORTB` register is initialized by the hardware to zero. You never
write to this register, so it always stays zero.

Maybe you are mixing up `PORTB` and `PINB`:

* `PORTB` is the port **output** register, controlled by you
* `PINB` is the port **input** register, for which the bits
  corresponding to input pins are controlled by whatever drives those
  pins from the outside.


body:
i am trying to make a stop watch with a stop/start button and a reset button

i have made this

    #include "RTClib.h"
    //Setup the Real Time Clock, DS3231
    RTC_DS3231 rtc;

    const byte SQWinput = 2;  // Must be External Interrupt

    volatile uint32_t  MillisecondsAtStartOfSecond = 0;

     unsigned long secondss=0 ;
     unsigned long minutess=0 ;

     unsigned long  hourss =0;
     unsigned long ms;

    boolean passed_second=true;
    boolean start=true;

    const byte ledPin = 13;

    const byte startButton = 7;

    const byte resetButton = 3;
    // Instantiate another Bounce object

    const char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

    // The SQW pin, when set to 1 Hz mode, has a falling edge at the beginning of every second.
    void SQWFallingISR()
    {
      MillisecondsAtStartOfSecond = millis();
    }

    void setup ()
    {
      Serial.begin(9600); // Set Serial Monitor to 115200
      delay(200);

      pinMode(7, INPUT);
      digitalWrite(7, HIGH);
      pinMode(3, INPUT);
      digitalWrite(3, HIGH);

      if (! rtc.begin())
      {
        Serial.println("Couldn't find RTC");
        Serial.flush();
        abort();
      }

      if (rtc.lostPower())
      {
        Serial.println("RTC lost power, let's set the time!");
        // When time needs to be set on a new device, or after a power loss, the
        // following line sets the RTC to the date & time this sketch was compiled
        rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
        // This line sets the RTC with an explicit date & time, for example to set
        // January 21, 2014 at 3am you would call:
        // rtc.adjust(DateTime(2022, 4, 03, 21, 14, 0));
      }

      // Configure SQW pin on the DS3231 to output a 1Hz squarewave
      rtc.writeSqwPinMode(DS3231_SquareWave1Hz);

      // Get MillisecondsAtStartOfSecond on the falling edge of SQW.
      attachInterrupt(digitalPinToInterrupt(SQWinput), SQWFallingISR, FALLING);
    }

    void loop ()
    {
      DateTime now = rtc.now();

        ms = millis();

      noInterrupts();
      // How long since the second started?

      ms -= MillisecondsAtStartOfSecond;
      interrupts();

      if(digitalRead(7) != HIGH)   //START BUTTON
    {    displayTime (now, ms);
         Serial.println("stopwatch  ");

      Serial.print(hourss);
      Serial.print(':');
      Serial.print(minutess);
      Serial.print(':');
      Serial.print(secondss);
      Serial.print(':');
      Serial.println(ms);
    }

     if(digitalRead(3) != HIGH)   //RESET BUTTON
    {
         Serial.println("stopwatch  ");

      Serial.print(0);
      Serial.print(':');
      Serial.print(0);
      Serial.print(':');
      Serial.print(0);
      Serial.print(':');
      Serial.println(0);
      ms=0;
    }
     // displayTime (now, ms);
      /*Serial.println("stopwatch  ");

      Serial.print(hourss);
      Serial.print(':');
      Serial.print(minutess);
      Serial.print(':');
      Serial.print(secondss);
      Serial.print(':');
      Serial.println(ms);
      Serial.println("*********************************");
      Serial.println("Clock & Date  ");*/

      }

    void displayTime(DateTime &now, unsigned long ms)
    {
      ms = ms % 1000;  // Ignore full seconds

      Serial.print(now.year(), DEC);
      Serial.print('/');
      Serial.print(now.month(), DEC);
      Serial.print('/');
      Serial.print(now.day(), DEC);
      Serial.print(" (");
      Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
      Serial.print(") ");
      Serial.print(now.hour(), DEC);
      Serial.print(':');
      if (now.minute() < 10)
        Serial.print('0');
      Serial.print(now.minute(), DEC);
      Serial.print(':');
      if (now.second() < 10)
        Serial.print('0');
      Serial.print(now.second(), DEC);
     // Serial.println();
      Serial.print(':');
      if (ms < 100)
        Serial.print('0');
      if (ms < 10)
        Serial.print('0');
      Serial.print(ms, DEC);
      Serial.println();
      Serial.println("*********************************");

      if(ms>998) {
          secondss++;

      }
        if(secondss>59) {
         secondss=0;
          minutess++;

        }
        if(minutess>59) {
         minutess=0;
          hourss++;}

        }

but it is not working properly

the time is not incrementing after ms reaches 999

what is causing this?

title: Stopwatch stop/start button and reset

Answers: 1

body:
This code is quite confusing, as you are using both `millis()` and an
RTC as time sources.

Your problem may come from here:

```c++
ms -= MillisecondsAtStartOfSecond;
```

If the internal clock of your Arduino is a bit off, it may happen that
an RTC second is only 999 milliseconds from `millis()`. If that happens,
then `ms` will never hit 999, and will instead go straight from 998
to 0.

Or maybe it's here:

```c++
ms = ms % 1000;  // Ignore full seconds
// ...
if (ms > 998) {
    secondss++;
}
```

If you sketch is busy (maybe it is communicating with the RTC), it may
not run this code precisely at millisecond 999. And 999 is the only
value of `ms` that can possibly increment `secondss`.

For a stopwatch, you don't really need the RTC data. You can implement
it entirely on the basis of `millis()`, and that would simplify things:

```c++
bool stop_watch_running;
uint32_t stop_watch_last_update;
uint16_t stop_watch_ms;
uint8_t stop_watch_s;
uint8_t stop_watch_min;
uint8_t stop_watch_h;

void stop_watch_reset() {
    stop_watch_running = false;
    stop_watch_ms = 0;
    stop_watch_s = 0;
    stop_watch_min = 0;
    stop_watch_h = 0;
}

void stop_watch_start() {
    stop_watch_last_update = millis();
    stop_watch_running = true;
}

// Call this periodically.
void stop_watch_update() {
    if (!stop_watch_running)
        return;
    uint32_t now = millis();
    stop_watch_ms += now - stop_watch_last_update;
    stop_watch_last_update = now;
    while (stop_watch_ms >= 1000) {
        stop_watch_ms -= 1000;
        stop_watch_s++;
        if (stop_watch_s >= 60) {
            stop_watch_s = 0;
            stop_watch_min++;
            if (stop_watch_min >= 60) {
                stop_watch_min = 0;
                stop_watch_h++;
            }
        }
    }
}

void stop_watch_stop() {
    stop_watch_update();
    stop_watch_running = false;
}
```

If you know a bit about C++ classes, you may want to turn this into a
class, and replace the `stop_watch_` prefix with `StopWatch::`.


body:
i am brand new to arduino and was looking for a little help. i am looking to activate a motor once the button is pushed for 10 seconds and then have it stop. then the next time the button is pushed, it runs in reverse for ten seconds and stops. i need it to continue this cycle everytime the button is pushed. button push 1 = forward 10 seconds, button push 2 = reverse ten seconds, button push 3 = forward 10 seconds and so on... i believe i am very close to accomplishing this task however like i said i am new to all this and i could be miles away. any help would be appreciated. i am using a mega 2560 even though the picture shows an UNO. i dont think itll matter as long as i use the correct pins.
[link to tinkercad.com][1]

```
int BUTTON = 9;
int DIRA = 3;
int DIRB = 4;
int FOR = true; //forward - reverse
int ENABLE = 5;

void setup() {
  //---set pin direction
  pinMode (ENABLE, OUTPUT);
  pinMode (BUTTON, INPUT_PULLUP);
  pinMode(DIRA,OUTPUT);
  pinMode(DIRB,OUTPUT);
  Serial.begin(9600);
}

void loop() {
 if (digitalRead(BUTTON) == HIGH) {
   digitalWrite(ENABLE, HIGH);
   if (FOR == true) {
    digitalWrite(DIRA,HIGH); //on forward
    digitalWrite(DIRB,LOW);
    delay(10000);
    FOR = false;
    digitalWrite(ENABLE,LOW);  //stop
   } else {
    digitalWrite(DIRB,HIGH); //on reverse
    digitalWrite(DIRA,LOW);
    delay(1000);
    FOR = true;
    digitalWrite(ENABLE,LOW); //stop
  }
 }
}`
```

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

  [1]: https://www.tinkercad.com/things/87HCwRBbweN-stunning-esboo-hillar/editel?sharecode=wSmZURvHPVNHDUkKud8zMDtZFs6znFj78JnjbHiDQpM
  [2]: https://i.stack.imgur.com/wmwmw.png

title: I’m having trouble getting a motor to run for 10 seconds and then reverse direction every time push button is pushed down

Answers: 0


body:
It is s a bit complicated to ask such question, but what may be the reason that **one time  compilation passes and other fails without any changes in code?** surely debugging this way is very hard (one time commenting out one part of code seems to stop this problem and later it returns even if commenting out was canceled).

I suspect it has to do with some changes in code regarding some `ArduinoJson` functionality

Sketch was was tested on 2 different platforms, Linux and Mac, and error occurs on both.

**What troubles me is compilation inconsistentancy rather than some bugs in my code.**

Error message:

    /home/guy/snap/arduino/70/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: sketch/inFlash_Parameters.ino.cpp.o: in function `_Z17updateTopicsFlashRN18ArduinoJson6171_9112JsonDocumentE':
    /home/guy/Documents/Dropbox/Arduino/libraries/myIOT2/examples/inFlash_Parameters/myIOT_settings.h:46: undefined reference to `_ZN6myIOT223extract_JSON_from_flashEPcRN18ArduinoJson6171_9112JsonDocumentE'
    /home/guy/snap/arduino/70/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: /home/guy/Documents/Dropbox/Arduino/libraries/myIOT2/examples/inFlash_Parameters/myIOT_settings.h:44: undefined reference to `_ZN6myIOT228update_vars_flash_parametersERN18ArduinoJson6171_9112JsonDocumentE'
    /home/guy/snap/arduino/70/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: sketch/inFlash_Parameters.ino.cpp.o: in function `_ZN18ArduinoJson6171_9110MemoryPoolC4EPcj':
    /home/guy/Documents/Dropbox/Arduino/libraries/myIOT2/examples/inFlash_Parameters/myIOT_settings.h:52: undefined reference to `_ZN6myIOT223extract_JSON_from_flashEPcRN18ArduinoJson6171_9112JsonDocumentE'
    /home/guy/snap/arduino/70/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: sketch/inFlash_Parameters.ino.cpp.o: in function `_Z22readParameters_inFlashv':
    /home/guy/Documents/Dropbox/Arduino/libraries/myIOT2/examples/inFlash_Parameters/myIOT_settings.h:52: undefined reference to `_ZN6myIOT228update_vars_flash_parametersERN18ArduinoJson6171_9112JsonDocumentE'
    /home/guy/snap/arduino/70/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: /home/guy/Documents/Dropbox/Arduino/libraries/myIOT2/examples/inFlash_Parameters/myIOT_settings.h:57: undefined reference to `_ZN6myIOT223extract_JSON_from_flashEPcRN18ArduinoJson6171_9112JsonDocumentE'
    /home/guy/snap/arduino/70/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/bin/../lib/gcc/xtensa-lx106-elf/10.3.0/../../../../xtensa-lx106-elf/bin/ld: /home/guy/Documents/Dropbox/Arduino/libraries/myIOT2/examples/inFlash_Parameters/myIOT_settings.h:59: undefined reference to `_ZN6myIOT223extract_JSON_from_flashEPcRN18ArduinoJson6171_9112JsonDocumentE'
    collect2: error: ld returned 1 exit status
    Multiple libraries were found for "WiFiUdp.h"
     Used: /home/guy/snap/arduino/70/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/libraries/ESP8266WiFi
     Not used: /home/guy/Documents/Dropbox/Arduino/libraries/arduino_648747
     Not used: /home/guy/Documents/Dropbox/Arduino/libraries/WiFiNINA
     Not used: /snap/arduino/70/libraries/WiFi
    Multiple libraries were found for "ArduinoJson.h"
     Used: /home/guy/Documents/Dropbox/Arduino/libraries/arduino_215091
     Not used: /home/guy/Documents/Dropbox/Arduino/libraries/arduino_892158
    exit status 1
    Error compiling for board NodeMCU 1.0 (ESP-12E Module).

Sharing function that are mentioned in error to make the picture clearer:

    void updateTopicsFlash(JsonDocument &DOC)
    {
        for (uint8_t i = 0; i < 3; i++)
        {
            sprintf(topics_gen_pub[i], DOC["pub_gen_topics"][i]);
        }
        for (uint8_t i = 0; i < 3; i++)
        {
            sprintf(topics_pub[i], DOC["pub_topics"][i]);
        }
        for (uint8_t i = 0; i < 2; i++)
        {
            sprintf(topics_sub[i], DOC["sub_topics"][i]);
        }
    }

    void readParameters_inFlash()
    {
        StaticJsonDocument<1250> DOC;

        iot.extract_JSON_from_flash(parameterFiles[0], DOC);
        iot.update_vars_flash_parameters(DOC);
        DOC.clear();

        iot.extract_JSON_from_flash(parameterFiles[1], DOC);
        updateTopicsFlash(DOC);
        DOC.clear();

        iot.extract_JSON_from_flash(parameterFiles[2], DOC);
        DOC.clear();
    }

calling 2 functions from lib:

    bool myIOT2::extract_JSON_from_flash(char *filename, JsonDocument &DOC)
    {
     File readFile = LITFS.open(filename, "r");
     DeserializationError error = deserializeJson(DOC, readFile);
     readFile.close();

     if (error)
     {
      return 0;
     }
     else
     {
      return 1;
     }
    }
    void myIOT2::update_vars_flash_parameters(JsonDocument &DOC)
    {
     useWDT = DOC["useWDT"];
     useOTA = DOC["useOTA"];
     useSerial = DOC["useSerial"];
     useFlashP = DOC["useFlashP"];
     useDebug = DOC["useDebugLog"];
     debug_level = DOC["debug_level"];
     useResetKeeper = DOC["useResetKeeper"];
     useNetworkReset = DOC["useNetworkReset"];
     noNetwork_reset = DOC["noNetwork_reset"];
     useBootClockLog = DOC["useBootClockLog"];
     ignore_boot_msg = DOC["ignore_boot_msg"];
    }

title: Inconsistant compilation error

Answers: 0


body:
Here is the datasheet I followed: https://lcsc.com/product-detail/Motion-Sensors-Accelerometers_SENSORTEK-STK8321_C966924.html

We are trying the following code:

```c++
#include <Wire.h>

int ADXLAddress = 0x0F; // Device address in which is also included the 8th bit for selecting the mode, read in this case.

#define X_Axis_Register_DATAX0 0x03 // Hexadecima address for the DATAX0 internal register.
#define X_Axis_Register_DATAX1 0x02 // Hexadecima address for the DATAX1 internal register.

#define Y_Axis_Register_DATAX0 0x05 // Hexadecima address for the DATAX0 internal register.
#define Y_Axis_Register_DATAX1 0x04 // Hexadecima address for the DATAX0 internal register.

#define Z_Axis_Register_DATAX0 0x07 // Hexadecima address for the DATAX0 internal register.
#define Z_Axis_Register_DATAX1 0x06 // Hexadecima address for the DATAX0 internal register.

int X0, X1, X_out;
int Y0, Y1, Y_out;
int Z0, Z1, Z_out;

void setup() {
  Wire.begin(); // Initiate the Wire library
  Serial.begin(115200);
  Wire.beginTransmission(ADXLAddress);
  Wire.endTransmission();
}

void loop() {

  ArduinoOTA.handle();

  Wire.beginTransmission(ADXLAddress); // Begin transmission to the Sensor
  //Ask the particular registers for data
  Wire.write(X_Axis_Register_DATAX0);
  Wire.write(X_Axis_Register_DATAX1);
  Wire.endTransmission(); // Ends the transmission and transmits the data from the two registers

  Wire.requestFrom(ADXLAddress, 2); // Request the transmitted two bytes from the two registers
  if (Wire.available() <= 2) { //
    X0 = Wire.read(); // Reads the data from the register
    X1 = Wire.read();
  }

  Serial.print("\n   X0= "); Serial.print(X0); Serial.print("         X1= "); Serial.print(X1);

  delay(100);

  Wire.beginTransmission(ADXLAddress); // Begin transmission to the Sensor
  Wire.write(Y_Axis_Register_DATAX0);
  Wire.write(Y_Axis_Register_DATAX1);
  Wire.endTransmission(); // Ends the transmission and transmits the data from the two registers

  Wire.requestFrom(ADXLAddress, 2); // Request the transmitted two bytes from the two registers
  if (Wire.available() <= 2) { //
    Y0 = Wire.read(); // Reads the data from the register
    Y1 = Wire.read();
  }

  Serial.print("   Y0= "); Serial.print(Y0);  Serial.print("       Y1= "); Serial.print(Y1);

  delay(100);

  Wire.beginTransmission(ADXLAddress); // Begin transmission to the Sensor
  Wire.write(Z_Axis_Register_DATAX0);
  Wire.write(Z_Axis_Register_DATAX1);
  Wire.endTransmission(); // Ends the transmission and transmits the data from the two registers

  Wire.requestFrom(ADXLAddress, 6); // Request the transmitted two bytes from the two registers
  if (Wire.available() <= 6) { //
    Z0 = Wire.read(); // Reads the data from the register
    Z1 = Wire.read();
  }

  Serial.print("    Z0= "); Serial.print(Z0); Serial.print("         Z1= ");  Serial.print(Z1);

  delay(200);
}
```

Please help us to get the final X, Y, and Z.

Raw values of X and Y are somewhat correct, but Z always shows - 0.

Also, we are not able to calculate correctly X, Y, and Z to get the final G-force value.

Main point of datasheet :

> The acceleration data of STK8321 is 12 bits and is given in two's complement format. The MSB in each axis will be stored in register XOUT2/YOUT2/ZOUT2 (0x03, 0x05, 0x07) individually, and the LSB will be stored in register XOUT1/YOUT1/ZOUT1 (0x02, 0x04, 0x06) individually. The NEW_X/NEW_Y/NEW_Z bit in register XOUT1/YOUT1/ZOUT1 (0x02, 0x04, 0x06) is used for new data flag, and it will be set to 1 if the data is updated, and reset if either the corresponding MSB or LSB is read. Reading the acceleration data registers shall always start with the LSB part due to the data protection function. When data protection function is enabled, the content of an MSB register will be updated by reading the corresponding LSB register.

title: STK8231 accelerometer, getting two axis (x & y data) but not z, also in 0-255

Answers: 0


body:
I am working on this code to turn a servo when the PIR motion sensor detects no motion, but it is not working.
Some symptoms include:

 1. Servo is turning extremely slowly
 2. PIR is not turning the servo
 3. Servo is turning to incorrect angles

I have tried test programs, and when I type in the serial monitor, the servo turns (slowly and inaccurately) (I coded the serial monitor to do this). I have input from the PIR sensor but it is constantly high, even after waiting 2 minutes for it to initialize. My code and schematic are shown below.

[![Schematic][1]][1]

My code:

    #include <Servo.h>
    Servo servo;

    void setup() {
      // put your setup code here, to run once:
      servo.attach(13);
      pinMode(2, INPUT);
      Serial.begin(9600);
      Serial.println("Please wait");
      delay(60000);
    }

    void ifMos() {
      if (digitalRead(2) == HIGH) {
        int USER = 270;
      }
    }

    void loop() {
      // put your main code here, to run repeatedly:
      int USER = Serial.parseInt();
      servo.write(USER);
      Serial.println(USER);
      ifMos();
      delay(10000);
    }

  [1]: https://i.stack.imgur.com/55lFe.jpg

title: Servo not moving with PIR motion sensor

Answers: 1

body:
> firget about the servo for now ... write the simplest code that lights an LED when motion is detected –
-jsotola

It worked! Thank you so much.
All I had to do was add the servo library, write to the servo and upload it. Only 21 lines of code! Final code:

    #include <Servo.h>
    Servo servo;

    void setup() {
      // put your setup code here, to run once:
      pinMode(2, INPUT);
      pinMode(3, OUTPUT);
      servo.attach(13);
    }

    void loop() {
      // put your main code here, to run repeatedly:
      if(digitalRead(2) == HIGH) {
        digitalWrite(3, HIGH);
        servo.write(270);
      }
      else {
        digitalWrite(3, LOW);
        servo.write(0);
      }
    }

Thank you to everyone. This was my first time posting on stack exchange, and it was a huge success. Thank you again!


body:
I am using `ESPAsyncWebServer` `ArduinoJson (6.19.4)`

     server.on("/", HTTP_GET, [](AsyncWebServerRequest * request)
        {
          AsyncJsonResponse  *response = request->beginResponseStream("application/json");
          DynamicJsonDocument doc(1024);
          doc["deviceType"] = deviceType;
          for (uint8_t i = 0; i < NUM_RELAYS; i++)
          {
            doc[String(i)] = !configJSON["devices"][i]["ledState"];
          }
          serializeJson(doc, *response);
          request->send(response);
        });

the above code works fine but seems the response doesnt ends, any subsequent calls also doesnt work on the same URL.

Any help please.

title: Return json from AsyncWebserver

Answers: 0


body:
I'm trying to pass a list of files (located in sketch) to be read using a library I write. List can have different filenames and vary in number of files.

How to pass a this array to my library?

for example:

`char *parameterFiles[3] = {"/myIOT_param.json", "/myIOT2_topics.json", "/sketch_param.json"};`

**EDIT_1**

To explain more clearly what are my needs:
Let's say that my library has a class name `myIOT2`. That class holds an array that contains a list of all filenames (what shown here is not all class). Those names are different from one use of the library to the other, and it might not have all 4 files ( can be also 0 files stored ).

I wish to have the flexibilty not to hard code exact filename in advance, but to pass that array as part of my sketch, as show prior to EDIT_1.

    class myIOT2
    {
    public:
    const char *parameter_filenames[4] = {nullptr, nullptr, nullptr, nullptr};

    };

title: pointing to array of chars

Answers: 1

body:
You have to pass both a pointer to the list, and the length of the list
as an extra argument. The signature of the function may be something
like:

```c++
void processFiles(const char *fileList[], int fileCount);
```

Note that `const char *fileList[]` is just a fancy way of writing
`const char **fileList`. I find the former more readable, but that is
completely subjective.

Here is a small test code showing this in action:

```c++
void processFiles(const char *fileList[], int fileCount)
{
    for (int i = 0; i < fileCount; ++i) {
        Serial.print("Processing file ");
        Serial.println(fileList[i]);
    }
}

const char *parameterFiles[3] = {
    "/myIOT_param.json",
    "/myIOT2_topics.json",
    "/sketch_param.json"
};

void setup() {
    Serial.begin(9600);
    processFiles(parameterFiles, 3);
}

void loop() {}
```

Alternatively, you may put a “sentinel” at the end of the list: a null
pointer that signifies that the list ends there:

```c++
void processFiles(const char *fileList[])
{
    for (const char **p = fileList; *p; ++p) {
        Serial.print("Processing file ");
        Serial.println(*p);
    }
}

const char *parameterFiles[] = {
    "/myIOT_param.json",
    "/myIOT2_topics.json",
    "/sketch_param.json",
    nullptr
};

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

void loop() {}
```

------------------------------------------------------------------------

**Edit**: Answering to EDIT\_1.

> [My library's] class holds an array that contains a list of all
> filenames

First of all, you have to decide who is responsible for storing those
file names: the library or its client. When you write:

```c++
const char *parameterFiles[3] = {
    "/myIOT_param.json", "/myIOT2_topics.json", "/sketch_param.json"
};
```

you are creating 4 arrays: an array of 3 pointers named
`parameterFiles`, and three arrays of characters holding the file names.
Note that those 3 arrays are _anonymous_: they are not array
variables. If the client code tries to pass this `parameterFiles` to
your library, the array identifier will decay to a pointer, and your
library will receive that pointer. What should it do with it?

1. The library could just keep a copy of the pointer. The client is then
   responsible for ensuring that it remains valid for as long as the
   library may need it. This practically implies that `parameterFiles`
   should be a global variable, and should not be modified once given to
   the library.

2. The library could make a copy of the array. Then the client is freed
   from this responsibility. However, it is still responsible for
   ensuring that the pointers that were copied from the array remain
   valid, i.e. that the file names stay in the same place in memory.

3. The library could copy the file names themselves. Then the client
   doesn't have any responsibility about keeping pointers valid.

If you choose option 2 or 3, the library will have to hold one or more
arrays. You will then have to choose whether you allocate them
statically, or dynamically with `new`. Dynamic allocation is more
efficient when the arrays can vary greatly in length, but it can raise
issues of memory fragmentation in RAM-constrained devices.

I cannot tell you which option is best: it depends on your use case. In
any case, whatever you choose, you should document it: the user of the
library should know whether they are responsible for keeping any
pointers valid.

In the following, I will assume option 2 with static allocation. This is
consistent with the code snippets in your question. Also, if the client
provides the file names as string literals, then pointers to these
strings remain always valid.

Here is a toy implementation of the `myIOT2` class, where the list of
file names is copied by the constructor into the class:

```c++
class myIOT2 : public Printable
{
public:
    static const int maxFileCount = 4;

    myIOT2(const char *fileList[], int count) {
        if (count > maxFileCount)
            count = maxFileCount;  // discard extra files
        fileCount = count;
        for (int i = 0; i < fileCount; i++)
            filenames[i] = fileList[i];
    }

    size_t printTo(Print& p) const {
        size_t count = p.print(F("myIOT2["));
        for (int i = 0; i < fileCount; i++) {
            count += p.print('"');
            count += p.print(filenames[i]);
            count += p.print('"');
            if (i < fileCount - 1)
                count += p.print(", ");
        }
        count += p.print(']');
        return count;
    }

private:
    const char *filenames[maxFileCount];
    int fileCount;
};
```

Note that, the array of file names being statically allocated, there is
a hard maximum on the number of files that can be stored. I made the
class `Printable` only for debugging convenience.

And here is an example of this class in use:

```c++
const int fileCount = 3;

const char *parameterFiles[fileCount] = {
    "/myIOT_param.json", "/myIOT2_topics.json", "/sketch_param.json"
};

myIOT2 iot(parameterFiles, fileCount);

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

void loop() {}
```

This test sketch prints:

```text
myIOT2["/myIOT_param.json", "/myIOT2_topics.json", "/sketch_param.json"]
```


body:
I have tired Arduino smoothing example but mine analog value are not staying constant even when I don't rotate the potentiometer. I am mapping the values from 0 -> 1024 to 0-> 100. I have tried exponential filter also but the result is same.

Values change 2 to 3 point mostly. Any idea how can I make the readings much more smooth.

title: Arduino Uno Analog pot values are not smooth

Answers: 1

body:
There will always be noise in the output an [Analog to Digital Converter (ADC)][1].

> An ADC converts a continuous-time and continuous-amplitude analog
> signal to a discrete-time and discrete-amplitude digital signal. The
> conversion involves quantization of the input, so it necessarily
> introduces a small amount of error or noise.

All one can do is mitigate the noise.  Consider cleaning up your power supply.  Make sure your voltage reference is well filtered.  Inspect these power rails with an oscilloscope if one is available.  Also consider keeping all wiring as short as possible and avoid using [Bread Boards][2] as they tend to introduce noise in sensitive circuits.

When using [exponential averaging][3] consider the equation / code can be modified easily to accommodate very noisy signals at the sacrifice of responsiveness.  If the application can tolerate the delay, the decay of historical samples can be lowered such that what most consider noise can be filtered out.  One can do this by picking very small values for alpha in the following equation found on wikipedia.org:

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

  [1]: https://en.wikipedia.org/wiki/Analog-to-digital_converter
  [2]: https://www.adafruit.com/product/239
  [3]: https://en.wikipedia.org/wiki/Exponential_smoothing
  [4]: https://i.stack.imgur.com/qLMuv.jpg


body:
**What does the `.ino` file extension mean?**

We have `.cpp` meaning C++, `.py` meaning Python, `.exe` meaning executable and so-on.They're obvious. The `.pde` file type that sketches previously used, I think, comes from _processing development environment_ (the arduino IDE being based<sup>*<sup> on / inspired by [processing](https://processing.org)).  But what does `.ino` mean?

There's plenty that explains what such files are, but nothing explains what those three letters mean, if anything.

<sub>\* source [wikipedia](https://en.wikipedia.org/wiki/Arduino)</sub>

title: What does the .ino file extension mean

Answers: 2

body:
> Ardu***ino***

That's all there is to say about that really.

---

As [commented in the source code](https://github.com/arduino/Arduino/blob/1.0/build/shared/revisions.txt#L5-L7)

> The file extension for sketches has changed from .pde to .ino, to avoid
  conflicts with the Processing software ("ino" are the last three letters
  in "Arduino").

body:
"Arduino" is an Italian word, and "ino" is the suffix which lends itself well to a filename extension.

From [Google Translate of Italian ino][1]:

> ino
>
> 1. Suffisso alterativo di aggettivi e sostantivi; nei primi ha valore diminutivo-vezzeggiativo, talvolta con sfumatura ironica ( biondino, carino ), oppure significa appartenenza etnica ( alessandrino, cadorino ), collegamento con materie ( argentino, salino ); nei secondi, oltre ad avere valore diminutivo-vezzeggiativo ( gattino, pensierino ), indica pure un mestiere ( ciabattino, tamburino ), uno strumento o arnese o apparecchio ( cerino, lavandino ); in alcuni casi è applicato a verbi ( imbianchino, accendino ).
> 2. In chimica organica, suffisso che nella nomenclatura ufficiale indica gli idrocarburi acetilenici, cioè gli alchini ( etino ).

> 1. Alterative suffix of adjectives and nouns; in the former it has a diminutive-pet name, sometimes with an ironic tinge (blond, cute), or it means ethnic affiliation (Alexandrian, Cadore), connection with materials (Argentine, saline); in the latter, in addition to having a diminutive-pet name (kitten, little thought), it also indicates a trade (cobbler, drummer), an instrument or tool or apparatus (match, sink); in some cases it is applied to verbs (painter, lighter).
> 2. In organic chemistry, suffix that in the official nomenclature indicates acetylenic hydrocarbons, i.e. alkynes (ethin).

  [1]: https://translate.google.com/?sl=it&tl=en&text=ino

1
Suffisso alterativo di aggettivi e sostantivi; nei primi ha valore diminutivo-vezzeggiativo, talvolta con sfumatura ironica ( biondino, carino ), oppure significa appartenenza etnica ( alessandrino, cadorino ), collegamento con materie ( argentino, salino ); nei secondi, oltre ad avere valore diminutivo-vezzeggiativo ( gattino, pensierino ), indica pure un mestiere ( ciabattino, tamburino ), uno strumento o arnese o apparecchio ( cerino, lavandino ); in alcuni casi è applicato a verbi ( imbianchino, accendino ).
2
In chimica organica, suffisso che nella nomenclatura ufficiale indica gli idrocarburi acetilenici, cioè gli alchini ( etino ).&op=translate


body:
I have multiple SNMP devices on the same network and I am trying to request, *via OID numbers*, each SNMP device and assign the **response** into an array.
When I request a single IP, I get the correct response as expected.

**Problem:**
If I run the same code in a for loop (*multiple ip's 192.168.1.150, 192.168.1.151, etc*), I get duplicate info.
*I might be using the wrong callback method, or the SNMP Manager can not dynamically change the ip address..*
I have researched a lot of topics and tried many avenues, but I can't get past this point.

**If anyone can assist me, it would help a lot!!**

__________

**Example Output:**
*The model name and serial should be different on each ip*
```
----------------------
192.168.8.150
KONICA MINOLTA bizhub C658
A79J021002278
----------------------
192.168.8.151
KONICA MINOLTA bizhub C658
A79J021002278
----------------------
192.168.8.152
KONICA MINOLTA bizhub C658
A79J021002278
----------------------
192.168.8.153
KONICA MINOLTA bizhub C658
A79J021002278
----------------------
192.168.8.154
KONICA MINOLTA bizhub C658
A79J021002278
```

**Here is the code**
```
#if defined(ESP8266)
#include <ESP8266WiFi.h> // ESP8266 Core WiFi Library
#else
#include <WiFi.h>        // ESP32 Core WiFi Library
#endif

#include <string.h>
#include <WiFiUdp.h>
#include <Arduino_SNMP_Manager.h>

//************************************
//* Your WiFi info                   *
//************************************
const char *ssid = "Workmin_Sales";
const char *password = "workmin92429242";
//************************************

//************************************
//* SNMP Device Info                 *
//************************************
const char *community = "public";
const int snmpVersion = 1; // SNMP Version 1 = 0, SNMP Version 2 = 1
// OIDs
const char *oidModelName = ".1.3.6.1.2.1.25.3.2.1.3.1";               // OctetString SysName
const char *oidSerialNumber = ".1.3.6.1.2.1.43.5.1.1.17.1";              // OctetString SysName
//************************************

//************************************
//* Settings                         *
//************************************
int pollInterval = 20000; // delay in milliseconds
//************************************

//************************************
//* Initialise                       *
//************************************
// Variables
char *modelNameArray[5];
char *serialNumberArray[5];

char modelName[50];
char *modelNameResponse = modelName;
char serialNumber[50];
char *serialNumberResponse = serialNumber;

// Blank callback pointer for each OID
ValueCallback *callbackSerialNumber;
ValueCallback *callbackModelName;
//************************************

unsigned long pollStart = 0;
// SNMP Objects
WiFiUDP udp;                                           // UDP object used to send and receive packets
SNMPManager snmp = SNMPManager(community);             // Starts an SMMPManager to listen to replies to get-requests
SNMPGet snmpRequest = SNMPGet(community, snmpVersion); // Starts an SMMPGet instance to send requests

//************************************
//* Function declarations            *
//************************************
void getSNMP();
//************************************

void setup()
{
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  Serial.println("");
  // Wait for connection
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to SSID: ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  snmp.setUDP(&udp); // give snmp a pointer to the UDP object
  snmp.begin();      // start the SNMP Manager
}

void loop()
{
  // put your main code here, to run repeatedly:
  snmp.loop();
  if (millis() - pollStart >= pollInterval)
  {
    pollStart += pollInterval; // this prevents drift in the delays

    getSNMP();
    // doSNMPCalculations(); // Do something with the data collected
  }
}

void getSNMP()
{
  for (int i = 0; i < 5; i++) {
    // Build a SNMP get-request add each OID to the request
    IPAddress router(192, 168, 8, i + 150);

    // Get callbacks from creating a handler for each of the OID
    callbackSerialNumber = snmp.addStringHandler(router, oidSerialNumber, &serialNumberResponse);
    callbackModelName = snmp.addStringHandler(router, oidModelName, &modelNameResponse);

    snmpRequest.addOIDPointer(callbackSerialNumber);
    snmpRequest.addOIDPointer(callbackModelName);

    snmpRequest.setIP(WiFi.localIP()); // IP of the listening MCU
    // snmpRequest.setPort(501);  // Default is UDP port 161 for SNMP. But can be overriden if necessary.
    snmpRequest.setUDP(&udp);
    snmpRequest.setRequestID(rand() % 5555);
    snmpRequest.sendTo(router);
    snmpRequest.clearOIDList();
    delay(1000);

    modelNameArray[i] = modelNameResponse;
    serialNumberArray[i] = serialNumberResponse;
    Serial.print("192.168.8.");
    Serial.println(i + 150);
    Serial.println(modelNameArray[i]);
    Serial.println(serialNumberArray[i]);
    Serial.println("----------------------");
  }
}
```

title: SNMP Manager - Multiple IP address -issue

Answers: 2

body:
You're not storing the data in your array, you're storing a pointer to the storage where the callback stores its data. So every entry gets the same pointer to the same storage, which gets its content changed. So all the array entries see the same (last) content.

It took me many years to properly get my head around C pointers.

Instead of just assigning (`=`) the value you need to *copy the content*.

Since you just have an array of pointers that can be done with `strdup()` which allocates a new block of RAM and copies the contents to it. Be sure to use `free()` on that allocated block when you've finished with it.

* [strdup](https://man7.org/linux/man-pages/man3/strdup.3.html)

body:
I think I see multiple issues with the example above.
1. The `snmpRequest.sendTo(router);` will send the SNMP packet out. But you need to call `snmp.loop()` to read the incoming replies to your request. So you need to restructure the code so that you can call loop() potentially many times in order to wait for the incoming replies before you read and store the values.
2. `serialNumberResponse` is a pointer to a character array `serialNumber` (likewise for the model). If the callback returned serial number `123ABC` the first time, and the next device was called `1XD` then the array would have a value of `1XDABC`. So if you plan to re-use the variable, you'll need to clear it between uses something like: `memset(serialNumber, 0, sizeof(serialNumber));`
3. As you might not always get a successful response, or a response within the time allowed, the value may be still blank, if you're looking to store the values in another variable, you may want to ensure they aren't empty, as this would overwrite the value you may have had back on a previously successful call. If you were dealing with numbers, the value might also be that of a previous call. As pointed out in the answer above, you're dealing with pointers, so if you want to store the value you need to copy the value out, otherwise, you'll just point to the same pointer.

I hope this helps point you in the right direction. I've added an example to the library to show how multiple devices can be queried and the results stored in an array, see: https://github.com/shortbloke/Arduino_SNMP_Manager/tree/master/examples/ESP_Multiple_SNMP_Device_Polling. It stores the responses directly into the array. This might cause values to be cleared in the event of a timeout, I've not tested it completely.

Martin


body:
I have data on firebase rtdb, which i want to listen in my nodemcu. I know there are libraries available like [this one][1] which provides listeners, but i want to do it using REST API streaming as mentioned in [firebase documentation for rest api streaming][2].
So far i have successfully tested with curl on cmd as shown[![][3]][3]

My curl command is:

````
curl -v https://<name of rtdb>.firebaseio.com/SD0001/Up.json -H "Accept:text/event-stream"
````

I want to do the same thing on ESP8266 using [ESP8266HTTPClient][4] library. The firebase documentation states "Set the client's Accept header to text/event-stream" (which i added in header), "Respect HTTP Redirects, in particular HTTP status code 307" (which i am still struggling).

So far, my code is somewhat like this

```#include<Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClientSecureBearSSL.h>

const uint8_t fingerprint[20] = {<<<<fingerprint of rtdb database>>>>};
HTTPClient https;
std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure);
void setup()
{
  Serial.begin(115200);
  WiFi.begin("SSID", "PASSWORD");
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP()); // successful Connection of ESP8266,

  client->setFingerprint(fingerprint);

  if (https.begin(*client, "https://<name of rtdb>.firebaseio.com/SD0001/Up.json"))
  {
    https.addHeader("Accept", "text/event-stream", false, true);
    https.setFollowRedirects(HTTPC_FORCE_FOLLOW_REDIRECTS);
    int httpCode = https.GET();
    Serial.println(httpCode);

    Serial.println(https.getString());
    //    Serial.println(https.getLocation());
    //    Serial.println(https.header("Location"));
    //https.end();
  }

}

void loop()
{
  //  Serial.println(https.getStream());
  //  Serial.println(https.getString());
  //  Serial.println(https.getLocation());
  //  delay(1000);
}
```

My code GETs the respone with 200 code, but there is no "Location" to redirect in the response header (at least i can't find any). Should i do http GET in the loop everytime? If so, where will i get my redirection url?
It would be really helpful if any solution is provided or any documentation to guide me in the right way.

Edit: I have put the text versions of curl command and the code in the post alongwith the screenshots. This is my first post here, so please bear with me.

  [1]: https://github.com/mobizt/Firebase-ESP8266
  [2]: https://firebase.google.com/docs/database/rest/retrieve-data#section-rest-streaming
  [3]: https://i.stack.imgur.com/3Gbvb.png
  [4]: https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266HTTPClient
  [5]: https://i.stack.imgur.com/sRY0j.png

title: Stream data using Firebase Realtime Database rest api with nodeMCU client

Answers: 0


body:
Helllo,\
I am using the HX711 module and load cell with an arduino uno for force measurements.
I am using [this library](https://github.com/olkal/HX711_ADC).

I first use the example ["Calibration"](https://github.com/olkal/HX711_ADC/blob/master/examples/Calibration/Calibration.ino) code for calibration with a 200 g weight.
Then I save the calibration constant to the eeprom (choosing yes on the serial monitor).
Then the load cell is able to measure weights accurately.

After that I remove the weight from the load cell and run [this code](https://github.com/olkal/HX711_ADC/blob/master/examples/Read_1x_load_cell/Read_1x_load_cell.ino) after uncommenting the last line of this part of the above code:
```
LoadCell.begin();
  //LoadCell.setReverseOutput();
  float calibrationValue;
  calibrationValue = 696.0;
#if defined(ESP8266)|| defined(ESP32)
  //EEPROM.begin(512);
#endif
  EEPROM.get(calVal_eepromAdress, calibrationValue); // I have uncommented this
```

The weights are measured accurately.

**But when before powering the arduino, if I keep a weight on the load cell that weight is taken to be 0.**

For this I have done the following change to the code:
```
boolean _tare = false;
```

But I get the following output on the serial monitor (Note: The following output is obtained on startup when there is/there is no weight on the load cell):

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

**Questions:**
What is the use of the following line:
```
calibrationValue = 696.0; // uncomment this if you want to set the calibration value in the sketch
```
Is it useless for the code I am using above? Because I am using the calibration value from the eeprom.

Q2) Why is it showing -39000 as an output value?
And how to correct it?

**Alternate Statement:**
In other words, I want to use the HX711 module with the arduino and a load cell. I will first calibrate it with a known weight and save the calibration value.
Before powering up the arduino I will keep a weight on the load cell. After powering up the weight value should be the absolute value instead of making the Weight Null.

**EDIT1:**
I incorporate the changes suggested in the answers by @Edgar Bonet and also make the problem more clear just in case.
According to suggestions I have made the corresponding changes to the calibration code. Then I run that and the values are saved to eeprom. Code changes:
```
const int calVal_eepromAdress = 0;
const int tare_eepromAdress = sizeof(float);
```
and
```
#endif
        EEPROM.put(calVal_eepromAdress, newCalibrationValue);
        EEPROM.put(tare_eepromAdress, LoadCell.getTareOffset());
#if defined(ESP8266)|| defined(ESP32)
        EEPROM.commit();
```

Now, I wish to run the [second script](https://github.com/olkal/HX711_ADC/blob/master/examples/Read_1x_load_cell/Read_1x_load_cell.ino) and for this to display the correct weights.
This should work in all cases regardless of whether a weight has not been kept on the load cell or has been kept and should be independent of the weight that has been kept.
To this script I have made the following changes:
```
const int calVal_eepromAdress = 0;
const int tare_eepromAdress = sizeof(float);
```
and
```
// Inside void setup()
void setup() {
  Serial.begin(57600); delay(10);
  Serial.println();
  Serial.println("Starting...");

  LoadCell.begin();
  //LoadCell.setReverseOutput(); //uncomment to turn a negative output value to positive
  float calibrationValue; // calibration value (see example file "Calibration.ino")
  float tareValue;
  calibrationValue = 696.0; // uncomment this if you want to set the calibration value in the sketch
  tareValue = 0;
#if defined(ESP8266)|| defined(ESP32)
  //EEPROM.begin(512); // uncomment this if you use ESP8266/ESP32 and want to fetch the calibration value from eeprom
#endif
  EEPROM.get(calVal_eepromAdress, calibrationValue); // uncomment this if you want to fetch the calibration value from eeprom
  EEPROM.get(tare_eepromAdress, tareValue);

  unsigned long stabilizingtime = 2000; // preciscion right after power-up can be improved by adding a few seconds of stabilizing time
  boolean _tare = true; //set this to false if you don't want tare to be performed in the next step
  LoadCell.start(stabilizingtime, _tare);
  if (LoadCell.getTareTimeoutFlag()) {
    Serial.println("Timeout, check MCU>HX711 wiring and pin designations");
    while (1);
  }
  else {
    LoadCell.setCalFactor(calibrationValue); // set calibration value (float)
    LoadCell.setTareOffset(tareValue);
    Serial.println("Startup is complete");
  }
}
```

**EDIT2:**
```
#if defined(ESP8266)|| defined(ESP32)
        EEPROM.begin(512);
#endif
        EEPROM.put(calVal_eepromAdress, newCalibrationValue);
        EEPROM.put(tare_eepromAdress, LoadCell.getTareOffset());

        Serial.println(newCalibrationValue);
        Serial.println(LoadCell.getTareOffset());
```
Output:
```
-206.90
8368790
```

In the second script:
```
#if defined(ESP8266)|| defined(ESP32)
  //EEPROM.begin(512); // uncomment this if you use ESP8266/ESP32 and want to fetch the calibration value from eeprom
#endif
  EEPROM.get(calVal_eepromAdress, calibrationValue); // uncomment this if you want to fetch the calibration value from eeprom
  EEPROM.get(tare_eepromAdress, tareValue);
  Serial.println(calibrationValue);
  Serial.println(tareValue);
```

Output:
```
-206.90
0.00
```

I am uploading my codes onto Github just in case. They can be found [here](https://github.com/atharvaaalok/LoadCell_Corrected).

Q) What is happening here?

**EDIT3:**
The following changes make it work like a charm:
In the "Calibration" script:
```
long tareValue = LoadCell.getTareOffset(); // Instead of float tareValue
```
Similarly in the second script:
```
long tareValue; // Instead of float tareValue
```

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

title: Prevent Resetting of Null Weight when using HX711 with a load cell

Answers: 1

body:
In order to convert the raw ADC readings to a weight, the library needs
two coefficients:

* a “tare offset”, which is the raw reading when there is no weight on
  the scale
* a gain, or “calibration factor”, which is the ratio of a change in the
  ADC reading to the corresponding change in weight.

The examples provided with the library use the EPPROM to store and
retrieve the calibration factor, but not the tare offset. This makes
sense as, in common usage, a weight scale is always zeroed at power up,
or right after power up. This is usually desirable as one would often
place an empty container on the scale which should not affect the
displayed weight.

If you do not want to zero the scale at power-up, then you need your
sketch to remember the tare offset in addition to the calibration
factor. For this, you can use the methods of `LoadCell`:

```c++
// Get the tare offset (raw data value output without
// the scale "calFactor").
long getTareOffset();

// Set new tare offset (raw data value input without
// the scale "calFactor").
void setTareOffset(long newoffset);
```

Now, to the more specific questions:

> What is the use of the following line:
>
> ```c++
> calibrationValue = 696.0;
> ```

None. It is just an example. You are supposed to either replace this
number with your measured calibration factor, or remove this line and
read `calibrationValue` from the EEPROM.

> Why is it showing -39000 as an output value?

Because the tare offset has not been set, so it presumably defaults to
zero.

------------------------------------------------------------------------

**Edit**: Answering extra questions in comment.

> Do I need to store this value to the eeprom when running the
> calibration script?

You can store it whenever it is convenient to you. The calibration
script seems a good place.

> I am not able to get this into code. I read the source files but I am
> unsure about what changes to make.

What you may try (untested):

1. right after the line

   ```c++
   const int calVal_eepromAdress = 0;
   ```

   add this:

   ```c++
   const int tare_eepromAdress = sizeof(float);
   ```

2. Right after this:

   ```c++
   EEPROM.put(calVal_eepromAdress, newCalibrationValue);
   ```

   add this:

   ```c++
   EEPROM.put(tare_eepromAdress, LoadCell.getTareOffset());
   ```


body:
I want to connect an Arduino Uno to an Arduino Nano, so that it can send signals. The problem is that the Arduino Uno has a motor shield connected to it, and it takes up all pins of the Arduino.

This is a picture of the whole motor shield contraption if it helps:

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

Does anybody know any solution for this?

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

title: Is there a way to connect two Arduinos, when one of them has all of its pins occupied?

Answers: 1

body:
Pins 0 and 1 are serial pins which are also connected to usb, and you use them when you are programming your board or when you send anything to serial. It is unlikely that any shield uses it unless it has to and it although has a benefit of being able to listen to what the Arduino sends.
I think hitching a ride on pins 1 and 0 (rx/tx) would be the easiest. SO you can print or write to them the same way as you respond to yourself.

Just a warning that when you are sending data between two boards and Print numbers they come as symbols of the numbers, not the numbers themselves So ``` Serial.print(7) ``` would arrive to the next arduino as number 55 or symbol '7'. If you are sending numbers between two arduinos you can use write ```Serial.write(7);``` which does not change data, but your serial monitor on a computer wont read it right, or you can send them as symbols, but then the arduino listening may have to convert number symbol to the number. (sooner or later you will have to create yourself a simple function to convert symbols to numbers in your project...