text:
Timing taking longer than expected
This is on a custom Arduino PCB (32u4) that I am programming with a Sparkfun Pocket AVR Programmer. A different program that I was writing wasn't working the way I expected it to, so I tried the "BlinkWithoutDelay" example sketch from the Digital section of the examples.
https://media.discordapp.net/attachments/572565310679547946/650075749851856908/unknown.png
^ So you don't have to look it up yourselves. previousMillis is initialized to 0.
However, the LED seems to alternate states every 4 seconds instead of every 200 ms with this code. I increased the interval from 200 to 400, and the IRL time increased from 4 seconds to 8 seconds, so at the very least it's consistent that way. My first instinct is that the crystal is broken somehow, but I don't think I'd be able to flash the MCU in the first place if it was. So, does anyone have any idea what's happening? For the record, I had 5 of these PCB's assembled, and the first one worked perfectly for 2 months before something else broke. I've had this issue with the second and third PCB I've tried.

Check F_CPU when compiling and your lfuse setting. See http://www.engbedded.com/fusecalc for a convenient tool.

Hey, sorry it took so long to get back. I'm using the arduino IDE, and I can't find the settings you're talking about in the preferences section, so I'd assume everything's fine on that front. I can turn compilation/upload to verbose and post that, if you think that would help.

Never mind, check the answer I just posted.

Arduino IDE has the fuses settings in boards.txt. Either you "Burn Bootloader" or use your programmer standalone with the avrdude utility.

Factor 8 in timing smells like wrong fuses.
Perhaps you don't use an external oscillator, but the internal one?

It's a factor of 20, isn't it? And I'm pretty sure that it's using the external 16 Mhz oscillator on the board, unless that has been damaged somehow. I also just noticed that the second board is showing a factor of 16, coincidentally.

I take that back about the second board. I just doubled the delay in the code and the observed delay stayed the same. I am very confused.

You're right: it's hard to get 8 from a 4 and a 5. (Not sure how I assumed 10/5 just to explain the smell/odor ;) But then, your question is even more a miracle.

On all of the new boards I had tested (excluding the first one that I said worked), I had not burned the bootloader. Burning the bootloader made the timing normal! If anyone can tell me why that's the case, I'll accept your answer as the "correct" answer.

Burning the bootloader also (usually) sets the fuses, as the particular fuse settings are specific to the bootloader. Thus DataFiddler's answer has the why, you have found the how to fix.

:) so you deserve a +1 as well ...

Awwww thank you


text:
ESP8266 - Garbled output when using serial Swap
I want to use two serial ports
Serial1 - for debugging - No RX needed
Serial - to read from a different device
I receive garbled output instead of valid characters
Here is code for NodeMCU
#define LED D0

void setup() {
  // put your setup code here, to run once:
  pinMode(LED, OUTPUT);
  Serial.begin(9600);
  Serial.flush();
  Serial.swap();
  Serial1.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  if(Serial.available()>0)
  {
//    digitalWrite(LED, HIGH);
//    delay(500);
//    digitalWrite(LED, LOW);
//    delay(500);
//    digitalWrite(LED, HIGH);
//    delay(500);
//    digitalWrite(LED, LOW);
//    delay(500);
    Serial1.print(Serial.read());
  }
}

and here is the code for Arduino mega which is emulating a send and receive
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial1.begin(9600);    //Transmit
  Serial2.begin(9600);    //Recieve
}

void loop() {
  // put your main code here, to run repeatedly:
  if(Serial.available()>0)
    Serial1.print(Serial.read());

  if(Serial2.available()>0)
    Serial.print(Serial2.read());
}

When I Send an Charater(Single) I receive something like this
for "s" - 5257525753515257534952575256
for "d" - 5257525652565257534952575256
Kindly help

use Serial.write to write a character returned by read

That does work. Thanks @Juraj

Serial.swap() function swaps the Serial to pins 15 and 13

source: Stack Exchange

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

sort: votes


text:
converting character to strings in transmitter and receiver Arduino
I am using transmitter and receiver but I want to change the data type from character to int
receiver code
#include <RH_ASK.h>//include radioHead ASK library
#include <SPI.h> // include dependant SPI libray

 RH_ASK rf_driver; // create ASK object
int ledon = 13;
String userid;
String password;
 //RH_ASK ID1; // create ASK object
//RH_ASK pass1; // create ASK object

void setup() {

  rf_driver.init(); //initialize ASK object

  Serial.begin(9600); //setup serial monitor to 9600

  //if(!rf_driver.init())
       //Serial.print("init failed");
}

void loop() {

  // set buffer to size of expected message
  uint8_t buf[9];
  uint8_t buflen =sizeof(buf);

  //check if recevied packet is correct size
  if (rf_driver.recv(buf,&buflen))
  {
    int i;
    // message received with valid checksum
    Serial.print("id: ");
    Serial.println((char*)buf);
      userid =(char*)buf;
        Serial.println(userid);

  }

delay(5000);

   uint8_t buf2[8];
  uint8_t buflen2 = sizeof(buf2);

   if (rf_driver.recv(buf,&buflen))

  {

    int i;
    // message received with valid checksum
    Serial.print("password: ");
    Serial.println((char*)buf);
      password = (char*)buf;
      Serial.println(password);

  }
  delay(5000);

transmitter code
//Include RadioHead Amplitidue shift keying library
#include <RH_ASK.h>
// Include dependatnt ISP library
#include <SPI.h>

//create Ampitude shift keying object
RH_ASK rf_driver;

void setup() {
 // intialize ASK objct
rf_driver.init();

Serial.begin(9600);

  //if(!rf_driver.init())
      //Serial.print("init failed");

}

void loop()
{

  const char *pass= "123456789";
rf_driver.send((uint8_t *)pass, strlen(pass));
rf_driver.waitPacketSent();
delay(5000);

const char *ID= "A00034732";

rf_driver.send((uint8_t *)ID, strlen(ID));
rf_driver.waitPacketSent();
delay(5000);

The title and the text in the answer do not ask the same. What do you want to do? char to num or char to string? And the code is very bad formatted. I also don't see a variable (content) of the transmitter that can be converted or is password always a number? So what do you mean exactly?

If ID is a HEX value then it is too long for an int.

What exactly do you want to convert to a number, and why do you think that converting it to a number is a good idea?

You have to properly understand what you are trying to do. (It looks like) you have a decimal representation of a number, encoded as a string of characters. "12345" is not a number but a series of characters. (Technically each character is a number with a certain ASCII value, the digit "1" has ASCII value 49 for instance.)
To convert "12345" into the number 12345, the CPU needs to take each character, find its digit value, multiply it by the correct power of 10 and add it to all the others. There are a few built-in ways that do this for you. The easiest is the atoi() function, e.g.
int x = atoi("150");

In your case, try this:
int userid = atoi((char *) buf);

Serial.println(userid);

Note that an int on an Uno is only 16 bits, thus atoi() is only good for numbers within [−32,768, +32,767].

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


text:
SPI communication with Arduino and PGA411-Q1 resolver sensor
I have been trying to implement SPI communication between an Arduino board and a PGA411-Q1 resolver sensor board. I have set up the Arduino SPI settings as indicated on the resolver sensor's datasheet (http://www.ti.com/lit/an/slaa688/slaa688.pdf) - 8MHz sclock, MSB first and SPIMode1.
The communication is done by sending and receiving 32 bits both to and from the Arduino. The bits are distributed as follows.
Outgoing 32bit data frame by Arduino to the sensor:
O-5 bits: Arduino's CRC for data
6-7 bits: Always zero
8-23 bits: Data
24-31 bits: Register address
Incoming 32bit data frame by the sensor to the Arduino:
O-5 bits: Sensor's CRC for data
6-7 bits: SPI communication status
8-23 bits: Data
24-31 bits: Register address
Also, there is mandatory to send and receive a CRC6 code from both the board and Arduino and I have implemented it as well. (I will not be checking the CRC code received by the Arduino board. I will check it later. But I am already sending the CRC code needed by the sensor board).
This is the code written by me:
NOTE: The crc_cal function outputs the crc code from Arduino to the sensor along with the two 'always zero' bits.
#include <SPI.h>
unsigned int crc_cal (unsigned long datin);

 const int ncs = 10;
 unsigned char crc_char = 0x3F;

 void setup() {

  // initalize the chip select pin:
  pinMode(ncs, OUTPUT);
  pinMode(FAULTRES,OUTPUT);
  pinMode(NRESET,OUTPUT);

  // put your setup code here, to run once:
  Serial.begin(9600);

  //NRESET must go from LOW to HIGH
  digitalWrite(NRESET,LOW);
  digitalWrite(NRESET,HIGH);

  //wait at least 5ms to complete diagnostics tests
  delay(10);

  //FAULTRES LOW
  digitalWrite(FAULTRES,LOW);

  // start the SPI library:
  SPI.begin();

 // give the sensor time to set up:
  delay(100);

   }

void loop() {

SPI.beginTransaction(SPISettings(6400000, MSBFIRST, SPI_MODE1));

digitalWrite(ncs, LOW);

byte temp_3 = SPI.transfer(0x41);

byte temp_2 = SPI.transfer(0x0F);

byte temp_1 = SPI.transfer(0x0F);

byte temp_0 = SPI.transfer(crc_char);

digitalWrite(ncs, HIGH);

SPI.endTransaction();

unsigned int angle_raw = 0;
angle_raw = temp_2;
angle_raw = angle_raw << 8;
angle_raw = angle_raw | temp_1;
angle_raw &= 0x3FF;
Serial.println(angle_raw);

int crc = crc_cal(0x410F0F00);
unsigned char crc_char = crc;
crc_char = crc_char & 0x3F;
 delay(100);

 }

     /* CRC6 calculation - optimized for PGA411 */
 unsigned int crc_cal (unsigned long datin)
 {
 unsigned int byte_idx, bit_idx, crc= (0x3F << 2);
 /* byte by byte starting from most significant (3-2-1) */
 for (byte_idx = 3; byte_idx >= 1; byte_idx--)
 {
 /* XOR-in new byte from left to right */
 crc ^= ((datin >> (byte_idx<<3)) & 0x000000FF);
 /* bit by bit for each byte */
 for(bit_idx = 0; bit_idx < 8; bit_idx++)
 {
 crc = crc << 1 ^ (crc & 0x80 ? (0x5B << 2) : 0);
 }
 }
 return(crc >> 2 & 0x3F); /*restore two bit offset */

 }

I have used the code provided in the PGA411-Q1's datasheet (http://www.ti.com/lit/an/slaa688/slaa688.pdf) and it works fine when I check it manually. Some examples for input data frames and their CRC codes can be found in the section 7.5.4 of the datasheet found here http://www.ti.com/lit/ds/symlink/pga411-q1.pdf
As you may notice from the code I am sending the register address which I want data from in the first 8 bits of SPI.transfer. The read address of that register is 0x41.
Next, I'm sending two garbage values as data because this is a read-only register.
Finally, I'm sending the CRC code calculated by the crc_cal function.
All I'm receiving in the serial monitor are zeros and I can't figure out what went wrong. I would appreciate some insight into this.

Why are you sending a CRC value calculated from values that you received? In my understanding you send a CRC value calculated from the values, that you are sending

@chrisl I have fixed it now. Still no change.

Then please update your question with your new code. In the linked application note I see an initialization process. But I don't find point 2 and point 5 in your program: "Step 2.  Ensure that the NRESET signal has a low-to-high transition. Step 5.  Set the FAULTRES pin logic low." May be a good thing to include that also

hello @chrisl the FAULTRES pin can be set to zero by the GUI software that comes with the sensor board. I have already set it low. Also, the NRESET can be made low-to-high by manually pressing the pin associated with the NRESET pin. I have done both but still no progress.

I have separately connected NRESET and FAULTRES pins to pin 4 and 3 of Arduino board and have updated the code


text:
NEO 6M data is not working properly with uno
I am using a arduino uno and neo 6m gps module. The problem I am facing is quite weird. When I connected the setup the data from neo6M was seen in serial monitor, I even printed it on a Oled display. It was a close room at night. I used tiny gps plus plus library to parse the data. I got both latitude longitude. After disconnected the circuit i tried again and that is when nothing came out in serial monitor. The same sketch did not work for a day. But again at afternoon at some point i got the data properly.
Sometimes the red led is blinking but nothing happens.
While I change the rx and tx pins in software serial it got data but then again same problem and changing pins don't work. I have tested it in front of my window so there must be a good signal.
Can someone tell me what is wrong with the system? I have so far waited long enough like 10 mins to get the data but nothing. I have to present the project by tomorrow in office.
This is the code :
https://pastebin.com/TMRYXFNw

I am using this tutorial https://lastminuteengineers.com/neo6m-gps-arduino-tutorial/

Unless you can format your code properly (select it, then press the {} button in the editor) no one is going to look twice at your question.

Sorry for that. But in my phone i did not have a formatting option.


text:
How to burn a bootloader to non-bootloaded(clean crystal) ATMEGA328P-PU with USBASP programmer via Avrdudess?
I'm trying to burn bootloader to my clean crystals, atmega328p-pu.For this I use the 16MHZ crystal with two ceramic capacitors and USBASP programmer, on Windows 10 Pro. As program for burning I tried: Arduino IDE, AVRDUDESS,AVRDUDEPROG. But when I would to detect my chip(or in IDE try to burn the Chip)., I get this error:
`
avrdude.exe: set SCK frequency to 1500000 Hz
avrdude.exe: warning: cannot set sck period. please check for usbasp firmware update.
avrdude.exe: error: program enable: target doesn't answer. 1
avrdude.exe: initialization failed, rc=-1
             Double check connections and try again, or use -F to override
             this check.
avrdude.exe done.  Thank you.
`
From this error I understand that the target(My chips) Wouldn't to start. I checked my connection for 1000 times and I tested mt wires too, they works correctly. And supply 5V comes o chip and it become warm(it means that supply comes and it should start). I have got 5 chips And I tested all of them. I searched internet but nothing.
Please,help me, and say how can I burn them.
Best Regards,
E.M.

My understanding of that error message is that your USBASP is unable to set the right clock speed. Maybe it's got inferior (out-dated) firmware on it...

Not only. In khazarma or in avrdudeprog it don't work too

It without the bootloader. And

Have you tried with another programmer? Like I said: the error looks to pertain to the programmer, not the software or the chip.

So can I use the Arduino As ISP? If yes should I change the SPI_CLOCK to (16000000/6) as I use the 16 MHZ crystal? And which baudrate should I use:19200,115200,1000000? in ArduinoISP sketch?

don't change the Arduino as ISP sketch. select Uno in Tools menu to burn the bootloader. Uno has a 16 MHz oscillator

I'm intrigued to know what a "clean crystals atmega328p-pu" is...

it worked!!!. I took of the capacitors that was connected to crystal 16MHZ, that connected to the common GND of Arduino. So and I changed in sketch and defined the Old Wiring that I used it and it worked!!! And one more question. Why the capacitors are changed this results?

clean crystals atmega328p-pu is non-bootloaded chips


text:
How do I segment Arduino program when line count is so large that code maintenance is difficult?
I'm looking for the Arduino/C++ equivalent of COBOL's 'copy' statement.
I'm working on a program that is approaching 600 lines of code in the TopLevel.cpp source file.  This is hard to manage because I feel like I spend all my time scrolling up and down the source file.  The code in question does not easily lend itself to conversion to a class because it is sections of loop/main.  I've tried using xxx.h (for storage definitions) and yyy.cpp (for code sections).  Those approaches yield error messages, which I think are due to the different timings of the Arduino pre-processor and the compiler code that resolve the #include statements.
Thanks for the help.
--CVTBrakeman
p.s.
I wrote my first program in 1967; the language was GOTRAN on an IBM 1620.  For almost 50 years, I made my living designing/writing COBOL and SAS code on IBM mainframes.  Yes, Y2K was real and I survived it.

you can have many .ino files in an Arduino project. Use Add file in Sketch menu in IDE. what error messages for h/cpp?

You can use a #include directive. You can build your C++ subclasses in separate .CPP & .H/.HPP files. The Arduino IDE is just a wrapper around a C++ compiler and a bunch of scripts to load the .HEX to the Atmel chip using ICSP.

https://arduino.stackexchange.com/questions/60656/split-up-arduino-code-into-multiple-files-using-arduino-ide/60659#60659

Thanks for the help; I think the solution is to restructure the program and convert my 'include' code to separate classes. Probably should have done that in the beginning.  It looks to me as if included files are compiled separately.  Variables defined in the included code are no longer visible to the setup/main code blocks.  Thanks for your help.

This is more like a general programming question than an Arduino
question but, anyway...
You don't need to write classes to sort your code into files. You just
need to think in term of independent pieces of functionality. Each of
those pieces would be implemented in a .cpp file, with the interface
declared in a .h file.
As an example, let's say your Arduino is controlling an hyperdrive.
Managing the dilithium plasma generator is one of those functionalities
that can be separated in its own files. The .h files declares everything
that is needed for using that functionality:
plasma_generator.h:
// Read the state of the plasma.
float plasma_density();
float plasma_temperature();

// Control the plasma.
void set_plasma_target_temperature(float target_temperature);
void ignite_plasma();
void turn_off_plasma();
void add_dilithium(float amount);

Then the .cpp file contains the implementation:
plasma_generator.cpp:
#include "plasma_generator.h"

// A "static" function is a function private to this module.
static float get_gauge_reading(int gauge_number)
{
    ...
}

// Implementation of a public function, described in the .h file.
float plasma_density()
{
    float raw_reading = get_gauge_reading(42);
    ...
}

...

In your main program (or even in other modules, if needed) you
#include the .h file and use the functionality defined therein.

There are two ways of doing this:

Multiple INO files

The Arduino IDE combines multiple INO files into one single CPP file before compilation. You can split your program across multiple INO files at will. It makes it easier to manage, since you can split your program into logical chunks at will, but you don't have to think much beyond "which file shall I stick this function in?"

Create libraries

Some functionality of your program could be placed into a library or multiple libraries. This is kind of like option 1, but you have to think more about C++ syntax and suchlike that with INO files (function ordering, externs, etc). It does have the benefit that you could easily re-use code between programs, though
Personally I usually use option 2 before option 1. If a code is genericisable ("able to be made generic") then it can be made into a library - after all, I may want it later for some other program. However, if all you want to do is split your program into different chunks with each chunk a different topic or area of your program then option 1 is definitely for you.
Alternatively you might consider a different IDE, such as UECIDE which gives you such things as function bookmarks& to make navigation of your code easier.


text:
Use esp-01 relay with Nodemcu possible?
I'm building a simple mobile controlled relay switch. however, I'm out of relay modules, but I do have these esp-01 relays: https://ae01.alicdn.com/kf/HTB1VIKLeJLO8KJjSZFxq6yGEVXaW.jpg
I'm wondering if these can work with a nodemcu? So far no luck.

What do you mean by "work with a nodemcu"? You mean, can you connect a NodeMCU to them, or can you plug an ESP-01 into them and communicate to them with a NodeMCU?

the relay is on io 0 or io 2 of the esp-01 so give the relay board power and try to connect io 0 or io 2 with a resistor to ground or 3.3 V pin on the header  (the yellow header has the esp-01 pinout of course)


text:
Compile code error: 'Serial' does not name a type

int LDR_deger = 0;

int Ledpin1 = 12;
int Ledpin2 = 11;
int Ledpin3 = 10;
int Ledpin4 = 9;
int Ledpin5 = 8;

int LDR_pin = 0;

void setup()
{

  Serial.begin(9600);
  pinMode(Ledpin1, OUTPUT);
  pinMode(Ledpin2, OUTPUT);
  pinMode(Ledpin3, OUTPUT);
  pinMode(Ledpin4, OUTPUT);
  pinMode(Ledpin5, OUTPUT);
}
void loop()

{
  LDR_deger = analogRead(LDR_pin);
digitalWrite(Ledpin1,HIGH);
digitalWrite(Ledpin2,HIGH);
digitalWrite(Ledpin3,HIGH);
digitalWrite(Ledpin4,HIGH);
digitalWrite(Ledpin5,HIGH);

if (LDR_deger <= 80 && LDR_deger> 30) {
  digitalWrite(Ledpin1, LOW);
} else{
  digitalWrite(Ledpin1, HIGH);
  if (LDR_deger<= 150 && LDR_deger > 80){
  digitalWrite(Ledpin2, LOW);
  digitalWrite(Ledpin1, LOW);
  }else{
    digitalWrite(Ledpin1, HIGH);
    digitalWrite(Ledpin2, HIGH);
    if (LDR_deger  <= 200 && LDR_deger> 150){
      digitalWrite(Ledpin2, LOW);
      digitalWrite(Ledpin1, LOW);
      digitalWrite(Ledpin3, LOW);
     }else{
      digitalWrite(Ledpin1, HIGH);
      digitalWrite(Ledpin2, HIGH);
      digitalWrite(Ledpin3, HIGH);
      if (LDR_deger <= 1000 && LDR_deger> 300){
      digitalWrite(Ledpin2, LOW);
      digitalWrite(Ledpin1, LOW);
      digitalWrite(Ledpin3, LOW);
      digitalWrite(Ledpin4, LOW);
      digitalWrite(Ledpin5, LOW);
     }else{
      digitalWrite(Ledpin1, HIGH);
      digitalWrite(Ledpin2, HIGH);
      digitalWrite(Ledpin3, HIGH);
      digitalWrite(Ledpin4, HIGH);
      digitalWrite(Ledpin5, HIGH);
     }
       }
     }
   }
  }
Serial.print("LDR Deger: ");
Serial.print(LDR_deger);
Serial.println(" ");
delay(500);
}

Don't simply post code and expect us to guess what is the problem.  Also give some explanation of what you have tried

One reason you are receiving the compile error, is due to the code outside of a function. When you write nice, neat, properly formatted code, these errors are easy to spot. The Arduino IDE has a built in feature that will "highlight" a matching curly bracket (or curly brace?).

Maybe the Auto Format (CTRL+T) feature should be mentioned too. It gets so obvious after using it.

VE7JRO already has answered your question. Below is not an answer to the question but a better way to program something like you have.
In your case, you need to set 5 pins according. I assume the following lines are just for initialization (and not needed when you set them afterwards to FALSE), as I do not see any delay.
digitalWrite(Ledpin1,HIGH);
digitalWrite(Ledpin2,HIGH);
digitalWrite(Ledpin3,HIGH);
digitalWrite(Ledpin4,HIGH);
digitalWrite(Ledpin5,HIGH);

It is much easier for each pin to set the conditions direction; this will reduce all the if statements and make it very clear for each pin what the value should be.
First we make some variables to prevent duplication. Actually I normally like using bool but it is not a predefined type. Also I like to have the low range on the left and the high range on the right, and using parenthesis. I added the range 200-300, and lower/upper range:
int LDR_deger_min_inf_30 =  (LDR_deger <= 30);
int LDR_deger_30_80      = ((LDR_deger >  30) && (LDR_deger <=   80));
int LDR_deger_80_150     = ((LDR_deger >  80) && (LDR_deger <=  150));
int LDR_deger_150_200    = ((LDR_deger > 150) && (LDR_deger <=  200));
int LDR_deger_200_300    = ((LDR_deger > 200) && (LDR_deger <=  300));
int LDR_deger_300_1000   = ((LDR_deger > 300) && (LDR_deger <= 1000));
int LDR_deger_1000_inf   =  (LDR_deger > 1000);

Now you can create a table for each pin (which makes great documentation and a clear overview); I would add it in a comment (if you have no other documentation way):
// pin min_inf_30 30_80 80_150 150_200 200_300 300_1000 1000_inf
//  1     HIGH     LOW    LOW     LOW   HIGH      LOW     HIGH
//  2     .. (fill in yourself)
//  3     .. (fill in yourself)
//  4     .. (fill in yourself)
//  5     .. (fill in yourself)

Now you can write the pins one by one (I only did the first as example):
digitalWrite(Ledpin1, LDR_deger_min_inf || LDR_deger_200_300 || LDR_deger_1000_inf ? HIGH : LOW);
digitalWrite(Ledpin2, …);


text:
How to get air speed, which sensor to use?
I want to measure the airspeed on a flying vehicle and get the data with arduino. Note that, there will not be any control mechanism on the flying object, it will be flying mechanicaly/passively, I mean no flight controller or something like that will be present.
However, I could not understand whether there is a sensor to measure the airspeed directly or is airspeed something you analyze by using other datas(temperature, pressure etc.)
I saw there are sensors which are sold as "airspeed sensor" however it is not so common that I cannot find examples in which the incoming data is shown.
Anybody ever experienced with this issue may lighten me.
Thanks in advance.

please do not post at multiple sites ... https://robotics.stackexchange.com/questions/19830/how-to-obtain-airspeed-data

@jsotola why? I am not sure which community fits the best

Typically you want to use Pitot tube sensor


text:
ESP32-Cam No Response and Unable to Program - Timed out waiting for packet header
I recently purchased an ESP32-CAM but have had no luck in programming the board or getting any response whatsoever. I first tried to program it using the an FTDI programmer and the Arduino IDE (following the steps from this tutorial: https://randomnerdtutorials.com/esp32-cam-video-streaming-face-recognition-arduino-ide/).
I used this exact wiring diagram:  but got the Timed out waiting for packet header error message. This was with the jumper on the FTDI on the 3.3V section.
Other things I've tried:
-Moving jumper to 5V, powering ESP from 5V pin
-Powering ESP from external 5V source (Arduino pin)
-Powering ESP from external 3.3V source
-Switching computers (Linux and Windows)
-Programming board directly from Arduino (bypassing FTDI)
-Various combinations of pressing/holding reset button during flash process
The other thing is that there is no LEDs that turn on when the board is powered. I couldn't find a concrete reference online that said an LED turns on when the device is on, but I assume the one LED would at least flash or something. Also monitoring the serial output with putty during boot did not yield any output. I'm all out of ideas and I am just starting to suspect that the board is completely dead. Any ideas would be appreciated, thank you.

the FTDI can't supply enough current for the ESP32 from the 3.3 V pin

@Juraj was right, connecting 5V to VCC worked! Seems like the diagram above is wrong then because the pin labelled 3.3V on the ESPCAM32 is just an output pin. The only issue I have having now is that my board is extremely hot when doing it this way, too hot to touch in most parts. Is this due to this connection or a different issue

so I was not right. in the schematic Vcc pin is connected to both 5 V and 3.3 V. is there some jumper next to the Vcc pin, which I can't see on photos? use 5 V pin to power the board over voltage regulator. schematics from Adriano's link https://github.com/SeeedDocument/forum_doc/blob/master/reg/ESP32_CAM_V1.6.pdf

there are solder bridges labeled 3.3 V and 5 V next to Vcc pin

Yes I was going to say VCC has a bridge to 3.3V and 5V so it is likely an additional output based on the input power. I am still having issues with this chip, I was able to upload the one time by connecting 5V from FTDI to VCC on ESP. Now that is no longer working and it seems like the device is trying to boot but failing (I can see jumbled up output on a serial output when it tries to boot).

I'm not sure if maybe it is not getting enough power, I think I'll try powering it with a lipo to give it more current, and maybe slightly above 5V, like 5.3 or so since there is a regulator. The yellow square with the +/- is also lighting up, when powering now, not sure if this means low voltage or something. Couldn't find any documentation on that.

to run the sketch remove jumper from io 0. by yellow light you mean the camera's flash light? on USB it should not have problem with current draw, but the manual recommends capacitors on 5 V Vcc to cover current draw spikes by WiFi

Yes I have removed the jumper from io 0. Yes it is quite bright so it is probably the camera's flash light. Weird that it worked to upload once then with the same setup it hasn't worked since then.

to upload wire io 0 to ground again

Yes I have been toggling to io wire appropriately. I think the board is just bricked I ordered another one and I'll see if it works. If there are any other suggestions I'm all ears

esp32 can't be bricked. the bootloader is in ROM.

You're right. There is no LED when you power up your ESP32 cam. So this is normal.
Try to power it with the 5V, so you can power it from your USB instead of the 3.3V regulator of your FTDI. The ESP just need 50mA when in programming mode, so it should not be a problem for your FTDI.
Do you see anything on your serial output? Once you connect it in this way, you should set the baudrate to 115200 on your serial terminal and see some characters.
Then, try to program it.
Once you see the output "...___...", press the reset button! Since you are just connecting RDX and TDX, you have to manually press "RESET" on your ESP32 module.
At this point the ESP will reset and enter in the programming mode.

io 0 is wired to ground on the picture, so any reset or power-up will put the esp32 in flashing mode forever. no need to wait for ...___...

@Juraj: if he get the "Timed out waiting for packet header error message", the ESP is not in flashing mode or the RX/TX are inverted. If he get some characters on the FTDI, then the RX/TX are connected in the right way and the ESP is not in flashing mode. I can't see any other reason why it should not be able to connect.


text:
unable to read RS232 output on Arduino mega with MAX232 shield
I am trying to read data from an RS232 equipped sensor using a serial monitor connected to an Arduino Mega with RS-232 shield but I do not receive any data.
I am unable to detect the exact cause of the problem, as it only occurs when combining sensor and RS232shield/Arduino, while communication works as expected when testing them separately
What works:

Connecting the sensor to a computer with a RS232-USB converter cable.
Passing data from the computer through the USB-RS232 converter cable to RS232 shield and back through Arduino USB output.
Connecting the RS232-pin 2 to port 10 using {SoftwareSerial} library with inverted logic.

What does not work:

Passing data from the sensor to the computer via the MAX232 and Arduino.

The setup:

Arduino Mega 2560
Seeed RS232 shield (MAX232 based)
Sensor with RS232 output (57600 8N1)

I have connected the RS232 output of the sensor to the shield using an M-M gender changer. The shield and Arduino are connected with three wires: GND-GND , 5V-5V, 232_TX-RX1), and the Arduino connects to a Macbook via USB. The serial monitor on the computer is set to 56700 baud.
I use the following sketch to transfer data from the RS232 shield to Serial:
void setup()
{
// Open serial communications at 5700 baud
    Serial.begin(57600);
    Serial1.begin(57600);

// Check whether Serial1 is active
if (Serial1.available())
     while (!Serial1) {
        ;
    }
    Serial.println("Serial 1 is active");
}

void loop()
{
    if (Serial1.available()){
    Serial.write(Serial1.read());
    }

}

Does your sensor require hardware flow control signals that the shield doesn't provide?

I have solved the above and will share the answer as it may be of help to others:
As the Tx indicator LED on the RS232 shield would not light up when connected to the sensor, I checked the voltage difference between pin 2 (Tx) and pin 5 (GND) of the RS232 connector. This turned out to be only 5V, indicating that the protocol used is TTL-RS232 rather than 'true' RS232.
Due to the low voltage, I have connected the RS232 Tx and GND pins directly to the Arduino. With Tx connected to digital port 10, I used the SoftwareSerial library with logic inversion to read the data: SoftwareSerial mySerial(10, 11, 1).
This works!

this is not an answer to the question, because the answer uses information not mentioned in the question. what sensor is it?


text:
Counter on my coin acceptor goes up without a coin input, any advice?
I'm working on a project that makes use of a CH926 coin acceptor. The problem we're having is that when I read the serial monitor, the coin value is continuously going up and adding credits when it's supposed to remain at 0 until a coin Is fed into the acceptor.
We've tried a different coin acceptor, different codes, arduinos, wiring, resistors, breadboards, the lot. nothing seems to be solving this problem and we can't determine why, it had been working fine until we tried to tidy up our wiring and untangle it.
we're using a basic code that had worked fine up until we had the issue of the counter value no longer remaining at 0:
const int coinpin = 2;
const int ledpin = 3;
const int targetcents = 100;

// Variables
volatile int cents = 0;
int credits = 0;

// Setup
void setup() {

  Serial.begin(9600);
  attachInterrupt(digitalPinToInterrupt(coinpin), coinInterrupt, RISING);
  pinMode(ledpin, OUTPUT);

}

// Main loop
void loop() {

  // If we've hit our target amount of coins, increment our credits and reset the cents counter
  if (cents >= targetcents) {
    credits = credits + 1;
    cents = cents - targetcents;
  }

  // If we haven't reached our target, keep waiting...
  else {
  }

  // Debugging zone
  Serial.print(cents);
  Serial.print(" cents toward current credit and ");
  Serial.print(credits);
  Serial.println(" credit(s) earned so far.");
  delay(1000);

  // Turn off LED
  digitalWrite(ledpin, LOW);

  // Now, write your own cool code here that triggers an event when the player has credits!
  if (credits > 0) {
    // Play music?
    // Spin up a motor?
    // Start a game?
    // It's up to you!
  }

}

// Interrupt
void coinInterrupt(){

  // Each time a pulse is sent from the coin acceptor, interrupt main loop to add 1 cent and flip on the LED
  cents = cents + 1;
  digitalWrite(ledpin, HIGH);

}

any advice on what may be causing this problem?
cheers

Sounds like a floating input. Check your pullup / pulldown resistor on coinpin.

In addition to what @Majenko said, I have the following idea: Since the Sensor is powered by 12 V I guess you power it externally. Have the external power and the Arduino a common ground connection? I.e. did you connect the GND of the external power and a GND Pin of the Arduino.  Perhaps you did it in your first setup but forgot it after rewiring.

if the coin acceptor worked until you tidied up the wiring, then why are you posting code? ... why did you say nothing about the wiring?

"...it had been working fine until we tried to tidy up our wiring and untangle it." Wait, what? Your hardware/software system was working fine until you made a hardware change (trying to tidy up the wiring) and now it isn't working, so you decide it must be the software? Why does that make any sense? If it worked fine until you made a hardware change, shouldn't you focus on hardware problems? You almost certainly messed up some of the wiring. Focus on that.

I'm also complicated by that. The advice I saw here was to connect a COIN wire also against an electric "R" 10K and connect  to the second hole on the left in the Arduino "IOREF" now it works.


text:
reading micro SD card directly from PC
Is it possible to read a microSD card (on a breakout) through the USB port on the arduino? or perhaps another USB port I could attach to the breakout?  Basically, I would like to read data off the card with my laptop without having to go and remove it each time!

yes, that is possible

@jsotola Really? I wonder how (I thought the Arduino did not support USB to be used within a sketch, at least by default).

@MichelKeijzers, use the serial connection for the data transfer ... the OP inquired about the possibility of data transfer ... i do not see a requirement to emulate a flash drive

@jsotola ok than I think we have about the same idea (I deleted my answer based on your comment, now undeleted, shoot at it if it is incorrect though).

doesn't every PC have a SD card reader?

@201, Just in case it is not clear from the comments or answers:  USB contains many different protocols.  The Arduino uses the USB serial protocol.  An SDCard uses the USB mass storage protocol.  Not many, if any, USB peripherals can switch between protocols. I see you have not picked a correct answer yet.  If you want me to elaborate in yet another answer - add a comment stating so.

@Juraj Probably yes, but I think he does not want to remove the SD card ... actually in my project I also am thinking about building the SD card somewhere inside the device (thus not accessible from outside) because it makes building it in an enclosure much easier.

@MichelKeijzers, In my project I show/download the files from SD over a web server

@juraj sounds like a great idea!

@MichelKeijazers can you share the program with me?

@st2000 another protocol like SPI right? can you give me more info about how to do this?

@201, I think Majenko answered your question the best.  But, to add a bit, for complex protocols, there are physical layers / upper layers (USB) and lower layers (USB serial or USB mass storage & others).  The SDCard will need to use USB mass storage and the Arduino interface always uses USB serial.  Yes, at the SDCard one of two possible physical layers is SPI.  But by the time you get to the USB  port, an SDCard is using USB mass storage.  And, unfortunately, that is not what the Arduino supports on its USB port. The Arduino is of course supporting USB serial.

@st2000 So,it is possible to use SPI  to make connection between SD card and Arduino serial, right? the project i'm working on demands the last year's data stored in SD card and show it on PC without ejecting the SD card from shield data logger... it sound complicated to me...

Although, I think i found the answer, i can just ask the serial port to write the file saved in SD card for me with this command : Serial.write(dataFile.read());

so here is another question... can i save data for along time in my SD card? for example for one year?

This web site claims ~10 years.

@st2000 thank you so much

It would be very useful, but afaik this is not possible, since the Arduino sketch you write communicates to the PC via the serial interface only.
The IDE/Arduino driver can use the USB to write your sketch and use the USB for communicating, but for sketches the USB (as direct medium) is not possible.
The SD card will not show up as a specific drive/map/folder on your PC.
Since you want to read the SD card, write in your sketch code to transmit the file(s) you want to send to the PC, to transfer them by UART, and on the PC write a program that reads the serial port and processes it.

In general that's possible. But you can't read the sd card through the arduino's usb port. Instead you have to read the sd card via another protocol, e.g. SPI (look for the apropriate library) and send it to the pc via serial. You'll need software on the pc side to write the content that was read from the arduino to a file.
Take a look at the SD card tutorial to see how to read it.

so, if i want to lets say read the last year history of my data from data logger, can i use SPI to make this connection between SD card and arduino? do you have an example code that may be useful?

There are examples and tutorials out in the internet (I found one for you). But may I ask why you want to use an arduino? Don't you have an sd card reader to use with usb on your laptop?

@201, and how is it wired for data logging? not over SPI?

you're right, but that's actually the project i'm working on right now..

It can't be done with an Arduino, but it can be done with other microcontrollers. You need a microcontroller with a direct USB ("native") connection plus a USB stack that is capable of acting as a USB Mass Storage Device.  Something like the Teensy or chipKIT series of boards can do that.
Then you can write software that will, on command, detach the SD card from your normal sketch operation and re-attach it to the MSD device in the USB stack. You can then read and write to the SD card (though your sketch otherwise cannot access it) as much as you like - then "unmount" the MSD device and detach the SD card from it, at which point your sketch is then free to re-attach itself to the card and start using it again.
Note that the important thing here is that only one functionality can work at a time - either you can read and write the files on the card with your sketch, or you can export the device through MSD. Never both. That way leads to filesystem corruption and loss of data.


text:
Arduino UNO R3 + SIM800L / NodeMCU via Hadware Serial. Possible?
I'm using Arduino UNO R3 with NodeMCU and SIM800L module. I have to connect these two devices to UNO and make a serial communication between them: UNO<>SIM800L and UNO<>NodeMCU.
Can I use GPIO0 and GPIO1 of UNO (RX, TX) to communicate with one of above devices?
Thanks in advance.

RX/TX is used to communicate with the computer over USB

Okey, but if I do it this way:

Upload program first.
Power off uno, disconnect from PC and then power ON.
Then connect for example SIM800L to GPIO0 and GPIO1.

?

yes. do you know that you can use the NodeMcu as Arduino?

Why both Uno and NodeMCU? For wifi?

NodeMCU for using it as Web Server.

that is OK, but what for is the Uno? NodeMcu is a development board with 8 io pins, I2C, SPI, PWM, ....

If all you need to do is communicate between the NodeMCU and the SIM800L, what do you need the Arduino for?
Connect the SIM800L directly to the NodeMCU and program the NodeMCU to do whatever communication is needed for the SIM800L.


text:
SIM900 module not reading Sim Card
I am using GPRS Shield for Arduino Uno with SIM900 module on it. I am able to communicate with the module just fine (using AT commands), but whenever I try to use a command which involves sim card (like AT+CCID) I get a message saying ERROR and that's it (while AT+CCID=? returns OK as it should).
So I wanted to ask can it be that I am missing out on some parameter on SIM900 module that would allow using sim card? And is it possible somehow to do a hard reset on all module's parameters (in the documentation a command ATZ is mentioned, but it doesn't seem to reset all parameters)?
Thanks in advance!

try the SIM card in a phone

The SIM card works just fine in my phone (it has PIN disabled as well). Also tried using different SIM cards on the SIM900 module, with same effects.

The "standard" modem reset string is AT&F0 - though whether the SIM900 supports that or not I have no clue.

Even after doing the factory reset with AT&F0 command, I get same results...


text:
Using usb port to communicate with standalone atmega328p circuit
noob here
So I managed to get my circuit to be a standalone circuit (as pictured below). I want to use this circuit as an input to a game on my computer. What I want to know is could this micro-usb breakout board https://www.diyelectronics.co.za/store/breakout-boards/2414-micro-usb-power-switch-breakout-module.html
 be used to communicate with the computer. Where would the data pins (d+/d-) connect to the atmega328?
Any help will be most appreciated

ATmega328p is not a right choice for a game controller. from the ATmega family ATmega32u4 would be better (Arduino Leonardo and Micro). it has native USB with HID capability. but it is not available as DIP package

@Juraj So I would need a breakout board for the ATMEGA32u4?

Arduino Micro is a breakout board for 32u4. Micro Pro is even more compact (without the ICSP header)

@Juraj Ah okay, I will consider this option: thank you.

as I read in comments that it is a controller for a game you develop, then you can of course implement a basic Serial communication between your sketch on Arduino and your PC application

@Juraj I wouldn't be able to use the Atmega328 though right? If I want serial communication?

not without an USB adapter chip

@Juraj okay in that case it might be better if I use bluetooth then. Thank you for your help

The ATmega328 does not have any native USB capability, so there is nowhere appropriate to connect D+/D- to the ATmega328.
Assuming you are emulating an Arduino Uno, then something like this:
https://www.jaycar.com.au/arduino-compatible-usb-to-serial-adaptor-module/p/XC4464
is what will come closest to mimicking the USB function on an Uno (ie a serial connection).
This shows how such a device would be connected:
https://www.jaycar.com.au/usb-serial-converter

Oh, so basically without a usb to serial adaptor, this won't be possible? Thank you for saving me time @user85471

Yep. Long answer is that there may be a software USB implementation that allows this but you're better to look at something like an ATmega32u4, which is what is on a Leonardo, but they only appear to come in surface mount packages (but breakout boards exist).

does the ATMEGA32u4 have native usb capability?  @user85471

Something else to think about, there are many USB protocols.  The linked to item in the answer likely uses a USB serial protocol.  Keyboards use a USB human interface protocol.  I assume gaming consoles which connect to computers using a USB port also use the USB human interface protocol.  So the linked to device may not work.

You need to look at the chip specifications here. In the specifications it says: "Complies fully with Universal Serial Bus Specification Rev 2.0".  However, note, that does not say what USB protocol is supported.  That is up to the software.  You need to do some leg work and figure out which USB protocol your game pad is using.  Or if you can use your keyboard as the gaming input.

@st2000 hmm these are all factors I hadn't considered, admittedly. Just to clarify, however, this circuit is the input to the game and the game is a game that I am developing. I am exploring communication types for my game and have explored bluetooth, now I want to see if i could use USB

Bluetooth like USB can contain many protocols. Listening to stereo, talking on the phone and using a keyboard all use different Bluetooth protocols.  You need to narrow your question down to the specific protocol your game will use.

@st2000 Also true. I have used the bluetooth module HC-06 before for a very similar project. How would I know what protocol that falls into?

I want to say "HC-06 Bluetooth serial..." which I just copied from the aliexpress web page.  Check this wikipedia.org page for a list of bluetooth protocols.  Most of the time, when people are creating projects, it is easiest to use the serial protocol embedded into Bluetooth or USB protocols.  But, as you might already know or have a feel for, sending music, for example, this way would not work very well.

There are way cheaper ones on eBay.
Search "USB Serial" on eBay.
In 2014, I used them without any issue.
You have to order few more than you need, because some of them are DOA.
It is an old question, still some people stumble on this question.


text:
How to get keyboard input to Arduino from the computer its plugged in to?
I have an Arduino Uno connected to my laptop and I need to get keypress info from the laptop's keyboard
with only the Arduino sketch and without any program running on the laptop.
Is there a specific library or some way of doing so?

As you wrote your question: No, you can't do this. How could a sketch running on the Arduino make the computer transfer keyboard input, if there is no program for this running on the computer?

I read this question and commented it earlier today. Did you delete it and ask again with the "no program" addition?

@Juraj, you are correct in your thinking ... i have also seen this same question earlier ... i commented about using Processing ... now the OP apparently wants to use a keyboard on a laptop that is shut down ... lol

@asaf, perhaps you could use a PS2 keyboard that is directly connected to the arduino

@Juraj it has been edited by an 'anonymous user'.

This sounds like a key logger -  which may be innocent, but is probably morally/legally dubious (especially if the owner of the PC is unaware that it is attached).

You can't. It's impossible.
Or not as you have requested it, anyway.
The Arduino can only talk over Serial, so you will have to have some software running on the PC that transfers data (however that data is generated) over serial to the Arduino to process.
The only other option will be to have one of the Arduino boards that is capable of acting as a USB Keyboard device, such as a Leonardo, plus either a PS/2 keyboard or a USB keyboard plus a USB Host shield. Your Arduino the receives the keystrokes from the keyboard, processes them, and sends the result on to the PC.


text:
Having problems compiling this code for NRF24l01 on stm8s103f3p6
It said it has mutiple libraries were found for "nRF24L01.h"
but i check the Ardurino libraries I can only found one.
And it work fine if I compile it to Arduino uno.

//Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

//create an RF24 object
RF24 radio(8,9 );  // CE, CSN

//address through which two modules communicate.
const byte address[6] = "00001";

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

  while (!Serial);
    Serial.begin(9600);

  radio.begin();

  //set the address
  radio.openReadingPipe(0, address);

  //Set module as receiver
  radio.startListening();
}

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

  if (radio.available())
  {
    char text[32] = {0};
    radio.read(&text, sizeof(text));

    Serial.println(text);

  }

}

Here is the error message
Arduino: 1.8.10 (Windows 8.1), Board: "STM8S103F3 Breakout Board"

Multiple libraries were found for "nRF24L01.h"
bash.exe: warning: could not find /tmp, please create!
 Used:
C:\Users\UserName\Documents\Arduino\libraries\RF24
C:\Users\UserName\AppData\Local\Arduino15\packages\sduino\tools\sdcc\build.10738/bin/sdcc sketch\receiver.ino.cpp

nul re12 -c -Ddouble=float -DUSE_STDINT -D__PROG_TYPES_COMPAT__ -E -MC -mstm8 -DSTM8S103 -DF_CPU=16000000L
-DARDUINO=10810 -DARDUINO_STM8S_BLUE -DARDUINO_ARCH_STM8
-IC:\Users\UserName\AppData\Local\Arduino15\packages\sduino\hardware\stm8\0.4.0\cores\sduino
-IC:\Users\UserName\AppData\Local\Arduino15\packages\sduino\hardware\stm8\0.4.0\variants\standard
-IC:\Users\UserName\Documents\Arduino\libraries\RF24
-IC:\Users\UserName\AppData\Local\Arduino15\packages\sduino\hardware\stm8\0.4.0/STM8S_StdPeriph_Driver/inc
-IC:\Users\UserName\AppData\Local\Arduino15\packages\sduino\tools\sdcc\build.10738/include
Mark re12:C:\Users\UserName\AppData\Local\Arduino15\packages\sduino\tools\sdcc\build.10738/bin/sdcc -c -Ddouble=float -DUSE_STDINT -D__PROG_TYPES_COMPAT__ -E -MC -mstm8 -DSTM8S103 -DF_CPU=16000000L -DARDUINO=10810 -DARDUINO_STM8S_BLUE -DARDUINO_ARCH_STM8 -IC:\Users\UserName\AppData\Local\Arduino15\packages\sduino\hardware\stm8\0.4.0\cores\sduino -IC:\Users\UserName\AppData\Local\Arduino15\packages\sduino\hardware\stm8\0.4.0\variants\standard -IC:\Users\UserName\Documents\Arduino\libraries\RF24 -IC:\Users\UserName\AppData\Local\Arduino15\packages\sduino\hardware\stm8\0.4.0/STM8S_StdPeriph_Driver/inc -IC:\Users\UserName\AppData\Local\Arduino15\packages\sduino\tools\sdcc\build.10738/include sketch\receiver.ino.cpp -o nul
cpp gefunden
In file included from C:/Users/UserName/Documents/Arduino/libraries/RF24/RF24.h:18,
                 from C:\Users\UserName\Desktop\mad\receiver\receiver.ino:4:

C:/Users/UserName/Documents/Arduino/libraries/RF24/RF24_config.h:143:30:
fatal error: avr/pgmspace.h: No such file or directory

compilation terminated.

exit status 1
Error compiling for board STM8S103F3 Breakout Board.

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

High likely this library is for Arduino only, not for your MCU

The sduino core is lacking any form of PROGMEM compatibility layer. Contact the maintainers of it.

the error is fatal error: avr/pgmspace.h: No such file or directory. ignore the 'multiple libraries' warning


text:
ESP32-CAM interfacing with CCS811+HDC1080+BMP280
I want to measure Temprature, Pressure, Humidity and CO2 in a room with ESP32-CAM & CCS811+HDC1080+BMP280
Since this module is combination of 3 sensors. Can I integrate it with ESP32-CAM over Software SPI ?

No. Those three devices are I2C devices, not SPI devices.
Using that is no different to using three individual sensors all wired to the same I2C bus.


text:
how to read arduino board info serial no programmatically
well I am try to make an project with original arduino. but I want to make this project unique. if my codes are copied and loaded another arduino board, my app should not work. how can make unique app, are there any idea? on Arduino IDE Tools> Get Board İnfo> SN look unique id. but how can read it programmatically.

You can't. The serial number is burned into the ATMega16U2 chip and is only available to the computer over the USB interface.  There is no method for you to get it from the UART interface that connects the two MCUs together.
To stop people copying your code there are two things you need to do:

Don't allow anyone access to the source code or any compiled code files, and
Enable the "code protection" facility of the ATMega328P.

The latter will stop people being able to read the code from the Arduino. It would also be beneficial to remove the bootloader and program the board directly. That way there is no other possible route for getting at your code.
You enable code protection by setting the correct fuse bits.


text:
Receive socket when in loop arduino (Interupt a while loop with a socket)
I'm currently working on an arduino project. Were the arduino is communicating with a NodeJS server via web sockets.
The socket connection is working fine and has no problems. But the problem I currently have is that I want to be able interupt an infinite while loop with a socket emit from the NodeJS server.
I found a page that had a solution for this problem but only with a button attached to the arduino.
Link to page (Interrupt with button)
This is the loop I want to be able to interrupt with a socket:
bool loopRunning = true;

void rainbow(int wait) {
while(loopRunning == true) {

      for(long firstPixelHue = 0; firstPixelHue < 3*65536; firstPixelHue += 256) {
        for(int i=0; i<strip.numPixels(); i++) {
          int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
          strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
        }
        strip.show();
        delay(wait);
      }
    }
}

I want to set loopRunning to false when I recieve a socket emit.
Anyone have any ides how I can implement this?
Page to the socket functionality that I use

There are two ways to handle events: interrupts (hardware triggered) and polling (software triggered). Interrupts are much more efficient but also more difficult to use. SocketIoClient uses polling.
The necessary part of polling is... polling. That is, many times per second, you (or your library) needs to check if anything interesting is happening.
With this library, you have to call SocketIoClient::loop() many times a second. That's why SocketIoClient::loop() exists. So it needs to be added to your outer for loop.
(If your delay(wait) takes too long, you may need to break it up into a series of several shorter ones, but I think you can get away with it in this case.)
Then all you need to do is use SocketIoClient::on() to perform an action when an event happens. There is an example in the documentation. You will need to make loopRunning into a global variable.

The problem is the while loop trapping execution.  When you have a small section of your loop that you want to stick in, you can do it two ways. You can do what you did with a while loop, that keeps execution stuck inside the while loop with nothing else happening.  Or you can let the loop function be the loop and use flags and if statements to decide what's running.
Imagine this code:
void loop() {
  if(loopRunning){
     // do the stuff in your while loop
  }
  else {
     // all the other stuff in loop that you don't want running during that
  }
  // all the stuff you want to run regardless, like listening to your socket.
}

When you do it like that you still get to have the stuff you were going to while loop to happen on it's own without the rest of loop, but you can also have some stuff that runs both ways.  That logic can be extended in all kinds of ways.  Maybe you want that part to always run but the rest of loop to be skipped when loopRunning is false.
void loop(){
   //  all the stuff that should run all the time (like your socket)
   if(!loopRunning) {
       // all the stuff you would put into a while(!loopRunning) code
       // but wouldn't be able to catch the socket.
   }
}

You'll also have to ditch the delay calls and go to a "Blink Without Delay" style use of millis if you really want to be responsive to your socket.  Those for loops are also blocking, you could have that code take one step at a time and wait to be called from loop to take the next step.  Google around for Arduino neopixel and non-blocking.  You aren't the first person to realize that the demo stuff for neopixels doesn't work out in larger programs.  It's not hack-and-paste code, it's just for demo.


text:
Using Arduino based OpenCR with USB Host Shield 2.0 to connect to PS4 controller
I am trying to use a PS4 controller with my dynamixel setup using the OpenCR 1.0 board. The USB Host Shield 2.0 library is used to talk to the controller, but the current library does not support Open CR 1.0, but it does support other ARM boards. Is it easy to modify the library to talk to Open CR? My guess is that it is just the SPI pins (and other pins) that need to be redefined, but any guidance regarding the same would be great.
https://github.com/felis/USB_Host_Shield_2.0
https://github.com/ROBOTIS-GIT/OpenCR

which library are you talking about ... questions like Is it easy ... are pointless ... it is easy for someone that can write a library, and not so easy for someone that can't even blink an LED

USB_Host_Shield_2.0.zip in https://github.com/ROBOTIS-GIT/OpenCR/tree/master/arduino/opencr_arduino/libraries


text:
Dotstar strip goes nuts when connected to MIDI piano
I've got a Dotstar strip, a piano, and an UNO(w a usb host shield).
I can get and properly translate data from the piano to the UNO, so I'm definitely getting the right information to the board. When i hardcode input values into my code it reacts appropriately, so I know my code works.
However, when I attempt to take data from the USB piano keyboard and light a corresponding LED, the whole strip lights up blue and green and flashes brightly between them. This happens before I even hit a key on the keyboard.
When I hit a key, the correct light lights up for roughly a milisecond before returning to flashing green or blue.
I feel like there's some electrical concept that I'm not getting- I've got the MIDI information correctly making it to the board, and it can correctly control the LEDs. I don't know where it could be getting the data that's causing it to do this.
I think I might need a resistor- I tried to set an AND gate from the SS pin and the data pin, but that didn't do anything.

Here's the AND gate setup I attempted.

Please include your code and wiring into the question by editing it

The USB host shield and the LED strip use the same SPI bus. The USB host shield has a cable select line, but the LEDs don't, so they're always listening to the bus, even when the USB shield is using it.
You'll have to add some logic gates on the data and clock lines to the LED strip to turn them on or off, depending on another cable select line for the LEDs.
LED Clock = NOT LED CS AND SPI CLK
LED Data = NOT LED CS AND SPI MOSI
If you're only using two SPI devices, you could do:
LED Clock = USB CS AND SPI CLK
LED Data = USB CS AND SPI MOSI
https://forum.arduino.cc/index.php?topic=644679.msg4363133
Edit: Judging from the image, you're asking the exact same question as the one I already replied to on the Arduino forum a month ago. Why do you ask the same question twice if you're not even going to reply?

Took me a month to get a chance to try it-thought you'd have long forgotten about it.


text:
Convert float to hexadecimal value
I am trying to convert a float value to a 4-byte hexadecimal value.
For example my input is: 58.5. My expected output is: 426A0000 or like 0x42 0x6A 0x00 0x00.
My program is:
void setup() {
  Serial.begin(9600);
  float z = 128;
  unsigned i;
  unsigned char *chpt;
  chpt = (unsigned char *)&z;
  Serial.print("Float Value             : ");
  Serial.println(z);
  Serial.print("4 Byte hexadecimal Value: ");
  for (i = 0; i < sizeof(z); i++) {
    Serial.print(chpt[i],HEX);
    //Serial.print(" ");
  }
  Serial.println();
}
void loop() {
}

My current output is:
Float Value             : 128.00
4 Byte hexadecimal Value: 00043

This value looks pretty correct to me. It is stored in little endian thou.
0x43000000 is the actual value.
Serial.print(x, HEX) truncates leading zeros. so 00 gets 0
So your output is 0 0 0 43 which corresponds to the little endian representation of the above.
Make yourself familiar with the floating point representation IEEE-754.
Also try the online FoatConverter.
Try the following:
char floatString[9];
sprintf(floatString, "%02X%02X%02x%02x", chpt[3], chpt[2], chpt[1], chpt[0]);
floatString[8] = '\0';
Serial.print(floatString);

Thanks for the reply @kwasmich If I input the float value say Float Value                  : 235.56 I am getting values like this.
4 Byte hexadecimal Value: 5C8F6B43 Any changes in the program that you would like to suggest to obtain the result as 436B8F5C

I just added some sample code that should give you what you wanted in the first place.

printf is a powerful tool. %02X means, print the value as hex (x) with at least 2 places width (2), padded with zeros(0).

Thanks a lot!!!!!!!!!!!!! I as able to get my output. But then I am manually entering the float values. What should I change in the program so as to input a float value from Serial monitor and get the output in serial monitor?

I don't have a ready made solution for that. But the steps would be similar but in reverse. Use String string = Serial.readString(); to obtain the entire string in one block. Use sscanf(string.c_str, "%02X%02X%02X%02X", &chpt[3], &chpt[2], &chpt[1], &chpt[0]); to transfer the read hex values into the byte array. Something like that.

Thanks it helped me

You're welcome. Consider accepting my answer as the solution to the problem and let others know your question has been solved.

Sure ... !!! It has been solved and it worked very well


text:
How to upload file from SD card by Micro SD adapter to ftp server using Filezilla?
I use Arduino Mega 2560 to send a file stored in a micro sd by a module "Micro SD adapter" to ftp server. I use the sim800l evb v2.0 module and I proceeded as follows:
I insert the AT command :
AT+SAPBR=3,1,"CONTYPE","GPRS"

AT+SAPBR=3,1,"APN","internet"

AT+SAPBR=1,1

AT+FTPCID=1

AT+FTPTYPE="I"

AT+FTPMODE=0

AT+FTPSERV="197.158.86.105"

AT+FTPPORT=42

AT+FTPUN="user"

AT+FTPPW="password"

AT+FTPPUTNAME="test.txt"

AT+FTPPUTPATH="/"

AT+FTPPUT=1

Results :
+FTPPUT:1,62

sometimes +FTPPUT:1,63
or +FTPPUT:1,64
or +FTPPUT:1,65
or +FTPPUT:1,78
what do I have to do. Please, can anyone help me? thank you

Maybe the next step is to send the data? I don't see what a load of AT commands have to do with an SD card adaptor and an Arduino. Do you have some kind of (unspecified) GSM module attached? Or a network device? Please give us all the information, not just a few random snippets.

Indeed, I'm sorry, yes I forgot to mention that I use the sim800l evb v2.0 module

And what does the datasheet or manual for that module tell you about performing an FTPPUT session?

yes, I have the AT command manual and I applied it

But it does not work :
62 DNS error
63 Connect error
64 Timeout
65 Server error
78 Upload error

Well, then you have some pointers to start debugging your connection.

thank you, exactly, I am aware of the bugs but I don't know how to proceed

Check some points: Is there a FTP server running on the server device "197.158.86.105"? Or just a ssh server for sftp? Are you allowed to used a IP address instead a FQN like "ftp.example.org" with the command AT+FTPSERV.  The standard ftp port is 21. You use 42 is that intended? I don't see something like AT-FTPOPEN or AT-FTPCONNECT. Is this done implicitly or did you forget it? (I don't say there are such commands. But normally you have to connect to a ftp server and to establish a session.)

Thank you for your attention. As far as I know, no, no FTP server isn't running on this device. Since I don't have a domain name yet, so I have to mention an IP adress but I'm going to take a closer look. And yes, the use of port 42 is normal. AT+FTPPUT= 1 is the command that starts the connection to the server. Thank you

So if there is no ftp server running on the target, the problem is quite clear. Also, using port 42 for ftp is not "normal", as mentioned by Peter Paul Kiefer you should try port 21 or 22 (sftp) once you have a server running.

Thank you, I'm going to try.


text:
Reliably reloading the calibration data of IMU BNO055
I am using the BNO055 IMU and the Adafruit Library.
I want to store the calibration data and load them after the microcontroller is powered off and repowered on.
The Adafruit Library provides an example for storing and restoring but, in actual facts, it does not work. It is always required to recalibrate the magnetometers, but even doing so, the library reperform the whole calibration including the accelerometers.
I would like to simply restore all the calibration data (including the magnetometers) so that no calibration needs to be performed when the IMU starts.
I have read a massive amount of posts on the argument, but I really could not figure out how to reliably load all the calibration data at boot and avoid recalibrating them.
Is there anyone who succeeded and can please share the code?

Possible duplicate of After restoring the BNO055 offsets to the sensor the calibration values are all 0

Actually no, it is not a duplicate at all. Indeed I am using a Teensy and Arduino. Also, that post does not show code.

read the answer in the duplicate, not the question. there is no way to avoid automatic calibration. the stored calibration is only used while the automatic calibration finishes. don't waste your time on it.

Thanks. Then what I am supposed to do? The last comment says "I would ignore the calibration. The sensor handles it. After power-up make same movements and the sensor calibrates itself. " So should I avoid any calibration in the end? And should I avoid storing the calibration in the EEPROM at all?

do you try to solve some problem or you only thought that you must handle the calibration?

I just want to have the calibration performed at boot automatically with the data previously stored. Any suggestion/code?

https://github.com/adafruit/Adafruit_BNO055/tree/master/examples/restore_offsets

I found the solution. It is enough to add a function that when reperfoming the calibration of the magnetometer, checks ONLY if the magnetometer is calibrated (while the calibration for the accelerometer and gyroscope is reloaded from the EEPROM).
void performMagCal(void) {
  uint8_t system, gyro, accel, mag;
  system = gyro = accel = mag = 0;

  while (mag != 3) {

    bno.getCalibration(&system, &gyro, &accel, &mag);
    displayCalStatus();
    Serial.println("");
  }

  Serial.println("\nMagnetometer calibrated!");
}


text:
esp32 with Neo6M gps gives no data
I am simply using the following code
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  // set the data rate for the HardwareSerial port
  Serial2.begin(115200);
}

void loop() {
  while (Serial2.available() > 0)
    Serial.write(Serial2.read());
}

the Connection is as follows
pin 16(D27) of esp32 - > Tx of Neo6M
pin 17(D14) of esp32 - > Rx of Neo6M
Now I am not getting any data in the serial monitor. The same module works with arduino with software serial.
I am completely new in this thing and office is keep asking about the progess.

What exact ESP32 board do you have, and why have you tagged the question "Arduino UNO"? Is there an Uno in the mix as well?

I am using esp32 dev module. I tagged uno as the same pattern worked in uno. No uno is associated.  so let me remove it.  this one I am using : https://lastminuteengineers.com/wp-content/uploads/2018/08/ESP32-Hardware-Specifications-USB-to-TTL-Converter.jpg

The default baud rate for the Neo-6M is 9600, not 115200. Have you reconfigured it to work at 115200 baud?

Did not noticed that. But I just modified the baud rate and still nothing. current baud rate is 9600

The pins you are using are the ones actually labelled TX2 and RX2?

Yes that I can check from the librarary too. But should not they work simply? I mean I lost here completely.

are you suggesting me to connect me the module 6M with TX2 and RX2 ? Sorry for souding dumb but my office is keep asking I am loosing myself too.

The default pins for Serial2 are GPIO16 and GPIO17 (D16 and D17) not pins 16 and pin 17. Those pins are helpfully labelled TX2 and RX2.

okay! so I have connected the Tx of neo6m to rx2 and Rx of neo 6M to tx2. hope this is the wiring?  now the same code in with baudrate 9600 is uploaded. still nothing. I should get NMEA raw data in the serial monitor?

As long as you have power and ground connected too, that should be fine. There are other possible baud rates that could be configured on your module as default - you could try 4800, 38400 or 57600.

I guess the esp32 3.3v is not sufficient to power up the neo6m

It's possible. I am not sure off hand how much it needs. It shoudn't need much, it's receive only.


text:
Can you use a 128 pin LCD on an atMega?
I found a couple old calculators and their LCD's have about 130 pins.
I was wondering if I can build an LCD driver to reduce the number of I/O pins, because I don't want to use like 14 I/O extenders; or can I make 1 huge extender?

Shift registers might be easier and cheaper as you don't need input capability like with IO extenders

What kind of LCD is this? Is each pin connected to one segment/pixel, and all of them share the same backplane? Or is this a row-column-matrix? Please keep in mind that you need to apply alternating voltage to LCD because DC will be bad for it.

It is a 32x96 dotmatrix the entire thing running on 1 1.5v lr44

This answer assumes that each LCD segment is controlled by a separate pin (see comment of Juraj).
With a 74HC595 (shift register) you can use SPI to control 8 outputs.
You can daisy chain 4 of them to get 32 outputs with just the SPI pins, to get 128 pins. I assume two pins are for GND and VCC. If you need more than 128 GPIO output pins, than use 5 or more sets of daisy chained shift registers.
Now, since these shift registers use SPI, you can use the slave select to use multiple sets of daisy chained shift registers. I never tried this myself though.
The pins (except GND/VCC) you use is:

3 SPI pins (MISO, MOSI, CLK)
4 SS pins (one for each set of 4 daisy chained shift registers)

The idea is:

Set SS pin to the first set of 4 shift registers
Write 32 outputs for the first 32 segment output pins (using the 4 shift registers of the first set)
Set SS pin to the next set of 4 shift registers
Write 32 outputs for the next set
Continue with the next 2 sets (so you can use 32 * 4 = 128 pins)
In the next cycle, start with step 1 again

this assumes that one pin controls one segment on a LCD with digit segments

@Juraj True, I added it in the answer, thanks. I would think it's otherwise anyway, why would you create a nontrivial protocol and still using 130 pins. And thanks for improving my answer.

it could be a matrix, but now as I think about it, it doesn't change the answer

@Juraj That would make a lot of segments possible (having an X-Y matrix). But indeed only the algorithm to fill the pins is more complicated. I expect like e.g. 10 digits * 8 segments = 80 pins, and some extra for the items/words around (since it's an old calculator).

I see i was thinking of using 8 mcp23017 chips from 2 pins to get to 128 and use 15 for matrix buttons which leaves me 36 pins

That might also be possible, I don't have used MCP23017s so far. In principle the 74HC595 are typically for adding outputs, however, I found out the 74HC595's can only source 70 mA, so in case of 8 segments you could use e.g. an ULN2803. However, as the busybee has written, you might not be able to use these at all, but a specific LCD IC/driver, since LCD uses AC.


text:
Multiple Loops to control on and off LEDs
I'm new here. I have tried to write a simple code to turn LED's and light them up in specific pattern and being able to switch it off while in loop. So far I've managed to either get them constantly flashing in pattern and not responding to button or when I wrote in seperate void loops each function IDE Arduino throwing me error 'expected 'while' before 'loop1'' and I'm completely stuck and not got a clue what's the problem with code. Anyone could help?
Here's a code:
const int ledPin =  2;
const int ledPin1 = 3;
const int ledPin2 = 4;
const int buttonPin = 5;

int programState = 0;

int buttonState;
long buttonMillis = 0;
const long intervalButton = 300;

long ledMillis = 300;
const long intervalLed = 500;

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(buttonPin, INPUT);
  digitalWrite(buttonPin, HIGH);
}

void loop()
{
  unsigned long currentMillis = millis();
  buttonState = digitalRead(buttonPin);

 if (buttonState == LOW && programState == 0)
  do{
   programState = 1;
    }
void loop1(){
if {programState = 1 && buttonState == HIGH}
 do  {
   programState = 2;
    ledMillis = currentMillis;
    digitalWrite(ledPin, HIGH);
    delay(200);
    digitalWrite(ledPin1,HIGH);
    delay(200);
    digitalWrite(ledPin2,HIGH);
    delay(200);
    digitalWrite(ledPin2,LOW);
    delay(200);
    digitalWrite(ledPin1,LOW);
    delay(200);
    digitalWrite(ledPin,LOW);
    delay(200);
    digitalWrite(ledPin,HIGH);
    delay(200);
    digitalWrite(ledPin1,HIGH);
    delay(200);
    digitalWrite(ledPin2,HIGH);
    delay(200);
    digitalWrite(ledPin2,LOW);
    delay(200);
    digitalWrite(ledPin1,LOW);
    delay(200);
    digitalWrite(ledPin,LOW);
    delay(1500);}
 }
 void loop2(){
 if (programState = 2 && buttonState == LOW)

 do {
  programState = 2;
    digitalWrite(ledPin, HIGH);
    delay(200);
    digitalWrite(ledPin1,HIGH);
    delay(200);
    digitalWrite(ledPin2,HIGH);
    delay(200);
    digitalWrite(ledPin2,LOW);
    delay(200);
    digitalWrite(ledPin1,LOW);
    delay(200);
    digitalWrite(ledPin,LOW);
    delay(200);
    digitalWrite(ledPin,HIGH);
    delay(200);
    digitalWrite(ledPin1,HIGH);
    delay(200);
    digitalWrite(ledPin2,HIGH);
    delay(200);
    digitalWrite(ledPin2,LOW);
    delay(200);
    digitalWrite(ledPin1,LOW);
    delay(200);
    digitalWrite(ledPin,LOW);
    delay(1500);}

 else if  (programState == 2 && buttonState == HIGH)
 do
   {

    digitalWrite(ledPin, LOW);
    digitalWrite(ledPin1, LOW);
    digitalWrite(ledPin2, LOW);
  }
}
yield();
}

You are using the do function wrongly:
Like this:
do{
  programState = 1;
}

It should be something like:
do
{
  programState = 1;
} while (`some condition`);

Where some condition is a condition that repeat the parts in { and } in case some condition is true.
However, besides that, it does not make sense normally to assign a variable in a while loop as only statement, since it will be 1 after the first iteration and reassigning it again does not make the value different (programState stays at 1).
Also note that in most cases the following form is used (unless you always want the body to be executed at least once):
while (`some condition`)
{
  `statements`
}

Are you sure you need the do or while statement at all? Otherwise, try to remove the do statements and see if that is closer to what you need (I cannot map the code to your requirements). I have the feeling you want to use loops to prevent a lot of code duplication, for that you need to store the ledPin, ledPin1 and ledPin2 variables in an array and loop over them.
Another way is instead of e.g. the following code:
digitalWrite(ledPin, HIGH);
delay(200);

to create a separate function:
void setPin(int pin, int value)
{
   digitalWrite(pin, value);
   delay(200);
}

and call the function by:
setPin(ledPin, HIGH);

Now you can change all occurences of 'digitalWrite(some pin, some state); delay(200)' to the single statement above.
Also, I see there is a function yield that is not implemented.

Thank You :) I will follow Your advice and see where it takes me

In addition to using the do construct incorrectly, you are also using an approach that won't work.
You generally should not use a do-while statement in Arduino. That causes your code to "stick" in the body of the do-while statement while the while condition is true, which prevents the rest of your code from executing.
You also should not use the delay() function if you need to manage timing different things at the same time. (To make a more general statement, you should not use the delay() function at all. Forget it exists.) There are rare cases (like doing one-time setup of hardware in your setup() method.) where using the delay() function is appropriate, or very short intervals like timing ultrasonic pulses, but the delay() function ALWAYS causes your program to come to a complete halt until the delay interval has passed.
You should search on "Arduino blink without delay" and study the example project you find. It outlines how to use the millis() function to keep track of timing. With that approach you can time multiple things at the same time. (You'd have multiple "fire time" variables that would remember the millis() value at which you want a change to occur, and you get that value of millis(), your code would trigger the change (toggling an LED, for example) and then update that "fire time" variable.


text:
Compilation Error - Yellow LED blinking as I have installed & connected Arduino UNO board to Windows XP PC
This is the first time when I have installed Arduino IDE (arduino-1.8.10-windows.exe) in my Win. XP SP-3 OS and it seems that the Arduino IDE software installation is successful without any hitch.
After restarting the PC, connected it  with Arduino Uno board through USB-Printer cable provided with the board and then selected Arduino Uno, Selected Port: COM3 (Arduino/Genuino Uno) - as I have verified in the Device Manager that the Arduino Uno installed in COM3 port.
As soon as I have connected Arduino Uno board to my PC, the yellow LED started blinking slowly. As I have tried uploading the sketch -  File>Examples> 01.Basics>Blink - there is an Error message that says, "Error compiling for board Arduino Uno" - even though the yellow LED still kept blinking without a reasonable act from my side.
So, where have I gone wrong - either in performance or in understanding? And is there any suggestion for making things right?
I thank you.
// the setup function runs once when you press reset or power the board
void setup(){

  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);

}

// the loop function runs over and over again forever
void loop(){

  // turn the LED on (HIGH is the voltage level)
  digitalWrite(LED_BUILTIN, HIGH);

  // wait for a second
  delay(1000);

  // turn the LED off by making the voltage LOW
  digitalWrite(LED_BUILTIN, LOW);

  // wait for a second
  delay(1000);

}

Please edit your question to add the sketch or any new information, rather than putting it in comments. Even the "Auto format" feature in the IDE couldn't fix the code mis-alignment. I've formatted your sketch and added it to the question. Using comments before the line of code and proper line spacing make the code easier to read and find problems.

The yellow LED may be flashing because there may be a "Blink" LED program pre-installed on the Arduino.
To diagnose the "Error compiling for board Arduino Uno", we need to see the sketch you are trying to upload, and detailed error messages. If you go to Arduino > Preferences, check the "compilation" and "upload" checkboxes beside Show verbose output during:. Display line numbers is another checkbox you could enable.


text:
I need some help getting data from a rangefinder
I have wired up my range finder (CJVL53L0XV2) to a breadboard for testing and have run the arduino example code for the rangefinder. The rangefinder works, but I do not know how to take the distance that the range finder shows on the serial monitor, example: distance measured 44mm, and turn that information into a variable that the rest of my program could use.
I am not sure how to "grab" data from the sensor and turn that data into a variable that I can then manipulate. I have tried to dissect the example code, but it seems to be taking data and using functions that do not exist anywhere but in some files in the arduino library that I can't identify or access.
Below is the code that I have been trying to reverse engineer.
[code]
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
int pbl = 9;
void setup() {
  pinMode(pbl, OUTPUT);
  digitalWrite(pbl, HIGH);
  delay(1);
  Serial.begin(115200);

  // wait until serial port opens for native USB devices
  while (! Serial) {
    delay(1);
  }

  Serial.println("Adafruit VL53L0X test");
  if (!lox.begin()) {
    Serial.println(F("Failed to boot VL53L0X"));
    while(1);
  }
  // power
  Serial.println(F("VL53L0X API Simple Ranging example\n\n"));
}

void loop() {
  VL53L0X_RangingMeasurementData_t measure;

  Serial.print("Reading a measurement... ");
  lox.rangingTest(&measure, false); // pass in 'true' to get debug data printout!

  if (measure.RangeStatus != 4) {  // phase failures have incorrect data
    Serial.print("Distance (mm): "); Serial.println(measure.RangeMilliMeter);
  } else {
    Serial.println(" out of range ");
  }

  delay(100);
}
[/code]

use a lookup table ... distance to number of rounds

please reduce the amount of text in your post ... you can delete the first and third paragraphs ... also delete the bottom half of second paragraph, starting with The way I would like the rangefinder .... that should leave a simple, to the point question.

jsotola, Thanks. I have edited my question to get to the point more quickly.

Perhaps if you add the code to the question, we can suggest what to add/change.

My apologies. The code I have been trying to work with is just the sample code. I posted it with my question. Thanks!

measure.RangeMilliMeter was the key to it all. After experimenting for several hours, I finally got it.


text:
Trying to measure distance using an ultrasound sensor
I am relatively New to Arduino and need your help. Actually i made a code and the problem is that the ultrasound sensor doesn't work at all. It isn't displaying the distance between the object and and the sensor. Can you help me please!
Here is my code:
note: the code has some motor cotrol commands
int enableBridgePin = 10;
int forwardPin = 11;
int backWardPin = 9;
int tickPin = 2;
const int trig = 5;
const int echo = 6;

int dt;
int distance;

float rotationSpeed[50];

void setup() {
  pinMode(enableBridgePin, OUTPUT);
  pinMode(forwardPin, OUTPUT);
  pinMode(backWardPin, OUTPUT);
  pinMode(trig, OUTPUT);
  pinMode(echo, INPUT);
  Serial.begin(9600);

  digitalWrite(forwardPin, LOW);
  digitalWrite(backWardPin, LOW);

  interrupts();
  digitalWrite(enableBridgePin, HIGH);
}

void loop() {
  analogWrite(enableBridgePin,255);

  digitalWrite(forwardPin, HIGH);
  digitalWrite(backWardPin, LOW);

  distancefonction(dt, distance);
  if(distance>5){
   detachInterrupt(digitalPinToInterrupt(tickPin));
   digitalWrite(forwardPin, LOW);
   }

}

int distancefonction(int dt, int distance)
{
  digitalWrite(trig, LOW);
  delayMicroseconds(2);
  digitalWrite(trig, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig, LOW);
  dt = pulseIn(echo, HIGH);
  distance = 0.034/2*dt;
  Serial.println(distance );}

reduce the sketch to minimum to measure and print the distance and then test it.

You have declared int distance outside of any method. That means it's available from all methods. Some people call it a global variable.
However, you have a method int distancefonction(int dt, int distance) which receives int distance as a parameter. This results in an ambiguity: if you refer to distance within the method like
distance = 0.034/2*dt;

should this now refer to the parameter distance or the global variable distance?
The answer is: you can't decide. The C/C++ standard has decided for you and the answer is: the parameter will take precedence and thus hide the global variable. This thing is also called "shadowing".
What does it actually mean?

The global variable distance has an undefined value at the start of the program. Let's assume the value is 0.
distancefonction() is called, passing distance as a parameter. This will create a copy of the value 0 on the stack.
the function will calculate the distance and update the variable on the stack.
The Serial.println() statement within the function accesses the variable on the stack and will print the correct distance.
Once the function is complete, the code in loop() will access the global variable distance, which still has the old value, because only a copy has been updated.

What is the solution?
Of course there are several solutions.

The simplest fix is probably to remove the parameter int distance from distancefonction. Thus the function will not receive a copy and instead operate on the global variable.
Another solution is to let distancefonction return the actual distance. The method signature already indicates that you wanted to return a value: the intfrom int distancefunction(...) says that. At the moment, the function does not return anything. You could write return distance; at the end. This approach could eliminate the global variable completely.

"Some people call it a global variable." because if it is on the top of the project's main ino file, the it has global scope

thanks a lot for your help it worked! i actually returned the distance from the function.


text:
choosing prober controller to measure engin speed changes
In order to monitor engine speed changes in real time, sensor is detecting the motion of few magnets around a disk driven by the motor.
1st approach Hall effect sensor signal is regulated by LM393 comparative IC, resulting digital clean signal, connected as input to a selected pin then measuring the timing changes between of the signals to calculate the speed changes.
2nd approach is to connect hall sensor directly without modeling to a micro controller ADC, then process the digital noisy unclean signal which require much processing power than 1st approach.
Better approach are welcome, but the question is how to choose proper controller specs for such task

There is too much guesswork in trying to understand what you are asking.  Can you post some schematics, code and pictures?

The first option is way better than the second. Measuring a voltage with the ADC takes time and you don't really need the analog values in your code. (Though depending on the actual values you might not need a comparator befor it. The digital input pin acts as Schmitt Trigger. The only requirement for this is, that the signal range is greater than 0.3*Vcc to 0.7*Vcc.)
About the needed controller: That greatly depends on the speed, that the motor is running at (e.g. the frequency of pulses), and the way you are measuring it.

The easiest Arduino way is to attach an interrupt to the pin and increment a counter variable in it. Reading and resetting the variable in regular time ranges (using millis() will give you the pulse frequency and thus the speed. For this you don't need much extra functionality in the microcontroller. One with external interrupts or pin change interrupts is sufficient (almost all microcontrollers have those).
Another way is to utilize a hardware timer as counter. You can configure a timer of a microcontroller to get it's clock source from a pin. If you connect your sensor output to it, the counter will increment on every edge (falling and rising). The first timer of an Arduino is used by the Arduino core as time-keeper. You can use it to get the time component. Configure the second timer as counter, set it's value to zero, then start the timer and track the time passed using millis(). When the measurement time has passed, you read the counter value, reset it to zero and start a new measurement. While the hardware timer counts the pulses, you can calculate the speed with the number of pulses and the time passed and do whatever you want with it. This approach of course needs at least 2 timers (which most microcontrollers have, I think).

Of course the general speed of the microcontroller, meaning it's clock frequency, is also a concern. But this only becomes relevant, as you reach high pulse frequencies.
This answer is a general overview on how to go on. For a more specific answer, you should edit your question to also be more specific. For example you could include the expected pulse frequency.

Thanks chrisl for your adequate details, I'm concern if the hall sensor direct connection without LM393 will be sufficient so each changes will count.

on the other hand, I don't want to calculate only the speed, but also the real time changes "acceleration" that's why we put many magnet on the rotator not only one, to sense the changes in each rotation not every many rotations.

If it will work without the LM393 depends on the voltage levels of the signal. And what is important is the pulse frequency. What frequency do you expect?

frequency is below 1000 HZ, but my test for the Hall effect sensors available result in different voltage depend on the speed, lower speed means lower voltage

I didn't comprehend the difference between Schmitt trigger and comparator, but I noticed schmitt will keep only the larger wave while smalls will not be detected


text:
sending specific date's data from data logger shield to serial port
I was wondering if it is possible to save lots of data( exp: one year data) in data logger shield and then read them from serial port without ejecting the SD card... this part of my question is fine... the main subject is that i want to read specific date's data from the logger... To explain this better, lets say you have a humidity sensor and saved it's data for a year. Now you want to send the last 6 month's data to your phone via bluetooth. Is it possible?
Also, i wanted to use the circular buffer but that doesn't seem like a good idea because it's costly... any ideas will be such a great help.

how many lines are logged in one day?

Is it important? i wanted to lower the daily sampling, so maybe 2 times...

ok, it is not too much for one year. to copy part of the file to Serial you would read the file line by line from the beginning and start printing after you find the line with the requested start date.

I see a few questions (reading specific data from an SD) and the circular buffer; I think these are two different 'problems'.
Reading specific data from an SD
It depends how you save your data. Do you make one big file, or you create daily a new file for example?
Assuming the last, it's relatively easy, just sent the file contents of the files within a certain date.
In case you have a big file, you need to parse the file, in specific the time stamps you have to include in the file, and send everything within certain dates.
If this takes too long parsing, you could create a second file that contains the starting points (e.g. byte offset) for every day. So e.g. Jan 1 -> 0 means Jan 1 starts at byte 0, Jan 2 -> 3633 starts at byte 3633; you can use some kind of seek function to start reading the data file starting from date; and continuing also checking the end date's byte offset.
You can get the time stamp of a file:
void dateTime(uint16_t* date, uint16_t* time)
{
    DateTime now = rtc.now();
    // return date using FAT_DATE macro to format fields
    *date = FAT_DATE(now.year(), now.month(), now.day());
}

You can start reading from a certain position in a file by using the fseek function, see https://www.arduino.cc/en/Reference/FileSeek.
Circular buffer
This relates to sending bytes (via a peripheral/bluetooth). It is not costly at all. What you do is create a circular buffer (e.g. 50 bytes or whatever). Than you start writing bytes into it (which you copy from the SD file increasing the buffer space. Than you start sending bytes from it, decreasing the buffer space.
I never used Bluetooth, so I don't know how the packet (and size) is sent; if you can just sent packages of a certain or fixed length,  you don't need a circular buffer, just keep reading e.g. 50 bytes, put it in a fixed array, send it, and load it again etc until all bytes are sent.

The idea was to ask for any data history i want through mu cellphone... I wanted to make different files with specific time stamps but then if the period i want wasn't in the files it would be a problem...

And another thing i don't know is how can i specify a certain starting point for my files?

You can get the time by using:
void dateTime(uint16_t* date, uint16_t* time) { DateTime now = rtc.now();  // return date using FAT_DATE macro to format fields
*date = FAT_DATE(now.year(), now.month(), now.day());

Can i also get the period of different times?

So after you write a file (each day), or for the last time once per day, you can get the date back, although it might be even easier to write the date in the file name (data_yymmdd.log)

Not sure what you mean … if you need 5 to 10 December, just read out the 5 files and send them (?)

About reading not from the start, see https://www.arduino.cc/en/Reference/FileSeek

yes for example from 5 to 10 December. how can i do that?

If you have a separate file for each day, read the 5dec file (in parts of e.g. 50 bytes or so), and send each packet, than do the same with the 6dec file etc.

How can i save each data in their own file? for example for 1 week, 1 month, etc. I mean the data from 1 week should also be in the data for one month... can you help me with the code?

That depends, better make some commands that send the information you need (like start/end period).


text:
Trouble trying to turn a stepper while a button is pressed down
So i'm currently coding a little device that rotates a step motor round one 8th of a full revolution every time a button is pushed. the motor is attached to a question reel with 8 questions on it, each one is viewable through a little window covering the reel after each button press. the thing im concerned about is that if even one of the question sections is slightly larger or smaller than the others, it will cause the question to become misaligned with the window after a certain number of run throughs.
in order to combat this I want to have a back up code that simply rotates the stepper while the button is held down. this will allow me to manually reset the reel to its proper positioning should the questions become misaligned. im not achieving this however, and was hoping someone may be able to detect where the issues are in my code?
#include <Stepper.h>

#define STEPS 2048

Stepper myStepper(STEPS, 8, 10, 9, 11);

const int  buttonPinBlue = 6;

void setup() {

  myStepper.setSpeed(5);
}

void stepp() {

 myStepper.step(1);

  pinMode(buttonPinBlue, INPUT);
}

void loop() {

 if (buttonPinBlue == HIGH) {

  Serial.print("pin is high");

   stepp();
  }

}

also just as a side note, the stepper runs fine using the 'define steps' value and the speed that I've set here, the issue appears to be that the button press is not being detected

You don't set the pin itself:
Change
if (buttonPinBlue == HIGH) {

to
if (digitalRead(buttonPinBlue) == HIGH) {

Also you don't have to set the pin every time, only one time is enough: in function setup should be the following line (and it can be removed from the function stepp:
pinMode(buttonPinBlue, INPUT);

Note that if you want to use a 'click' to move to the next item, you have to debounce the button; on the Arduino site check for button debouncing: https://www.arduino.cc/en/Tutorial/Debounce

Ahhh that's sorted it, should have known that really. Thanks for your help!

I also aligned your code slightly (next time select it and press ctrl-k), to make it better, remove the empty lines and align the code nicer.

You're welcome (if it is the correct solution, upvote and accept the answer). Welcome to Arduino Stack Exchange.

I was thinking of a while loop since the title of the OP says "while" but this works just as well if the OP is only spinning a motor in the loop() method.

@KingDuken True, probably if he sees the motor is running he has a starting point how to proceed