text:
Arduino uno wifi rev2 stuck inside loop
It might be a stupid question but I can't figure it out. While running the code below. I want to open the box when the code matches the code in API. This all works. I can even close the box afterwords. But then I am stuck inside my loop. after the box is closed I want the screen to say box closed and then I want the void loop() to start again. so my screen asks for a code again. I tried using break and exit but no luck so far.
entire code:
/* hardware libraries*/
#include <Key.h>
#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>

/*Wifi and request libraries*/
#include <SPI.h>
#include <WiFiNINA.h>
#include <ArduinoJson.h>

#define HIGH 0x1
#define LOW 0x0

/* wifi credentials*/
char ssid[] = "ssid";        // your network SSID (name)
char pass[] = "password";    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;

int status = WL_IDLE_STATUS;
char server[] = "parcelbox.1819.caro.deweze.nxtmediatech.eu";
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
WiFiClient client;

LiquidCrystal_I2C lcd(0x27, 16, 2); // lcd object
Servo myservo; //servo object
boolean boxOpenend = false ;

/* Keypad*/
const byte ROWS = 4;
const byte COLS = 3;

char keys[ROWS][COLS] = {
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};

byte rowPins[ROWS] = {3, 4, 5, 6};
byte colPins[COLS] = {9, 8, 7};

Keypad customKeypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
String value = "";

void setup() {
  lcd.begin(); //start lcd
  Serial.begin(9600);
  myservo.attach(A0); // attach servo to pin
  lcd.backlight(); // start screen light

  /* connect to wifi */
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }

  String fv = WiFi.firmwareVersion();
  if (fv < "1.0.0") {
    Serial.println("Please upgrade the firmware");
  }

  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }
  Serial.println("Connected to wifi");
  printWifiStatus();
}

void loop() {
  lcd.clear();
  lcd.print("Geef bestelcode");
  char customKey = customKeypad.getKey();   // get the key pressed
  value = value + String(customKey);
  lcd.setCursor(0, 1);
  lcd.print(value);
  if (customKey == '#') {

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

    // if you get a connection, report back via serial:
    if (client.connect(server, 80)) {

      value.remove(16);
      Serial.println(value);
      Serial.println("connected to server");

      // Make a HTTP request:
      client.println("GET /api/boxes/1444/code/" + value + " HTTP/1.1");
      client.println("Host: parcelbox.1819.caro.deweze.nxtmediatech.eu");
      client.println("Connection: close");
      client.println();
    }
    // if there are incoming bytes available
    // from the server, read them and print them:
    StaticJsonBuffer<500> jsonBuffer;

    while (client.connected()) {

      String response = "";
      bool begin = false;

      while (client.available() || !begin) {
        char c = client.read();

        if (c == '{') {
          begin = true;
        }
        if (begin) response += (c);
        if (c == '"}') {
          break;
        }
        delay(1);
      }
      int start = response.indexOf("status\":\"") + 11;
      int end = start + 3;
      response_Status = response.substring(start, end);

      JsonObject& root = jsonBuffer.parseObject(response);

      if (!root.success())
      {
        Serial.print("parseObject(");
        Serial.print(response);
        Serial.println(") failed");
        break;
      }

      Serial.println(response_Status);
      if (response_Status == "200") {

        Serial.println("200");
        boxOpenend = true;

        while (boxOpenend) {

          lcd.clear();
          lcd.print("Box openend ,press");
          lcd.setCursor(0, 1);
          lcd.print(" * to close");

          myservo.write(0);// rotate the servo to open
          delay(175);

          char key = customKeypad.getKey();   // get the key pressed
          //value = value + String(key);

          if (key == '*') {
            myservo.write(90); // rotate the servo to lock
            value = "";                           // clear the string
            boxOpenend = false;

          }
          // box gaat terug toe maar ik blijf in deze loop zitten want lcd scherm blijft staan op "Box geopend , druk * om te sluiten
        }

      }
      else if (response_Status != "200") {

        Serial.println("not 200");

        lcd.clear();
        lcd.print("wrong code or");
        lcd.setCursor(0, 1);
        lcd.print("already deliverd");

        delay(175);
        value = "";
        exit;
      }
      //hier net hetzelfde
      break ;
    }
    // if the server's disconnected, stop the client:
    if (!client.connected()) {
      Serial.println();
      Serial.println("disconnecting from server.");
      client.stop();

      // do nothing forevermore:
      while (true);
    }
    exit;
  }

  if (customKey == '*') {
    myservo.write(90);                   // rotate the servo to lock
    value = "";                           // clear the string
  }

  delay(175); // for optimal lcd screen view
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your board's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

This is where the code get's stuck.
It keeps on showing box opened press  * to close.
even when I press * and the box closes it keeps on saying this
while (boxOpenend) {

          lcd.clear();
          lcd.print("Box openend ,press");
          lcd.setCursor(0, 1);
          lcd.print(" * to close");

          myservo.write(0);// rotate the servo to open
          delay(175);

          char key = customKeypad.getKey();   // get the key pressed
          //value = value + String(key);

          if (key == '*') {
            myservo.write(90); // rotate the servo to lock
            value = "";                           // clear the string
            boxOpenend = false;

          }
          // box gaat terug toe maar ik blijf in deze loop zitten want lcd scherm blijft staan op "Box geopend , druk * om te sluiten
        }

      }

It might have a simple solution that I'm just not thinking of but it really bothers me!
UPDATE , We made a little progress as to figuring out why it wont work. the code that we are running now is:
/* hardware libraries*/
#include <Key.h>
#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>

/*Wifi and request libraries*/
#include <SPI.h>
#include <WiFiNINA.h>
#include <ArduinoJson.h>

#define HIGH 0x1
#define LOW 0x0

/* wifi credentials*/
char ssid[] = "XXXXXXX";        // your network SSID (name)
char pass[] = "XXXXXXX";    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;

int status = WL_IDLE_STATUS;
char server[] = "parcelbox.1819.caro.deweze.nxtmediatech.eu";
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
WiFiClient client;

LiquidCrystal_I2C lcd(0x27, 16, 2); // lcd object
Servo myservo; //servo object
boolean boxOpenend = false ;

/* Keypad*/
const byte ROWS = 4;
const byte COLS = 3;

char keys[ROWS][COLS] = {
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};

byte rowPins[ROWS] = {3, 4, 5, 6};
byte colPins[COLS] = {9, 8, 7};

Keypad customKeypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
String value = "";

void setup() {
  lcd.begin(); //start lcd
  Serial.begin(9600);
  myservo.attach(A0); // attach servo to pin
  lcd.backlight(); // start screen light

  /* connect to wifi */
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }

  String fv = WiFi.firmwareVersion();
  if (fv < "1.0.0") {
    Serial.println("Please upgrade the firmware");
  }

  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }
  Serial.println("Connected to wifi");
  printWifiStatus();
}

void loop() {
  lcd.clear();
  lcd.print("Geef bestelcode");

  char customKey = customKeypad.getKey();   // get the key pressed
  value = value + String(customKey);

  lcd.setCursor(0, 1);
  lcd.print(value);

  if (customKey == '#')
  {
  Serial.println("PRESSED #");
    String response_Status = "";
    Serial.println("\nStarting connection to server...");

  Serial.println("RESULT OF CLIENT.CONNECT()");
  Serial.println(client.connect(server, 80));

    // if you get a connection, report back via serial:
    if (client.connect(server, 80) == 1)
  {
    Serial.println("IK BEN HIER");
    value.remove(4);
    Serial.println(value);
    Serial.println("connected to server");

    // Make a HTTP request:
    client.println("GET /api/boxes/1444/pin/" + value + " HTTP/1.1");
    client.println("Host: parcelbox.1819.caro.deweze.nxtmediatech.eu");
    client.println("Connection: close");
    client.println();
  }
  else
  {
    Serial.println("client.connect() not successfull");
  }

    // if there are incoming bytes available
    // from the server, read them and print them:
    StaticJsonBuffer<500> jsonBuffer;

    if (client.connected())
  {
    Serial.println("CLIENT CONNECTED");

    String response = "";
    bool begin = false;

    while (client.available() || !begin) {
      char c = client.read();

      if (c == '{') {
        begin = true;
      }

      if (begin) {
        response += (c);
      }

      if (c == '"}') {
        break;
      }

      delay(1);
    }

    int start = response.indexOf("status\":\"") + 11;
    int end = start + 3;

    response_Status = response.substring(start, end);
    Serial.println(response_Status);

    // response successfull
    if (response_Status == "200")
    {
      Serial.println("RESPONSE 200");
      Serial.println("response state == 200");

      // First open the box
      // 0° means open
      Serial.println("OPEN BOX");
      myservo.write(0);
      delay(175);

      lcd.setCursor(0, 0);
      lcd.print("                ");
      lcd.setCursor(0, 0);
      lcd.print("Box opened ,press");
      lcd.setCursor(0, 1);
      lcd.print("                ");
      lcd.setCursor(0, 1);
      lcd.print(" * to close");
    }
    else
    {
      Serial.println("RESPONSE NOT 200");
      Serial.println("not 200");

      lcd.clear();
      lcd.print("Foute code of");
      lcd.setCursor(0, 1);
      lcd.print("al afgeleverd");

      delay(175);
    }
    }

  // reset the value
  value = "";
  }

  // lock box and reset value
  if (customKey == '*')
  {
    Serial.println("CLOSE BOX");
    myservo.write(90);
    value = "";
    client.stop();
  }

  delay(175); // for optimal lcd screen view
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your board's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

this is the serial output:

it's clear that the first request the check the code goes thru but when you try a second time it comes out empty. We did some research and we found that in some cases the servo could affect the request in a bad way. Just not sure if that is correct and how to fix this

Comments are not for extended discussion; this conversation has been moved to chat.

/* hardware libraries*/
#include <Key.h>
#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>

/*Wifi and request libraries*/
#include <SPI.h>
#include <WiFiNINA.h>
#include <ArduinoJson.h>

#define HIGH 0x1
#define LOW 0x0

/* wifi credentials*/
char ssid[] = "sidd";        // your network SSID (name)
char pass[] = "pass";    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;

int status = WL_IDLE_STATUS;
char server[] = "parcelbox.1819.caro.deweze.nxtmediatech.eu";
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
WiFiClient client;

LiquidCrystal_I2C lcd(0x27, 16, 2); // lcd object
Servo myservo; //servo object
boolean boxOpenend = false ;

/* Keypad*/
const byte ROWS = 4;
const byte COLS = 3;

char keys[ROWS][COLS] = {
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};

byte rowPins[ROWS] = {3, 4, 5, 6};
byte colPins[COLS] = {9, 8, 7};

Keypad customKeypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
String value = "";

void setup() {
  lcd.begin(); //start lcd
  Serial.begin(9600);
  myservo.attach(A0); // attach servo to pin
  lcd.backlight(); // start screen light

  /* connect to wifi */
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  /*
    // check for the WiFi module:
    if (WiFi.status() == WL_NO_MODULE) {
      Serial.println("Communication with WiFi module failed!");
      // don't continue
      while (true);
    }

    String fv = WiFi.firmwareVersion();
    if (fv < "1.0.0") {
      Serial.println("Please upgrade the firmware");
    }

    // attempt to connect to Wifi network:
    while (status != WL_CONNECTED) {
      Serial.print("Attempting to connect to SSID: ");
      Serial.println(ssid);
      // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
      status = WiFi.begin(ssid, pass);

      // wait 10 seconds for connection:
      delay(10000);
    }
    Serial.println("Connected to wifi");*/
  createConnection();
}

void loop() {
  lcd.clear();
  lcd.print("Bestelcode / pin");

  char customKey = customKeypad.getKey();   // get the key pressed
  value = value + String(customKey);

  lcd.setCursor(0, 1);
  lcd.print(value);

  if (customKey == '#')
  {
    createConnection();
    Serial.println("PRESSED #");
    String response_Status = "";
    Serial.println("\nStarting connection to server...");

    Serial.println("RESULT OF CLIENT.CONNECT()");
    Serial.println(client.connect(server, 80));

    // if you get a connection, report back via serial:
    if (client.connect(server, 80) == 1)
    {
      int valueLen = value.length();
      if(valueLen == 5){
      Serial.println("IK BEN een pin ");
      value.remove(4);
      Serial.println(value);
      Serial.println("connected to server");

      // Make a HTTP request:
      client.println("GET /api/boxes/2025/pin/" + value + " HTTP/1.1");//1444
      client.println("Host: parcelbox.1819.caro.deweze.nxtmediatech.eu");
      client.println("Connection: close");
      client.println();
      }
      if(valueLen ==17){
      Serial.println("IK BEN een bestelcode");
      value.remove(16);
      Serial.println(value);
      Serial.println("connected to server");

      // Make a HTTP request:
      client.println("GET /api/boxes/2025/code/" + value + " HTTP/1.1");//1444
      client.println("Host: parcelbox.1819.caro.deweze.nxtmediatech.eu");
      client.println("Connection: close");
      client.println();

        }
        else{

          Serial.println("invalid amount of numbers code");
          /*lcd.clear();
          lcd.print("ongeldige code");*/

          }
    }
    else
    {
      Serial.println("client.connect() not successfull");
    }

    // if there are incoming bytes available
    // from the server, read them and print them:
    StaticJsonBuffer<500> jsonBuffer;

    if (client.connected())
    {
      Serial.println("CLIENT CONNECTED");

      String response = "";
      bool begin = false;

      while (client.available() || !begin) {
        char c = client.read();

        if (c == '{') {
          begin = true;
        }

        if (begin) {
          response += (c);
        }

        if (c == '"}') {
          break;
        }

        delay(1);
      }

      int start = response.indexOf("status\":\"") + 11;
      int end = start + 3;

      response_Status = response.substring(start, end);
      Serial.println(response_Status);

      // response successfull
      if (response_Status == "200")
      {
        Serial.println("RESPONSE 200");
        Serial.println("response state == 200");

        // First open the box
        // 0° means open
        Serial.println("OPEN BOX");
        myservo.write(0);
        delay(175);

        lcd.setCursor(0, 0);
        lcd.print("                ");
        lcd.setCursor(0, 0);
        lcd.print("Box open ,druk");
        lcd.setCursor(0, 1);
        lcd.print("                ");
        lcd.setCursor(0, 1);
        lcd.print("* om te sluiten");
        delay(5000);
      }
      else
      {
        Serial.println("RESPONSE NOT 200");
        Serial.println("not 200");

        lcd.clear();
        lcd.print("Foute code of");
        lcd.setCursor(0, 1);
        lcd.print("al geleverd");

        delay(2500);
      }
    }

    // reset the value
    value = "";
  }

  // lock box and reset value
  if (customKey == '*')
  {
    Serial.println("CLOSE BOX");
    myservo.write(90);
    value = "";
    client.stop();
  }

  delay(175); // for optimal lcd screen view
}
void createConnection() {

  // This new line is required to disconnect the previous connection otherwise
  // it will try to use the old connection and never reconnect if the connection fails
  status = WiFi.disconnect();

  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10);
  }
  // you're connected now, so print out the status:
  printWifiStatus();

}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your board's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

I had to rewrite my wifi connection into a function outside my setup. Because the program only established a connection in the beginning and closed it after my first request. By giving it it's own function I could call it inside my loop whenever the user would enter a code the program could reestablish a connection. My program now runs how I need it to run.

Although I can not verify my code, I tried to modify your program. Probably it does not compile and you have to do some corrections. I changed it in a way I would expect it to work and hopefully I understood your intentions.
At least we could use this version as a base to elaborate a working one together.
#include <Key.h>
#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
#include <SPI.h>
#include <WiFiNINA.h>
#include <ArduinoJson.h>

#define HIGH 0x1
#define LOW 0x0

char ssid[] = "ssid";
char pass[] = "password";
int keyIndex = 0;

int status = WL_IDLE_STATUS;
char server[] = "parcelbox.1819.caro.deweze.nxtmediatech.eu";

WiFiClient client;

LiquidCrystal_I2C lcd(0x27, 16, 2);
Servo myservo;

/* Keypad*/
const byte ROWS = 4;
const byte COLS = 3;

char keys[ROWS][COLS] = {
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};

byte rowPins[ROWS] = {3, 4, 5, 6};
byte colPins[COLS] = {9, 8, 7};

Keypad customKeypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
String value = "";

void setup()
{
  lcd.begin();
  Serial.begin(9600);
  myservo.attach(A0);
  lcd.backlight();

  if (WiFi.status() == WL_NO_MODULE)
  {
    Serial.println("Communication with WiFi module failed!");
    while (true);
  }

  String fv = WiFi.firmwareVersion();
  if (fv < "1.0.0") { Serial.println("Please upgrade the firmware"); }

  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED)
  {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    status = WiFi.begin(ssid, pass);
    delay(10000);
  }

  Serial.println("Connected to wifi");
  printWifiStatus();
}

void loop()
{
  lcd.clear();
  lcd.print("Geef bestelcode");
  char customKey = customKeypad.getKey();
  value = value + String(customKey);
  lcd.setCursor(0, 1);
  lcd.print(value);
  if (customKey == '#')
  {
    String response_Status = "";
    Serial.println("\nStarting connection to server...");

    if ( client.connect( server, 80 ) )
    {
      value.remove(16);
      Serial.println(value);
      Serial.println("connected to server");

      // Make a HTTP request:
      client.println("GET /api/boxes/1444/code/" + value + " HTTP/1.1");
      client.println("Host: parcelbox.1819.caro.deweze.nxtmediatech.eu");
      client.println("Connection: close");
      client.println();
    }

    StaticJsonBuffer<500> jsonBuffer;

    if ( client.connected() )
    {
      String response = "";
      bool begin = false;

      // I do not understand why you have to use  || ! begin
      // If the client has no content available, you can not read some
      // It doesn't matter if begin is true or false.
      // Or am I missing something?
      while ( client.available() || ! begin )
      {
        char c = client.read();

        if ( c == '{' )  { begin = true;    }
        if ( begin )     { response += (c); }
        if ( c == '"}' ) { break;           }

        delay(1);
      }

      // Why do you parse the json text for a special
      // attribute and then parse it again into a json object
      // where you can read this attribute?
      int start = response.indexOf("status\":\"") + 11;
      int end = start + 3;
      response_Status = response.substring(start, end);

// I commented this out because you do not use the root variable
// in the following code
//      JsonObject& root = jsonBuffer.parseObject(response);
//      if (!root.success())
//      {
//        Serial.print("parseObject(");
//        Serial.print(response);
//        Serial.println(") failed");
//        break;
//      }

      Serial.println(response_Status);
      if (response_Status == "200")
      {
        Serial.println("response state == 200");

        // First open the box

        // 0° means open
        myservo.write(0);
        delay(175);

        // Then inform the user how to close it

        lcd.clear();
        // I added the cursor positioning.
        // As far as I know clear does not reset the cursor.
        lcd.setCursor(0, 0);
        lcd.print("Box openend ,press");
        lcd.setCursor(0, 1);
        lcd.print(" * to close");

        // then check if the user wants to close it
        char key;
        do
        {
          key = customKeypad.getKey();
          if (key == '*')
          {
            // 90° means locked
            myservo.write(90);
            value = "";
          }
        }
        while( key != '*' );

      }
      else
      {
      // I replaced the else if by a simple if
      // as (response_Status != "200") is the else case
      // of (response_Status == "200")
        Serial.println("response state != 200");

        lcd.clear();
        // "set cursor" added
        lcd.setCursor(0, 0);
        lcd.print("wrong code or");
        lcd.setCursor(0, 1);
        lcd.print("already deliverd");

        delay(175);
        value = "";
      }
      // I change the while loop into an if block
      // so you don't need a break; here
    }

// Here you could enter a halt state without a reason.
// Even you won't expect to halt here.
//    if (!client.connected())
//    {
//      Serial.println();
//      Serial.println("disconnecting from server.");
//      client.stop();
//
//      // do nothing forevermore:
//      while (true);
//    }
  }

  if (customKey == '*')
  {
    // 90° means locked
    myservo.write(90);
    value = "";
  }

  // for optimal lcd screen view
  delay(175);
}

void printWifiStatus()
{
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

EDIT
This edit is related to the updated version of your program.
If you close the box with a key press you also stop the client with the last line.
Please remove the following line from the program.
// lock box and reset value
if (customKey == '*')
{
  Serial.println("CLOSE BOX");
  myservo.write(90);
  value = "";
  // remove this as you can not connect a stopped client
  // client.stop();
}

I tried your code it builds perfectly, I could open the box and close it but the LCD keeps displaying " box open press * to close ". Your code is much more readable and structured than mine! I can learn alot from this

Thank you for the reply and extending your question. By looking at my code I saw that I made a terrible mistake. Perhaps I've programed with JavaScript for too long now. In JS "" and '' is the same. In C/C++ Its something completely different. The line while( key != "*" ) is always true and the Loop is never left. I've corrected it in  my answer. while( key != '*' ).  Could you please change it in your program too and try that version.

@imkeVr I just realize that, you use a complete different code now.  And it would be better if I had looked into the output earlier.;-) I don't believe the the Server disturbed the client communication. I think you are simply not able to open a connection with a client that is stopped. I'll update the answer once more. ;-)

I found the a way that works for my program. I scratched the wifi setup in the void setup en relocated it to its own function outside any loop or setup. This way I could call for the function and reestablish a connection inside my void loop itself. It now works like it should. Thank you for all the help I learned alot by doing this!

@imkeVr It was a pleasure to work with you. I first wanted to propose what you have done now by yourself, but I didn't want to make my answer too complicated. And now I see you managed it, just with the few information i gave you. This is one of the moments, that keeps me answering questions on SE. And I could imagine that, if you keep on learning quickly, our conversation in the future would be with changed rolls. I ask and you answer. I wish you and your partner success with the project.


text:
serial 1 was not declared in the scope
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
#include <SoftwareSerial.h>

char Mob[20]="+923319020922";
String stringGPS = "";
String stringGPS1 = "";
char c=0;
int t=0,i;
int buzzer = 9;
int buttonState = 0;

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

//const int buttonPin1 =9 ;
int buttonState1 = 0;
int helmetstate=0;
const int relay=8;
char inByte=0;

void setup()
{
  lcd.begin(20, 4);
  lcd.setCursor(0, 0);
  pinMode(relay, OUTPUT);
  pinMode(buzzer, OUTPUT);
  Serial.begin(9600);
  Serial1.begin(9600);
  Serial2.begin(9600);
  digitalWrite(relay, LOW);
  delay(15000);
  lcd.print("Config modem....");

  Config();

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Smart helmet      ");
}

void loop()
{
  if(Serial2.available())
  {
    inByte = Serial2.read();
    //Serial.write(inByte);
    if(inByte=='A'||inByte=='B'||inByte=='C'){
    inByte=0;
    SMS(Mob);

    while(Serial2.available()>0)
    {
      i = Serial2.read();
    }
  }

  if(inByte=='D')
  {
    digitalWrite(relay, LOW);
    inByte=0;
  }

  if(inByte=='E')
  {
    digitalWrite(relay, HIGH);
    inByte=0;
  }
  else
  {
  }
}

 //buttonState = digitalRead(buttonPin);
 // if (buttonState == LOW) {
 //Serial.print("ok");
 //lcd.clear();
 // lcd.setCursor(0, 0);
 //lcd.print("Sending msg       ");
 // lcd.setCursor(0, 0);
 //lcd.print("Smart helmet      ");
 // checkGPS();
 // SMS(Mob);

 //helmet();
 checkGPS();
 lcd.setCursor(0, 1);
 lcd.print(stringGPS1);
 //Serial.println(stringGPS1);
}

/*
void helmet()
{
  buttonState1 = digitalRead(buttonPin1);
  if (buttonState1 == HIGH)
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("SWITCH ON  .......    ");
    digitalWrite(relay, HIGH);
  }
  else
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("SWITCH OFF .......    ");
    digitalWrite(relay, LOW);
  }
}
*/

void checkGPS()
{
  // Serial.print("check gps");
  // while (Serial.available())
  // {
  if (Serial.available()>0)
  {
   // c = Serial.read();
   // stringGPS  = c;
   //Serial.print(c);
   while (c != 'R')
   {
     c = Serial.read();
     // Serial.print(c);
   }
    // if (c== 'R')
    // {
    //   Serial.print(c );
         while(t!=41)
         {
           if (Serial.available())
           {
             c = Serial.read();
             stringGPS += c;
             t++;
             //Serial.print(stringGPS );
          }
  }
  stringGPS1= stringGPS.substring(15, 41);
  // Serial.println(stringGPS1);
  t=0;
  c=0;
  stringGPS = "";
    // }
  }
  }

void SMS(char Mob[20])
{
   digitalWrite(buzzer, HIGH);
   lcd.setCursor(0, 0);
   lcd.print("Sending msg       ");
   Serial1.print("AT+CMGS=\"");     // send the SMS number
   Serial1.print(Mob);/// Send mobile number
   Serial1.print("\"\r");
   delay(4000);
   Serial1.print(stringGPS1);// send the SMS Data
   Serial1.print("\r");
   delay(2000);
   Serial1.write(0x1A);  ///Ctrl+Z
   delay(1000);
   Serial1.write(0x0A);  ///Carrige return
   delay(1000);
   Serial1.write(0x0D);    ///line feed
   delay(1000);
   stringGPS1 = "";
   lcd.setCursor(0, 0);
   lcd.print("Smart helmet      ");
   digitalWrite(buzzer, LOW);
}

void Config()/////configuration for sim900
{
  delay(4000);
  Serial1.print("ATE0\r"); ////Disable Echo
  delay(4000);
  Serial1.print("AT\r"); ///checking echo
  delay(4000);
  Serial1.print("AT+CMGF=1\r");///msg format
  delay(4000);
}

when i run this code it give me error that serial1 was not decleared in the scope

The board, that you are compiling for, does not have Serial1 and Serial2. Why did you try to use them? Or are you simply compiling for the wrong board type? What Arduino do you have?

What board are you using? If it's not one of the bigger boards then what makes you think it would have Serial1 and Serial2?

If you had formatted your code in a readable manner you would see, that there are too many closing curly braces . One in your loop function and two in the code at the end. Correct formatting makes the code readable and let you find your mistakes easier.

The only SoftwareSerial you a declaring is SoftwareSerial mySerial(10, 11); // RX, TX

(And you you didn't use it afterwards).
If the hardware serials Serial1, Serial2 or Serial3 are available
(and already declared in the arduino.h header depends on the board you are using.

source: Stack Exchange

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

sort: votes


text:
SG 90 servos randomly spinning
I started one project where i need 4 servos to control 4 grabbers jaws. i use STM32F103C8T6 with arduino IDE for programming it. The motor TZT Micro Servo 9g SG 90. First, I was playing with stepper motors to make them rotate how I want, then I added one servo on the same protoboard where are steppers and drivers for each. I used servo sweep example, and it randomly started twitching and sometimes to spin until power is off. the STM is powered with usb cable from PC. Then i tried other 3 motors and got same result.
Then i put STM on separate protoboard and there connected servo and it was not perfect but it was much stable than on onther protoboard. Then i used old PC power supply which i modified long time ago to have jacks for 12V, 5V and 3,3V, and connected servo to it and it worked normally.
So I started connecting motors 1 by one back to protoboard with other elements and tested them while adding them, first the first one , then added second and tested both, then added 3rd and tested all 3...
First two worked fine, but when i added third, all of them started twitching again, but then it stopped. So i added fourth and now all of them are twitching even if I write in code to rotate only one or two of them, which I don't understand how they can move if I do not give them signal from code.
Here is code for controlling both servo and stepper motors:
#include<Servo.h>

const int stepPin1 = PA4;
const int dirPin1 = PA0;
const int stepPin2 = PA5;
const int dirPin2 = PA1;

const int stepPin3 = PA6;
const int dirPin3 = PA2;

const int stepPin4 = PA7;
const int dirPin4 = PA3;

Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;

void setup() {
  pinMode(stepPin1,OUTPUT);
  pinMode(stepPin2,OUTPUT);
  pinMode(stepPin3,OUTPUT);
  pinMode(stepPin4,OUTPUT);

  pinMode(dirPin1,OUTPUT);
  pinMode(dirPin2,OUTPUT);
  pinMode(dirPin3,OUTPUT);
  pinMode(dirPin4,OUTPUT);

  servo1.attach(PB12);
  servo2.attach(PB14);
  servo3.attach(PA8);
  servo4.attach(PA10);

  //servo1.write(0);
  //servo2.write(0);
  //servo3.write(0);
  //servo4.write(0);
}

void loop() {
  digitalWrite(dirPin1,HIGH);
  digitalWrite(dirPin2,HIGH);
  digitalWrite(dirPin3,HIGH);
  digitalWrite(dirPin4,HIGH);

   //servo1.write(100);
   servo2.write(100);
   //servo3.write(100);
   //servo4.write(100);

  for(int x = 0; x < 200; x++) {
    digitalWrite(stepPin1,HIGH);
    digitalWrite(stepPin2,HIGH);
    digitalWrite(stepPin3,HIGH);
    digitalWrite(stepPin4,HIGH);

    delayMicroseconds(750);

    digitalWrite(stepPin1,LOW);
    digitalWrite(stepPin2,LOW);
    digitalWrite(stepPin3,LOW);
    digitalWrite(stepPin4,LOW);

    delayMicroseconds(750);
  }

  delay(1000); // One second delay

  digitalWrite(dirPin1,LOW);
  digitalWrite(dirPin2,LOW);
  digitalWrite(dirPin3,LOW);
  digitalWrite(dirPin4,LOW);

  //servo1.write(-100);
  servo2.write(-100);
  //servo3.write(-100);
  //servo4.write(100);

  for(int x = 0; x < 200; x++) {
    digitalWrite(stepPin1,HIGH);
    digitalWrite(stepPin2,HIGH);
    digitalWrite(stepPin3,HIGH);
    digitalWrite(stepPin4,HIGH);

    delayMicroseconds(750);

    digitalWrite(stepPin1,LOW);
    digitalWrite(stepPin2,LOW);
    digitalWrite(stepPin3,LOW);
    digitalWrite(stepPin4,LOW);

    delayMicroseconds(750);
  }

  delay(1000);

}

Here is also link to a short video of how the servos are behaving:

Do the servos still twitch if the steppers are quiet ? If the stepper-drivers are disconnected?

Yes, they are twitching. Soon I should get another STM and Arduino uno to test board and motors to check if they are broken.

Try assigning pins to the servos that are physically distant on the Arduino board from those assigned to steppers. Does anything change? It's looks rather like crosstalk from one to the other.

They are already separated because pins for stepper motors are on one side of board and servo pins are on another. Btw i managed to get both arduino and another STM from friend. I tested only servo motors on arduino alone with separated power supply, and only once one motor started spinning continuously until power supply is off. Next I will try same with STM and if it works, I will put it back on protoboard with other elements. But first I need to sleep after being awake all night, so I will update situation after some time.

With second STM it doesn't work too. When I added first servo, it started twitching, then i tried other 3 and then I tried them on other pins but its same. Maybe they would work if I would use software for STM, but this was easier way for me. So because it works on arduino (I tested them now again), I will probably buy arduino nano and use it just to control servos with them, MEGA is expensive here where I live and i do not have much time left so I have to use 2 controllers for this...
Anyway, thanks :D

Not necessarily on topic, but I could swear I saw the front servo in the video turn 360°; did it? As far as I know, the SG90 servos only do about 180°.

Just got arduino nano and it worked perfectly fine. So only problem that I see now is probably that Arduino IDE and arduino libraries are not fully compatible with STM chips and that is why that happened to me.
Anyway, thanks for help

ocrdu, sorry for late answer. Yeah it did 360°, sometimes it was going more than 360°. But if you make mods on those servos, than they can be continuous servos, so it isnt impossible. But my problem was that they all did it without mods and i was totally confused how is that happening xD

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


text:
about receiving float on Atmega32 from matlab
I want to receive a float on Atmega32 from matlab. I display the output on an lcd, but i receive 0.000, can any one help me? Please ...
matlab code
s=serial('COM1','BaudRate',9600);
fopen(s)
fwrite(s,170,'uint8');//header frame
fwrite(s,1.2,'float');//the data to be sent

ATmega32 code
union {
  signed long l;
  float f;
} data;

int main(void)
{
  DDRA=0xff;//for LCD
  DDRB=0xff;//for LCD
  data.l;
  char value[8];
  usart_init();
  Lcd8_Init();

  while(1)
  {
    if(uart_receive()==0xAA)
    {
      //header,0xAA=170
      Lcd8_Set_Cursor(0,0);
      Lcd8_Write_String("Float");
      _delay_ms(100);

      data.l=(long)uart_receive();
      data.l=(long)(data.l||(uart_receive()<<8));
      data.l=(long)(data.l||(uart_receive()<<16));
      data.l=(long)(data.l||(uart_receive()<<24));

      dtostrf(data.f,8,3,value);//convert float to string

      Lcd8_Clear();
      Lcd8_Set_Cursor(0,0);
      for(int i=0;i<8;i++) Lcd8_Write_Char(value[i]);
   }

}}

I would say you wrote the value into the long member of data data.l, but you tried to convert the float member of data data.f to a string. data.f is still 0.0

data.l contains the float value sent from matlab..so how to convert data.l to float?

You send a float value from mathlab byte wise to the AVR and store 4 bytes of the float value into a long variable of the AVR. That's complicated, becaus you have to know several things. How is the structure of a float in matlab? Is this the same on a AVR? I would suggest you send a String with the value from mathlab to the AVR and on the AVR convert the string into a float. (I know atof() for this reason. You use an AVR lib I don't know. In matlab you can use the fprintf function to convert the float to a string and send it to the AVR.


text:
ESP-01 wakes up from deep sleep and then hangs
I have found a number of other posts from people with the same problem but I can't find an answer.
I have a small batch of ESP-01 boards, sold by Inland, and I wish to use deep sleep mode on them.
I soldered a small copper wire from pin 8 (i.e. GPIO 16) to RST.  On one board I soldered it directly, on another I soldered pin 8 and RST to two sides of a 2 pin header so I could use  jumper in case I wanted to disconnet GPIO 16 from RST.
I am flashing the following simple code (using Arduino IDE 1.8.12), which is about the simplest test of the deep sleep mode that I can think of.
void setup()
{
   Serial.begin(74880);
   Serial.setTimeout(2000);

   while(!Serial) { }

   Serial.println(
     "I'm awake, but I'm going into deep sleep mode for 15 seconds");

   ESP.deepSleep(15e6);
}

void loop() {
}

On starting the serial monitor shows
ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3664, room 16
tail 0
chksum 0xee
csum 0xee
v39c79d9b
~ld
I'm awake, but I'm going into deep sleep mode for 15 seconds

After 15 seconds the serial monitor shows
ets Jan  8 2013,rst cause:2, boot mode:(3,6)

and nothing else. After that the thing hangs and nothing further happens.
So,  it appears that the setup runs, the serial monitor prints the message, the mc goes into deep sleep, after 15 seconds it wakes up by a reset, but doesn't go through set up again, hence doesn't print the message or go back sleep.
Here are some comments.    The problem has nothing to do with Wifi, MQTT etc, I have tried many fancy sketches using all of these, I have same problem no matter what, the above sketched is my distillation to the simplest demonstration of the deep sleep problem.
I have flashed the program with Arduino IDE, Platform IO, and esptool.py from a command line.  It doesn't make a difference.
There may be a problem with my soldering job, but I'm pretty good at soldering and SMD rework, and I have repeated the job on a number of these ESP-01 modules, inspected and tested with multimeter, etc.  all with the same outcome.
I don't see a problem with my code or IDE, I have a batch of Lolin Nodemcu boards, and this sketch works perfectly on all of those.  In that case I simply connect GPIO 16 to RST with a jumper wire, the program prints the message, sleeps for 15s, wakes up, prints it again, goes back to sleep for 15s more, etc. etc.
Are these just bad boards?  I have read some things that say the flash chips might be lousy, and if I replace those it might help? I'm tempted to trash these boards and buy some D1 mini's, but I've seen a number of posts from people who say they've had the same problem with D1 minis.   If the board is the problem, are there any recommendations for manufacturers or vendors that sell better quality?

Do you happened to have anything connect to reset pin, for example, from the USB-TTL serial adaptor? 2) Try to use CH_PD instead of RESET pin to see if it works? For CH_PD, it will depends on whether you have ESP-01 or ESP-01S (which already has a pull resistor on CH_PD).

while(!Serial) { } does nothing on esp. why do you have Serial.setTimeout(2000);? let the esp start completely before going to sleep. I guess it is still in process of autoconnecting to last remembered AP.

@hcheung The board is an ESP-01, not an ESP-01S. I'm programming it with a simple USB-TTL flasher also sold by Inland, plugged into the USB port of my Macbook.   When the board is plugged into the flasher the RST pin is pulled up to 3v3 by a 12K resistor.   So I should try connecting GPIO 16 or CH_PD instead of RST and see what happens?

@Juraj Good question! I"m not sure, I copied the code since I'm not quite sure what I'm doing. I commented out the lines with while(!Serial)... and Serial.setTimout.... and the result didn't change. As I mentioned, I can run the exact same sketch on several ESP8266 Nodemcu boards and it works fine, so I figured the problem wasn't with the software.

I need to amend one thing:  I said "after 15 seconds it wakes up by a reset, but ....". This isn't totally clear.   As an experiment, I ran the sketch on a nodemcu board (where it works perfectly), but I did NOT connect GPIO 16 to RST with the jumper.   The result is exactly the same it goes to sleep, then after 15 seconds prints ets Jan  8 2013,rst cause:2, boot mode:(3,6), and nothing else, and then hangs.  In other words the ESP-01 board is behaving exactly as if GPIO 16 is NOT connected to RST.

on esp-01 io 16 is not connected to reset

@juraj I'm not sure what you mean.  Do you mean that GPIO 16 is not connected by default to reset on the ESP-01 board, or do you mean that it shouldn't be connected? It clearly is not connected by default.   According to the ESP8266 data sheet GPIO 16 needs to be connected to reset in order to enable wake up from deep sleep. My objective is to get the chip to wake up from deep sleep.

it is not connected. you can wire it if you can solder to the chip's leg. it must be connected to reset out from deep-sleep. it is a workaround for an error in the basic bootloader of the esp8266. this bootloader can't be updated and it hangs on internal wake-up.

@juraj That makes sense that it's a workaround for an error. You would think when the chip was first being designed that it could have been made to wake up from deep sleep without having to make an external connection.

Not necessarily an answer, but something to look at: check the Manufacturer ID of the Flash on your board.  My suspicion is that when some Flash chips come out of suspend, they're in lower drive mode than on initial power-up.  At least one person fixed his 'zombie mode' by replacing the Flash with a different vendor.  Nobody else has attempted it yet.
I have an Inland ESP-01S that's reporting MID = 0x5E (supposedly Zbit) and it comes out of Deep Sleep repeatedly.  Here's all of the Manufacturer IDs I know of or have seen:
Winbond EF
GigaDevice C8
Puya 85
Bright Moon 53
BergMicro E0
XMC 20
XTX 0B
Eon 1C
Shanghai Fundan A1
Macronix C2
Hua Hong Zhixin 68
ISSI 9D
Paragon E0 (same as Berg - oopsie or clone?)
Zbit 5E
Zetta BA
esptool.py --port /dev/ttyUSB0 flash_id   (linux)
esptool.py -p COMx flash_id    (Windoze)
Note: the cheap D1 Mini boards with no-name ESP-12F modules flooding eBay, Aliexpress and other places report XTX Flash, and they have a 5.6K pull-up on EXT_RSTB which will shorten the RST pulse from GPIO16, as well as making it hard to hit the level to be detected as a LOW due to the series 470 ohm resistor.  We're unsure whether it's the Flash or the low value pull-up (typically 10 or 12K on other boards/modules) that's causing issues with those boards.  Normally if RST isn't seen as LOW after Deep Sleep then you'll get an "ets_main.c" message at boot before it hangs.
I have a clone D1 Mini Pro that has a Flash that reports MID = EF (Winbond), although the marking on the Flash is nothing I can find on Winbond's site, only on places selling cheap Flash.  Luckily the D1 Mini Pro also exits Deep Sleep successfully.

I have come to the conclusion that these boards are bad.    I wrote a simple sketch that turns an LED on for 3 seconds, then goes into deep sleep for 12 seconds, then wakes up.   I have a batch of 3 Lolin ESP8266 nodemcu boards and the sketch works fine on all of them.   The LED goes on for 3s, then goes off for 12s, then goes back on, etc. Furthermore using an ammeter I measure a current draw of around 80 mA while the LED is on, and around 4 mA while it's off, repeatedly.
However --- I have another batch of five ESP-01 boards.   I soldered a fine copper wire to GPIO 16 and to the reset pin, used the same code, same set up, power supply, LED, etc.
The light goes on for 3s then goes off for 12s,  then comes back on and stays on and then there is no further change.  Furthermore, the current draw during the first 3s is around 80 mA, but when the light comes back on and the controller hangs, the current draw is around 40mA.
Incidentally, I tested the nodemcu boards,the ones that work fine, with this sketch but disconnecting the jumper from GPIO 16 or RST, and it behaves exactly the same as the ESP-01 boards, including the 40mA current draw in  the zombie state.   So it would appear that the problem on the ESP-01 boards is that the GPIO 16 pin is just not connected to RST.  However I have soldered all five of these things multiple times, and I have become pretty darned proficient at soldering that little pin, and I am 99.999999% sure that I have the wire soldered to the pin, with no bridges, didn't fry anything, etc.

I was wrong: I have an Inland ESP-01.  The package was marked ESP-01S...  Yep, I got screwed.  There's no pull-up resistor on EN, GPIO0 or GPIO2, and GPIO15 is shorted to GND on the board which is generally a Bad Idea with a GPIO.  Looks like a 12K resistor to 3V3 and possibly a .1uF cap on RST.  It works OK with Deep Sleep as long as it's in that USB converter board, I'd have to attach the program mode resistors to get it to run free-floating.  Here's a photo of what Inland is selling marked as "ESP-01S": https://i.imgur.com/2OFr8r9.jpg  Yeah, NOT!  Don't buy it if you're expecting ESP-01S.


text:
Improper functioning of Node mcu when connected to source other than PC
I connected EM18 rfid reader to NodeMCU to read rfid card data. It showed card number very quickly and consistently till it was connected to my PC's USB. But when I connected it to 5v power source (mobile phone charger) then it didnt read cards well i.e. sometimes it read and sometime dosent.
Thants very strange.
Grounds might not be the issue as EM18 is powered from NodeMCU and NodeMCU ultimately connected to source(mobile phone charger)
Code is given below :
int count = 0;
char input[12];
boolean flag = 0;

void setup()
{
   pinMode(LED_BUILTIN, OUTPUT);
   // begin serial port with baud rate 9600bps
   Serial.begin(9600);
}

void loop()
{
   if(Serial.available())
   {
      count = 0;
      // Read 12 characters and store them in input array
      while(Serial.available() && count < 12)
      {
         input[count] = Serial.read();
         count++;
         delay(5);
      }
      // turn the LED on (HIGH is the voltage level)
      digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
  }
}

Where did you see the card number.? Why are you sure it reads the card? Or did you mean the LED goes on, when you said it had read the card number? The only thing I can imagine is that if the MCU is connected to the PC, the if(Serial.available())  is true and can enter the block (for what reason ever). If you have the EM18 also connected to the same Hardware serial port (it seems so) then this connection might fail. check the setup or add a picture of you setup to the question.

Thanx for reply <3, and yeah you are right ! To check if card is read... in built LED is turned on or off as per above code. When I connect it to PC I have serial monitor thus i see card number and LED blinks accordingly. But when i connect it to power source then cards sometimes read and sometimes not in a single attempt because the in built LED doesn't  on or off to prove the same. It seems as the Tx pin got slowed down (just to imagine as this is so strange issue). If you need pictures I can post but there se nothing to show as the setup is very simple. EM18 is just connected to Nodemcu.

You see the card number in the serial terminal on the PC if this is connected. But you do not write the card number from the MCU to the PC.(at least if that is the original code) I fear you connected the EM18 to the RX TX pins that are also connected to the USB to Serial converter on the board. So  the PC can spy and read the card number. I never thought this is possible but it seems so.  You should use two serial ports one for the EM18 and the standard port for the PC. Hint: https://community.blynk.cc/t/how-to-use-2-serial-ports-or-more-in-nodemcu/20282

I will give it a try and will inform you shortly.


text:
I2C and SPI using sensor and Oled display
Im currently working on a project which displays vital signs such as pulse and oxygen on my display. Now, my sensor is connected through I2C while my OLED runs through SPI. Im trying to display the sensor readings on the OLED but that doesnt seem to work. Tried reading through the threads and wasnt able to come up with a concise solution.
Anyone with a similar case and working solution will truly appreciate the support.
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Arduino.h>
#include "algorithm.h"
#include "max30102.h"

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for SSD1306 display connected using
// software SPI (default case):
#define OLED_MOSI   11
#define OLED_CLK   13
#define OLED_DC    9
#define OLED_CS    12
#define OLED_RESET 8
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT,
  OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

#define ONE_WIRE_BUS 4
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors( &oneWire );

#define MAX_BRIGHTNESS 255

#if defined(ARDUINO_AVR_UNO)
// Arduino Uno doesn't have enough SRAM to store
// 100 samples of IR led data and red led data in 32-bit format
// To solve this problem, 16-bit MSB of the sampled data
// will be truncated. Samples become 16-bit data.
uint16_t aun_ir_buffer[100]; //infrared LED sensor data
uint16_t aun_red_buffer[100];  //red LED sensor data
#else
uint32_t aun_ir_buffer[100]; //infrared LED sensor data
uint32_t aun_red_buffer[100];  //red LED sensor data
#endif

// data length
int32_t n_ir_buffer_length;
// SPO2 value
int32_t n_spo2;
// indicator to show if the SPO2 calculation is valid
int8_t ch_spo2_valid;

// heart rate value
int32_t n_heart_rate;

// indicator to show if the heart rate calculation is valid
int8_t  ch_hr_valid;
uint8_t uch_dummy;

void setup()
{
  //resets the MAX30102
  maxim_max30102_reset();

  // initialize serial communication at 115200 bits per second:
  Serial.begin(115200);

  // pin D10 connects to the interrupt output pin of the MAX30102
  pinMode(10, INPUT);
  delay(1000);

  // Reads/clears the interrupt status register
  maxim_max30102_read_reg(REG_INTR_STATUS_1,&uch_dummy);
  // wait until user presses a key
  while( Serial.available() == 0 )
  {
    Serial.write(27);       // ESC command
    Serial.print(F("[2J")); // clear screen command
    Serial.println(F("Press any key to start conversion"));
    delay(1000);
  }

  uch_dummy=Serial.read();
  maxim_max30102_init();

  Serial.begin(115200);
  sensors.begin();

  if(!display.begin(SSD1306_SWITCHCAPVCC))
  {
    Serial.println(F("SSD1306 allocation failed"));
  }

  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(30,30);
  display.print("ATRAL:D");
  display.display();
  delay(1000);
  display.clearDisplay();
}

void loop()
{
  // Call sensors.requestTemperatures() to issue
  // a global temperature and Requests to all devices on the bus
  sensors.requestTemperatures();

  Serial.print("Celsius temperature: ");
  // Why "byIndex"? You can have more than
  // one IC on the same bus. 0 refers to the first IC on the wire
  Serial.print(sensors.getTempCByIndex(0));
  Serial.print(" - Fahrenheit temperature: ");
  Serial.println(sensors.getTempFByIndex(0));
  delay(100);

  // variables to calculate the on-board LED
  // brightness that reflects the heartbeats
  uint32_t un_min, un_max, un_prev_data, un_brightness;
  int32_t i;
  float f_temp;

  un_brightness=0;
  un_min=0x3FFFF;
  un_max=0;

  // buffer length of 100 stores 4 seconds
  // of samples running at 25sps
  n_ir_buffer_length=100;

  // read the first 100 samples, and determine the signal range
  for( i=0; i < n_ir_buffer_length; i++ )
  {
    // wait until the interrupt pin asserts
    while( digitalRead(10) == 1 );
    //read from MAX30102 FIFO
    maxim_max30102_read_fifo( ( aun_red_buffer + i ),
                              ( aun_ir_buffer + i ) );

    if(un_min>aun_red_buffer[i])
      un_min=aun_red_buffer[i];  //update signal min
    if(un_max<aun_red_buffer[i])
      un_max=aun_red_buffer[i];  //update signal max
    Serial.print(F("red="));
    Serial.print(aun_red_buffer[i], DEC);
    Serial.print(F(", ir="));
    Serial.println(aun_ir_buffer[i], DEC);
  }
  un_prev_data=aun_red_buffer[i];

  // calculate heart rate and SpO2 after first 100 samples
  // (first 4 seconds of samples)
  maxim_heart_rate_and_oxygen_saturation( aun_ir_buffer,
         n_ir_buffer_length, aun_red_buffer,
         &n_spo2, &ch_spo2_valid, &n_heart_rate,
         &ch_hr_valid );

  // Continuously taking samples from MAX30102.
  // Heart rate and SpO2 are calculated every 1 second
  while(1)
  {
    i=0;
    un_min=0x3FFFF;
    un_max=0;

    // dumping the first 25 sets of samples
    // in the memory and shift the last 75 sets
    // of samples to the top
    for( i=25; i<100; i++ )
    {
      aun_red_buffer[i-25]=aun_red_buffer[i];
      aun_ir_buffer[i-25]=aun_ir_buffer[i];

      //update the signal min and max
      if(un_min>aun_red_buffer[i])
        un_min=aun_red_buffer[i];
      if(un_max<aun_red_buffer[i])
        un_max=aun_red_buffer[i];
    }

    //take 25 sets of samples before calculating the heart rate.
    for( i=75; i<100; i++ )
    {
      un_prev_data=aun_red_buffer[i-1];
      while(digitalRead(10)==1);
      digitalWrite(9, !digitalRead(9));
      maxim_max30102_read_fifo((aun_red_buffer+i), (aun_ir_buffer+i));

      //calculate the brightness of the LED
      if(aun_red_buffer[i]>un_prev_data)
      {
        f_temp=aun_red_buffer[i]-un_prev_data;
        f_temp/=(un_max-un_min);
        f_temp*=MAX_BRIGHTNESS;
        f_temp=un_brightness-f_temp;
        if(f_temp<0)
          un_brightness=0;
        else
          un_brightness=(int)f_temp;
      }
      else
      {
        f_temp=un_prev_data-aun_red_buffer[i];
        f_temp/=(un_max-un_min);
        f_temp*=MAX_BRIGHTNESS;
        un_brightness+=(int)f_temp;
        if(un_brightness>MAX_BRIGHTNESS)
          un_brightness=MAX_BRIGHTNESS;
      }
#if defined(ARDUINO_AVR_LILYPAD_USB)
      analogWrite(13, un_brightness);
#endif

#if defined(ARDUINO_AVR_FLORA8)
      LED.setPixelColor(0, un_brightness/BRIGHTNESS_DIVISOR, 0, 0);
      LED.show();
#endif

      //send samples and calculation result to terminal program through UART
      Serial.print(F("red="));
      Serial.print(aun_red_buffer[i], DEC);
      Serial.print(F(", ir="));
      Serial.print(aun_ir_buffer[i], DEC);

      Serial.print(F(", HR="));
      Serial.print(n_heart_rate, DEC);

      Serial.print(F(", HRvalid="));
      Serial.print(ch_hr_valid, DEC);

      Serial.print(F(", SPO2="));
      Serial.print(n_spo2, DEC);

      Serial.print(F(", SPO2Valid="));
      Serial.println(ch_spo2_valid, DEC);
    }
    maxim_heart_rate_and_oxygen_saturation(aun_ir_buffer, n_ir_buffer_length, aun_red_buffer, &n_spo2, &ch_spo2_valid, &n_heart_rate, &ch_hr_valid);
  }

  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.print("Temp: ");
  display.print(sensors.getTempCByIndex(0));
  display.print("C");
  display.setCursor(0,10);
  display.print("Temp: ");
  display.print(sensors.getTempFByIndex(0));
  display.print("F");
  display.setCursor(0,20);
  display.print("HR: ");
  display.print(n_heart_rate, DEC);
  display.setCursor(0,30);
  display.print("02: ");
  display.print(n_spo2, DEC);
  display.setCursor(0,50);
  display.setTextSize(2);
  display.print("BOX.E");
  display.display();
  display.clearDisplay();

}

Sure thing, Ill share two separate sketches, the sensor sketch that I want to combine with the Oled sketch that has a temperature sensor in it too

@VE7JRO I Hope the codes will help

"Doesn't seem to work" is not a good description of the problem. We cannot know, what that means. You need to tell us, what you expected with each code and what exactly is actually happening. Also: You have included 2 seperate sketches, but your question is more why the combination does not work. For answering that, we need to see your combined code.

@chrisl Thank you for highlighting and clarifying, Ill do what you've suggested and get back

@chrisl the code has been modified and thank you all for editing it.. kinda new to the whole community and formatting


text:
I get the following error while using esp32

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0,
  SPIWP:0xee
  clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
  mode:DIO, clock div:1 load:0x3fff0018,len:4 load:0x3fff001c,len:1044
  load:0x40078000,len:8896 load:0x40080400,len:5816 entry 0x400806ac
[E][camera.c:1049] camera_probe(): Detected camera not supported.
  [E][camera.c:1249] esp_camera_init(): Camera probe failed with error
  0x20004

I tried all the troubleshooting methods found in other forums

have you tried reading the error printout to determine what the problem is?

Welcome to StackExchange!
I guess you flashed esp32-cam firmware to off-branded ESP32-CAM with different pinout assignments.
To fix this, maybe you should try around with different settings.
Your code should have something similar to this:
// Select camera model
//#define CAMERA_MODEL_WROVER_KIT
#define CAMERA_MODEL_ESP_EYE
//#define CAMERA_MODEL_M5STACK_PSRAM
//#define CAMERA_MODEL_M5STACK_WIDE
//#define CAMERA_MODEL_AI_THINKER

Now try to comment out the third line, and uncomment the last one. Probably it would help.

Whatever code you have on the ESP32 is looking for a camera. That camera can't be found - is it attached? Did you install the code? Did it come with the code pre-installed? If you installed the code, what code is it? If you didn't install the code yourself, maybe you want to write some new code to get the ESP32 to do what you want it to do.


text:
converting character to strings in transmitter and receiver Arduino
I am using transmitter and receiver but I want to change the data type from character to int
receiver code
#include <RH_ASK.h>//include radioHead ASK library
#include <SPI.h> // include dependant SPI libray

 RH_ASK rf_driver; // create ASK object
int ledon = 13;
String userid;
String password;
 //RH_ASK ID1; // create ASK object
//RH_ASK pass1; // create ASK object

void setup() {

  rf_driver.init(); //initialize ASK object

  Serial.begin(9600); //setup serial monitor to 9600

  //if(!rf_driver.init())
       //Serial.print("init failed");
}

void loop() {

  // set buffer to size of expected message
  uint8_t buf[9];
  uint8_t buflen =sizeof(buf);

  //check if recevied packet is correct size
  if (rf_driver.recv(buf,&buflen))
  {
    int i;
    // message received with valid checksum
    Serial.print("id: ");
    Serial.println((char*)buf);
      userid =(char*)buf;
        Serial.println(userid);

  }

delay(5000);

   uint8_t buf2[8];
  uint8_t buflen2 = sizeof(buf2);

   if (rf_driver.recv(buf,&buflen))

  {

    int i;
    // message received with valid checksum
    Serial.print("password: ");
    Serial.println((char*)buf);
      password = (char*)buf;
      Serial.println(password);

  }
  delay(5000);

transmitter code
//Include RadioHead Amplitidue shift keying library
#include <RH_ASK.h>
// Include dependatnt ISP library
#include <SPI.h>

//create Ampitude shift keying object
RH_ASK rf_driver;

void setup() {
 // intialize ASK objct
rf_driver.init();

Serial.begin(9600);

  //if(!rf_driver.init())
      //Serial.print("init failed");

}

void loop()
{

  const char *pass= "123456789";
rf_driver.send((uint8_t *)pass, strlen(pass));
rf_driver.waitPacketSent();
delay(5000);

const char *ID= "A00034732";

rf_driver.send((uint8_t *)ID, strlen(ID));
rf_driver.waitPacketSent();
delay(5000);

The title and the text in the answer do not ask the same. What do you want to do? char to num or char to string? And the code is very bad formatted. I also don't see a variable (content) of the transmitter that can be converted or is password always a number? So what do you mean exactly?

If ID is a HEX value then it is too long for an int.

What exactly do you want to convert to a number, and why do you think that converting it to a number is a good idea?

You have to properly understand what you are trying to do. (It looks like) you have a decimal representation of a number, encoded as a string of characters. "12345" is not a number but a series of characters. (Technically each character is a number with a certain ASCII value, the digit "1" has ASCII value 49 for instance.)
To convert "12345" into the number 12345, the CPU needs to take each character, find its digit value, multiply it by the correct power of 10 and add it to all the others. There are a few built-in ways that do this for you. The easiest is the atoi() function, e.g.
int x = atoi("150");

In your case, try this:
int userid = atoi((char *) buf);

Serial.println(userid);

Note that an int on an Uno is only 16 bits, thus atoi() is only good for numbers within [−32,768, +32,767].


text:
How to communicate with arduino uno when arduino motor shield connected to arduino uno?
I'm using this Dual Motor Shield

when I plug Arduino Dual Motor Shield into Aruino uno can't seen any way to communicate with Adruino uno.how can I communicate with uno ?

What "communication" are you talking about? Do you mean "plug wires into D0-D13, A0-A5 pins of the Arduino UNO (in this case that would not be called communication) or USB communication to your PC, or ICSP communication with a programmer?

plug wires into D0-D13

Communicate with what? A PC? The usb serial port should still work fine, and anything connected to the RX/tx pins (D0 and  D1)
If your concern is that there is no longer a socket on the top of this shield that you can plug wires into, well you can solder on some wires to the top of the board, or you could get a screw shield board to go between the arduino and motor shield which would make all the pins available. I have also use small gauage wire wrapped around the shield pins and then just insert the shield onto the arduino making kind of a wire wrap connection between the boards.

i need to plug wires into D0-D13

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

authors: สาโรจน์ เกตุสมบัติ


text:
Arduino UNO voltage supply reduces when I add more sensors
I have an Arduino UNO. When I connect an MQ-9 sensor or an ESP8266MOD WiFi chip, the LCD backlight drops that it doesn't display anything, the red LEDs on the Arduino board dims, and the voltage regulator begins to get hot.
I am using a 12V -- 1.5A DC supply to power the Arduino as the USB port only works for uploading sketches, it doesn't even power the Arduino when nothing is connected. What could be wrong?
NOTE: When I unplug the gas sensor, the Arduino board LEDs get brighter and the LCD too, it works fine with some other sensors like an LM35 or a flame sensor.

You are overloading the Arduinos voltage regulator.
The Arduino uses a linear voltage regulator, which dissipates the excess voltages as heat.The higher the provided voltage, the lesser current you can draw from it (since it can only handle a specific power dissipation without a heatsink and power is voltage * current). If you have a genuine Arduino, the voltage regulator will go into thermal emergency shutdown, if you completely overload it. Most Arduino clones use a cheaper regulator, which will just burn out and possibly destroy the Arduino.
So if you require quite an amount of current (like the MQ-9 due to its heating element), you should buy an extra voltage regulator, in best case a switching "buck" regulator (since they are way more efficient than linear regulators). For example there are many rather cheap boards with a switching regulator, which take 12V and output a variable voltage controlled via a small potentiometer (which you can trim for 5V output).

the USB port only works for uploading sketches, it doesn't even power the arduino when nothing is connected.

Then most likely you have already overloaded the diode, that is in the USB power path (for protecting the PCs USB port and helping with supply voltage selection). If the diode were fried and failed open, then the connection from USB positive power to 5V rail on the Arduino is no longer there. A genuine Arduino Uno should also have a polyfuse in the USB line, which can save you from drawing too much current. It should connect again, after you removed the devices, that draw too much power.

Note that the Arduino Uno Rev 3 does not have a protection diode in the path of the USB, only a polyfuse and a mosfet controlled by an op-amp, which activates the mosfet if VIN is below 7V

The MQ-9 has a heating preparation cycle that draws more than a third of a watt which is more power than the Arduino can supply via a pin if I remember correctly. Have you taken that into allowance? You can design the heater power to be triggered by the Arduino without overloading the pin (e.g, using a transistor).
See https://electronics.stackexchange.com/questions/67092/how-much-current-can-i-draw-from-the-arduinos-pins
If your circuit already allows for the above it could also be a bad/shorted sensor? You could test it’s resistance with a multimeter and compare it to the data sheet.

I guess OP uses a sensor module which is powered from 5 V pin

I think your guess is right. Chrisl’s is a much better answer.

You are using a lot more power than an arduino pin can supply. The gas sensor takes a lot of power which the arduino's pin supply of 5v and 200mA MAX cannot tolerate. So I would suggest you power the gas sensor using ur 12v Powersupply by creating a simple potential divider, using a buck converter or simply one of those cheap 7805 regulators. For any other power related queries you can refer this excellent article by BILL from Dronebot Workshop. Good Luck!!


text:
Arduino and fingerprint scanner - can I get the fingerprint scanner data?
I am currently planning a thesis that involve scanning fingerprints and storing the data in a database. The problem is that I do not know if it is possible for me/us to get the fingerprint data or variables scanned by the fingerprint scanner.
I tried searching on google, of course, but I don't see any information on how to display the data in a form such as binary.  I'm not sure if I can extract the data from the Arduino then store it in a website/database (---which to be fair, since fingerprints can be confidential, I understand if some articles don't provide a sample.)
Is it possible to get and extract the fingerprint scan data? For example, converting the scanned data in to a binary representation (011010101 etc.)

What is the fingerprint scanner you are using? Of course it is possible to get fingerprint data since that's what the scanner is doing. It just might not give you the data if it's designed to be used as a pass/fail kind of device. Fingerprints are hardly confidential, you can record one with a camera or just a drop of wet ink.

I have 3 Products in my choices: AS608, R307  and this one
(https://shopee.ph/Fingerprint-Scanner-Reader-Sensor-i.18252381.1243862326?position=4&hybrid_pc=1&stm_referrer=https%3A%2F%2Fshopee.ph%2Fsearch%3Fkeyword%3Dfingerprint%2520arduino) sorry this one didnt write the product type.
i wonder what are suitable for the thing im looking for?

I'm a software engineer that works with biometric sensors. The answer is, it will vary greatly depending on the scanner you've chosen. Some hardware solutions have built-in subject enrollment and database matching; some simply collect an image and return it in an appropriate format- sometimes an image file (e.g. PNG), or a template file (a binary representation of a subject and/or their fingerprint(s)).
For you, I highly recommend avoiding the pain of interfacing with an Arduino at such a low level, and use a Raspberry Pi or other full computer to write a collection program with your vendor's SDK. Linux is supported by all the major players I've worked with, and that will drastically ease integration with whatever database or website you have in mind. Many vendors have built-in enrollment, storage, and matching examples as part of their SDKs that will help you get up and going in short order
EDIT: As this is an Arduino SE, I realize I should give a microcontroller-friendly answer as well. There are indeed scanners like this. It does templating and matching on board if I understand correctly, and the provided library does indeed allow you to transfer those templates over serial. Granted, you still have to get that data from your Arduino to a computer of some sort, so I still think a Pi is the shorter putt ;)

highly appreciated!
regarding to "some simply collect an image and return it in an appropriate format- sometimes an image file (e.g. PNG), or a template file (a binary representation of a subject and/or their fingerprint(s))." does the "template file" is literally different to each other. like my thumb left will have different template to right thumb? sorry i dont have Fingerprint scanner yet(but just like the sample, im planning to buy one like that). im curious a bit

If I understand what you are asking, yes, those two template files will be unique. As a matter of fact, even if you scan the same finger twice, the two resulting templates will be unique, like taking a picture of the same thing twice will make two slightly different pictures- it's up to the matcher to tell you if the two prints are "close enough" to be considered a match. How close is "close enough" will vary based on your desired false-positive and false-negative rates

It is also worth noting that "template" is a general term that means "a data representation of a fingerprint," and not a standardized file/data format. Each vendor has its own proprietary template format. If you don't mind me asking, what is your thesis trying to show, exactly?

in my thesis im planning to make. simply taking the template of the fingerprint. basically it is like a "registration system" similar to School Attendance System but unlike the regular thing you can see in youtube tutorial for beginners, what we are planning is to take the scanned fingerprint then convert it a template then store it online/database.
so for example, when a person is suspected for a crime. we can re-enter the fingerprint then determine it by matching the fingerprint.

but actually, the first pharagraph is the main objective. making a Matching System is not part of our scope but we would consider it since our Panelist/professor may question the quality of our way of getting fingerprint.

Sounds cool! Best of luck!

@DreacLeoson If this has helped you, can you mark it as the Accepted Answer? Much appreciated :)

There is a discussion thread on Quora discussing finger print scanners that provide raw output. The Quora author recommends a  Futronic device which comes with an API for raw image collection. They also discussed NeuroTechnology which apparently also has a downloadable image database. Looking at the neurotechnology website they also have some interesting SDK options. These of course all give you an image not the binary output you described.
It strikes me that a binary encoded output would likely be the result of a recognition algorithm, or a resultant / generated security key. Not sure that is what you intended by your question?
There are a mass of academic papers on open finger print scanning algorithms.
I did a bit of google searching for people capturing raw data from Arduino compatible devices. Didn’t find anyone saying it was easy. Please post back here if you make progress.
Hope this helps get you started.

Those information were so useful. thank you so much!

the "binary" thing is simple example of how can i convert it to a data since im not sure of how the data will be converted aside from .bmp. im not entirely hoping if i can convert it to Binary(but if it is possible, ill gladly to know/try)

You’re welcome @DreacLeoson. Remember to please  upvote the responses you find useful, and mark if a response answers your question ( I could use the reputation points :-)

will do. alhough i need more 15 reputation or higher. still, im going back here to report my progress. this is a good information actually!

So I upvoted your question, not only for the reputation, I
also find the subject interesting and thanks to Rowap for excellent research.

Echoing my comment on SO with more information:
Commercial fingerprint sensors like this one do local store and compare and do not expose the actual image or binary signature. What they transmit to the microcontroller are ID's and match success.
If you need the binary data of the image itself you may be able to write your own image processing algorithm, perhaps using machine learning, and use a simple video camera connected to a microcontroller that in turn will send the captured image to your web server for processing.
Arduino can be programmed to capture still images and transfer a bitmap file to a server, such devices (microcontroller and cameras) are widely available.

ahhh. thank you so much for your service. my bad this is just a copy paste from SO but still, thank you for directing me here. i thought Arduino Forum is the only existing QandA website for this. thank you so much!


text:
Find number of RX and TX-pin on ArduiMu
I've got an Arduino V3+ and need to find the correct PIN number for its RX and TX-pin on the FTDI-connector.
How can I find out the correct number of them to use them with the SoftwareSerial-library?
Why I need these numbers:
I'm connecting a Sparkfun Bluetooth Mate/BlueSMIRF to the ArduiMUs FTDI headers and need to set a few settings in its command mode before it operates without flaws.
This is the code I'm using:
#include <SoftwareSerial.h>

int bluetoothTx = ???;  // TX-O pin of bluetooth mate, Arduino D2
int bluetoothRx = ???;  // RX-I pin of bluetooth mate, Arduino D3
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup()
{
  Serial.begin(9600);  // Begin the serial monitor at 9600bps

  bluetooth.begin(115200);  // The Bluetooth Mate defaults to 115200bps
  bluetooth.print("$$$");  // Enter command mode
  delay(5000);  // Short delay, wait for the Mate to send back CMD
  bluetooth.println("U,9600,N");  // Temporarily Change the baudrate to 9600, no parity
  // 115200 can be too fast at times for NewSoftSerial to relay the data reliably
  bluetooth.begin(9600);  // Start bluetooth serial at 9600
}

You can use FTDI cable with your board on the last row of pads as you have highlighted.
Unfortunately your board designers do not publish a pdf version of the schematic so I opened the provided schematics in EAGLE and exported the FTDI connector diagram.
Here is the FTDI connector connections from the schematic:

Here is the pinout of the FTDI cable

So you can solder a 6 pin header on the bottom row and use the standard FTDI cable.
The FTDI row on your board indicates "BLK" on the left so orient your FTDI connector's black wire with the "BLK" pad on your board.
EDIT:
As per your edits you are using hardware serial on your arduino board to monitor and you are using one instance of "SoftwareSerial" to interface with bluetooth.
As SoftwareSerial library says, you can define any digital pins for Tx and Rx. In the example they have used Arduino pins 10 (pin 14 of the ATMEGA) and 11 (pin 15 of ATMEGA) for Rx and Tx respectively. In your non-standard arduino board, the micro-controller pin 14 is labeled as PWM1 and pin 15 is labeled as MOSI and they are brought out on connector JP7.

So in a nutshell you can use pin 4 of JP7 as SoftRx and pin 5 of JP7 as SoftTx.
If those pins are in use, you can always use other digital pins that are unused in your design. Just refer to the schematic of your board, ATMEGA328 datasheet and arduino libraries.

Thanks for your effort. I'm already using a FTDI cable to put Arduino Software on it. I need to know to RX & TX pin mumber because I connect a  Bluetooth module (FTDI compatible) and need to send a few messages to it (it is a Bluetooth Mate Silver and has a command mode). I need the pin numbers to communicate via ArduiMu with the Bluetooth module.

@Hedge pin number of what? ATMEGA device? pin number of board? pin number of FTDI cable? Please clarify your question. Thanks.

Sorry for the confusion. I need the PIN number of the RX and TX pin on the Arduino board to write to the TX channel and receive data from the RX channel of the ArduiMU overall. The SoftwareSerial-library needs the port numbers of them to operate SoftwareSerial mySerial(10, 11); // RX, TX

I added the code I need the PIN-numbers for to the original question. You should be able to  better understand what I'm trying to do.

@Hedge now I understand that you are using the main ftdi port to monitor and want to use another serial port for bluetooth. Is that correct?

If the bluetooth-device would accept data sending through the default Serial-port Serial.print("$$$"); it would be good enough too but it doesn't seem to work. I would prefer it this way since Bluetooth Mate and ArduiMU have 6 matching pins and therefore i can plug the Bluetooth Mate directly in the ArduiMU.

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


text:
Is there any way that the values here be converted to another variable and not string?
int val1 =(mfrc522.uid.uidByte[0]);
int val2 =(mfrc522.uid.uidByte[1]);
int val3 =(mfrc522.uid.uidByte[2]);
int val4 =(mfrc522.uid.uidByte[3]);

String valA=String(val1);
String valB=String(val2);
String valC=String(val3);
String valD=String(val4);
uID=valA+valB+valC+valD;

The function above with mfrc522.uid.uidByte[x] is from the MFRC522.h Library by Miguel Balboa and it is initialized as byte there. But when I initialize the val1 to val4 as byte, the desired number doesn't appear. I don't intend to print the uID to serial (as someone may suggest that to readily print to serial as it converts it automatically to some ASCII strings), but instead in the client.print() of the Ethernet library along with other codes. I want to save it into another "greater" variable in terms of speed and memory allocation. The Arduino community warns about the use of String as it uses additional decoding which is not needed as well as may crash Arduino and make Arduino run out of memory. And somehow, I experience some lagging or hanging in the serial, which I thought maybe due to the use of Strings variable. Please help me. I've read some sprintf() concatenations and free() but not well documented, I'm quite confused on their explanations. :)

It sounds like you want to print the UID to serial. Have you tried using "mfrc522.PICC_DumpToSerial(mfrc522.uid);" ?

sprintf() is a nicer way to do that (imo), however, there's nothing wrong with what you've done-- if you don't have a ton more code, I'd continue to use it.
It's simple and that's a lot more important that speed most of the time. Also, the likely memory usage isn't enough to worry about.
In my experience, once I got past 1500 bytes SRAM (dynamic) memory usage, I ran into trouble. But my projects have a ton of code. I've read through the String class code and it's totally reasonable-- you're not likely to experience lag there.
My bet is that the lag is due to the timeout period, try making it smaller.

The UidByte[] is a 10 character array, loaded with the tag ID (this is an RFID reader) by the library.
Your code is attempting to put a character value into integer variables.
What you mean to do (I think) is to read the string as a number - this would be val=atoi(mfrc522.uid.uidByte) which relies on there being only numeric data in the ID string - or at least, will only read the leading numbers (if any). Also, there are 10 characters in the string - if you want to limit this to 4 you will need slightly more code.
If you have a tag on which you set the ID then this is usable, for your tags at least; but you can't rely on numeric uid's being universal.
If your intent is, as you say, to include it in a longer string, then the overhead of atoi is completely unnecessary and you should just handle it as a string. I think you have misunderstood the warnings about strings, there isn't a problem just handling short chunks of fixed-length data as strings, and I think you are inadvertently causing trouble by extra conversions.

The poster's concerns are based in real issues with dynamic memory allocation on small systems, and while they may not occur here is what could hopefully turn out to be a reuse-in-place allocation case, it is also not necessary to allocate a bunch of dynamic Strings to accomplish this goal at all.  If the size of the intended result is known or reasonably bounded, byte/character values can be directly written to appropriate positions in a C string.


text:
Arduino Software serial not showing the received data

I get the data from a sensor which is in RS485. I am using RS485-RS232 Converter. Then its given to uart usb converter and I get the data in TTL. I am able to receive the data in uart (hyperterminal). I have connected the TX, RX, GND pins to 10, 11, GND pins of Arduino UNO.
I want to communicate it with Arduino UNO through SoftSerial and here is the code
#include <SoftwareSerial.h>
#define rxPin 10
#define txPin 11

SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);

void setup() {
    pinMode(rxPin, INPUT);
    pinMode(txPin, OUTPUT);
    mySerial.begin(9600);
    Serial.begin(9600);
}

void loop()
{
    while (mySerial.available() > 0) {
        Serial.println("Data is available");
        Serial.println(mySerial.read());
    }
}

But I'm not able to see the data on serial monitor.

After converting it to RS232, its given to uart converter where i get data in TTL - please edit your post to show your wiring.

Also please show what these mysterious converters are that you have used. Model numbers, connector types, etc.

The phrase "given to uart usb converter" immediately rings alarm bells to me - is this something that you plug into a USB port, and you are now trying to connect it to a TTL UART input?

Did you reverse tx and rx pins?

Majenko...Its an nT RS422 to RS232 converter.After that its connected to UART USB   converter which has max3233. I'm getting data properly at hyper terminal. Then  i have connected RX TX pins of it  to TX RX of microcontroller. But not able get the output.

Yes i have reversed the RX TX pins @Visual Micro

Confirm each step. Do you have data when going directly from 485 to 232 into Hyperterminal?  Do you have communication between Arduino and Hyperterminal without the extra software serial stuff? If you do then it's probably something to do with how its pulling data from your software serial and sending it to the Serial.println(). Try using mySerial.readline() or change the Serial.println(mySerial.read()) to Serial.print(mySerial.read()).

Remove setting the pinMode(). Note required for SoftwareSerial

Yes i have data from 485 to 232 to Hyperterminal and o checked in hyperterminal also. Communication between Arduino and Hyperterminal is not happening. Only if i press RESET button once, i am able to get one data. If i press RESET many times then data is displayed on serial monitor. And data is displayed properly on Serial Monitor if i remove the microcontroller (ATMEGA328). So i thought of using Software Serial. @ChefFlambe

Okay @VisualMicro

Still not getting output. Don't know what is wrong

Is your end goal to have the Arduino act only as a bridge to a PC for sensor data?

No it not like that. I want to manipulate the data coming from sensor using Arduino and then store it onto SD Card. Its kind of a datalogger  @Chef Flambe

Voting to close as this question was abandoned in unanswerable form over a year ago.

I had a problem similar to yours recently.
The thing that got me was that the RS232 from the Arduino is reverse. This is because it would usually go through a RS232 IC that produces +12 and -12 signals.
A sensor or RS232 backpack on a LCD cannot deal with the reverse signals.
The SoftwareSerial library has an undocumented feature that will reverse the RS232 output for you.
When you configure your interface do the following:
SoftwareSerial mySerial(3, 2, true);

The true option instructs the library to reverse the RS232 signals.
Hope this helps you out since this post was a long time ago.

While occasionally useful, this overlooks the dangerous issue that even apart from the inversion, the Arduino cannot safely handle RS232 levels.  Pretty much every level shifter intended for RS232 is an inverting level shifter - so this issue basically only comes up with homegrown minimalist implementations, and would not be expected to occur with the MAX3233 the poster says they are using.


text:
lcd.print then dataFile.print
My program is a bit large and I'm worried about stability.
I need to print data to both a file and to my LCD. It's like this:
if (hour<10) {
    dataFile.print("0");
}
dataFile.print(hour, DEC);
dataFile.print(":");
if (minute<10) {
    dataFile.print("0");
}
dataFile.print(minute, DEC);
dataFile.print(":");
if (second<10) {
    dataFile.print("0");
}

Then
if (hour<10) {
    lcd.print("0");
}
lcd.print(hour, DEC);
lcd.print(":");
if (minute<10) {
    lcd.print("0");
}
lcd.print(minute, DEC);
lcd.print(":");
if (second<10) {
    lcd.print("0");
}

What is a smart way to make this shorter? Should I write a function to add the leading zero then another that does something like:
void printboth (thing) {
    dataFile.print(thing);
    lcd.print(thing);
}

good idea?

possible duplicate of What will use less memory, an array or if ... else?

You asked an almost identical question here: http://arduino.stackexchange.com/questions/13876/what-will-use-less-memory-an-array-or-if-else where you start: I'm trying to make my sketch smaller.  Please stick to one question for one topic to avoid splitting answers.

Give __attribute__((always_inline)) void printboth (thing) a try and see if it results in a smaller size. PS make sure you are using the latest version of the Arduino IDE.

You could format the data with snprintf:
char timestamp[9];
snprintf(timestamp, 9, "%02d:%02d:%02d", hour, minute, second);
dataFile.print(timestamp);
lcd.print(timestamp);

%02d in the snprintf format means "print at least 2 digits of this value and pad with leading zeros".

While true, note that *printf() will increase code size a lot.

Define "a lot".  I make it an increase of 1046 bytes and the program is far more readable.

I'm making changes with the main goal of making the sketch smaller


text:
Ethernet shield not have MAC address sticker
Hi everyone I recently bought an Arduino Mega and Arduino Ethernet Shield. There are lots of forum posts that say the shield should have a MAC address that is written on the back side of shield, but I don't have any sticker which has the MAC address. Does anyone know how I can get my MAC address or configure it with a new MAC address? Thanks

You can set the MAC address to whatever you want. See the above question that yeti mentions.

According to this documentation, you can just provide your own.

mac: the MAC (Media access control) address for the device (array of 6 bytes). this is the Ethernet hardware address of your shield. Newer Arduino Ethernet Shields include a sticker with the device's MAC address. For older shields, choose your own.

YES... you can define a MAC yourself. If you want to do it right, read a bit about MACs, especially the LAA-bit and how not to specify a broadcast address...


text:
What are the distances between Arduino Mega connectors?
I am trying to build an Arduino Mega shield. For that, I need to know the exact distances between the different connectors.

Why not start with an EDA file that already contains the connectors?

The pin layout and dimensions of the Mega are as follows:

Dimensions are in thousandths of an inch. Source


text:
ATtiny85 communication with computer through USB
I am trying to receive and send some data from a computer to an ATtiny through USB. Can an ATtiny85 IC communicate with a computer through USB? If yes, how should it be connected?

The answers don't seem to address the core question. I believe he is asking how to communicate with a computer over the USB port AFTER burning the code. The answers talk about connecting seemingly for the purpose of programming and developing and loading any program. The question is, how do you communicate with a host PC over USB FROM the attiny with your own code? I have the same question. Paul

Digispark made a lot of these as part of a "cheap Arduino USB interface" project a while back.
This is my Digispark, it's pretty cute:

They have a web page here.

I got them for about $2 each. The board has the ATtiny85, a voltage regulator, and a handful of other parts.
Schematic (courtesy of Digistump Wiki):

More information about the Virtual USB idea at USB-Keyboard with Arduino and V-USB library, an example.

If someone is wondering if you can use SPI devices with it due to the low amount of pins, the answer is yes, you can.

Can an ATtiny85 ic communicate with a computer through USB?if yes,how should be the connection?

Have you checked the web? There are many such projects. Here is a link to one:
http://www.instructables.com/id/Digispark-DIY-The-smallest-USB-Arduino/
Please remember "Google is your friend".
Cheers!

Nooo... not Google... Marjory!!!

Whatever make you happy - "Google == Web search tool of your liking" :)

The Digispark (of which I bought a few) works quite well. It is based on the "Virtual USB" (V-USB) concept which you can find with a *ahem* search-engine-of-your-choice search.

@MikaelPatel Could you please highlight the most important parts of the content you linked? It's currently very much link-only answer.

@Avamander Please see the schematics provided below by Nick. That should answer all your questions about how to connect the ATtiny85 to USB.

After much searching the best I've found is a lot of examples where the Digispark emulates a keyboard or mouse, so one crude way to read data is to output it as keystrokes, then make sure you have Notepad open to capture the keystrokes when you plug the Digispark in.
There did appear to be a CDC library that might have been usable at some time but as I understand it Windows 10 doesn't recognise it, though Linux might.
The explanation I saw was that the Digispark is a Low speed USB device, and by the USB specification low speed devices are only allowed to implement HID (keyboard, mouse) and not CDC though some operating systems may ignore this.
It ought to be possible to set the Digispark up as a HID device with no functions and then communicate with its endpoint directly, but I have not found a working demo of this although I suspect this is how the bootloader communicates.


text:
Interrupt variable not getting called while executing another part
volatile byte _incomingFlag = 0;

void onIncoming () {
    _incomingFlag = 1;
    Serial.println(F("You got an interrupt"));
    mySerial.println("ATH0");
}

void setup () {
    /* First Start the module */
    Serial.begin(9600);
    Serial.println(F("Initializing module..."));

    powerOn();

    mySerial.begin(9600);

    sendcommand(F("AT"), F("OK"), 1000);
    sendcommand(F("AT+CLIP=1"), F("OK"), 1000);
    sendcommand(F("AT+CMGF=1"), F("OK"), 1000);

    /* We need to attach ringing Interrupt */
    attachInterrupt(M_RING_INTERRUPT, onIncoming, FALLING);

    delay(100);
}

void loop() {
    if (_incomingFlag == 1) {
        manageIncoming();
        Serial.print(F("_incomingFlag: "));
        Serial.println(_incomingFlag);
    } else  {
        Serial.println(_incomingFlag);
        Serial.println(F("not getting value"));
    }
    get_currentLocation();
    send_Location();
}

I am trying to check the value of incomingFlag from the loop() . When I get a call or an SMS the interrupt function is getting executed and incomingFlag is set to 1 but I am not getting that value from the loop(). Everytime it's getting 0 if I check the value while the send_Location function is executing (data uploading part). How can I access the value of incomingFlag from the main loop().

Using serial inside an interrupt is not advisable. Especially if you talk to the GSM module inside an ISR. The rest of the code looks fine, though I'd like the see the send_Location function.

Hi Gerben, thanks for your reply. Please see my send_Location function and that serial functions inside interrupt is just for testing purpose.

I cannot see your send_Location function personally, because you did not post it.

do not use leading underscores in symbol names.  that can confuse the compiler, which uses 1 or 2 leading underscores for special purposes.

where does the code reset the _incomming_flag to 0 after finding the flag ==1?    Never call any kind of print operation from within a interrupt.   Where is the code resetting the 'interrupt pending' bit for that interrupt?

Interrupt flag bits are automatically cleared upon entering the corresponding ISR. I agree about the underscore. Leading underscores in variable names in global namespace are reserved by the Standard. Each name that begins with an underscore is reserved to the implementation for use as a name in the global namespace.

volatile byte _incomingFlag = 0;
 void onIncoming () {
             _incomingFlag = 1;
            Serial.println(F("You got an interrupt"));
            mySerial.println("ATH0");

        }

Regardless of what your purpose is there, you cannot successfully do serial prints inside an ISR. All bets are off if you do that.
In fact you are doing two prints - is one SoftwareSerial?
If you must have a debugging "flag" turn on an LED. Doing serial printing requires interrupts to be on, and they are off inside an ISR.

Note: You may get the display once, and therefore you think it works. As soon as the serial buffer fills up (probably 64 bytes) then it will just block indefinitely. Your message "You got an interrupt" is already 22 bytes if you count the trailing carriage-return/linefeed.

More detailed explanation
In your main loop, every time through it, you are printing either:
_incomingFlag: 1

or
0
not getting value

Therefore the serial buffer will be definitely full (or almost full). It can't empty the buffer if you are cramming this stuff into it every time through loop.
So now you have an incoming call. You set _incomingFlag to 1, then try to do this:
    Serial.println(F("You got an interrupt"));

That blocks, because if can't fit all that into the output buffer, and the program then hangs, because the buffer is not emptied inside an ISR.