text:
Why do ESP boards break out the SPI flash pins?
I have an ESP32 development board and a NodeMCU board here. Both breaking out the pins for the SPI flash of the ESP. These pins are mentioned in standard pinout descriptions as must/should not connect. This pinout description states, that they

are not recommended for other uses. So, don’t use these pins in your projects

The answer to this question suggests, that you can somehow connect other SPI devices to the same bus as the SPI flash. The linked documentation from that answer states, that in that case you cannot control the chip select for the additional SPI device via a digital pin, but have to let the "hardware arbiter" (whatever that is) decide, when to connect to the additional SPI device.
That is the only use of these pins, that I could find, and even this seems pretty niche. It doesn't seem to be a standard way of usage for the pins and also rather difficult.
Considering the very limited and difficult use of the SPI Flash pins, why do ESP boards break these out to the user? Why aren't they just kept internal, making the board a little smaller?
Maybe there is another use of the pins or I just underestimate the importance of adding additional SPI devices to the bus.

Majenko's answer applies to esp8266 modules. But the question "why on the NodeMcu" remains? Can the NodeMcu Lua firmware use it?

Considering the very limited and difficult use of the SPI Flash pins, why do ESP boards break these out to the user? Why aren't they just kept internal, making the board a little smaller?

The ESP32 is not designed specifically for Arduino. There are other boot modes, such as SD card boot, whereby the internal flash is not directly used. In this situation you are free to use those pins as you wish (given that there is a flash chip attached to them).
The "ESP32 Development Board" was not primarily designed for Arduino. Instead it's a generic board designed by Espressif (and copied many times), and is usable with the Arduino core as one of many options.
In short: the pins aren't there for Arduino users, they're there for other users.

Addendum:
The SPI flash pins can also be used for (and are most commonly used for):

Adding more SPI flash chips which then get integrated into the normal memory space and with the internal caching system, and
Adding PSRAM to increase the RAM memory space.

A good example of the latter is the ESP32-CAM which has an SPI-connected PSRAM chip for framebuffering and image analysis connected to the SPI pins.
You can think of them not so much as SPI pins but as the EBI pins of the PIC32MZ or the EMB of the ATMega2560, etc. Used for expanding the memory rather than for adding random peripherals.

+1. That said, I do find it silly to breakout those pins on consumer-targeted devboards...

@dandavis What's a "consumer-targeted devboard"?  A devboard by definition is not consumer targeted. It's developer targeted. A consumer would never see one.

Fair point, I meant something like a Wemos D1, ESP-CAM, and other's you can buy on consumer sites like ebay/amazon/ali, compared to "pro" dev things from digikey, mouser, TI, and the like...

Most of those are cheap chinese copies of the original Espressif devboard. You may want them, so they give them. Why not? If you don't need them just ignore them. If you do need them then they're there for you. The more people that the board can appeal to the more people will buy it.

Wow, didn't know of the SD card boot. That sounds really interesting. I guess the lines between consumer and developer are a big fuzzy for the field of hobbyists. That explains it for me. @Majenko Thank you for your expertise

@chrisl, SDIO card/device, not SD card

I'm happy to see an answer for this. It has always confused me why those pins are present, and also confuses me when I try to figure out how to connect an SPI peripheral!


text:
Atmega32A fuses
I have Atmega32A and 16 MHz quartz, with 22pF capacitors. Tell me, please, how to set the fuses correctly so that the MK works from external quartz.
Will MK work when setting 0xFF LOW and 0xD8 HIGH? These are the fuses of the Arduino Leonardo
As a result, I want to get a working microcontroller with work from external quartz and that I could rewrite the program.
I use eXtreme Burner - AVR and usbasp

have you searched for a fuse calculator on the internet?

Yes. I already set 0xFB LOW and 0x99 HIGH. After that, my microcontroller does not respond. As with the JP3 jumper on usbasp and without it.

@ОлегС So you've used "Low Freq" Crystal/Resonator... No wonder it's not working with High Freq Crystal

@ОлегС what exactly is your question? ... your post asks how to set fuses, but then your comment says that you already set the fuses

@KIIV And what is the difference between Low Freq 16K CK and High Freq 16K CK?

@jsotola Probably my question is incorrect. Sorry. I just wanted to know how to properly set the fuses, so as not to spoil the next microcontroller.

@ОлегС it's usually weaker driver

This Atmel fuse confuses me a lot so I have figure out an easy way of finding fuses for such controllers basically two methods that I have used once are:
Method 1:(explaining specific for this controller (
    ATmega1284,
    ATmega644,
    ATmega324,
    ATmega164,
    ATmega32,
    ATmega16,
    ATmega8535
))
Add this to your Arduino board manager it is from MCU dude they have different varients also for other controllers check here.
Now select your controller and your clock frequency and all parameters as you like after that use USBASP or Arduino as isp for burning bootloader inside your controller, in this case, we will burn the bootloader into Atmega32A.
After the successful burning bootloader, you will need an AVRdudess software by using this software you have to just read the fuse of our MCU so we will get the fuse setting done by MCUdude from Arduino and after that, you can directly set those fuse setting and it will work fine.
Method2:
just use online calculators such as here for finding fuse settings.

source: Stack Exchange

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

sort: votes


text:
Need help with idea before I buy parts. Want to use arduino to act as the button on a TRRS wire to answer and hang up calls
I intend to buy CH340G USB Microcontroller Board Arduino UNO R3 ATmega328P Development Module
I want to use it and a MOSFET or whatever needed to act as a button for a TRRS wire I already have home made to act as a call button. I know it has to be 0ohm when activated but im not sure if this can be done and with what and how.
I was hoping to have a key on my computer activate the code from the arduino which I dont mind figuring out later but I just need to get an idea on what to use for the button and how I would activate it after wiring.

most (all?) MOSFETs have a diode across source to drain, so that won't work very well with an AC signal like music. You could use a reed relay. The only other non-polar switch i know if is a CDS, but those might have too high a resistance here.

Its not being used for music just to activate like if I took a standard momentary push button from mic to gnd on the TRRS plug. But I wanna do it from Arduino so I can control it on hotkey or mouse button.

you could likely use an nchan fet wired source to gnd, drain to the other side of the button, whatever that's connected to.

Better to use an opto isolator or a small reed relay to keep everything isolated.

If you are trying to answer phone calls, bear in mind that the ring signal is something like 90VAC. (For historical reasons it is enough voltage and current tp ring an electromechanical bell. I've gotten a pretty unpleasant shock before when I was working on phone wiring when a call came in.
That's a problem for 2 reasons: It's too much voltage for all CMOS circuits and most transistors, and transistors can't switch AC. You should isolate the TRRS pins from your digital circuitry, and use a "digital" relay to close the circuit.

DuncanC: This is for a Cell Phone TRRS 3.5mm Audio cable. I dont think its rated that high..
@Majenko: That actually looks like a neat idea. I just need to figure out how that works with a switch that should be off to start.

a reed relay has normally open contacts

For this a reed relay would be my ideal choice. When you're working with audio signals adding anything in there that's not 100% passive could corrupt the audio signal.

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


text:
Slave unreliably sends bit 7
I'm trying to send a byte from an Arduino Nano I2C slave to a Raspberry Pi 3B Master by directly connecting the two I2C pins of each device with no external pull-ups or level converters. It mostly works but the high bit is sometimes misread as a 0 when it should be a 1.
It seems to be caused by that bit being put on the data line at the same time as the clock rising edge so it's not clearly a 0 or a 1. Here's a scope trace showing what I think the problem is for slave address 4 (binary 0000100) and data 231 (binary 11100111). Why is it doing that and how can I fix it?

Another guess is that the Raspberry Pi might be holding the data line low and blocking the slave's value.
Using Wire library on the Arduino and SMBus on the Pi.
EDIT: I added a level converter and the problem is still there, so it's not caused by the 3.3V/5V difference.

With no pull-up and no level converter you shouldn't expect it to work.  Actually it may damage the Pi unless you have the Nano running at 3v3.

@Delta_G Pi has internal 3.3V pull-ups and Nano has higher-valued pull-ups to 5V which don't seem to cause any problem since signals are all 3.3V as shown in scope.

Depending on the speed, the built-in pull-ups might be too large. What happens if you add external pull-ups?

The waveforms aren't rounded off and the voltages are easily correct. How could too-high pullups affect the timing of one or two pulses but none of the others?


text:
Does DFR0063 I2C LCD work with Arduino Due? I cannot even pass i2C scanner
I have 2 Due and Two DFR0063 I2C LCD.  I cannot even pass i2C scanner.
I always got No I2C devices found.  I tried both SCL/SDA and SCL1/SDA1. For SCL1/SDA1, I do add 10K pull up resister. But still not work.
I notice most of example is using Arduino Uno not Due.  So I wonder maybe they just not work together.
I actually just need any Chelp I2C device work smoothy with DUE not other board.
Anyone recommend any goof I2C device for DUE?
Thanks
Joseph

See this link about i2c problem on Due, this was several years ago so not sure whether this was fixed or not.


text:
Problem With interfacing of 16 Servo MG996R with Arduino Uno
I am using 16 MG996R servo motor with PCA9685 servo driver with Arduino Uno, but the motors are not working properly. What is the best power supply/battery for my project as it worked well earlier but is not working right now.

which part of your question is about the Arduino?

I am interfacing PCA using Arduino Uno

You need a power supply that is rated for the same voltage as your servos, and can provide at least the total amount of current for all the servos combined.

Same case here.... Have you solved the problem yet?
Thanks so much!

I use a 2s battery setup. Specifically Tenergy 18650 Lion 2600mah 7.4v. These are PCB protected lithium battery packs.
I use 3 of them in parallel 7.4v  7800mah.
BTW. I also use a UBEC rated at 7 amps to bring the voltage down to 6v.


text:
ESP32 Cannot assign value to string. Getting wrong value
Hello I have problems with strings in my sketch. I assingn values to my string (for example tempStrReturn) in the functions setNr1, setNr2. If i pass the value 1 to the function i get "" or "application/x-www-form-urlencoded" when there should be 1. I don't understand why this is happening.
If you see the output printout from the function setNr1 i get "" then after assigning the value (nr1+"") to the tempStrReturn i still get "". After i use the tempStrReturn in the setNr2 function it asigns a mishmash value to it.
I dont use the tempStrReturn, she is just there for showing the error. When i change the int values of nr1 or nr2 that i want to assign to the string, the value mishmash in the strings changes. With the same numbers the string value has always the same mishmash.
OUTPUT:
192.168.43.140
Function setNR1............
Got: 0
NR1 int: 0
tempStrReturn before:
tempStrReturn after:
Function setNR2............
Got: 1
NR2 int: 1
tempStrReturn before:
tempStrReturn after: application/x-www-form-urlencoded
Function setID...........
String id: ID
Set msgId to: 0
Set msgPos to: 1
Function setNR1............
Got: 1
NR1 int: 1
tempStrReturn before: ID
tempStrReturn after: application/x-www-form-urlencoded
Function setNR2............
Got: 1
NR2 int: 1
tempStrReturn before: application/x-www-form-urlencoded
tempStrReturn after: application/x-www-form-urlencoded
Function setH...........
nr1: 1
nr2: 1
Created value: 11
Original value in string: 0
nrX: 0 nrPos: 1 Value i want to enter: n/x-www-form-urlencoded
Value afther assignment: n/x-www-form-urlencoded

MY CODE:
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <FS.h>
#include <Wire.h>

const char* ssid = "Ti";
const char* password = "1234567891234";
// Stores LED state
String ledState;
// Create AsyncWebServer object on port 80
AsyncWebServer server(80);

#define ledPin 2  //BuiltInLed is inverted
#define countMax 2500
#define multiplyMax 100
int count = 0, multiply = 0, msgDel = 0;
int nr1=0, nr2=0,msgPos, msgId, msgVar;
String inOut[10][10];
String tempStr1, tempStr2, tempStrReturn;
bool oneShot = false;

//***************************************

/*Set value of String[] on the nrPos to val*/
void inOutSet(int nrX, int nrPos, String val)
{
  Serial.print("Original value in string: "); Serial.println(inOut[nrX][nrPos]);
  Serial.print("nrX: ");Serial.print(nrX);Serial.print(" nrPos: ");Serial.print(nrPos);
  Serial.print(" Value i want to enter: "); Serial.println(val);
  inOut[nrX][nrPos] = val;
  Serial.print("Value afther assignment: ");Serial.println(inOut[nrX][nrPos]);
}

String inOutGet(int nrX, int nrPos)
{
  return inOut[nrX][nrPos];
}

String dataRequest(int roomNr)
{
  tempStrReturn = "";
  Serial.println("Preparing to send data as word...");
  Serial.print("Value in TempStringReturn before: "); Serial.println(tempStrReturn);
  tempStrReturn = "g" + roomNr;
  tempStrReturn = tempStrReturn+".";
  Serial.print("Adding g and . : "); Serial.println(tempStrReturn);
  nr1 = 0; nr2 = 0;

  for (int i = 0; i < 9; i++)
  {
    Serial.print("Data Request: "); Serial.println(msgId);
    tempStrReturn = tempStrReturn+inOut[roomNr][i];
    Serial.print("Ading value from inOut: "); Serial.println(tempStrReturn);
  }
  Serial.print("Returning value: ");
  Serial.println(tempStrReturn);

  return tempStrReturn;
}

//saves value to nr1 as int
String setNr1(String var)
{
  Serial.println("Function setNR1............");
  Serial.print("Got: "); Serial.println(var);
  nr1 = var.toInt();
  Serial.print("NR1 int: "); Serial.println(nr1);
  Serial.print("tempStrReturn before: "); Serial.println(tempStrReturn);
  tempStrReturn = nr1+"";
  Serial.print("tempStrReturn after: "); Serial.println(tempStrReturn);
  return nr1+"";
}

//saves value to nr2 as int
String setNr2(String var)
{
  Serial.println("Function setNR2............");
  Serial.print("Got: "); Serial.println(var);
  nr2 = var.toInt();
  Serial.print("NR2 int: "); Serial.println(nr2);
  Serial.print("tempStrReturn before: "); Serial.println(tempStrReturn);
  tempStrReturn = nr2+"";
  Serial.print("tempStrReturn after: "); Serial.println(tempStrReturn);
  return nr2+"";
}

//Creates values for the array
String setID()
{
  Serial.println("Function setID...........");
  msgId = nr1;
  msgPos = nr2;
  nr1 = 0; nr2 = 0;
  tempStrReturn = "ID";
  Serial.print("String id: "); Serial.println(tempStrReturn);
  Serial.print("Set msgId to: "); Serial.println(msgId);
  Serial.print("Set msgPos to: "); Serial.println(msgPos);
  return "ID";
}

//Creates value from nr1 and nr2
String setH()
{
  Serial.println("Function setH...........");
  msgVar = (nr1*10)+nr2;
  Serial.print("nr1: "); Serial.println(nr1);
  Serial.print("nr2: "); Serial.println(nr2);
  nr1 = 0; nr2 = 0;
  if (msgVar >= 99)  {  msgVar = 100;  }
  Serial.print("Created value: "); Serial.println(msgVar);
  inOutSet(msgId, msgPos, msgVar+"");
  return "H";
}

String getIO()
{
  nr1 = nr1/10;
  return dataRequest(nr1);
}

String processor(const String& var){
  Serial.print("Processor in: ");  Serial.println(var);
  return var;
}

void setup() {
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);
  Serial.begin(9600);

  //Filling the inOut array
  for (int i = 0; i < 10; i++)
  {
    for (int x = 0; x < 10; x++)
    {
      inOut[i][x]= "0";
    }

  }

  if(!SPIFFS.begin()){Serial.println("\nSPIFFS chyba!"); return;}

  // Connect to Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi..");
  }

  // Print ESP32 Local IP Address
  Serial.println(WiFi.localIP());

  // Route for root / web page
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send(SPIFFS, "/index.html", String(), false, processor);//change
  });

  //route to favicon
  server.on("favicon.ico", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send(SPIFFS, "/favicon.png", "image/png");
  });

  // Route to load style.css file
  server.on("/style.css", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send(SPIFFS, "/style.css", "text/css");
  });

  // Route to javascript
  server.on("/main.js", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send(SPIFFS, "/main.js", "text/javascript");
  });

// Nr1 of the msg
  server.on("/0", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setNr1("0").c_str());
  });
  server.on("/1", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setNr1("1").c_str());
  });
  server.on("/2", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setNr1("2").c_str());
  });
  server.on("/3", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setNr1("3").c_str());
  });
  server.on("/4", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setNr1("4").c_str());
  });
  server.on("/5", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setNr1("5").c_str());
  });
  server.on("/6", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setNr1("6").c_str());
  });
  server.on("/7", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setNr1("7").c_str());
  });
  server.on("/8", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setNr1("8").c_str());
  });
  server.on("/9", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setNr1("9").c_str());
  });
// Nr2 of the msg
  server.on("/X0", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setNr2("X0").c_str());
  });
  server.on("/X1", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setNr2("X1").c_str());
  });
  server.on("/X2", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setNr2("X2").c_str());
  });
  server.on("/X3", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setNr2("X3").c_str());
  });
  server.on("/X4", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setNr2("X4").c_str());
  });
  server.on("/X5", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setNr2("X5").c_str());
  });
  server.on("/X6", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setNr2("X6").c_str());
  });
  server.on("/X7", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setNr2("X7").c_str());
  });
  server.on("/X8", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setNr2("X8").c_str());
  });
  server.on("/X9", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setNr2("X9").c_str());
  });
//end commands for use the nr values
  server.on("/ID", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setID().c_str());//Set ID nr
  });
  server.on("/H", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", setH().c_str());//Set value to id
  });
  server.on("/G", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", getIO().c_str());//Get value
  });

  // Start server
  server.begin();
}

/*-------------LOOP---------------*/
void loop() {
  count++;
  if (count > countMax)  {    multiply++; count = 0;  }
  if (multiply > multiplyMax)
  {
    if (!oneShot)
    {
      setNr1("0");
      setNr2("1");
      setID();
      setNr1("1");
      setNr2("1");
      setH();
      oneShot = true;
    }

    if (nr1 != 0 || nr2 != 0)
    {
      msgDel++;
      if (msgDel > 5)
      {
        nr1 = 0; nr2 = 0;
        Serial.println("DELETING...");
        msgDel = 0;
      }

    }

    //delay(60000);
    multiply = 0;
  }
}

Also posted at StackOverflow

nr1+"" is not how you convert an integer to a String. All you are doing there is taking the value of nr1 and adding it to the address of a string constant that consists of just a \0. Then assigning that to a String.
The results of such an operation are undefined.
Instead you should go:
tempStrReturn = String(nr1);

which will create a new String object, populate it with the text representation of the value of nr1 then copy that content into the tempStrReturn String.
However I would recommend avoiding using String, even on a chip as capable as the ESP32. Instead use C strings (NULL terminated character arrays) which are far less wasteful of resources.

My point is to add it to a String array. In the function setH i add it via inOutSet() to the two dimensional array inOut[][]. I then send a string message to my website that is completed in dataRequest(). It adds part of the array to one string that i send back to my website. I know that String is a little bit overkill for the poor processor. Any better idea?

Why use strings at all? You have numbers. Store them as such. You only care about them being stringified when you construct your HTTP request.

80%of the values are numbers but not all. I wanted to have one inOut array with all my values. I try to make a web gui. This inOut array will store the values of Analog values, digital values or messages like "Something overfilled". I created the Website and the javascript so that i doesnt need to change the html, css or javascript. All i need to do is to program the sketch.

Do you really need to store the text "Something overfilled" in your array? Why not just a simple flag that says something overfilled, then when you construct your request you say "Is the something overfilled flag 1? Yes? Ok, send 'something overfilled'".

I use it as addresses. inOut[0][1] is the first item on the first page. It should be modular. I don't know in advance which address will be int and which string or what will be the text in it

I understand now The array should be int and only when i complete the string request i add the messages. Thank you I will do so. You helped me alot


text:
PROGMEM for IR command storage
I'm working on a code that is able to send raw data as IR signal to IR transmitter,
the memory of arduino Nano is not enough to store the array in SRAM storage,so i'm about to use PROGMEM to store arrays in flash memory.
these are arrays for IR signal raw command:
unsigned int irSignaloff[]={6060, 7420, 532, 1652, 544, 1668, 508, 1688, 508, 1688, 508, 1692, 532, 1664, 532, 1664, 532, 1664, 536, 604, 528, 588, 548, 580, 552, 580, 528, 636, 500, 600, 532, 588, 548, 580, 552, 1644, 552, 1644, 528, 1664, 532, 1668, 532, 1664, 532, 1668, 528, 1668, 528, 1668, 508, 624, 536, 600, 532, 600, 536, 576, 528, 600, 532, 604, 532, 604, 532, 580, 552, 1648, 548, 1648, 552, 1644, 552, 1648, 552, 1644, 552, 1640, 556, 1644, 528, 1668, 528, 600, 508, 624, 512, 620, 536, 600, 536, 604, 528, 576, 508, 624, 532, 604, 532, 1660, 536, 1660, 540, 596, 536, 1644, 552, 1648, 552, 1644, 552, 580, 524, 1672, 524, 604, 508, 624, 536, 1660, 536, 632, 504, 580, 552, 608, 500, 1668, 528, 600, 508, 1688, 512, 1684, 560, 1668, 504, 660, 500, 1660, 536, 604, 532, 1656, 540, 1660, 540, 584, 548, 580, 528, 596, 512, 1688, 508, 660, 500, 1660, 536, 596, 540, 584, 548, 604, 500, 1672, 528, 600, 512, 1684, 512, 620, 540, 1656, 540, 600, 536, 580, 552, 1644, 552, 576, 528, 1668, 532, 600, 508, 1688, 536, 596, 536, 1660, 540, 1660, 536, 7420, 536};

unsigned int irSignalon[]={6156, 7336, 592, 1588, 612, 1584, 612, 1588, 608, 1588, 608, 1588, 604, 1592, 604, 1592, 604, 1592, 604, 528, 504, 628, 588, 548, 588, 552, 580, 524, 608, 524, 572, 560, 592, 540, 588, 1608, 592, 1604, 592, 1604, 592, 1608, 592, 1604, 592, 1604, 592, 1604, 596, 1600, 596, 524, 608, 520, 584, 544, 596, 540, 596, 536, 596, 524, 608, 520, 604, 524, 588, 1608, 588, 1608, 588, 1608, 588, 1608, 588, 1612, 536, 1660, 572, 1624, 572, 1628, 564, 600, 504, 628, 504, 580, 528, 600, 636, 528, 540, 564, 532, 588, 548, 604, 504, 1664, 532, 604, 504, 624, 536, 1660, 532, 1664, 532, 1664, 532, 604, 532, 1660, 536, 584, 548, 1652, 548, 1644, 552, 580, 556, 572, 532, 604, 532, 1664, 532, 600, 532, 1668, 532, 1660, 536, 1688, 532, 600, 536, 1664, 532, 584, 620, 1576, 552, 1644, 552, 576, 532, 604, 608, 524, 532, 1664, 608, 512, 620, 1576, 548, 580, 556, 572, 600, 536, 604, 1588, 608, 528, 536, 1660, 536, 584, 620, 1580, 620, 508, 596, 532, 508, 1688, 512, 620, 536, 1660, 604, 532, 608, 1588, 604, 516, 620, 1576, 620, 1576, 624, 7308, 552};

and this is sending command uses IRemote.h library:
 irSend.sendRaw(irSignalon, sizeon, FREQ_KHZ, false);

so how can i use PROGMEM to store and read this int array in order to send them?
thanks

Unless the IR library supports reading from PROGMEM you can't use PROGMEM.

You are using 788 bytes there. Yes, that's a lot for a Nano, but way below the limit. Maybe you should be pruning your other RAM usage which must total more than just these two arrays if you are running out of memory.

Understanding/decoding the IR signals and not using the raw timings would be also more space efficient.

do not use raw .... convert the time intervals to actual data ... the first line is unsigned int irSignaloff[]={start, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, end} ..... that is same as hexadecimal 00ff 00ff 00ff 22dd 14eb ab54

what is the make and model of the device that you are controlling?

the device is an Air Conditioner and signal is not decodable with usual libraries because it contains dynamic info about temperature,mode,etc.

you did not answer my question ... what is the manufacturer name?

If your IR library does not support sending signals stored in PROGMEM,
then you will have to provide the data in RAM. However, you do not have
to keep both signals in RAM permanently: only the one you are about to
send needs to be there.
I suggest you keep all the IR signal data in PROGMEM while not sending
them. Whenever you want to send a signal, you copy it to a RAM-based
buffer and give the address of that buffer to the library. The same
buffer will be reused for any signal you are sending. This will cost
you some CPU time for the copy, and save 394 bytes of RAM. The savings
will scale up if you add more signals to your sketch.
const size_t signal_size = 197;

static PROGMEM const uint16_t irSignaloff[signal_size] = { ... };

static PROGMEM const uint16_t irSignalon[signal_size] = { ... };

/* Send an IR signal from PROGMEM. */
void send_signal(const uint16_t *signal) {
    static uint16_t signal_buffer[signal_size];
    memcpy_P(signal_buffer, signal, signal_size * sizeof *signal);
    irSend.sendRaw(signal_buffer, signal_size, FREQ_KHZ, false);
}

//...
send_signal(irSignalon);
send_signal(irSignaloff);

Here I am assuming that all your signals have the same length, which is
true for the example you show, but may be false if you add more signals
later. You may then need to size the buffer as the longest of all your
signals, and provide the signal length as an extra parameter to
send_signal().
Note that the RAM buffer does not need to be static. I chose to make it
static here only in order for avr-size to give you a good estimate of
the memory requirement of the program.

thank you so much, i just added the size of array as input of send_signal function to cover multiple commands and worked fine.
void send_signal(const uint16_t *signal,const size_t size) {
unsigned int signal_buffer[size];
memcpy_P(signal_buffer, signal, size * sizeof *signal);
irsend.sendRaw(signal_buffer, size, khz);
}


text:
A library for interfacing TMS9918 with Arduino
I want to make a personal computer that includes using the ATMEGA8 acting as the CPU, and using an easy to interface DIP IC as video chip. I am considering to interface an Arduino with a TMS 9918 video chip,a chip used a lot in 1980s home computers, to an Arduino-this  seems like a good choice because it uses it own video RAM (instead of the Arduino's which cannot be expanded).
So,my question is, where is the link to a library for interfacing the Arduino Uno  and TMS9918?

I just googled for it and didn't found any Arduino library for that chip. So I guess you need to write that yourself

what do you expect the finished project to be used for?


text:
ModbusMaster - Read 64 Bit integer
i'm using ModbusMaster library (Repo) to read from a device some registers.
Many of them are float and i've no problem to read them using the following code:
  //for float conversation
  union
    {
      uint32_t i;
      float f;
    }u;
    uint8_t result = node.readInputRegisters(address, 2); // for 3000xx registers
    Serial.println("Result : " + String(result));// to get error type
    if (result == node.ku8MBSuccess)
    {
         u.i=(((unsigned long)node.getResponseBuffer(0x01)<<16) | (node.getResponseBuffer(0x00)));// shifting 2nd register to left & stiching with 1st register
    }
    Serial.println("Reading is "+String(u.f));

But i have the energy registers that are 64 Bit unsigned int and i can't figure out how to adapt the above code in order to read them.
Anyone has a solution?

64bit must be stored in two registers. so (r1 << 32) | r2 or (r2 << 32) | r1


text:
ESP32 using PubSub, creating an error when implemted inside a library
I wish to combine into a single library Wifi + MQTT, for a multi devices project.
right after boot, getting Wifi - I get an error the moment MQTT server is trying to connect:
mqttClient.connect(DEVICE_TOPIC, MQTT_USER, MQTT_PASS, MQTTavltopic, 0, true, "offline");
yields :
WiFi connected
IP address: 192.168.3.186
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC      : 0x400d26bd  PS      : 0x00060630  A0      : 0x800d28e8  A1      : 0x3ffb1eb0
A2      : 0x3ffc116c  A3      : 0x3f4010ef  A4      : 0x3f40108c  A5      : 0x3f4010b7
A6      : 0x3ffc106c  A7      : 0x00000000  A8      : 0x800d26b6  A9      : 0x3ffb1e90
A10     : 0x00000000  A11     : 0x3ffc116c  A12     : 0x0000000e  A13     : 0x00000010
A14     : 0x0000000e  A15     : 0x3ffb1d94  SAR     : 0x0000000c  EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xfffffffc

Backtrace: 0x400d26bd:0x3ffb1eb0 0x400d28e5:0x3ffb1ef0 0x400d0fa6:0x3ffb1f20 0x400d103b:0x3ffb1f50 0x400d0e59:0x3ffb1f90 0x400d3651:0x3ffb1fb0 0x40088b7d:0x3ffb1fd0

Rebooting...

I'm sharing both .h and .cpp files.  Library is at its begining - so don't pay attention for irrelevant/ immature parts.
TNX
this is .h file:
#ifndef myIOT32_h
#define myIOT32_h
#include "Arduino.h"

// #include <ESPmDNS.h>
// #include <WiFiUdp.h>
// #include <ArduinoOTA.h>
#include "time.h"
#include "WiFi.h"
#include "secrets.h"
#include <PubSubClient.h>

class myIOT32
{

#define DEVICE_TOPIC "ESP32_SLEEP"
#define MQTT_PREFIX "myHome"
#define MQTT_GROUP ""
private:
    char MQTTmsgtopic[50];
    char MQTTlogtopic[50];
    char MQTTavltopic[50];
    char MQTTdevtopic[50];
    char MQTTlastctopic[50];
    struct tm _timeinfo;
    time_t _epoch_time;
    bool _wifi_status = false;
    char *wifi_ssid; // = "WIFI_NETWORK_BY_USER";
    char *wifi_pass; // = "WIFI_PASSWORD_BY_USER";
    char *mqtt_server;
    char *user = "";
    char *passw = "";

    WiFiClient espClient;
    PubSubClient mqttClient;

public:
    myIOT32(char *devTopic = "no-name", char *ssid = SSID_ID, char *wifi_p = PASS_WIFI, char *mqtt_broker = MQTT_SERVER1, char *mqttU = MQTT_USER, char *mqttP = MQTT_PASS, int port = 1883);
    void looper();
    void start();
    void mqtt_pubmsg(char *msg);
     bool use_wifi = true;
     void startMQTT();

private:

    void MQTTloop();
    void startNTP(const int gmtOffset_sec, const int daylightOffset_sec, const char *ntpServer);
    bool startWifi();
    void getTime();
    void MQTTcallback(char *topic, byte *payload, unsigned int length);
    void createTopics();
    void connectMQTT();
    void subscribeMQTT();
};

endif
and my .cpp file
#include "myIOTesp32.h"

myIOT32::myIOT32(char *devTopic, char *ssid, char *wifi_p, char *mqtt_broker, char *mqttU, char *mqttP, int port)
{
  mqtt_server = mqtt_broker;
  user = mqttU;
  passw = mqttP;
  wifi_ssid = ssid;
  wifi_pass = wifi_p;
}
void myIOT32::start()
{
  if(startWifi()){
      getTime();
      startMQTT();
  }
}
void myIOT32::looper()
{
  MQTTloop();
}

void myIOT32::MQTTcallback(char *topic, byte *payload, unsigned int length)
{
  char incoming_msg[150];
  char msg[100];

  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");

  for (int i = 0; i < length; i++)
  {
    Serial.print((char)payload[i]);
    incoming_msg[i] = (char)payload[i];
  }
  incoming_msg[length] = 0;
  Serial.println();
}
void myIOT32::createTopics()
{
  sprintf(MQTTmsgtopic, "%s/%s", MQTT_PREFIX, "Messages");
  sprintf(MQTTlogtopic, "%s/%s", MQTT_PREFIX, "log");
  sprintf(MQTTdevtopic, "%s/%s", MQTT_PREFIX, DEVICE_TOPIC);
  sprintf(MQTTavltopic, "%s/%s", MQTTdevtopic, "Avail");
  sprintf(MQTTlastctopic, "%s/%s", MQTTdevtopic, "nexton_command");
}
void myIOT32::connectMQTT()
{
  if (!mqttClient.connected())
  {
    mqttClient.connect(DEVICE_TOPIC, MQTT_USER, MQTT_PASS, MQTTavltopic, 0, true, "offline");
  }
}
void myIOT32::subscribeMQTT()
{
  mqttClient.subscribe(MQTTdevtopic);
  mqttClient.subscribe(MQTTlastctopic);
}
void myIOT32::mqtt_pubmsg(char *msg)
{
  mqttClient.publish(MQTTmsgtopic, msg);
  Serial.print(MQTTmsgtopic);
  Serial.print("/");
  Serial.println(msg);
}
void myIOT32::startMQTT()
{
  mqttClient.setServer(mqtt_server, 1883);
  mqttClient.setCallback(std::bind(&myIOT32::MQTTcallback, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
  createTopics();
  connectMQTT();
  subscribeMQTT();
}
void myIOT32::MQTTloop()
{
  static long lastReconnectAttempt = 0;

  if (mqttClient.connected())
  {
    mqttClient.loop();
  }
  else
  {
    long now = millis();
    Serial.println("MQTT Server- NOT connected");
    if (now - lastReconnectAttempt > 5000)
    {
      lastReconnectAttempt = now;
      connectMQTT();
      subscribeMQTT();
    }
  }
}

void myIOT32::startNTP(const int gmtOffset_sec = 2 * 3600, const int daylightOffset_sec = 0, const char *ntpServer = "pool.ntp.org")
{
  configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
}
bool myIOT32::startWifi()
{
  long beginwifi = millis();
  WiFi.begin(wifi_ssid, wifi_pass);

  while (WiFi.status() != WL_CONNECTED && millis() - beginwifi < 30000)
  {
    delay(200);
    Serial.print(".");
  }

  if (WiFi.status() == WL_CONNECTED)
  {
    Serial.println("");
    Serial.println("WiFi connected");
    Serial.print("IP address: ");
    Serial.println(WiFi.localIP());
    startNTP();
    return 1;
  }
  else
  {
    Serial.println("NO-WiFi");
    return 0;
  }
}
void myIOT32::getTime()
{
  int a = 0;
  while (a < 3)
  {
    if (getLocalTime(&_timeinfo))
    {
      delay(100);
      time(&_epoch_time);
    }
    a++;
  }
}

myIOT32::myIOT32(char *devTopic, char *ssid, char *wifi_p, char *mqtt_broker, char *mqttU, char *mqttP, int port)
    : mqttClient(espClient)  // <--- this part was missing *****
{


text:
Arduino Due with Logitech F710 gamepad
I'm having Arduino Due board and Logitech F710 Wireless Gamepad. I have connected the receiver dongle to native port of Due board via OTG cable.
As the native usb host library supports only keyboard and mouse,
pease help me with correct library for connecting my gamepad with Due board without usb_host_shield as I have budget constraint and space constraint.
Thanks in advance

it is unclear what you are wanting to do ... what are the two things that you want to connect together?

Logitech F710 Wireless Gamepad -> USB OTG -> Arduino Due (Native Port)

here is a project that may get you started ... https://tutorial.cytron.io/2019/05/01/interfacing-logitech-wireless-gamepad-f710-using-arduino/

This is done with the help of external usb shield. I want to make use of the usbhost built-in Due board. Default it only supports keyboard and mous. I want to know how to extend that to Logitech f710 Gamepad.

that library shows you how to talk to the gamepad ... you will have to adapt the code to your device


text:
Stopping the program after 1 second
I am a Beginner in Arduino Programming.
I am working on a project where I control A DC motor with IR sensor and arduino.
Until here it is fine. But I want the Motor to stop after one second even though the IR sensor detects the Obstacle
Here's My Program
Pin 2- IR Sensor
Pin 4,5,6- Motor
enter code here
//Included Libraries
#include <motor.h>

//MACROS are defined here
Motor Motor1(4, 5, 6);

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

    pinMode(2, INPUT);

}

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

    if(digitalRead(2)) {
        Motor1.moveMotor(2.55*0);
    }
    else {
        Motor1.moveMotor(2.55*100);
    }
}

Can anyone help out in this Program. I Just want the Motor to stop after one second.
Thank you in advance!

First, edit your question, select all of your code, and tap the {} button to format it.

Also, you need to explain your goal more clearly. What should start your motor? The IR sensor? You say "I want the Motor to stop after one second as soon as the sensor detects the Obstacle." I don't understand what that means. You want it to run for at least one second no matter what, and after a second passes, have the IR sensor stop it if it detects and obstacle?

“after one second” alongside “as soon as” is a contradiction.

You show code that reads pin 2. Is that your IR sensor? What do the 2 different motor calls do? Does moveMotor(0) stop the motor, and moveMotor(255) cause the motor to move?

I am sorry, I dint make my point Clear. I edited the Question. Thanks

For doing timed things, learn how to use the millis() functions. Look at the BlinkWithoutDelay example and google for tutorials about that function. When you are understanding how these examples and tutorials work, you will be able to adapt that for your code.

The moveMotor(0) stops the motor and the moveMotor(2.25*100)  makes the motor run.

You improved a few things, but we still can't understand your goal. Please post a complete statement of how you want your sketch to behave. The phrase "I want the Motor to stop after one second as soon as the sensor detects the Obstacle" does not make sense. The "After one second" part is contradicted by the
"as soon as the sensor detects an Obstacle" part.

Does Motor1.moveMotor(2.55*100); delay(1000); Motor1.moveMotor(0); work for you?

look at example sketches in the Arduino IDE ... look at the one named StateChangeDetection

You need to use read the time (millis()) when you start the motor and read it frequently while the motor is running to know when to stop it. You also need to keep track of the sensor, and don't start the motor again until after you've seen the sensor turn off (detect no obstacle). Here is an outline of the logic in psuedo-code; turn this into a detailed loop() function in C++:
if the motor is ON {
  if (millis() - motorStartMillis) > 1000 {
  stop the motor;
}
else if sensor is ON {
  if the sensor was OFF {
    start the motor;
    motorStartMillis = millis();
    sensorWasOn = true;
  }
}
else {      // sensor must be off
  sensorWasOn = false;
}


text:
NodeMCU Power supply
I got a question about externally powering my NodeMCU V3. It has an onboard voltage regulator (3v3) which breaks out to 3 header pins. Now I want to power 3v3 from an external board. Can I supply 3v3 to all of those pins at the same time? (Basically connected in parallel).
Anyone has done this before or has this experience with NodeMCU V3?
I have supplied a link below:
https://www.theengineeringprojects.com/2018/10/introduction-to-nodemcu-v3.html
Thanks a lot!

Yes, you may connect all 3V pins together (red) and all GND pins together (black), like so:

In some cases, more wires will improve the circuit. E.g. when you build the Ben Eater 8-Bit CPU, you'll find that connecting power in a ring instead of a line will reduce voltage drop by about 50%.

When first reading your question, I got the impression that you wanted to solder the 3.3 V wires directly to the voltage regulator. Here's my original answer for that:
That's not a good idea: if you connect the same wire to all pins, your're creating a short, typically causing a malfunction if not worse. You may destroy your equipment (external board as well as the NodeMCU v3). Do NOT connect 3.3V to all pins of the voltage regulator.
A voltage regulator has 3 pins:

voltage in (for an unregulated voltage you can't exactly control; typically higher than the output voltage)
voltage out (for the stabilized resulting voltage you want to have)
ground

The only pin to connect the voltage to is the "voltage in" pin (VIN). And typically, a development board has a pin for that:

However, you'll find that the input voltage must be between 4.75V and 10V, so supplying 3.3V from an external board is not sufficient.
If you have regulated (stable) 3.3V already, you can connect that to a pin labelled 3V:

Also, you need to connect the grounds (GND) of both circuits together (GND of external board to GND of NodeMCU), otherwise the current will not find its way back.

I don't believe the OP wants to short the regulator, but externally apply 3V3 to the circuit

Hi! Thanks for your replies!
Like Sim Son said, I would just like to externally supply the 3V3 pins with a voltage regulator. Would it hurt if the 3, 3V3 pins are tied together to the same net? Would it give me problems?

@sanrays10: yes, that's possible. I've updated the answer and uploaded an image where I did exactly that.

Thanks a lot! Just what I needed to know!


text:
Why am I only seeing 1.3V on an analog pin that has been set to high using digitalWrite?
I have run into a bit of trouble with a sewable electronics project. I am trying to power a SparkFun 7-Segment Serial Display from one of the analog ports of a ATmega328 board. I realize this is unconventional, but I designed the circuit to not require any crossed connections to make the sewing a bit easier, and that was the only way to do it. The display wouldn't light up, and after some debugging with a multi-meter it turned out that the analog pin I was using (A3) was only at 1.3V despite a digitalWrite command. I tested the same command on one of the other analog pins (A0) and it produced 5V as expeced. When I bridge the VCC pin and A3, everything works fine. When I set A0 to 5V , and bridge it with A3, the output voltage drops to 1.8V relative to GND.
The really weird thing is that just running the example code from the sparkfun website without any modifications still somehow results in a \~1.2V reading from A3 to GND. I have no clue what is going on here. Usually I would disconnect the display from A3 and keep testing, but I am trying to avoid it. Troubleshooting is difficult as I had to clip the excess tails to prevent short circuits making me extremely reluctant to disconnect anything until I have figured out what the problem is, as the thread is very hard to work with, and it took the project on the order of 60 man-hours to get where it is. I was hoping someone here might know what is going on, or point me in the right direction.

You should measure required current first. There is possibility the A3 output driver is already destroyed. I'd expect it needs over 100mA if you lit everything on.

The doc says it should not draw more than 14.1 mA @ 5 V.

The sample code you mention uses Hardware SPI, with fixed pins. Check the desired digitalWrite separately and if it shows your atmega328 still alive, you can post your actual problem here.

I am using the I2C example code. What are you looking for me to check? I can get the atmega in the lillipad to control the other pins just fine.

The supply current is without including the LEDs. That's just for the ATMega328P on the board. You can add up to 24mA for the LEDs (with 1kΩ resistors on the board and 2V forward voltage for the LEDs, and multiplexed in groups of 8) depending on the number of LEDs turned on at any one time.  Yo A3 pin is daid!  You should never try and power anything like that from an IO pin.

As I said, I don't have a choice without crossing wires. Where would I find the actual maximum draw?

"I don't have a choice without crossing wires." You don't have a choice period. If you draw more than 14 mA from the pin, you will overload it and possibly burn it out. If you tried to power a 7 segment serial display from an analog pin on your Arduino you very likely fried the pin, and possibly the whole board.

A single LED will draw up to 20mA. (or more for a high current LED. A 7-segment display will draw 7x4 times that. If it's multiplexed, it might only light one digit at a time, so only 7 times the single LED current. Plus the 14 mA for the microcontroller on that unit adds up to way, waaaay more than you can draw from any one output pin on an Arduino.


text:
ESP32 proper DS18B20 wiring
I want to connect a DS18B20 to my newly bought Heltec ESP32 LoRa (V2). For initial testing I have used some standard code:
#include "heltec.h"
#include <OneWire.h>
#include <DallasTemperature.h>

OneWire ds(14);
DallasTemperature sensors(&ds);

void getDS18B20values()
{
  Serial.print(" Requesting therms...");
  sensors.requestTemperatures();
  Serial.println("DONE");

  uint8_t count = sensors.getDeviceCount();
  for (int i = 0; i < count; i++)
  {
    Serial.print("Temperature " + String(i) + "is: " + String(sensors.getTempCByIndex(i)));
  }

  delay(1000);
}

void setup()
{

  //WIFI Kit series V1 not support Vext control
  Heltec.begin(
      true /*DisplayEnable Enable*/,
      true /*Heltec.LoRa Disable*/,
      true /*Serial Enable*/,
      true /*PABOOST Enable*/,
      868E6/*long BAND*/);

  sensors.begin(); // initialize therm-sensors
}

void loop()
{
  getDS18B20values();

  delay(1500);
}

Here's a quick schematic I designed with the designer provided by stackexchange. Not all parts were available so I had to improvise a litte. I hope it is accurate enough.

simulate this circuit – Schematic created using CircuitLab
Another weird thing is that if I wire it all up I can start the ESP but I can't flash any new software to it because it doesn't react. So I assume it's a wiring issue the code should be fine but I posted it anyway. I had tested it with multiple DS18B20 sensors. A while ago on an Arduino they were all still working. I am more experienced with Arduinos than with ESPs. Are there any differences in regard to the wiring I have to be careful of?
Edit: I already have some sensored wired to the ESP, a BH1750, DHT11, an analog soil moisture sensor and an analog light dependent resistor.

Please just use a blank rectangle if you can't find the proper schematic symbols instead of random components.

You should become sceptical when connecting two pins of a device together :) if that was correct, the manufacturer hinself could have connected those pins inside the device and one of the pins wouldn't be there

I have not checked your code, but you certainly have a wiring issue.
There are two main problems.

Your Vcc is connected to the data output of the DS18B20. This means you will never read anything except logic "high" from the data output.
The 4k7 resistor should not be connected this way. See the schematic below on how it should be connected. You could also set up a data pin with an internal pullup so you don't need an external pullup.

This is roughly how it should look.

simulate this circuit – Schematic created using CircuitLab


text:
HC-05 Stuck in slave loop mode (loopback)
got my HC-05 today and accidently set the AT+ROLE=2(slave loop) and now I can't get out of it! Anything I send it just resends it back to me, even commands like AT+RESET and AT+ORGL, they just get returned. I can't figure out how to put the device back in slave mode, your help would be highly appreciated!

H., you have to connect the module in the natural configuration mode to receive AT commands by default, which it is at 38400 Baud. Try sending AT with the arduino console (with carreturn and new line control). If this works then send AT+MODE=0.
Also, from here, you can send AT+ORGL to set original from factory. I usually use a CP2102 usb-serial interface with the hc-05 module, and the YAT serial terminal program from windows, because it is comfortable for me. Greetings. jvarl.


text:
what command should i use to read and write through spi.tranfer command
#include<spi.h>
byte val;     // variabe for storing temp data
#define PIN_SPI_SS    (9)
#define PIN_SPI_MOSI  (10)
#define PIN_SPI_MISO  (11)
#define PIN_SPI_SCK   (12)

void setup();
pinMode(SS,output);
pinMode(SCLK,output);
pinMode(MOSI,output);
spi.setBitorder(MSBFIRST);
SPI.setDataMode(SPI_MODE3);
serial.begin(9600);
spi.begin();

void loop();
  digitalWrite(SS,LOW);
  uint8_t b1 = SPI.transfer(0x00);
  uint8_t b2 = SPI.transfer(0x00);
  uint8_t b3 = SPI.transfer(0xFF);
  digitalWrite(SS,HIGH);
  int16_t val = b1 | b2 ;
  serial.print("val=");
  serial.println(val,DEC);

refer for DATA SHEET//https://www.ti.com/lit/ds/symlink/lm74.pdf?ts=1591436049550&ref_url=https://www.ti.com/product/LM74
my problem is i am not able to know what command should i use in SPI.transfer function for writing & reading  temperature data here i use 0x00 for reading 16 bit data of temperture register,but what about writing in configuration register  ,LM74 use 0xFF command for shutdown mode,but  how we came to know that 0xFF refer only to configuration register.

In the LM74 the third byte you send (or more specifically the last 8 bits of up to 32 bits past the 16th bit that you send) is read and used as the configuration register setting.
Since the configuration register only has two states 0xFF is go to sleep sleep and 0x00 is do conversions (as shown in table 1 of the datasheet).
So:
0x00 0x00 0xFF

means get one result then go to sleep.
0x00 0x00 0x00

means get one result and stay awake.
If the LM74 is currently asleep from an 0x00 0x00 0xFF sequence the result you get returned is not a temperature but the chip's manufacturer ID.
It's not an obvious method of controlling a chip, and it's actually pretty poorly written in that datasheet, so don't feel bad about not understanding it, it took me a few moments to understand it.


text:
Car freaks out on CANBUS shield connection
So, I'm trying to connect to my car's CAN-BUS (via the OBD2). I initially ordered a cheep shield then an even cheaper module to provide connection between my uno and the car.
Using the module I was able to use some of the example libraries to successfully connect to the car and even get some IDs out. There was no data alongside the IDs so I figured my module needed upgrading.
I bought the seeedstudio shield and used their libraries. At first I had the CANH and CANL connected into the car before starting it but that seems to have overwhelmed the car and I couldn't start it, it behaved as if the battery was dead.
Eventually when it recovered I tried again, this time the car was already running. Havig the CANL&H connected and the shield attached to the arduino and using the example sketches, when I provided power to the Arduino via the USB port the car started freaking out. The dials went crazy and started moving left to right and all sorts of warning messages started appearing on the dash - "check airbag", "engine motion something.." Disconnecting the shield from the car stops the freaking out and removes the errors displayed.
Any idea what's going on ?
Also should any of these be soldered to each other as the manual suggests there's some cutting and soldering there but I haven't cut nor soldered anything and this is how the shield arrived.
Worth pointing out that I tried connecting to both Pin6 as the proper CANH and also Pin1 as that one was discovered to also provide CANBUS data for the cabin. Here's the obd2 diagram pinout for my car.

This is old but for the sake of anyone who finds this. I cannot say for sure but Im pretty sure what you were seeing (gauges acting crazy) is due to your can card trying to communicate across the bus network at the same time as another moduL. If you were using this on an older car only one module “speaks” at any given time. Currently this is the same problem i am having which brought me to your post as i am trying to figure out which module in my car has a problem. My problem is so intermittent that back probing the individual modules doesnt help as the problem may only surface once every week

continuation of Shizzavip's answer converted to comment: ... or two. Gauges go wack. Either it will take care of itself after few minutes of driving or I can turn off and on and back to normal. So i am trying to build a arduino with canbus shield to just sniff so i can log to memory card and try and figure out which module is having problem.

You are lucky you did not damage your vehicle. The bus is not the same on all cars.


text:
Arduino Trinket and CCS811 sensor
I have connected trinket and CCS811
I am trying to build and upload sketch to the module:
  /******************************************************************************
  Read basic CO2 and TVOCs

  Marshall Taylor @ SparkFun Electronics
  Nathan Seidle @ SparkFun Electronics

  April 4, 2017

  https://github.com/sparkfun/CCS811_Air_Quality_Breakout
  https://github.com/sparkfun/SparkFun_CCS811_Arduino_Library

  Read the TVOC and CO2 values from the SparkFun CSS811 breakout board

  A new sensor requires at 48-burn in. Once burned in a sensor requires
  20 minutes of run in before readings are considered good.

  Hardware Connections (Breakoutboard to Arduino):
  3.3V to 3.3V pin
  GND to GND pin
  SDA to A4
  SCL to A5

******************************************************************************/
#include <Wire.h>

#include "SparkFunCCS811.h" //Click here to get the library: http://librarymanager/All#SparkFun_CCS811

#define CCS811_ADDR 0x5B //Default I2C Address
//#define CCS811_ADDR 0x5A //Alternate I2C Address

CCS811 mySensor(CCS811_ADDR);

#include <SoftwareSerial.h>
const int rx = 0; //3
const int tx = 2; //4
const int alarmPin = 4;
SoftwareSerial mySerial(rx, tx);

void setup()
{
  mySerial.begin(9600);
  mySerial.println("CCS811 Basic Example");

  Wire.begin(); //Inialize I2C Hardware

  pinMode(alarmPin, OUTPUT);
}

void loop()
{
  //Check to see if data is ready with .dataAvailable()
  if (mySensor.dataAvailable())
  {
    //If so, have the sensor read and calculate the results.
    //Get them later
    mySensor.readAlgorithmResults();

    mySerial.print("CO2[");
    //Returns calculated CO2 reading
    double val = mySensor.getCO2();
    mySerial.print(val);
    if(val>=2000){
      digitalWrite(alarmPin, HIGH);
    }
    //Serial.print("] tVOC[");
    //Returns calculated TVOC reading
    //Serial.print(mySensor.getTVOC());
    //Serial.print("] millis[");
    //Display the time since program start
    //Serial.print(millis());
    //Serial.print("]");
    //Serial.println();
  }

  delay(10); //Don't spam the I2C bus
}

However when I verify the sketch I get following errors:
In file included from C:\Users\Nitin\Desktop\co2\co2.ino:26:0:

C:\Users\Nitin\Documents\Arduino\libraries\SparkFun_CCS811_Arduino_Library\src/SparkFunCCS811.h:77:28: error: 'TwoWire' has not been declared

  CCS811_Status_e beginCore(TwoWire &wirePort);

                            ^~~~~~~

C:\Users\Nitin\Documents\Arduino\libraries\SparkFun_CCS811_Arduino_Library\src/SparkFunCCS811.h:97:2: error: 'TwoWire' does not name a type; did you mean 'Wire'?

  TwoWire *_i2cPort; //The generic connection to user's chosen I2C hardware

  ^~~~~~~

  Wire

C:\Users\Nitin\Documents\Arduino\libraries\SparkFun_CCS811_Arduino_Library\src/SparkFunCCS811.h:112:13: error: 'TwoWire' has not been declared

  bool begin(TwoWire &wirePort = Wire);         //Use the Wire hardware by default

             ^~~~~~~

C:\Users\Nitin\Documents\Arduino\libraries\SparkFun_CCS811_Arduino_Library\src/SparkFunCCS811.h:113:34: error: 'TwoWire' has not been declared

  CCS811_Status_e beginWithStatus(TwoWire &wirePort = Wire);    //Use the Wire hardware by default

                                  ^~~~~~~

C:\Users\Nitin\Documents\Arduino\libraries\SparkFun_CCS811_Arduino_Library\src/SparkFunCCS811.h:112:33: error: could not convert 'Wire' from 'TinyM_USI_TWI' to 'int&'

  bool begin(TwoWire &wirePort = Wire);         //Use the Wire hardware by default

                                 ^~~~

C:\Users\Nitin\Documents\Arduino\libraries\SparkFun_CCS811_Arduino_Library\src/SparkFunCCS811.h:113:54: error: could not convert 'Wire' from 'TinyM_USI_TWI' to 'int&'

  CCS811_Status_e beginWithStatus(TwoWire &wirePort = Wire);    //Use the Wire hardware by default

                                                      ^~~~

Multiple libraries were found for "Wire.h"
 Used: C:\Users\Nitin\AppData\Local\Arduino15\packages\adafruit\hardware\avr\1.4.13\libraries\Wire
 Not used: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire
Multiple libraries were found for "SparkFunCCS811.h"
 Used: C:\Users\Nitin\Documents\Arduino\libraries\SparkFun_CCS811_Arduino_Library
 Not used: C:\Users\Nitin\Documents\Arduino\libraries\arduino_613982
Using library Wire at version 1.0 in folder: C:\Users\Nitin\AppData\Local\Arduino15\packages\adafruit\hardware\avr\1.4.13\libraries\Wire
Using library SparkFun_CCS811_Arduino_Library at version 2.0.1 in folder: C:\Users\Nitin\Documents\Arduino\libraries\SparkFun_CCS811_Arduino_Library
Using library SoftwareSerial at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial
exit status 1
Error compiling for board Adafruit Gemma (ATtiny85 @ 8MHz).

I see that this library - SparkFun_CCS811_Arduino_Library is not compatible with trinket
https://github.com/sparkfun/SparkFun_CCS811_Arduino_Library/issues/19
can anyone give me pointer to write sketch for trinket connected to CCS811 sensor?

read the error printout carefully ... what is it telling you?

Looks like you have two choices

Use a different controller that is compatible with the normal Arduino Wire library - maybe something like the Nano?
Modify SparkFunCCS811.h to #include TinyWireM.h instead of Wire.h. This is actually not hard at all - just takes a bit of patience and the knowledge that "there is no magic".

Frank


text:
How do I know if I need to use a resistor in a circuit?
I have been trying to find answers on Google to this question but cannot seem to find any answers that actually pertain to what I am wanting to know.  I would consider myself a beginner in the area of electronics having some experience but not understanding how everything comes together outside of the some of the basics.  What I am wondering is this; How can I tell if I need to use a resistor in a circuit?  More specifically, When I am hooking sensors up to an Arduino, how can I determine if I need resistors in the circuit?  Anywhere I look I typically see the default LED/Resistor example but that is not helpful.  It doesn't explain how Arduino/Raspberry PI modules and sensors fit into the equation.  I know the data sheets for the various modules/sensors explain how much current is needed/used by the device but how do I take that and apply it to an Arduino circuit?  Thanks in advance.

the answer it ... it depends. resistors are used to limit current mostly, so it depends if the sensor needs this (and on which pins). The best way is to read into the datasheet, there are mostly examples shown for a typical circuit.

From the specifications of the sensor, you know the maximum current the sensor should be allowed to draw. Suppose you need to put 5v across the sensor.
Then write down Ohm's law: E = IR (the voltage across a component is given by the product of its resistance and the current through it. You need to know the value of a resistor to put in series with the sensor to limit the current to that maximum value or less. So solve Ohms law for resistance (R) of voltage (E):
R = E/I or 5v / maximum current.
That gives you the values of a series resistor to limit the current to the maximum, assuming the sensor has no (or very little) internal resistance of its own.
Or let's look at an LED, where the spec sheet gives you both the maximum current and the internal voltage drop (called "forward voltage"). If you don't need the LED to run at full power (and you probably don't), it will last longer if you limit it to less than that, so let's take 75% as a working figure and calculate the serial resistor to give 75% of maximum current. Red LEDs typically have 2v forward voltage and 15 milliamps max current (but don't build for "typical" parts - build for the part you have). We'll assume a 5v power supply:
R = E/I = (5v - 2v) / (.015 X 0.75)  = 3 / .01125 = 266 Ohms.
So we'd pick an available resistor value close to 266 Ohms (no need to be exact here - we've already left a safety factor by reducing the current 25%).
If you calculate the voltage (again, using Ohm's law) across the 266 (or whatever you used) Ohm resistor, you'll find a voltage drop of about 3v, and adding the LED's forward voltage of 2V, you'll get the power-supply voltage of 5v.

simulate this circuit – Schematic created using CircuitLab
Update:

Why do we need a resistor on an LED which draws 15mA of current which
the Arduino can supply nicely, but we don't on a sensor like the
HC-SR04 which draws 15mA of current?

It's about the behavior of the component or module itself, and that needs a datasheet for the component and spec-sheet for the module. An LED has a forward voltage drop but otherwise looks like a nearly short circuit, so it requires a resistor to protect it from over-current. A module often provides some circuitry around the component to help the user integrate into their project. Of course, how much help it provide is up to the designer. One module may offer nothing more then breadboard-compatible pins where another one - for the same device - may have power-conditioning or power supply components, 3.3v <-> 5v logic-level shifters, and protective circuitry to help protect an expensive component from misuse.
Why does this component need a resistor and another one doesn't? It's up to the electrical behavior of those components. Here's a trivial, but I hope illustrative example:

The device on the left might be considered an LED module, compared to the one on the right which is just an LED. Obviously, all I've done is to solder a current limiting resistor in place on one leg to make a ready-to-go breadboard LED. It is designed for 5v circuits; putting it in a 12v circuit would fry the LED. Here is where I (as the "module designer") used the LED's datasheet to know what circuitry it needed to protect it, and as the "consumer", would need to consult the spec sheet for the module to know how to apply it. If I were selling these things, they'd come with a Spec Sheet: "Only use this LED module in 5v or less applications."]  Hmph - pretty trivial example, but you get the idea.

Thanks for the response.  I think I understand the part of ohms law, however, Where my confusion has been coming in is, we put a resistor on an LED but some of the 'starter' kit tutorials like the ones from SparkFun use different sensor modules such as the HC-SR04 Ultrasonic Sensor, without putting resitors into the circuit.  That is what I don't understand.  Why do we need a resistor on an LED which draws 15mA of current which the Arduino can supply nicely, but we don't on a sensor like the HC-SR04 which draws 15mA of current?  What determines I need a resistor here but not there?

Also, do modules and sensors work differently in determining the need for resistors?  I notice that some modules have resistors built into them.  Does that mean I don't need to add a resistor into the circuit from my Arduino to my module?

The HC-SR04 is an entire module with lots of components on it. It is, itself, an entire circuit.  The LED is a single component. It needs other components with it to make it a circuit. One of those is the resistor.

How can I tell if I need to use a resistor in a circuit?

You can tell because the circuit includes a resistor.
If a circuit needs a resistor the circuit diagram will include a resistor. If it doesn't, then it won't.
The circuit for connecting an LED to an Arduino consists of an Arduino, an LED and a resistor.  Because of that you know it needs a resistor. Because it says it needs a resistor.
A resistor drops a certain voltage across it when a specific current flows through it (Read up on Ohm's Law...). If you need to drop a specific voltage with a specific known current, or if you need to cause a specific current to flow with a fixed voltage, then you use a resistor for that job.
You don't just throw resistors willy-nilly into every circuit you make simply because you see one being used with an LED.
If a device says it runs off 5V and uses 300mA current then you know that you need to hook it up to a power source that is 5V. You also know that the module will use up to 300mA of current from that source, so your source has to be capable of providing at least that much current.


text:
When does the ADC start reading again in interupt mode?
Simple question, I have set my ADC to read in "continuous"/interrupt mode and I take the reading the following way:
ISR(ADC_vect) {
   int val = ADCL;
   val += ADCH << 8;
   ... //Code to do stuff with reading here.
   }

My question is does the ADC start the new reading as soon as I have read the ADCH register or does it wait for the code inside the interrupt to finish? Basically I need to know if having more instructions in the interrupt will slow down my reading rate.
I don't have an oscilloscope or any good way to measure my reading rate accurately enough to know if a few extra lines of codes is affecting the rate or not.

Your answer is correct. The ADC does indeed keep going independently of
what the ISR does. There is, however, a point I would like to make
clearer. You asked:

My question is does the ADC start the new reading as soon as I have
  read the ADCH register or does it wait for the code inside the
  interrupt to finish?

The ADC starts a new reading as soon as it is done taking the previous
one, irrespective of whether you read ADCH or not. When your ISR
starts, the ADC is already busy making the following conversion. This
guarantees a steady conversion rate, at one A/D conversion every
13 ADC clock cycles exactly.
As a side note, you can read the result with
int val = ADC;

No need to read the bytes separately unless you are using a very ancient
version of gcc that does not know how to read a 16-bit register.

Thanks for the clarification :) Quick unrelated question (if you don’t know the answer I’ll delete this comment). In some debugging efforts I hooked up the A0 pin I was reading from to ground with a 300k resistor between them and got some rather significant ( up to 20 ) readings from it, fluctuating like a wave. I would expect it to be 0, what exactly is being measured when doing this? I thought the ADC did not recieve any voltage inside itself so where is the voltage comming from? :s guessing this is related to ”floating pin readings”, but I am still confused.

@BeaconofWierd that's probably your circuit catchinh some electromagbetic radiation and 300kOhm is simply too high to pull the analog pin to ground in that case. If you imagine you increase this resistance, at some point you would consider the pin floating (maybe at 1MOhm or at 100MOhm?).

@BeaconofWierd: I agree with Sim Son that the resistance is too high. According to the datasheet, the ADC should be fed the voltage to be measured from a source with no more than 10 kΩ of internal impedance.

Ok, I'm pretty sure I know the answer to this one now after some more testing. I played around with the number of instructions performed inside the ADC interrupt call and simply timed it using micros(). Though it did not give me super precise accuracy there was a clear and quick drop in read frequency when the number of CPU cycles needed inside the interrupt call exceeded the number of CPU cycles needed by the ADC while the frequency was hardly affected when the CPU cycles needed for the instructions were less than the cycles needed for the ADC. The only way I can make sense of this is if the ADC keeps going independently of the code that's inside the interrupt.
If someone wants to correct me/add some details here I would be very happy. But for my purposes this answer is enough :)


text:
Error in defining Ticker in ESP32 library
I'm using the exact piece of code in my ESP8266 library (which works OK ), but when used in a ESP32 library- I got an error:
This is the relevant code snip:
void myIOT32::_feedTheDog()
{
  _wdtResetCounter++;
  if (_wdtResetCounter >= _wdtMaxRetries)
  {
    sendReset("Dog goes woof");
  }
}
void myIOT32::_startWDT()
{
  wdt.attach(1, std::bind(&myIOT32::_feedTheDog, this)); // Start WatchDog
}

void myIOT32::sendReset(char *header)
{
  char temp[150];

  sprintf(temp, "[%s] - Reset sent", header);

  if (useSerial)
  {
    Serial.println(temp);
  }
  if (strcmp(header, "null") != 0)
  {
    pub_msg(temp);
  }
  delay(1000);
  ESP.restart();
}

and this is the error:
/home/guy/Documents/git/Arduino/libraries/myIOTesp32/myIOTesp32.cpp: In member function 'void myIOT32::_startWDT()':
/home/guy/Documents/git/Arduino/libraries/myIOTesp32/myIOTesp32.cpp:333:55: error: no matching function for call to 'Ticker::attach(int, std::_Bind_helper<false, void (myIOT32::*)(), myIOT32*>::type)'
   wdt.attach(1, std::bind(&myIOT32::_feedTheDog, this)); // Start WatchDog
                                                       ^

ESP32 ticker attach functions take pure function pointers with at max one argument type -- not a std::function/ std::_Bind_helper that std::bind produces.
See code and types at https://github.com/espressif/arduino-esp32/blob/master/libraries/Ticker/src/Ticker.h#L38.
For the ESP8266 however, they do use a std::function:
https://github.com/esp8266/Arduino/blob/master/libraries/Ticker/src/Ticker.h#L36
And that's why it works on ESP8266 and not on ESP32 -- either adapt the Ticker library or rework your own code to not use member functions of classes.
Edit: You can easily rewrite your code to use a static helper function with one argument (the watchdog object itself) which then just calls the member function of that object. For this to work, the called function must be public. So a rewrite like
static void watchdog_timer_triggered_helper(myIOT32* watchdog) {
   //needs to be public!
   watchdog->_feedTheDog();
}

void myIOT32::_feedTheDog()
{
  _wdtResetCounter++;
  if (_wdtResetCounter >= _wdtMaxRetries)
  {
    sendReset("Dog goes woof");
  }
}
void myIOT32::_startWDT()
{
  wdt.attach(1, &watchdog_timer_triggered_helper, this); // Start WatchDog
}

void myIOT32::sendReset(char *header)
{
  char temp[150];

  sprintf(temp, "[%s] - Reset sent", header);

  if (useSerial)
  {
    Serial.println(temp);
  }
  if (strcmp(header, "null") != 0)
  {
    pub_msg(temp);
  }
  delay(1000);
  ESP.restart();
}

Since both the ESP32 and ESP8266 versions implement the
    template<typename TArg>
    void attach(float seconds, void (*callback)(TArg), TArg arg)

templated function this should work on both platforms now.

Thank you for explaining. Can you share an example how to rework ?

@Guy.D see update.

@Maximillian  - thank you for you answer. I'm afraid your it a bit more than I understand :( , and I do not like to copy an answer without fully understand. Can you please explain more, or perhaps a more simple answer ( sorry... )

@Guy.D didn't you write the initial code with std::bind, which is more complex than the function pointer used in the answer? Anyways I suggest reading up on C++ templates (attach() is a templated function), pure function pointers and std::function in C++. I'd take some quiet lengthy text to explain that fully in my answer o_o.

to be honest, when I found that answer for 8266, I just took it as a given solution without knowing how bind work for every detail.... ( shame me :) )....

@Maximillian - Well, after a long look up ( from almost a month ) I couldn't find any exaplining example to understand your solution ( not the template part ). Can you please refer ?


text:
How do i fix the "A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header"
I have an AI Thinker ESP32-CAM and I've had issues uploading the CameraWebServer sketch, every time I hit upload it says "A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header" and I've tried everything that I can think of, I disconnected and reconnected all the connections on my FTDI board and I've done all sorts of button presses during the connection, I've switched the voltage and I've bought a whole new board and I don't know what the issue is or how to fix it.

Did you connect IO0 to Ground?

ESP32 only works with 3.3 V serial do not switch the FTDI voltage to 5 V
Watch out for the serial connections too
U0R-->TX
U0T-->RX
If you mixed it up it won't work!
First of all you need to connect two pins only when uploading
It is all ready fixed for you need to press the rest button when uploading
and seeing these dots as below image.

ESP32-CAM on-board RST button Press and hold until you see uploading

After a few seconds, the code should be successfully uploaded to your board.
I hope this helped for you!
You can reffer to this link for more info
https://randomnerdtutorials.com/esp32-cam-take-photo-display-web-server/

Good info about ESP32. In addition, I think some confusion comes from the ESP32-CAM, which does have +5V option. And you have to ground GPIO0 in order to program that board. But other than that they are very similar. Again, this comment and link applies to ESP32-CAM, as the original question asked about. https://randomnerdtutorials.com/program-upload-code-esp32-cam/

I have had the same problem / error message with a different board. I did not realise that during upload you must make sure that any GPIO pins that the board uses to talk to the flash chip are NOT connected to other devices. The upload process should be:

Disconnect any GPIO pin connectors.
Upload your code.
Reconnect any GPIO pin connectors.

(In your question, you say "I disconnected and reconnected all the connections" but you do not say whether all your connections were disconnected while you were trying to upload your code.)
I found this information here (the text in that post says "This message normally means that the ESP32 can't talk to its attached flash chip (the flash chip may be in the module). Check the GPIO pins 6,7,8,9,10 & 11 (which are shared with the flash chip) are not connected to anything external or shorted together, etc.")
HTH.


text:
Compile-time 'Undefined reference' error for functions defined in a .cpp source file that are called in my main project file
I'm currently working with the NodeMCU ESP12E and MPU6050 IMU using the Arduino IDE and wanted to create a project that has a .h file that declares the variables and functions. In the .cpp file, I have various function definitions. The main.ino file just calls some of these functions. Please find some excerpts of code from each file and the errors I encountered. The errors say the three functions called in the .ino file are undefined even though they are defined in the .cpp file
Algo.h file:
extern int activity_state; // activity_state=1 for RUN and activity_state=0 for WALK
extern float * speedarray; // Dynamic array for storing speed
extern int speedindex;
extern float * timearray; // Dynamic array for storing time
extern int timeindex;

extern unsigned int localPort;

Algo.cpp:

static void pedometerInit() // Initialising all pedometer algorithm variables
{
      int i = 0;
  //pedometerAlgo varibles
  pedi_window_high = 2000;
  pedi_window_low = 200;

  pedi_sampling_counter = 0;
  pedi_refresh_frequency = 50;
  validZone = 1;
  jatin_index_1 = 0;
  jatin_mag = 0;
  pedi_max = 0;
.
.

All the functions work on the variables declared in the header file.
Ped_algo.ino:
void setup() {

  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(STASSID, STAPSK); // Setting up WiFi station
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print('.');
    delay(500);
  }

  Udp.begin(localPort); // Setting up UDP connection

  MPU6050_Init(); // Initial configuration of the MPU6050
  pedometerInit();
}

void loop() {

  pedometerAlgo();
}

Error messages:
Ped_Algo.ino.cpp.o:(.text.loop+0x0): undefined reference to pedometerAlgo()'
in functionloop':
 undefined reference to pedometerInit()'
 undefined reference toMPU6050_Init()'
 undefined reference to `pedometerInit()'
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

Well, for example in the static void pedometerInit() that static means linker is not allowed to use it outside its own compilation unit Algo.cpp (Algo.o)

Also, it seems you don't have the constructor pedometerAlgo::pedometerAlgo() implemented.

did you include Algo.h in .ino?

I have included Algo.h in the .ino file. Also, I'm not using classes here. And removing the static, gives me the undefined reference error to all the variables used in the functions.

As well as extern in the header for your variables you have to actually create those variables somewhere. extern just t tells the compiler that they exist somewhere else. You have to ensure that they actually do exist somewhere.

Firstly, static keeps a function from ever being exported globally:
static void pedometerInit() // Initialising all pedometer algorithm variables

should not be static.
Secondly, extern does not define a variable, it merely tells the compiler that "this variable exists somewhere. Find it at link time." - however you're not actually defining those variables anywhere.  In addition to the extern hints in the .h file you need to have the variables in the .cpp file for the compiler to be able to find them.
int activity_state; // activity_state=1 for RUN and activity_state=0 for WALK
float * speedarray; // Dynamic array for storing speed
int speedindex;
float * timearray; // Dynamic array for storing time
int timeindex;

unsigned int localPort;

void pedometerInit() // Initialising all pedometer algorithm variables
{
 ... your code ...
}