text:
After restoring the BNO055 offsets to the sensor the calibration values are all 0
Board: ESP32
Script: restore_offsets.ino from Adafruit's BNO055 library
The only difference is I am storing the information in ESP's NVS using the Preferences Library
Code
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
#include <Preferences.h>

/* Set the delay between fresh samples */
#define BNO055_SAMPLERATE_DELAY_MS (1000)

Adafruit_BNO055 bno = Adafruit_BNO055(1390);

Preferences Calibration;

/**************************************************************************/
/*
    Display some basic info about the sensor status
    */
/**************************************************************************/
void displaySensorStatus(void)
{
    /* Get the system status values (mostly for debugging purposes) */
    uint8_t system_status, self_test_results, system_error;
    system_status = self_test_results = system_error = 0;
    bno.getSystemStatus(&system_status, &self_test_results, &system_error);

    /* Display the results in the Serial Monitor */
    Serial.println("");
    Serial.print("System Status: 0x");
    Serial.println(system_status, HEX);
    Serial.print("Self Test:     0x");
    Serial.println(self_test_results, HEX);
    Serial.print("System Error:  0x");
    Serial.println(system_error, HEX);
    Serial.println("");
    delay(500);
}

/**************************************************************************/
/*
    Display sensor calibration status
    */
/**************************************************************************/
void displayCalStatus(void)
{
    /* Get the four calibration values (0..3) */
    /* Any sensor data reporting 0 should be ignored, */
    /* 3 means 'fully calibrated" */
    uint8_t system, gyro, accel, mag;
    system = gyro = accel = mag = 0;
    bno.getCalibration(&system, &gyro, &accel, &mag);

    /* The data should be ignored until the system calibration is > 0 */
    Serial.print("\t");
    if (!system)
    {
        Serial.print("! ");
    }

    /* Display the individual values */
    Serial.print("Sys:");
    Serial.print(system, DEC);
    Serial.print(" G:");
    Serial.print(gyro, DEC);
    Serial.print(" A:");
    Serial.print(accel, DEC);
    Serial.print(" M:");
    Serial.print(mag, DEC);
}

/**************************************************************************/
/*
    Display the raw calibration offset and radius data
    */
/**************************************************************************/
void displaySensorOffsets(const adafruit_bno055_offsets_t &calibData)
{
    Serial.print("Accelerometer: ");
    Serial.print(calibData.accel_offset_x); Serial.print(" ");
    Serial.print(calibData.accel_offset_y); Serial.print(" ");
    Serial.print(calibData.accel_offset_z); Serial.print(" ");

    Serial.print("\nGyro: ");
    Serial.print(calibData.gyro_offset_x); Serial.print(" ");
    Serial.print(calibData.gyro_offset_y); Serial.print(" ");
    Serial.print(calibData.gyro_offset_z); Serial.print(" ");

    Serial.print("\nMag: ");
    Serial.print(calibData.mag_offset_x); Serial.print(" ");
    Serial.print(calibData.mag_offset_y); Serial.print(" ");
    Serial.print(calibData.mag_offset_z); Serial.print(" ");

    Serial.print("\nAccel Radius: ");
    Serial.print(calibData.accel_radius);

    Serial.print("\nMag Radius: ");
    Serial.print(calibData.mag_radius);
}

/**************************************************************************/
/*
    Arduino setup function (automatically called at startup)
    */
/**************************************************************************/
void setup(void)
{
    Wire.begin(13, 16, 400000);
    Serial.begin(115200);
    delay(1000);
    Serial.println("Orientation Sensor Test"); Serial.println("");

    /* Initialise the sensor */
    if (!bno.begin())
    {
        /* There was a problem detecting the BNO055 ... check your connections */
        Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
        while (1);
    }

    Calibration.begin("offsets", false);
    adafruit_bno055_offsets_t calibrationData;
    sensor_t sensor;

    int32_t bnoID = Calibration.getInt("bnoID");
     bool foundCalib = false;
    /*
    *  Look for the sensor's unique ID at the beginning oF EEPROM.
    *  This isn't foolproof, but it's better than nothing.
    */
    bno.getSensor(&sensor);
    if (bnoID != sensor.sensor_id)
    {
        Serial.println("\nNo Calibration Data for this sensor exists in NVS");
        delay(500);
    }
    else
    {
        Serial.println("\nFound Calibration for this sensor in NVS.");

        // Accelerometer offsets
        calibrationData.accel_offset_x = Calibration.getInt("acc_off_x");
        calibrationData.accel_offset_y = Calibration.getInt("acc_off_y");
        calibrationData.accel_offset_z = Calibration.getInt("acc_off_z");

        // Gyroscrope offsets
        calibrationData.gyro_offset_x = Calibration.getInt("gyr_off_x");
        calibrationData.gyro_offset_y = Calibration.getInt("gyr_off_y");
        calibrationData.gyro_offset_z = Calibration.getInt("gyr_off_z");

        // Magnetometer offsets
        calibrationData.mag_offset_x = Calibration.getInt("mag_off_x");
        calibrationData.mag_offset_y = Calibration.getInt("mag_off_y");
        calibrationData.mag_offset_z = Calibration.getInt("mag_off_z");

        displaySensorOffsets(calibrationData);

        Serial.println("\n\nRestoring Calibration data to the BNO055...");
        bno.setSensorOffsets(calibrationData);

        Serial.println("\n\nCalibration data loaded into BNO055");
        foundCalib = true;
    }

    delay(1000);

    /* Display some basic information on this sensor */
//    displaySensorDetails();

    /* Optional: Display current status */
    displaySensorStatus();

   //Crystal must be configured AFTER loading calibration data into BNO055.
    bno.setExtCrystalUse(true);

    sensors_event_t event;
    bno.getEvent(&event);
    if (foundCalib){
        Serial.println("Move sensor slightly to calibrate magnetometers");
        while (!bno.isFullyCalibrated())
        {
            bno.getEvent(&event);
            displayCalStatus();
            Serial.println("");
            delay(BNO055_SAMPLERATE_DELAY_MS);
        }
    }
    else
    {
        Serial.println("Please Calibrate Sensor: ");
        while (!bno.isFullyCalibrated())
        {
            bno.getEvent(&event);

            Serial.print("X: ");
            Serial.print(event.orientation.x, 4);
            Serial.print("\tY: ");
            Serial.print(event.orientation.y, 4);
            Serial.print("\tZ: ");
            Serial.print(event.orientation.z, 4);

            /* Optional: Display calibration status */
            displayCalStatus();

            /* New line for the next sample */
            Serial.println("");

            /* Wait the specified delay before requesting new data */
            delay(BNO055_SAMPLERATE_DELAY_MS);
        }
    }

    Serial.println("\nFully calibrated!");
    Serial.println("--------------------------------");
    Serial.println("Calibration Results: ");
    adafruit_bno055_offsets_t newCalib;
    bno.getSensorOffsets(newCalib);
    displaySensorOffsets(newCalib);

    Serial.println("\n\nStoring calibration data to NVS...");

    bno.getSensor(&sensor);
    bnoID = sensor.sensor_id;
    // enter the Sensor ID
    Calibration.putInt("bnoID", bnoID);

    // store new Accelerometer offsets
    Calibration.putInt("acc_off_x", newCalib.accel_offset_x);
    Calibration.putInt("acc_off_y", newCalib.accel_offset_y);
    Calibration.putInt("acc_off_z", newCalib.accel_offset_z);

    // store new Gyroscope offsets
    Calibration.putInt("gyr_off_x", newCalib.gyro_offset_x);
    Calibration.putInt("gyr_off_y", newCalib.gyro_offset_y);
    Calibration.putInt("gyr_off_z", newCalib.gyro_offset_z);

    // store new Magnetometer offsets
    Calibration.putInt("mag_off_x", newCalib.mag_offset_x);
    Calibration.putInt("mag_off_y", newCalib.mag_offset_y);
    Calibration.putInt("mag_off_z", newCalib.mag_offset_z);
    Serial.println("Data stored to NVS..");

    Serial.println("\n--------------------------------\n");
    delay(500);
}

void loop() {
    /* Get a new sensor event */
    sensors_event_t event;
    bno.getEvent(&event);

    /* Display the floating point data */
    Serial.print("X: ");
    Serial.print(event.orientation.x, 4);
    Serial.print("\tY: ");
    Serial.print(event.orientation.y, 4);
    Serial.print("\tZ: ");
    Serial.print(event.orientation.z, 4);

    /* Optional: Display calibration status */
    displayCalStatus();

    /* Optional: Display sensor status (debug only) */
    displaySensorStatus();

    /* New line for the next sample */
    Serial.println("");

    /* Wait the specified delay before requesting new data */
    delay(BNO055_SAMPLERATE_DELAY_MS);
}

The only difference in the code is instead of passing the offset struct I save information individually using putInt method
steps

I calibrate the sensor connected via I2C
Once the calibration is done store it into NVS
Observe values for a bit
Restart the node and retreive the offsets from NVS

Problem
The calibration offsets are stored into the BNO and it takes hella time in the following block:
   if (foundCalib){
        Serial.println("Move sensor slightly to calibrate magnetometers");
        while (!bno.isFullyCalibrated())
        {
            bno.getEvent(&event);
            displayCalStatus();
            Serial.println("");
            delay(BNO055_SAMPLERATE_DELAY_MS);
        }
    }

I added the displayCalStatus to see the values of the accelerometer, gyroscope and magnetometer and all values within the block are Zero.
Doesn't this defy the whole idea of storing offsets in the first place if the values are all zero?
Output from board
Found Calibration for this sensor in NVS.
Accelerometer: 19 -10 4
Gyro: -3 -4 9
Mag: 589 986 1473
Accel Radius: 0
Mag Radius: 0

Restoring Calibration data to the BNO055...

Calibration data loaded into BNO055

System Status: 0x0
Self Test:     0xF
System Error:  0x0

Move sensor slightly to calibrate magnetometers
    ! Sys:0 G:0 A:0 M:0
    ! Sys:0 G:0 A:0 M:0
    ! Sys:0 G:0 A:0 M:0
    ! Sys:0 G:3 A:0 M:0
    ! Sys:0 G:3 A:0 M:0
    ! Sys:0 G:3 A:0 M:0
    ! Sys:0 G:3 A:0 M:0
    ! Sys:0 G:3 A:0 M:0
    ! Sys:0 G:3 A:0 M:0
    ! Sys:0 G:3 A:0 M:0
    ! Sys:0 G:3 A:0 M:0
    ! Sys:0 G:3 A:0 M:0
    ! Sys:0 G:3 A:0 M:0
    ! Sys:0 G:3 A:0 M:0

As you can observe the calibration are all set to 0 and I have to do the whole thing again. why ?

Should we assume that there are non-zero calibration offsets that are returned, that they are correctly saved in NVS, and that they are correctly retrieved from NVS? Have you verified all of that, so that the only issue is that you are certain that you "saved" non-zero offests to the sensor and it's still returning zero offsets when read back?

I can assure you that the values are non-zero. I am pretty sure the values retreived are also non-zero from NVS. However I can perform tests again and edit the question with more concrete values to support the assumption.

I only ask because concrete values are the only way members of the community have to evaluate the problem.

I will get back at reproducing the query and edit the question with all relevant outputs from the node and bno055

@josecanuc I have added the log from my board

The displayCalStatus() function shows the status of the calibration, not the offsets or current sensor values. With calibration in progress the status is zero. Once the calibration of a sensor is complete, the status is 3. The sensor starts the calibration itself with first movements after power up.
The set offsets are used after power-up only until the initial automatic calibration finished.
from datasheet:

Once  the  device  is  calibrated,  the  calibration  profile  can  be  reused  to  get  the
  correct  orientation  data  immediately  after  ‘Power  of  Reset’.  However,  once  the  sensor  enters  the  internal
  calibration  routine,  the  calibration  profile  is  overwritten
  with  the  newly  obtained  sensor  offsets  and  sensor radius.

Is there way to avoid entering the internal calibration routine of the BNO055?

no. why is it a problem for you? it happens in the background. the sensors work all the time. the remembered offsets are good to have better values for first readings

The problem is that once the offsets are restored, I calibrate the magnetometer because it is very easy, but the while loop doesn't come out easily. I have to do all the calibration techniques all together.

but in your sketch you can do what you want. the offsets sketch is an example. I would ignore the calibration. The sensor handles it. After power-up make same movements and the sensor calibrates itself.

I think I will give give your stuff a try.


text:
Can now() roll over just like millis()?
I'm using now() and millis() to trigger events after a certain time has passed.
I am aware, and it's also easily found on the web, that millis() rolls over after a certain time has passed and for code that has to run indefinitely you have to handle this.
However I am not aware of if now() can do the same at some point. I mean it does count the seconds from the 1.1.1970 so just regarding this fact, it should not roll over. However, just like millis() this has to be counted somewhere no? How does it work?

What now() are you talking about? Could you give a reference?

@EdgarBonet probably https://www.arduino.cc/en/Reference/CurieTimeNow

he asks about Epoch seconds in Arduino, as used by the TimeLib

It may be worth noting that you don't necessarily have to "handle" millis() rollover; you just have to prepare your comparison correctly, and there is no rollover problem, as long as you are trying to compare durations smaller than the maximum millis() value.

If now() is from the TimeLib.h library, then this definition:
typedef unsigned long time_t;

indicates time_t is 32-bit unsigned value. Since it represents seconds since 1970-Jan-01 00:00:00, it will experience a rollover when representing dates past approximately 2106 (1970-Jan-01 + 2^32 seconds). Being unsigned, it also cannot represent dates earlier than 1970-Jan-01.
This is slightly different than the 2038 Rollover Problem, which occurs when a system defines a time_t as a signed 32-bit integer, and thus experiences this rollover earlier, in year 2038.
All of this depends on how/where the type time_t is defined for your CPU architecture, and this answer assumes an 8-bit AVR like Arduino Uno. If you use a different architecture, for which TimeLib.h has a different type definition, read the source code to find out exactly what you're dealing with.

sorry, long is 32 bits on 32 bits system too

arm gcc and xtensa compiler have time_t as signed long

Yes, it's highly architecture dependent.

Thank you, this is the answer I was looking for.

now() is a function that is specific to Intel Curie based boards.
It returns an unsigned long (which on a 32-bit system is the same as an unsigned int) and so can provide the number of seconds since 1/1/1970 up until the year 2106, at which point it will roll over.
If you plan on having your system run continuously for more than the next 88 years you will have to deal with that rollover correctly, including:

Using subtraction to "wrap around" your calculations
Not trying to calculate any periods longer than 136 years

Time represented in seconds from 1970-01-01 is called Epoch or Unix time. Function now() and similar functions in Arduino libraries returning 'epoch' use 32-bit representation. Some use the time_t type defined in basic includes distributed with the compiler (types.h). On some compilers or in many time and RTC libraries the 32-bit type is signed allowing to represent time before 1970, on some system the type is unsigned.
The signed 32 bit type for epoch time overflows in 2038 (Year 2038 problem). The unsigned 32-bit overflows in 2106.
I use the TimeLib library and it uses the time_t type defined on SAMD and ESP in type.h distributed with the compiler. ARM GCC has time_t as long, which is signed 32 bit type. The same for ESP boards with xtensa compiler. time_t for AVR is defined in the TimeLib library as unsigned 32bit type and overflows in 2016.

source: Stack Exchange

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

sort: votes


text:
Why after the reset the program vanish?
I buy a stm32 board as picture below, I connect the Boot0 to 3.3 and use the serial port  download the program.
I use the library https://github.com/rogerclarkmelbourne/Arduino_STM32
The second and third picture is my program. After I download the program, the led on board shine and the serial is normal, but after I press RESET on board, it is not shine. Seemly, the program vanish.
Why it is so ? And how to let the program in board after press reset ?

By connecting BOOT0 to 3.3V you are telling the chip When I reset for whatever reason you must go into the bootloader.
So you reset, and it goes into the bootloader. You then upload your sketch.
At that point the programming software tells the bootloader "Ok, you are done now. Run the program". And it does.
Until you reset. And because you are telling it to go into the bootloader with BOOT0 it dutifully does so, waiting for you to load a new program.
The old program is still there, but you just aren't letting run, since you are insisting that the chip go into the bootloader when you reset.
In order to get your program to run and not the bootloader you must disconnect BOOT0 so it doesn't enter the bootloader.
You only need to connect the BOOT0 when you want to put a new program on there.

From http://wiki.stm32duino.com/index.php?title=Bootloader

Activating the bootloader is done through forcing two boot pins (and
  then resetting the MCU). Many boards have one or more boot pins
  exposed as jumpers or push buttons.
Normal boot (to user firmware, which may be a secondary bootloader):

Boot0 LOW
Boot1 LOW

Allow firmware upload through USART1:

Boot0 HIGH
Boot1 LOW

After uploading new software through the serial, move Boot0 back to GND so that the MCU loads the firmware you uploaded, rather than it's internal serial bootloader.

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


text:
How to post data to database using nodeMCU?
We created a website hosted by 000webhost and we're trying to post data from our nodeMCU to the database using the sketch below, but the database doesn't seem to show any received data. How do you fix this?

and below is the php code to rtecieve the data:

#include <ESP8266WiFi.h>

const char* ssid = "Jino";
const char* pass = "myinternet";
char server[] = "cdgresearch.000webhostapp.com";

WiFiClient client;

int led = 2;

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid,pass);
  pinMode(led,OUTPUT);
  digitalWrite(led, HIGH);

  Serial.println("Connecting to: ");
  Serial.println(ssid);
  Serial.print("Connecting");

  while(WiFi.status() != WL_CONNECTED){
    delay(1000);
    Serial.print(".");
    }

  delay(300);
  digitalWrite(led, LOW);
  Serial.println();
  Serial.println("Successfully connected to the network");
  Serial.print("NodeMCU IP Address: ");
  Serial.println(WiFi.localIP());

  if (client.connect(server, 80)){
    String data = "incoming=fromDuino&incoming2=FROMDUINO2";
    client.println("POST /tag.php? HTTP/1.1");
    client.println("Host: cdgresearch.000webhostapp.com");
    client.println("User-Agent: 8266/1.0");
    client.println("Connection: close");
    client.println("Content-Type: application/x-www-form-urlencoded");
    client.print("Content-Length: ");
    client.print("\n\n");
    client.println(data);
    client.stop();

    Serial.println("Connected to server");
    }
    else{
    Serial.println("Failed to Connect to server...");
    }

  client.stop();
  Serial.println("Disconnected from Server");
}

void loop() {
 // put your main code here, to run repeatedly:
}

post the code as text

did you see my answer?

im sorry, going to post the codes soon hopefully

HTTP requires \r\n as line ending. println adds \r\n. So to print the host name to client use println and remove \n from the string. And replace client.print("\n\n") with client.println(); client.println(); (or println the length and then use one println)

You are using POST method in the php script ($_POST['var']) and trying to pass parameters to the script by adding them in the URL. This addition of the parameters would work only if it were a GET method in place of a POST method.
Change wherever you have written POST to GET (Both in the php script and the node mcu code) and your data will be inserted into the database.
1) Change both the $_POST['var'] to $_GET['var'] in the php file.
2) Change client.println("POST /tag.php HTTP/1.1") to client.println("GET /tag.php?incoming=fromDuino&incoming2=fromDuino2 HTTP/1.1")
Also, you can go through this link to learn more about how to make a
POST request. And can you show me the whole code or the classes that you have instantiated?

what do I do if I want to use POST though? I know GET can also work that way but I need the sending of data to be more discrete, and POST method seems to be more discrete than GET

Can you please post your whole code (Including the libraries and all the declarations)? I might help you with POST method then :D

@Manav, the POST request is of type form-urlencoded. and the parameters are in body as it should be

1st I would check each part i.e.
First check your PHP script can insert by setting some values in the script i.e. incomming = "somejunk";
I assume the PHP include file connects to your DB and changes into the corresponding DB?
I assume you have setup a user for the DB in say cPanel and set privileges
Your method of sending data is different to my working format...
You are sending the data at the end rather than the beginning...
Also if you look at your server log you can see if the values get sent
if (client.connect(server, httpPort)) {
  // connected to resource
  // send data
  client.print("POST /dir/file.php?field1=");
  client.print(data1&field2=data2); // must be url encoded
  client.println(" HTTP/1.1");
  client.println("Host: www.domainname.com");
  // client.println("Content-Length: " + String(data.length())); // you dont need
  client.println("User-Agent: ESP8266");
  client.println("Connection: close");
  client.println();

what is this? POST with url parameters. do you know what is "Content-Type: application/x-www-form-urlencoded"?


text:
How to use stm32duino control 5110?
I want to use stm32duino to control 5110, I use the library http://www.rinkydinkelectronics.com/download.php?f=LCD5110_Basic.zip
Before, I use arduino pro mini to control 5110 by this library, it works well. But when I use stm32, it fails. Whether this library is not suitable for stm32duino ? If so, which library is suitable for me ?

The library you linked to does not indicate it works for STM32 architecture. The display uses SPI, and each architecture has it's own way of implementing such peripherals.
There is this library: https://github.com/KenjutsuGH/Adafruit-PCD8544-Nokia-5110-LCD-library which is a port of the Adafruit 5110 driver to STMduino.

Thanks, do you know any library of stmduino for Si4463 (RH_Rf24) and Sx1278 ?

Search in stm32duino forum http://www.stm32duino.com/


text:
Shift register with relay board behaving erratically
I have a nodemcu connected to a shift register(https://www.amazon.de/gp/product/B07CHBYR7Z) to control an 8 channel relay board (https://www.amazon.de/Elegoo-Relaismodul-Optokoppler-Arduino-Raspberry/dp/B01M61VVGV). The realy board is connected to various pumps. The setup itself works quite well normally. However after some switching cycles or when I manually bridge the relay to activate a pump the shift register suddenly either doesnt react at all. Switches on everything or is off by one. I read that it might be possible that I have flow back from the relay coil so I added the diode over the gnd and vcc pin of the relay board. However that didnt help either. Can anybody tell me what I am doing wrong? I hope the schematic is legible.

Can you explain what you are doing when you say "manually bridge the relay"?  Also, what are you switching through the relays?  110 volts AC from mains?  Or are you switching lower voltage?  And, if lower voltage, are you using the same power supply / source as that which powers the Arduino?  Lastly, are the Arduino and this control board located close (within inches) of each other?

With manually briding i mean connecting the two "output" pins from the relay with a cable to activate the pump without switching the relay for testing purposes. I am switching a 220v light bulb as well as 5 pumps which are 12v and connected to a different power supply but to the same multi plug. The distance from the arduino to the relay is ~15cm. The arduino and the relay board are on the same power supply (the relay board is connected to Vcc from the arduino)

Do you have the required bypass caps on the shift register?

No. Where would I need to put those?

Item 2 in my answer:  "as near as possible to each integrated circuit".  Oh, I see, it is commonly understood that these should go across the power pins of each integrated circuit.

If this is a noise issue, there are a number of mitigating actions to consider.  Also, consider that most if not all noise mitigating approaches are generic and may not apply to all situations.

It is almost always easier to mitigate noise at the source.  Filtering the power & shielding are two approaches.
When laying out digital integrated circuits, it is common to include bypass or decoupling capacitors as near as possible to each integrated circuit.  If unfamiliar with these, these capacitors go across the power pins of the integrated circuit.
If an electrically noisy environment is anticipated, making all communication leads and cables as short as possible prevents the likely hood of unexpected results.
If cables need to be long different communications methods such as balanced line or differential signalling should be considered.
Bring all power grounds to a single point.  This mitigates current loops which can cause unexpected power voltage fluctuations.
Consider the power requirements and generally use a power supply that is rated for double to have a margin of safety.
Avoid running cables containing high power or switched power near or in parallel to cables containing low voltage logic.

For this particular application / design:

Likely the reversed bias diode on the relay power supply lines is not needed.  There appears to be optical isolators on the relay board which should prevent the inductance of the relays from feeding back.
Verify you are creating the correct signal to the 74HC595 chip.  Use the timing diagrams on page 8 of this ti.com 74HC595 specification sheet as a guide.
Consider the gauge of the power cables.  Thinner wires over longer runs will drop the voltage proportional to the current demand.  If all 8 relays are active, the current demand may be as much as an Amp.

Thank you I will try those. The signals should be correct as I am using the arduino library for the shift register and as I said it is normally working. Only it sometimes stops and I need to turn off power to fix that.


text:
ESP8266 - 12F High consumption in led blink (with pictures)
My esp is consuming 180mA with a led blink. The same consumption happens when I put it in WIFI_STA mode with the WiFi.mode(WIFI_STA); function.
What should I do to reduce consumption? Used AMS1117 CI as tension regulator.
My code:
void setup() {
  pinMode(2, OUTPUT); // pin number 2 is on board blue led
}

void loop() {
  digitalWrite(2, LOW); // blue led highlight with LOW level
  delay(100);
  digitalWrite(2, HIGH);
  delay(100);
}

Why all this consumption?

if it's in WIFI_STA  and not doing anything network-related, it should eventually go into modem sleep and draw a lot less.

The SDK library of the ESP8266 remembers on flash memory the mode, SSID and password of the last WiFi network it connected. At start or by enabling STA mode it tries to connect to that network. The SDK library is always part of the compiled sketch for the esp8266.
The esp8266 WiFi library has some functions to control this:

WiFi.setAutoConnect(false)
WiFi.disconnect(true);
WiFi.persistent(false)


text:
Not enough memory
I am making a simple calculator with Arduino Uno R3. It only has +, -, x and /.
I use 3 libraries:

This use for LCD with I2C module. Arduino-LiquidCrystal-I2C-library
This use for keypad 4x4. Chris--A/Keypad
And this: jamesgregson/expression_parser

My code:
#include "expression_parser.h"
#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x3F, 16, 2);

const byte ROWS = 4;
const byte COLS = 4;

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

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

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

String s = "";
char ex[16];

void setup() {
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0, 0);
}

int cur = 0;
bool enter = false;

void loop()
{
  char key = keypad.getKey();

  if ((key != '=') && (key != NO_KEY) ) {
    if (!enter) {
      Serial.println(F("key"));
      if(key=='/')
        lcd.print(F("':'"));
      else
      if (key=='*')
        lcd.print(F("'x'"));
      else
        lcd.print(F("key"));
      s = s + key;
      cur++;
      lcd.setCursor(cur, 0);
    } else {

      lcd.setCursor(0, 0);
      lcd.print("");
      enter = false;
      lcd.setCursor(0, 0);
      cur = 0;
      lcd.print(F("key"));
      s = "";
      s = s + key;
      cur++;
      lcd.setCursor(cur, 0);
    }
  } else if (key == '=') {
    enter = true;

    if ((s[0] == '=') || (s[0] == '/') || (s[0] == '*') || (s[0] == '.')) {
      lcd.setCursor(0, 1);
      lcd.print("Error");
    } else {
      lcd.setCursor(0, 1);
      lcd.print("");
      s.toCharArray(ex, 16);
      Serial.println(F("s"));
      int re = parse_expression(ex);
      String check = String(re);
      if (check.length() > 15) {
        lcd.setCursor(0, 1);
        lcd.print("Overflow");
      } else {
        Serial.println(re);
        lcd.setCursor(0, 1);
        lcd.print("=");
        lcd.print(F("re"));
      }
    }
  }
}

I ran it and got error:
Global variables use 3302 bytes (161%) of dynamic memory, leaving -1254 bytes for local variables. Maximum is 2048 bytes.
Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint.
Error compiling for board Arduino/Genuino Uno.
So what should I do?

the expression parser uses a lot of ram, get rid of it. You're only doing 4 basic operations, so all you need to do is a small set of IF statements and parse the numbers themselves, which arduino can do without a big lib.

The most efficient system you can use is called "Reverse Polish Notation", or RPN.  It's a stack-based system and can run very efficiently on systems with very very little memory. You just have to get used to how to enter the equations properly...

which Arduino board you are using?

Your own declared global variables do not use up much space.
Watch out for using string, this can be extended during the flow of the program thus using more.
The problem is in the libraries.
What you can do:

Leave out the include and related code per library to see which is using up a lot of global space.
When you find out which causes problems, try to follow the internals of the library to see if there is some buffered memory that you can decrease.

If not, I'm afraid the only solution is to move to an Arduino with more memory (like the Arduino Mega which has 8 KB).
With the use of PROGMEM you can save some space on
char keys[ROWS][COLS] = {
  {'1', '2', '3', '+'},
  {'4', '5', '6', '-'},
  {'7', '8', '9', '*'},
  {'.', '0', '=', '/'}
};

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

Because it will be placed in Flash instead of SRAM, but it will save you just 24 bytes.

From a cursory look at those libraries, it seems to me that the expression parser eats a lot more RAM than the two others. It contains lots of error messages and code to deal with transcendental functions: things the OP does not have use of.

Move up to a '1284P based board. They have 16K of SRAM and 12 more IO pins, will give you plenty of room to add and expand into more functions later.
I offer '1284P boards in several form factors at www.crossroadsfencing.com/BobuinoRev17/
It is easy to add to the IDE with MCUdude's MegaCore
https://github.com/MCUdude/MegaCore


text:
Arduino Force sensitive Resistor with an lcd
So we were asked to do something with a force sensitive resistor so naturally i thought of a project which takes the name of the main component which is force and applies it ,mine works by as  you apply more and more pressure to the sensor it takes this value and displays it on an lcd but the display should be a bar graph which increases as the pressure increases. the problem is i dont really know how to do a bar graph on a 16x2 lcd. Please help. (my lcd has an I2c)
here is my code for the pressure sensor so far
int fsrAnalogPin = 0; // FSR is connected to analog 0
int fsrReading;      // the analog reading from the FSR resistor divider

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

void loop(void) {
  fsrReading = analogRead(fsrAnalogPin);
  Serial.print("Analog reading = ");
  Serial.println(fsrReading);
  delay(100);
}

ok so i improved my code and i finally got it this code displays the force detected by the fsr into a bar graph
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LcdBarGraphX.h>
#include<LcdBarGraph.h>

byte lcdNumCols = 20; // -- number of columns in the LCD

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);   // -- creating LCD instance

int fsrAnalogPin = 0; // FSR is connected to A0

// -- creating a 4 chars wide bars
LcdBarGraphX lbg0(&lcd, 16, 0, 0); // -- First line at column 0 and row 0 with 16 columns

void setup(void) {
  Serial.begin(9600);   // We'll send debugging information via the Serial monitor
  lcd.begin(4, lcdNumCols); // start lcd with 2 rows and 16 columns
  lcd.clear();
  delay(100);
}

void loop(void) {
  lbg0.drawValue( analogRead(fsrAnalogPin), 9); // the 9  is the maximum range you want for pressure
  Serial.print("Analog reading = ");
  Serial.println(fsrReading);
  delay(100);
}

your question has nothing to do with a force sensor ... it is a question about drawing bar graphs on an LCD .... you should really edit your question and the title so that it reflects the actual question .... that way, people will find your question if they are researching graphing on an LCD

There's two ways you can do it: the easy way, and the fancy way.
The easy way really is easy.  Since the display can only display characters you just display characters - enough to represent a bar graph.
If you have a display with "Rom Code A00"* then character 255 is a solid block (▇) so you just print between 0 and 16 of them in a row.  0 is 0% and 16 is 100%. (If you have ROM Code A02 then you could just use #, or custom design a character - see below).
Force:▒▒▒▒▒▒▒▒▒▒
▇▇▇▇▇▇▇▇▇▒▒▒▒▒▒▒

Or with #:
Force:▒▒▒▒▒▒▒▒▒▒
#########▒▒▒▒▒▒▒

The fancy way is to use the programmable characters facility.  You would create 4 new characters that partially fill a block.  Each character is 5 pixels wide, so creating a character with 1 column of pixels set (▏), one with 2 set (▍), 3 set (▌) and 4 set (▋) (you already have all 5 set on in character 255 if you have ROM Code A00 - otherwise define a 5th with all 5 columns on).  Now you can be clever and work out:

How many full characters to print, and
Which of the extra characters to print on the end.

That gives you effectively 16*5 (80) pixels of horizontal resolution (albeit with a small gap between each set of 5 pixels).
Exactly how you do whichever of those methods you choose is now up to you.

*: ROM Code A00 is the character ROM with Japanese characters in the characters 128-255.  ROM Code A02 has European accented characters instead.

From the Library Manager, install the LcdBarGraphX library by Balazs Kelemen.
There are several examples there as well.

See also LcdBarGraph Library for Arduino. Prapec's github has the original fork for LcdBarGraphX.


text:
Will this sketch eventually fail because of integer limit issue?
I am a novice in Arduino programming and I'm setting up an Arduino controlled, underwater time-lapse camera to take a picture every 2 hours.  It's going in the ocean for a month and I want to be sure that the code will not fail because of the upper limit that normal integers can go.
The Arduino simply switches on a relay (connected to the LED_PIN 11) and the camera does the rest, using a script from the awesome Canon Hackers Development Kit C.H.D.K.
I've tried several variations of sketch, some using simple delay, some with millis and some with counters that print what increment the loop it up to.
One of my fast running test sketches, that used a counter, stopped prematurely, I suspect due to hitting the integer limit but I'm not sure if this only occurred due to the fact that it had a counter in the sketch.  So I've gone back to the simplest sketch I can find hoping it will not have this issue.
I think I read that once the integer limit is reached, the sketch will simply restart.  Or maybe it will become unpredictable.  I'd rather the  former than the latter.
Any suggestions would be welcome.
I am sure there are many ways to go about this but I'm looking for the simplest and most robust one I can find, so that I can adjust the async timing easily ie.
loop starts
CameraOn for 10 seconds
CameraOff for 2 hours
Loop repeats
thanks in advance for your consideration
Here's the sketch I'm testing right now.
#define LED_PIN 11
#define LED_OFF 7200000     // 2 hours in millis
#define LED_ON  8000       // 6 seconds in millis

unsigned long ms;        //time from millis()
unsigned long msLast;    //last time the LED changed state
boolean ledState;        //current LED state

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

void loop(void)
{
    ms = millis();
    blinkLED();
}

void blinkLED(void)
{
    if (ms - msLast > (ledState ? LED_OFF : LED_ON)) {
        digitalWrite(LED_PIN, ledState = !ledState);
        msLast = ms;
    }
}

==================================================================
Okay, I've come up with a new, much simpler sketch based on delay.
Can someone please tell me if this is more robust in terms of continued looping for weeks on end?
#define LED_PIN 11

void setup()
{
   Serial.begin(9600);
   pinMode(LED_PIN, OUTPUT);
   digitalWrite(LED_PIN, HIGH);
}

void loop()
   {
       delay(7200000);                 // 2 hours in millis
       digitalWrite(LED_PIN, LOW);
       delay(8000);                    // 8 seconds in millis
       digitalWrite(LED_PIN, HIGH);

   }

#define LED_ON  10000      // 1 seconds in millis      ..... tell me,  what does milli mean? .... hint: it is a prefix, like in millimeter and milliliter  and milliseconds

why are you initializing Serial?

the first seven words of my post introduce me as a novice..I'm hacking and snipping from all over the place and gradually filling in the blanks in my knowledge... Yes, I should probably spend a few days doing tutorials to get the basics but, I think you'd agree this is a simple task, so I have rolled up my shirtsleeves and dived in.

Possible duplicate of How can I handle the millis() rollover?

@Juraj, this is about letting the Arduino run for a long time. No duplicate I think. Hazy, both sketches should work as far as I can tell. When using large numbers I prefer to use "52000UL". The "UL" means it is an unsigned long number. Please update both your sketches and write also how long it is in comments at every large number. For example "52000" is 52 seconds. How is it powered? With a battery? Will that last long enough? The arduino boards are for fast prototyping, it is not protected against a harsh environment.

Thanks @Jot,  I've updated the sketches to the desired inteval (not very desirable for testing mind).
This unit will sit inside an underwater housing, fixed to a seaweed farm tray, roughly 1.5 meters below the surface of the Pacific Ocean, 5km off the north shore of Bali.
Ive

Cont...
I've just purchased a 26,000mAh USB power bank which will power it.  A recent 24 hour run test, measure on a USB Wattmeter showed 0.74W/h , so 26Ah / 0.74W/h = 35.135 days.  It's anybody's guess at what point it will not have enough voltage to drive the camera but, fortunately, we're aiming for as-long-as-it'll-run, rather than trying to hit a definite number of days.

@Jot, this is about "Will this sketch eventually fail because of integer limit issue?". the answer is no, because it correctlly handles the millis rollover

@Hazy, you should not ask more questions at once, here at SE https://arduino.stackexchange.com/tour

If you want any form of accuracy to your timing you should consider an RTC. The internal millis() is not particularly accurate over long periods.

26,000mAh USB power bank...  Good luck with that...  The best 18650 battery packs you can get retail (panasonic) are 13400mAh (4P, 3350/cell). Each one costs £70, so about £18/cell.  To get 26,000mAh you would need 8 cells, totalling about £140. And that is with proper batteries. Stuff off eBay / Amazon you'd be lucky to total 2600mAh from all the cells in it. A typical eBay battery has cells of about 1000mAh in them. You'd need 20+ cells in your battery for that to add up...

Oh, and if the cells are laid side-by-side as most power banks are, it would measure over a foot long.

There's a reason why "high capacity" USB power banks on eBay are so cheap - they aren't. High capacity, that is.  Every single seller out there blatantly lies about the capacity. Usually multiplying it by a factor of 10 or more.  I have seen 50,000mAh power banks with an acutal capacity of just 2600mAh.

@Majenko I hear you about the manufacturer's claims vs reality but this is the only form factor battery that will fit in my housing.  I bought from Amazon and here's a fairly comprehensive YouTube review, including charge and discharge measurements  https://www.youtube.com/watch?v=AqIwb4395SY

No, the sketches will not fail or work incorrectly. The Arduino "delay()" function calls the "micros()" function for timing. The "micros()" function uses the Atmel's TIMER0 clock and waits for 1000 microseconds (1 milliseconds) each iteration. The TIMER0 overflows about every 70 minutes, but the program code used in the "delay()" function handles that overflow correctly.

Actually Timer 0 overflows every 1024 µs.

You are somewhat more correct than I was (I was looking at the 16-bit Timer1) but actually both of us are wrong, since the overflow of the timers are dependent upon the prescaler settings. Nevertheless the timer overflow won't impact the micros() return value and therefore doesn't impact the response to the original question

On the Arduino Uno (that's what the OP is using), the initialization code in the Arduino core library sets the prescaler of Timer 0 to 64. If you mess with that prescaler (the OP doesn't), then all the Arduino's timing functions will be off.

the question was about the millis version of the code, not about later added version with delay()

Thanks for your input..  I feel more confident now to put it in the water.
@Juraj Sorry if I appear to be asking more than one question.  I did only mean to ask one but now I realize that question was not as precise as it could have been.  It should have been phrased "Should I use the 'millis' or 'delay' approach to avoid any issue with the integer limit"
Cheers

@Hazy, did you ever think about delay() overflowing? because this answer is about that. about delay() implementation over micros()

@Juraj I didn't but the helpful answers from Edgar Bonet and Zanshin informed me of the fact that delay 'overflows' but, apparently it shouldn't impact my project because I haven't fiddled with the prescaler - whatever that is.


text:
Stop and continue loop by using boolean flag for traffic light
By using boolean and flag, I can now control the green light but the program cannot repeat or loop the sequence for traffic light from red to yellow to green. If I don't use flag, the sequence red-yellow-green LED can be looped but I can't control and trigger green light on app.
My current project also serial communicate from NodeMCU to Arduino.
#include <SoftwareSerial.h>

SoftwareSerial nodemcu(2,3);
long int data;

boolean start = true;

void setup() {
  pinMode(7,OUTPUT);//greenbulb
  pinMode(8,OUTPUT);//yellowbulb
  pinMode(9,OUTPUT);//redbulb

Serial.begin(9600);
nodemcu.begin(9600);

}

void changeLights()
{
  digitalWrite(7,LOW);// greenbulb
  digitalWrite(8,LOW); // yellowbulb
  digitalWrite(9,HIGH);// redbulb
  delay(7000);

  digitalWrite(7,HIGH);// greenbulb
  digitalWrite(8,LOW);// yellowbulb
  digitalWrite(9,LOW);// redbulb
  delay(5000);

  digitalWrite(7,LOW);// greenbulb
  digitalWrite(8,LOW);// yellowbulb
  digitalWrite(9,LOW);// redbulb
  delay(1000);
  digitalWrite(7,HIGH);// greenbulb
  digitalWrite(8,LOW);// yellowbulb
  digitalWrite(9,LOW);// redbulb
  delay(1000);
  digitalWrite(7,LOW);// greenbulb
  digitalWrite(8,LOW);// yellowbulb
  digitalWrite(9,LOW);// redbulb
  delay(1000);
  digitalWrite(7,HIGH);// greenbulb
  digitalWrite(8,LOW);// yellowbulb
  digitalWrite(9,LOW);// redbulb
  delay(1000);

  digitalWrite(7,LOW);// greenbulb
  digitalWrite(8,HIGH);// yellowbulb
  digitalWrite(9,LOW);// redbulb
  delay(2000);
}

void loop() {

if ( nodemcu.available() > 0 )
{
  data = nodemcu.parseInt();
  delay(100);
  Serial.println(data);

      if (( data == 10) && (start == true)){
           changeLights();
            start = false;
      }

      if (( data == 11) && (start == false)){
      digitalWrite(7, HIGH);
      digitalWrite(9, LOW);
      digitalWrite(8, LOW);
            start = true;
      }
}
}

see the BlinkWithoutDelay example

tip: if (start) is same as if (start == true)  .........    if (!start) is same as if (start == false)   .............. less typing and less redundancy

What you really want is a Finite State Machine.

you have a bunch of useless code in your program .... why are you making pin 8 LOW a multiple times in a row? .... you only have to do it once .... same goes for the other pins

This is not an answer (that is looking at the BlinkWithoutDelay as Juraj mentioned), but I want to provide a way how to greatly reduce your program and use this method in future.
You are repeating
digitalWrite(7,LOW);// greenbulb
digitalWrite(8,HIGH);// yellowbulb
digitalWrite(9,LOW);// redbulb
delay(2000);

A lot, with variations of LOW/HIGH and the delay time. Instead, use a function that has parameters:
void changeLight(int green, int yellow, int red, int delayTime)
{
    digitalWrite(7, green);
    digitalWrite(8, yellow);
    digitalWrite(9, red);
    delay(delayTime);
}

And you can call it by
changeLight(LOW, HIGH, LOW, 2000);
You can do this for all of the 4 line repeats.


text:
5 switches, 5 leds, 5 tones, in an Array
The idea is when a switch is pushed, the corresponding tone will be played as well as lighting up the corresponding LED. I have the circuit set up to where each array matches another, for example Switch one will play tone 1 and light LED 1. When the switch is released the LED turns off and the tone no longer plays.
However I have to use an Array for the sketch instead of declaring each individual switch, led, and tone.  My issue is when I compile the code, I get the error message "i" is not declared.  Not sure where my error is within the for loop in the setup portion of the sketch.
I tried following the example from the Exploring Arduino web page but it did not help.
#define NOTE_C   262 //HZ
#define NOTE_D   294 //HZ
#define NOTE_E   330 //HZ
#define NOTE_G   392 //HZ
#define NOTE_A   440 //HZ

const int SPEAKER = 9;   //speaker on pin 10
int LED[5] = {13, 12, 11, 10, 8};   //led pins
int ledcount = 5;
int buttonState;
int buttonState1;
int buttonState2;
int buttonState3;
int buttonState4;

//Button Array
int Buttons[5]= {3, 4, 5, 6, 7};
int ButtonCount = 5;
const int numButtons = sizeof(Buttons) / sizeof (Buttons[0]);

//Tone Note Array
int Notes[5] = {NOTE_C, NOTE_D, NOTE_E, NOTE_G, NOTE_A};

void setup()
{
  for (int i = 0; i < sizeof (Buttons) / sizeof(Buttons[0]); i++){
  pinMode(Buttons[], INPUT);
}
  for (int i = 0; i < sizeof (LED) / sizeof (LED[0]); i++);{
  pinMode(LED[], OUTPUT);
}
  for (int i = 0; i < numButtons; i++){
  pinMode(Buttons[i], INPUT);
  debouncer[i].attach(Buttons[i]);
  debouncer[i].interval(100);
}
  buttonState = digitalRead(Buttons[0]);
  buttonState1 = digitalRead(Buttons[1]);
  buttonState2 = digitalRead(Buttons[2]);
  buttonState3 = digitalRead(Buttons[3]);
  buttonState4 = digitalRead(Buttons[4]);
}

void loop()
{

  if (buttonState == HIGH)
  { tone(SPEAKER, Notes[0]);
  digitalWrite(LED[0], HIGH);
  }
  else if (buttonState1 == HIGH)
  {tone(SPEAKER, Notes[1]);
  digitalWrite(LED[1], HIGH);
 }
  else if (buttonState2 == HIGH)
  {tone(SPEAKER, Notes[2]);
  digitalWrite(LED[2], HIGH);
 }
  else if (buttonState3 == HIGH)
  {tone(SPEAKER, Notes[3]);
  digitalWrite(LED[3], HIGH);
 }
  else if (buttonState4 == HIGH)
  {tone(SPEAKER, Notes[4]);
   digitalWrite(LED[4], HIGH);
 }

  else
 {
  digitalWrite(LED[5], LOW);
  noTone(SPEAKER);
 }
}

I have to use an Array  .....  is this a school assignment?

@jsotola, It is a school assignment.Its why i ask for suggestions and not completed codes.  It doesnt help if someone does the work for me.  Can only learn through doing.  Millis() was a great thing to learn through here, millis() will not even be covered through the curriculum.  However I don't think ill need millis() in this code.  Im now using the Bounce2 library and it gives a debounce interval. Ill update my code for the changes made.

i ask for suggestions and not completed codes .... i do not see that

@jsotola I do apologize for not making that clearer in this post.

You have a rogue ; here:
  for (int i = 0; i < sizeof (LED) / sizeof (LED[0]); i++);{
  pinMode(LED[], OUTPUT);                                 ^------HERE
}

That is terminating the for, making it empty, and the following block is a completely different scope.
Another thing I spotted - you aren't putting i into your array index LED[] (should be LED[i]).  The same is true with Buttons[].
However, on a different subject, this:
buttonState == digitalRead(Buttons[0]);
buttonState == digitalRead(Buttons[1]);
buttonState == digitalRead(Buttons[2]);
buttonState == digitalRead(Buttons[3]);
buttonState == digitalRead(Buttons[4]);

is pretty meaningless.  You are comparing values and throwing away the result.
In a similar vein:
if (buttonState = Buttons[0])

stores the current value of Buttons[0] into buttonState and succeeds if Buttons[0] is anything other than 0.  The same goes for all the others.
You need to sort out your comparisons (==) and your assignments (=) and also sort out what you think you are doing with all those buttonStates at the top of loop.

I did not notice the extra semi colons which explains why it was not declared in the scope.  I made the changes as well, tone plays and led lights up just wont turn off.  Im assuming ill need to debounce the switches in order to get them to work.

I debounced the switches and im still having the same issue.  Its debounced via array for loop, through the bounce2 library.  I am still not getting the led or other switches to work properly.  It will not let me post the new code in a comment either.

Unless you fixed all the other issues with your code you have no hope of it working.

I got it working now thank you for your help.  The issue ended up being the two things you pointed out, and how i was calling on the array.


text:
3.3 V Arduino Pro Mini and nRF24L01 issues
I have a 3.3 V Pro Mini connected to nRF24l01 as xmtr. The nRF24L01 does not respond to the Pro Mini. Any help will be appreciated.
I have attached the print detail output:
Transmitter 2  Started
STATUS       = 0xff RX_DR=1 TX_DS=1 MAX_RT=1 RX_P_NO=7 TX_FULL=1
RX_ADDR_P0-1     = 0xffffffffff 0xffffffffff
RX_ADDR_P2-5     = 0xff 0xff 0xff 0xff
TX_ADDR      = 0xffffffffff
RX_PW_P0-6   = 0xff 0xff 0xff 0xff 0xff 0xff
EN_AA        = 0xff
EN_RXADDR    = 0xff
RF_CH        = 0xff
RF_SETUP     = 0xff
CONFIG       = 0xff
DYNPD/FEATURE    = 0xff 0xff
Data Rate    = 1MBPS
Model        = nRF24L01
CRC Length   = 16 bits
PA Power     = PA_MAX

Transmitter 2 Started
STATUS       = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1     = 0xe8e8f0f0e2 0xc2c2c2c2c2
RX_ADDR_P2-5     = 0xc3 0xc4 0xc5 0xc6
TX_ADDR      = 0xe8e8f0f0e2
RX_PW_P0-6   = 0x20 0x00 0x00 0x00 0x00 0x00
EN_AA        = 0x3f
EN_RXADDR    = 0x03
RF_CH        = 0x73
RF_SETUP     = 0x07
CONFIG       = 0x0e
DYNPD/FEATURE    = 0x03 0x06
Data Rate    = 1MBPS
Model        = nRF24L01+
CRC Length   = 16 bits
PA Power     = PA_MAX
voltage = 3.97 V
0
RSLT (1 = success) 0
Data Sent 3.00  0.00  3.97
voltage = 3.85 V
voltage = 3.79 V
voltage = 3.75 V
voltage = 3.73 V
0
RSLT (1 = success) 0
Data Sent 3.00  0.00  3.73
voltage = 3.70 V
voltage = 3.68 V
voltage = 3.65 V
voltage = 3.62 V
0
RSLT (1 = success) 0
Data Sent 3.00  0.00  3.62
voltage = 3.58 V
voltage = 3.54 V
voltage = 3.50 V
voltage = 3.45 V
0

The top transmitter output is before I changed the nRF24L01 module which appeared to be bad.
The second transmitter started output. Module is good but nRF24L01 would not connect to receiver with 3.3 V Pro Mini. It connects if I use a Nano.

Transmitter 2 is not connected properly. Unwire and rewire it.

voltage = 3.97 V 0 RSLT (1 = success) 0 Data Sent 3.00 0.00

nrf24l01 is a 3.3V device, Where'd that come from?

LM317T set to 3.25 Volts and 220uF tantalum on the nrf24L01.
Pro mini and nrf24L01 powered by 3.25V works a treat. :-)
Problem with arduino nano is that the USB from laptop is 5V and that is a killer for the nrf24L01!
If using serial.write to send data to a serial monitor through the nano's USB insure that the power and levels are not 5V on the nrf24L01.

Promini 3.3V regulator is also only good for 150mA. I think the nrf24L01 needs more current than that.

Only the high-power version needs more current. What matters is stable voltage but this guy has wiring issues.


text:
How can I read the serial output of STM32F103C8T6 from USB to Serial TTL?
I recently bought a STM32F103C8T6 board (blue pill)
I programming to it using the USB to Serial TTL I bought (CP2102).
I'm still taking very first steps and trying to figure out how to operate the component.
I was able to burn a basic script to STM32F103C8T6 that causes the P13(LED) to blink.
Now I'm trying to add basic printing that I can see over the serial interface
Which I am already connected to (CP2102).
Here's what my code looks like:
void setup() {
// initialize digital pin PC13 as an output.
pinMode(PC13, OUTPUT);
Serial.print("finish setup function \r\n"); // try to print something using serial
}

void loop() {
digitalWrite(PC13, HIGH);
delay(500);

digitalWrite(PC13, LOW);
delay(500);

Serial.print("loop throgh loop function \r\n"); // try to print something using serial
}

Everything is compiled and loaded fine (I work through ARDUINO IDE), but it is not clear to me where I can see these prints.
I tried to see them in Tools-> serial monitor (in the arduino ide tool)
But I didn't see any printing ...
(I know that my code got loaded successfully because I play with the speed of the LED blinks and I see that it is responding to the change at the speed of the flicker).
It feels like it's a really stupid question but where can I see my prints?

Do you need to initialize the serial interface? That's normally done for Arduino sketches.

You miss-spelled the word 'throgh'. It should be 'through'. If it is a command it MUST have correct spelling.

thank you @Sparky256 it's not a command , i simply try to print this sentence

thank you @ElliotAlderson what i need to initialized and how? can you please give me some basics examples of this?

Look for some sample code that uses the serial interface. There are many, many examples available and some are included with the Arduino IDE. I'll admit it's not clear to me what programming environment you are using.

First you must study the documentation of the Arduino port you are using to find out which hardware UART/pins Serial refers to, or if it actually refers to a virtual channel through the stm32's USB port.  Only you know which port of Arduino to the stm32 you are using, so only you can do that.


text:
esp8266 + octocoupler relay: WDT reset when using AC current
I'm trying to switch on bulb via 4 channel 5V optocoupler relay controller from ESP8266 using WIFI Access point. All my connections looking fine and i can able to connect WIFI SoftAP and send signal to ESP8266 01. Even i can able to switch the Relay from NO to NC or other way around. Only when a connect 240V AC current to relay for powering the bulb, i'm getting following error from ESP
21:11:34.312 ->  ets Jan  8 2013,rst cause:4, boot mode:(1,7)
21:11:34.312 ->
21:11:34.312 -> wdt reset

If i use 12V DC power to light the led via relay its working fine. if again use 240V power to relay to light bulb i'm get same error again.
I have already tried using ceramic capacitor for decoupling to avoid noise from AC. Still no luck. Please advice. I'm very new and naive at handling electronics.
Adding the circuit as well.

Update: After further testing, I can see following behaviour,
If i connect AC bulb to relay and turn it on. Then by provide a long gap before turning it off makes the ESP stable for longer time.
Even better, if i turn off/on my mobile wifi between each time i turn on or off the AC bulb then ESP is always stable.
Adding my code as well.
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

/* Set these to your desired credentials. */
const char *ssid = "*****";
const char *password = "*********";

ESP8266WebServer server(80);

const int led = 2;  //GPIO2

/* Just a little test message.  Go to http://192.168.4.1 in a web browser
 * connected to this access point to see it.
 */
void handleRoot() {

  int size=1000;
  char temp[size];

  int sec = millis() / 1000;
  int min = sec / 60;
  int hr = min / 60;

  snprintf ( temp, size,

"\

Status: Light ON

\

Turn ON

\

\

Turn OFF

\
  \
  ",

    hr, min % 60, sec % 60
  );
  server.send ( 200, "text/html", temp );

}

void setup() {
    delay(1000);
    Serial.begin(115200);
    Serial.println();
    Serial.print("Configuring access point...");

    /* You can remove the password parameter if you want the AP to be open. */
    WiFi.softAP(ssid, password);

    IPAddress myIP = WiFi.softAPIP();
    Serial.print("AP IP address: ");
    Serial.println(myIP);

  pinMode(led, OUTPUT);
  digitalWrite ( led, HIGH );

  //URLs available to query
    server.on("/", handleRoot);
  server.on ( "/on", turnON );
  server.on ( "/off", turnOFF );
    server.begin();
    Serial.println("HTTP server started");

}

void turnON(){

  digitalWrite ( led, HIGH );

  int size=1000;
  char temp[size];

  int sec = millis() / 1000;
  int min = sec / 60;
  int hr = min / 60;

  snprintf ( temp, size,

"

Turn OFF

",

    hr, min % 60, sec % 60
  );

  server.send ( 200, "text/html", temp);

}

void turnOFF(){

  digitalWrite ( led, LOW );

  int size=1000;
  char temp[size];

  int sec = millis() / 1000;
  int min = sec / 60;
  int hr = min / 60;

  snprintf ( temp, size,

"

Turn ON

",

    hr, min % 60, sec % 60
  );

  server.send ( 200, "text/html", temp);

}

void loop() {
    server.handleClient();
}

I know this question is more than 5 years old, but since nobody has mentioned it: are you trying to produce 5 V from a 5 V input using a linear regulator? That will not work. Also, if the regulator is an LM317T, it's wired incorrectly and would need a pair of resistors to set the output voltage.

Before running to dark magic of EMI problems - let's try isolate all our parameters that can cause or affect (and perhaps is is not only one):

make a test code as simple as possible for switching a relay periodically on/off. At start make a 5 second delay between changing states, and down to 500 millis- This way you check both EMI interference and power issues inside you circuit (sometimes the relay consumes power more that the MCU can give, and that can cause resets. Problem can be MCU's power issue or Relay, mechanical or electrical issues).
Components - try to replace with others, especially MCUs, and relays, to make sure it is not a malfunctioned or degraded components. For example - a Wemos mini with is Relay shield can easily isolate any "EMI"- related issue.
From you diagram (and in contrast to your question's title) - an Uno is used for switching ? and not the ESP-01' right? did you make sure that the relay's vcc is correct for its MCU? (you said 5v relay, which is not correct for ESP8266).
Load - make sure to choose a simple resistive load (AC light bulb), rather that an AC motor (which cause a massive EMI interference).
EMI - if all above did not help (I doubt) or it solved for that "bulb case" only, EMI affect are distance related. Try to use a long AC wires that will take you MCUs and relay far from that source. 1m will be enough.

To sum up, I will be very surprised to know that it is EMI (and I dealt with AC motors with WEMOS and a dual relay module successfully).
Please update.
Guy


text:
ArduinoJSON: Using a reference to a reference when parsing array of arrays
I started to play around with the ArduinoJson library to parse data I got from one of my APIs (the format of the JSON data I get from my API can be improved for sure, but the software I had to implement the API with is rather limited in formatting JSON strings). The data is formatted as an array of arrays like this:
[["P101","1.2345","bar(a)"],["P102","1234.567","mbar"],["P103","2345.678","mbar"],["P104","2.3456","bar(a)"]]

In order to get a first impression about how much memory is needed I used ArduinoJSON's Assistant to analyse my dataset, calculate memory requirements and get a very basic code snippet for parsing the data. Code snippet generated by the assistant is as follows:
const size_t bufferSize = 4*JSON_ARRAY_SIZE(3) + JSON_ARRAY_SIZE(4) + 90;
DynamicJsonBuffer jsonBuffer(bufferSize);

const char* json = "[[\"P101\",\"1.2345\",\"bar(a)\"],[\"P102\",\"1234.567\",\"mbar\"],[\"P103\",\"2345.678\",\"mbar\"],[\"P104\",\"2.3456\",\"bar(a)\"]]";

JsonArray& root = jsonBuffer.parseArray(json);

JsonArray& root_ = root;

JsonArray& root_0 = root_[0];
const char* root_00 = root_0[0]; // "P101"
const char* root_01 = root_0[1]; // "1.2345"
const char* root_02 = root_0[2]; // "bar(a)"

JsonArray& root_1 = root_[1];
const char* root_10 = root_1[0]; // "P102"
const char* root_11 = root_1[1]; // "1234.567"
const char* root_12 = root_1[2]; // "mbar"

JsonArray& root_2 = root_[2];
const char* root_20 = root_2[0]; // "P103"
const char* root_21 = root_2[1]; // "2345.678"
const char* root_22 = root_2[2]; // "mbar"

JsonArray& root_3 = root_[3];
const char* root_30 = root_3[0]; // "P104"
const char* root_31 = root_3[1]; // "2.3456"
const char* root_32 = root_3[2]; // "bar(a)"

I did not test this, yet but had a look at the produced snippet and stumbled upon these lines:
JsonArray& root = jsonBuffer.parseArray(json);

JsonArray& root_ = root;

What is the exact advantage of using address-references root, root_ and e.g. root_1 here? Those should, as far as I understood the code, reference to the same data at the end. Is it for better readability only?

The advantage of reference above pointers:

References cannot be NULL, so it's much safer to use them
Address of a reference cannot be acquired, this means a calling function cannot mess up anything outside the type (value) being passed.

For passing a reference to an address the same advantages applies (cannot be NULL, address cannot be changed).
Also, address arithmetic (address + xxx or address - xxx) cannot be used, which prevents tricky programming errors where values outside a variable's memory space can be changed.

It is not a reference to reference. It is a copy of the reference.
The generator must handle more difficult JSON inputs then yours and to make output readable it has a strategy, which in simple case can look as unnecessary. Yes, it could use root[n][m].


text:
Arduino UNO socket
As I learnt so far is that Arduino UNO board has a socket for power input. The available power input range is between 7V - 20V, but the optimal usage range is 7V-12V.
Here I am wondering:
  ---> if there is a USB port for power supply, why do we need a power input socket?
  ---> Or there is a battery on-board to charge?

With a 5v power supply or power bank, the usb connector can be used. The dc barrel jack is for a power supply or battery pack of 7v to 12v, I prefer 7.5v to 9v.

The Arduino Uno has no on-board battery. The dc barrel jack is provided to give you more options to power the Uno, which is handy for stand-alone applications (without USB-connection to a computer) and/or battery powered applications. It can also supply more current than the USB-connection, which can be necessary when using shields.
The current taken from the usb port is limited to 500 mA by by an auto resettable fuse on the Uno (the voltage is not regulated by the Uno). This is the same amount of current as the USB 2.0 standard specifies that a standard down stream port (computer USB port) should be capable to deliver (for USB 3.0 this is 900 mA).
The power taken from the barrel jack is regulated to 5 V by a voltage regulator, the NCP1117ST50T3G. To work properly, this regulator needs a voltage difference (dV) between input and output of 1.2 V (depending on output current and ambient temperature). This means that the minimum voltage on the barrel jack is 6.2 V.
The regulator has an internal thermal limiting circuit that limits the junction temperature to ca. 175°C. This determines the maximum power dissipation (= output current times dV) the regulator can handle at a given ambient temperature. The maximum allowable power dissipation also depends on the size of the copper pad under the cooling tab of the regulator. As I don't know this size it is difficult to calculate de maximum power dissipation precisely, but my guess is that at 25°C and 6.2 V a power dissipation of 1 Watt should be possible. This gives a maximum output current of 1/(6.2-5.0)=0.833A=833 mA. Of course, at higher input voltages the maximum output current is lower. For example at 12 V: 1/(12.0-5.0)=0.143A=143mA.

Many projects (robots, drones, 3D printers, light control, art) made with Arduino have actuators (relays, motors), lights and displays which require a 9 or 12 V power supply. To use this power supply for the Arduino too, you need a voltage regulator which converts the voltage level and filters the noise and fluctuations created for example by that actuators.

Also keep in mind the reverse polarity protection diode that follows the barrel jack after which current goes into the 5V regulator. The diode is only rated for 1A, if one is connecting to Vin as a source for 9V or 12V for other parts of a project.


text:
Linked List based question
I am making a Smart Cart using RFID. The user will
have a RFID card. As soon as he swipes the card on
the RFID Reader it will identify the user and will create
a linked list for that particular user. The linked list will
contain the unique Rfid based Ids of the items purchased by the user. In my code
the problem is that after the detection of the user it is
not creating any linked list for the items/it is not detecting the items bought by the user. Both the user and items are identified by their unique ids (ie RFID tags).It is detecting the user but once the user is being detected it is not mapping the items bought with that user.
the code for the same is :
int count = 0; // count = 0
int i;
char input[12];                                   // character array of size 12
boolean flag = 0;
// flag =0

boolean comparetag(char x[12], char bb[12]) {
  boolean ff = false;
  int fg = 0;
  for (int cc = 0; cc < 12; cc++) {
    if (x[cc] == bb[cc]) {
      fg++;
    }
  }
  if (fg == 12) {
    ff = true;
  }
  return ff;
}

struct Node {
  char x[12];
  struct Node *next;
};

struct Node* X;
struct Node* point;

void printList(struct Node *n) {
  while (n != NULL) {
    Serial.print(n->x);
    n = n->next;
  }
}

struct Node* Shopping(char[]) {

  Serial.print(input);
  // Print RFID tag number
  Serial.print("Welcome User");
  Serial.println();

  Serial.print("Start Shopping ");

  struct Node* head = NULL;
  head = (struct Node*) malloc(sizeof(struct Node));

  return head;

}

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

void loop() {

  if (flag == 0) {
    if (Serial.available()) {
      count = 0;
      while (Serial.available() && count < 12) // Read 12 characters and store them in input array
      {
        input[count] = Serial.read();
        count++;
        delay(5);
      }

      if (comparetag(input, "1B006AFA9F14")) {
        flag = 1;

        point, X = Shopping(input);
      } else {
        Serial.println("not Registered User");
      }
    }
  } else {
    int c = 0;
    if (Serial.available()) {
      while (Serial.available() && c < 12) // Read 12 characters and store them in input array
      {
        Serial.print("Taking Input");
        X->x[c] = Serial.read();
        c++;
        delay(5);
      }
      struct Node* second = NULL;
      second = (struct Node*) malloc(sizeof(struct Node));
      second = NULL;

      X->next = second;
      X = second;

    }
  }
  printList(point);
}

your question is not related to RFID as the title suggest .... your question is about linked lists .... please update your question title

I don't see any code for making new nodes or linking them into a list. A linked-list needs a root (a known variable that points to the first member of the list); a way to make or acquire new nodes and link them onto the list as the number of items grows; and a way to unlink a node and "discard" it - return its memory - once it is no longer useful.
I'll offer a couple of suggestions for linked-lists, especially in processors like the Uno with limited memory:

Don't be tempted to use malloc() and free() or new and delete for a system that must run continuously. Allocating and deallocating small pieces of memory, especially when interspersed with other allocation & deallocations, will lead to fragmentation of the heap (that portion of memory used for allocating memory at run-time). The result is that the heap will end up with lots of separate pieces of memory that are free but too small for other allocation requests, so the heap has to acquire more memory to satisfy the larger allocations. It does this by reducing the stack space! Eventually the stack will grow into the heap space, and the program will fail.My solution is to define a global array of node structs; enough of them for the program's greatest conceivable need, plus a few more for safety; link them into a list of free nodes; and give new nodes to the application by deallocating one from the free list. A You need link() and unlink() functions for a linked-list anyway, so it takes very little more code to do this.
Because we're talking about memory limited processors, If I don't need more than 255 nodes, I link with array indices instead of pointers, saving one byte per node. This costs a little bit more code to index into an array than to de-reference a pointer but compilers have gotten pretty smart about minimizing even that overhead.


text:
How to regulate a led on-board?
There is blink project consisting 3 sections:
1 - regulation of the led brightness using a potentiometer
2 - whenever: the button is pressed - the led is on
-   the button is released - the led is off
3 - change state of a led statically
The question is that:
May I make this project on-board?
I am curious that, if I will try making this project on-board (Arduino UNO) will the Arduino damaged?

When the button is released, the led is off, but at the same time the brightness is regulated with a potentiometer. Those two things can not be done at the same time.

"making this project on-board"? what do you understand by that?

@Juraj Using just Arduino UNO board, not using extra breadboard and led. There are 11 leds like: ON, R17, R6, AX,.. and so on. As I unerstood on-board project is done just using these leds. If I am wrong, would be so glad to learn what on-board and off-board means? )))

so it should be "making this project by using on-board LED"? button or pot should not be on-board

only on-board LED controllable from the sketch is LED on pin 13. and it is not dimmable as you can read in the Answer by Kevin

there are only 4 LEDs on Uno R3. RX, TX for Serial lines, power and L on pin 13

@Juraj So we can connect a potentiometer and button to regulate the led(pin 13), right?

NO, it is not dimmable. you can turn it on and off with a button. (and the button is not on board)

If you really want to dimm the onboard LED, you can bitbang the PWM signal by setting the state of pin 13 directly in your code (changing rapidly between high and low, with a variable ratio of high to low time). But this means, that you will not be able to do much else.

@chrisl,  the LED on D13 can be dimmed using standard blink without delay coding.  Turn it on, monitor the time going by, when enough has passed then turn off the LED. Do that at a "fast enough" rate, say every 5mS, and it appear to be dimmed. For brighter, have more on-time than off-time. For dimmer, have more off-time than on-time.  The code can lots of other stuff while waiting for the time to pass for the next transition. This is basically bit-banged PWM as mentioned elsewhere.

@chrisl, good idea. I hope marvB will come back and read it. (including the end :-) )

Pin 13, which is the on-board LED, is not a pwm pin. So you cannot Control the brightness of that LED on-board. You will have to use another LED and a PWM pin.


text:
Help with AlphaNumeric array
I have a Leonardo board and I want to set up my pins to input in one shot using a for loop but the problem is with the analog pins I can't see how to set up a mixed alphanumeric array it gives me some errors.
Code:

// including keyboard.h library for the keyboard functions
#include <Keyboard.h>

// setting Arrays for looping later
   int myIntPins[12] = {2,3,4,5,6,7,8,9,10,11,12,13};
   int myChar[12] = {97, 98, 99, 100, 101,102,103,104,105,106,107,108};
  int myChar2[6] = {109,110,111,112,113,114};
 myCharPins[6] = {"A0","A1","A2","A3","A4","A5"};
  int a;
  int x;
  int i;

void setup() {
  // put your setup code here, to run once:

 //Setting up Digital Pins
for (int i=0; i <= 11; i=i+a){
  pinMode(myIntPins[i],INPUT);
  }

//pinMode(2, INPUT);
//pinMode(3, INPUT);
//pinMode(4, INPUT);
//pinMode(5, INPUT);
//pinMode(6, INPUT);
//pinMode(7, INPUT);
//pinMode(8, INPUT);
//pinMode(9, INPUT);
//pinMode(10, INPUT);
//pinMode(11, INPUT);
//pinMode(12, INPUT);
//pinMode(13, INPUT);

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------

// setting up Analog Pins to Digital
for (int x=0; x <= 5; x=x+a){
  pinMode(myCharPins[x],INPUT);
  }
//pinMode(A0,INPUT);
//pinMode(A1,INPUT);
//pinMode(A2,INPUT);
//pinMode(A3,INPUT);
//pinMode(A4,INPUT);
//pinMode(A5,INPUT);

// starting keyboard
Keyboard.begin();

}

void loop() {
  // put your main code here, to run repeatedly:

  //if pin 2 is pressed then send the a key/char
 // if (digitalRead(2) == LOW) {Keyboard.write(97);}

// instead of doing an if one by one doing a loop all in one shot
// this loop for regular digital pins
a=1;
  for (int i=0; i <= 11; i=i+a){
    if (digitalRead(myIntPins[i]) == LOW){
      Keyboard.write(myChar[i]);
      }
      }
a=1;
  // this loop for the analog pins now working as digital pins
  for (int x=0; x <= 5; x=x+a){
    if (digitalRead(myCharPins[x]) == LOW){
      Keyboard.write(myChar2[x]);
      }
      }

  delay(10);

  }

Error:
    Arduino: 1.8.7 (Windows 10), Board: "Arduino Leonardo"

Mandar_Keyboard_Key_1:10:2: error: 'myCharPins' does not name a type

  myCharPins[6] = {"A0","A1","A2","A3","A4","A5"};

  ^

C:\Users\manue\OneDrive\Documents\Arduino\Mandar_Keyboard_Key_1\Mandar_Keyboard_Key_1.ino: In function 'void setup()':

Mandar_Keyboard_Key_1:45:11: error: 'myCharPins' was not declared in this scope

   pinMode(myCharPins[x],INPUT);

           ^

C:\Users\manue\OneDrive\Documents\Arduino\Mandar_Keyboard_Key_1\Mandar_Keyboard_Key_1.ino: In function 'void loop()':

Mandar_Keyboard_Key_1:77:21: error: 'myCharPins' was not declared in this scope

     if (digitalRead(myCharPins[x]) == LOW){

                     ^

exit status 1
'myCharPins' does not name a type

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

If I change my code I to this, I get a different error.
Code:
// including keyboard.h library for the keyboard functions
#include <Keyboard.h>

// setting Arrays for looping later
   int myIntPins[12] = {2,3,4,5,6,7,8,9,10,11,12,13};
   int myChar[12] = {97, 98, 99, 100, 101,102,103,104,105,106,107,108};
  int myChar2[6] = {109,110,111,112,113,114};
  char myCharPins[6] = {"A0","A1","A2","A3","A4","A5"};
  int a;
  int x;
  int i;

void setup() {
  // put your setup code here, to run once:

 //Setting up Digital Pins
 a=1;
for (i=0; i <= 11; i+=a){pinMode(myIntPins[i],INPUT);}

//pinMode(2, INPUT);
//pinMode(3, INPUT);
//pinMode(4, INPUT);
//pinMode(5, INPUT);
//pinMode(6, INPUT);
//pinMode(7, INPUT);
//pinMode(8, INPUT);
//pinMode(9, INPUT);
//pinMode(10, INPUT);
//pinMode(11, INPUT);
//pinMode(12, INPUT);
//pinMode(13, INPUT);

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------

// setting up Analog Pins to Digital
for (x=0; x <= 5; x+=a){pinMode(myCharPins[x],INPUT);}
//pinMode(A0,INPUT);
//pinMode(A1,INPUT);
//pinMode(A2,INPUT);
//pinMode(A3,INPUT);
//pinMode(A4,INPUT);
//pinMode(A5,INPUT);

// starting keyboard
Keyboard.begin();

}

void loop() {
  // put your main code here, to run repeatedly:

  //if pin 2 is pressed then send the a key/char
 // if (digitalRead(2) == LOW) {Keyboard.write(97);}

// instead of doing an if one by one doing a loop all in one shot
// this loop for regular digital pins
for (i=0; i <= 11; i+=a){if (digitalRead(myIntPins[i]) == LOW){Keyboard.write(myChar[i]);}}

  // this loop for the analog pins now working as digital pins
  for (x=0; x <= 5; x+=a){if (digitalRead(myCharPins[x]) == LOW){Keyboard.write(myChar2[x]);}}

  delay(10);

  }

Error:
    Arduino: 1.8.7 (Windows 10), Board: "Arduino Leonardo"

Mandar_Keyboard_Key_1:10:54: error: too many initializers for 'char [6]'

   char myCharPins[6] = {"A0","A1","A2","A3","A4","A5"};

                                                      ^

exit status 1
too many initializers for 'char [6]'

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

If you show what the difference is between the two sets of code, it would be helpful

why did you think it should be string "A0"? you have pinMode(A0, INPUT), not pinMode("A0", INPUT)

@Juraj Idk I thought that int was for integer numbers and a mix of letters and and number would be a string that's all don't blame me I didn't go to school for programming it's just a hobby that I like and I'm learning you know

All of those "A1" "A2" pins have other numbers that go with them.  The A1 or A2 is #defined in the core to be some number.  You can just use A1 or A2 and it will work.
For example, try this line and see what it prints:
Serial.println(A0);

And for your pins, just put A0, A1, etc. in your int array and leave the quotes off.  Those symbols are being replaced by numbers because they're defined constants.
int myIntPins[12] = {2,3,4,5,6,7,8,9,10,11,12,13, A0, A1, A2};

That worked just fine   Thanks a lot!!!


text:
Controlling a servo motor with a touch sensor
I want to modify my code to move a servo motor only for the duration of time that the sensor is touched and stop moving immediately when the sensor is no longer touched. The code I have moves the sensor from 0 to 90 and back.  That motion is completed even when you remove your finger. I want it to be such that if you remove your finger before the servo reaches 90 degrees the servo stops.  And the servo starts up again toward 90 when touch resumes. This is the code I currently have:
//when signal output is high the sensor is being pressed

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
int pos = 0;    // variable to store the servo position
int sensor=11; //initialises component to arduino digital pins
led=13;

void setup() {
        myservo.attach(9);
        pinMode(led,OUTPUT);
        pinMode(sensor,INPUT);
        Serial.begin(9600);
}

void loop() {

        int value=digitalRead(sensor);
        if(value == HIGH){
                digitalWrite(led, HIGH);
                for (pos = 0; pos <= 90; pos += 1) {
                        myservo.write(pos);              // tell servo to go to position in
                        variable 'pos'
                                delay(15);                       // waits 15ms for the servo to reach the
                        position
                }
                for (pos = 90; pos >= 0; pos -= 1) { // goes from 90 degrees to 0 degrees
                        myservo.write(pos);              // tell servo to go to position in
                        variable 'pos'
                                delay(15);
                }
                Serial.println("TOUCHED ");
        }else{
                digitalWrite(led, LOW);

                Serial.println("NOT TOUCHED ");
                delay(500);
        }
}

You could test the button in the for loop, while the servo is moving. Bail out of the for loop with 'break' if the button is released. When you do that and add more things to the sketch, the code becomes harder to maintain. Another option is rewriting your sketch and use millis, start with the example: https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay

Leonardo, what I recommend you do is non-blocking "cooperative multitasking". Start with the "Blink Without Delay" tutorial @Jot pointed you to. I've written a few more-advanced examples here: https://stackoverflow.com/questions/50028821/best-way-to-read-from-a-sensor-that-doesnt-have-interrupt-pin-and-requires-some/50032992#50032992 and here: https://arduino.stackexchange.com/questions/75932/calculating-amp-hrs-of-a-solar-panel/75937#75937. You can study my code to see how I do it. Side note: this is the start of building a scheduler, which results eventually in a basic operating system.

To solve your problem, you need to take a tiny step into real time programming.  Most Arduino programs deal with one issue or action at a time.  Your simple twist to interrupt and action "i want it to be such that if you remove your finger before the servo reaches 90 degrees that's where the servo stops" requires you to continuously monitor your input (touch switch) while changing your output (next servo position).
You can go about this 2 ways.  You can use interrupts to inform you when the state of the touch switch changes. This is challenging.  Many find it difficult to conceive of what might happen if their program were to be interrupted at any and all possible points in its execution.  A mistake here can lead to unexpected results.
Or you could take turns polling the state of the touch switch then making a small adjustment in the position of the servo.  When the state of the touch switch changes from active to not-active, exit the loop you are using to change the servo position.


text:
Can an IC be programmed by an Arduino and then be removed, to be used in an external breadboard?
I wanted to find out if is possible to write programs into a micro controller using the Arduino and use the micro controller independent of the Arduino board?

yes ...........

Yes. The compiles code will is burned in the Arduino ROM. You can then take the Atmel chip (the Arduino microprocessor) and use it. You only need a few extra component for a chip like the 328p (Arduino Uno).

That design also needs 0.1uF caps from the VCC, AVCC, and Aref pins to Gnd.

For another example, using another method, an Uno can program another MCU without the target needing any bootloader, thus enabling your code to occupy the entire Flash memory of the target devices. Here is a link describing how to program an Attiny using an Uno and the ArduinoISP example program. An Attiny85, for example, has 8K of flash, all of which is usable by your application, using this technique. For comparison, a bootloader in an Attiny85 takes about 2.5K, or 30% of the Flash space! And it only gets worse with the smaller Attinys.


text:
Arduino DC motor with 2 buttons
I have a problem with my Arduino project and I tried everything to fix it but nothing helps.
I am trying to rotate my DC motor with two buttons:

one button is to stop/start rotating on left side, and;
the second one is for stop/start rotating on the right side.

I can't switch the states and if the motor is rotating I can't stop it. The speed is controlled by the potentiometer and works fine, just the buttons are the problem. I hope somebody can help me.
int enablePin = 11;
int in1Pin = 10;
int in2Pin = 9;
int switchPin = 7;
int switchPin1 = 6;
int potPin = 0;
int statusPin= 13;
boolean status;

void setup()
{
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(enablePin, OUTPUT);

  pinMode(switchPin, INPUT_PULLUP);
  pinMode(switchPin1, INPUT_PULLUP);

  pinMode(statusPin,OUTPUT);
  Serial.begin(9600);
}

void loop()
{
  digitalWrite(13,HIGH);

  int speed = analogRead(potPin) / 4;

  boolean reverse = digitalRead(switchPin);
  boolean reverse1 = digitalRead(switchPin1);

  if(reverse == false){
    status = true;
  }
  if(reverse1 == false){
    status == false;
  }

  setMotor(speed, status);
}

void setMotor(int speed, boolean reverse)
{
  analogWrite(enablePin, speed);

  digitalWrite(in1Pin, ! reverse);
  digitalWrite(in2Pin, reverse);
}

I just added the second button with paint, so don't get confused.

Did you try a simple sketch that rotates right and an other one that rotates left to make sure that at least that was working ?

Also format and comment your code it will be a lot easier to read.

In your code the buttons only control the direction, but are not turning the motor on or off. This is only be done with the potentiometer, which can be set to zero speed.
To really enable the motor with the buttons, you have add some logic for the enable pin. For example change the setMotor() function and give it also a boolean as parameter, which indicates the enabling of the motor:
void setMotor(int speed, boolean enabled, boolean reverse)
{
    if(enabled) analogWrite(enablePin, speed);
    else        analogWrite(enablePin, 0);
    digitalWrite(in1Pin, ! reverse);
    digitalWrite(in2Pin, reverse);
}

You can set a corresponding boolean variable in the loop() function like you did with the status variable. Set this new variable to true in both if-statement of the buttons. Alternatively you can do this inline with the setMotor() call by writing:
setMotor(speed, reverse || reverse1, status);

The || is a logical OR operation. It returns true if any of both operands are true. In a similar way you can ditch the other if-statement with the status variable:
setMotor(speed, reverse || reverse1, !reverse && reverse1);

! negates the value of reverse and && does a logical AND. You can decide yourself, if you want to use if-statements (which are a bit easier to read or these logical statements (which are more compact).

Also you should use better variable names. reverse and reverse1 are not really good to distinguish. Better would be reverse and forward.


text:
Connecting 12V WS2811 RGB LEDs to Arduino Uno & 5V Power Source (Breadboard needed?)
I have an Arduino Uno, 12V WS2811 RGB LEDs (from Mokungit), a 5V power source, and DC power connector. I do not have a breadboard and hope I don't need one.
This is almost exactly what I need to follow this tutorial to build a Stranger Things wall. The LED strip listed shares the same name as the one I have, but the wiring is different.
Here's a photo from the Instructables site:

However, the wires coming from my strip don't match up to the instructions, and I can't seem to figure out how to get these bad boys burning.

Thanks to anyone who can help me get started!

This image, from here, shows which pins are what:

Note the flat key next to the 12 V and GND pins. In addition:

the GND wire has a black broken line printed along it;
the data line is in the middle.

If you trust the image then you should be able to wire them up correctly.

That picture is for a 5 Volt rgb led strip. You have to use a 12 Volt power supply for your led and power the uno with another 5volt source. A computer power supply would be great for supplying power both 5 Volt and 12 Volt.

The signals are clear on the bulb pcb. Take a multimeter in continuity mode and probe to see which pins on the round connector is DI, GND and +12v.
Then connect DI to the arduino. +12v to the strip. GND from the Arduino, LED strip and your +12v source should all be conected together.

Do you know where in the Arduino I should connect the DI?
I don't see how I can connect the +12V to the strip. The the round connector is the only one available.

You know how to use a multimeter in continuity test mode ? You need to probe each pins on the round connector with the pins on the 1st LED PCB to see which is which.
Once you know that you will know where to connect the Arduino and your +12v.
If you don't have a matching female round connector, I would cut it and use the direct wires. Or solder wires on the 1st LED PCB.

I don't know how to use a multimeter in continuity test mode. Also, I don't think I have a PCB. I assume this is nowhere nearly as straight-forward as the wiring in the Instructables instructions, eh?

Before launching into an electronics project I really suggest that you learn the basics like using a multimeter (and buy one, even a cheap one, if you don't have one). Here is a quick 2m video on how to do a continuity test with a multi-meter: https://www.youtube.com/watch?v=OOK8np4t40c
Without this basic skill you will not be able to complete your project.

Thanks for the tip. I needed neither a multimeter nor the skills to use one in order to complete the project as it was described on the Instructables site. I should probably get one and learn how to use it, but I need to complete this today. Perhaps I won't be able to. It seems odd that having a different version of WS2811 would change the steps required so significantly.

Welcome to the world of electronics and proprietary connector pinout.
Without testing which pins is which on the round connector, you have 2 chances out of 3 of applying +12v on the wrong pin and burning your entire LED strip.


text:
Keypad giving random inputs
I have a keypad like this:
here is another, closer look at the bottom part.
Basically, I want the LED to power the amount that I pressed.
this is my code:
int LED = 1;
int inputs[4] {
  6,
  4,
  2,
  0
};
int outputs[4] {
  13,
  12,
  10,
  8
};
void outputAllBut(short int);
int numberInputCheck();
int inputCheck();

void setup() {
  for (int i = 0; i < 4; i++) {
    pinMode(outputs[i], OUTPUT);
    pinMode(inputs[i], INPUT_PULLUP);
  }
  pinMode(LED, OUTPUT);
}

void loop() {
  while (true) {
    int x = numberInputCheck();

    if (x == 500) {
      break;
    }

    delay(500);

    for (int i = 0; i < x; i++) {
      digitalWrite(LED, HIGH);
      delay(500);
      digitalWrite(LED, LOW);
      delay(300);
    }
  }
}

int numberInputCheck() {
  while (true) {
    for (int i = 0; i < 4; i++) {
      outputAllBut(i);
      for (int m = 0; m < 4; m++) {
        if (digitalRead(inputs[m]) == LOW) {
          switch (i) {
          case 0:
            if (m == 3) {
              return 500;
            } else {
              return m + 7;
            }
          case 1:
            if (m == 3) {
              return 500;
            } else {
              return m + 4;
            }
          case 2:
            if (m == 3) {
              return 500;
            } else {
              return m + 1;
            }
          case 3:
            return 500;
          }
        }
      }
    }
  }
}

void outputAllBut(short int b) {
  for (int i = 0; i < 4; i++) {
    if (i != b) {
      digitalWrite(outputs[i], HIGH);
    }
  }
}

int inputCheck() {
  for (int i = 0; i < 4; i++) {
    if (digitalRead(inputs[i]) == LOW) {
      return i;
    }
  }
  return 5;
}

for reference, the numberInputCheck function is the one that might go wrong here, I want it to wait for an input and return the number that I pressed. i is the rows and m is the columns.
My problem is that whenever I press the keypad at one of the numbers, it will give me a random amount of times that the LED turns on, there doesn't seem to be any pattern.
m+1, m+4 & m+7 is because m is my columns so if I press 0 and the row is 0 then I add 1, same goes with everything else. Can anyone help me?

Your outputAllBut function is wrong. It turns all but the specified output high, but it doesn't turn the specified output low. As a result, after calling it multiple times, you end up with all of the outputs high forever (since you don't have code anywhere else that would turn them off), so it's just a question of timing which one it considered "on" any time you press a button.
Side note: toggling the outputs between low and high to do the matrix read is dangerous, as pressing multiple buttons at a time can cause a short circuit that way. You should instead always keep all of them low, and control which one is active by setting it to output mode and the rest to input mode.

your answer helped the situation but I'm still getting mixed signals. my button 2 just pressed only once for some reason


text:
Arduino UNO + ESP8266 WiFi Relay by LC Technology
I have Arduino Uno, and recently obtained ESP8266 WiFi Relay by LC Technology. I tried to look up some information about that on the net, but all the answers / suggested solution didn't work for me. Let me briefly explain the problem.
I have connected this module to arduino in a very simple way:

TX -> pin 7
RX -> pin 6
5V -> IN +
GND -> IN -

Simple code:
#include "Arduino.h"
#include <SoftwareSerial.h>

#define TxPin 7
#define RxPin 6

SoftwareSerial ESPrelay(RxPin, TxPin);

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

    readRx();

    ESPrelay.println("AT");
    readRx();
}

void loop() {
    Serial.println(ESPrelay.read());
    // this above is constant -1
}

void readRx() {
    String msg = "";
    while (ESPrelay.available()) {
        char rxByte = ESPrelay.read();
        msg += rxByte;
    }
    Serial.println(msg);
    delay(500);
}

I can see WiFi AP created by the module - so I think module itself works fine - communication between Arduino and module is somewhat broken.
I tried all different AT commands, but none of them seems to take an effect (tried switching modes and connecting to home WiFI, but no luck) also, no response is returned. Could someone try and help me debug this issue?
I tried changing 9600 to 115200 when communicating, but no luck with this either.

Did you remove the ESP-01 from the relay board?

No, I didn't...

and how did you wire it then?

https://imgur.com/a/xoNjI62 - from the left: 1) IN+ -> 5V 2) IN- -> GND 3) RXD -> pin 6 4) TXD -> pin 7

connect everything to the pins header, not to screw terminals. the IN terminals are for powering the relay coil

I did now, and nothing has changed. Still 0 response for AT and AT+RST commands.

you should connect RX to TX.  TX to 6 and RX to 7

so the other way around than what I had? Sorry got a little bit confused. I tried connecting it the other way around and still nothing... Are you willing to hop on discord chat?  Might be easier/faster to communicate...

call read readRx in the loop(). add delay before sending "AT" in setup to let the esp8266 time to boot

I had 115200 set up before, hence was not seeing anything. Changed back to 9600 and I can see response from the module!

Serial connection requires connecting transmit TX pin to receive RX pin. Your SoftwareSerial pins ar pin 6 RX and pin 7 TX. So your wiring should be esp8266 TX to Uno pin 6 and esp8266 RX to Uno pin 7.
Connect 5 V and ground to the pins header, not to screw terminals. The IN terminals are for powering the relay coil.
Call read readRx() in the loop(). Add delay before sending "AT" in setup to let the esp8266 time to boot.