text:
Why is my liquid crystal display not showing any output?
UPDATE:
The LCD will light up only when the all my components are located in the bottom right of the breadboard. Why am I not able to use the entire breadboard for my circuit?
I am trying to display data from a temperature and humidity sensor on the serial monitor and the liquid crystal display.
I am using :

Arduino Uno R3
I2C 16x2 LCD Module
3 pin DHT11 sensor

Here is my code :
#include <dht.h>                // initialize the digital temperature and humidity sensor library ("DHTlib")
#include <LiquidCrystal_I2C.h>  // initialize the liquid crystal display library ("LiquidCrystal I2C")
#include <Wire.h>               // intialize the wire library

/*   the first parameter is the I2C address
 *   the second parameter is how many columns are on your screen
 *   the third parameter is how many rows are on your screen
*/
LiquidCrystal_I2C lcd(0x27, 16, 2);

dht DHT;              // create a handle to call functions from the sensor library
#define DHT11_PIN 7   // assign a digital pin number to the sensor
float TempC;          // create a variable to store temperature in celsius
float TempF;          // create a variable to store temperature in fahrenheit
float Humi;           // create a variable to store humidity

void setup()
{
  lcd.init();                // initialize liquid crystal display
  lcd.backlight();           // turn on the backlight of the lcd
  pinMode(DHT11_PIN,INPUT);  // configure the pin for the sensor as an input for reading the data
  Serial.begin(9600);        // set data rate in bits per second for serial data transmission
}

void loop()
{
  // collect sensor data
  int chk = DHT.read11(DHT11_PIN);  // store sensor data in a variable
  TempC = DHT.temperature;          // store temperature in Celsius
  TempF = 9 / 5 * TempC + 32;       // store temperature in Fahrenheit
  Humi = DHT.humidity;              // store relative humidity as a percentage

  // display sensor data on LCD
  lcd.setCursor(0,0);    //tell the screen to write on the top row
  lcd.print("T: ");
  lcd.print(TempC);    // print the temperature in Celsius
//  lcd.print(TempF);    // print the temperature in Fahrenheit
  lcd.print((char)223);  // print the degree symbol
  lcd.print(" C");
//  lcd.print(" F");
  lcd.setCursor(0,1);    // tell the screen to write on the bottom row
  lcd.print("H: ");
  lcd.print(Humi);       // print the humidity
  lcd.print(" %");

  // display sensor data on the serial monitor
  Serial.print("Temperature = ");
  Serial.print(TempC);     // print the temperature in Celsius
//  Serial.print(TempF);     // print the temperature in Fahrenheit
  Serial.print("\xc2\xb0");  // print the degree symbol
  Serial.println(" C");
//  Serial.println(" F");
  Serial.print("Humidity = ");
  Serial.print(Humi);        // print the humidity
  Serial.println(" %");

  delay(2000);  //delay fetching the next sensor values for 2 seconds
}

My jumper wires are connected as follows:

DHT plus → red plus row
DHT middle → digital pin 7
DHT minus → blue minus row
LCD GND → blue minus row
LCD VCC → red plus row
LCD SDA → analog pin A4
LCD SCL → analog pin A5
Red plus row → 5V pin
Blue minus row → GND pin

Do you not see a breadboard, an arduino board, a liquid crystal display, a sensor, and jumper wires all hooked up?

The picture is unusable, dark and low resolution. Pin names and wire paths are not clearly visible. These allow others to try to identify your problem and it would be a good idea to put some more effort into getting them across clearly. It might also be a good idea to describe your setup in text (such as which pins are connected to which other pins).

Btw, it looks like there’s nothing connected to the (I2C) SDA and SCL pins on your Arduino, but it’s hard to make out. There’s also no way to see if the power pins of your LCD are properly connected.

All right, I put a new picture, and I explained the setup. Is there an error in my code or in my circuit?

Did you try moving the knob on the I2C 16x2 LCD Module for changing the contrast?

@MichelKeijzers I was finally able to get the LCD to light up and show sensor data. The breadboard I have is divided roughly into 4 sections. The circuit works only if all of my components are contained in one quadrant.

@MichelKeijzers I have not tried turning the knob. I do have a contrast issue and it is too bright to see anything properly. Do you know what type of screwdriver will fit?

A small screwdriver, simple one, they are called precision screwdrivers sometimes. You also could try it with your finger nail or something small.

Your breadboard is one of those which have the power/GND lines interrupted between columns 31 and 33. I also once fell into this trap. If you look closely, you see that the blue and red lines are interrupted in the middle of the board. Just put wires between these pins to bridge the gap.

Thanks! I never realized my problem was so trivial!

Glad I could help. If this answer helped you, please don't forget to accept it.


text:
ISR for timer on Arduino MEGA gets called only once
I am trying to write an Arduino code to blink LED using timer 4 on Arduino MEGA (atmega2560). I resetted the timer registers, and entered all the necessary values to bring to 16MHz to 1Hz (rescalar = 1024, OCR4B = 15624), then I wrote the blinking code inside the service routine block. Now when I run the program, the ISR is called only once. I saw from Youtube videos that even though the setting up of TCCR registers and TIMSK is in setup() function, it repeats indefinitely like a loop. Below is my code. Any help would be immensely appreciated. Thank you.
int led_pin = 10;
static int counter = 0;
int led_blink = 0;

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(led_pin,OUTPUT);
cli();
TCCR4A = 0;
TCCR4B = 0;
TCNT4 = 0;
OCR4B = 15625;                                //set the maximum count 16MHz -> 1Hz
TCCR4B |= (1<<CS10) | (1<<CS12) | (1<<WGM12); // prescalar = 1024 , CTC(OCR3B) mode
TIMSK4 |= (1<<OCIE4B);
sei();
interrupts();
}

ISR(TIMER4_COMPB_vect)
{
  Serial.println(millis());
  led_blink = !led_blink;

}

void loop() {
  // put your main code here, to run repeatedly:
  if(led_blink == 1)
    digitalWrite(led_pin,HIGH);
}

Are you sure, that the ISR gets only called one time? With your current code the LED will only be turned on, not blinking (since you never turn it off anywhere). Do you get the Serial output in the Serial Monitor, which shows the values of millis()?

It's ok to set a variable and do the "heavy lifting" outside the ISR, but you got a bit side-tracked here. digitalWrite is very cheap, and having it in the ISR shouldn't make problems, but Serial.println is a very complex function that on itself uses timers and takes several ms to execute.

You can use uint8_t for the led_blink variable and it must be volatile. Otherwise compiler might optimize it out when it founds out it can't change. Also led_pin doesn't magically clear itself. It stays set forever if you don't write LOW to it...

Oh I am sorry, yes I forgot yo write the LED to low in else condition, but even after that I observed that the Serial.println(millis()) still worked only once. But out of luck when I tried to add values in both OCR4A and wrote the ISR for A register, it worked perfectly fine, even the Serial.println() worked. Can anybody please explain why? Also thank you for sharing your knowledge. I had no idea Serial.println() uses timers. Newbie things.

Your missing an else statement in your loop:
else
  digitalWrite(led_pin,LOW);

source: Stack Exchange

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

sort: votes


text:
Can UNO log more PCB 353b33 accelerometer data points compared to TDS3014B oscilloscope?
I'm currently recording data points from an analog accelerometer(PCB 353b33) using a TDS3014B oscilloscope which has Record Length of 10,000 points at a Sample Rate 1.25 Ga/s. I'm want to record more data points, would it be possible to use UNO as a data acquisition device and record much higher data points than the oscilloscope(>> 10,000)

No way. The UNO has only 2.5kb of RAM, so you can't cache the data points and you would need a very quick link to get the data out. And sampling at 1.25 GigaSamples/s is orders of magnitude beyond an UNO, as its maximum clock frequency is only 16 MHz. An Uno is about $20, while your TDS3014B is around $1500. Sometimes, there's a reason for a different price tag.

So if I want to log data for a period of time say 10 mins, then would using an uno a good idea considering the trade off's being the lower sampling rate. As the problem with the oscilloscope is that it's a triggered logging device and I need data for a period of 10 mins or more.

The sampling rate would be significantly lower, and depending on the signal quality you need, it might not be accurate enough (you did not specify what kind of signal you're measuring). And you need the UNO connected to a PC so that you can transmit and store the collected data right away.

For 10 minutes of sampling at 1.25Gsps using 32-bit floats you would need about 3 terabytes of memory. You're not going to even get close to that with a very very powerful desktop. An Arduino...? Dream on. It's never going to happen.
An Arduino has a couple of kB of memory. Plus a slow, crude, ADC. You may get a fraction of a second at its highest sample rate. To stretch it out over 10 minutes you'd be looking at no more than about 800 samples (16 bit values from a 10 bit ADC), so maybe one sample every 1 1/2 seconds.

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


text:
Send values from Arduino Uno to Wemos D1 R1
I have a weather project in which I have to measure the temperature and humidity (DHT22 sensor), the pressure, and other things, and then show them on a local web page (using a Wemos D1 R1) in either my phone or PC (I have both an Arduino Uno and a Wemos D1 R1 for this project)
I wanted to use only the Wemos D1 R1 since it works the same as an Arduino Uno except it has an ESP8266 WiFi built-in while the Arduino Uno doesn't, but as you may know it only has 1 analog pin while I need at least 3 or 4 analog pins, so in my case I should connect the sensors with the Arduino Uno and measure the temperature, humidity, etc. and then send those values to the Wemos D1 R1 which will show the results itself on a web page as I said earlier.
It seems that there is a way to do that using an I2C connection, but I have read many articles talking about connecting an Arduino to another Arduino using an I2C connection, but I don't know how to do that in my case (Arduino Uno and Wemos D1 R1); if there is another way to send values please tell me.

You basically have the standard communication interfaces available: I2C, SPI or Serial (UART). You can freely choose between those, depending on your requirements. For I2C: You didn't describe, what exactly your problem is with doing this. Is it, that you didn't find a tutorial specifically describing the connection for Uno and Wemos d1 r1? Thats not really a problem, since codewise you can use any I2C code, that is aimed at the ESP8266 (which is the chip on the Wemos D1 r1). For the electrical connections: Just connect the corresponding pins (marked with SDA and SCL).

Yes, my problem is that unfortunately I did not find any tutorial out there showing how to do that! If there is a blog or a website showing how to do that please send it to me! otherwise for the electrical connections I only have to connect the arduino's ( the slave sender which is connected to the pc in the port usb directly in this case ) SDA and SCL pins to the wemos d1 SDA and SCL ( the master reciever )? what about the GND & 3.3V ( since it works on 3.3v not 5v) pin of the WeMos d1?

DHT doesn"t use analog pins

You can use an analog multiplexer, greatly simplifies the code and only one micro.

As I see it, the most straight-forward way to connect 2 Arduinos is using their built-in UART (aka Serial port, TX/RX pins) communication.
There are many tutorials on this on Google, and a similar explanation can be found in this question:
Serial communication arduino mega and D1 Wemos Mini
However, there is a slight difference.
Arduino Mega has built in more than 1 hardware serial ports (I can't recall now if it's full 3 ports, or just 2), what leave one port for debug purposes, and the other - for your communication.
In your case (Arduino Uno) - you have only one serial port, that if will be used for the inter-Arduinos communication - will not be available for debug/console messages.
The solution for this is adding a Software Serial port, also highly available in tutorials over the net, here is one example:
softwareserial between arduino uno and esp8266
Enjoy your project!

Thank you <3 I will choose the I2C connection, So in my case I must work with 2 computers ( one connected with the slave sender which is Arduino Uno and the other one is master receiver which is WeMos d1 ) and the two board must be connected through i2c connection, my question is that can I work with only one computer which will be connected with UNO through the USB port and then send the values measured from the sensors to the WeMos? and if that possible sending me some code example will be much appreciated!

I agree with @Offer that using UART is the simplest solution to connect the devices.
I just want to suggest two alternatives:

Use an external analog to digital converter IC. Using the Arduino only for analog conversion is a bit over powered. E.g. the ADS1115 has a resolution of 16 bits and there's already a library, so usage should be easy.

The ESP8266's bigger brother - the ESP32 - has several ADC pins.

The biggest advantage (beside the higher resolution) is, that you only need to write code for one device, which makes your project less complex.

The external ADCs like ADS1115 are also much more precise than what Arduino Uno has, while cheap (less than 10 USD)

Have a look at my blog 'Paynters Palace' and search for posts with the 'I2C' tag - you'll find quite a bit of useful code, I think.
This project shows how to connect two Arduinos using SPI
This project shows how to connect two Arduinos using I2C and how to pass arbitrary data types between the two units


text:
Need documentation for Soil Sensor from DIYmore
Does anyone have any documentation on this device?
Im just curious how it work out of the box and how to reference the on board temp and soil sensors.
Its a (for lack of a better name)a "ESP32 DHT11 WIFI Bluetooth Soil Temperature Humidity Sensor18650"
SKU:012592
Item on DIYmore site

With a broken link to the manual on their website we're as clueless as you are.

@Majenko ...Right...I was just hoping someone somewhere once had one! I was hoping more data would come over the come post...but it not shedding much light.

You'll have to work out the schematic yourself by "buzzing out" the connections between the different components with a DMM.

The DHT11 is well documented with plenty of examples, if you can work out which pin of the ESP32 is used to communicate with it. The soil probe, likewise, looks like a simple pair of prongs with an op-amp for threshold detection - again well documented with lots of examples, if you can work out what pins it's on.

As Majenko said, without a manual or datasheet we cannot be sure (you can contact the seller about this), but it looks just like a ESP32 devboard, which already has some sensors on it. If it already "works" out of the box, I guess that means, that it comes with a working program flashed to it. Though you can also just write your own program in the Arduino framework. The sensors seem to be standard components. You would need to figure out, to which pins of the ESP32 they are connected. Thats again something, that the seller should be able to tell you.

@chrisl Well...though it "is" working...I cant see it (ble or wifi)..or communicate with it..Its actually comming to me via 3rd party...so it may have been flashed by others.

That looks like a copy of the HiGrow sensor from Hackaday.

@sempaiscuba Nice find. Chasing it down that rabbit hole leads, eventually, to TTGO as the originator: https://github.com/pesor/TTGO-T-HIGrow

@Majenko..that looks promising..

I am a bit old fashioned, as Ronald Reagan’s famous dictum, “Trust, but verify.” I always download it before ordering, there have been many suppliers that did not sell me stuff because the link was broken o data not available.

@Gil Good sound advice...It just happens that I got this device in a box with a bunch of other stuff...turns out I figured out all the thing and got a web server running with all the sensors.

Congratulations, a great job:-)


text:
Multiple arduino slaves with one master computer that sends instructions for the actuators to work
I am in the middle of an automation project and suddenly after completing one stage of my assembly, I now need to scale it. So my computer which until now was sending data to only one arduino UNO can send to multiple arduino uno's, also I am seeking an advice, I am using up all the digital pins on my arduino Uno and this makes me think if I should upgrade to arduino mega or leave it the way it is.
The communication protocol I am using is UART which is done through USB from my computer to the board, so can I just use a USB hub to handle this issue?

If you’re sure that you won’t expand your project and need more pins, why upgrade? If you have lots of free analog pins you can use them as digital pins too.

Yes, if course you can use a USB hub to connect multiple Arduinos to your PC at once. If you need to upgrade to a mega depends on if you need more pins

Thank you so much I definitely not need more pins on one communication as the more the messy it gets thats why I tried sticking to Uno to the least, I would rather get multiple unos so troubleshooting doesn't become a challenge.


text:
How to work with WS2812B 16x16 matrix panel from aliexpress
I'm completely new to Arduino, and I want to build the project using an LED 16x16 matrix, but I don't know where to start. On the internet, I keep finding these custom matrix panels and they aren't similar to mine. So I'm asking here. Does anyone have experience with this Arduino-compatible RGB LED matrix panel? This is the link to the Aliexpress product.

Will I need an additional power supply? What will I need to install to make it work? Where do i plug what wire into my arduino? Thanks for any answer!

It's just a string of WS2812B LEDs that have been "bent" into a grid. You treat it exactly like any other WS2812B strip of LEDs.
You have 256 LEDs, and as far as the Arduino is concerned, they are just in a line numbered 0-255.
The "grid" arrangement is solely down to you to you to calculate.  Fortunately 256, or 16x16, is very easy to work with: you have a byte which can represent any one of the LEDs, and each half of the byte (a nibble) is one coordinate.
The traditional calculation to convert X and Y into a linear number is:
num = x + y * width

where width is the number of LEDs in the X direction (16).  However since we're working with a width of 16 that can be optimized to use bit-shifting and bitwise operations:
num = x | (y << 4)

That is assuming LED 0 is on the left (either top or bottom) and LED 1 is one place to the right.
Will you need an external power supply for it? Yes, most certainly (and they even provide you with a dedicated power connection for it). 256 LEDs, if all are turned on full brightness at once, could consume up to about 15 amps (20mA per channel, three channels per LED, 256 LEDs).

Just want to add more to your answer. Theoretically, 5V - 15A the power supply he needs. But he may get away with just 2A power supply if he's careful not to turn on all LEDs at a time and just use about 80/255 brightness on each colour. From my experience, I had a project that used 18 panels of 8x8 ws2812b. It was just a single letter (using just one colour) displayed on each LED panel so that I could get away just with a single 12V - 2A power supply for the whole system. Step down (buck) to about 3V3 at each LED panel and each panel had its own nano clone to control it.


text:
Trouble using bluetooth module with the ESP32s2 feather board
I am trying to use an ESP32-S2 feather board with a separate bluetooth module, the Adafruit BLuefruit LE UART Friend. I previously used this bluetooth module with the Feather M0 Adalogger through UART without experiencing any major problems. Now, the bluetooth module does not even get past its begin function. In fact, in order for my program to even compile, I have to change the UART header and cpp files in the nRF51 library by commenting out Software Serial code (although, I don't actually use software serial) because the esp32 core does not have that library. Is this a matter of cores (esp32 as opposed to samd or avr) or something else entirely?

SAMD cores don't have SoftwareSerial. the Adafruit_BluefruitLE_nRF51 library has #define SOFTWARE_SERIAL_AVAILABLE   ( ! (defined (_VARIANT_ARDUINO_DUE_X_) || defined (ARDUINO_ARCH_SAMD) || defined (ARDUINO_STM32_FEATHER)) )


text:
Why echo "R" > /dev/ttyUSB0 doesn't work, but on the same PC Serial Monitor in Arduino IDE works?
I have a strange problem. I am running Ubuntu and NodeMCU si plugged into USB. I have very simple sketch running on it, when it reads letter "R" on serial, it turns ON relay.
When I open Serial Monitor in Arduino IDE and I type letter "R" and send it, it works perfectly. However when I run commands below, it does nothing:
stty -F /dev/ttyUSB0 115200
echo "R" > /dev/ttyUSB0

I tried running the same commands on different PC with Ubuntu and these system commands work just fine.
I also tried copying exact same configuration from stty -a -F /dev/ttyUSB from PC where it works to PC where it doesn't, but it didn't help either.
I don't think it's driver issue, because if it would, then I suppose it wouldn't work with Serial Monitor also.
Thank you for any help or hints in advance.

Do you have something else plugged through USB in the PC where it does not work? Maybe the NodeMCU is ttyUSB1?

Does this answer your question? How to connect Arduino device to Linux?

Are you waiting a bit between opening the port and sending the data? The Arduino might not yet be ready to receive data directly after opening the port (since it resets)

Try executing: stty -F /dev/ttyUSB0 -hupcl

OK, so I resolved this problem, but only half-way. I was using NodeMCU with CH340 ... and this controller worked only in Serial Monitor, not in command shell on one computer (it worked fine on other computer).
So I tried using different NodeMCU with CP2102 and it worked just fine. So I assume there must be some kind of issue with ch341 driver in my linux, I don't know.

I had the same issue.
After entering command that Majenko suggested:
stty -F /dev/ttyUSB0 -hupcl

I still wasn't able to send commands to Arduino nano.
Strangely, when I open Arduino IDE Serial Monitor and send command it works.
When I close it, I can send commands in terminal to Arduino for some time. Then it stops working again :/


text:
L298 Motor Driver not showing Red light when connecting power supply
I recently bought an L298 motor driver module for controlling 2 motors(5v each).
When i connect the power supply(which is a normal RC car battery holder(3)) the red light doesn't light up.
Instead if i connect the +ve to the 5v on the motor driver, the red light is glowing, but the motors don't work.

you accepted an answer that is not quite correct ... the reason that motors do not run is that the L298 is technology from last century and is very inefficient ... your power supply needs to be a bit higher than 7 V if your motor requires 5 V ... the L298 uses up a couple of Volts

You need to do math on the power consumption as arduino uno takes takes 5 V 500 mA at least for it to work. That is why it can be powered by USB cables too.
Now if you try calculating power consumption on the motors you would understand that the power you are giving is nowhere enough for the arrangement to work or you could have been able to run the motors without the motor driver.
Try upgrading the power you are giving.

Thanks. I tweaked up the power and now its working fine.

@RiteshSharma  your answer provides incorrect information ... Arduino Uno requires a lot less current than 500 mA to operate ... please research the correct value and update your answer .... you also used incorrect units of measure, which I edited

I would definitely do the research work on that @jsotola


text:
Does the Sparkfun ESP32 Thing is compatible with generic modules like DHT11 sensor?
First of all I am kind of a noob working with microcontrollers, by the way I am using Arduino IDE 1.8.13
I fallowed the hookup guide to set up Arduino IDE to work with Sparkfun ESP 32 Thing board, and actually I was able to run the Arduino examples "Blink" and "Wifi" with no problem.
But my problem is when I tried to use the DHT11 sensor, I did fallowed several tutorials like this one but for my bad fortune I did not succeed, instead I was getting NaN reading from the temperature and humidity sensor, at first I thought it might had something to do with the libraries version, which I installed and uninstalled several times, including the IDE, then using those same libraries I was able to do the exact same example on an Arduino Uno microcontroller.
Then I realized I did not find any example, tutorial or document using the Sparkfun ESP32 Thing with the DHT11 sensor, since most of the examples that I found are for the generic ESP32.
Which makes me wonder, how can I know if those two components are compatible at all?
Does any one has faced something similar using ESP32 Thing with DHT11 or any another sensor?, if yes, how did you make it work or what did you do instead?
However any piece of advise is welcome.
Thanks in advance!

An ESP32 is an ESP32 regardless of what shape board it's soldered on to.

Could it be what is not compatible is the library,? DHT sensor library by Adafruit

Unlikely. The DHT11 is pretty simple and doesn't require anything special.

Well it requires the library that I just mentioned and the dependecy to Adafruit Unified Sensorl, however do you happen to know any site or document showing those two components working together,  I wonder if sparkfun board is not very common?

There are many DHT11 libraries. Only one needs that Adafruit thing. Try using one of the simpler libraries.


text:
Arduino RTC SD Card problem
I am using a script on an Arduino to record BME280 data onto an SD card and to display it on a lcd display. To have a valid time stamp I am also using a DS3231 RTC module. I set the time succesfully and can manually read it and write it to the serial monitor.
Writing the sensor data to the SD card works fine as well. But as soon as I try to include the time from the RTC into the file onto the SD card the script jumps back to the else statement in the setup() where I try to open the file for writing the header line.
Without using the RTC time it works fine, as soon as I put it in using the corresponding function, it fails.
Here is the script I am using:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <SD.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

#define BME_SCK 8
#define BME_MISO 6
#define BME_MOSI 7
#define BME_CS 5

#define SEALEVELPRESSURE_HPA (1013.25)
#define RTC_I2C_ADDRESS 0x68 // I2C Adresse des RTC  DS3231

Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI

unsigned long lastReadRTC = -1;
boolean sd_ok = 0, sensor_ok = 0;
File dataLog;
String dat_time;

LiquidCrystal_I2C lcd(0x27, 20, 4);  //Hier wird das Display benannt (Adresse/Zeichen pro Zeile/Anzahl Zeilen)

void setup()
{
  Wire.begin(); //Kommunikation über die Wire.h bibliothek beginnen.
  Serial.begin(9600); // open serial communications and wait for port to open
  // SD Card Initialization
  if (SD.begin())
  {
    Serial.println("SD card is ready.");
    sd_ok = true;
  } else
  {
    Serial.println("SD card initialization failed");
    return;
  }
  //if( SD.exists("test.txt") == 1 ){
  dataLog = SD.open("test.txt", FILE_WRITE);
  if(dataLog) {                               // if the file opened okay, write to it:
     Serial.println("OK, writing header");
     // write some texts to 'test.txt' file
     dataLog.println("DATE | TEMPERATURE | HUMIDITY | PRESSURE");
     dataLog.close();   // close the file
  }
  else {
    Serial.println("error opening testfile.txt");
  }
  unsigned status;
  status = bme.begin();
  if (!status) {
    Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
    Serial.print("SensorID was: 0x");
    Serial.println(bme.sensorID(),16);
    Serial.print("        ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
    Serial.print("   ID of 0x56-0x58 represents a BMP 280,\n");
    Serial.print("        ID of 0x60 represents a BME 280.\n");
    Serial.print("        ID of 0x61 represents a BME 680.\n");
    while (1) delay(10);
  }else{
    sensor_ok = true;
    Serial.println("OK, sensor recognized");
  }
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("Temp. = ");
  lcd.print(bme.readTemperature());
  lcd.print(" *C");
  lcd.setCursor(0,1);
  lcd.print("Press. = ");
  lcd.print(bme.readPressure() / 100.0F);
  lcd.print(" hPa");
  lcd.setCursor(0,2);
  lcd.print("Alti. = ");
  lcd.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
  lcd.print(" m");
  lcd.setCursor(0,3);
  lcd.print("Hum. = ");
  lcd.print(bme.readHumidity());
  lcd.print(" %");

  delay(1000);
}

//Reads the current datetime from rtc module
String rtcReadTime(){
  Wire.beginTransmission(RTC_I2C_ADDRESS); //Connect to address 0x68
  Wire.write(0);
  Wire.endTransmission();
  Wire.requestFrom(RTC_I2C_ADDRESS, 7);
  int sekunde    = bcdToDec(Wire.read() & 0x7f);
  int minute     = bcdToDec(Wire.read());
  int stunde     = bcdToDec(Wire.read() & 0x3f);
  //weekday not included
  /* wochentag  =*/ bcdToDec(Wire.read());
  int tag        = bcdToDec(Wire.read());
  int monat      = bcdToDec(Wire.read());
  int jahr       = bcdToDec(Wire.read())+2000;

  char timestamp[30];
  sprintf(timestamp,"%02d.%02d.%4d %02d:%02d:%02d",tag,monat,jahr,stunde,minute,sekunde);
  return timestamp;
}

//Converts binary to numeric
byte bcdToDec(byte val){
  return ( (val/16*10) + (val%16) );
}

void loop()
{
  unsigned long currentMilliseconds = millis();
  if((lastReadRTC + 1000) < currentMilliseconds){
    lastReadRTC = currentMilliseconds;
    lcd.setCursor(0,0);
    lcd.print("Temp. = ");
    lcd.print(bme.readTemperature());
    lcd.print(" *C");
    lcd.setCursor(0,1);
    lcd.print("Press. = ");
    lcd.print(bme.readPressure() / 100.0F);
    lcd.print(" hPa");
    lcd.setCursor(0,2);
    lcd.print("Alti. = ");
    lcd.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
    lcd.print(" m");
    lcd.setCursor(0,3);
    lcd.print("Hum. = ");
    lcd.print(bme.readHumidity());
    lcd.print(" %");
    //Serial.println(rtcReadTime());
    if(sd_ok){
      dataLog = SD.open("test.txt", FILE_WRITE);
      //dataLog.print(rtcReadTime());
      dataLog.print(" |  ");
      if(sensor_ok) {
        dataLog.print(bme.readTemperature());
        dataLog.print("°C   |  ");
        dataLog.print(bme.readHumidity());
        dataLog.print("  | ");
        dataLog.println(bme.readPressure() / 100.0F);
        dataLog.close();
      }
      else{
        dataLog.println("  Error    |  Error   |  Error");
        dataLog.close();
      }
    }
  }
  delay(1000);
}

So when I run the script without the RTC time included it gives me the output:

SD card is ready.

OK, writing header

If I include the line dataLog.print(rtcReadTime()); towards the end (in the script commented out) it jumps to the beginning of the setup section into the else statement giving me:

error opening testfile.txt

and nothing is written into the file on the SD card.
I tried to find the mistake for multiple hours yesterday and was hoping to find it today after a good night of sleep, but nope. It is probably an easy fix that i can't see. The code is probably far from perfect or good. I am a beginner in c++, so keep that in mind. :)
EDIT:
As I was not able to find a solution using rtcReadTime(), I used the RTClib.h directly and created the time manually in the writing process for the SD card:
void loop()
{
  unsigned long currentMilliseconds = millis();
  if((lastReadRTC + 1000) < currentMilliseconds){
    lastReadRTC = currentMilliseconds;
    lcd.setCursor(0,0);
    lcd.print("Temp. = ");
    lcd.print(bme.readTemperature());
    lcd.print(" *C");
    lcd.setCursor(0,1);
    lcd.print("Press. = ");
    lcd.print(bme.readPressure() / 100.0F);
    lcd.print(" hPa");
    lcd.setCursor(0,2);
    lcd.print("Alti. = ");
    lcd.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
    lcd.print(" m");
    lcd.setCursor(0,3);
    lcd.print("Hum. = ");
    lcd.print(bme.readHumidity());
    lcd.print(" %");
    if(sd_ok){
      dataLog = SD.open("test.txt", FILE_WRITE);
      DateTime now = rtc.now();
      dataLog.print(now.day(), DEC);
      dataLog.print(' ');
      dataLog.print(now.month(), DEC);
      dataLog.print(' ');
      dataLog.print(now.year(), DEC);
      dataLog.print(" ");
      dataLog.print(now.hour(), DEC);
      dataLog.print(':');
      dataLog.print(now.minute(), DEC);
      dataLog.print(':');
      dataLog.print(now.second(), DEC);
      dataLog.print(" |  ");
      if(sensor_ok) {
        dataLog.print(bme.readTemperature());
        dataLog.print("°C   |  ");
        dataLog.print(bme.readHumidity());
        dataLog.print("  | ");
        dataLog.println(bme.readPressure() / 100.0F);
        dataLog.close();
      }
      else{
        dataLog.println("  Error    |  Error   |  Error");
        dataLog.close();
      }
    }
  }
}

Probably far from ideal, but enough for me.

timestamp in rtcReadTime() is a local variable. When you return from that function it ceases to exist - so what you have returned is nothing. You can't print nothing, so the Arduino crashes.
You either need to make the timestamp variable static so that it's not lost when you leave the function, make it a global variable, which has a similar effect, or pass a buffer variable to rtcReadTime() which is then filled instead of returning a pointer to a char.
The simplest of these is just to make timestamp static. Also you should use snprintf instead of sprintf to avoid the possibility of buffer overflows:
String rtcReadTime(){
  Wire.beginTransmission(RTC_I2C_ADDRESS); //Connect to address 0x68
  Wire.write(0);
  Wire.endTransmission();
  Wire.requestFrom(RTC_I2C_ADDRESS, 7);
  int sekunde    = bcdToDec(Wire.read() & 0x7f);
  int minute     = bcdToDec(Wire.read());
  int stunde     = bcdToDec(Wire.read() & 0x3f);
  //weekday not included
  /* wochentag  =*/ bcdToDec(Wire.read());
  int tag        = bcdToDec(Wire.read());
  int monat      = bcdToDec(Wire.read());
  int jahr       = bcdToDec(Wire.read())+2000;

  static char timestamp[30];
  snprintf(timestamp, 30, "%02d.%02d.%4d %02d:%02d:%02d",tag,monat,jahr,stunde,minute,sekunde);
  return timestamp;
}

Thx for the input, sadly that doesn't work. Don't ask me why though^^

Even taking the content out of the function and put it directly into the if(sd_ok)-statement gives me the same result

Btw. I can print the time to the serial monitor by using Serial.println(rtcReadTime());. I would have thought that means returning the variable from the function does work?

It "works" because you have other variables in the function's stack frame acting as a buffer to the timestamp variable - subsequent functions that you call happen to not quite encroach their stack frames far enough through that buffer of old variables in memory to corrupt the string. Purely by chance.


text:
GPS Ublox neo-6mv2
I'm trying to get gps data from ublox neo-6mv2 module via arduino. Should ublox's neo-6mv2 light blink after power up by 5v from arduino ? Or is there any other sign that tells the module isnt dead ?
Module is connected to 5v, gnd for few hours - still no blink / light.

With respect to your question, your Arduino seems to be serving the purpose of a 5V power source.  It should be more integral to the question.

Is there any serial (NMEA) output from the GPS? Have you put it outside with a good part of the visible? Is this an original Ublox or a (cheap) clone?

The Ublox is just the part with the Ublox sticker.  Unless you call out the PCB it is soldered to, we don't have much to go on with respect to LEDs lighting up.

I have uploaded the picture of my module and code. Yes my arduino mega 2560 is only power supply now. I havent try to get serial output yet - I'm waiting for any sign that the module isnt dead :( It's connected as I said - 5v,gnd, 8 and 9 pin

You should be able to output the raw NMEA data coming out of the GPS and see if it is “alive”, see here, for example. The cheap/generic GPS modules I know only start blinking an LED after they’ve acquired an initial position, which can take a very long time.

[added photo]
I have found a post that on arduino mega is better to use Serial(1/2/3) than SoftwareSerial so I tried it. Now it shows some data so I assume it's alive even without any light blinking on the module. Thanks everyone :)
All the data are the same - it's waiting for the signal right ? :D

Be sure the active antenna is attached and may have to move it around to differnent areas of you work bench. some of these modules are very deaf or prone to inteference from reflections in the room.

Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.


text:
Nrf24l01 smd pcb placement tips
I am working on pcb design with nrf24l01 smd. I have read somewhere that nrf24l01 module has problem while communication when it is placed with its antenna within the pcb. I want my module to be within the pcb as much as possible to save some space. I will be making the pcb at home and will be placing atmega 328p smd on the opposite layer. Should I fill the opposite layer with ground pad?

You need to keep the ground plane away from the antenna. The rest of the module doesn't care (and having a ground plane under it can help with unwanted EMI).
Here's a design I did recently for a customer with the same module in it. It's placed near the edge of the PCB with the ground plane cut out around the antenna:

That layout is actually set up for either the small SMD, the SMD with PA+LNB or the thorugh-hole version. The important thing is that there is a nice big exclusion zone in the ground plane where the antenna is.

Thanks for your answer

Hi @Majenko! Would it be okay to have the NRF24L01 module and ATMega module on the same PCB with also the antenna on the PCB?


text:
How to split 12V power suply to arduino and led matrix panel
I'm trying to build my Arduino project with Arduino mega and led matrix panel. I'm wondering what power supply should I buy, my first thought was to power the matrix panel from a 5v Arduino pin, but I read here that it's not really a good idea. So now I'm wondering if I can buy a 12V power supply and somehow split it to 6V and 6V (or something like it). To connect one end to Arduino and the other to the matrix panel. If it's possible, how do I do that? Thanks for any help!

what is the arduino mega power supply voltage requirement?

6-12V, but it runs on USB too, so 5V minimum i quess

so, if it runs on a 12 V supply, then connect it to a 12 V supply

https://forum.arduino.cc/index.php?topic=618723.0 - In this forum, they don't recommend that, because if a large current is drawn, it will overheat the built-in power regulator.

you don't want to use the arduino to supply current to drive peripherals anyway ... LEDs and motors should be supplied externally ... arduino should only provide control signals ... if you are still worried, then use a buck converter to supply 5 V to the arduino

That's why I'm asking if and how to split power from that 12V power supply.

I wouldn't recommend to share power-supply as disturbance from the high power load could cause erratic Arduino behavior. A simple decoupling capacitor could be enough,  https://en.wikipedia.org/wiki/Decoupling_capacitor or a more complex solution such as buck converter and so on...

No,you cannot split the voltage and expect the devices (Arduino and LED strip) to work correctly together (would lead to different ground levels beside other problems). For getting a different voltage you would need a voltage regulator. A switching "buck" regulator is the better choice here than a linear regulator (lile the one on the Arduino), since it is way more efficient (To get from 12V to 5V a linear voltage regulator would burn up the excessive 7V as heat).
But since both Arduino and LED strip use 5V, why not just buying a 5V power supply, which can provide enough current. Then you can connect it to the Arduino and the LED strip in parallel. No need for voltage regulation in that case.

Figure out the amp draw of each component, i.e. Arduino and LED strip.  Buy a voltage regulator that supplies the voltage needed but, more importantly, can supply the Arduino amp draw plus the LED strip amp draw.


text:
Scheduler comparison for Arduino Uno
I understand that the official Arduino Scheduler doesn't support Uno, and there are several third-party schedulers to fill the gap, notably, Scheduler, Arduino-Scheduler and TaskScheduler. There are probably many more, though I see that many so-called "task schedulers" are actually just periodic function callers which don't handle context (i.e. they don't support yield()).
I need to make a choice of a scheduler to use in a project (a real one, with yield, not a periodic function caller). Is there any comparison of Arduino task schedulers? I'm specifically interested in the following aspects:

context switching time (the most important one)
RAM/ROM consumption estimation
list of supported boards

Arduino featured this on Facebook some weeks ago https://hackaday.com/2021/03/17/running-57-threads-at-once-on-the-arduino-uno/?fbclid=IwAR0r7ot5Yz6MYjDLW6d5_rPAbfLXv_bCqoO869QKmjz0qN1zvYtmUw1Wf8U

@Juraj This seems to be yet another cyclic function runner with no context handling. You simply can't fit 57 separate stacks in 2k of RAM.

I have just tested vbextreme/Scheduler and Arduino-Scheduler using the following code:
#include <Scheduler.h>

void setup() {
  pinMode(3, OUTPUT);
  Scheduler.startLoop(loop2);
}

void loop() {
  digitalWrite(3, LOW);
  yield();
  digitalWrite(3, HIGH);
  yield();
}

void loop2() {
  yield();
}

Without any Scheduler lines, the code occupies 734 bytes of ROM, 9 bytes of RAM, and the pin toggles with a period of 8.5 us (117 kHz). The numbers below represent the additional ROM/RAM/execution time:

vbextreme/Scheduler occupies additional 1676 bytes of ROM, 70 bytes of RAM, and the context switch takes 15.5 us (toggle frequency 14.18 kHz). It seems to only support AVR/SAMD boards.

vbextreme/Scheduler with CONFIG_AVR_OPTIMIZE_COOPERATIVE set to 1 occupies additional 1568 bytes of ROM, 70 bytes of RAM, and the context switch takes 11 us (toggle frequency 19.07 kHz).

Arduino-Scheduler occupies additional 578 bytes of ROM, 44 bytes of RAM, and the context switch takes 10.6 us (toggle frequency 19.59 kHz). It supports AVR/SAMD and some of the Teensy/STM32 boards. It seems that this scheduler is not compatible with tasks which use malloc().

CopyThreads occupies an additional 2148 bytes of ROM, 41 bytes of RAM, and the context switch takes 54.5 us (toggle frequency 4.417 kHz). This scheduler claims to have the advantage of using a single stack, so as long as tasks do not yield during peak stack usage, each task has essentially the complete stack at its disposal.

I couldn't get the equivalent code for TaskScheduler to run, I'll be grateful if someone posts an answer featuring schedulers I didn't test.


text:
Running Arduino mega on 5V power supply
I'm wondering if I can run Arduino mega on 5V power supply, even though it's recommended for 6-12V. USB has only 5V right, will it be a problem? I expect to draw quite a lot of power from the 5V pin too so could it be a problem?

Here's what I did for my project:
I used a high current regulated 5V supply. I took a USB cable with the square connector that goes into the Arduino and cut it in half. I attached the red and black wires to +5V and ground on my regulated power supply. I then drove the high current components in my project directly from the 5V supply.
If you use this approach you should probably also add filter capacitors between 5V and ground at both the Arduino and the high current load. Those will help  smooth out the voltage variations as the high current load switched on and off.

You should also make sure the grounds for USB (both host and Arduino sides) and the bench power supply are 1) connected and 2) at the same potential.  Plugging all the power sources (USB, bench) into the same power strip suffices for the latter.

You misunderstand what I'm suggesting. I power my project with a single 5V power supply. The high current components are connected directly to the 5V, and the Arduino and it's low current components are fed through a dummy USB cable that is also connected to the 5V supply. If I need to program the Arduino I instead use a real USB cable connected to my computer.

If you do this often, you can buy a variety of USB connectors to build your own cable, instead of sacrificing a cable. This could allow using a project box with a female USB input to a power rail, then over to the Arduino through the onboard USB connector. You can even hook up the data between the female USB on the box to the internal USB male connector, if you wanted to keep that functionality for debugging and reprogramming purposes.

The 6-12V range applies only to the onboard voltage regulator(if you provide power via Vin or the barrel jack). The Arduino itself runs on 5V and the regulator needs a bit headroom above that to do the regulation.
You can run the Arduino via USB, since it has 5V, just as needed by the Arduino
And you can provide power directly to the 5V pin (with a voltage of 5V or course).
If some of your components draw a lot of power, you should never draw that current through the Arduino. You need to connect the power supply in parallel to your components and the Arduino, so that the high currents can flow past the Arduino, not through it.

If you connect it from the USB port on your computer to the USB plug on the Mega, you'll do fine. What you can't do is connect a 5v source to the barrel jack; that goes to the board's voltage regulator which needs ~ 7v minimum to provide 5v out.
"Quite a bit of power" is a rather vague specification. A USB port can supply 500mA unless the device in question negotiates for more current and the port in question is capable of supplying it. What is probably more concerning is if you're trying to pull a lot of current through the Mega, you risky overloading its pin-drivers or its PCB tracks. The Mega's pins are spec'd for 20mA; 40mA Absolute Max, briefly, to not damage it. The total current budget is 200mA max. If you're planning to approach either of those levels, you should consider powering some of your devices separately. That might include powering from the same or another USB port, as long as you don't pass it through the board, and you observe the USB ports' maximum currents as well.

Yes, you can run the Arduino Mega off of a 5V supply. Instead of connecting the voltage to the DC jack, instead feed your 5V into the +5V pin on the Arduino header. (it is one of the red pins in the image below).

It's important to add that this only works if it's a regulated 5V power supply, that means it must be able to provide (more or less) exactly 5V, regardless of the load.


text:
Arduino UNO with integrated ESP2866 wifi not working correctly
I bought this "knockoff" Arduino UNO with an integrated ESP 2866 wifi module. But I can't make it work. I've followed this tutorial because it's the same product as I have, but I can't make it work anyway - even blinking with LED doesn't work. Does anyone have experience with this exact (or similar) board with integrated ESP2866? I would be really glad for any help. link to the product. If you need to know anything else, I'll try my best to answer it.
My problem:
The board normally loads into IDE and i can send code to it. But after I do that, I get this:
Executable segment sizes:
IROM   : 228624          - code in flash         (default or ICACHE_FLASH_ATTR)
IRAM   : 26756   / 32768 - code in IRAM          (ICACHE_RAM_ATTR, ISRs...)
DATA   : 1248  )         - initialized variables (global, static) in RAM/HEAP
RODATA : 688   ) / 81920 - constants             (global, static) in RAM/HEAP
BSS    : 24880 )         - zeroed variables      (global, static) in RAM/HEAP
Sketch uses 257316 bytes (24%) of program storage space. Maximum is 1044464 bytes.
Global variables use 26816 bytes (32%) of dynamic memory, leaving 55104 bytes for local variables. Maximum is 81920 bytes.
esptool.py v2.8
Serial port COM6
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 2c:f4:32:44:1f:0b
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Erasing flash (this may take a while)...
Chip erase completed successfully in 8.7s
Compressed 261472 bytes to 193136...
Wrote 261472 bytes (193136 compressed) at 0x00000000 in 17.0 seconds (effective 122.9 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

But the LED doesn't blink.

The link to the tutorial is invalid. Please provide a valid link

@chrisl Sorry, changed it

I don't know why the answer below is accepted, as it clearly doesn't solve the question but also gives false information. In this answer @chrisl assumed that blinking green LED is what was programmed with sketch, but if you will open sketch used in this video and read comments in the source code, then this misconception will become obvious: actually red RX LED is what was programmed.
This board has two independent chips: ATmega328P and ESP8266, and ESP8266 built-in LED is combined with RX LED. So when you are blinking with ESP8266 LED, you are blinking with RX led.
And this is what tricked most people answering here, as they were looking on green blinking LED, which is controlled by ATmega328P.
Having said that, I also have to admit that I don't have solution for original question and I don't know why it doesn't work for @krystof18, but in video it clearly works.
EDIT:
TL/DR:
Don't use LED_BUILTIN, but attach an external LED and a resistor to ESP GPIO pins. Modify the sketch to use correct pin and upload while switches 5,6 and 7 are ON. Then disconnect the board and turn switch 7 OFF. Then you have to power board again and it should work.
Long explanation:
I have a board visually similar to what is on the video tutorial you have posted, but for me the blink example doesn't work, probably because LED is wired to some other PIN, rather than #defined for LED_BUILTIN. But I managed to get it working using this tutorial! Watch from 5:58. (Please note this video is in language I don't understand and have no idea what language it is, but the video itself is so obvious, that you basically don't need to understand what does that guy say).
Basically in this tutorial it is just blink example, but using external LED, instead of built-in. If you look at your board, then you can find 4x3 bar of pins located near 0, 1 and 2 Arduino digital pins. This bar is labelled "ESP pins" and it is what is says: ESP8266 pins. Pin labels are on the back of the board.
So this guy in video just connects GPIO16 and GND pins to a LED with resistor, and then modifies original blink example to use 16 instead of LED_BUILTIN. Then he uploads it to his board with switches 5,6 and 7 ON. Then he plugs-off the board and turns switch 7 OFF, so only switches 5 and 6 are on. Then he plugs board back in and it works!
I tried it and it works for me, hooray!
Also, if anyone can tell me what language this guy speaks in the video tutorial I posted - I am just curious! :)

You seem to have more knowledge than me within this topic, so do you know how do i make these two chips comunicate? And in best scenario, even transfer small amount of data?

I got this board recently and still trying to understand how to work with it properly. I was able to successfully upload sketch for ATmega328, with proper switch setup, as per table mentioned in response above, but when I change switches to USB->ESP8266 sketch update, then it seems to be uploaded fine, but then just doesn't work :( I will continue my efforts and will let you know if I'll be successful.

Hey, @krystof18, I managed to get it working and edited my original answer! Hope it will work for you too! Please let me know.

I know it's been a while, but I had a lot to do and today I finally got time for that and I wanted to thank you so much, it works for me now too. Did you find a way to transfer for example an array (or how is it called in Arduino IDE) to the atmega chip? Thanks much for the second time. BTW the language is Indoneese according to google translator.

You are obviously currently programming the ESP8266, not the Atmega328p. The board seems to have DIP switches on it. With those you can control, which chip is connected to which. The product description has the following table
Connection  DIP
1   2   3   4   5   6   7
ATmega328<->ESP8266     ON  ON  OFF     OFF     OFF     OFF     OFF
USB <->ATmega328    OFF     OFF     ON  ON  OFF     OFF     OFF
USB<->ESP8266 (Update firmware or sketch)   OFF     OFF     OFF     OFF     ON  ON  ON
USB<->ESP8266 (communication)   OFF     OFF     OFF     OFF     ON  ON  OFF
All independent     OFF     OFF     OFF     OFF

If you want to program the Atmega328p on it, you need set the DIP switches to the combination "USB <-> Atmega328". Currently you most likely have the combination "USB<->ESP8266 (Update firmware or sketch)", which means, that the ESP is connected to the USB chip (and thus to the PC) for programming. For blinking the Arduinos buildin LED you need to program the Atmega328p.

About the blink sketch: In the tutorial video he programs the ESP. But in the blink example he changes the delay time to 5000, which would mean on and off times of 5s. The LED, that he is pointing to, is blinking much faster, though he doesn't address this. I think he actually has the standard blink sketch on the Atmega and only pretends (or just didn't notice) that this happened due tp his programming. As you don't see a blink with the ESP, but with the Atmega, I would guess, that the LED marked with L is connected only to the Atmega (like on a normal Uno) and the ESP doesn't have any LED to blink connected. So everything is actually working as expected, the tutorial was just bad at that point.

In the tutorial, he uses contection USB <-> ESP8266 and example that is mentioned for ESP8266, i don’t think I made mistake there, but you can tell better if you watch the tutorial. My switch setup is 1,2,3,4-off 5,6,7-on 8-off

What is shown in that tutorial doesn't really add up. He changed the delay in the ESP8266 blink sketch to 5000. That would mean the LED stays on for 5s, then goes off for 5s and repeat. The LED in the video blinks way faster than that. I guess he has the standard blink on the Atmega328p and now tells us, that that is his changes code. Please try the standard blink sketch on the Atmega328p. Then we can test that hypopyhsis

Its advertised as UNO, but UNO in IDE doesn’t work, what device should i pick for that?

What do you mean with "doesn't work"? Aren't you able to upload to it? Have you changed the DIP switches to "USB <->Atmega328"? Maybe it comes without a bootloader. Then you would need to burn it to the Atmega via ISP (using another Arduino or an ISP programmer). Or maybe it has the old bootloader. Then you need to choose the corresponding option in the menu

My bad, sorry it does work, I just switched it wrongly, it's late :D And yes, normal blink works perfectly

Also what I noticed, even if I change the switches to set up in tutorial and run ESP8266 blink, it blinks in the interval I set on the normal blink, so nothing blinked on his side too I guess.

The ESP8266 blink only works, if there is actually an LED connected to that pin of the ESP on the board. Most likely the ESP just doesn't have an LED connected

@krystof18 I added a small paragraph about that in my answer, since comments are temporary. If you consider my answer as correct, you can mark it as correct.


text:
Programming ATtiny85 with Arduino-IDE and an 8MHz external oscillator
I have a digispark ATtiny85 development board and I am using the Arduino IDE to program it along with the Arduino UNO as my hardware programmer.
I have successfully burned the fuses for both the internal 1 and 8 MHz RC oscillators using the original Arduino as ISP sketch (you'll understand why I said original in a moment), but as my application needs precise timing, I would like to use an external oscillator, however, every time I tried to burn/program the bootloader/fuses using the Arduino IDE and using the original Arduino as ISP, the avrdude spits the infamous (Yikes).
I searched online and found an updated version of the Arduino as ISP sketch, which is supposed to an updated version, it has only one downside, which is, it can't do anything other than burn/program the bootloader/fuses, meaning that it can't be used to program the ATtiny85 like the original Arduino as ISP could do.
So without hesitating, I tested it to burn/program the bootloader/fuses for the internal 1 and 8 MHz RC oscillators, and it worked perfectly, and as expected, it fails to upload the code.
But the original Arduino as ISP successfully uploaded the code.
When I tried to burn/program the bootloader/fuses for the external 8MHz crystal oscillator using the updated Arduino as ISP, it worked flawlessly... until I noticed that the ordinary Arduino as ISP can not upload the code anymore and I am presented with the infamous (Yikes!) error.
Let me elaborate the difference in the connections between the two sketches.
The updated Arduino as ISP generates a clock signal on pin #9, which connects to the CLKI of the ATtiny85 (AKA Pin #2 "PB3"), while the original Arduino as ISP does not utilize this pin at all.
I found the updated Arduino as ISP on the electronics stack exchange forum, but unfortunately I lost the link to the question which contained why is this updated Arduino as ISP is better.
I can provide both codes though if someone needs them.
I have my crystal connected in both cases, burning/programming the bootloader/fuses and while trying to upload my code.
This is the infamous (Yikes!) error which I was talking about.

This is my current wiring.

Please note that I connect pin #9 to the CLKI of the ATtiny85 (AKA Pin #2 "PB3"), only when I am using the updated Arduino as ISP.
This is the actual wiring.

My two questions are:

How could I burn/program the bootloader/fuses of the ATtiny85 to use an external oscillator of 8MHz or 16 MHz?
How could I upload my application code after burning/programming the bootloader/fuses?

I hope the answers elaborate how the connections would differ, if it would.
Thank a lot in advance.

It may just be because I'm tired, but: You programmed the fuses for use with a crystal.  Did you not attach a crystal?

@timemage, good comment, I forgot to mention that I have my crystal connected in both cases, burning/programming the bootloader/fuses and while trying to upload my code.

Can you show how this is wired?

@timemage, yes, allow me 5 minutes to upload a proper image please.

@timemage, post edited.

I was sort of looking for a picture of the actual wiring.  But, your diagram does raise the question: Do you not have any load capacitors?

@timemage, no problem I can upload a picture of the actual wiring, sorry for the misunderstanding.
But to answer your question, if by load capacitors you mean the capacitors connected between the crystal pins and ground, no I have both of them disconnected.
But if you mean the decoupling capacitors connected between VCC and GND, yes I do have these connected, one 0.1uF to be exact.

Let us continue this discussion in chat.

@jsotola, I am sorry, I only wanted to reach more people in different fields.
That post is now deleted.

If you look at the Digispark Schematic you'll see resistors and Zener diodes attached to XTAL1 and XTAL2:

These are for the USB D+ and D- signals that the Digispark bit-bangs.  I deeply suspect that the crystal is just not going to resonate with these parts connected.
To get back to a working Digispark you'll probably have to inject signal onto XTAL1 again and reprogram the fuses to internal OSC.

Thank you, I am glad you asked for actual wiring.
Can I "in theory" remove the resistors R1 and R2 so I can test this out?
The end-user project will not be using a digispark, but a bare-metal ATtiny85 on a PCB.

Yes, that should allow you to use an external crystal.  Although it will no longer bit-bang USB, but I suspect you understand that.

Yes, I do understand, thank you very much for your time.
I will try what I have said and get back to you if you please.
Thank you.

It may be a number of hours before I see any update or respond to it.

No problem at all, take your time.

It worked, thanks a lot.
Words can't express it really.

It might have been easier to use a bare ATTiny85 DIL package and a 5V linear voltage regulator, you don't seem to be using much else on the Digispark. The old "Arduino as ISP" sketch supported three diagnostic LEDs which were useful. AVR programmers can be quite inexpensive - e.g. I like the Pololu USB AVR programmer (another)


text:
I need a good battery reccomendation
I have simple project composed of an Arduino Nano, a HC-05 module, and a small toy DC motor controlled using a L293D driver, I want to be able to power this circuit entirely using a battery, here is what I tried:
-The motor/L293D combo works when the Arduino Nano is powered through it's USB jack, except the L293D is drawing power from the Nano, which I know is very bad practice, but I only did it for testing purposes.
-The HC-05 module also works fine when the Nano is powered through it's USB jack, as expected.
-However, the power received through the USB jack is not enough power for both the HC-05 and the L293D & motor simultaneously, if I want to change the PWM through the HC-05, I have to disconnect the motor, send the instruction, then disconnect the HC-05 and re-connect the motor.
-I have tried 3, pretty much new 9V batteries, none of them were enough to power anything, not the Nano board through the Vin pin, not an Uno board through barrel plug, not the motor, nothing, except a LED diode, I've read somewhere that most brands of these kinds of batteries don't actually provide nearly as much power as they claim, so that might explain it. (In case it's relevant, the brands I tried are VARTA, Uniross and Goldmen.)
-Someone gave me the idea of using an old mouse cable to power the Arduino, by taking the VCC and GND wires from the mouse cable and using those to power the Nano board through it's Vin and GND ports, it works, but not any components connected to it, not even the HC-05 module, which I even tried powering directly from the mouse cable, which lit up it's LED, but did not get it to work.
Honestly this isn't that relevant, I just wanted to make sure the Vin pin worked.
-Also, few side notes:
My multimeter mysteriously stopped working when I actually needed it, which is why I couldn't take any measurements.
The L293D datasheet and other pinouts suggest no less than 12V supply voltage, so maybe a 9V battery wasn't the right answer to begin with.
The power coming from the mouse cable is enough to power the DC motor independently, but not through the L293D, it says online the average output for these cables is around 5V, but without measurements I can't be sure.
The battery holder for the toy train that has DC motor inside accepts 1.5V batteries wired in series, and considering there's not much else there aside from the motor itself, it's safe to say that 3V is the minimum required voltage for the motor.
So, what battery do you think would be most suitable for my project?
And if it's not against the rules, what brand would you recommend?

9V batteries aren't any use for anything at all. You need the voltage of the motor plus the voltage drop of the motor driver. For 3V motors the L293D is useless. TBH I wouldn't recommend using it for anything. It's old technology. You want a MOSFET based motor driver.

@Majenko Well, you see, I'm trying to keep the circuit a small as possible, because I'm installing the whole thing on a small 3x13x3cm toy train, the one with the motor I'm trying to control, so I'm either gonna have to stick to the l293d, or something as equally small, something that fits on a 4.5x3 breadboard while also leaving enough space for the HC-05 module, got anything that fits that description?

The L293D has about a 2.6V drop on the output pins. That means for a 3V motor you need to provide about 5.6v for it to run at full speed. 5V will work, but it will run slightly slow and underpowered.
9V batteries are useless. Only any good for very low power applications like smoke alarms. They just can't provide the current you need.
Instead you need to be looking at model aircraft / drone suppliers for a "2S" battery (7.4V Li Poly / Li Ion) and a suitable 5V (or 5.6V if you can get it) UBEC (switching regulator).

Is the UBEC necessary? Also will 7.4V be enough, L293D data sheets and pinouts always specify 12V as minimum voltage.

The datasheet I just looked at specified 4.5v to 36v for the supply voltage. I don't know what datasheet you've been reading.  If you have too high a voltage you can burn out our motor.

Yeah I checked more reliable resources and you're right, so what about the UBEC? Is it a necessity or will one of the batteries you mentioned be sufficient on it's own?

That depends entirely on your motor.

Is there a way for me to know? We already established my motor requires around 3V, if I'm supplying somewhere between 5 to 7.4V, I don't think there's any risk of burning the motor, that's similar to what the Nano board is supplying so I don't think there's any risk...Which does remind me, what about the Nano board itself as well, the battery I need will be supplying the Nano board as well, so I'm assuming I'm gonna need a battery that supplies double of what we discussed, right?

7.4V is fine for the VIN to the nano. If you think you need to double it then you need to put the electronics away in a drawer and go and learn some basic theory before you start.

No need to be condescending, I studied electronics for 6 years between highschool, college and a training center, but there's a big difference between studying something and actually learning it, evidenced by the fact that I learned nothing, which is why I'm now taking a more practical approach by attempting these kinds of projects, thank you.

Then you should know that devices connected in parallel (as you would for this) sum the current, not the voltage.

Yeah I guess, they taught us Kirchhoff's law, but it's practical application, merely another formula to be regurgitated in exams.

You should spend some time doing a little revision before you blow something up then...

I meant to say "but not it's practical application", but yeah you're right, I'm on a tight schedule with this project, but I'll take a more methodical approach next time, thank you.

You could also use a 4 channel relay for making the motors work and they can be independent of using power from arduino and is really effective, I sometimes use it for high voltage optocoupling and can be used for small ones too all you need to do is build logic and everything would work fine I assume you know how to reverse polarity on a dc motor.
Relays are not power hungry and can be powered from arduino but if you could give it an external 5 volts that would be better.
Which in case of L293d driver is not the case you would require at least 12 volt to power the driver itself.

Well, you see, I'm trying to keep the circuit a small as possible, because I'm installing the whole thing on a small 3x13x3cm toy train, the one with the motor I'm trying to control, so I'm either gonna have to stick to the l293d, or something as equally small, something that fits on a 4.5x3cm breadboard while also leaving enough space for the HC-05 module, got anything that fits that description? Plus I still need to find a decent power source so if you have a recommendation for that as well I wouldn't mind.


text:
Where is the digitalPinToInterrupt macro defined
I am new to Arduino, and it's confusing to me how you can just write code in the IDE and use functions or macros such as #define ISR() in the avr-libc library without having to include the header file in the Arduino sketch.
I was trying to find where digitalPinToInterrupt() is defined, but had no luck. Any idea?

Looked at Arduino.h?

https://arduino.github.io/arduino-cli/latest/sketch-build-process/

Generally, if you want to find identifiers in your Arduino board support, you can run the ctags program on the libc and Arduino core files.  ctags is used as part of the build process in its effort to generate C++ declarations for you.  So it is generally available to you as an Arduino user.  You should find ctags or ctags.exe in:

/path/to/arduino15/builtin/tools/ctags/version-number/

This can be run against your board support in:

/path/to/arduino15/packages/vendor/hardware/architecture/version-number/

And your standard libraries found under directories in the form of:

/path/to/arduino15/packages/vendor/tools/compiler-tool/version-number/

If you're wondering what /path/to/arduino15/ would be on your system, it's documented here in terms of where the preferences file is stored.  The relevant paths containing and version numbers and architecture names should show in the verify/compile output when verbose mode is turned on in preferences.
Specific example
On my linux system with reasonably current versions of UNO-related things, my command-line would look like:
~/.arduino15/packages/builtin/tools/ctags/5.8-arduino11/ctags \
    -f /tmp/output-file \
    -R \
     ~/.arduino15/packages/arduino/hardware/avr/1.8.3/ \
    ~/.arduino15/packages/arduino/tools/avr-gcc/4.8.1-arduino5/avr/include/

The resulting tag file can then greped or just opened and the following entries can be found, showing the filenames and line numbers to investigate:
DigitalPinToInterrupt   /home/user/.arduino15/packages/arduino/hardware/avr/1.8.3/variants/circuitplay32u4/pins_arduino.h   138;"   d
digitalPinToInterrupt   /home/user/.arduino15/packages/arduino/hardware/avr/1.8.3/variants/ethernet/pins_arduino.h  79;"    d
digitalPinToInterrupt   /home/user/.arduino15/packages/arduino/hardware/avr/1.8.3/variants/gemma/pins_arduino.h 64;"    d
digitalPinToInterrupt   /home/user/.arduino15/packages/arduino/hardware/avr/1.8.3/variants/leonardo/pins_arduino.h  160;"   d
digitalPinToInterrupt   /home/user/.arduino15/packages/arduino/hardware/avr/1.8.3/variants/mega/pins_arduino.h  110;"   d
digitalPinToInterrupt   /home/user/.arduino15/packages/arduino/hardware/avr/1.8.3/variants/robot_control/pins_arduino.h 120;"   d
digitalPinToInterrupt   /home/user/.arduino15/packages/arduino/hardware/avr/1.8.3/variants/robot_motor/pins_arduino.h   115;"   d
digitalPinToInterrupt   /home/user/.arduino15/packages/arduino/hardware/avr/1.8.3/variants/standard/pins_arduino.h  79;"    d

In the case of an UNO the standard variant is the significant declaration.

There are different implementations of ctags.  The one used by the Arduino support files is Exuberant CTAGS and you may want to read its documentation, to learn how to control the program to display differently to only search for specific identifiers, etc.  It is also typically used with editors that have some special support for the resulting tags file, to jump to definitions, like an IDE would.

By the way, I just noticed your atmega2560 tag.  The generic instructions should cover this anyway, but: You'd be looking at the mega variant, which indicates this file and line.

If you like to tinker with the files. Than platformio is great option to go with. It provides auto completion and much more advance functionality.
You can easy see where some function/mecro is defined, by just right click on the function than click on the "Go to definition" option.

The file that contains the definition will be opened in the new tab. As for your current Macro check the image below


text:
Interfacing Arduino nano ,adxl335 ,nrf24l01
I'm trying to make a project with this conection diagram  but I don't think it's correct , and my adxl sensor died . Can you help me with a modified one ?

the Nano ground is not connected to the battery ground

what do you need help with? ... you said nothing about any problems that you are having ... adxl sensor died does not mean anything ... description of what you observed would mean something

I want to connect that transceiver and accelerometer to arduino nano and I don't know how to make the connections correctly , I used that picture and destroyed my adxl sensor.Battery's -, accelerometer and tranceiver should all be connected  to arduino's ground and adxl's VCC should be connected to arduino's 3V3 ?

did you get the solution i have the same project


text:
Digital pins are no longer outputting enough to click a relay
I've been working on a project for awhile now, and I ran into a problem a week ago I couldn't solve. I'm using an Arduino uno R3.
My project involves the use of 4 relays triggered by the digital pins. Write a HIGH value, relay clicks. Write a LOW value, relay unclicks. Rather simple.
One day, I come back to it to discover it can no longer click the relays. No changes were made to my code that worked previously. The relay light came on, but no click. Could it be that I sent HIGH to 4 at the same time? My theory is that I could've drawn too much power at the same time, weakening it in a way that causes it to not output as much as it did previously.
I tested a relay on a different board and it works perfectly fine.

how are the relays powered?

The relay has 3 pins. 5V in, GND, and signal. It's powered by the board. Reconnecting the signal wire from the PWM pin to the 5V triggered the relay, so it's not a voltage problem or a relay problem. I've also tested many relays

stop calling it PWM pin. it is a digital pin. you don't use PWM to control a relay

Relays need a certain current and Arduino pins can only provide a small amount of current. Normally you don't power the relay coil directly from a pin.
Please post a schematics of your wiring, as well as a reference or datasheet for the relay you're using.

Are you recommending I use the relay in a different way? I'm unable to provide a visual diagram for my wiring, but it goes like this: 5V power to DC+; GND to DC-; PIN6 to IN1.

Yes I am. You can use an online schematic tool or either draw a crude one by hand. In any case, the specs of your relay is an important information (either part reference or datasheet).

Not knowing the reference of your relay, my answer is generic but should suit your needs.
Relays need 2 things in order to work properly: a sufficient voltage source, and one that can provide enough current.
The Arduino output pins provide 5V on 5V boards or 3.3V on 3.3V boards. BUT, most Arduino GPIO can provide only 20 mA of current. That might not be enough for your relay. The solution here is to use a transistor to drive the relay.
Also, relay coils are inductive loads that generate voltage spikes when current is turned off. That voltage can rise much higher than 5V and damage your Arduino pins and weaken or destroy them. The solution to this problem is to add a flyback diode.
This is what a typical circuit with relay driven by an Arduino looks like:

When the Arduino pin is LOW, the transistor is turned off and no current goes through the relay.
When the Arduino pin turned ON, the transistor turns on fully saturated and the relay coil is energized.
When the Arduino pin is turned LOW, the coil generates a negative voltage and current is allowed to go through the diode, dissipating energy in the relay coil. More information on flyback diodes: https://en.wikipedia.org/wiki/Flyback_diode

inductive loads generate reverse voltage spike when it is turned OFF

Well-spotted, thx.

There is another thing: the SUM of currents (driving or sinking), may be a thing. Despite proper operation of one relay, even two, when situation comes to drive all relays this may be too much when all currents add. For ATMEGA328P-PU sum of currents may not exceed 200mA. Recommended lecture: Arduino Uno R3 microprocessor's datasheet (ATMega328P-PU)

For 4 relays, the OP would be limited by the per pin current limitation way before being limited by the per chip limitatation. Using a transistor would reduce the current provided by the chip to way below both limits.

Post a link to the relay you are using, I do not know if it is a plane relay or a relay module for the arduino. The modules are less then a buck from your favorite china supplier.

As I stated on the other Forum a Power Supply the Arduino Is NOT! What else is connected, I have a feeling if you touch the regulator on the Arduino you will burn your finger and it may even be loose. Use a volt meter and measure the 5V, I think that is your problem.


text:
How to avoid two arduino components using the same digital PIN
I'm trying to build an Arduino project where it involves a TFT and an ethernet W5500 component.
Here's the project I want to build to learn Arduino. However I wanted to change the board that already has an ethernet PoE here. The TFT I plan to use is a shield. It seems that pin D10 are being used by both components.
Is it possible through software to use a different Digital pin through software for either the board or the TFT display?  I have read where users are cutting traces and using jumper wires - would that be required in my case? I am planning on using SPI pins if possible. Thanks!

Sorry - let me edit.  I forgot to mention the TFT I plan on using is a shield. The W5500 mention in my link is built-in to the board and uses CS10.

Yes you can, but you will need to modify your TFT screen shield to disconnect pin 10 and route it to an unused pin.

Just connect the pin that would go into D10 to an unused pin with a cable. When defining TFT_CS, change the 10 simply to the pin you used.


text:
NodeMCU and relay with VIN power
Have read a lot of different things online, and I just ain't sure yet.
I'm trying to hook up a NodeMCU to control some relays. And want to power the NodeMCU by the VIN pin.
Anyone know if this setup is possible?
Or should I do it in another way?

Is it necessary to use the JDVCC at all when I use this setup?
Maybe I can keep the jumper on VCC/JDVCC and only connect to the VCC on the relay?

you would use JDVCC with separate power supply for relay coils. then you would not connect the grounds. main reason would be to prevent EMI from relays switching

So what you are saying is that, for my setup, I don't need to use JDVCC?

I see. For my setup, I will only be using max 2-3 relay at the time

24VAC to control some irrigation valves

it should, but you could also be just out of range of the 5v hi/lo. You can fix that with a level shifter, or, feed the esp32 3.6v instead of 3.3v (still in spec).

Looks fine to me, I don't see any issues, assuming the PSU has sufficient 'grunt' to power both, and most will have.

I'm using a 24VAC to 5VDC 3A converter as the PSU supply

Plenty of surplus power there, you shouldn't have any issues


text:
HC-05 bluetooth module short range
I have started learning about arduino and just bought a bluetooth module, HC-05. From where i bought, it says it has range of approx.10 meters. I made hc-05 connection with arduino in below described ways
I am using it as a slave with default configurations, 9600 baud rate and HC-05 name with pin 1234
GND of HC05 -> GND of `arduino`
VCC of HC05 -> 5V of `arduino`
TX of HC05 -> RX of `arduino`
RX of HC05 -> TX of `arduino` via voltage divider network 2k---|---1k

Below is my arduino code
#include <SoftwareSerial.h>
SoftwareSerial BTserial(2, 3); // RX | TX
// Connect the HC-05 TX to Arduino pin 2 RX.
// Connect the HC-05 RX to Arduino pin 3 TX through a voltage divider.

int pin = 13;
char c = ' ';

void setup()
{
 Serial.begin(9600);
 Serial.println("Arduino is ready");
 pinMode(pin,OUTPUT);

 // HC-05 default serial speed for communication mode is 9600
 BTserial.begin(9600);
 Serial.println("BTserial started at 9600");
}

void loop()
{
  if (BTserial.available()>0){
    c = BTserial.read();
    Serial.println(c);
    switch (c){
      case '1' :
        digitalWrite(pin,HIGH);
        break;
      case '2' :
        digitalWrite(pin,LOW);
        break;
      default: break;

    }
  }
}

Following things happening to me:

When I power the module I am able to discover it with my phone but only when I hold my phone very near to the module. If I move away from the HC05 module, for example 3-4 feet, I am not able to discover it.

2.After connecting with it (while holding phone near to the module), I am able to send data to it but again, if I move away , only a few steps, I am unable to send data and I disconnect from it automatically. Also if I change direction of the antenna even then no communication happens.
My purpose is to control my home's lights and TV with the help of this module and Relays. But HC05 is useless so far. I was hoping that I would code it and wire it and hang it on a wall and interact it with and andoird app.
Is it suppose to happen like this? or there's something wrong with my module's antenna
thank you.

What, if anything, is near your HC-05 antenna?

on breadboard, some jumper wires near antenna

but i tried holding it up in the air buy pulling it from breadboard and using female jumpers


text:
SIM808 GPS+GSM Vehicle Tracking using Maduino Zero SIM808 GPS Tracker V3.5
I'm learning about GPS technology and I bought the Maduino Zero SIM808 board V3.5 to design a vehicle tracker. I have found source code for the project online.  After I upload the code to Maduino board, the code executes fine.
I'm sending "Location" to the device and i'm expecting reply with google map on my phone to be able to check device location, but i'm not getting reply from the device. i have changed the AT commands to test if i will get reply from the device, here is the source where i got the project: https://how2electronics.com/gps-gsm-based-vehicle-tracking-system-using-arduino/
Here is my output from the code:
Text Mode: ON
GPS Intializing…
GPS Initialized
Location:
Send sms to get the location

#include<string.h>

#define DEBUG true

int PWR_KEY = 9;
int RST_KEY = 6;
int LOW_PWR_KEY = 5;

String msg = String("");
int SmsContentFlag = 0;
String mob;
String loct;
void setup()
{
  pinMode(PWR_KEY, OUTPUT);
  pinMode(RST_KEY, OUTPUT);
  pinMode(LOW_PWR_KEY, OUTPUT);
  digitalWrite(RST_KEY, LOW);
  digitalWrite(LOW_PWR_KEY, HIGH);
  digitalWrite(PWR_KEY, HIGH);

  //      String msg = String("");
  //    int SmsContentFlag = 0;

  SerialUSB.begin(115200);
  Serial1.begin(115200);
  //modulePowerOn();
  delay(2000);
  SerialUSB.println("Checking Module...");
  int i = 1;
  String res;
  while (i) {
    Serial1.println("AT");
    while (Serial1.available() > 0) {
      if (Serial1.find("OK"))
        i = 0;
    }
    delay(500);
  }
  SerialUSB.println("Module Connected");
  //GprsTextModeSMS();
  SerialUSB.print("Text Mode: ");
  i = 1;
  while (i) {
    Serial1.println("AT+CSMP=17,167,0,0");
    delay(100);
    Serial1.println("AT+CMGF=1\r");
    while (Serial1.available() > 0) {
      if (Serial1.find("OK"))
        i = 0;
    }
    delay(500);
  }
  SerialUSB.println("ON");
  Serial1.println("AT+CGNSPWR=1");
  delay(100);
  Serial1.println("AT+CGNSSEQ=RMC");
  SerialUSB.println("GPS Intializing...");
  delay(5000);
  SerialUSB.println("GPS Initialized");
  SerialUSB.flush();
  i = 1;
  String str;
  while (i) {
    Serial1.println("AT+CGPSINF=0");
    delay(100);
    while (Serial1.available() <= 0);
    if (Serial1.find("AT+CGPSINF=0")) {
      str = Serial1.readString();
      //SerialUSB.println(str);
      i = 0;
    }
    delay(500);
  }
  loct = str.substring(4, 23);
  SerialUSB.print("Location: ");
  SerialUSB.println(loct);
  //while(1);
  SerialUSB.println("Send sms to get the location");
}

void loop()
{
  char SerialInByte;

  if (Serial1.available())
  {
    //char SerialInByte;
    SerialInByte = (unsigned char)Serial1.read();
    if ( SerialInByte == 13 ) //0x0D
    {
      ProcessGprsMsg();
    }
    if ( SerialInByte == 10 )
    {
    }
    else
    {
      //EN: store the current character in the message string buffer
      msg += String(SerialInByte);
    }
  }
  if (SmsContentFlag == 1) {
    int i;
    SerialUSB.println("Flag Cleared");
    SerialUSB.print("Message: ");
    SerialUSB.println(msg);
    if (msg.indexOf("Location")) {
      SerialUSB.println("Message Received");
      i = msg.indexOf("+27");
      //SerialUSB.print("index: ");
      //SerialUSB.println(i);
      //SerialUSB.println(msg[i+1]);
      i = i + 3;
      for (int j = 0; j < 10; j++, i++) {
        mob += msg[i];
      }
      SerialUSB.print("Mobile: ");
      SerialUSB.println(mob);
      String cmd = "AT+CMGS=\"";
      cmd += mob;
      cmd += "\"";
      cmd += "\r";
      Serial1.println(cmd);
      delay(100);

      Serial1.print("Your Vehicle Current Location ");
      Serial1.print(loct);
      Serial1.print("\n");
      Serial1.print("Check Map: \n");
      Serial1.print(" https://www.google.com/maps/@");
      Serial1.println(loct);
      Serial1.println((char)26);
      delay(1000);
    }
    ClearGprsMsg();
    SmsContentFlag = 0;
    msg.remove(0);
    mob.remove(0);
  }
  delay(100);
}

// EN: Request Text Mode for SMS messaging
void GprsTextModeSMS()
{
  Serial1.println( "AT+CMGF=1" );
}

void GprsReadSmsStore( String SmsStorePos )
{
  // Serial.print( "GprsReadSmsStore for storePos " );
  // Serial.println( SmsStorePos );
  Serial1.print( "AT+CMGR=" );
  Serial1.println( SmsStorePos );
}

// EN: Clear the GPRS shield message buffer
void ClearGprsMsg()
{
  msg = "";
}

// EN: interpret the GPRS shield message and act appropiately
void ProcessGprsMsg()
{
  SerialUSB.println("");
  //  Serial.print( "GPRS Message: [" );
  SerialUSB.print( msg );
  //    Serial.println( "]" );
  if ( msg.indexOf( "Call Ready" ) >= 0 )
  {
    SerialUSB.println( "*** GPRS Shield registered on Mobile Network ***" );
    GprsTextModeSMS();
  }

  //EN: unsolicited message received when getting a SMS message
  if ( msg.indexOf( "+CIEV" ) >= 0 )
  {
    SerialUSB.println( "*** SMS Received ***" );
  }

  //EN: SMS store readed through UART (result of GprsReadSmsStore request)
  if ( msg.indexOf( "+CMT:" ) >= 0 )
  {
    // EN: Next message will contains the BODY of SMS
    SmsContentFlag = 1;
    // EN: Following lines are essentiel to not clear the flag!
    //ClearGprsMsg();
    return;
  }

  // EN: +CMGR message just before indicate that the following GRPS Shield message
  //     (this message) will contains the SMS body
  if ( SmsContentFlag == 1 )
  {
    SerialUSB.println( "*** SMS MESSAGE CONTENT ***" );
    SerialUSB.println( msg );
    SerialUSB.println( "*** END OF SMS MESSAGE ***" );
    //ProcessSms( msg );
  }

  /*ClearGprsMsg();
    //EN: Always clear the flag
    SmsContentFlag = 0; */
}

Did you mean "device will not reply with google map link"?  It's not clear (to me anyway) what the problem is that you're suggesting may have something to do with your network connection.

I'm sending "Location" to the device and i'm expecting reply with google map to be able to check device location, but i'm not getting reply from the device.  i have changed the AT commands to test if i will get reply from the device, here is the source where i got the project: https://how2electronics.com/gps-gsm-based-vehicle-tracking-system-using-arduino/

remove all GPS code ... reduce your code to only a simple text reply ... something like receive any text, reply "hello world"


text:
sim808 init error when trying to use DFRobot to get gps
I'm using "mega 2650 pro" Arduino with SIM808 BK-808 V-3.1 and I connect the vcc for the sim808 to 5volt pin in the arduino, and the arduino connected with laptop usb. and I add a sim to the sim808 module.
I upload the following code:
#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>

#define PIN_TX 14
#define PIN_RX 15
SoftwareSerial mySerial(PIN_TX,PIN_RX);
DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,

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

//******** Initialize sim808 module *************
while(!sim808.init()) {
delay(1000);
Serial.print("Sim808 init error\r\n");
}

//************* Turn on the GPS power************
if( sim808.attachGPS())
Serial.println("Open the GPS power success");
else
Serial.println("Open the GPS power failure");

}

void loop() {
//************** Send the coordinates(latitude&lonitude)in the Serial Monitor *******************
if (sim808.getGPS()) {

Serial.print("latitude :");
Serial.println(sim808.GPSdata.lat);
Serial.print("longitude :");
Serial.println(sim808.GPSdata.lon);

}

}

but the output is
Sim808 init error
and I tried several codes to test AT commands, nothing work!
so what is the problem?

does Sim808 init error print only once?

no, several times. the while loop repeated @jsotola