text:
How to extend gsm buffer?
Haii All,
I am using gsm SIM900A module with arduino uno. I am trying to send some data from that to server. When i am writing some commands for that, let's say i have written 3 commands before. But when i am adding one more command, it is giving me error. It seems like there's a buffer issue i.e, maybe it is getting full. So it is nto taking extra commands written on sim900A. How to solve this problem? If it a buffer issue then how should i solve it?
Thanks in advance.

you have not described the problem .... you only described what causes the problem

What error do you get? Do you receive an error code from the SIM900A? Or do you have some compiler error? You have to include the full error message and what triggered it into your question

I got the solution. My SIM900A buffer was getting full. I had to clear it after one complete cycle so that when next time loop will get started, the buffer will be empty to store new data. Thanks for your time. Thank you everyone.


text:
Second item in array not gets assigned from struct object, ArduinoJson
I got the below code generated this amazing tool.
const size_t capacity = JSON_ARRAY_SIZE(2) + JSON_OBJECT_SIZE(1) + JSON_OBJECT_SIZE(4) + 2*JSON_OBJECT_SIZE(7);
DynamicJsonDocument doc(capacity);

JsonObject config = doc.createNestedObject("config");
config["type"] = "power_plug";
config["chip_id"] = "12345";
config["mac_address"] = "abc";

JsonArray config_attachments = config.createNestedArray("attachments");

JsonObject config_attachments_0 = config_attachments.createNestedObject();
config_attachments_0["name"] = "socket";
config_attachments_0["input_type"] = "toggle_switch";
config_attachments_0["on_state"] = "on";
config_attachments_0["off_state"] = "off";
config_attachments_0["pin_type"] = "output";
config_attachments_0["pin"] = 15;
config_attachments_0["current_state"] = "on";

JsonObject config_attachments_1 = config_attachments.createNestedObject();
config_attachments_1["name"] = "socket_1";
config_attachments_1["input_type"] = "toggle_switch";
config_attachments_1["on_state"] = "on";
config_attachments_1["off_state"] = "off";
config_attachments_1["pin_type"] = "output";
config_attachments_1["pin"] = 12;
config_attachments_1["current_state"] = "off";

serializeJson(doc, Serial);

This prints out the desired json properly. but when amend single line from the second array item, to take the on_state from my struct object d_config,
Serial.println(">>" + d_configs.peripherals[1].current_state);
Serial.println(">>" + d_configs.peripherals[1].on_state);
config_attachments_1["on_state"] = d_configs.peripherals[1].on_state;

the parsing gets quiet unexpected, and some of the keys from serialised string json gets missing. For above case, This gets printed in serial monitor;
>>off
>>on
{"config":{"type":"power_plug","chip_id":"12345","mac_address":"abc","attachments":[{"name":"socket","input_type":"toggle_switch","on_state":"on","off_state":"off","pin_type":"output","pin":15,"current_state":"on"},{"name":"socket_1","input_type":"toggle_switch","on_state":"on","off_state":"off","pin_type":"output","pin":12}]}}

NOTE in the second item of attachments, the key current_state is entirely missing.
When I assign all values from this struct object, the serialised json misses many more keys... and the behaviour is quite unexpected. here is how I have defined my structs;
typedef struct Peripheral{
    String name;
    String input_type;
    String on_state;
    String off_state;
    String pin_type;
    String current_state;
    int pin;
};

typedef struct {
  String type;
  String chip_id;
  String mac_address;
  Peripheral peripherals[10];
} DeviceConfig;

I am not sure if its an issue during serialization or something else... :/
Any help would be highly appreciated :) .
UPDATE When I added three items inside attachments, then the serialized json string is missing some keys for only the last item. Seems like only the last item on the list is having problem getting serialized.

ArduinoJson stores strings differently depending on their types:

for const char*, it saves a pointer;
for other types (char*, String...) it copies the string.

Because ArduinoJson stores the copy of the string in the JsonDocument, you must increase the capacity of the JsonDocument.
In your case, you pass Peripheral::current_state, which is a String, so ArduinoJson makes a copy in the JsonDocument. Increasing capacity by a few bytes should solve the problem.
Note that the ArduinoJson Assistant also computes the number of bytes required to store all the strings. Look for "Additional bytes for strings duplication" on the right panel.

source: Stack Exchange

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

sort: votes


text:
Can an arduino Uno control led, sound and smoke?
I'm pretty new to this and I've not seen anyone answer this question yet - so I figured I would ask.
I have a vape mod that is set up to expel smoke with a trigger. I want to merge this trigger to the arduino so that the arduino can then have 2 single buttons. One would trigger a specific led set (8 LEDS), the vape mod, and sound through 2 external speakers for about 5 seconds. I'd like the second button would trigger another specific LED set (8), vape mod and sound (through two external speakers) for 3 seconds. I have acquired a 555 chip, which I've researched can control the timing of the triggers yet can't find anything about how much power is needed for these types of things.
If I'm able to have the LEDs, Sound, and Vape mod separately how do I combine these to control them all with a single push of a trigger?
However, again, the main thing I'm wanting to know is if an Arduino Uno can trigger all of these devices at a single time or if it would drain too much power?
Any help is truly appreciated! Also, if there is anything that you think I need to take into consideration that I haven't already - feel free to make suggestions. Like I said, I'm just starting out and I know I should start with simpler projects but I'm just really interested in whether or not this can be done.
All the best,

the arduino can most likely do all of that ... it is impossible to guess for sure because you have provided almost no information about the devices

An Arduino is a microcontroller. It can do all the logic for your project, including the timing. You won't need a 555 timer. However, the Arduino does not output enough current to drive an 8-LED strip or a smoke machine directly. You'll need an external power supply with enough current to drive those things, and will need to rig transistors to switch the power to those things on and off. A high current MOSFET transistor works very well for most DC applications.

If the load is inductive like a motor or relay, you'll likely need a "flyback diode" to protect the transistor from being fried by the surge of reverse current (back EMF) from the inductor. See this link: https://en.wikipedia.org/wiki/Flyback_diode

You'll need to post a lot more details if you want concrete help.

The arduino has more than enough processing power to manage those tasks mentioned. You probably won't need that 555. Playing music is possible as long as the arduino doesn't have to process the file itself. But switching on an external player is no problem (with what so ever circuitry).
The electrical power is another story, you probably will need extra power-supplies, but nobody can say without knowing your exact setup.

Thank you. I apologize.  Everything was delivered today. I can include the set up equipment once I get home. I appreciate the replies.

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


text:
24/14 second countdown timer or shot clock for basket ball start/stop button doesn't respond well
Start button doesn't respond correctly, i can't figure out whats wrong with the code ? pls help,
this code is for 24 second and 14 second countdown timers in a same unit
comes with three physical push buttons

start/pause
reset
shift (Arduino pin 8 as shift button)

both 1 and 2 uses arduino pin 2 and 3 for interrupts,
by pressing reset counter sets for 24 second timer and shift+reset will set the timer for 14 seconds and by pressing start button will start the countdown and press again will pause the timer,
to display it uses two seven segment displays with 74LS47 Binery code decoder
here is the code
//Declaring and Initializing Variables
int p4 = 4;
int p5 = 5;
int p6 = 6;
int p7 = 7;
int p9 = 9;
int p10 = 10;
int Buzzer = 12;
boolean Standby = true;
unsigned long newTime, oldTime = 0;
const long timeDelay = 1000;
volatile int Num1 = 0;
volatile int Num2 = 0;
volatile int Zero = 0;
volatile byte Press = 0;
volatile boolean Ready = false;
volatile boolean Shifter = false;
volatile int Shift = 8;

void setup() {
  pinMode(Shift, INPUT);//Shift pin button
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);

  pinMode(9, OUTPUT);//FirstDigit
  pinMode(10, OUTPUT);//SecondDigit

  pinMode(12, OUTPUT);//Buzzer
  attachInterrupt(0, Starting, HIGH);
  attachInterrupt(1, ReStarting, RISING);
  digitalWrite(12, LOW); //Set it LOW first
}

void refresh() {
  SecondDigit();
  FirstDigit();
}

void Starting() {
  //Running and Stopping here
  if (Ready == false) {
    Press = 0;
  }

  Press++;
  if (Press >= 4) Press = 2;
} //End of Starting

void ReStarting() {
  //Restart sequence
  Zero = 0;
  if (Press == 0) {
    Num2 = 2;
    Num1 = 4;
    Ready = true;
    Press = 1;

  }

  if (digitalRead(Shift) == HIGH) Shifter = true;

  if (Shifter == false) {
    if (Zero == 3)Press = 1;
    Num1 = 4;
    Num2 = 2;
    Zero = 0;
    Ready = true;
    Press = Press;
  }
  else {
    if (Press == 2) {
      if ((Num1 + (Num2 * 10)) < 14) {
        Num1 = 4;
        Num2 = 1;
        Zero = 1;
        Ready = true;
        Press = 2;
      }
    }
    else {
      if (Press == 1 || Press == 3) {
        //Uncomment the next line to disable the 14 seconds reset if time is greater than 14 seconds
        if ((Num1 + (Num2 * 10)) < 14) {
          Num1 = 4;
          Num2 = 1;
          Zero = 1;
          Ready = true;
          Press = 1;
        }
      }
    }
  }
}//End of ReStarting

void Display() {
  if (Press == 2) {
    if (Zero <= 3) {
      Num1--;
      if (Num1 == 0)Zero++;
      if (Num1 == -1) {
        Num1 = 9;
        if (Num2 > 0)Num2--;

      }
    }
  }
  for (int Transition = 0; Transition < 500; Transition++) {
    FirstDigit();
    SecondDigit();
    if (Ready == true) {

      if (Zero == 3)BuzzMaker();
    }
  }
} //End of Display

void FirstDigit() {
  //Display 4 BCD digits of Number in First LED Segment
  digitalWrite(10, LOW);
  digitalWrite(9, HIGH);
  if (digitalRead(Shift) == HIGH) Shifter = true;
  digitalWrite(4, bitRead(Num1, 0));
  digitalWrite(5, bitRead(Num1, 1));
  digitalWrite(6, bitRead(Num1, 2));
  digitalWrite(7, bitRead(Num1, 3));
  delay(1);
  Shifter = false;
} //End of FirstDigit

void SecondDigit() {
  //Display 4 BCD digits of Number in Second LED Segment
  digitalWrite(9, LOW);
  digitalWrite(10, HIGH);
  if (digitalRead(Shift) == HIGH) Shifter = true;
  digitalWrite(4, bitRead(Num2, 0));
  digitalWrite(5, bitRead(Num2, 1));
  digitalWrite(6, bitRead(Num2, 2));
  digitalWrite(7, bitRead(Num2, 3));
  delay(1);
  Shifter = false;
} //End of SecondDigit

void BuzzMaker() {
  //Configuring Buzzer frequency and setting go with the counting numerals
  digitalWrite(9, HIGH);
  digitalWrite(10, HIGH);
  digitalWrite(12, HIGH);

  delay(1000);
  digitalWrite(12, LOW);
  delay(200);
  digitalWrite(12, HIGH);

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

  Press = 2;
  Zero = 0;
  Ready = true;
  Shifter = false;
}//End of BuzzMaker

void loop() {
  if (Press == 0)refresh;
  refresh();
  newTime = millis();
  if ((newTime - oldTime) >= timeDelay) {
    oldTime = newTime;

    if (Num2 == 0 && Num1 == 0 && Press == 2) {

      Press = 1;
    }

    //Here we are going to access each case with each different routine by case
    switch (Press) {

      case 0://Initial

        Display();
        break;

      case 1://Stop - Displaying 24 but still not yet running

        Display();
        break;

      case 2://Running

        Display();
        // PlayTime();
        break;

    }
  }//End of millis() condition

} //End of main loop function

What do you mean by "doesn't respond correctly"? Can you tell us what it's doing and what it should be doing?

Without going through your (messy) code: have you debounced the button?

i am apologizing for my indentations... doesn't respond means at the first when i press start button it starts at once then i press again it wont pause i have to press start two or three times to pause it the again to start same sometimes it respond quickly some times not at all

one of the person from a forum told me to add a debounce which i dont know how to add... i already add a physical debounce using diode capacitor and resistor which gives some clearing up but still the start button response isn't smooth

In the Arduino IDE there is a "Auto format" key kombo, Crtl + T that will fix the formatting of the code.


text:
Checking Specific Brand SIM card Type Available in GSM module
Can I program a GSM module to accept a specific type of Sim card to be ready by the module? If so please post something that can give me an Idea of how do it. Generally I want to lock the GSM module to accept a given brand of sim card to be detected in the Module but I do not know if its possible. I will be glad for any help offered by anyone on the platform. I will be glad for any help

write the software to work only with certain SIM cards

How can I do that? maybe provide a link were I could get some insight on how its supposed to be done


text:
Delayed response from web server
I am trying to implement a web server in ESP8266 that will handle simple HTTP GET requests by initiating an operation (e.g. move a stepper motor to the requested position) and return a response when the operation is finished (i.e. when the motor has reached the target position). This may take a few seconds, but during that time  the main loop should run normally so that both the TCP stack can work and the stepper library can actually move the motor (it works in the background). This means I cannot wait for the operation to complete within the handler. I have to start the operation in the handler, return without sending back a response and when the operation is done (i can poll for that in the main loop) then send the response.
I have been looking at https://github.com/me-no-dev/ESPAsyncWebServer but I'm not sure if such a scenario is supported. Has anynone done anything similar? Is it even possible?
One solution I was thinking was to store the request in a global variable (or queue) before exiting the handler and use it when the operation finishes. But will the request survive outside of the handler? And is it even possible to send the response outside the handler?

Without knowing too much about this, it sounds like a bad idea to delay the actual response to the GET request. A client with a too short timeout might think, that the connection was lost. It may be feasible for you to just poll the ESP from the client for the status of the operation, to get the information if it was finished

Granted, this is not a good design, but since this is what the client expects and I have no control of the client, I am looking at how to implement the requirement

if you are using a webpage to interact with the server, then put a timer into the webpage for auto refresh ... i think that using ajax may also do the job (I'm not sure though)

I'm thinking of going a completely different direction. Dump the client and make my own. Then I have full control and I can do any polling or even use websockets to send events from ESP


text:
What kind of USB cable do I need for my Arduino NANO 33 BLE W/ HEADERS?
I have recently purchased an Arduino Nano from the main site, but it did not come with a USB cable for programming it. I have also checked out the Arduino site and there was no reference for what type of cable I needed. I saw that there was a USB 2.0 CABLE TYPE A/B on the site but I'm not sure that it is the one that I require.
Does anyone know which cable I should buy? Thank you in advance!
Edit: To clarify, I checked out the Arduino Store https://store.arduino.cc/usa/

what is main site? .... we have no idea what you bought ... please provide a link or a picture ....  check this out https://www.cablestogo.com/learning/connector-guides/usb

On Arduino.cc Store I see a Micro USB port on the image


text:
Weird Arduino Code Problem
I'm currently getting started with Arduino, so I do not have very much knowledge.
In this project I have a receiver and a transmitter with 2 buttons.
So, I'd like to switch something to on, when I press the A button. If A is pressed longer I'd like something else to happen.
Same thing goes on with the B button, but for some reasons, when I long press A, then B gets triggered and I have no clue why...
Btw. this code is not purely made by me, but copied and edited for my use.
If anyone could help me I'd be very happy :)
code:
//ButtonAEvents

long prevA = 0;
long prevB = 0;
int buttonStateA = 0; // 0 = not pressed   --- 1 = long pressed --- 2 short pressed
int buttonStateB = 0; // 0 = not pressed   --- 1 = long pressed --- 2 short pressed
int ButtonAPin = 2;
int ButtonBPin = 3;
int DURATION_A_IN_MILLIS = 1000;
int DURATION_B_IN_MILLIS = 1000;

//ONE TIME SETUP

void setup()
{
    pinMode(ButtonAPin, INPUT);
    pinMode(ButtonBPin, INPUT);
    Serial.begin(9600);
}

//LOOP BEGIN

void loop()
{

    //BUTTON A CHECK
    buttonStateA = 0;
    if (digitalRead(ButtonAPin)) {
        prevA = millis();
        buttonStateA = 1;
        while ((millis() - prevA) <= DURATION_A_IN_MILLIS) {
            if (!(digitalRead(ButtonAPin))) {
                buttonStateA = 2;
                break;
            }
        }
    }

    if (!buttonStateA) {
        // Nothin pressed
    }
    else if (buttonStateA == 1) {
        //LONG PRESS

        Serial.println("LongpressA");
        digitalWrite(A1, HIGH);
        delay(100);
    }
    else if (buttonStateA == 2) {
        //SHORT PRESS
        digitalWrite(A1, HIGH);
        Serial.println("ShortpressA");
        delay(100);
    }

    //BUTTON B CHECK
    buttonStateB = 0;
    if (digitalRead(ButtonBPin)) {
        prevB = millis();
        buttonStateB = 1;
        while ((millis() - prevB) <= DURATION_B_IN_MILLIS) {
            if (!(digitalRead(ButtonBPin))) {
                buttonStateB = 2;
                break;
            }
        }
    }

    if (!buttonStateB) {
        // Nothin pressed
    }
    else if (buttonStateB == 1) {
        //SHORT PRESS

        Serial.println("LongpressB");
        delay(100);
    }
    else if (buttonStateB == 2) {
        //LONG PRESS
        digitalWrite(A1, LOW);
        Serial.println("ShortpressB");
        delay(100);
    }
}

All no reasons for your problem, so that's why this is a comment: you switched the words LongpressB and ShortpressB in the serial print statements, also it is adviced not to use the ! operator for integer (use buttonStateB == 0), or even better in your case a switch statement.

upvote for well written question

What are your hardware connections? The button pins are assumed to be HIGH when pressed and LOW when not pressed. You also do not use pullups/downs, so that must be external.

I tested your code on my Arduino Uno with 2 buttons which go LOW when pressed and are pulled up externally, inverted the logic in the digitalRead() in the code and it works as expected. If pressing one button triggers the other one, I'd search for a fault in your hardware setup (crosstalk, accidentally bridged, wrong button polarity,..) Also signal bouncing can be an issue (and can be suppressed with capacitors)

Thanks for your fast answers everyone!
I changed the positions of the pins and made sure, that they are not bridged, sadly the issue still exists. Should I maybe use a resistor between the receiver and the arduino? regards

Could you edit your question and add a circuit diagram drawn on paper or using the circuit tool in the question edit menu so that we can all see your hardware connections without confusion / assuming something?

Hi again, I tried using the circuit diagram function, but I'm not very familiar with the symbols and electronics behind it, so I drew it in Photoshop, I hope it's understandable tho, sorry again...
http://prntscr.com/p7vc8m

Please edit your post to including that picture and the datasheet of RO2A sc2272 chip

Not sure if this is just an academic exercise on your part to learn (which is totally cool), but if you're just trying to move forward and get something working you may consider one of the many excellent button libraries out there for Arduino.
I recently used a library called ButtonKing that allowed me to do some very sophisticated menu interactions on a MKR1010 with a display and single button interface.  There are several other libraries out there as well that take care of debouncing, long clicks, double clicks, etc.


text:
Feeding microcontroller and linear actuators (motors) with the same power supply
I have already made a diagram using a motor controller. I want to use only one power supply to feed arduino and motors. I want to use MDD10 dual motor driver.
The details of the actuators each one is:
Input voltage: 12VDC,
Max Load: 750N(168.607lbs),
Stroke Length: 16 inch,
Travel Speed: 12mm/s,
Duty Cyle: 25%,
Current: 5A.
The power supply is 12V, 10A.
Could you please check if it is ok, or which would be the best solution?
Some of my concerns are:
Be sure if the feed of 12 volts for the motors, and 5 volts for Arduino are correct and can live together as shown.
Be sure if the wiring for the Arduino, driver and motors is correct since it looks kind of simple.

I want to know if this is the natural approach by doing it with a voltage regulator to feed the Arduino and with 12V 10A power supply to feed the motors, or if there are other, better options to make the circuit feed only using one power supply (12V, 10A).
MDD10 Datasheet Link: https://www.robotshop.com/media/files/content/c/cyt/pdf/cytron-10a-7-30v-dual-channel-dc-motor-driver-shield-datasheet.pdf
Thanks in advance
UPDATE
I have increased power supply to 13A, also changed the linear voltage regulator (7805) to a switching voltage regulator (OKI-78SR-5), what do you think about this approach?

Or I should try with the 12V DC Vin of Arduino(I understand that it works with a linear voltage regulator)? Being this option, it could be maybe with a voltage pre-regulation stage(for example from 12V to 9V) or maybe connecting directly to the jack.

Thanks, Best Regards.

First of all I would look to see if the two motors will actually run at the same time.
If not then the 10A power supply, is fine.
If they do run together, for how long? (you mention 25% duty cycle), power supplies usually have a over capability for a short period of time, and batteries will supply more current but at a slightly reduced voltage, so if going slightly slower isn't an issue then this would be fine.
Then there is the question of do they really use all 5Amps, I very much suspect not, unless you are fully loading the actuator(750N), they prob run at 2-3 amps at most.
Secondly
Circuit protection, fuses or thermal shutdown links for the motors is required, better still instant overcurrent protection for them set at 1.2x nominal current.
Do some worst case tests and measure the current, set the protection to 1.2 x this.
Remember if there is an issue the supply voltage will start to drop, its now that the micro will suffer if the voltage dips too much and you have no protection/sensing.
So suspect the power supply is more than ok.

Your approach looks reasonable, but you don't have enough power. The motors will draw 10A, which is the full output of your power supply/battery. That doesn't leave any left over for your Arduino system.
You should have a high enough capacity power supply/battery for your total peak power requirement plus a little margin (say 10%-20%) The Arduino and all the other electronics on it might draw another 1/2 amp, so 10.5 total. Add 20% margin to that and you get 10.5 * 1.2, or about 12.6 A.
(When you drive a power supply up to its upper limit its output voltage can start to sag. By having a buffer it doesn't have to work as hard.)
One advantage you have in your circuit is that you're feeding unregulated 12V to your motors, and then feeding 12 into your Arduino's voltage regulator. That way even if the 12V supply droops to 10V under maximum load, the voltage regulator will still be able to maintain a clean 5V supply to your MCU.
Also note that you could feed 12V into the Arduino's V in and use its built-in voltage regulator. As long as don't draw a lot of current out of its 5V line the built-in regulator could manage the 5V voltage regulation itself. If you need ≥500 mA, though, you might want to use an external buck converter (or a high capacity linear regulator with a good heat sink.)

Hello Duncan C. So what I understand is that the circuit I show could connect it directly to the 12-volt arduino jack because I don't need much current. And only If I need more current for an extra element that is connected to arduino output, I would need a buck converter or high capacity linear regulator to increase amperage. Did I understand correctly? Could you give an example when I need a buck converter, What exactly is a buck converter/high capacity linear regulator? Thanks

The Arduino uses a linear voltage regulator. A linear voltage regulator is an analog circuit that uses a transistor to apply a variable resistance to the input voltage to lower it down to the output voltage. It converts the excess voltage to heat, so at high source voltages and current loads it gets hot. A buck converter is a type of switching power supply that instead uses pulses of current to regulate the output voltage. Buck converters are more efficient, and don't create as much heat at high current loads.

If you're just powering an Arduino and a few components, you won't be using much current, so the built-in linear power supply in the Arduino will be fine. If you need ≥500mA of 5V, the Arduino's power supply will start to get hot, and as you get up to 1A, it may even overheat when fed from a 12V supply.

Hey @Duncan, Greetings. I have updated my question. I changed the schematic by adding a switching regulator, instead of the linear regulator. I am also referring to the option to connect directly to the 12V jack of arduino. Could you please check it? Thanks

Same problem. You don't have enough power. You want your power supply to provide a little MORE current than your max need, and your 10A supply is less, not more. Boost the battery/power supply to ≈13A and you should be good.

Hello @Duncan,  I made another update. I have already changed the current of the power supply to 13A. I also added a schematic for using Vin pin of Arduino as another second option. Could you please chek the two options, and tell me which one you think is better. Thanks


text:
How to implement server.on() without any libraries?
I was trying to setup a web server with Arduino and ESP32, without using the ESP32 libraries.
Currently I'm able to display a webpage(a form with single submit button) from the server, with only using AT commands.
But how can I receive GET/POST requests send buy the form fields?
In the WebServer.h library this is done by the method
    server.on("/actionPage", HTTP_GET, []() {
        server.sendHeader("Connection", "close");
        server.send(200, "text/html", "This is actionPage");
    })

I was wondering if there is a way to do this without libraries, I searched a lot, but didn't found a solution for this..
Thanks in advance!

Why, in gods name, would you choose to cripple an ESP32 with AT commands? You are currently using a Fiat Panda to tow a Lamborghini, in which you have placed a toddler to control it. Crazy, man...

@Majenko, it may be crazy, but is it doable?

Sure, it's doable. You just need to send the right AT commands to perform the task you need to do. Personally I wouldn't, but you do you m8.

@Majenko, I was just studying how the AT commands are used to configure a web server, and there are a lot of examples are available showing how to send GET/POST request from a local server to the ESP, But didn't found one regarding  how to receive GET/POST request from a client!!

just curious about how these things are done with AT commands..Even didn't know where these AT commands are stored in arduino libraries. It would be extremely helpful if you guys could give me any information regarding this, Thanks!

Until you raised the question, I didn't even know there was AT firmware for the ESP32. I have no idea how they chose to implement it. What does the manual for the AT firmware say?


text:
How to use void swap with multi-dimensional array to control motor with openCR board
i am a beginner.
About my problem, there is an "invalid conversion' error in the swap(goal_positionall)
#include <DynamixelWorkbench.h>

#define Device_Name ""
#define BAUDRATE 57600
#define DXL_ID_1  1
#define DXL_ID_2  2
#define DXL_ID_3  3
#define DXL_ID_4  4
#define DXL_ID_5  5
DynamixelWorkbench dxl_wb;

int32_t goal_positionall[3][5] ={{0, 1024, 2048, 3072, 4080},
                                 {0,1000,0,3000,0},
                                 {1000,1000,500,700,2048}};

const uint8_t handler_index = 0;

    void setup()
    {
      Serial.begin(57600);
      while(!Serial);

      const char *log;
      bool result = false;

      uint16_t model_number = 0;
      uint8_t dxl_id[5] = {DXL_ID_1, DXL_ID_2, DXL_ID_3, DXL_ID_4,DXL_ID_5};

      result = dxl_wb.init(Device_Name, BAUDRATE, &log); //To initialize the
motor
      if (result == false)
      {
        Serial.println(log);
        Serial.println("Failed to init");
      }
      else
      {
        Serial.print("Succeeded to init : ");
        Serial.println(BAUDRATE);
      }

      for (int X = 0; X < 5; X++) //To do the actions 5 time
      {
        result = dxl_wb.ping(dxl_id[X], &model_number, &log); //Ping the 5 motors
        if (result == false)
        {
          Serial.println(log);
          Serial.println("Failed to ping");
        }
        else
        {
          Serial.println("Succeeded to ping");
          Serial.print("id : ");
          Serial.print(dxl_id[X]);
          Serial.print(" model_number : ");
          Serial.println(model_number);
        }

        result = dxl_wb.jointMode(dxl_id[X], 0, 0, &log);  //Change joint mode for 5 motors
        if (result == false)
        {
          Serial.println(log);
          Serial.println("Failed to change joint mode");
        }
        else
        {
          Serial.println("Succeed to change joint mode");
        }
      }

      result = dxl_wb.addSyncWriteHandler(dxl_id[0], "Goal_Position", &log); //Add Sync write handler
      if (result == false)
      {
        Serial.println(log);
        Serial.println("Failed to add sync write handler");
      }

    }

    void loop()
    {
      const char *log;
      bool result = false;

      result = dxl_wb.syncWrite(handler_index, &goal_positionall[0][0], &log);
      if (result == false)
      {
        Serial.println(log);
        Serial.println("Failed to sync write position");
      }

      delay(1000);

      swap(goal_positionall);
    }

void swap (  int32_t **array[][5] )
    {
      int32_t tmp = array[0][5];
      array[0][5] = array[1][5];
      array[1][5] = array[2][5];
      array[2][5] = tmp;

    }

please format your code ... select the code and click the {} button

No wonder, the int32_t **array[][5] means int32_t *** array[5], so you're passing 2 dimensional array into the 4 dimensional parameter.

what should i do to avoid this?

Either fully define the size of the 2 dimensional array or don't specify the size at all


text:
about required memory size in ATmega32 to execute a certain program
If I want to add two numbers and print the output on LCD
char answer[8];
float a=5.1,b=3.2,c;
c=a+b;
 dtostrf(c,8,3,answer);//convert float to ASCII to print it on LCD
for(i=0;i<8;i++) Lcd8_Write_Char(answer[i]);

What is the required memory space to execute this program?

You can't execute that program. It's incomplete. Also it's not easy to second guess the optimizer in the compiler. All I can say is "at least 8 plus whatever i needs and maybe a b and c if they don't get optimized out".  So between 8 and 24 bytes plus anything else the rest of the program will need.

You can easily find out the size of a program and the needed RAM, by writing a full program (with void setup() and void loop()) and compile it in the Arduino IDE. It will tell you, what you want to know

@chrisl afaik local variables and stack size are not taken into account while compiling, so one needs to use the SRAM size mentioned by the compiler + the maximum amount / deepest stack flow arguments usage + local variables.

You can use the utility freeRAM https://playground.arduino.cc/Code/AvailableMemory/ to check what the compilation can't tell you. Besides, your variable answeris too small by 1 (the trailing \0 )


text:
Stream video from camera to mobile and send control signal back from mobile to Arduino via WiFi
I want to make an Ardunio based project in which I want to stream live video from camera (which is connected to Arduino borad ) to my Android app via WiFi and send back actions/control signals from my android app to Arduino to controller servo motor which are connected to Arduino board. Right now I only have Arduino mega with me. What else components are going to be required?

Most Arduino platforms (there are many) can not handle video.  There is simply too much data. A quick internet search find this talked about many times.  Here for instance.  Where the discussion quickly elevates to a more powerful platform such as a Raspberry Pi.

Nope, a Mega is not up to the task. It may be possible with an ESP directly, but it will be way easier with a Raspberry Pi (for example the Zero W, which is quite small)

you can use independent WiFi IP camera for the live video

I had heard of esp32 cam which is suitable for live video streaming to mobile buy can we control servo motor from that.

You need good MPU with enough buffer size and nand size for such an intense process
Search esp modules
Thanks.

What do you mean by the distingtion between buffer size and NAND size? Also: can you provide a bit more information about how it would look like with an ESP?


text:
Trying to get pseudorange data out of NS-RAW GPS
I have an NS-RAW CPGPS and I am trying to get GPS Data using an arduino. Do I just use the serial to get the data out of it and just convert and extract the data to what I need?

yes, that is correct

so i looked at the document for the data, how would you convert it? http://navspark.mybigcommerce.com/content/AN0030_1.4.35.pdf


text:
How to add indicator lights to button sketch
I would like to add leds to each button switch in the first code, The first code sends midi messages to a DAW I would like it to also turn on a led as an indicator light. The switch needs to turn the light on if off and off if on. The second code is an example that does this, it works well with one button. I would like to have the 3 buttons on pins 0, 1, 2 and the leds on pins 3, 4, and 5.

#include <Bounce.h>

const int channel = 1;
Bounce button0 = Bounce(0, 5);
Bounce button1 = Bounce(1, 5);
Bounce button2 = Bounce(2, 5);

void setup() {
  pinMode(0, INPUT_PULLUP);
  pinMode(1, INPUT_PULLUP);
  pinMode(2, INPUT_PULLUP);
}
void loop() {
  button0.update();
  button1.update();
  button2.update();

  if (button0.fallingEdge()) {
    usbMIDI.sendNoteOn(60, 99, channel);  // 60 = C4
  }
  if (button1.fallingEdge()) {
    usbMIDI.sendNoteOn(61, 99, channel);  // 61 = C#4
  }
  if (button2.fallingEdge()) {
    usbMIDI.sendNoteOn(62, 99, channel);  // 62 = D4
  }

  if (button0.risingEdge()) {
    usbMIDI.sendNoteOff(60, 0, channel);// 60 = C4
  }
  if (button1.risingEdge()) {
    usbMIDI.sendNoteOff(61, 0, channel);  // 61 = C#4
  }
  if (button2.risingEdge()) {
    usbMIDI.sendNoteOff(62, 0, channel);  // 62 = D4
  }
  while (usbMIDI.read()) {
  }
}

Second sketch:
/*********************
Simple toggle switch
Created by: P.Agiakatsikas
*********************/

int button = 0;
int led = 13;
int status = false;

void setup(){
  pinMode(led, OUTPUT);
  pinMode(button, INPUT_PULLUP); // set the internal pull up resistor, unpressed button is HIGH
}

void loop(){
//a) if the button is not pressed the false status is reversed by !status and the LED turns on
//b) if the button is pressed the true status is reveresed by !status and the LED turns off

if (digitalRead(button) == true) {
  status = !status;
  digitalWrite(led, status);
} while(digitalRead(button) == true);
  delay(50); // keeps a small delay
}

Your "Simple toggle switch" code toggles the button status on/off on each button press. Your MIDI sketch is more like an organ key, where the note plays as long as the key is held down, and stops playing when the button is released. Do you want the LEDs to toggle on/off on each button press even though that is not how the MIDI note behaves?

This is not a code writing service. You should attempt to edit your code yourself, and post questions if you have trouble.

The midi sketch is used to to switch things on or off not for playing notes, I don't know why but this is the only sketch I found that works. I have tried to change the note on/off  to cc messages but it does not work. The midi sketch will turn on a parameter in Ableton (for example) the record function and and it will stay on until pressed again. which is exactly what I need the lights to do. I am not asking anybody to wright the complete code for me Just an example how to do it.

I'd suggest creating an array of MIDI button structs. For each entry you'd have a button object, an LED pin, and a BOOL to track the state of thate button.
Write a function that loops through the array of structs, checks the state of each one, and does the work to play/stop the notes and toggle the LED states based on the state of each button.


text:
How to upload already compiled code when no changes were made?
How do I use the Arduino IDE to upload the last compiled code? I don't want to have to wait 2 minutes to upload compiled code when there are no changes. It's a big codebase, where I frequently make one or two small changes and have some issue with my MCU or USB cables. Frequently the controller on my boards are damaged due to some overcurrent issue because of the high-heat nature of 3D printing. Having to wait an extra 2-5 minutes every time I experiment with this is unacceptable.
Obviously, there is a keyboard shortcut to do this that I'm unaware of, because otherwise  this would add hours to development.
Please tell me how I can get the Arduino IDE to just 'upload without compiling' my sketch.

What version of the Arduino IDE are you using? It used to be rubbish, but later versions have better caching of compiled code.  Alternatively UECIDE has far better caching than the Arduino IDE and recompilation is a lot faster because of that.

you can find the compile bin file in your temp folder, then use a different upload tool (or OTA) to send it out.

@Majenko: the link above to UECIDE doesn't seem to point to where it is supposed to point; maybe replace with https://github.com/UECIDE/UECIDE ?

You can upload hex file to your board from command line without Arduino IDE.
To get the hex file, use in Arduino IDE in menu the command "Export compiled binary". It will save the hex file next to the ino file.
I assume your board in printer has AVR MCU. Then you can use avrdude from command line to upload the hex file again and again without any compilation.
The avrdude command on Windows is (if started from the sketch's folder):
%LOCALAPPDATA%\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -C%LOCALAPPDATA%\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega328p -carduino -PCOM11 -b115200 -D -Uflash:w:Blink.ino.hex:i

The command line is for the Blink sketch and for AVC boards package 1.6.21

This is what I have done.  In the arduino IDE settings panel, turn on the "Show verbose output during compile and upload". This way whenever you are doing verify and upload you can see all the command that Arduino has performed. Now after you hit Verify or Upload it, you can copy the last command before the upload, such as
"/Users/fang/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude" "-C/Users/fang/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega32u4 -cavr109 "-P/dev/cu.usbmodem21101" -b57600 -D "-Uflash:w:/private/var/folders/xb/4609zdjx4tn3bv_6jh2nym_r0000gn/T/arduino/sketches/7972D54945A751059BF3114D2057C2B6/sketch_aug4c.ino.hex:i"
Now, when you need to upload without compiling again, just paste this line to the Terminal, it'll do the rest for you. Essentially you can see Arduino IDE is just a wrapper around these commands.
Update:
I also found another way which is kinda of different but more effective. If you happen to use Visual Studio Code, you can also try the PlatformIO plugin which can compile and upload code separately, I wrote an article about it here, https://windmaomao.medium.com/use-platformio-to-write-arduino-code-3c957c4e58b5


text:
Are there any standard ways of reporting a runtime error?
I'm new to Arduino but I'm an experienced programmer. I'm wondering if there are any common functions for reporting errors in Arduino programs? For example, in JavaScript we have the alert() function, or on Unix you can write a message to standard error and exit.
Ideally, if the serial port is available then an error message would be printed there, or if there is an LED then maybe we should blink it. This would need to be configurable based on what the programmer wants to do with available hardware.
Looking the example sketches, error reporting seems pretty horrible. I'm wondering if any libraries handle this better?

How you report an error depends entirely on what communication channels you have available and what kind of error reporting is appropriate for your design. There can be no "standard" since every design is different. Welcome to the embedded world. When you have no OS and no screen and keyboard you have to make do with what resources you have.

I myself have resorted to blinking an LED with morse code to indicate different error conditions.

I don't see any reason why there couldn't be a standard macro call that libraries use to set an error condition. (The default implementation could be a no-op.) I guess it doesn't exist, though?

As pointed out by Majenko in a comment, you can hardly define a standard
facility for error reporting when you don't know what kind of I/O
hardware will be available on any particular project. Printing to the
serial port is the most common method though, as it tends to always be
available during the development phase, while the Arduino is tethered to
the development computer. I personally tend to just do something like
Serial.println(F("Error: the warp field coil is busted."));

and be consistent with the error prefix, so that a program receiving
this can tell it's an error by matching the line against /^Error: /.
While it is OK for user code, reporting errors through Serial is
certainly not a good practice for library code. Alas, it is done way
too often in Arduino libraries. I've seen at least one library (don't
remember which one) that allows the user to provide a reference to a
Print object (defaulting to Serial) to be used for this purpose.
This is way better, as it allows the user to handle the error messages
any way she chooses. It is also very easy to turn off the error
reporting altogether by implementing a do-nothing Print, which would
be a /dev/null of sorts.
Note that the avr-libc allows you to print to stderr, as long
as you have first implemented stderr->put... While this method is the
closest you can get to the standards you are used to, it may not be
portable to non-AVR Arduinos. And it is worth noting that we tend to
avoid the printf() family of functions on Arduinos, as they tend to be
quite large compared to the print() and println() methods.


text:
Serial data printing slowly
I have connected an arduino serial port to my PC and monitoring the output in realterm. I am trying to print:
CR
11.98,123,3520,01CRLF
But it is resulting with some delay. First
CR
1
Is printed. After sometime, say 0.25sec, the rest of the data (1.98,123,3520,01CRLF) is received. Finally its shown like
CR
11.98,123,3520,01CRLF
Why is there a delay between CR1 and the rest of the characters when printing using a single serial print!?
Serial.print("\r11.98," +string1+","+string2+",01"\r\n);
string1 & string2 hold data values from 2 separate sensors.

I will receive sensor values and calculate and store them in the names of string1 & string2. Because the data that i am displaying are in diff data types. So i save them as string and display

Please include a full working example, that shows this problem in your question.

Please don't try and concatenate Strings and string literals. It's just nasty. Really nasty. Just print each portion separately.

For your information, i printed each portion separately. Output mid-delay was there. I changed the code as like the post. Still i got the same...  So i need solution alone...

You still did not show a full working example. “Full” = something that defines both setup() and loop() and can be compiled and tested.


text:
How do I use PlatformIO to flash ESP-12F (ESP8266MOD)
In PlatformIO while creating a project , in the board selection there is no ESP-12F in the boards. While there is ESP-12E. I can flash ESP-12F while choosing ESP-12E from the boards without any flashing issue. But there are some runtime issues, the one that I noticed is the LED doesn't blink when flashed from PlatformIO , but works fine, when flashed using Arduino IDE using the same code.
So there may be some difference in the configurations.

C:\Users\USER\.platformio\platforms\espressif8266\boards

In this directory I found the esp-12e board which is a JSON format.
{
  "build": {
    "core": "esp8266",
    "extra_flags": "-DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP12",
    "f_cpu": "80000000L",
    "f_flash": "40000000L",
    "flash_mode": "dio",
    "ldscript": "eagle.flash.4m1m.ld",
    "mcu": "esp8266",
    "variant": "nodemcu"
  },
  "connectivity": [
    "wifi"
  ],
  "frameworks": [
    "arduino",
    "simba",
    "esp8266-rtos-sdk",
    "esp8266-nonos-sdk"
  ],
  "name": "Espressif ESP8266 ESP-12E",
  "upload": {
    "maximum_ram_size": 81920,
    "maximum_size": 4194304,
    "require_upload_port": true,
    "resetmethod": "nodemcu",
    "speed": 115200
  },
  "url": "http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family",
  "vendor": "Espressif"
}

How do I add ESP-12F to the PlatformIO boards and flashing without any issue.

Ask platformIO... it's their responsibility to keep their boards packages up to date for their platform...

@Majenko Thanks for the direction!! :)

At the PlatformIO community I asked the same question, and pfeerick  suggested to add a build flag.

It’s most likely the onboard LED is on GPIO2, not GPIO1 so try adding
build_flags = -D LED_BUILTIN=2 to your platformio.ini … hopefully that
  kicks in before the pins_arduino.h defintion.

But It didn't did the trick.
And the compiler throws a bunch of warnings.
What I did to make it work is to ignore LED_BUILTIN constant and use 2 instead.
#include <Arduino.h>
void setup() {
 pinMode(2, OUTPUT);
}

void loop()
{
  digitalWrite(2,LOW);
  delay(200);
  digitalWrite(2,HIGH);
  delay(200);
}

The build flags shouldn't have a space after the "D".
build_flags = -DLED_BUILTIN=2


text:
reference to 'File' is ambiguous. Why am I getting this error?
The program is supposed to take photo and store the picture into the SD card with the timestamp.
My Program Code:

#include <SdFat.h>
#include <Adafruit_VC0706.h>
#include <SPI.h>
#include<JPEGDecoder.h>
#include <SoftwareSerial.h>
#include <RTClib.h>
#include <Wire.h>
#include <SD.h>

#define SD_CS D8    //For NodeMCU Kit Set version 1
#define DS3231_ADDRESS  0x68  ///< I2C address for DS3231

SoftwareSerial mySerial (D4, D3); //D4-RX, D3 TX For NodeMCU Kit Set version 1
Adafruit_VC0706 cam = Adafruit_VC0706(&mySerial);
File myFile;  // test file
RTC_DS3231 RTC;  // define the Real Time Clock object

char timestamp[30];
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
void setup()
{
  pinMode(SD_CS, OUTPUT);

  Serial.begin(115200);
  Wire.begin ( D1, D2); //D1=SDA D2=SCL
  if (!SD.begin(SD_CS))
  {
    Serial.println("SD card is not inserted");
    return;
  }

  Serial.println("SD Card Present");

  // Try to locate the camera
  if (cam.begin()) {
    Serial.println("Camera Found:");
  } else {
    Serial.println("No camera found?");
    return;
  }

  if (!RTC.begin()) {
    Serial.println("RTC failed");
    while (1);
  }

  snapshot();
  //  ESP.deepSleep(0);  //deep sleep mode until RESET pin is connected to a LOW signal
}

void loop() {

}
//------------------------------------------------------------------------------
void snapshot() {
  // Set the picture size - you can choose one of 640x480, 320x240 or 160x120

  cam.setImageSize(VC0706_320x240);        // medium

  //cam.setImageSize(VC0706_160x120);          // small

  // You can read the size back from the camera (optional, but maybe useful?)
  uint8_t imgsize = cam.getImageSize();
  Serial.print("Image size: ");
  Serial.println(imgsize);
  // Serial.println("640x480");
  Serial.println("320x240");
  // Serial.println("160x120");

  Serial.println("Snap");
  delay(2500);

  if (!cam.takePicture())
  {
    Serial.println("Failed to snap!");
  }
  else
  {
    Serial.println("Picture taken!");
  }
  // Create an image with the name IMGxxxx.JPG
  char filename[13];
  strcpy(filename, "IMG0001.JPG");
  for (int i = 1; i < 10000; i++) {
    filename[3] = '0' + i / 1000;
    filename[4] = '0' + i % 1000 / 10;
    filename[5] = '0' + i % 100 / 10;
    filename[6] = '0' + i % 10;
    // create if does not exist, do not open existing, write, sync after write
    if (! SD.exists(filename)) {
      break;
    }

  }
  // Open the file for writing
  File imgFile = SD.open(filename, FILE_WRITE);
  SdFile::dateTimeCallback(dateTime); //Timestamp for file
  // Get the size of the image (frame) taken
  uint16_t jpglen = cam.frameLength();
  Serial.print("Storing ");
  Serial.print(jpglen, DEC);
  Serial.print(" byte image.");

  int32_t time = millis();
  //pinMode(D8, OUTPUT);
  byte wCount = 0; // For counting # of writes
  while (jpglen > 0) {
    // read 32 bytes at a time;
    uint8_t *buffer;
    uint8_t bytesToRead = min(32, jpglen); // change 32 to 64 for a speedup but may not work with all setups!
    buffer = cam.readPicture(bytesToRead);
    imgFile.write(buffer, bytesToRead);
    if (++wCount >= 64) { // Every 2K, give a little feedback so it doesn't appear locked up
      Serial.print('.');
      wCount = 0;
    }
    //Serial.print("Read ");  Serial.print(bytesToRead, DEC); Serial.println(" bytes");
    jpglen -= bytesToRead;
  }
  imgFile.close();

  time = millis() - time;
  Serial.println("done!");
  Serial.print(time); Serial.println(" ms elapsed");
  Serial.println("Storing Time in Textfile");
  myFile = SD.open("DATES.txt", FILE_WRITE);
  DateTime now = RTC.now();
  myFile.print(filename);
  myFile.print(' ');
  myFile.print(now.year(), DEC);
  myFile.print('/');
  myFile.print(now.month(), DEC);
  myFile.print('/');
  myFile.print(now.day(), DEC);
  myFile.print(" (");
  myFile.print(daysOfTheWeek[now.dayOfTheWeek()]);
  myFile.print(") ");
  myFile.print(now.hour(), DEC);
  myFile.print(':');
  myFile.print(now.minute(), DEC);
  myFile.print(':');
  myFile.print(now.second(), DEC);
  myFile.println();
  myFile.close();
  Serial.println("Done");
}
//------------------------------------------------------------------------------
// call back for file timestamps
void dateTime(uint16_t* date, uint16_t* time) {
  DateTime now = RTC.now();
  sprintf(timestamp, "%02d:%02d:%02d %2d/%2d/%2d \n", now.hour(), now.minute(), now.second(), now.month(), now.day(), now.year() - 2000);
  // return date using FAT_DATE macro to format fields
  *date = FAT_DATE(now.year(), now.month(), now.day());

  // return time using FAT_TIME macro to format fields
  *time = FAT_TIME(now.hour(), now.minute(), now.second());
}
//------------------------------------------------------------------------------

The error message is too long so I can only copy paste some parts which I think might be relevant:
    In file included from C:\Users\ACER\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\SD\src/SD.h:25:0,

                     from C:\Users\ACER\Documents\Arduino\libraries\JPEGDecoder-master\src/JPEGDecoder.h:56,

                     from C:\Users\ACER\Desktop\Arduino IDE\Snapshot NodeMCU with RTC\Snapshot_NodeMCU___RTC\Snapshot_NodeMCU___RTC.ino:4:

    C:\Users\ACER\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\SDFS\src/SDFS.h:190:5: error: 'sdfat' does not name a type

         sdfat::SdFat* getFs()

         ^

    C:\Users\ACER\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\SDFS\src/SDFS.h:215:5: error: 'sdfat' does not name a type

         sdfat::SdFat _fs;

         ^

    C:\Users\ACER\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\SDFS\src/SDFS.h: In member function 'virtual bool sdfs::SDFSImpl::exists(const char*)':

    C:\Users\ACER\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\SDFS\src/SDFS.h:98:27: error: '_fs' was not declared in this scope

             return _mounted ? _fs.exists(path) : false;

                               ^

    C:\Users\ACER\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\SDFS\src/SDFS.h: In member function 'virtual bool sdfs::SDFSImpl::rename(const char*, const char*)':

    C:\Users\ACER\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\SDFS\src/SDFS.h:104:27: error: '_fs' was not declared in this scope

             return _mounted ? _fs.rename(pathFrom, pathTo) : false;

                               ^

    C:\Users\ACER\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\SDFS\src/SDFS.h: In member function 'virtual bool sdfs::SDFSImpl::info(fs::FSInfo&)':

    C:\Users\ACER\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\SDFS\src/SDFS.h:113:26: error: '_fs' was not declared in this scope

             info.blockSize = _fs.vol()->blocksPerCluster() * 512;

reference to 'File' is ambiguous

    //There are a lot of '???' not declared in this scope and 'sdfat' does not name a type error.

At first, there was a different error that states that SdFile::dateTimeCallback(dateTime); is not declared. After doing some research online, I tried to install SdFat library here to see if it helps
and after installing I got more error as shown above.
How can I solve these errors?

Are these the very first errors reported by the compiler? Anything that follows the first ones may be noise.

Why are you trying to use both SdFat and SD?

Before, I was using SD only but the error SdFile::dateTimeCallback(dateTime); is not declared comes out. I when online to see if there are only solution and I ended up downloading the SdFat library and use it. It got rid of the error but now I have all the other errors coming out.


text:
char buffer to String in Arduino UNO
String getAPIData()
{
  char res_buffer[450];
  int numdata = inet.httpGET("myserver.com", 80, "/call.php?id=1&q=1&code=1001", res_buffer, 450);
  String result = String(res_buffer);
  Serial.println(result);
  Serial.println(numdata);
  return result;
}

Output on Serial:
15:52:07.208 ->
15:52:07.208 -> 393

But, When I print the buffer by loop I got the below output:
HTTP/1.1 200 OK
Date: Mon, 16 Sep 2019 06:28:59 GMT
Server: Apache
X-Powered-By: PHP/7.2.20
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Set-Cookie: PHPSESSID=5b21eeac22dcf61f2e4d2efd579d437c; path=/
Upgrade: h2,h2c
Connection: Upgrade, close
Vary: Accept-Encoding,User-Agent
Content-Type: text/html; charset=UTF-8

-1

I am not sure why the char buffer is not converting to String in Arduino UNO.
Any known issues ? Please suggest if any correction required.

Don't use String. It's not fit for purpose. There is no cause to ever use String.

Chances are you are running out or memory and the String allocation doesn't happen. You need 450 bytes for your buffer, 450 bytes for the String you are using, and another 450 bytes for the String you are returning. That's 1350 bytes out of a maximum 2048 just for that function.

Do not use String. And especially do not use String in the way you are using it.
You can read more about why not here.
Instead stick to just using char* buffers.
The correct way of doing what you want is to define the buffer outside your function and then pass that buffer to the function to be populated:
int getAPIData(char *buf, int maxlen) {
  return inet.httpGET("myserver.com", 80, "/call.php?id=1&q=1&code=1001", buf, maxlen);
}

Then you call it with:
char *my_buffer[450];
getAPIData(my_buffer, 450);
Serial.println(my_buffer);


text:
What do these pins mean? Where should I plug them in?
I am trying to collect data from the arduino into a SD card for the first time, so I bought the adapter at my local electronics/arduino shop. However, I could not find an explanation as to what each pin does, and the other adapters that I have seen online have different pins, so I am not sure what to do with the pins (except for the obvious ones, GND and VCC)

The order of pins is as follows:
CD, DO, GND, SCK, VCC, DI, CS.
Could you help me figure out what they mean and where to plug them into my arduino?

for Uno use an 5 V SD card adapter. this is only for 3.3 V

You should read the documentation.

See https://www.instructables.com/id/Adafruit-Sparkfun-MicroSD-Breakout-and-Arduino-Mic/ for a useful starting point

This is called the SPI interface (See Serial Peripheral Interface, Wikipedia. The pin names typically used for SPI are:

GND : Power Ground
VCC : Power input
CS : Chipselect
SCK/SCLK (SD-Clock): SPI Clock
MOSI (SD-DI, DI) : SPI Master out Slave in
MISO (SD-DO, DO) : SPI Master in Slave out
CD: Card Detect (see comment of rollinger below (thanks).

On an Arduino Uno the SPI pins are:

CS – digital 10; this can be in principle any pin
SCK – digital 13
MOSI – digital 11
MISO – digital 12

I'd expect CD to be card detect, switch signalling when a card has been inserted- e.g. see https://www.instructables.com/id/Adafruit-Sparkfun-MicroSD-Breakout-and-Arduino-Mic/ for hookup of a similar / same board

@rollinger Thanks ... and yes, that sounds more plausible than my search on google, so I updated my question. Thanks/credits to you.

CS = Chip select
DI = Data In (MOSI)
VCC
SCK = Serial Clock
GND
DO = Data Out (MISO)
CD (not sure what it stands for, but this pin isn't used when connecting to an Arduino. I think it's used for faster transfers.)

Note that SD card run at 3.3Volt, not 5V. Also the input pins of the SD can't handle 5Volt signals. So you need to convert the 5V signals coming out of the UNO to 3.3V before connecting to the SD card.

Oh that is actually a problem for me, because I wanted to run it from the arduino! How can I convert it? Would a voltage divider be good enough?

It appears you can, but you'd have to run at a lower speed, so it doesn't work out of the box with the standard libraries. But nothing a few lines of code can't fix.

Could CD stand for Card Detect? changing state depending on whether a card is physically in the slot.

CD could be one of two things:
a) a simple mechanical switch on the socket, usually used for Card Detect.  Measure from the pin to Gnd and see if contact is open/closed when a card is plugged in.
b) the fifth IO pin to a uSD card.  See the chart on the middle of this data sheet
https://www.molex.com/pdm_docs/sd/472192021_sd.pdf
You will see there are 4 data lines for parallel operation (Dat0, Dat1, Dat2, and CD/Dat3), and the Clock and Command (CMD) pin.   Arduino uses serial operation over the SPI bus tho, so in this case CD is likely card detect from what appears to be a mechanical lever switch at the bottom of the socket.
This drawing shows how the pins are used
http://www.dotmana.com/weblog/wp-content/uploads/izQKT.png

Your question's been well answered, but I just wanna point out, when you get the library code that lets you access the SD card, there will probably be instructions on what pins to wire up where. That's nearly always the case. Particularly since this one uses the SPI pins.
There's also loads of instruction websites that would take you through it. The cheap Chinese stuff is nearly always copies of designs from the West, as seen on popular websites. So the instructions usually apply. Arduino is bloody great! Good luck in your adventure.


text:
How do I extract code from an arduino?
I updated and uploaded some code on another computer that got wiped and didn't send the new code to my current computer, the updated code is still on the board but I don't have access to it. How do I get it back?

You have a couple of answers, but here's a piece of advice for going forward... protect yourself against code loss by learning how to use a VCS (Version Control System). This will allow you to keep all changes to your software on both your local computer as well as a remote system which stores it. Nowadays, I use git, but there are several. Github is a free online git storage facility. So you do some code, "commit" your changes, and then "push" them up to Github. You can then pull your code down to any computer with git on it thereafter.

You likely can't recover the source code, but if you had some important logic that you don't want to rewrite from scratch, it's very likely you can dump out the assembly and reconstruct that into C pretty easily (although manually).

Isn't the code in one of your backups, or your version control system?

The short answer: You don't.
With enough know-how, you could probably extract the executable binary from the Arduino, but the source code is not installed on the device. You would need to run a decompiler on the binary. (Or read the machine code directly.) The output of a decompiler is usually pretty ugly however, and will look quite different from the original source-code. It won't have meaningful variable names, class names, or function names, and the code structure will likely be a little different than the original source code.
EDIT:
As mckenzm pointed out in his answer, you could download the binary image from your Arduino, and then copy it onto another Arduino, but all that would let you do is to make an exact copy of the program. You wouldn't be able to modify it at all.

You never can get the actual code back ... by reading the flash you might be able to get the executable/runtime code, but this doesn't look at all similar as your code, although it's functionally the same.
For example, all function names, all variable names will be just numbers (or non recognizable names), and all C statements are converted in machine language instructions, probably so many, you will need much knowledge to find out which instructions belong to which (original) C statements.

I'm rather new to Arduino so can you explain how I can do this

See this link: https://stackoverflow.com/questions/42770319/how-to-read-arduino-flash-memory

Do I upload "avrdude -p m328p -P usb -c usbtiny -U flash:r:flash.bin:r" in a new sketch?

You have to start it from the command line

how do I get there

go to the windows icon (left bottom, type 'cmd'  go with cd to the correct path

Do you know how to do it on a mac? Sry

Sorry, I don't know much about macs, I do not have one myself. Maybe ask on stackoverflow? (how to startup a console)

On a Mac, open the application `terminal. Then the command should be the same. (Mac terminal windows use BASH, and the Windows command line has vague similarity to Unix)

You read the contents of flash and save it to a file. It can then be re-flashed if your need is not to edit, but duplicate.

This reads all flash, including the bootloader, and also PROGMEM data.

Use avr-objdump (or similar) to disassemble the instructions.

Again, PROGMEM data is going to be interpreted as opcodes, and may not be valid opcodes.
You may want to dump the fuses as well, for redirected vectors and such.

Use pattern analysis to recognise source patterns as compiled. Then iteratively compile and compare fragments.

This is harder than is looks, whilst most Arduino code is very simple, the libraries can be be wild and woolly. At least the hex file is human readable, but little endian.
It might be easier to "walk through" the assembly and perform a translation of the perceived behaviour. OK for 10 instructions, but harder for 16K of them.
You will also need the Atmel/Microchip *def.inc files for the MPU component enumerations so that you know your DDRB from you DDRC a good disasembler should know.
You can do this well enough for Blink, and recognise stack pointer initialization.
It is much easier without a bootloader, as booting should jump to main and main can start at 0 other than after the vectors.
Of course lock bits will ruin your day, and it may just be better for character to code it again.

Note that: 1. The Arduino IDE does not mess with the fuses nor lock bits. 2. Full-program optimization, which the IDE sets on by default, will make it near to impossible to find Arduino library functions by pattern-matching. Avr-libc is pre-compiled (with no LTO sections AFAICT), so it can be pattern-matched. 3. The boot loader will not be a problem: application code always starts at address 0, which is a jmp to __init. A few instructions through __init you find call main followed by jmp _exit. Thus, at least main is easy to find. Anything beyond will likely be a mess.

Good points. The IDE does set fuses for "burn bootloader".  Especially for contributed cores and in particular for clock selection and bootloader operation. You always have the ICSP option.


text:
how to get text box values from webserver of esp32 and print them in to serial monitor by using <webserver.h> library
Actually I'm trying to get the values from esp32 server webpage. Suppose there is a web page containing some text box fields, user has to enter some details in it and this details I want to be print on serial monitor.
And didn't get any solution regarding that. Though it is working with ESPAsyncWebServer.h library, that i found here -- > https://randomnerdtutorials.com/esp32-esp8266-input-data-html-form/
but I want to do this task with webserver.h library, for some reason I don't want to use ESPAsyncWebServer.h library.. Hope you all guys can understand what I'm trying to ask and say. Thank You.

Do you, first of all, understand how HTML forms function?

html side if i try method = post, then how would i fetch this post value in arduino ? in php its so easy to fetch with $_POST["value"], but in arduino i don't have any idea about it. new to arduino programming so facing this problem.

POST data is just in the body of the request. I don't know how webserver.h will present that to you.

thats the problem brother, i guess i need to dig more deep into this library.

see the SimpleAuthentification example

I didn't get one  @Juraj  .. Still struggling and finding a way to do this task :(

$_POST["value"] is server.arg("value")


text:
SD card example freezes at line SD.begin() what should I do?
I have a 16GB SD card which is formated with FAT32. I'm trying to run the example codes presented for SD in Arduino. The SD card is inserted in the data logging shield and the CS pin in this shield is connected to pin 10.
I first tried the Cardinfo example and this is the result:

The SD card is not empty, there exist a few files in it but this example was unable to show this files.
I then tried the example ReadWrite and the code freezes on line SD.begin(10).
I have no Idea where this problem is coming from.

try the card without files on it

I tried this, it doesn't work. The Cardinfo example can detect it but can't read the system file. The ReadWrite example freezes on SD.begin() line.

I had the same problem when I used a big SD card, maybe because some cards have a more modern format.
If you have smaller / older cards, try them and see if those work; than you rule out it is not a circuit/connection problem.

It is difficult to find an SD with lower capacities. But I search maybe that is the problem.

I think I had that problem about 2 years ago too when I tried a bigger SD card.

I found another SD card with 16GB capacity, but fortunately, it worked!

Good to hear your problem is solved ... maybe the smaller SD card I tried has the same properties as your working card ... still wondering what the exact specifications should be.. But glad you found one that worked.

Thanks for you help, I appreciate it.

I found another SD with 16GB capacity, and fortunately it worked. So the problem was because of the SD but I don't know what was the exact problem. I post the photo of this SD cards.


text:
pulseIn on ESP32 return 0 regularly
I'm using pulseIn on an ESP32 for measuring a frequency between 500 Hz and 10 KHz. I measure both the HIGH and the LOW time, as all simple examples suggest. 95% of the time the result is correct, but sometimes pulseIn returns 0. It can happen on the HIGH or the LOW measure. I'm using GPIO27, which should not be a problem. On a digital scope the signal is very steady and clean.The code is very basic.

const int pulsePin = 27; // Input signal connected to Pin 12 of Arduino

unsigned long Htime;
unsigned long Ltime;
unsigned long Ttime;
float Frequency; // Calculated Frequency

void setup() {
  pinMode(pulsePin, INPUT);
  Serial.begin(9600);
}

void loop() {
  Htime=pulseIn(pulsePin,HIGH);
  delay(10);
  Ltime=pulseIn(pulsePin,LOW);
  Ttime=Htime+Ltime;
  Serial.print(Htime);
  Serial.print(", ");
  Serial.println(Ltime);
  delay(100);
}

The output looks like below:

Of course I can add code to ignore measurements with a 0 result, but any ideas on why they appear?

pulseIn() returns 0 in case of a timeout

I'm aware of the time-out, but then it will take some time before it results to 0. In this case the 0 result come just af fast as the normal readings. If I disconnect the signal it all return zero, but also the reading becomes very slow. The zero-result above come just as fast as the normal readings. And even if I use the time-out parameter, with like a few seconds, the zero-readings come jus as fast as the normal, so there is no time-out, otherwise I would have to wait a few seconds.

It might be noise on the signal. If you just want to measure a frequency you can use the counter modules to count pulses in a specific range. This would probably be more precise than you approach


text:
How do I send Sensor Data from one Arduino to another Arduino that is a Webserver to post it?
I have been looking for over 2 hours now and just cant get it figured out. Im very confused as to how to do this. The solution I thought I found was to use HTTP POST. But I just cant get it to work. To be honest i'm guessing this should be very simple. Im using the variable
sensorValue = analogRead(0);

And then want to sent that Variable to my Webserver with the ip 172.20.10.5
Then I wish to save this variable into an array on my Webserver. I am sorry for this request I of course looked at least on 20 diffrent sites and questions and cant find a solution.

#include <SPI.h>
#include <Ethernet.h>
#include "ESP8266WiFi.h"

IPAddress server(172,20,10,5);
 if(client.connect(server, 80)) {
  client.println("POST /Raum1 HTTP/1.1");
  client.println("Host: 172.20.10.5");
  client.println("User-Agent: Arduino/1.0");
  client.println("Connection: close");
  client.print("Content-Length: ");
  client.println(sensorValue.length());
  client.println();
  client.println(sensorValue);
}
void setup(){
Serial.begin(9600);                            // sets the serial port to 9600
  WiFi.begin("iPad von Tobias", "12345678");  //Connect to the WiFi network

  while (WiFi.status() != WL_CONNECTED) {  //Wait for connection

    delay(500);
    Serial.println("Waiting to connect…");

  }

  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());  //Print the local IP
 }

//byte server[] = {172, 20, 10, 5}; //IP
void loop(){
sensorValue = analogRead(0);       // read analog input pin 0
Serial.print("AirQuality=");
Serial.print(sensorValue, DEC);               // prints the value read
Serial.println(" PPM");
delay(1000);

This is my current code on the ESP8266 I have the sensor on. The error im getting the most is: "client" has not been definied in this context.
I had the HTTP POST in the loop, out of the loop, in the setup, it just doesn't work. I tried diffrent methods to write the IPAddress which didnt help either. I also do not know how to then save that Data on the Webserver. They are connected over WIFI. Maybe the http way is completly wrong?. I can't find anything for this.
I would most likely have it look like this but this doenst work either.
#include <SPI.h>
#include <Ethernet.h>
#include "ESP8266WiFi.h"
int sensorValue;

void setup(){
Serial.begin(9600);                            // sets the serial port to 9600#
WiFi.begin("iPad von Tobias", "12345678");  //Connect to the WiFi network

  while (WiFi.status() != WL_CONNECTED) {  //Wait for connection

    delay(500);
    Serial.println("Waiting to connect…");

  }

  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());  //Print the local IP
 }

 IPAddress server(172,20,10,5);
 client.connect(server, 80)
void loop(){sensorValue = analogRead(0);       // read analog input pin 0
Serial.print("AirQuality=");
Serial.print(sensorValue, DEC);               // prints the value read
Serial.println(" PPM");
delay(1000);
  client.println("POST /Api/AddParking/3 HTTP/1.1");
  client.println("Host: 172.20.10.5");
  client.println("User-Agent: Arduino/1.0");
  client.println("Connection: close");
  client.print("Content-Length: ");
  client.println(sensorValue.length());
  client.println();
  client.println(sensorValue);
}

Thank you for your help, I dont need a direct solution if you can point me to literatur that will help me solve this problem.

use GET request to post a single value

And how do i do that? @Juraj

try to adapt this example https://github.com/arduino-libraries/WiFi/blob/master/examples/WiFiWebClient/WiFiWebClient.ino

In the first block of code, you have an if statement that is not inside a function. It is immediately after  IPAddress server(.... This is invalid syntax. If statements must be inside a function and this could well be the source of the error about client not being defined. Also, you never actually declare client, you might start with the examples and try to adapt them...

If found that you can also use UDP to do what I want.


text:
Is there way to wirelessly connect a arduino drone‘s camera?
Is there way to wirelessly connect a arduino drone‘s camera and stream to a set device from 10 km away?

Welcome to Arduino.SE. Questions starting with "Is there a way" are usually very broad and sometimes difficult to answer. You may receive more and better answers if you expand your question by describing, what you have tried already and how you (not) succeeded.

You could try using the most common solution for streaming low latency drone video, called FPV. You basically connect an AV video output from a camera to a transmitter and use a receiver on the ground to receive the AV video. After this you can connect it to any AV display (or a usb AV decoder if you want to use a computer) and you'll get an almost real time video feed of what is happening on your drone. To get long range you would need to buy a powerful transmitter, good receiver and decent antennas for bout of them. You can find different configurations for different ranges online.

Most (commonly available) RF links' communication distance is more limited than that (10 Km). If your flying locations are within a cell service area, a cell radio aboard the drone will probably give you the most universally available connection. Note that your streaming rate may vary with the location and cell congestion at that particular time, and may sometimes be limited, especially for video.


text:
Current mouse pointer position with Digispark attiny85
I am trying DigiMouse library for attiny85 Digispark board.
It allows to emulate the mouse quite well.
However, I also need to know the current cursor position. Is there a way to get it?

emulate an "absolute position" mouse ... regular mouse only sends "relative move" values

There is no way for a mouse of any kind (especially not one as minimal as DigiMouse.h) to know the current cursor position - USB just doesn't provide that kind of facility.
Instead you need to implement an "absolute" mouse (aka a "tablet").  However DigiMouse doesn't implement such a facility. So you would have to implement your own tablet driver.
A normal mouse sends a "delta" for the position. That is, a difference in position from whatever the current position is.  An absolute mouse, or tablet, sends the position on the screen as a proportion of some maximum set of dimensions.  Ideally that would be the same dimensions as your screen, but doesn't have to be.
The main differences between DigiMouse and whatever you would implement for a DigiTablet would be the "HID Report Descriptor". This defines what the data that is sent means and how the computer should interpret it.


text:
#include <ESP8266WiFi.h> Error with WiFiClientSecureBearSSL.h
I am new to the Arduino world and it seems that this simple problem is keeping me at the start line.

I use the Generic ESP8266 Module as Board
In my sketch I just write:

#include < ESP8266WiFi.h >
void setup(){}
void loop(){}

The ERROR is :
BearSSLHelpers.h:148:34: error: 'virtual const unsigned char* BearSSL::HashSHA256::oid()' marked override, but does not override
 virtual const unsigned char *oid() override;

                              ^

How am I going to solve that? Any help is appreciated.

with esp8266 Arduino core 2.5.2 I can compile it without errors

Well, I can't..

Installed the ESP8266 Arduino core 2.5.2 and tried to run this simple code above

File > Preferences  and on Additional Boards Manager URLs i pasted
http://arduino.esp8266.com/stable/package_esp8266com_index.json

Tools > Board > Board Manager > typed "ESP8266" and installed ESP8266 by ESP8266 Community version 2.5.2

there is virtual const void *hash() override on line 148 in release

Thank you. But what I have to do to fix this?

how did you get parts of the git version? did you download and install the library separately? delete it from your libraries folder

Ok after deleting the library folder from my libraries folder it worked!
Thank you so much!
So just to get this straight, when I install a library, I don't have to have the library folder in my Arduino > libraries folder ??

not the libraries which are part of the boards package

Thank you very much!

You installed the latest git version of the ESP8266WiFi library into your libraries folder and this version is not compatible with the 2.5.2 version of the esp82666 Arduino core.
The ESP8266WiFi library is part of the esp8266 boards package. It should not be installed separately. Delete the library from your libraries folder.


text:
ATtiny167 Device not recognized
I'm frustrated I feel like I am 90% there but my computer will not recognize the ATtiny167. Here i9s the list of things I have completed/tried using Windows 10 and Arduino 1.8.6;
                  1) Installed Driver USB Bootloader is complete
                  2) Device Management I see the device
                  3) Arduino Sketch select 16.5 MHz board in parameters
                  4) Led on the board flashes sound beeps and stops flashing
                  5) "Device not recognized"
                  6) I have rebooted many times. I deleted everything and started over again with same
                      results
                  7) Used a 3rd party software to look at my USB ports it see the device
                   I have tried more than one device as well

         I'm stuck at this point. I've tried running example programs however the device is not recognized.

Any suggestions?

Do you have some code on the chip that makes it appear to be a USB device? Otherwise, do you have some USB to UART hardware for communicating with the chip? Is this something you have built yourself, or some non-standard development board?

If Digispark Pro clone is not recognized, you can try to use/upload .ino programs via ArduinoISP.
note use in File -> Preferences -> Additional Boards Manager URLs:
http://drazzy.com/package_drazzy.com_index.json
instead:
http://digistump.com/package_digistump_index.json
(The first is AttinyCore by Spence Konde, the second is the normal Digistump AVR Boards)
Then selected Tools -> Boards Manager, and Find AttinyCore -> (Wait and Install).
Now you can upload File -> Example -> ArduinoISP on your Arduino connected in ISP mode with your ATtiny167.
Now select ATtiny167 Board, 16Mhz (External) and write bootloader with your Arduino connected in same manner ISP mode with your ATtiny167.
And now upload any .ino file for ATtiny167 in the same manner with your Arduino connected in ISP mode with your ATtiny167.


text:
ESP32 WiFiClient request missing response
I am facing problem with ESP32. I use basic example for WiFiClient and making request to my server. The problem is that the response should be 15000 bytes long, but very often I got only 2750 or less.
char buffer[15000];
while (client.available()) {
  char c = client.read();
  buffer[i++] = c;
}
Serial.println(i);

You are assuming that all 15000 bytes are available all the time.
They won't be.
Instead of "while available read something" you need to "While not enough has been read, then if available read something".
When reading from (assuming) HTTP you first need to read and interpret the headers (the lines before a single blank line).  One of these will be the "Content-Length:" header, which will tell you exactly how many bytes are in the body of the response. Then you use that to read the right number of bytes from the body.
So the sequence is:

Read line by line for the headers interpreting the ones you need to, until:
You receive a single blank line
Read the data byte-wise until you have read the number of bytes indicated in the Content-Length header.

If you aren't reading from an HTTP server and you are certain that the data is exactly 15000 bytes in length then you need to skip to point 3 above. Never assume that all the data is there. If there is data then read it, and repeat until you have totalled 15000 bytes.

Thanks, the problem was probably caused by client.available(), while reading response, it found a gap when client has no data available and so ends the reading.
When I havent got enought data, I wait (with timeout) to get some data available.


text:
how to do Arduino to esp8266 communication
I am trying to do Arduino to ESP8266 communication, but I am not able to send data to esp8266. However I can receive data from esp8266.
Here if my Arduino code:

#include <SoftwareSerial.h>
SoftwareSerial ESPserial(0, 1); // RX | TX

void setup()
{
  Serial.begin(115200);     // communication with the host computer
  // Start the software serial for communication with the ESP8266
  ESPserial.begin(9600);

  Serial.println("Enter 1 to turn led high & 2 to turn led low.");
}
// the loop function runs over and over again forever
void loop() {
  // listen for communication from the ESP8266 and then write it to the serial monitor
  if ( ESPserial.available() )   {
    Serial.write( ESPserial.read() );
  }

  // listen for user input and send it to the ESP8266
  if ( Serial.available() )       {
    ESPserial.write( Serial.read() );
  }

}

Here is esp8266 code:
void setup()
{
  Serial.begin(9600);     // communication with the host computer
  // Start the software serial for communication with the ESP8266
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
  Serial.println("ESP -- Hello");
  delay(1000);
  // listen for user input and send it to the ESP8266
  if ( Serial.available() )  {

    int ledState = Serial.parseInt();
    if (ledState == 1) {
      digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
      Serial.println("ESP Led On\n");
    }
    if (ledState == 2) {
      digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
      Serial.println("ESP Led Off\n");
    }
  }
}

Once I upload both sketches, then I can see it terminal " ESP -- Hello " keep printing comming from esp8266 but when I enter 1 or 2, its not sent to esp8266 due to which I never see "ESP led on/off" messages , so correct me guys what mistake I am making.

Don't ever use SoftwareSerial in pins 0 and 1!  And never use pins 0 and 1 for anything if you are using Serial for Arduino to PC communication.

@Majenko ok thanks then how can i solve the issue of this communication on UNO i have just these one RX and TX pair it 0,1 pins so should i try the same code on mega2560

you can use SoftwareSerial on any pair of pins. that is why it is called 'software' Serial

using SoftSerial on the hardware serial isn't working on Arduino properly as sometime data receive and sometime not with garbage added so Using digital pins  other  2, & 3  other than hardware serial resolved the issue.

Perhaps you should clarify that using SoftSerial on the hardware serial isn't working, choose any other digital pins than the hardware serial pins.

@MatsK thanks i updated the answer


text:
How to burn arduino bootloader on SAMD21 chips using J-Link mini
I am planning on making my own custom PCB of a SAMD21 board. I would like to ask if anyone has experience uploading arduino bootloader on a J-link Mini although adafruit has a guide on this device, its not uploading a arduino bootloader.
On a related note which pins should I connect it to my SAMD21 chip ?

SWD pins. see the schematic of some SAMD21 Arduino. the connection is same for any bootloader or application upload. it is used for debugging too.

https://forum.arduino.cc/index.php?topic=636902.0

on the github guide he posted, it does not mention on how to upload the arduino bootloader sadly. But thank you for telling me  SWD pins are standard on most applications

I did it in Arduino IDE. I selected the Atmel EDBG programmer and then Burn Bootloader. all SAMD programmers use the same protocol

@Juraj the Atmel EDBG would work for Arduino Zero since that has the EDBG chip.     With Jlink, I usually use Atmel Studio. Once the Jlink is connected to the chip via SWD, just goto the programmer option in Atmel Studio, select the chip and programmer and burn the programmer. It is pretty straightforward. There is a nice tutorial here which walks through it.

@karan, it worked with NXP LPC-Link2. IDE calls openocd and the programmer is configured in openocd

Hey guys post your comment as answers, so i can mark them as correct when my jlink arrives. Thanks for the replies

The Atmel EDBG would work for Arduino Zero since that has the EDBG chip. With Jlink, you can use Atmel Studio. Once the Jlink is connected to the chip via the 10 pin SWD header, goto the programmer option in Atmel Studio, select the chip and programmer and burn your firmware with the selected programmer. You can follow a tutorial here which walks through it.


text:
ESP 01 calling Pushing Box API
I want to write my data on google sheets using ESP 01 and Arduino Nano.
So I copied code from some website I don't remember the website "how to send data on a local server" and modified it a bit.
But it is directly sending the data to the local server only.
Please help me to call Pushing box API and write on Google Sheets.
Here is my current code:

#include<SoftwareSerial.h>

SoftwareSerial comm(12,11); //setting Tx and Rx pins

String server=""; //variable for sending data to webpage
boolean No_IP=false; //variable to check for ip Address
String IP=""; //variable to store ip Address
char temp1='0';

int a=0;
int b=0;

void setup()
{
Serial.begin(9600);
comm.begin(9600);
wifi_init();
Serial.println("System Ready..");
}

void loop()
{
b=0;
Serial.println("Refresh Page");
while(b<1000)
{
b++;
while(comm.available())
{
if(comm.find("0,CONNECT"))
{
Serial.println("Starting");
sendToServer();
Serial.println("Finished");
delay(1000);
}
}
delay(1);
}
}

void findIp(int time1) //check for the availability of IP Address
{
int time2=millis();
while(time2+time1>millis())
{
while(comm.available()>0)
{
if(comm.find("IP has been read"))
{
No_IP=true;
}
}
}
}

void showIP()//Display the IP Address
{
IP="";
char ch=0;
while(1)
{
comm.println("AT+CIFSR");
while(comm.available()>0)
{
if(comm.find("STAIP,"))
{
delay(1000);
Serial.print("IP Address:");
while(comm.available()>0)
{
ch=comm.read();
if(ch=='+')
break;
IP+=ch;
}
}
if(ch=='+')
break;
}
if(ch=='+')
break;
delay(1000);
}
Serial.print(IP);
Serial.print("Port:");
Serial.println(80);
}

void establishConnection(String command, int timeOut) //Define the process for sending AT commands to module
{
int q=0;
while(1)
{
Serial.println(command);
comm.println(command);
while(comm.available())
{
if(comm.find("OK"))
q=8;
}
delay(timeOut);
if(q>5)
break;
q++;
}
if(q==8)
Serial.println("OK");
else
Serial.println("Error");
}

void wifi_init() //send AT commands to module
{
establishConnection("AT",100);
delay(1000);
establishConnection("AT+CWMODE=3",100);
delay(1000);
establishConnection("AT+CWQAP",100);
delay(1000);
establishConnection("AT+RST",5000);
delay(1000);

Serial.println("Connecting Wifi....");
establishConnection("AT+CWJAP=\"Leobotics\",\"leobotics123\"",7000); //provide your WiFi username and password here
delay(2000);
Serial.println("Wifi Connected");
showIP();
establishConnection("AT+CIPMUX=1",100);
establishConnection("AT+CIPSERVER=1,80",100);
}

void sendData(String server1)//send data to module
{
int p=0;
while(1)
{
unsigned int l=server1.length();
Serial.print("AT+CIPSEND=0,");
comm.print("AT+CIPSEND=0,");
Serial.println(l+2);
comm.println(l+2);
delay(100);
Serial.println(server1);
comm.println(server1);
}
}
void sendToServer()//send data to webpage
{
//String aquib = "http://busgetbeast.in";
sendData("http://api.pushingbox.com/pushingbox?devid=vBDFF4154ABE4F6F&humidityData=33&celData=44&fehrData=111&hicData=22&hifData=77");
      sendData(" HTTP/1.1");
      sendData("Host: ");
      sendData("api.pushingbox.com");
      sendData("User-Agent: ESP8266/1.0");
      sendData("Connection: close");
    // sendData();
delay(5000);
comm.println("AT+CIPCLOSE=0");
}

better use a library. it will get too complex for direct use of AT commands. WiFiEsp library or WiFiEspAT if you don't need SSL and you can flash AT 1.7 (SDK 3) to esp-01. or write a sketch for the esp for the networking part

I've used WiFiEsp Library, modifying the WebClient Example but still, its showing Data Packet Error (2)

where is CIPSTART in your sketch?

when i'm adding CIPSTART it showing me error on serial monitor


text:
L298N motor driver issue
I am facing the same issue with my motor driver. Initially I ran the code and connected the L298N with Arduino and it worked fine. At that time motors were running absolutely fine. But when I ran it sometimes later then the motors are not running. However the motors are getting power but I think thy are getting very less power from the Motor Driver.
I directly ran motors from Arduino +5V pin and the motors were running fine. Is there something wrong with my L298N motor driver?
One more thing I checked the power for all the pins for L298N motor Driver and all pins are working fine.
Here is my complete program:

const int MOTOR_RIGHT = 1;
const int MOTOR_LEFT =  2;
const int MR_CONTROL_PIN_A = 8;
const int MR_CONTROL_PIN_B = 9;
const int ML_CONTROL_PIN_A = 10;
const int ML_CONTROL_PIN_B = 11;

void setup() {
  // These two pins will act as output pin

  pinMode(MR_CONTROL_PIN_A,OUTPUT);
  pinMode(MR_CONTROL_PIN_B,OUTPUT);
  pinMode(ML_CONTROL_PIN_A,OUTPUT);
  pinMode(ML_CONTROL_PIN_B,OUTPUT);
  Serial.begin(4800);

}

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

  forward(MOTOR_RIGHT);
  forward(MOTOR_LEFT);
  delay(5000);
  stopMotor(MOTOR_RIGHT);
  stopMotor(MOTOR_LEFT);
  delay(1000);
  backward(MOTOR_RIGHT);
  backward(MOTOR_LEFT);
  delay(5000);
  stopMotor(MOTOR_RIGHT);
  stopMotor(MOTOR_LEFT);
  delay(1000);

}
/////////////////////////////////////////////////////////////////////
//Forward

  void forward(int motorNo)
  {

  Serial.print("\r\n Forward : ");
  Serial.print(motorNo);

  switch(motorNo)
  {
    case MOTOR_RIGHT:
    digitalWrite(MR_CONTROL_PIN_A,HIGH);
    digitalWrite(MR_CONTROL_PIN_B,LOW);
    break;

    case MOTOR_LEFT:
    digitalWrite(ML_CONTROL_PIN_A,HIGH);
    digitalWrite(ML_CONTROL_PIN_B,LOW);
    break;

  default:
    Serial.print("\r\n Error :Invalid Motor No ");
    Serial.print(motorNo);
   }
  }

//////////////////////////////////////////////////////////////////////
  void backward(int motorNo)
  {
   Serial.print("\r\n Backward : ");
   Serial.print(motorNo);
  switch(motorNo)
  {
    case MOTOR_RIGHT:
    digitalWrite(MR_CONTROL_PIN_A,LOW);
    digitalWrite(MR_CONTROL_PIN_B,HIGH);
    break;

    case MOTOR_LEFT:
    digitalWrite(ML_CONTROL_PIN_A,LOW);
    digitalWrite(ML_CONTROL_PIN_B,HIGH);
    break;

  default:
    Serial.print("\r\n Error :Invalid Motor No : ");
    Serial.print(motorNo);
   }

  }

///////////////////////////////////////////////////////////////////////
  void stopMotor(int motorNo)
  {
   Serial.print("\r\n STOP : ");
   Serial.print(motorNo);
  switch(motorNo)
  {
    case MOTOR_RIGHT:
    digitalWrite(MR_CONTROL_PIN_A,HIGH);
    digitalWrite(MR_CONTROL_PIN_B,HIGH);
    break;

    case MOTOR_LEFT:
    digitalWrite(ML_CONTROL_PIN_A,LOW);
    digitalWrite(ML_CONTROL_PIN_B,LOW);
    break;

  default:
    Serial.print("\r\n Error :Invalid Motor No : ");
    Serial.print(motorNo);
   }

  }

Is there something wrong with my L298N ? How can I test it?

Can the driver chip provide enough current to drive your motor continueously?

Actually that's what the problem is ...it is not providing enough current to move the motor. I can feel the spark in motor when power up and connected with L298N via Arduino but the motor is not rotating.

How much current does your motor need? As I remember the L298N has a quite bad efficiency, because it uses bipolar transistors instead of MOSFETs

I don't think you are supposed to run a motor from the 5V regulator on the Arduino. Try using a separate power supply for the motor driver.

The specified minimum voltage for the motors is 2.5 volts higher than the logic supply.
You need to use a separate supply for the motor that is higher than the logic power.

I am directly supplying power to L298N from the +9v battery but still finding same issue. Arrengement is like this :
+12V L298N Pin connected to Battery,
GND L298N pin connected to both Battery and Arduino GND,
+5V L298N pin connected to +5V of Arduino.

9 volt batteries have very low capacity. That could be the cause of your problem. Replace the battery with a power supply with higher capacity. Or other bigger batteries that add up to around 9 volts.


text:
Blink Adafruit_NeoPixel
I wish to blink all the strip. In the code below it just blink the first LED, how can I fix it?
Code:
#include <Adafruit_NeoPixel.h>

#define PIN 6
#define NUM_LEDS 24

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.begin();
  strip.show();
}

void loop() {
  strip.setPixelColor(0, 255, 255, 255);
  strip.show();
  delay(1000);
  strip.setPixelColor(0, 0, 0, 0);
  strip.show();
  delay(1000);
}

The first argument of setPixelColor is is the number of the led. In your case 0, so the first led.
Instead use a for loop to set all the leds from 0 until (excluding) 24 (which is stored in NUM_LEDS).
void loop()
{
  for (int led = 0; led < NUM_LEDS ; led++)
  {
    strip.setPixelColor(led, 255, 255, 255);
  }
  strip.show();
  delay(1000);

  for (int led = 0; led < NUM_LEDS ; led++)
  {
    strip.setPixelColor(led, 255, 255, 255);
  }
  strip.show();
  delay(1000);

To make the code better (shorter, but more important more maintainable, and reducing code duplication), create a separate function:
void loop()
{
  setLeds(255);
  setLeds(0);
}

void setLeds(int intensity)
{
  for (int led = 0; led < NUM_LEDS ; led++)
  {
    strip.setPixelColor(led, intensity, intensity, intensity);
  }

  strip.show();
  delay(1000);
}

Thanks. In the longer script I presume it should be strip.setPixelColor(led, 0, 0, 0);

Yes, because the argument intensity decides when values 0 or 255 are used.