text:
What's Wrong with this DHT22?
I made a circuit that takes humidity and temperature from DHT22 sensor and displays it on Lcd Screen. Simple enough but i get this error "Failed to read from DHT". That happens because i have this code
 if (isnan(t) || isnan(h)) {
  delay(100);
    Serial.println("Failed to read from DHT");
  } else {
    delay(100);
    Serial.print("Humidity: ");
    Serial.print(h);
    Serial.print(" %\t");
    Serial.print("Temperature: ");
    Serial.print(t);
    Serial.println(" *C");
    //lcd.print("Temp: ") ;
    //lcd.print(t);
    //lcd.setCursor(0, 1);
    //lcd.print("Hum: ") ;
    //lcd.print(h);
  }

So the values are NaN . But 1 minute before it worked fine, and now again it doesnt. Everything is soldered the right way and nothing is false. Lcd is wired ok and it works but i dont get values from DHT22.
Here are some pics to help you out.

In the third Image we see its working. And now its not!
is the DHT sensor broken?
  #include "DHT.h"
#include <LiquidCrystal.h>`

#define DHTPIN 2
#define DHTTYPE DHT22   // DHT 22  (AM2302)

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  Serial.println("DHT22 test!");
  lcd.begin(16, 2)
  dht.begin();
}

void loop() {

  float h = dht.readHumidity();
  float t = dht.readTemperature();

  if (isnan(t) || isnan(h)) {
    Serial.println("Failed to read from DHT");
  } else {

    lcd.print("Hum: ");
    lcd.print(h);
    lcd.setCursor(0, 1);

    lcd.print("Temp: ");
    lcd.print(t);

  }
}

Thats my code by the way

What lib are you using? Can you post your setup code also?

#include "DHT.h"
#include <LiquidCrystal.h>
#define DHTPIN 2
#define DHTTYPE DHT22   // DHT 22  (AM2302)
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
Serial.println("DHT22 test!");
lcd.begin(16, 2)
dht.begin();
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(t) || isnan(h)) {
Serial.println("Failed to read from DHT");
} else {
lcd.print("Hum: ");
lcd.print(h);
lcd.setCursor(0, 1);

lcd.print("Temp: ");
lcd.print(t);

}
}`

Please amend your question to post the code. Putting it in a comment is pretty-much unreadable.

@NickGammon  done

I can't see a resistor in your photo (maybe it is hidden). There should be a 10 k pull-up from pin 2 to 5V (that is, between pin 2 and pin 1). Do you have that?

@NickGammon no and I guess I don't need that.  Lcd works fine

I always use Adafruit_Sensor and DHT - have you tried that?

Two things:

You need to put a delay in between your read requests. Currently you're reading way too fast, every few milliseconds you're hitting the DHT. Max interval should be every two seconds or so.
Add a 10k resistor between pin 1 and 2 of the DHT.

I'd bet adding a delay, or using the simpleTimer library to control how frequently you read from the DHT will clear this up.

Where should I put resistor

Solder between pin 1 and 2 on DHT. Google image it. It's a very common question.


text:
BMP280 sensor not initializing
I am successfully using a BMP280 sensor via SPI connection with an Arduino Uno R3 board. I'm trying to run the same code with the same setup on an Arduino Ethernet. However the sensor is not initializing.
The setup function looks as follows:
void setup() {
    delay(1000);
    dht.begin(); // starts DHT sensor
    chk = dht.read(DHTPIN); // reads DHT status
    while ((!bmp.begin()) || (chk != 1) ) {
      // checks DHT and BMP status and shows red LED, in case one of them
      // wasn't found. Loops and resets timeout each time.
      wdt_reset();
      Serial.println("Could not find a valid sensor, check wiring!");
      digitalWrite(RED, HIGH);
      delay(300);
      digitalWrite(RED, LOW);
      delay(1000);
      chk = dht.read(DHTPIN);
    }
}

The code only returns the error message and does not initialize the BMP sensor (DHT is fine).
Full code:
#include "ThingSpeak.h"
#include <SPI.h>
#include <DHT.h>
#include <Ethernet.h>
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xE5, 0xBF};
IPAddress ip(10,42,0,69);
EthernetClient client;

// --- Libraries --- //
#include <avr/wdt.h> // Watchdog, interrupts and reboots
#include <Adafruit_BMP280.h> // BMP library for BMP280

// --- Constants --- //
// DHT22
#define DHTPIN 7
// BMP280 (SPI)
#define BMP_SCK 13 // Serial clock pin for BMP (10k pullup to +5V)
#define BMP_MISO 12 // SDO, has 10k pullup
#define BMP_MOSI 11 // SDI, no pullup
#define BMP_CS 9 // CS, has 10k pullup
// LEDs
#define RED 5 // pin for LEDs
#define YELLOW 3
#define GREEN 2

unsigned long myChannelNumber = 115634;
const char * myWriteAPIKey = "***"; // removed for privacy reasons
float dht_temp;
float dht_hum;
float bmp_temp; // values from sensors
float bmp_press;
int chk; // DHT status (0 or 1)
int k; // counter variable
int number;
char COLOR;

// --- Initialization --- //
DHT dht(DHTPIN, DHT22); // initializes sensors
Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK);

void setup() {
  wdt_disable(); // disables watchdog for initial communication
  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);
  pinMode(4, OUTPUT);
  digitalWrite(4, HIGH);
  pinMode(YELLOW, OUTPUT); // LED pins set as output
  pinMode(RED, OUTPUT);
  digitalWrite(YELLOW, HIGH); // starts yellow LED
  Serial.begin(9600); // begin serial connection with 9600 baud
  delay(500); // delay to get connection and sensors ready
  wdt_enable(WDTO_8S); // start watchdog timeout (4 sec might be too short)
  blink(RED, 3);
  Serial.println(bmp.begin());
  dht.begin(); // starts DHT sensor
  chk = dht.read(DHTPIN); // reads DHT status
  if ((!bmp.begin()) || (chk != 1) ) {
    // checks DHT and BMP status and shows red LED, in case one of them
    // wasn't found. Loops and resets timeout each time.
    wdt_reset();
    Serial.println("Could not find a valid sensor, check wiring!");
    digitalWrite(RED, HIGH);
    delay(300);
    digitalWrite(RED, LOW);
    delay(1000);
    chk = dht.read(DHTPIN);
  }
  Ethernet.begin(mac, ip);
  ThingSpeak.begin(client);
}

// --- Loop --- //
void loop() {
  wdt_reset(); // resets watchdog
  pinMode(GREEN, OUTPUT); // gets green LED ready
  digitalWrite(GREEN, LOW);
  delay(1600); // delay for sensors to be read. In total, at least 2 sec!
  dhtread();
  delay(5000);
  wdt_reset();
  bmpread();
  ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
  delay(5000);
  wdt_reset();
  delay(5000);
}

void blink(char COLOR, int number) {
  for (k = 1; k <= number; k = k + 1) {
    // blinks 3x to show that Arduino rebooted
    digitalWrite(COLOR, HIGH);
    delay(100);
    digitalWrite(COLOR, LOW);
    delay(100);
  }
}

void bmpread() {
  bmp_temp = bmp.readTemperature(); // reads BMP sensor
  bmp_press = bmp.readPressure();
  Serial.println(bmp_temp);
  Serial.println(bmp_press);
  if (bmp_press > 0.0) {
    // if sensor isn't attached, it shows 0.0 or negative pressure.
    // This is used as check criterion
    digitalWrite(GREEN, HIGH); // blinks green for good BMP values
    Serial.println("bmp ok");
    ThingSpeak.setField(3,bmp_temp);
    ThingSpeak.setField(4,bmp_press);
    delay(150);
    digitalWrite(GREEN, LOW);
  } else {
    // if pressure is 0.0 or negative, blink red
    // and print 0.0 to keep formatting
    digitalWrite(RED, HIGH);
    Serial.println("Error, BMP280 missing");
    delay(150);
    digitalWrite(RED, LOW);
  }
}

void dhtread() {
  chk = dht.read(DHTPIN); // checks if connection to DHT sensor is ok (0: no connection, 1: ok)
  if (chk == 1) {
    dht_temp = dht.readTemperature();
    dht_hum = dht.readHumidity(); // reads DHT sensor
    digitalWrite(GREEN, HIGH); // blinks once for successful DHT sensor values
    ThingSpeak.setField(1,dht_temp);
    ThingSpeak.setField(2,dht_hum);
    delay(150);
    digitalWrite(GREEN, LOW);
    delay(100);
  } else {
    // if no connection, blink red instead and print "nan"
    // (keeps formatting ok)
    digitalWrite(RED, HIGH);
    Serial.print("Error, DHT22 missing");
    delay(150);
    digitalWrite(RED, LOW);
    delay(100);
  }
}

The problem now is that it seems to initialize (bmp.begin() returns 1), but the sensor is still not reading a correct value (either 0.0 for both pressure and temperature, or a large negative pressure and very large temperature (-2602 Pa, 185°C). What might be the problem? I have tried it with another sensor of the same type, same result. Where else can I attach the CS wire to?

To what pins did you connect the BMP280? It could be that you are using a pin that the Ethernet module already uses. I suspect you are using Pin 10 as the chip-select for the BMP.

Ah no, I am using an Arduino Ethernet, that has the Ethernet module built in (not a shield). I am using 13 for SCK, 12 for MISO, 11 for MOSI and 10 for CS (for CS Ive tried the other free pins I have, 9, 8 and 7).

There is also a DHT22 sensor connected to it (on pin 6), which works fine: https://thingspeak.com/channels/115634
The bottom two fields show the BMP280 values (it returns 0.0 if it isnt connected)

As an update, I managed (somehow) to initialize the sensor by putting the CS on 7 (10 also works though) and disabling the SD card by pulling pin 4 high as output. It still fails to read the correct value though (and returns 0). Any other ideas?

Pin 10 is already used by the W5100.

But regardless of if I put it on 7, 8, 9 or 10, it doesnt work in either case..

You can only enable one 'chip-select' (CS) line at a time, that's how the devices know who you're talking to.   You say you got something to work by disabling the SD card... that would be your issue then... You're selecting the SD Card AND the BMP280 at the same time, they're both talking on the SPI bus.

Hm. When the SD card is disabled, it only sometimes initializes the sensor, but in either case, it never shows a valid value, no matter what pin. Is this an issue with the Ethernet board I am using? Maybe the SPI.h library can be changed to accommodate another pin?

Update the image and code in your question. Also include other stuff that you've tried so far.

The software must be OK, because it runs on the other board, so it has to be a hardware fault. The sensor is OK, because it works on the other board. Assuming the board isn't defective then it must be the way you have connected it.
You haven't included your pin designations. Some Ethernet shields use certain pins and prevent them being used by other devices. Is it possible that this could be the cause of you problems?

Documentation says to use pins 13-10 for SPI connections. This is how I defined the pins: #define BMP_SCK 13 (and the others in the same way), and later initialized the sensor with Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK); which worked fine on the Uno board.

From Arduino.cc - "Arduino communicates with both the W5100 and SD card using the SPI bus (through the ICSP header). This is on digital pins 10, 11, 12, and 13 on the Uno and pins 50, 51, and 52 on the Mega."
I don't know if this applies to you board.

I think you will need to change BMP_CS pin, but not to 4 because that's used by the SD card.

I changed it to 8 and 9, both seems to have the same result

source: Stack Exchange

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

sort: votes


text:
Burn Arduino Bootloader - Atmega8L
I am making an RGB LED project right now using the Arduino UNO board.
At this point everything is working fine so I would like to transfer this onto a small microcontroller circuit to be put inside the enclosure. Since the enclosure is small, I cannot fit the UNO board inside it, hence I want to make a small circuit on perfboard with minimal components.
I read that you can burn the arduino bootloader on a standalone AVR (hooked up to power, filter caps and 16Mhz crystal) which can then execute Arduino code.
Any idea how can I do this? Also can I do this on an ATmega8l AVR, since my code is small enough to fit in one? No point wasting a 328 if 8L can do the job.
Thanks!

If you have the ability to burn the bootloader to a chip then you have the ability to burn the program to it without using the bootloader.

No need for a bootloader. Just upload your program to the ATMega8 using your Uno as an ISP programmer. If you do more projects like this, it would be a good idea to buy a separate programmer like mpflaga is suggesting.

Also, why the '8L instead of the '88PA (or even '48PA)?

@IgnacioVazquez-Abrams 8L because I had several of them lying unused in my parts box. Regarding burning the bootloader, I understand now that the bootloader is only required to do stuff like uploading using USB etc. Has nothing to do with the actual compiled program

The Bootlader
If you want to burn the bootloader to the standalone AVR that you will be using, you can do so using a programmer like the USBasp. Or, you can simply use the Arduino  itself to do this.

Open the ArduinoISP sketch from File > Examples.
Upload it.
Push reset on the Arduino.

Wire it up
Next, wire up the AVR on a breadboard as shown here: Arduino ISP

If you are using a variant/derivative, use a crystal that matches the crystal on your board. You might have not_in_sync() trouble if you don't.
Add a 10uF capacitor between RESET and GROUND on the Arduino, if you are using Uno, or something similar.

Burning the Bootloader
Then select Arduino as ISP as the programmer.

Goto Tools > Programmer.
Select Arduino as ISP.

Now click on Tools > Burn Bootloader.
Verifying it all works
Once that is done, open the Blink LED example and try uploading it to the AVR. You have to use the Upload using Programmer option from File > Upload using Programmer. You can verify if it is successful, by connecting an LED to pin 19 of the AVR, and checking if it blinks.
Notes:

Remember that the pins on an AVR don't map to the corresponding pins on the Arduino, even if they are both the same chips. Search for "AVR to Arduino pin mapping" for your chip on Google. Here's the ATMega8 to Arduino pin mapping.

Don't forget to connect the ground lines of the AVR and the Arduino.

This worked for me using an ATMega8A-PU. It should work with the 8L too.

Post here if you have any problems. Glad to help :)

"First, you have to burn the bootloader to the standalone AVR that you will be using." Incorrect. You do not need the bootloader in order to use ISP, nor do you need it in order to use the Arduino libraries.

Yes, I am aware of that. OP: "I read that you can burn the arduino bootloader on a standalone AVR". I assumed the OP wanted to burn the bootloader. Will re-word the answer. Thanks for pointing it out :)

Thanks guys. I realize now my wording was quite incorrect.

You can program the 8u2 by either using a ISP programmer such as Pocket AVR Programmer or directly over USB using the FLIPS software as documented
In reference to:

"hence I want to make a small circuit on perfboard with minimal
  components"

I would recommend getting Tiny AVR Programmer or alike to program ATtiny's and at use the ATtiny's directly for small specific tasks. Hence you can avoid the cost of the whole UNO if not needed. You can even emulate limited USB connection as done with the DigiSpark. They even support internal oscillator. So they often need now external parts. They can be often applied without PCB.

Maybe coffee needed?

I would add there are several hardware library Add-on's such as https://code.google.com/p/arduino-tiny/ that give the Stock IDE native support for the Tiny's.

The question mentions the ATmega8L.

Problem with Atmega8A-pu
Make sure the correct com port is selected then on the tools menu select Arduino NG or Older as the board type then choose the ATmega8 as the processor from the tools menu and upload any example Program probably i prefer blink to test (courtesy-PARC-India).
All the best

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


text:
Controlling Arduino through Internet and Bluetooth
I have an Arduino sketch that controls an LED through the Internet, and another through Bluetooth. The thing is I want to combine both sketches so that I can control my Arduino LED by Bluetooth as well as through the Internet. Is it possible to do that?

If I were you, I would separate the "hardware" from the "software". This is quite an interesting "pattern". It's used by almost every Operating System, to assure compatibility with devices all around the world.
But how?
Layers
The "OSI-model" typically describes a few layers. But to me, the most interesting part is the difference between "Host layer" and "Media layer".
Media Layer
The media layer(s) typically handle the transportation of your bits, addressing and data collision. In "the internet" you can 'simply' change from copper to glasfiber without it being noticeable in your end application (apart from being faster).
Host layer
The same for the host layers, whatever PC or network adapter you have, your program will run fine (if this abstraction/integration is done well).
Applying this
So how do we apply this? In a basic, small application.

We want our Host to not care too much about which Media(layer) it is using.
The Arduino has to be able to be configured or detect which media layer it is using.
Something like this is neccesary (this is not actual code, more pseudo code):
String messageBuffer = "";

void Setup(){
   setupWifi(pin1,pin2);
   setupBluetooth(pin3,pin4);
}

void Loop(){
   messageBuffer = getWifiMessage();
   handleMessage(messageBuffer);
   messageBuffer = getBluetoothMessage();
   handleMessage(messageBuffer);
}

If you set up this correctly, you'll only have to write the buffer handling code once. Which is very useful!
Handling buffers along with all the logic/effects it will cause, should be solid. You (probably) don't want different behaviour when you use bluetooth as when you use WiFi. Imagine your web-browser only working when you use copper, but not when you use glasfiber :)
Protocol
Your message should be exactly the same for WiFi and bluetooth. This way you won't have to deal with two different protocols and it will be easier to implement this at the other (control) side.
A good protocol/message can be this:
"@12#13,255,255,0;"

I use the @ as an start indication. This is very usefull for receiving, since you know where to start (obviously?).
You'll have to make rules for what will follow (maybe a set amount of characters, in my example, between @ and # it will indicate an "address". When you send it to multiple devices, you only want (in my example) device 12 to react. This often is handled by the bluetooth or wifi already, but it can be good to have some sort of unique header. So that random messages (which might look alike) won't be seen as one of your messages.
An message ID is useful, you kinda want to have different types of messages, for either "LED brightness" or "debug request" or "set output".
Each message could have an x amount of parameters, it's often better to separate these. It's important that you specify the maximal amount of parameters and what behavior they will cause.
Some protocols use a set length, but an end delimiter ";" is often the best way to let the other device know your message is completely received.

Some notes

Try to aim for existing protocols, it will be cool if your device is compatible and creating yet another protocol isn't particularly useful.
Mind that possible transmitted text does not include your start/end delimiters. You could use the message length or exclusions/inclusions in this case.
Be wary that the protocol adds overhead. But usually being able to "read" a message will make it much more easier to program a handler or generally work with it.
Check if the message is fully received and does not have errors. If you have an error, be sure your system can handle it and will respond with a message telling so. In no way your system should lock down on error or not provide a reaction (which makes debugging a pain).

The server
From whatever device you're sending your stuff, it should have bluetooth and/or WiFi. Bluetooth is fairly easy and should get you started quite fast.
If you're using WiFi, you should check if your device can make a TCP/IP connection. TCP/IP is basically a "shell" around your message, to shoot it over the internet ;D it comes with some neat addressing and error checking built in (but you can't be 100% sure there will be no error between your receiver and arduino).
But why?
Not only is it useful to learn how to do this, having to write the handler and protocol specification for both the Wifi and bluetooth (and possible usb, rf, ethernet etc).
Apart from that, in embedded systems, you want to be sure that something works, using different handlers for different physical layers will create vague specific errors and might rip up your program logic. Also, if your protocol/application is used/reviewed by more people, you'll be more certain that it works well.

What if I don't what to use the wifi or Ethernet shield.. ??? I will use directly from USB port.

so that I can control my adruino led by Bluetooth as well as through Internet. Is it possible to do that?. How you mean? Will you use your PC as the "internet receiver" and send it to the Arduino through serial?

It's not trivial to use Wifi or Ethernet without any form of (certified) receiver. The ESP8266 is a cheap 3$ Wi-Fi solution, but you could indeed use your PC as a master.

Yes ..I'm  doing my project.. I didn't bought the Ethernet/wifi shield so I want to show a demo only how we can control from Internet..

Can It be done or not...Bluetooth as well as Internet without wifi shield to control led?

Judging from your reaction, you don't want to use a WiFi/Bluetooth/Ethernet shield
Arduino has no built-in Bluetooth or Ethernet.
The question is shifting a little towards software, but okay.
1. Using your PC as Ethernet/Bluetooth receiver
You can (and I believe you want to) use your PC as the receiver.

Talking in network terms, your phone has to become a "client" and your PC will become a "server".
I would advise using Processing on your PC as a "Server".
Within processing you can easily set up a connection to your Arduino.
And even use your PC's bluetooth or you might just set up a "bluetooth COM port" which makes your Bluetooth device look like a serial device like the Arduino.
There is a little catch though. Processing can easily set up a TCP/IP connection. On your phone this might be a little less trivial. Your browser generally uses HTTP(s) to connect.
So you should either implement HTTP in Processing or make/use an app that supports TCP/IP message sending.

Okay..I want to use Bluetooth which I can control using an Android app. And also the same led which I controled using Android I even want to control through Internet i.e. serial communication

You use MIT App Inventor (http://appinventor.mit.edu/explore/ or alternatively http://www.appinventor.org/), create your own app and after that you can access all the results of Arduino on your smartphone.


text:
uBlox Neo 6M GPS module not responding
I started recently working with a uBlox Neo 6M GPS module (data sheet http://www.u-blox.com/images/downloads/Product_Docs/NEO-6_DataSheet_%28GPS.G6-HW-09005%29.pdf). I connected it to an Arduino Uno as shown:
GPS  Arduino
VCC-- 3.3V
RX -- D11
TX -- D10
GND-- GND
I tried this example code from TinyGps++ (of course, changing the pins and the gpsbaud to 9600, which is the gps' default).
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
/*
   This sample sketch demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/
static const int RXPin = 10, TXPin = 11;
static const uint32_t GPSBaud = 9600;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

void setup() {
  Serial.begin(115200);
  ss.begin(GPSBaud);
  Serial.println(F("DeviceExample.ino"));
  Serial.println(F("A simple demonstration of TinyGPS++ with an attached GPS module"));
  Serial.print(F("Testing TinyGPS++ library v. ")); Serial.println(TinyGPSPlus::libraryVersion());
  Serial.println(F("by Mikal Hart"));
  Serial.println();
}

void loop() {
  // This sketch displays information every time a new sentence is correctly encoded.
  while (ss.available() > 0)
    if (gps.encode(ss.read()))
      displayInfo();
  if (millis() > 5000 && gps.charsProcessed() < 10) {
    Serial.println(F("No GPS detected: check wiring."));
    while(true);
  }
}

void displayInfo() {
  Serial.print(F("Location: "));
  if (gps.location.isValid()) {
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(","));
    Serial.print(gps.location.lng(), 6);
  } else {
    Serial.print(F("INVALID"));
  }

  Serial.print(F("  Date/Time: "));
  if (gps.date.isValid()) {
    Serial.print(gps.date.month());
    Serial.print(F("/"));
    Serial.print(gps.date.day());
    Serial.print(F("/"));
    Serial.print(gps.date.year());
  } else {
    Serial.print(F("INVALID"));
  }

  Serial.print(F(" "));
  if (gps.time.isValid()) {
    if (gps.time.hour() < 10) Serial.print(F("0"));
    Serial.print(gps.time.hour());
    Serial.print(F(":"));
    if (gps.time.minute() < 10) Serial.print(F("0"));
    Serial.print(gps.time.minute());
    Serial.print(F(":"));
    if (gps.time.second() < 10) Serial.print(F("0"));
    Serial.print(gps.time.second());
    Serial.print(F("."));
    if (gps.time.centisecond() < 10) Serial.print(F("0"));
    Serial.print(gps.time.centisecond());
  } else {
    Serial.print(F("INVALID"));
  }
  Serial.println();
}

However, I do not get the GPS LED to blink, as well as my Arduino's RX LED, so the module is not transmitting any data. This is the output from the code:
A simple demonstration of TinyGPS++ with an attached GPS module
    Testing TinyGPS++ library v. 0.92
    by Mikal Hart

    Location: INVALID  Date/Time: 0/0/2000 00:00:00.00
    Location: INVALID  Date/Time: 0/0/2000 00:00:00.00

Thanks!

Where did you get the gps from? Its possible the one you got was configured to use the uBlox binary protocol as default instead on NMEA

Another comment: I spent a while working with some of the u-blox LEA-6T gps modules, and they were REALLY intolerant of baud-rate mismatches, to the point where it wouldn't talk to my device speaking 115200 baud even through the baud rate was only ~2% off. I wound up specifically choosing a baud-rate that worked well with the local oscillator I had. I don't know if the NEO-6M modules are similar, but it could be a possibility.

The Neo 6M takes a bit of time to fix when first powered on. If your board is fitted with a small battery it will most probably be flat and will take an hour or two to charge up. It is there to provide charge to the EEPROM and the onboard RTC.
Also check that the leads on the battery are not shorting.
You do not get a valid data sentence out of the GPS until the RTC can sync time.
The Error message that you got from Mike Hart routine first says that there is not enough data to do a FIX and second the Date Time is not syncing.

I thought my GPS was faulty. Thank God I saw your answer and let my module stay ON for an hour... And guess what... It worked perfectly... The on board LED started blinking

After 2 days of troubleshooting I found the solution

Use 3.3 volt external supply
Use voltage dividers to make 3.3 volt compatible to module
go outside(open space)

That's it

1) Try outside or near the window.
because the signal may not reach inside a house.
2)Check the connection.
3) Print the number of satellites connection to know the device is connectied by
Serial.println(gps.satellites.value());

Good luck!!!

Try to connect your GPS module with an FTDI cable directly to the Serial-Port of your computer (and read it with screen or any other terminal program). Once that works, proceed with the Arduino.
And check what your GPS-module not blinking does mean. Usually it says there is no 'fix', which means it does not see enough satellites. The output you showed would fit into that theory. Which would mean everything is ok, except your module is not seeing the sky...

Thanks! There was no actual problem, it was just that I was in a close space and had no patience ;)

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


text:
NodeMCU Ping working on one but not another
Update 2:
Have tested by pinging various devices on different subnets / vlans
and did a pcap on the wifi AP
I can see the icmp requests going through for each request except for ones on the 4.x subnet, almost like the arduino doesnt like that IP address and refuses to send those packets?
Update 1:
Have tested the following
Turned on logging on firewall and noticed the following actions:

Ping router from Arduino - See logs in firewall, arduino gets response. (Red line)
Send external web request from arduino - See logs in firewall, arduino gets response. (Orange Line)
Send web request to internal server - Arduino queries internal DNS and gets IP of web server, but no request send (Nothing in firewall logs) (Yellow and Blue)
Send ping to internal server - Arduino queries same dns server, gets ip, but no request sent (Firewall logs again) (Yellow and Green)

however, sending the ping and web request from desktop, shows both the firewall log blocking the ping request, and the rule allowing the web request.(Brown Purple Pink)
Have attached diagram again to help visualize whats going onAnd can attach router logs or rules if required
https://imgur.com/a/g4TipmZ
Also have set a windows PC with the same IP address, and can ping the web server, so I know it's something wrong with the arduino's requests to the web server in particular, and not the firewall?
End Update
I have two Node MCUs which I'm using for a project.
A while ago they were working fine, but i recently changed some network settings on my home network and found that it broke the script I had running on them.
I finally figured out where it went wrong and fixed it, but now I have another interesting problem.
One of my nodes runs this script fine, where as the other gets stuck on the ping stage.
I have uploaded the same script to both nodes and swapped over the IP address assigned and it follows the device not the IP.
So I know its not a networking issue.
I know the WiFi is working on the funny node, as it gets a IP address.
but it doesn't go any further
Any ideas?
Script attached below:
    #include <DHT.h>
    #include <ESP8266WiFi.h>
    #include <ESP8266HTTPClient.h>
    #include <ESP8266Ping.h>

    // WiFi credentials.
    const char* WIFI_SSID = "SSID";
    const char* WIFI_PASS = "******";
    WiFiClientSecure wifiClient;
    bool connection = false;
    WiFiClient client;
    const char* dbServer = "webaddress";

    void setup() {
      //Open Serial
      Serial.begin(9600);
      Serial.setTimeout(2000);

    //Connect to Wifi
      bool pingtest = false;
      Serial.print("Connecting to WiFi");
      WiFi.begin(WIFI_SSID, WIFI_PASS);
      //Wait for connection
      int wificount = 0;
      while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
      }
      if (WiFi.status() == WL_CONNECTED) {
        connection = true;
        Serial.println("WiFi connected");
        Serial.println("IP address: ");
        Serial.println(WiFi.localIP());
        while(!pingtest){
          Serial.println("Pinging Server");
          if(Ping.ping(dbServer) == true){
            pingtest = true;
          }else{
            Serial.print(".");
            delay(1000);
          }
        }
      }

    }

void loop() {
  Serial.println("Hello");
  delay(2000);
}

Update (Cross posted from another forum):
I have an Arduino which pings a server on a different VLAN / subnet as part of its code.
It was working a while ago, but I changed some settings on my firewall to restrict stuff down, and that broke the Arduino code.
I found it was because I was blocking ICMP across VLANs.
So I created a rule to allow ping requests between the two VLANs
tested on my desktop (on same net as Arduino) and works fine.
Went to test on Arduino and wasn't getting any response.
So I put the router IP in and tested it on the Arduino, works fine. I can even ping the Arduino from my desktop, and ping my desktop from the Arduino
So I figured I must have some other firewall rule allowing my desktop to have special access. (not that I could find it)
so gave the arduino the same Ip address and no luck, yet can still ping the router
I have attached a crude drawing here. Hopefully it helps to visualize my problem.

try to erase the flash memory with esptool to clear old RF settings, then upload the sketch and wait a couple of minutes until RF settings calibrate

That didn't work
Erased the flash on both devices and now they are both failing to ping, or to do my web request later in the code.

ok, not sure if its a routing issue or a arduino issue as im getting some odd test results.
Will update original posting with new findings

did you let it time to calibrate the RF part?

Yes, have updated the original posting with more information

If a ping doesn't work over a routed connection it could be.

Default gateway on the Arduino device, add a Serial.println(WiFi.gatewayIP().toString()); to print the default gateway.
DNS issue, I presume that the const char* dbServer = "webaddress"; indicate a FQDN.
Firewall is blocking the ICMP on either the inbound or outbound path.

Have done alot of testing on another forum, and have come to the conclusion its the arduino not wanting to send requests to a very specific IP range.
For testing I have the following setup
Desktop PC: 192.168.1.100, arduino 192.168.1.222 (Vlan 10)
Server 1: 192.168.99.40 (Vlan 99)
Server 2: 192.168.4.200 (Vlan 40)
I can ping both servers fine from my desktop pc.
I can ping google, the router, and server 1 from the arduino, but not server 2.
I did a packet capture on the WiFi access point, and can see the ICMP packets for the other pings going though, but not when pinging server 2

I have also set a laptop to have the same IP address as the arduino (After turning the arduino off to avoid conflicts) and the ping goes though fine.
I have also confirmed that the gateway ip and netmask are set correctly on the arduino.
and I have removed any domains from the scripts for testing, using just IP addresses to try remove DNS issues

Add a sniffer to vlan 10 and have a look at whet the Arduino is sending. And check what the firewall log is saying/blocking.

Not to come across as rude.
Just I have already mentioned this twice. Did a pcap on the wifi AP and dont see any requests from the arduino when pinging the 4.x range, but i do with the other ping requests. And the firewall shows the same, logs for all my ping tests except 4.x range

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


text:
Will this buck converter power my arduino?
I'm thinking of using something like this: https://www.amazon.ca/Dolity-Converter-Isolated-Switching-Transformer/dp/B07CSZ1174?SubscriptionId=AKIAILSHYYTFIVPWUY6Q&tag=duc12-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B07CSZ1174
or this: https://www.amazon.ca/Voltage-Regulator-Converter-Transformer-Protection/dp/B07LC1C4ZZ?SubscriptionId=AKIAILSHYYTFIVPWUY6Q&tag=duc12-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B07LC1C4ZZ
to power my arduino.
The reason for this is I have a contained box with a few pieces of equipment (all on ac power) controlled by an Uno. There is a single AC power cord (North American) running from the box to power the whole unit. Obviously this just leaves the Uno.
Sure the standard 5V barrel adapter prongs could be shrink wrapped to the raw AC wires but that's not very clean. I was imagining a module like those converters that could be wired into the VIN pin and gnd after converting the AC input from the main power line going to the box.
The uno is powering an ethernet shield, 4 port relay, sht20 sensor, mh-z16 sensor, and 16x2 lcd display.
Thoughts? Honestly this isn't really my call. My boss doesn't want any plugs or standard outlets inside the box. It's like he only wants it to be formal circuit boards and soldering. No shrink wrap or electrical tape. Yes I realize standard adapters that plug into a wall are already at a price that won't be possible to beat.

I highly aggree with @Majenko. Any old USB phone charger would make a safer and also cheaper power source for your Arduino.

Sure the standard 5V barrel adapter prongs could be shrink wrapped to the raw AC wires but that's not very clean.

Also very deadly.  DO NOT DO THIS!!!!  The Arduino will explode (literally. I am NOT joking here!!!) and potentially electrocute you.

Those modules you show are not "buck" regulators. They are SMPS modules - an entirely different thing.
Yes, one of those would be suitable for powering an Arduino from a mains supply, but given your supposition above I rather suspect your skills and knowledge would make wiring it up a dangerous prospect.
Better would be to use a proper off-the-shelf power plug and have someone qualified install a suitable socket inside the enclosure.


text:
How can a function/method determine if a const array passed in is PROGMEM (flash) or not (RAM)?
Is it possible for a function/method to know if a constant array that has been passed in is in flash or RAM?
If I have a method or function that receives a constant array that is in RAM, the array is declared like this:  const uint8_t MY_ARRAY[] = { 1, 2, 3, 4 };
gets passed into a method or function like this:  MyFunction(MY_ARRAY);
and the method or function can handle it like this:
void MyFunction(const uint8_t *MY_ARRAY) {
     uint8_t secondElement = MY_ARRAY[1];
     ...

However, if the array is in Flash (because it's a constant array, so that's where it should go), then the declaration adds PROGMEM:   const uint8_t PROGMEM MY_ARRAY[] = { 1, 2, 3, 4 };
The pass looks the same:  MyFunction(MY_ARRAY);
And the function declaration looks the same but it needs to use pgm_read_byte_near to get the correct values back:
void MyFunction(const uint8_t *MY_ARRAY) {
     uint8_t secondElement = pgm_read_byte_near(MY_ARRAY+1);
     ...

How can the receiving method know if the array is in flash (PROGMEM) or RAM (no PROGMEM) so it knows to use pgm_read_byte_near or not?  Ideally I'd like a compiler error, but the type is the same (both are const arrays of uint8_t).
If pgm_read_byte_near is used when it shouldn't be, or it's not used when it should be, the results are garbage.
Some relevant questions:
How to pass a static const (progmem) array to a function
RAM usage question: PROGMEM vs const vs #define
Storing array in PROGMEM
PROGMEM: do I have to copy data from flash to RAM for reading?
UPDATE:
It looks like what I want to do is not possible.  The responses below are very interesting options though:  using __flash in plain C, using OOP to make PROGMEM and non-PROGMEM data holders or trying to (somehow?) use non-deprecated progmem specific data types from avr/gpmspace.h.
The best answer to my original question is that the method can not make this determination.  The best solution, from a comment by Delta_G, is to create regular (ram) and "_P" (flash/ progmem) versions of the functions and to be as obvious as possible in the naming of those functions.

You can use the same trick as the Arduino classes are using. class __FlashStringHelper; #define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal))) and function overloading

@KIIV That sounds very promising.  Can you show me what the function declaration would look like or give some references on how to do that?

Go look at the Print class in the Arduino core.

void someFunction(const __FlashStringHelper *str); and call it like   someFunction(F("soometning"));

But the input is an array of uint8_t not a string.  Does it still work?

Not exactly, but if you go look at the Arduino core at how that whole thing works it is possible to do something similar.  You can do that or you can have two different functions.  But you can't make it where the user doesn't have to know the difference.  They'll either have to declare their data with your specific data type that you create for your overload, or they'll have to cast to it, or they'll have to know to call a different function.  You can't take that decision off of them either way.

You would have to create your own dummy class, analogous to __FlashStringHelper, for each type that you want to store in flash. Not very convenient to say the least...

Or, you can use arduino based on Atmega4809 as there is flash address space mapped into memory address space with 0x4000 start offset (and compiler takes care about it if it's const variable)

After digging through WString.h and pgmspace.h, this looks beyond my c++ chops.  It also would seem to force the caller to use an F() type macro, which if I can be sure they will do that, then I can be sure it will use PROGMEM.  I guess I can add some notation, likely including the word "PROGMEM" in the function name as well as in the input name for the flash const array and just hope all callers remember the PROGMEM contract.

That's what you end up having to do.  You release with two versions of the code and a note that if the user wants to use PROGMEM they can but they have to call the _P version of the function or however you name it differently.  Often that's easier than trying to have it both ways because it reminds the user right in the name of the function and that sort of forces them back to the docs to see how it needs to be set up.

@Delta_G  Thanks.  I've messed up the using or not using the pgm thing enough times that I was hoping there was a way to solve it once and for all (anticipating that I'll do it again).  Oh well, more hardware testing.  If you write that up as a solution I can accept it.

everything in this question, comments and answers assumes classic AVR. it is different for esp8266 and the Arduino megaavr boards package

@KIIV Please do not answer questions in a comment. See How do comments work?. They are not for answering a question.

@Delta_G You too. This isn't a forum. The whole idea here is that you make an actual answer. Then people can vote on it and it can be accepted. Bonus feature - you get reputation from this. Not from answering in comments.

And you other guys.

I am afraid there is no good solution to this problem. One option I do
like is to use the __flash qualifier instead of PROGMEM:
const uint8_t ram_array[] = { 1, 2, 3, 4 };
__flash const uint8_t flash_array[] = { 5, 6, 7, 8 };

void function_reading_ram(const uint8_t *array)
{
    uint8_t secondElement = array[1];
    // ...
}

void function_reading_flash(__flash const uint8_t *array)
{
    uint8_t secondElement = array[1];
    // ...
}

int main(void)
{
    function_reading_ram(ram_array);      // OK
    function_reading_flash(flash_array);  // OK
    function_reading_ram(flash_array);    // Warning
    function_reading_flash(ram_array);    // Warning
}

Note that, with __flash, you don't need pgm_read_byte_near() or
anything similar. You just use the array like you would use any regular
array, and the compiler is smart enough to generate the code required to
access the Flash memory.
The warnings generated by gcc are:
warning: conversion from address space ‘__flash’ to address space ‘generic’ [-Waddr-space-convert]
     function_reading_ram(flash_array);
     ^
warning: conversion from address space ‘generic’ to address space ‘__flash’ [-Waddr-space-convert]
     function_reading_flash(ram_array);
     ^

Given how nice this solution is, you may wonder why I wrote “there is no
good solution”. Well, this comes with two caveats, one small and one
huge. The small caveat is that you need to explicitly pass the option
-Waddr-space-convert to the compiler if you want it to generate the warnings.
It is not implied even with
-Wall -Wextra. The huge caveat is that this only works in plain C.
If you try to use this trick in C++ you get:
error: ‘__flash’ does not name a type

This is an implementation of the “named address spaces” extension to the
standard C. Since nothing like this is standardized in C++, the authors
of gcc assumed it would not be useful to users of C++. :-( You can mix C
and C++ sources in Arduino, but you can't call class methods from C.

That's good to know.  I've not heard of _flash before.  However, I've got classes on my classes, so I'm stuck with C++ on this one.

There is also an OO solution possible, using the strategy design pattern, but this comes with some (slight) memory and performance penalties. You need to use C++ for this.

Put each array you want to differ between flash/SRAM in a separate class (one per type). You get data hiding and possible separation of concerns for free.
Instead of putting the array in each class, put a reference/pointer or use it directly.
You can use inheritance:

Create a Flash Array class with a SRAM array reader/writer
Create an SRAM Array class with a Flash array reader/writer
Inherit each of the array types you use from one of these classes where the base class takes care of reading/writing.

Alternative solution: use the strategy pattern; involves a bit more work, but you can prevent multiple inheritance (although since you use C now, you don't use inheritance (yet)). This would involve roughly:

Create a Flash and SRAM Array class reader as above.
Instead of inheritance, create a pointer to one of these classes which suits the type of the array.

Although I can imagine this will mean quite some changes in your sketch.
Explanation using Inheritance
(requested by comment)
@Casey I assume you mean the Inheritance way. Assume in a class you have x_array which is of type FlashArray. You just call x_array.Read(...). This method is implemented in FlashArray, but also with the same parameters in RamArray. You can enforce this by inheriting both FlashArray and RamArray by a base class (e.g. ArduinoArray and create a (pure) virtual function Read with the same arguments. Anyway, the implementation of Read method in FlashArray should read from Flash and the same method in RamArray should read from RAM.
When you change the type of x_array from FlashArray to RamArray or vice versa, you don't need to change anything (except the types). To make this easier consider defining a type for x_array, so when you later need to change it, you only need to do this in one location.

The advantage of two separate classes is that you can make a per-class policy on data accesses, e.g. "for this class, I would like to copy the data into the current stack frame before working with it". Given the typically small scope of Arduino programs, the code duplication is probably still more readable than a template monster that tries to avoid it. Typical data classes I work with have a "from-flash" constructor, where they copy all the members out of a struct with no methods, and the compiler optimizes out the copies for the members that go unused.

@SimonRichter Thanks for the additional comment. I almost never program beforehand on performance, unless I know it will be an issue. As you say, nowadays compilers optimizes a lot.

Yes, that's the beauty of it: I can change the performance characteristics later on by changing the communication between the "in-flash" and "in-ram" classes, without changing the users of these classes.

@SimonRichter you could even change it dynamically, during execution of the sketch).

I think I see how this would work, but one of my goals here is to make the handling method be able to deal with either without relying on the author of the caller to do anything special.  My fear is the wrong array type (flash or ram) gets send to a routine and the reader uses the wrong method and produces garbage as a result.  Your OO option seems to force a bunch more on the caller side.  Do I have this right?

@Casey I added an example in my answer.

Or you could have a single class and overload the read() method.

@EdgarBonet That's also possible, although I rather like a neater split as ArduinoArray is more suitable as an abstract base class. But indeed, both ways are possible.

The classic avr-gcc way is to have dedicated functions with different names
e.g. void* memcpy(void* dest, const void* src, size_t n);  // Only works if src is RAM
vs. void* memcpy_P(void *dest, PGM_VOID_P src, size_t n); // Only works if src is PROGMEM
BTW: That's mentioned in a comment to the question already by @Delta_G. More about the example memcpy_P here

PGM_VOID_P looks very similar to what I'm after.  Can I just use that to enforce that the pointer (well, array really) is in PROGMEM?  Or, do I need a different version of it that is for uint8_t arrays?

I tried replacing my "const uint8_t *" declaration with "PGM_VOID_P" but that doesn't work because they are different types.  avr/pgmspace.h has a bunch of PROGMEM data types, such as prog_uint8_t, but they have all been deprecated.  pgmspace.h recommends using the attribute during declaration.  So, it looks like what I want to do use to be possible, but isn't any longer.


text:
ESP8266 WiFiClient Slow Over LocalHost
Appears to be something to with Apache configuration, swapping to Nginx solved my issue.
I'm getting slow responses when using localhost with a NODEMCU 1.0 and esp8266 WiFi library.
If I GET a PHP file on a remote server the response is almost instantaneous and the output of the PHP file is printed extremely quickly after the HTTP headers. If I GET the same PHP file on localhost the response takes over 5 seconds even if that PHP files is echoing just a single character.
I've tried with XAMPP and a local server configuration on a Raspberry Pi but both have the same slow response speed.
void loop() {
  WiFiClient client;

  if (wiegand.available()) {
    // Convert the code into a suitable type and construct the GET request
    double readWiegand = wiegand.getCode();
    String readWiegandStr = String(readWiegand, 0);
    String httpGet = "GET /verify.php?code=" + readWiegandStr;

    Serial.printf("\n[Connecting to %s ... ", host);

    if (client.connect(host, 80)) {
      Serial.println("connected]");
      Serial.println("[Sending a request]");
      client.print(httpGet + " HTTP/1.1\r\n" +
                   "Host: " + host + "\r\n" +
                   "Connection: close\r\n" +
                   "\r\n"
                  );
    }

    Serial.println("[Response:]");

    while(client.connected() || client.available()) {
      if(client.available()) {
        String line = client.readStringUntil('\n');
        Serial.println(line);
        if(line == "ACCEPT") {
          Serial.println("Code accepted");
        } else if (line == "DECLINE") {
          Serial.println("Code declined");
        }
      }
    }
    client.stop();
    Serial.println("\n[Disconnected]");
  }

seems the issue is with the server if two different servers behave differently - perhaps your local server (not localhost, as that actually means something else) isn't closing the connection after sending the response

Thanks for the response, any ideas how I'd go about checking this?

check the local server is closing the connection in a timely manner - without knowing anything at all about your local server, the best I can do is suggest you "fix it" :p

I 'fixed it' by uninstalling Apache and installing Nginx, instant response with Nginx, thank you for the suggestions.

So much can be fixed by removing Apache :p


text:
Adafruit RGB LCD w/ Shield kit connection to arduino uno?
I have a adafruit rbg 16x2 lcd with shield kit and am trying to connect it to an arduino uno. The only thing is the assembly instructions have the lcd basically using every pin on the arduino, even tho it says its not for connections. Since we are using many of the pins already on the board, can I wire it to the board without soldering it to every pin, essentially only wiring to the few necessary pins?
Sorry, I am very new at this. Thank you for the help.
EDIT: Was essentially looking for the follwing diagram. Thanks to all!

Every pin, that is not electrically used by the shield can be used for other purposes. It is not clear, what is preventing you from doing so? Is it just, that the shield blocks all the other pins (without using them)?

The idea of shields is that they (in theory) can be stackable.
(In practice they are usually not)
This means that technically you can do this:

That's why by design every shield connects to every Arduino pin but uses only some of them. That way shield is mechanically well attached to the Arduino, and can pass "unused" pins to the shield above it.
Your shield is designed to be always "on top" so I think it only connects to some pins just for mechanical support. Technically the LDC screen needs only 6 pins and 1 pin per button.
EDIT:
I read now that the shield you got uses only 2 pins and communicates using I2C bus (which is perfect) so I'm 100% sure that it's designed to be on top of the stack and work together with other shields and uses extra pins for mechanical support.


text:
why sound appears between VCC and GND pins in esp8266 module?
When I use esp8266 as STATION mode and connect a speaker between VCC(3.3v) and GND pin a sound appears like "doop doop". what is this sound?
I test this in version 01 and 12 of esp8266 module and this appear in both versions.
maybe you ask me why I connect speaker to this pins. problem is that when I use pwm of esp8266 for playing a sound, this sound ("doop doop") appear to it also.
What is problem? How can I fix this?

sounds like your power supply is weak. it might also have trouble driving an 8-ohm load (400+ma) plus the MCU. more capacitors would help as well.

Maybe the ESP resetting? It is really not a good idea, to connect a speaker like this.

No .I use different power supply and different battery. I use high pass and low pass filter but it does not fix yet. Also I use capacitor between VCC and GND. I'm wondered now.

If reset occurred LED must be on in a moment. I'm sure reset does not occur

It's called "noise" and is to be expected. Wi-Fi devices are generally very electrically noisy - and the ESP8266 is no exception.

I think noise sound is irregular but this sound is regular and periodic.

As regular and periodic as the transmission of packets over WiFi?

No. when I set esp8266 as station mode, without any connection and sending and receiving packet this problem occur

Just because you aren't sending packets doesn't mean packets aren't being sent. Wi-Fi is complex. There's constant chatter between stations and the AP.

It's true. your mean is packets send in environment such as mac address or Host name?

And others. Key exchange, etc. Lots of things happening. And it all needs lots of current - and that makes noise on the power.

it's not a way for removing this noise from power? I see some project with Node MCU that playing stream audio without this noise. should I use additional hardware?

You can't "get rid" of the noise. You just have to block it from going where you don't want. Filters, capacitors, inductors, etc. They all help.

https://majenko.co.uk/blog/filtering-wifi-noise

thank you so much.


text:
Changing Baud Rate not working
I have copied this code from Github :
 #include <Wire.h>
 #include <MPU6050.h>

MPU6050 mpu;

// Timers
unsigned long timer = 0;
float timeStep = 0.01;

// Pitch, Roll and Yaw values
float pitch = 0;
float roll = 0;
float yaw = 0;

void setup()
{
    Serial.begin(115200);
    //Serial.begin(9600);

    // Initialize MPU6050
    while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))
    {
         //Serial.println("Could not find a valid MPU6050 sensor, check
               wiring!");
     }

     // Calibrate gyroscope. The calibration must be at rest.
     // If you don't want calibrate, comment this line.
    //mpu.calibrateGyro();

     // Set threshold sensivty. Default 3.
     // If you don't want use threshold, comment this line or set 0.
      mpu.setThreshold(1);
   }

   void loop()
      {
       timer = millis();

      // Read normalized values
     Vector norm = mpu.readNormalizeGyro();

     // Calculate Pitch, Roll and Yaw
      pitch = pitch + norm.YAxis * timeStep;
       roll = roll + norm.XAxis * timeStep;
       yaw = yaw + norm.ZAxis * timeStep;

         // Output raw
      //Serial.print(" Pitch = ");
         Serial.print(pitch);
           Serial.print(":");
        //Serial.print(" Roll = ");
     Serial.print(roll);
        Serial.print(":");
       //Serial.print(" Yaw = ");
        Serial.println(yaw);

           // Wait to full timeStep period
      delay((timeStep*1000) - (millis() - timer));
     }

Now the question is, whenever I try to change the baud rate Serial Monitor becomes empty.
How can this be resolved?
Some screen-shots :

Stuck!!!

where do you change the baud rate?

I changed, but nothing happened so I commented that line

please see there is a line //Serial.begin(9600);

And did you also change the baud rate in the serial monitor?

Yes, I have added screenshots ...

You are not very much clear but these are the possible reasons for your problem.

You are using a while loop in your setup() function in your code. Your code might get stuck in there that's why you are not able to see pitch and roll. Try removing comment from the Serial.begin function over there.
After Changing baudrate in your code please make sure you are changing it on your serial monitor as well.

I have changed the  baud rate both in code & serial monitor. After printing 6/7 values it gets stuck. I have no idea whats going on   :'(

I also added a Serial.println("ok") at the last line of Setup that worked.

can you provide screenshot of your serial monitor.

I have added screenshots, please see

last thing that i understand that can make issue is that delay function in the end, try setting some default value in that like 5 or 10 then check if window still stucks

I tried that too, but didn't working with 115200 baud rate

maybe it's because of the library

i think so as i tried your code with mpu part commented and code works well. Try this library example

Thanks, I was trying to move and rotate an object in Unity using Arduino as input . Now I have this , rotation is perfect but, position isn't . Maybe you can help me with that.


text:
Serial.println printing just after the previous string in same line
I wrote serial.println in my code but the string was printed in same line on serial moniter.
#include <WiFi.h>//for connecting esp32 to a wifi

#include <TinyGPS++.h>//to obtain gps data from neo-6m gps module

#define WIFI_SSID "Airtel_pawa_4182"//wifi name in simple words
#define WIFI_PWD "Ahuja6230"//wifi password

TinyGPSPlus GPS;//creating a gps object from tinygps++ library

void setup() {
 Serial.begin(9600);
  //wifi setup{
  WiFi.begin(WIFI_SSID, WIFI_PWD);
  Serial.println("connecting to wifi");
  while(WiFi.status() != WL_CONNECTED){
   Serial.println(".");
   delay(1000);
  }
  Serial.println("Successfully connected to ");
  Serial.print(WIFI_SSID);
  //}

  //gps setup{
  Serial2.begin(9600);
  delay(1000);
  Serial.println("ESP32-GPS Tracker");
  Serial.println("Initializing...");
  //}
}

void loop() {
}

In this code the string "esp32-gps tracker" is printing just after the previous string in same line on serial moniter.
I tried running code again and again but it didn't work...
I am using esp32 board(just a detail)
What do i do?

You need to be way more specific for your question to be answerable. Same line? Same as what? Please, post a minimal testable sketch showing the issue, tell us what you expected as an output, and tell us what the actual output was.

@EdgarBonet done

The previous print statements are these:
  Serial.println("Successfully connected to ");
  Serial.print(WIFI_SSID);

The SSID won't be terminated by a newline. Perhaps you meant:
  Serial.print("Successfully connected to ");
  Serial.println(WIFI_SSID);

?

To follow on from previous answer, your solution is to either:

change the previous Serial.print() to a Serial.println() so that that text is followed by a line end, or
add a \n to the front of the line you are having the problem with, so it starts with a new line, to make up for the "missing" new line in the previous Serial.print().

For consistency with what Serial.println() does, you should add "\r\n", not only '\n'. If you ever use a terminal emulator instead of the Arduino serial monitor, a bare '\n' will likely move the cursor one line down while staying on the same column.

Depends on your operating system. In Linux a newline advances to the start of a new line. On Windows YMMV. It's very common in Linux code to use \n for a newline when outputting and not \r\n, which may in fact put some weird character (the carriage-return character) in your terminal window.

@NickGammon: On a Linux terminal, a \n alone is a vertical-only cursor movement. When a program outputs \n, the tty driver converts it to \r\n before it reaches the terminal. This should become clear if you try to use a terminal with this output post-processing disabled (stty -opost). A serial communication program like picocom, by default, disables all tty driver processing: the bytes from the Arduino reach the terminal unaltered. This plays well with Serial.println(), as it ends the line with \r\n.

When sending text through a serial line, it is customary to
terminate each line with some sort of end-of-line marker: you print
some text, and immediately after it the EOL to signify that “this is
now a complete line”. Accordingly, the Serial.println() method prints
the requested text, immediately followed by the EOL marker (in this
case, CR+LF).
From your question, you seem to be thinking that the EOL immediately
precedes the text. This is not the case.
See JRobert's answer for the correct way to build a line from multiple
print statements: println() should be use on the last piece, not on
the first one.

Yes. Nice explanation. Now I know where I mistook. I thought that by using "print.ln()", the string will be printed in new line(I got this info from google). But it isn't like that print.ln is for terminating a line and starting a new line

Jrobert's comment was the first one to mark my mistake so I declared it as answer. But I also thank you for the explanation

@YugAhuja println not print.ln you need to be very specific when coding.


text:
How to send data from PC to arduino?
How can I read data in Arduino IDE from a text file, if I have a text file which has the angle of arm at the different time intervals? If I want to read a text file from PC, can anyone please show the demonstration code as well? I am attaching a code where I am writing a position to servo1 whose values I want to give via text file.
#include <Servo.h>

Servo myservo1 ;
int pos1 = 0;

void setup() {
  myservo1.attach(4);   //inner
}

void loop() {
   myservo1.write(pos1); // pos1 I will give different angles via text file
}

If I am not using SD card module, how can I do this with PC only? Someone please help.

Can you show us the code you have written so far? Are you using an SD card reader module? Perhaps processing could be used to communicate between the PC and Arduino? Please update your question with more information.

I edited accordingly with the code, now someone reply, please.

Use python to read the text file and send it to the arduino via serial. Use the serial library for python and Serial on the arduino side.

your code has nothing to do with the problem ... you need to realize that the data transfer between a PC and the Arduino is totally separate from the servo control ... what you do with the received data is irrelevant ... at this point you need to solve the data transfer problem

I assume you want to store multiple values in the text file, and then
have the Arduino IDE (not the Arduino itself) read the file and insert
the data into your sketch. If this is really what your question is
about, a quick and dirty solution would be as follows:

Format the text file as a list of comma-separated numbers, either in
one or several lines. For example:

1, 12, 23, 34, 45, 56, 67,
78, 89, 100

Include this file in your sketch as the body of an array initializer:

#include <Servo.h>

const int positions[] = {
#include "full_path_of_the_file_holding_the_positions"
};
#define positions_length (sizeof positions / sizeof positions[0])

Servo myservo1;

void setup() {
    myservo1.attach(4);
}

void loop() {
    for (int i = 0; i < positions_length; i++) {
        myservo1.write(positions[i]);
        delay(200);
    }
}

This helped me somewhat, thanks. Now I have a lot of variables and data that I will be sending to arduino IDE, Is there any size limit that Arduino accepts. I have a very big set of data for SERVO control.

@ShivamGoswami: Each board has a fixed amount of available flash and RAM memory. If you have lots of constant data, PROGMEM should help: do a Web search for that term.


text:
How to initialize digital output pin as low on arduino board??? I am getting lights on initially and i want lights off
/*
Please note as I have used the android app you told , the string inputs are taken as
A,B,C,D,E,F,G and a,b,c,d,e,f,g.
I have also written code for voice on and off which has all on and all off function
but since the android app we are using dosent have such key so i didnt took them
*/

String inputs;
#define relay1 2 //Connect relay1 to pin 9
#define relay2 3 //Connect relay2 to pin 8
#define relay3 4 //Connect relay3 to pin 7
#define relay4 5 //Connect relay4 to pin 6
#define relay5 6 //Connect relay5 to pin 5
#define relay6 7 //Connect relay6 to pin 4
#define relay7 8 //Connect relay7 to pin 3
#define relay8 9 //Connect relay8 to pin 2

void setup()
{
    Serial.begin(9600); //Set rate for communicating with phone
    pinMode(relay1, OUTPUT); //Set relay1 as an output
    pinMode(relay2, OUTPUT); //Set relay2 as an output
    pinMode(relay3, OUTPUT); //Set relay1 as an output
    pinMode(relay4, OUTPUT); //Set relay2 as an output
    pinMode(relay5, OUTPUT); //Set relay1 as an output
    pinMode(relay6, OUTPUT); //Set relay2 as an output
    pinMode(relay7, OUTPUT); //Set relay1 as an output
    pinMode(relay8, OUTPUT); //Set relay2 as an output
    digitalWrite(relay1, LOW); //Switch relay1 off
    digitalWrite(relay2, LOW); //Swtich relay2 off
    digitalWrite(relay3, LOW); //Switch relay1 off
    digitalWrite(relay4, LOW); //Swtich relay2 off
    digitalWrite(relay5, LOW); //Switch relay1 off
    digitalWrite(relay6, LOW); //Swtich relay2 off
    digitalWrite(relay7, LOW); //Switch relay1 off
    digitalWrite(relay8, LOW); //Swtich relay2 off
}
void loop()
{
    while(Serial.available()) //Check if there are available bytes to read
    {
        delay(10); //Delay to make it stable
        char c = Serial.read(); //Conduct a serial read
        if (c == '#'){
            break; //Stop the loop once # is detected after a word
        }
        inputs += c; //Means inputs = inputs + c
    }
    if (inputs.length() >0)
    {
        Serial.println(inputs);

        if(inputs == "A")
        {
            digitalWrite(relay1, LOW);
        }
        else if(inputs == "a")
        {
            digitalWrite(relay1, HIGH);
        }
        else if(inputs == "B")
        {
            digitalWrite(relay2, LOW);
        }
        else if(inputs == "b")
        {
            digitalWrite(relay2, HIGH);
        }
        else if(inputs == "C")
        {
            digitalWrite(relay3, LOW);
        }
        else if(inputs == "c")
        {
            digitalWrite(relay3, HIGH);
        }
        else if(inputs == "D")
        {
            digitalWrite(relay4, LOW);
        }
        else if(inputs == "d")
        {
            digitalWrite(relay4, HIGH);
        }
        else if(inputs == "E")
        {
            digitalWrite(relay5, LOW);
        }
        else if(inputs == "e")
        {
            digitalWrite(relay5, HIGH);
        }
        else if(inputs == "F")
        {
            digitalWrite(relay6, LOW);
        }
        else if(inputs == "f")
        {
            digitalWrite(relay6, HIGH);
        }
        else if(inputs == "G")
        {
            digitalWrite(relay7, LOW);
        }
        else if(inputs == "g")
        {
            digitalWrite(relay7, HIGH);
        }
        else if(inputs == "H")
        {
            digitalWrite(relay8, LOW);
        }
        else if(inputs == "h")
        {
            digitalWrite(relay8, HIGH);
        }
        inputs="";
    }
}

some relay modules are active LOW

On the ralay, check if you see the text NC or NO. "Normally Close", means that you have to set HIGH if you want your lights ON. If you connect the lights on "Normally Open", if means that you have to set LOW if you want your lights ON.


text:
Node MCU Wifi connection problem
I'm trying to connect my nodeMCU to my WiFi network also i have provided ip address  but it keeps printing ........ it is not connecting to the network. Below is my code.
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

// Configration Parameter for Access Poin
char * ssid_ap = "";
char * password_ap = "";
IPAddress ip(192, 168, 1, 158);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255,255,255,0);

// Set up the server object
ESP8266WebServer server (80);

// Keep track of sensor data that's going to be sent by the client
float sensor_value = 0.0;

void setup()
{
  WiFi.mode(WIFI_AP);
  WiFi.softAPConfig(ip,gateway,subnet);
  WiFi.softAP(ssid_ap,password_ap);

  Serial.begin(115200);
  delay(10);
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid_ap);

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

  Serial.println("");
  Serial.println("WiFi connected");

  server.begin();
  Serial.println("Server started");
  Serial.print("IP Address:");
  // Serial.print(WiFi.localIP());
  // Configure Server Router
  server.on("/",handleIndex); // use the top root path to report the last sensor value
  server.on("/update",handleUpdate);
  // server.begin();
}

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

}

void handleIndex()
{
  server.send(200,"text/plain",String(sensor_value)); //we'll need to refresh the page for getting the latest value

}

void handleUpdate()
{
 sensor_value = server.arg("value").toFloat();
 Serial.println(sensor_value);
 server.send(200,"text/plain","Updated");

}

softAP is for acting as an access point, not being a station in a pre-existing network.

You are creating a SoftAP (in essence creating a separate Wifi network). In this configuration, the ESP8266 will not "connect" to anything so polling WiFi.Status for the WL_CONNECTED status is meaningless.
To see if the SoftAP instance was created successfully, you should look at the output of WiFi.SoftAP() when you create the SoftAP instance, which returns a boolean indicating success (true) or failure. Or you should see the SSID of your newly created access point appearing on your PC or phone.
I suggest you look at the ESP8266 examples included in the Arduino IDE when you install device support for the ESP8266 to get some ideas about what you can do with a SoftAP.


text:
How can write a single data into spiffs?
typedef struct book {
char title[20];
 char author[20];
 int pages[10];

} Book;

Book b1 = {"The Zahir","Paulo Coelho",336,0};

while writing this structure into SPIFFS of ESP8266, I am using function
filename.write( (const uint8_t*)&b1, sizeof(b1));

but how can write a single data like name of book into structure of spiffs?

For this kind of situation it's best to treat your data as records in a database. To change one part of a record you read the entire record, change the value, then write that record back.
int record = 4; // which record you want to change

struct book b; // Temporary storage for editing the data

// Go to the record and read it in
filename.seek(record * sizeof(struct book));
filename.read( (const uint8_t*)&b, sizeof(struct book));

// Change the data
strcpy(b.title, "Winnie The Pooh");

// Go to the record again and write it out
filename.seek(record * sizeof(struct book));
filename.write( (const uint8_t*)&b, sizeof(struct book));


text:
ESP8266 WiFiClient connection always returns 0
I am trying to use a NodeMCU as a station to connect to a webserver, however, the WiFiClient connect function always returns 0 for no reason. I am able to connect the NodeMCU to my home WiFi, but it just cannot connect to any server (either with IP address or with URL).
If anyone is interested, the following is the testing code (I did not include the libraries intentionally for the clearness of the code).
int status = WL_IDLE_STATUS;
IPAddress server(74,125,115,105);  // Google

// Initialize the client library
WiFiClient client;

void setup() {
  Serial.begin(9600);
  WiFi.mode(WIFI_STA);
  Serial.println("Connecting to AP specified during programming");
  WiFi.begin("mySSID", "myPassword");
  while (WiFi.status() != WL_CONNECTED) {delay(500); Serial.print("."); }
  Serial.print("\r\nWiFi connected IP address: ");
  Serial.println(WiFi.localIP());
  Serial.println();
}

void loop() {
  Serial.println(client.connect(server,80));
}

I rolled back the question to original version answered by Jaromanda

i tried reaching the IP address in you code, using a web browser, without success ..... no response to ping either ............ please use a valid IP address in your code ...... update your post with corrected info

@JaromandaX, please undelete your answer


text:
sending data with rs485
I need to read acceleration data with ADXL335 using ARDUINO MICRO (or NANO) and send this data with RS485 module to another RS485 module connected to an ARDUINO UNO (300m between RS485 modules). Treated to use the codes below but slave does not receives any data.
Data from AXDL335 are in the form "xxx  yyy  zzz"
Do I need to write in a "string format" before send with RS485 (master)??
Many thanks in advance!!
master code
#include <SoftwareSerial.h>
#define SSerialRX   10
#define SSerialTX   11
#define SSerialTxControl  3
#define RS485Transmit  HIGH
#define RS485Receive  LOW
int x;                                                // channel X  ADXL335
int y;                                                // channel Y  ADXL335
int z;                                                // channel Z  ADXL335
SoftwareSerial RS485Serial(SSerialRX, SSerialTX);
void setup() {
  Serial.begin(9600);                                 // configure baud rate monitor

  pinMode(SSerialTxControl, OUTPUT);
  digitalWrite(SSerialTxControl, RS485Receive);
  RS485Serial.begin(4800);                            // starts serial(485) and configure baud rate
}

void loop() {

 x=analogRead(0);                                     //read X in analog(0)
 y=analogRead(1);                                     //read Y in analog(1)
 z=analogRead(2);                                     //read Z in analog(2)
                                                      // print read values in monitor
 Serial.print(x);Serial.print(" ");Serial.print(y);Serial.print(" ");Serial.print(z);Serial.println(" ");
 RS485Serial.print(x);
 delay (250);

 RS485Serial.flush();
 delay (750);
 }

SLAVE CODE
#include <SoftwareSerial.h>
#define SSerialRX   10
#define SSerialTX   11
#define SSerialTxControl  3
#define RS485Transmit  HIGH
#define RS485Receive  LOW
char x;
SoftwareSerial RS485Serial(SSerialRX, SSerialTX);

void setup() {
  Serial.begin(9600);        // configure baud rate monitor
  pinMode(13, OUTPUT);
  pinMode(SSerialTxControl, OUTPUT);
  digitalWrite(SSerialTxControl, RS485Receive);
  RS485Serial.begin(4800);  // start serial(485) and configure baud rate
}

void loop()
{
 if (RS485Serial.available()>0) {
  x = RS485Serial.read();
  if (x!="n")

  Serial.print(x);Serial.println(" ");
  delay(1000);

 }
}

print will print the number as text. use write as counterpart of read or use parseInt to read text printed with print(number)

x is char. you can't compare it with a string with !=. you can compare it with a char x != 'n'. when would x be 'n'?

For 300 meters you need to do it right and avoid things that can cause troubles. I suggest to stay away from the SoftwareSerial. Use a (pro) micro with its hardware serial port. Can you tell what kind of cable it is? Can you give a link to that cable? Some cables are cheap and have almost no copper in it. What kind of rs485 modules do you use? Are you testing this on your table or already with the 300 meters in between? How often do you need the data? Perhaps a slow wireless lora module might work. Add the extra information to your question. Your master has the control pin in receive mode.

dear Jot
I apologize since I am not native English speaker. At the beginning and if it works on the bench I think of using the RS485 modules of the LC electronics where the chip is already mounted with the DI RE RE pins already connected. If it works at my desk I will push the RS485 away until I check how far the signal emitted every 1 Hz is transmitted and properly received. There I will see which type of cable (4 ways I imagine it should be) can carry the signal and also feed the arduino and the accelerometers. Thanks for your help !!


text:
Grove Base Kit Multiple I2C Connection
I tried to connect two modules that require I2C connection and they won't work at the same time.
I used the Arduino Sensor Kit - Base. This kit does not need any connection, you just have to code to get your desired output. I wanted to display the Air Pressure (BMP280) module values to the 0.96" OLED Display, however, it is refusing to run both the air pressire and the OLED display at the same time. Only running one module (either Air pressure or OLED) at a time makes it work. Does it have something to do with how the I2C connection is wired on the board?
#include "Arduino_SensorKit.h"

void setup() {
  // put your setup code here, to run once:
  Oled.begin();
  Oled.setFlipMode(true);
  Oled.setFont(u8x8_font_7x14B_1x2_r);

  Pressure.begin();
}

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

  Oled.setCursor(0, 10);
  Oled.print("Temp: ");
  Oled.print(Pressure.readTemperature());
  Oled.print(" C");
  Oled.setCursor(0, 20);
  Oled.print("Pres: ");
  Oled.print(Pressure.readPressure());
  Oled.print(" Pa");
  Oled.setCursor(0, 30);
  Oled.print("Alti: ");
  Oled.print(Pressure.readAltitude());
  Oled.print(" m");

  delay(1000);
}

What I did:

Test to see if Air Pressure will still work while both Air Pressure and OLED is connected by using Serial.begin(). Now I know that only the OLED does not work when both modules are connected.
Changed order of initialization. Same result: Air Pressure works but not OLED

"it is refusing to do so" means what? It's printing nothing to the OLED? It's printing things but getting the values wrong? Please be more specific.

it has nothing to do with how the I2C connection is wired on the Base shield. run the I2C scanner sketch to see the devices I2C addresses

@Majenko The OLED is not working at all. Air pressure works (tested with Serial.print())

You tested the pressure using Serial.print() while the OLED code was there?

@Juraj The OLED has the address 0x3C and the Air Pressure has the address 0x77. Was also able to confirm it on their site: wiki.seeedstudio.com/I2C_And_I2C_Address_of_Seeed_Product/

@Majenko Yes I did

try to swap the initialization order

@Juraj Still the same output. OLED won't work :(

Perhaps it is something simple like: If you print the float pressure value (like 920.2773), the OLED line might overflow and cause and error/reset in the OLED lib. Did you try to print only one value without any prefixed text? Best would be to round the value before printing ;-)

@PeterPaulKiefer Yes, I tried to only print the letter "T" at the start of the loop (both air pressure and OLED are initialized) and the OLED still isn't working :(

Just for my understanding: You tried to print only the letter "T" and nothing else after that. When the pressure module is initialized the OLED does not display the "T" and when the Pressure Module is not initialized, the OLED shows the "T".

I've looked into the u8g2 lib that is used for the OLEAD. And I've found a possible issue with the constructor signature of this lib. But it could be a typo in the documentation. Later this day, I'll try to find the implementation and if it is an error I will report it with the resp. projects. It might not be you probleme here, as Olead can not work if this is really an error. But I may find an explanation while investigating the code.

I've also read that the Oled lib uses high speed I2C and that could be in conflict with the low speed Pressure I2C. Sadly, I forgott the reference. I'll have to look into the libs code. ;-)

@PeterPaulKiefer, regarding the I2C speed. I tested a similar OLED clone on the oscilloscope just now at 352kHZ, which would indicate it likely operates in fast I2C mode (up to 400kHz). The datasheet for the BMP280 indicates it is compatible with standard, fast or high speed I2C.

@fireblazer10, Juraj suggested (Jan 20) running an I2C Scanner sketch to see which devices it can see on your I2C bus. Did you get a chance to do that? An example is https://forum.arduino.cc/index.php?topic=197360. This will check addresses (and verify the information you found on the Seeed Studio website) and frequency compatability.

@RowanP Thank you for clearifying and for reminding me of what I what to do last evening. I completely forgott :-(. The BMP280 and Oled speed capabilities can be the same  but as the Pressure lib and the Oled lib both use the Wire lib when they initialize, there may be a side effect if both specify different speeds. It is just a guess. Perhaps the Wire lib gets confused.

@RowanP I apologize I honestly have forgotten about this but yes I did: 0x3C for the OLED and 0x77 for the pressure sensor

@PeterPaulKiefer Oh, that's a shame :(( I guess I would have to leave this project for a bit. I'll try other OLED libraries for a start and see if it changes anything

@fireblazer10, thanks for confirming the I2C scanner results. I put some general comments about I2C debugging on another question earlier today which may help. It may be difficult to make more progress without access to some additional test equipment.

I opend an issue on github. I think there is a problem with the Oled constructor. https://github.com/arduino-libraries/Arduino_SensorKit/issues/15 If i'm right, the clock of the 'I2C bus resets the OLED. If Pressure is active the I2C clock is active. -> reset the Oled. Tada. ;-)

About two weeks ago there was a change in the Arduino_SensorKit Library that introduced an error with the instanciation of the Oled object.
I found the error in the release (v1.0.6) of the library. The previous release (v1.0.5) could cause another issue, as it uses a software I2C. I doubt the hardwired sensores are connected with the correct pins. But I have no hardware, so I can not check this.
I propose a workaround to see, if the identified issue caused your observations.
#include "Arduino_SensorKit.h"

U8X8_SSD1306_128X64_NONAME_HW_I2C Oled2;
// if the line above does not work
// comment it and uncomment the following line.
// U8X8_SSD1306_128X64_NONAME_HW_I2C Oled2(U8X8_PIN_NONE);

void setup()
{
  Oled2.begin();
  Oled2.setFlipMode(true);
  Oled2.setFont(u8x8_font_7x14B_1x2_r);

  Pressure.begin();
}

void loop()
{
  Oled2.clear();

  Oled2.setCursor(0, 10);
  Oled2.print("Temp: ");
  Oled2.print(Pressure.readTemperature());
  Oled2.print(" C");

  delay(1000);
}

Could you please try out and report your experience.
If it would work, I can support the fixing of the issue.

It works! OLED just keeps blinking but it shows the output now! The blinking could be fixed by changing Oled2.clear() to Oled2.refreshDisplay(). Thank you so much!

You're welcome. Meanwhile I got feedback from marqdevx. He is about to release a new version of the lib. I think as soon as it is available, this workaround is not necessary furthermore (<- don'T know if this is an english word. But it sounds good ;-) ). As soon as the new revision is available I'll edit my answer and add your "blinking" solution too.   Cheers!

FWIW, I had the same issue with the latest version at the time - 1.0.10, and this fixed it. I have no idea what this does but it fixed it.

@davetron5000 Thank you for this comment. I completely forgot about this topic. I just remember that I waited for the new release and it had last longer then I expected. And then the topic get's out of my view ;-). I simply forgott it. In the very Moment I have not the time to look after it. Perhaps if I find some time in November I check what happend with the fix. It's in my calender.


text:
LM35 temperature decreases when heated
I have a question regarding the LM35. The sensor is supposed to have values that are to be directly proportional. But instead of the temperature increasing, the sensor values decrease.
This is my setup below. It seems to be a standard setup in different LM35 tutorial pages.

const int sensor= A0; // Assigning analog pin A0 to variable 'sensor'

void setup() {
  pinMode(sensor,INPUT); // Configuring sensor pin as input
  Serial.begin(9600);
}

void loop() {

  float reading=analogRead(sensor); //Reading the value from sensor
  float vout= (reading*5000)/1024;
  float temp= vout/10;

  Serial.print("in DegreeC= ");
  Serial.print(temp);
  Serial.println("");

  delay(500); //Delay of 1 second for ease of viewing

}

These are the results. From room temperature, I applied heat through the use of a lighter and it went lower instead of higher.

I read somewhere that it has something to do with the power supplied by the Arduino. However, when I used a 12V supply to power the Arduino, the readings became very erratic and unstable.
UPDATE:
I have finally returned from the city (Took a long time because of Quarantine Restrictions) and I brought 3 LM35 from another shop. All 3 of the new LM35 worked as intended and didn't lower its temp reading when exposed to heat (With the same configuration). I could rule out these possibilities as to the reason why the LM35 didn't work.
1. Manufacturing Defect - all three of the LM35 didn't work as intended. They all had their temperature lowered when exposed to heat. There could be a defect in the manufacturing process because it doesn't work as advertised. (Leaning towards this)
2. Static Electricity - I remember receiving the LM35 in a plastic bag as packaged by the shop. It could have been affected by static electricity and damaged the circuit inside (on all three though?). The LM35s I received recently had been packaged in those electrostatic discharge protection packaging so it could have probably contributed to it? I need more insight on this I apologize for not being able to properly word it out.
There could be more but these are the most I could come up with as a conclusion.

Do not configure the analog pin as an digitial input pin. If you want to use it as an analog pin.you don't need any setup. An lm35 is like a complicated zener diode. Perhaps it help to put a resistor (say 10 kOhms)  from Vout to GND to stabilize the output voltage of the LM35. Just two guesses.

@PeterPaulKiefer I added the 10kOhms however the temperature reading became 0 celsius. Changed the resistor to 1k Ohms, still 0 celsius reading. Changed to 100kOhms, still 0 celsius reading. I had also set my code and removed the pinMode however still the same output. The temperature always scales down when exposed to heat (even with my 3 other spare LM35 but they are from the same shop tho). I will go and buy a capacitor tomorrow to do more testing on the sensor.

If the GND with a 10k resistor leads to zero Volt, then the LM35 does not output any voltage. It might be broken. (All three are broken?; perhaps from a fake parts store ;-( ).  There is a (really low) probabillity that the arduino analog ports are broken. If you have two simple resistors (>= 1000Ohms) you can put them in series, add VCC and GND each at an end and connect the middle (where the resistors are put together) to the analog port. If both resistors are the same value, it should result in about 512 +- 20.

You are reading A5 but in your diagram you show it hooked up to A0:

Change your code to this and I believe it will work:
const int sensor= A0; // Assigning analog pin A0 to variable 'sensor'

void setup() {
  pinMode(sensor,INPUT); // Configuring sensor pin as input
  Serial.begin(9600);
}

void loop() {

  float reading=analogRead(sensor); //Reading the value from sensor
  float vout= (reading*5000)/1024;
  float temp= vout/10;

  Serial.print("in DegreeC= ");
  Serial.print(temp);
  Serial.println("");

  delay(500); //Delay of 1 second for ease of viewing

}

The data you are reading from A5 is indeterminate and just happens to decrease as A0 increases.
================================================================================
UPDATE:
Ok, so you corrected yourself and are reading the correct pin in spite of what your schematic shows.  Please explain this:
float vout= (reading*5000)/1024;
float temp= vout/10;

I think you want:
float vout = (reading/1024.0) * 5000.0;
float temp = vout/10.0;

You are carelessly mixing floating point and integer math.

I'm so sorry I forgot to change the code to A0 but the output is still the same. Temperature goes down when exposed to heat :(

Do you have a voltmeter?  Your next step is to determine what the voltage on pin 2 of the LM35 is doing when you apply heat.  If it actually goes down then you probably have a bad LM35.  If it goes up as it should, then you have an issue with your Arduino or the code.

I will update once I go out tomorrow to get myself a multimeter. The thing is, I have 3 other spare LM35 and all of them have the same behavior. They are however from the same shop so I think I'll find another LM35 from a local shop tomorrow and compare.


text:
Remove gravity from accelerometer of MPU-6050
I am currently working with MPU-6050. Now I want to minus gravity from my accelerometer's value as we minus the offset.
Here is the code:
#include <Wire.h>
#include <MPU6050.h>
//read as rool:pitch:yaw:accX:accY:accZ
MPU6050 mpu;
unsigned long timer = 0;
float timeStep = 0.01;
float pitch = 0;
float roll = 0;
float yaw = 0;
float accX = 0;
float accY = 0;
float accZ = 0;
float rollRad = 0;
float pitchRad = 0;
float yawRad = 0;

int count = 0;

Vector minusGravity(Vector vec)
{
    /*
     float x = vec.XAxis, y = vec.YAxis, z = vec.ZAxis;
     vec.XAxis -= x * cos(yawRad) - y * sin(yawRad) + x * cos(pitchRad) + z
           * sin(pitchRad) + 0;
     vec.YAxis -= x * sin(yawRad) - y * cos(yawRad) + 0 + y * cos(rollRad) -
           z * sin(rollRad);
     vec.ZAxis -= 0 - x * sin(pitchRad) + z * cos(pitchRad) + y *
           sin(rollRad) + z * cos(rollRad);
    */

    return vec;
}

float accP(float value)
{
    int x = (int)(value * 10);
    return ((float)(x)) / 10;
}

void setup()
{
    Serial.begin(115200);
    while (!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))
    {

    }
    //mpu.calibrateGyro();
    mpu.setThreshold(1);
 }

 void loop()
 {
    timer = millis();
    Vector norm = mpu.readNormalizeGyro();
    pitch = pitch + norm.YAxis * timeStep;
    roll = roll + norm.XAxis * timeStep;
    yaw = yaw + norm.ZAxis * timeStep;
    Vector normAccel = minusGravity(mpu.readNormalizeAccel());
    rollRad = roll * 0.0174533;
    pitchRad = pitch * 0.0174533;
    yawRad = yaw * 0.0174533;

    Serial.print(roll);
    Serial.print(":");
    Serial.print(pitch);
    Serial.print(":");
    Serial.print(yaw);
    Serial.print(":");
    accX = accP(normAccel.XAxis);
    accY = accP(normAccel.YAxis);
    accZ = accP(normAccel.ZAxis);
    Serial.print(accX);
    Serial.print(":");
    Serial.print(accY);
    Serial.print(":");
    Serial.println(accZ);
    delay((timeStep * 2500) - (millis() - timer));
}

I understand the problem is here :
vec.XAxis -= x * cos(yawRad) - y * sin(yawRad) + x * cos(pitchRad) + z
           * sin(pitchRad) + 0;
     vec.YAxis -= x * sin(yawRad) - y * cos(yawRad) + 0 + y * cos(rollRad) -
           z * sin(rollRad);
     vec.ZAxis -= 0 - x * sin(pitchRad) + z * cos(pitchRad) + y *
           sin(rollRad) + z * cos(rollRad);

New code :
      #include <Wire.h>
  #include <MPU6050.h>
  //read as rool:pitch:yaw:accX:accY:accZ
  MPU6050 mpu;
  unsigned long timer = 0;
  float timeStep = 0.01;
  float pitch = 0;
  float roll = 0;
  float yaw = 0;
  float accX = 0;
  float accY = 0;
  float accZ = 0;
  float rollRad = 0;
  float pitchRad = 0;
  float yawRad = 0;
  float gX = 0;
  float gY = 0;
  float gZ = -9.8;

  int count = 0;

  Vector minusGravity(Vector vec)
  {

    float x = gX, y = gY, z = gZ;
    vec.XAxis -= x * cos(yawRad) - y * sin(yawRad) ;
    vec.YAxis -= x * sin(yawRad) - y * cos(yawRad) ;

    x = vec.XAxis; z = vec.ZAxis;
    vec.XAxis -=  x * cos(pitchRad) + z * sin(pitchRad) ;
    vec.ZAxis -= - x * sin(pitchRad) + z * cos(pitchRad) ;

    y = vec.YAxis, z = vec.ZAxis;
    vec.YAxis -=  y * cos(rollRad) - z * sin(rollRad);
    vec.ZAxis -=  y * sin(rollRad) + z * cos(rollRad);

    return vec;
  }

  float accP(float value)
  {
    int x = (int)(value * 10);
    return ((float)(x)) / 10;
  }

  void setup()
  {
    Serial.begin(115200);
    while (!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))
    {

    }
    //mpu.calibrateGyro();
    mpu.setThreshold(1);
    Vector normAccel = mpu.readNormalizeAccel();
    gX = normAccel.XAxis;
    gY = normAccel.YAxis;
    gZ = normAccel.ZAxis;
  }
  void loop()
  {
    timer = millis();
    Vector norm = mpu.readNormalizeGyro();
    pitch +=  norm.YAxis * timeStep;
    roll += norm.XAxis * timeStep;
    yaw += norm.ZAxis * timeStep;
    Vector normAccel = minusGravity(mpu.readNormalizeAccel());
    rollRad = roll * 0.0174533;
    pitchRad = pitch * 0.0174533;
    yawRad = yaw * 0.0174533;
    Serial.print(roll );
    Serial.print(":");
    Serial.print(pitch );
    Serial.print(":");
      Serial.print(yaw );
    Serial.print(":");
    accX = accP(normAccel.XAxis);
    accY = accP(normAccel.YAxis);
    accZ = accP(normAccel.ZAxis);
    Serial.print(accX);
    Serial.print(":");
    Serial.print(accY);
    Serial.print(":");
    Serial.println(accZ);
    delay((timeStep * 2500) - (millis() - timer));
  }

It is little buggy.
Can anyone help me figure out what is my mistake ?

I understand the problem is here .... what is the problem?  .... what do you expect to see? .... what do you see instead?

I just want to see acceleration due to movement, not due to gravity. I'm trying to counter gravity portion.

When I put it on a surface or holding it, there should be no acceleration.

@jsotola I may have found a solution, added an answer , can you verify it, if it is correct or not ?

A general comment: you are trying to compute pitch, roll, yaw by integrating the readings from the gyroscope and and to account for gravity. In my experience this is unreliable beyond a few seconds and you would need more sophisticated methods if you want to track orientation.

May I know what are those methods ?

I have edited the question & added new code, which is just a little buggy, can you help me figure it out ? @ChristianLindig

Look for Kalman filter or this article.

I don't have problem with angle, acceleration is the problem

Did the updated code to remove gravity acceleration work. Or did u find something else if u did can u please send?

I may have come to a solution :
Vector minusGravity(Vector vec)
{

 float x = vec.XAxis, y = vec.YAxis, z = 0;
 vec.XAxis -= x * cos(yawRad) - y * sin(yawRad) ;
 vec.YAxis -= x * sin(yawRad) - y * cos(yawRad) ;

 x = vec.XAxis; z = vec.ZAxis;
 vec.XAxis -=  x * cos(pitchRad) + z * sin(pitchRad) ;
 vec.ZAxis -= - x * sin(pitchRad) + z * cos(pitchRad) ;

 y = vec.YAxis, z = vec.ZAxis;
 vec.YAxis -=  y * cos(rollRad) - z * sin(rollRad);
 vec.ZAxis -=  y * sin(rollRad) + z * cos(rollRad);

 return vec;
}

Now this is far better, as after calculating effect of roll,pitch,yaw in every step the  x,y,z changes. I missed that part. I was calculating directly, so it was giving me wrong value.
vec.XAxis -= x * cos(yawRad) - y * sin(yawRad)
then, vec.XAxis -=  x * cos(pitchRad) + z * sin(pitchRad)
 doesn't give the same result as the wrong one vec.XAxis -= x * cos(yawRad) - y * sin(yawRad) + x * cos(pitchRad) + z
           * sin(pitchRad) + 0;

@jsotola can you verify it ??


text:
Data Logging without Interfacing SD Card module
I want to log data to a text document without connecting the SD card module. I don't want to print the data on Serial Monitor I want to store it in a file. Is it possible? Can someone help me with it?
I am using a Arduino Nano on a Windows 10 system, and I want to know if there is an Arduino library to write logs to a file.

That is a problem for Ubuntu system, I am currently working on windows. I want to know if there is an Arduino library to write data into a .txt file directly available.

read the up-voted answer

To a file that is stored on the PC the Arduino is connected to?

it your not going to put the data on the serial port, and your not going to have a local storage option(SD card) how do you expect the data to get to said text document?

maybe they have such an Arduino library at Hogwarts

@Gerben Correct

One option, which is doable, but not elegant, is to store data in EEPROM.  You can't store much data, but if you don't want to use an SD card, and you don't want to talk via the serial port (or use Bluetooth, other communication protocols), that might work.  Not pretty, but if you need to store only a tiny bit of data, that is an option.    Here's an example; https://www.norwegiancreations.com/2017/02/using-eeprom-to-store-data-on-the-arduino/   User Juraj made a reference to a duplicate question where someone else mentions this as well.

You're asking the impossible, you want to create a file without attached storage (no SD card) and without outputting the data (via serial) to be stored. How else do you expect the data to be sent from the Arduino to your file?

The simplest answer is to install a program that handles serial connection and can write everything into a logfile. On Linux, CuteCom is a program like that. On Windows, putty can handle serial (as well as SSH and telnet), and has logging.
The more advanced soulution is to write a program (or a simple script) that can do that. You could make it to do some other stuff as well (like configuring the Arduino side), and you can run it in the background without user interaction.