text:
always detects same pin as HIGH even when its not connected
Im practicing with an arduino UNO board (I'm a begginer) and I'm trying to turn some LED's on depending on which analog pin is connected to 5V.
Here's my code:
int statusLed = 11;
int out1 = 2;
int out2 = 3;
int out3 = 4;
int out4 = 5;
int in1 = A0;
int in2 = A1;
int in3 = A2;
int in4 = A3;
int statusLedBrightness = 3;
int incBrillo = 3;
int fadeDelay = 5;

void blinkFade(int pin){
  analogWrite(pin, statusLedBrightness);
  statusLedBrightness = statusLedBrightness + incBrillo;
  if (statusLedBrightness <= 0 || statusLedBrightness >= 255){
    incBrillo = -incBrillo;
  }
  delay(fadeDelay);
  }

void wait(){
  digitalWrite(out1, LOW);
  digitalWrite(out2, LOW);
  digitalWrite(out3, LOW);
  digitalWrite(out4, LOW);
  blinkFade(statusLed);
}

void setup() {
  // put your setup code here, to run once:
  pinMode(out1,OUTPUT);
  pinMode(out2,OUTPUT);
  pinMode(out3,OUTPUT);
  pinMode(out4,OUTPUT);
  pinMode(in1, INPUT);
  pinMode(in2, INPUT);
  pinMode(in3, INPUT);
  pinMode(in4, INPUT);
  Serial.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (analogRead(in1)>=500){
    Serial.println("1: ");
    Serial.println(analogRead(in1)); //Print "1" and the read of pin A0
    turnOff();
    digitalWrite(out1,HIGH);
  }
  else if (analogRead(in2)>=500){
    Serial.println("2: ");
    Serial.println(analogRead(in2));//Print "2" and the read of pin A1
    turnOff();
    digitalWrite(out2,HIGH);
  }
  else if (analogRead(in3)>=500){
    Serial.println("3: ");
    Serial.println(analogRead(in3));//Print "3" and the read of pin A2
    turnOff();
    digitalWrite(out3,HIGH);
  }
  else if (analogRead(in4)>=500){
    Serial.println("4: ");
    Serial.println(analogRead(in4));//Print "4" and the read of pin A3
    turnOff();
    digitalWrite(out4,HIGH);
  }
  else{
    Serial.println("Stand By");
    wait();
  }

}

The problem Im having is when I connect a wire from 5V to any analog pin (A0 to A3) it always runs this segment of code:
Serial.println("1: ");
Serial.println(analogRead(in1));
turnOff();
digitalWrite(out1,HIGH);

By my understanding it's detecting as if it always was A0 the one that is connected to 5V but i dont understand why is this happening or how to solve it.
This is a screen capture of serial monitor when 5V is connected to pin A2. It should print "3:" and the reading
[]
1

You're not showing your schematic but I'm sure that you are simply leaving the Ax pins OPEN when you are not connecting them to your +V line.  In that case they are "floating" and as such they can float HIGH or LOW or just about anywhere.  What's happening is that when you hook up +V to any of them, that has the side-effect of pulling at least A0 HIGH along with it since you have allowed it to float.
Two things to do here:

Don't allow lines to float and expect deterministic behavior.  Tie them to +V or to GROUND when you are not using them.
Pull the Ax lines to +V or GND via a resistor like 10K Ohms.  This will prevent them from floating and will give you predictable results.

that was it, adding resistors to pull Ax lines to GND did it. Thanks!


text:
Control Air Pump Depending on Pressure Sensor
I am working with an Arduino Mega, a 12V micro air pump, and a MP3V5050 air pressure sensor. The sensor outputs an analog voltage depending on the pressure reading in an inflatable member. I'd like to turn on the micro air pump when the pressure is too low and turn off the pump when the pressure exceeds a determined threshold (exact pressure ranges are currently undetermined).
I have been looking for similar tutorials but this is my first experience working with Arduinos and most existing tutorials are either sensing or pump control, not both. I only have minor coding experience with MATLAB, so any help with this is appreciated. Thank you!

So you basically want a hysteresis control for the air pump.
const int lowerLimit;//fill in as needed
const int upperLimit;

void loop(){
    int pressure = readPressureSensor();
    if(pressure < lowerLimit) turnPumpOn();
    if(pressure > upperLimit) turnPumpOff();

}

The helper functions I used should be easy to implement based on the tutorials you found.

Nice, simple answer that should point the newbie in the right direction! (voited)

source: Stack Exchange

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

sort: votes


text:
my LM35 temperature sensor gives weird measurements,
Board: esp32
I know my wiring is correct because I get data from the sensor, but the data is a bit weird.
At 22 celcius I get 140, even though if I do the voltage calculation (* 0.473372) it still doesn't work.
the number 0.473372... comes from taking the voltage 4.7v / 1024 * 1000 / 10
My code:
 Serial.print("temp: ");
 float temp = (analogRead(A13) * 0.473372781065088);
 Serial.println(temp);
 delay(2000);

Any answers?

What is the voltage into the analog input when you get that reading? Explain why you multiply by 0.473. Show your schematics. I think the LM35 needs decoupling capacitors (if I remember correctly). Have you omitted them? Add the info into your question - not in the comments.

Your "conversion" from ADC value to temperature looks far too simple.  You have to convert the ADC value to volts, then from the voltage you can calculate the temperature.  This is a simple excercise, and a quick google search turns up examples (with explanations) for using the LM35 with an ESP32.

What JRE says: remember that 0 = 0 V but 1023 = VCC (unless you chose a different reference voltage).

analogRead value * (voltage to the sensor / 1024 * 1000 / 10) I think it should be: Actual Voltage = analogRead_value * (ADC reference voltage / 1023), see: https://www.arduino.cc/en/Tutorial/ReadAnalogVoltage

I mean like this.

You write an answer detailing what was wrong and how you fixed it (for the benefit of people in the future that have the same problem), wait the prescribed period, then accept it as the right answer.

btw: the esp32 is operated at 3.3V. so, if you really have a voltage of 4.7V at the analog inputs you are out of specs!

@SimSon what do you mean?

Normalizing voltage with 4.7v / 1024 * 1000 / 10 makes me believe that you measured/supplied a voltage of 4.7V. That's to much for the esp, the maximum permitted voltage is 3.6V as the esp32 must be operated at 3.3V

hmm idk, the documentation for the sensor said it needed 4.4 volts, so i just hooked it up with the vin pin

but i doesnt output 4.4 voltage, so i guess im fine

ok, the problem is that i used to the wrong voltage conversion, just use:
RawValue = analogRead("your analog input pin");
Voltage = (RawValue / 2048.0) * 3300;
Serial.println(Voltage);

this should print the tempeture in celcious

try this one i have worked with lm35 using this code and circuit. i have done this thing with arduino uno but you can try it with esp32

i dont need the sensor to measure minus decrease, so i use a diffrent setup

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


text:
several cameras share data lines
There are plenty of projects that connect an OmniVision camera, such as ov7670 , to an Arduino.
A good example would be:
https://www.scribd.com/document/356160003/Beginning-Arduino-Ov7670-Camera-Development
Now, let's say I want to connect 2 of those.
The problem with these cameras is that they require 17 IOs, which is a lot.
They are are:

1 power - cannot be shared
1 external clock (XCLK)
2 I2C lines (DATA, CLK)
8 data lines (D0:D7)
3 sync lines (PCLK, VSYNC, HREF)
2 control lines (RESET , PWD)

(Image attached below)
So, assuming I'm only powering 1 camera at a time, by giving each camera its own power IO, can all other IOs of both cameras be shared? at least some of them? (even if some intermediary simple HW is required)
Thanks!

Though question. Do you know how the datalines behave, when the camera is unpowered? Are they high impendance or may there be a parasite current? I assume you want to process the images in the Arduino, thus using the data lines.

And are you sure, that you want to do this with an UNO? Even a little bit of image processing is a big task for an UNO

No Image processing, only relay. I want to later port it to some Atmel SAMD, I use Arduino for prototyping, and want the SAMD have the same solution, if possible.

I don't know about electric behavior, I was hoping to get suggestions about this.

You might be able to use the Power-down mode pin and set the control register to tri-state data output to allow connecting multiple devices to the same data bus.


text:
WindowsError(31, 'A device attached to the system is not functioning.') in arduino
Having board esp32 devkit v1, to get started with arduino ide (installed recommended boards for esp32) I marked board asDOIT ESP32 DEVKIT V1 (as no other options as like ESP32 DEVKIT V1 ) so upload gets this error
    esptool.py v2.6
Serial port COM3
Traceback (most recent call last):
File "esptool.py", line 2959, in <module>
File "esptool.py", line 2952, in _main
File "esptool.py", line 2652, in main
File "esptool.py", line 222, in __init__
File "site-packages\serial\__init__.py", line 88, in serial_for_url
File "site-packages\serial\serialwin32.py", line 62, in open
serial.serialutil.SerialException: could not open port 'COM3': WindowsError(31, 'A device attached to the system is not functioning.')
Failed to execute script esptool
the selected serial port Failed to execute script esptool
 does not exist or your board is not connected

so how do I upload my programs?
I would be highly obliged if you could please help me solve this problem.
Thank you.

are you sure COM3 is the correct port?

It's only available

is that trying to say that COM3 is the only one available? if you disconnect the ESP, does COM3 also disappear?

Have you installed the CP2102 drivers?

Yupp if I disconnect esp com3 disappeared

No I haven't install that drivers

I am facing trouble with the same error. Did it get solved? I tried with both the DM board and AI thinker, but this error doesn't seem to get removed at all

I got this error.  Then switching USB ports fixed the problem.  Showed up on COM3 in either place. I just switched from a built-in USB port to on off a hub, and it started working.


text:
Backup an ATMEGA16
I have an ATMEGA16 lying around that was in an old robot I'd bought. It was in a socket, so I pulled it out and was thinking of using this page to use it with Arduino IDE. Is there a way for me to backup the chip's current state, so as to be able to restore it if I mess up?
I don't have an SPI programmer with me, but I do have a Arduino Uno available at hand

Comments are not for extended discussion; this conversation has been moved to chat.

A detailed how to is here its for the ATMega16 but check connections with the circuit diagram.

Use this command for backup of flash
 avrdude -c avrisp2 -p m16 -P /dev/ttyUSB0 -b 115200 -U flash:r:Old_flash_backup_file.hex:h

Backup EEPROM (just in case there is something stored there)
avrdude -c avrisp2 -p m16 -P /dev/ttyUSB0 -b 115200 -U eeprom:r:eeprom_backup_file.hex:h

and this for writing the new bootloader / backup back
 avrdude -c avrisp2 -p m16 -P /dev/ttyUSB0 -b 115200 -U flash:w:New_BootLoader.hex:i -v

and this for EEPROM writing back
avrdude -c avrisp2 -p m16 -P /dev/ttyUSB0 -b 115200 -U eeprom:w:new_eeprom_file.hex:h

As your avr-dude outputis
lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00

there seems to be no lock on the chip. As you are on LINUX when reading youhave tospecify the format :h hex when reading

Comments are not for extended discussion; this conversation has been moved to chat.


text:
Is there a way to reuse an old robot using arduino?
I had purchased a simple robot (named Qu-Bot) for a school project a couple of years ago. After the project, it just went into the attic. A few days ago, I purchased an Arduino Uno and started learning the how to operate it. But, before I could purchase LEDs, sensors, LCD, etc, a total lockdown was implemented in my country due to coronavirus.
Is there a way I could program that old robot in Arduino IDE like I program my Uno?

I'm not sure if this is useful or not, but, when I execute $ lsusb , the bot appears as Bus 001 Device 018: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port

Here's a link to some documentation of the bot:
http://www.technogravity.com/products/qu_bot/qu_bot_downloads.php
Here are photos of all the 3 chips I can see on the board of the bot:

As to your question can I program in ArduinIDE - Yes.

The main chip is from AVR ATMEGA16,
the LCD is a 16x2 (pinout for use with the LCD library is enclosed)
motor driver is (Big thanks to Juraj not a mystery) a ULN2803. Example to work with can be found here.

The circuit diagram enclosed:

How to use in ArduinoIDE:

First install the driver for prolific and makes sure your OS finds the robot  (done)

Then install the MightyCore which supports ATMega16 - there are detailed instructions how to do it
Start with a blink led example (pins from the schematic) compile and upload to test
Then a simple LCD example and so on.

Another posibility would be tor scrap the bot and salvage most parts.
If its feasable the Manual will tell you which parts can be removed without soldering
To get started you need the USB drivers for OS and the original SW to test wether the QBot is still ok from a hardware perspective,
Than you can salvage the parts from it to use with Arduino:

Than you have to make a new base plate (google for pics of 2-wheel robot base plates) and get a motor driver (I recommend for a beginner a cheap motor shield like an Adafruit V2 motor shield clone 5-7$).
As you probably have downloaded ArduinoIDE latest version for your OS, get some example programs and start to play around.

do you think it has Optiboot for the MightyCore?

could the ULN2803APG be the motor driver? https://cdn-shop.adafruit.com/datasheets/ULN2803A.pdf

I will look into the MightyCore solution tomorrow morning. Thanks a lot for that. As for salvaging it, I don't think that's possible as the parts as soldered without much margin to remove them

@Codebreaker007 I followed steps as specified. This is the error that occured: https://pastebin.com/b4biZqYE

@FitzWatson, of course. the upload expects Optiboot bootloader in the ATmega

On your linked website I wasn't able to open the sample programs (404 Not Found). The site seems very outdated (it has news from 2015 on it). So I cannot be sure, how the robot is meant do be programmed.
But: The Atmega16A is a programmable microcontroller and it most likely is the brain of the robot. Depending on how the original bot was programmed, you can have 2 ways to go:

If it was originally build around the Arduino platform, meaning, that it already has a fitting bootloader in it, then you might be able to program directly over USB/Serial from the Arduino IDE.
If not you can program it with the Arduino IDE over ISP by using your Arduino Uno as a programmer. Look at this documentation site for a more detailed description, how this is done. Note, that you will most likely have to remove the Atmega from the bot for programming, since the programming can interfere with the circuit of the bot (The Atmega seems to be in a socket, so that you can remove it from there). After programming you can put it into the bot again.

In both cases you need to install the correct core for that chip in the Arduino IDE, for example by following this guide (found by a quick search, not tested). (Maybe you even can find a core specifically for that robot)

The other shown chips seem to be the motor drivers.

you don't know the MightyCore? https://github.com/MCUdude/MightyCore

Here's a link to the sample codes: http://robokitsworld.com/downloads/QBVLab%20Sample%20Codes.zip


text:
Cannot write pin LOW
All the other examples I've seen have had coding errors where they set a pin LOW in a loop with no delay so that it goes high again right away - but this problem is different, and probably something obvious.
I set up a breadboard memory (EEPROM or similarly-pinned flash) programmer (ala BenEater and many similar sources) using two 74**595s for the first 15 address bits as well as the OE# bit in the MSB spot, and the nano digital outputs for the 8 data bits as well as the WE# (write-enable) bit.  The data, address, and OE# pins set correctly every time.  The WE# pin, however, stays HIGH forever once it goes HIGH.
I have tried every digital pin for WE#, I have tried every analog pin with an analogWrite.  I have tried now three different memory chips and three Arduino Nanos that I've used successfully elsewhere, but still no success.
The only thing I can assume is that the WE# pin on the memory ICs somehow is keeping the line high, but I can't for the life of me figure out how that's possible.
Code and logic analyzer example:
/*
 EEPROM Programmer
 In this case, programming a SST39SF010A
 55ns read access, 22us write time
 Software Data Protection to write:
 (0x5555, 0xAA)
 (0x2AAA, 0x55)
 (0x5555, 0xA0)
 */

#define SHIFT_DATA  13
#define SHIFT_CLK   12
#define SHIFT_LATCH 11
#define ROM_D0      2
#define ROM_D1      3
#define ROM_D2      4
#define ROM_D3      5
#define ROM_D4      6
#define ROM_D5      7
#define ROM_D6      8
#define ROM_D7      9
#define WRITE_EN    10

void setAddress(int address, bool outputEnable) {
  shiftOut(SHIFT_DATA, SHIFT_CLK, MSBFIRST, ((address >> 8) | (outputEnable ? 0x00 : 0x80))); // High bits
  shiftOut(SHIFT_DATA, SHIFT_CLK, MSBFIRST, address); // Low bits
  digitalWrite(SHIFT_LATCH, LOW);
  digitalWrite(SHIFT_LATCH, HIGH);
  digitalWrite(SHIFT_LATCH, LOW);
}

byte readROM(int address) {
  for (int pin = ROM_D0; pin <= ROM_D7; pin++) {
    pinMode(pin, INPUT);
  }
  byte data = 0;
  setAddress(address, /* outputEnable */ true);
  // Read each pin
  for (int pin = ROM_D7; pin >= ROM_D0; pin--) {
    data = (data << 1) + digitalRead(pin);
  }
  return data;
}

void printContents() {
  for (int base = 0; base < 256; base += 16) {
    byte data[16];
    char buf[80];
    for (int offset = 0; offset < 16; offset++) {
      data[offset] = readROM(base + offset);
    }
    // buffer (string) to hold the formatted data
    sprintf(buf, "%03x:  %02x %02x %02x %02x %02x %02x %02x %02x  %02x %02x %02x %02x %02x %02x %02x %02x",
      base, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7],
      data[8], data[9], data[10], data[11], data[12], data[13], data[14], data[15]);
    Serial.println(buf);
  }
}

void writeROM(int address, byte data) {
  for (int pin = ROM_D0; pin <= ROM_D7; pin++) {
    pinMode(pin, OUTPUT);
    digitalWrite(pin, LOW);
  }
  setAddress(address, /* outputEnable */ false);
  for (int pin = ROM_D0; pin <= ROM_D7; pin++) {
    digitalWrite(pin, (data & 0x01));
    data = (data >> 1);
  }
  digitalWrite(10, LOW);
  delayMicroseconds(10);
  digitalWrite(10, HIGH);
  delay(1);
}

void setup() {
  // put your setup code here, to run once:
  Serial.begin(56700);
  Serial.flush();

  pinMode(SHIFT_DATA, OUTPUT);
  pinMode(SHIFT_CLK, OUTPUT);
  pinMode(SHIFT_LATCH, OUTPUT);

  // Set pull-up resistor
  digitalWrite(WRITE_EN, HIGH);
  pinMode(WRITE_EN, OUTPUT);

  Serial.println();

  writeROM(0x5555, 0xAA);
  writeROM(0x2AAA, 0x55);
  writeROM(0x5555, 0xA0);
  for (int i = 0; i < 256; i++)
  {
    writeROM(i, i % 13);
  }
  printContents();
}

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

http://forum.arduino.cc/index.php?topic=68753.0

@MichaelT I am not seeing how that link is equivalent.  The pin in my project is not left floating.  It is connected and does not respond to commands to set to LOW.

Does the pin go low when disconnected from the memory chip?

@MaximilianGerhardt Good question - when it isn't connected, it stays low.

@MaximilianGerhardt Well, sometimes it just takes one rational question, thank you.  Somehow it works on my Arduino Uno but none of my Nanos...  I will just keep going from here and try to trouble shoot the nanos later

Are you sure you don't have a case of both chips trying driving the OE line (in opposite directions), destroying the output driver? What is the voltage of WE# on the memchip without the pin being disconnected? Is floating? Can you manually ground the pin and see a 0V on the multimeter? Maybe also see https://electronics.stackexchange.com/a/107190/158783

@MaximilianGerhardt Ding ding.  Not sure how, but somehow OE and WE are shorted on my breadboard.  It was the common factor, the memory have the same pinouts so I just swapped them.  Everything was driving the same channels high, thus no way to bring it low.  Also I think it killed my Uno D10 pin... :-(  But thanks for the help - I wasn't even thinking of that and I have no idea how two channels so far apart on a breadboard are shorted together, but my DMM reads 0.01 Ohms between them.  Now it's time to break apart a breadboard...


text:
Fading led with push button
I need to make for school a project. That when i hold a button it fades. But when you let go the button it needs to stop immediately. But when i you hold the button again it needs to start again with fading but the brightness needs to start from 0. I have a program but when i press again it just starts from the previous brightness. Pls help. This is my code:
int led = 9;
int brightness = 5;
int fadeAmount = 5;

void setup() {
   Serial.begin(9600);
    pinMode(led, OUTPUT);
}
void loop() {
  int val = digitalRead(2);
  Serial.println(val);
if (val==HIGH){
  analogWrite(led, brightness);
  brightness = brightness + fadeAmount;
  if (brightness <= 0 || brightness >= 255) {
    fadeAmount = -fadeAmount; }
  delay(100);
}
else{

  digitalWrite(9, LOW);
}
}

The main problem is you have to reset brightness to 0 when the switch is LOW. Btw, I did not test the sketch, only compiled it.
int led = 9;
int brightness = 5;
int fadeAmount = 5;

void setup() {
   Serial.begin(9600);
    pinMode(led, OUTPUT);
}
void loop() {
  int val = digitalRead(2);
  Serial.println(val);
if (val==HIGH){
  analogWrite(led, brightness);
  brightness = brightness + fadeAmount;
  if (brightness <= 0 || brightness >= 255) {
    fadeAmount = -fadeAmount; }
  delay(100);
}
else{

  digitalWrite(9, LOW);
  brightness = 0;    // Restart with brightness 0
}
}

Some other improvements result in:
#define LED_PIN      9
#define DELAY_TIME 100
int brightness = 5;
int fadeAmount = 5;

void setup() {
   Serial.begin(9600);
   pinMode(LED_PIN, OUTPUT);
}

void loop() {
  int switchButton = digitalRead(2);
  Serial.println(switchButton);

  if (switchButton == HIGH) {
    analogWrite(LED_PIN, brightness);
    brightness += fadeAmount;
    if ((brightness <= 0) || (brightness >= 255)) {
      fadeAmount = -fadeAmount;
    }
    delay(DELAY_TIME );
  }
  else {
    digitalWrite(LED_PIN, LOW);
    brightness = 0;    // Restart with brightness 0
  }
}

Explanation

Always indent your code (so that { and } are clear, notice each new { increases the indentation by two spaces, each } decreases the indentation by two spaces.
For values that do not change use a #define. This prevents (in this case) a few bytes not be stored in valuable memory space. Especially if you would use arrays this is important.
You used 9 in digitalWrite(9, LOW); which was probably a mistake, always use defines wherever possible. I also would use #define DELAY_TIME 100 instead of the hardcoded 100 value.
I addes some spaces before/after values (like switchButton == HIGH). It doesn't matter if you do or not, but be consequent.
Use good variable names (switchButton is more clear than val.
Use brightness += fadeAmount; instead of brightness = brightness + fadeAmount;; this is the normal way of increasing (or decreasing/multiplying/whatever) the value of a variable.
Use ( and ) in non trivial if statements like if ((brightness <= 0) || (brightness >= 255)), this could save you hours of searching in case you ever make a mistake (in this case there is no functional change).

Good luck with your project.

oh yeah thank you very much. i will test it soon.

Wow, a bounty of good coding advice! (Voted)


text:
How to generate .a and .so files to add in arduino project
I know to make a library on arduino ide with source codes, but I cant send my source code to another users who want to use my lib.
So I need to make a library with precompiled=true info at library.properties. And I need to put my .a and .so files at src/{build.mcu} (in my case, src/avr/mylib.a and mylib.so).
But, where is that files (.a and .so)?!
Does the arduino compiler generate this files? If so, where? If dont, how compiler I need to use?
I found the .o file at appData\local\Temp\arduino_build_XXXX\libraries\mylib\
Thank you very much and sory about my english.

[library] = library name
1) edit the [library] library.properties file and add dot_a_linkage=true to the end ... (/home/name/Arduino/libraries/[library]/library.properties)
2) build the example ...
3) After the build is complete navigate to the build folder (In Linux it's located in the /tmp/arduino_build_xxxxxx folder) then copy the dot_a file from under library folder (libraries/[library].a) to the arduino library folder for the [library] library (/home/name/Arduino/libraries/[library]/src/esp8266/lib[library].a)
4) edit the [library] library library.properties file again and remove dot_a_linkage=true and add precompiled=true and ldflags=-l[library] to the end of the file ...
5)  build the example ... this time it links to the dot_a file ...

Note: I have never done this with the Arduino IDE, so I don't know if the resultant file will be of any use to you.

A .a file (you don't want a .so file - that's a shared library that makes no sense on a platform without an OS) is merely an archive (ar archive, specifically) that contains one or more .o files.
You create one simply enough using:
avr-ar rcs myLib.a myLib.o

You will find the avr-ar program in the tools installation within your Arduino IDE somewhere.

As an aside, UECIDE (which I wrote) uses library files like these to cache its libraries and other compiled code. You can use UECIDE to directly grab a .a file for your library, which you would find in the cache folder of the UECIDE data folder (find it through the Help -> Debug menu).

Thank you Majenko!
But, the program is not avr-ar for me, I use the avr-gcc-ar.
After that, I must to dot_a_linkage=true in my library.properties and manually add mylib.a at AppData\Local\Temp\arduino_build_115676\libraries\mylib\
I dont know why, but this help for me.
I hope help other.
Best regards.


text:
Hand-held programmable device needed
Hopefully this question is not too off-topic for this board. I need a ready-made programmable hand-held device with an ethernet-connection. Something like an Arduino with batteries and display and some buttons in a box.
This is for my company so a complete ground-up assembly is too expensive and time-consuming in this case. Any hints to companies that produce something like this are welcome. And yes, I tried searching with different search-engines already. :-)
Thanks for your time!

And what is the purpose of this device? Connect to ethernet and.... intercept and analyse the traffic? Why does it need to be handheld when it is going to be wired? With PoE you don't even need a battery.

A Leonardo ETH with a keypad shield and a printed box perhaps?
Use PoE or two 18650 cells for power supply.

Use a cheap or preowned laptop with linux and wireshark.

try raspberry pi 3, it comes with all the features you needed. You need to take care of battery part.

I have no opinion about this hardware (I don't own it) so please treat my answer as information only. When I was searching through web I found M5Stack
It looks like hardware made for IoT development.
It has a LCD and 3 buttons and think it can be programmed using ArduinoIDE.
It's designed that you can design any hardware you want and "stack" the device on top of it. Found if available to buy from China for below 30USD.

https://www.youtube.com/watch?v=U2es-l4z2Zg

That's a really nice find, and what looks to be a fantastic module. I'm going to have to get myself one to play with and port DisplayCore to - and of course provide full support in UECIDE...

I thought that there might be an Arduino-based solution for my task, that's why I chose this board for my question. I'm sorry if I wasted a bit of you time and will take the answers I got so far as a starting point. Thanks to those who commented!


text:
Loop failure after unset amount of time
I am building an art piece that takes in input from three rotary encoders and two buttons. and outputs data to a large neopixel display and 2 large 4 digit seven segment displays. The displays are powered by the arduino 5V the neopixels are powered by a separate power source.
Everything works exactly as expected for a time. Then seemingly at random the code discontinues responding to any input. The seven segment displays continue to light up.
I believe it might be a power issue with the arduino overheating due to the power consumption of the seven segment displays (~300mA), however, the arduino is still "on" or reviecing power.
I have attached my code below as I worry that problem might come from a runtime error there rather that a power issue.
//3 rotary encoders
//2 buttons

//Displays:
//1 8x32 neopixel array
//2 4 digit 7 segment displays
//2 button LEDs

#include <Adafruit_NeoPixel.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h"
#include <Adafruit_VS1053.h>

//Music Maker Logic/Variables
#define mp_mcs 7
#define mp_dcs 6
#define mp_dreq 3
#define mp_ccs 4
#define mp_reset -1

char* music="TRACK001.wav";

//Music maker constructor
Adafruit_VS1053_FilePlayer mp =
  Adafruit_VS1053_FilePlayer (mp_reset, mp_mcs, mp_dcs, mp_dreq, mp_ccs);

//Neopixel Logic/Variables
#define neoPixelPin 26
#define pixelNumber 256
#define neoInterupt 50

Adafruit_NeoPixel neoArray = Adafruit_NeoPixel(pixelNumber, neoPixelPin, NEO_GRB + NEO_KHZ800);
uint32_t color;
bool flip;
bool nullColor[32] = {false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false};
bool colorTable[32] = {false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false};
long currentTime;
long pastTime;
long startingTime;
long pastTimeAlt;

//Encoder Logic/Variables
#define outputA1 40
#define outputB1 41
#define outputA2 42
#define outputB2 43
#define outputA3 44
#define outputB3 45

byte a1State;
byte a1LastState;
byte a2State;
byte a2LastState;
byte a3State;
byte a3LastState;
byte topDay;

//7 Segment Logic/Variables
Adafruit_7segment matrix1 = Adafruit_7segment();
Adafruit_7segment matrix2 = Adafruit_7segment();

byte month = 1;
byte day = 1;
short year = 2000;
String holder;
String holder1;
String holder2;

//button Logic/Variables
#define altResetPin 30
#define engPin 32

void setup() {
  Serial.begin(9600);
  //Serial.println("In setup");
  //Input initializations
  pinMode(altResetPin, INPUT_PULLUP);
  pinMode(engPin, INPUT_PULLUP);
  pinMode(outputA1, INPUT_PULLUP);
  pinMode(outputB1, INPUT_PULLUP);
  pinMode(outputA2, INPUT_PULLUP);
  pinMode(outputB2, INPUT_PULLUP);
  pinMode(outputA3, INPUT_PULLUP);
  pinMode(outputB3, INPUT_PULLUP);
  //pinMode(neoInterupt, INPUT);

  Serial.println("made it to structures");

  //begin structures
  neoArray.begin();
  neoArray.setBrightness(75);
  neoArray.show();
  Serial.println("Neo Array initialize");
  matrix1.begin(0x70);
  matrix2.begin(0x72);
  matrix1.setBrightness(4);
  matrix2.setBrightness(4);
  Serial.println("matrix initialize");
  //attachInterrupt(digitalPinToInterrupt(engPin), neoPixelSuprise, LOW);

  Serial.println("made it to initializations");

  //Music Player initialization
  if (! mp.begin()) {
   Serial.println(F("Music Maker connection failed, or not present"));
   while (1); // don't do anything more
  }
  Serial.println(F("Music Maker connection successful"));

  //SD card Check
  if (!SD.begin(mp_ccs)) {
   Serial.println(F("SD failed, or not present"));
   while (1);  // don't do anything more
  }
  Serial.println(F("SD Inserted and found"));

  mp.setVolume(10,10);
  mp.useInterrupt(VS1053_FILEPLAYER_PIN_INT);

  //initial Reads
  a1LastState = digitalRead(outputA1);
  a2LastState = digitalRead(outputA2);
  a3LastState = digitalRead(outputA3);

  //initial Outputs
  matrix1.print(combine(month,day),DEC);
  matrix1.writeDisplay();

  matrix2.print(year,DEC);
  matrix2.writeDisplay();

}

void loop() {
  //read current states
  a1State = digitalRead(outputA1);
  a2State = digitalRead(outputA2);
  a3State = digitalRead(outputA3);

  //deal with encoder readings
  //first encoder, encodes the month
   if (a1State != a1LastState){
     // If the B state is different to the A state, that means the encoder is rotating clockwise
     if (digitalRead(outputB1) != a1State) {
       //clockwise rotation
       if(month == 12){
        month = 1;
       }else{
        month ++;
       }
     } else {
        //cc-rotation
       if(month == 1){
        month = 12;
       }else{
        month--;
       }
     }
    }
   a1LastState = a1State; // Updates the previous state of the outputA with the current state

   //second encoder, encodes the day
   if (a2State != a2LastState){
     // If the B state is different to the A state, that means the encoder is rotating clockwise
     topDay = daysInMonth(month,year);
     if (digitalRead(outputB2) != a2State) {
       //clockwise rotation
       if(day >= topDay){
        day = 1;
       }else{
        day ++;
       }
     } else {
        //cc-rotation
       if(day == 1){
        day = topDay;
       }else{
        day--;
       }
     }
    }
   a2LastState = a2State; // Updates the previous state of the outputA with the current state

   //third encoder. encodes the year
   if (a3State != a3LastState){
     // If the B state is different to the A state, that means the encoder is rotating clockwise
     if (digitalRead(outputB3) != a3State) {
       //clockwise rotation
       if(year == 2100){
        year = 1900;
       }else{
        year ++;
       }
     } else {
        //cc-rotation
       if(year == 1900){
        year = 2100;
       }else{
        year--;
       }
     }
    }
   a3LastState = a3State; // Updates the previous state of the outputA with the current state

  //update 7segment display
  matrix1.print(combine(month,day),DEC);
  matrix1.writeDisplay();

  matrix2.print(year,DEC);
  matrix2.writeDisplay();

  //read buttons and act on them
  if(digitalRead(altResetPin)==HIGH){
    day = 1;
    month = 1;
    year = 2000;
  }

  if(digitalRead(engPin)==LOW){
    neoPixelSuprise();
  }
}

void neoPixelSuprise(){
  //put a crazy neopixel event here
  Serial.println("EngPin Hit");
  startingTime = millis();
  pastTime = millis();
  currentTime = millis();
  pastTimeAlt = millis();
  bool holdList[32] ={false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false};
  byte counter = 0;

  mp.startPlayingFile(music);

  while(currentTime - startingTime > 8000){
    currentTime = millis();

    if(currentTime - pastTimeAlt> 100){
      colorTable[counter] = flipper(colorTable[counter]);
      colorTable[31-counter] = flipper(colorTable[31-counter]);
      pastTimeAlt = currentTime;
    }

    //flickerControl
    if(currentTime - pastTime > 50){
      flip = flipper(flip);
      if(flip){
        fillRow(colorTable);
      }else{
        fillRow(nullColor);
      }
      pastTime = currentTime;
    }

    counter = counter+2;
    if(counter>31){
      counter = 0;
    }
  }
}

void fillRow(bool truthList[32]){
  //fills the panel with random color
  for(int i=0; i<32; i++){
    randomSeed(analogRead(A11));
    if(truthList[i]){
      //fills particular row with random color
      for(int j=0; j<8; j++){
        color = Adafruit_NeoPixel::Color(random(255),random(255),random(255));
        neoArray.setPixelColor((i*8)+j,color);
      }
    }else{
      //turns off particular row
      for(int j=0; j<8; j++){
        color = Adafruit_NeoPixel::Color(0,0,0);
        neoArray.setPixelColor((i*8)+j,color);
      }
    }
  }
}

bool flipper(bool whatIs){
  //flips a boolean
  if(whatIs){
    whatIs = false;
  }else{
    whatIs = true;
  }
  return whatIs;
}

byte daysInMonth(byte month, byte year){
  //based on the year it will tell you how many days there were in that given month
  //leap year condition, if month is 2
  if(month == 2){
    if((year%400==0) || (year%4==0 && year%100!=0)){
      return 29;
    }else{
      return 28;
    }
  }
  //months which have 31 days
  else if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month==12){
    return 31;
  }else{
    return 30;
  }
}

short combine(byte month, byte day){
  //takes the two bytes and truns them into one long digit
  holder1 = String(month);
  holder2 = String(day);

  if(holder1.length()==1){
    holder1 = "0" + holder1;
  }
  if(holder2.length()==1){
    holder2 = "0" + holder2;
  }

  holder = holder1 + holder2;

  return(holder.toInt());
}

don't use String class

char* is equivalent correct? I will look it up as well, however, what is so wrong with String class?

https://majenko.co.uk/blog/evils-arduino-strings

Your combine() function seems like you were searching for the most convoluted way of computing 100*month+day.

@Juraj thank you for the cool link!

@EdgarBonet you are completely correct. In retrospect it is super dumb. Thank you for pointing it out.


text:
Use of ESPAsyncWebServer.h with ArduinoJson version 6 for Master-Client transactions
I want to communicate two (2) ESP32's via Json commands using ESPAsyncWeb.h. The master should have specific operations to execute and respond to the client, and the client should be able to send specific Json commands to ask questions and receive responses. I have tried the method below but is throwing me weird errors such as

cannot bind non-const lvalue reference of type 'ArduinoJson::JsonObject&' {aka 'ArduinoJson6185_91::OBjectRef&'} to an rvalue of type 'ArduinoJson6185_91::enable_if<true, ArduinJson6185_91::ObjectRef>::type' {aka 'ArduinoJson6185_91::ObjectRef'}

I am not sure how to implement the operations for sending Json and receiving response from the Server using ArduinoJson 6. If anyone could enligthen me on how to conduct such transactions I'd appreciate it.
 void setup(){

//start serial comm
//Broadcast as WiFi SoftAP

 server.on("/command", HTTP_POST, [](AsyncWebServerRequest *request, JsonVariant &json)
          {JsonObject& jsonObj = json.as<JsonObject>();
           uint8_t command = jsonObj["C"];
           String response;
           switch(command){
                           case 0: response = "{\"SCAN\":\"received_scan\"}";
                           request -> send(200, "application/json", response);
                           return;
                           case 1: /*...similar stuff */

                           case 2: /*...*/
}});
server.begin();
}

Have you tried following the examples in the ESPAsyncWebServer documentation? The code you used is different from the example.

cannot bind non-const lvalue reference of type 'ArduinoJson::JsonObject&' {aka 'ArduinoJson6185_91::ObjectRef&'} to an rvalue of type 'ArduinoJson6185_91::enable_if<true, ArduinJson6185_91::ObjectRef>::type' {aka 'ArduinoJson6185_91::ObjectRef'}

In other words, "cannot assign JsonObject to JsonObject&".
The compiler refuses to save a reference to a temporary variable because the reference would inevitably dangle.
To fix this issue, you must remove the ampersand (&) after JsonObject, like so:
JsonObject jsonObj = json.as<JsonObject>();

And it would be best if you also did the same for JsonVariant.
BTW, the cast from JsonVariant to JsonObject isn't necessary in your case, so you could simplify your program to:
server.on("/command", HTTP_POST,
          [](AsyncWebServerRequest* request, JsonVariant json) {
            switch (json["C"].as<uint8_t>()) {
              case 0:
                request->send(200, "application/json",
                              "{\"SCAN\":\"received_scan\"}");
                return;

              case 1: /*...similar stuff */

              case 2: /*...*/
            }
          });

I recommend that you have a look at ArduinoJson's documentation; I heard it's pretty good ;-)


text:
Circuit diagram for running bipolar stepper motor using LDR
I am new to Arduino, some how I have put this code together to run stepper motor using LDR(kind of solar tracker program) I searched on net and tried using servo motor circuit to run stepper motor, assuming just replacing servo motor with stepper motor would work. I guess that is not the case (because servo motor is not moving according to LRD inputs). Please help me with circuit diagram.
Here is the code I am using

const int dirPin  = 5;
const int stepPin = 4;
const int enPin   = 6;
const int SensorPin1 = A0;
const int SensorPin2 = A1;
int sensorValue1 = 0;
int sensorValue2 = 0;

void setup() {

  pinMode(stepPin,OUTPUT);
  pinMode(dirPin,OUTPUT);

  pinMode(enPin,OUTPUT);
  digitalWrite(enPin,LOW);
  Serial.begin(9600);

}
void loop() {
  sensorValue1 = analogRead(SensorPin1);
  Serial.println(sensorValue1);
  sensorValue2 = analogRead(SensorPin2);
  Serial.println(sensorValue2);

  if(sensorValue1 < 40 && sensorValue2 < 400){
    Serial.print("No sun Detected");
    digitalWrite(dirPin,LOW);
    digitalWrite(stepPin,LOW);
  }
  else if(sensorValue1 > 400){

    digitalWrite(dirPin,HIGH);
    digitalWrite(stepPin,HIGH);

 }
else if(sensorValue2 > 400){
    digitalWrite(dirPin,LOW);
    digitalWrite(stepPin,HIGH);
}
}

Hardware Used:

Bipolar stepper motor- NEMA 23 20Kg torque
Stepper driver: TB6600
Power supply: SMPS 12V, 5amp
LDR: 2
Resistors: 2, 10K resistors
1 Arduino Uno
Breadboard

With most stepper drivers the stepper will move 1 (!) step when you put 1 pulse on the input (meaning a transition low-high-low or invers). Your code will at most drive the motor 1 step, most likely not enough to see it. Generate more pulses

Change digitalWrite(stepPin,LOW); to digitalWrite(stepPin,LOW);delay(1);digitalWrite(stepPin,HIGH);

Thanks @chrisl ..will try and let you know...but I am still looking for circuit digram

For the circuit diagram: Have you seen for example this User Guide on the TB6600? There it is mentioned, how the driver has to be connected to the Arduino and to the motor. You can even download the more detailed user guide as pdf.

If it helps, I tuned your code little.
const int dirPin  = 8;
const int stepPin = 7;
const int enPin   = 13;//with pin 13 You can monitor on-board LED, if its lit, "enable" is HIGH and stepper will turn.
const int rightSensorPin = A0;
const int leftSensorPin = A1;
int rightSensorRead = 0;
int leftSensorRead = 0;
int rightLightPct = 0;
int leftLightPct = 0;
int degreeChange = 1;

void setup() {
  Serial.begin(9600);
  pinMode(stepPin,OUTPUT);
  pinMode(dirPin,OUTPUT);
  pinMode(enPin,OUTPUT);
  pinMode(A0, INPUT_PULLUP);//no need extra resistors. Just connect one LDR leg to A0 and another GND.
  pinMode(A1, INPUT_PULLUP);
}

void loop() {
  rightSensorRead = analogRead(rightSensorPin);
  leftSensorRead = analogRead(leftSensorPin);
  rightLightPct = map(rightSensorRead, 0, 1023, 0, 100);
  leftLightPct = map(leftSensorRead, 0, 1023, 0, 100);
  degreeChange = map(abs(rightLightPct-leftLightPct),0,100,2,10);
  Serial.print("right = ");
  Serial.print(rightSensorRead);
  Serial.print(" left = ");
  Serial.print(leftSensorRead);
  Serial.print(" Pct r/l = ");
  Serial.print(rightLightPct);
  Serial.print("/");
  Serial.println(leftLightPct);
  if(rightLightPct < 15 && leftLightPct < 15){
    Serial.println("Sun is detected");
    digitalWrite(enPin, LOW);
    digitalWrite(dirPin,LOW);
    digitalWrite(stepPin,LOW);
    delay(5000);//if somthing get in a way, program waits 5 sec. If nothing in that time, program will continue. That time may erase or add some more.
  }else if(rightLightPct > 50 && leftLightPct > 50){
    Serial.println("Sun is set!");
    digitalWrite(enPin, LOW);
    digitalWrite(dirPin,LOW);
    digitalWrite(stepPin,LOW);
  }else if(rightLightPct > 20 && leftLightPct > 20){
    Serial.println("Seeking sun!");
    digitalWrite(enPin, HIGH);
    digitalWrite(dirPin,LOW);
    digitalWrite(stepPin,LOW);
    delay(1);
    digitalWrite(stepPin,HIGH);
  }else if(rightLightPct > leftLightPct){
    Serial.println("Turning CW!");
    digitalWrite(enPin, HIGH);
    digitalWrite(dirPin,HIGH);
    digitalWrite(stepPin,LOW);
    delay(1);
    digitalWrite(stepPin,HIGH);
  }else{
    Serial.println("Turning CCW!");
    digitalWrite(enPin, HIGH);
    digitalWrite(dirPin,LOW);
    digitalWrite(stepPin,LOW);
    delay(1);
    digitalWrite(stepPin,HIGH);
  }
}


text:
Circuit works on breadboard but has power problems on protoboard
I'm building a simple circuit that takes data from an IMU (using MPU6050), sends it to a microprocessor (Arduino Pro Mini 5V) to apply data smoothing and averaging, and then this data is sent using an HC-08 BLE module for the data to be further processed on a mobile. The circuit is powered by a 9V battery (6LR61) connected to RAW (Vin on other Arduino boards).
When I build this circuit on a breadboard, it works well, but the Arduino is power hungry as expected. It runs for over an hour in this setting (I haven't tested it for longer), but I've build this circuit twice using protoboards and it can't stay on. One circuit is able to send data for a while, but the LED on my BLE module dims and eventually turns off after ~5m, and requires me to wait 30+m before I try to power the circuit again. The other circuit has all LEDs shine when power is switched on, but the IMU doesn't send any data (an LED on the Pro Mini blinks whenever I2C data is received).
The shitty thing is that, whenever I power these circuits via USB, they work as intended, just like when I power them using 9V to RAW on the breadboard.
I tested the circuit on the breadboard later and after BLE has connected and is sending data, the whole circuit draws 42.9mA, the BLE module draws 1.5mA, and the IMU draws 5.4mA.
What is the most effective way to fix this problem? Should I focus on finding a different battery, or focus on power-savings within the circuit?
These are my ideas so far:

replace all boards with 3.3V versions
reduce clock speed (might not be viable, I need a lot of IMU data?)
use external voltage regulator, connect Vout from regulator to 5V of pro mini
replace 9V battery with Lithium Ion battery
replace Pro Mini with an ATtiny85

I'd like to take the least time to maximize power savings, so while I could go through all these ideas, I just need the circuit to work at the end of the day.

Where do the other 36mA’s go? Try doing some more measurements. My guess is that it’s mostly due to the regulator(s), on the pro mini. If so using a separate voltage regulator would help. Also ditch the 9V. Those are just 6 AAAA batteries in a packed together, and can only supply 400mAh. Lastly, the might be an issue with not having enough bypass capacitors. Breadboard have some capacitance due to how the are constructed. Switch to protoboard, glitches may occur due to no longer having bypass capacitors. Not sure if that’s the case here, but that immediately came to mind reading only the title

36mA sounds about right for an Arduino.

I have a page about power saving.
To summarize some of the techniques you can use:

Run the processor at a lower frequency
Run the processor at a lower voltage
Turn off unneeded internal modules in software (eg. SPI, I2C, Serial, ADC)
Turn off brownout detection
Turn off the Analog-to-Digital converter (ADC)
Turn off the watchdog timer
Put the processor to sleep
Don't use inefficient voltage regulators - if possible run directly from batteries
Don't use power-hungry displays (eg. indicator LEDs, backlit LCDs)
Arrange to wake the processor from sleep only when needed
Turn off (with a MOSFET) external devices (eg. SD cards, temperature sensors) until needed

I've got a temperature and humidity sensor which has been running for years on 3 x AA batteries.

The circuit is powered by a 9V battery (6LR61) connected to RAW (Vin on other Arduino boards).

That's not a great choice for a start, as the voltage regulator has to turn the 9V into 5V (in the form of wasted heat). You'd be better off with 3 x AA batteries (around 4.5V) and put them straight into the 5V pin.
Those 9V batteries have notoriously low mAh because they are basically 6 coin cells stacked on top of each other.

What Nick said about wasted heat sound very much like the issue you are having. The tiny little regulator on the board has to drop ~4 volts (=9-5) at 50mA or 0.2 watts which is fine for a while, but then the heat builds up, it goes into thermal overload protection, and won't run until it cools down. The 30 minutes seems excessive, as it should cool faster than that, but perhaps you meant 30 seconds? Could be something else.

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


text:
Did I overheat my Arduino while soldering to perfboard?
So this is the second time that I've had a circuit that worked perfectly on a breadboard, but as soon as I connected it to a perfboard and soldered the joints together, the Arduino stopped working and wouldn't let me upload sketches (though I could see a COM port for it).
I'm using lead-free solder for the first time, and had the temperature at 750 deg Fahrenheit, and I'm thinking that while I had quick joints to connect the Arduino to the perfboard, when bridging two joints with solder, the iron might have been heating the header pin for 4-10 seconds... Is that enough to break the board?

(note - I'm using jumper wires on the other side to connect everything up, and I've already checked the board's connections using a multimeter and they're all as intended, and there are no accidental shorts/bridges)

That's rather unlikely, especially as your Arduino is a module rather than a bare chip, there's a fair amount of distance between the pins you are soldering on and those of the chip.  Melting the plastic web of the headers would be more likely though of little consequence once mounted.  Unfortunately, it's not really possible to tell what is actually wrong from the very limited information in your question.

-1 for lead-free. -1 for not enough flux. pro-tip: use a socket or female pin headers instead of welding to the board; prevents heat damage and lets you swap out failed parts.

I would like to clarify that my only question in ENTIRE post was: "Is that enough to break the board?"

The answer to that narrow question is that heat from soldering with an iron is extremely unlikely to have done this.  IC's are in practice (vs data sheet) quite heat tolerant, and further the pins you are soldering on are not even the pins of the IC or any electronic components, but rather those of the module headers.  You'd be more likely to melt the plastic web between those headers pins, but even that won't be a great problem since they are already in place. Or if you were soldering directly on the board, lifting a pad or trace - but you were not doing that.
Your actual problem is something else, what that might be is presently unanswerable due to the lack of detail in your question.

yeah, I'm also really perplexed at what my actual problem might be, so I've already asked an entire other question about it with more detail - https://arduino.stackexchange.com/questions/50329/ . I'll admit, my problem is ambiguous so even though that post has as much detail as I can think to include, I'm really stumped and not sure it's the kind of question that can be answered without being physically present

Bridging adjacent pins by heating for 10 seconds is not a great way of doing things. You are trying to cross the "solder resist" with solder, so you are basically fighting something.
I normally use some tinned copper wire to cross gaps like that. You should be able to keep the soldering times down to a couple of seconds.

Did I overheat my Arduino ... ?

We can't really say from where we sit, but maybe.

I could see a COM port for it

The Pro Mini doesn't have a USB chip, so how are you programming it?

I am using an FTDI breakout board to program the Pro Mini, which then attaches to a USB cable.

Right, well you are seeing the COM port from the FTDI breakout board, not the Arduino as such. You would see that even if there was no Arduino there at all.

The soldering on one of your pins (5th from the bottom, on the right) looks a bit dodgy. It might just be the light.
As I said earlier, you possibly overheated the processor chip. I would use the technique I described rather than a 10-second heat.
See my question/answer: Have I bricked my Arduino Uno? Problems with uploading to board - that describes various tests you can do to check if the processor is still good.

This is not much of an answer...  Seems like this should be a comment

It's like asking "did I burn my roast beef"? How are we supposed to know that? However we can talk about ways that roast beef could be burnt. Feel free to post a better answer.

We arent, and there isnt one.   Questions do not require an answer, if there is none, there is none.

Chad has a good point - questions which are unanswerable aren't supposed to get non-answer answers, rather they are supposed to receive comments towards improvement and/or close votes.

I would like to clarify that my only question in ENTIRE post was: "Is that enough to break the board?" This question objectively has an answer. I simplified the question in the title so that people would know what this post is about, but if the answer is "yes, that could break the board," then follow-on tips on how I can not overheat future circuits would be appreciated (?)

I am using an FTDI breakout board to program the Pro Mini, which then attaches to a USB cable.

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


text:
Wire.h library works on Uno but won't compile for ATtiny85
TL;DR:

Arduinos are current hungry so I want to switch my microcontroller
code works on Uno, I change upload to ATtiny85, code doesn't compile
Wire.h breaks at the TWBR input
Should I keep trying to fix this or should I just use ATmega328P without the Arduino?

So I'm working on a project where I send data from an IMU (MPU6050) to a phone using Bluetooth LE (HC08) with a bit of signal filtering by a microcontroller in between. I've been using Pro Minis but the amperage consumption by these boards is ridiculous, so I'm trying to replace these with some ATtiny85's that I have laying around.
The problem is, the Wire.h library won't compile for the ATtiny85. It's also worth noting that the default MPU6050 code mandates use of an interrupt pin, which ATtiny's don't have, so I've modified the code to work without it (I'm not sure if that's part of the problem).
#include <SoftwareSerial.h>
#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
#include "Wire.h"

//==============================================================================
// MPU6050 initialization code
MPU6050 mpu;
uint16_t packetSize;
uint16_t fifoCount;
uint8_t fifoBuffer[64];
Quaternion q;
VectorInt16 aa;
VectorInt16 aaReal;
VectorInt16 aaWorld;
VectorFloat gravity;

//==============================================================================
// microcontroller initialization code
int avg_counter = 0;
int pts_to_avg = 15;
int * x_array = (int*)malloc(sizeof(int) * 25);
int * y_array = (int*)malloc(sizeof(int) * 25);
int * z_array = (int*)malloc(sizeof(int) * 25);

//==============================================================================
// HC-08 initialization code
const byte rxPin = 3;
const byte txPin = 4;
SoftwareSerial bleSerial(rxPin, txPin);

//==============================================================================
void setup() {
  // MPU6050 setup code ========================================================
  Wire.begin();
  TWBR = 24;
  mpu.initialize();
  mpu.dmpInitialize();
  mpu.setXAccelOffset(-1343);
  mpu.setYAccelOffset(-1155);
  mpu.setZAccelOffset(1033);
  mpu.setXGyroOffset(19);
  mpu.setYGyroOffset(-27);
  mpu.setZGyroOffset(16);
  mpu.setDMPEnabled(true);
  packetSize = mpu.dmpGetFIFOPacketSize();
  fifoCount = mpu.getFIFOCount();

  // microcontroller setup code ================================================

  // HC-08 setup code ==========================================================
  // make sure your HC-08 is set to the same baud as below!
  bleSerial.begin(19200);
  delay(100);
}

//==============================================================================
void loop() {
  while(fifoCount < packetSize){
    fifoCount = mpu.getFIFOCount();
  }

  if(fifoCount == 1024){
    mpu.resetFIFO();
    bleSerial.println(F("FIFO overflow!"));
  }else{
    if(fifoCount % packetSize != 0){
      mpu.resetFIFO();
    }else{
      while(fifoCount >= packetSize){
        mpu.getFIFOBytes(fifoBuffer, packetSize);
        fifoCount -= packetSize;
      }

      mpu.dmpGetQuaternion(&q,fifoBuffer);
      mpu.dmpGetAccel(&aa, fifoBuffer);
      mpu.dmpGetGravity(&gravity, &q);
      mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity);
      mpu.dmpGetLinearAccelInWorld(&aaWorld, &aaReal, &q);

      // points are averaged to keep the baud low w/o FIFO overflow
      if(avg_counter <= pts_to_avg){
        // add live data to this array and hold onto it to be averaged
        x_array[avg_counter] = aaWorld.x;
        y_array[avg_counter] = aaWorld.y;
        z_array[avg_counter] = aaWorld.z;
        avg_counter++;
      }else{
        // average data from the array
        int x_average=0;
        int y_average=0;
        int z_average=0;

        // sums the data in #_average
        for(int i = 0; i < avg_counter; i++){
          x_average += x_array[i];
          y_average += y_array[i];
          z_average += z_array[i];
        }

        // divides by avg_counter (which should == pts_to_avg)
        x_average /= avg_counter;
        y_average /= avg_counter;
        z_average /= avg_counter;

        // resets counter so the array data can be overwritten with future data
        avg_counter = 0;

        // prints data to serial port (if BT is connected, sends via BT)
        bleSerial.print(x_average);
        bleSerial.print(",");
        bleSerial.print(y_average);
        bleSerial.print(",");
        bleSerial.println(z_average);
      }
    }
  }
}

When using Arduino as ISP, selecting "Board: ATtiny25/45/85", "Processor: ATtiny85", & "Clock: Internal 1MHz", the following error showed up:
exit status 1
'TWBR' was not declared in this scope

this error did not occur when compiling for the Uno. If you comment out TWBR, then you get an enormous error message (I'll only paste a bit):
In file included from c:\users\auphynne\appdata\local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2\avr\include\avr\io.h:99:0,

                 from C:\Users\auPhynne\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\Wire\src\utility\twi.c:25:

C:\Users\auPhynne\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\Wire\src\utility\twi.c:426:15: error: 'TWINT' undeclared (first use in this function)

    TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;

               ^

C:\Users\auPhynne\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\Wire\src\utility\twi.c:426:28: error: 'TWSTA' undeclared (first use in this function)

    TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;

                            ^

C:\Users\auPhynne\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\Wire\src\utility\twi.c:426:40: error: 'TWEN' undeclared (first use in this function)

    TWCR = _BV(TWINT) | _BV(TWSTA)| _BV(TWEN) ;

                                        ^

exit status 1
Error compiling for board ATtiny25/45/85.

To try to remedy this, I went into
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src\utility\twi.c

and hardcoded this line from
// initialize twi prescaler and bit rate
cbi(TWSR, TWPS0);
cbi(TWSR, TWPS1);
TWBR = ((F_CPU / TWI_FREQ) - 16) / 2;

to
// initialize twi prescaler and bit rate
cbi(TWSR, TWPS0);
cbi(TWSR, TWPS1);
TWBR = 24;

and I still got the same gruesome error message.
Pins are what you'd expect, 5v power to both modules and grounded, plus:

Uno D4 -> HC08 RXD
Uno D3 -> HC08 TXD
Uno SCL -> MPU6050 SCL
Uno SDA -> MPU6050 SDA

(again note that the interrupt pin is not used, and this worked quite well when building on the Uno! I got data on my phone's BT serial terminal app so that doesn't seem to be the problem)
Any ideas on how I can get Wire.h to compile on my ATtiny85?
Or... should I just abort and go with the ATmega328P (without the accompanying Uno) since it comes in the Quad Flat SMD package? (footprint matters for the long term)

If you really want to minimize power consumption, you should probably connect the sensor directly to custom firmware on a BTLE MCU, without an intervening part.  You can run Arduino code on an nRF51822, though that may not be the lowest power software approach for it.  Also a MEMS sensor + BTLE is a common demo for the companies which make the latter, so you may be able to find the hardware already made with working example software.

I'd suggest going with an Arduino Pro Mini, (and an external usb-to-serial converter). Those use the same ATMega328P, but without the power wasting extra's of the uno. They are also a lot smaller. You could do some modifications to the board to get a bit more battery life, like removing the power led.

I am getting the same error even though I am using <TinyWireM.h> as the other libraries are <Adafruit_BNO055.h> and <SparkFun_Qwiic_OpenLog_Arduino_Library.h> use Wire.h library and ATTiny85 throws an error during the compilation. Can anyone help please. Code (Just including the libraries causes the error) #include <SparkFun_Qwiic_OpenLog_Arduino_Library.h> // Data logger #include <Adafruit_BNO055.h> //IMU #include <Adafruit_Sensor.h> #include <TinyWireM.h> #include <utility/imumaths.h> void setup() { // put your setup code here, to run once: } void loop() { // put your main code here, to run

You get this error, because the ATTiny85 doesn't have full I2C hardware. It only as an USI (Universal Serial Interface). This can be utilized to do the rest of the I2C protocol via software. There are some libraries out there to do that, most of them are somewhat named TinyWire. There were dedicated libraries for master and slave operation named TinyWireM and TinyWireS. And I composed one library with both functionalities (and some more) in TinyWire. The last one - I think - is not usable for you, because theSoftwareSerial library needs the PinChangeInterrupt to work, but TinyWire uses it for detecting stop conditions on the I2C bus.
So for your case you can use the TinyWireM library. Note that the master operations need exact timing. Using to much interrupts in this time can cause problems in transmission. Test it and disable interrupts, if it is needed.

I'm using the MPU6050 in my project and the library MPU6050.h, which is includes library I2Cdev.h, which includes library Wire.h and uses it a lot - I have a sinking feeling that it will not suffice to replace all instances of Wire.foo() with TinyWireM.foo() in the I2Cdev.h library.. ? The library TinyWireM.h absolutely looks like the right solution, thank you so much, but if implementing it is going to be too complex I'm not sure I'd have the coding skill to pull it off (in which case I'll just stick with ATmegas :l )

In principle the TinyWireM library has many of the same functions as the Wire library (except for the slave functions). But there might be other issues, with simply changing this. You can try to change it, the easier way would be to use an Arduino Pro mini (as mentioned by Gerben). And if this answered your question, please mark it as correct :D


text:
parse intel hex into SPI commands for arduino ICSP AVR
I'm attempting to use the arduino as an ICSP AVR to flash hundreds of ATMEGA's 90USB162.  I'm having some difficulties when trying to do the actual flashing of the chip.  I've go all the wires done properly and I'm able to read the signature.  My source is an Intel hex file and I'm reading it properly as I'm able to see each by as it is read from the arduino's memory.  Where I'm getting lost is the documentation states that I need to set the low byte first before I set the high byte for the same memory address.  Using the following as an example (underscores to break the data up) could someone help me descern what my SPI transaction bytes would look like?
:_20_0000_00_16C100003CC100003AC1000038C1000036C1000034C1000032C1000030C10000_48

I know the colon is the start code, 20 is the hex value of number of data bytes,  0000 is the address, 00 is the record type,  the next 32 bytes is my data followed by the checksum.
I thought that I would loop over the data portion and increment the address every other byte
uint16_t addr = 0;

while (recordtype != endOfFile)
{
  auto data[] = parseData();

  for(uint8_t index = 0; index < 32;)
  {
    SPITask.Send(0x40, 0x00, addr, data[index++]);//send low byte
    SPITask.Send(0x48, 0x00, addr, data[index++]);//send high byte
    SPITask.Send(0x4C, addr, addr, 0x00);//commit new bytes to address
    addr++;
  }
}

I don't think this is right and some examples i'm loosely following comment that they are changing the address byte into a word, which makes some sense based on the command layouts of the data sheet (page 260) 90USB162 Data sheet.  Can anyone please provide some guidance in how to break up this data into high and low bytes.

I have some code that does exactly what you want on GitHub.
Amongst other processors, it supports the At90USB162 chip. The code reads from an SD card in Intel hex format and writes to the chip at the press of a switch. This effectively is what you are trying to do.
Arduino forum moderator "Crossroads" (who has recently also joined Stack Exchange) has made a board to do the programming, hold the SD card, and have some status LEDs:

Here is my code to write to the flash:
// execute one programming instruction ... b1 is command, b2, b3, b4 are arguments
//  processor may return a result on the 4th transfer, this is returned.
byte program (const byte b1, const byte b2 = 0, const byte b3 = 0, const byte b4 = 0)
  {
  noInterrupts ();
  BB_SPITransfer (b1);
  BB_SPITransfer (b2);
  BB_SPITransfer (b3);
  byte b = BB_SPITransfer (b4);
  interrupts ();
  return b;
  } // end of program

// write a byte to the flash memory buffer (ready for committing)
void writeFlash (unsigned long addr, const byte data)
  {
  byte high = (addr & 1) ? 0x08 : 0;  // set if high byte wanted
  addr >>= 1;  // turn into word address
  program (loadProgramMemory | high, 0, lowByte (addr), data);
  } // end of writeFlash

Your loop looks a bit strange, the page size (before you need to commit) is 128 bytes (64 bytes), not 2 bytes.
See the datasheet:

Are these boards available for purchase anywhere?

http://www.crossroadsfencing.com/BobuinoRev17/Programmer.html

Yes, boards are available as noted. I accept payment via paypal and can have one in the mail for you tomorrow. Send me e-mail at robert@crossroadsfencing.com.

(xtreampb  said in a comment under a now-deleted answer): I don't see where it also will flash the EEPROM of the target which is something I also desire with my final product - however this is not mentioned anywhere in the question.


text:
Can't identify + or - in the 5v USB wall adapter, does it matter?

I want to power the UNO with the USB power adapter (the charger of a phone), the adapter delivers 5.0 volts and comes from the wall (in the photo a regulator is added). However, the legs of the USB adapter look the same, can I plug it to the wall indistinctly like I do when I charge the phone, or do I need to know which leg is + and which one is - ? (I don't have measurement equipment).

the circuitry of the adapter corrects the polarity to the USB cable for you.

Does the phone charge OK whichever way you plug it in? If so, why wouldn't the Arduino?

Power (which comes from your wall outlet), is AC, which means alternating current. It changes 50 or 60 times per second from direction, so this is the reason it does not matter if you plug it reversed or not. Some countries have plugs which can be plugged in normally or 180 degrees rotated (but you cannot see what is 0 or 180 degrees since these are symmetrical).
The circuit inside the adapter makes sure the AC is converted to DC, where it matters what is Plus or Minus.

It does not matter which orientation you plug it into the mains plug.
The power supply produces the same 5V regardless, and the USB plug has a fixed/standard polarity on the pinout.


text:
Distance from Arduino UNO to LCD: How far?
How far from the UNO can I place an LCD (the typical 16x2)? Assuming that everything that is plugged into the LCD comes directly from the Arduino (power and data).
I'd like to mount the LCD on the wall at eye level, my "box" will be on the floor, close to a power source.

Sounds like you are talking 6 feet or so? That should be fine,   I have found that I2C starts needing extenders around 10 feet or so. If you can slow the data rate down that would help as well.

The actual distance depends highly on several other factors:

Wire thickness / current carrying capacity / resistance
RFI (Radio Frequency Interference) environment
Data rate that you write to the LCD (Maybe you are using an I2C or SPI backpack)

In general, even 5 meters is probably going to work if you use sufficient wiring, but try it and see.
You may also need to add shielding to mitigate RFI.


text:
Use LoLin V3 pins starting with 'S' in Arduino
I have this LoLin NodeMcu V3 board:

What are the pins S3, S2, S1, SC, S0, SK?
Can I use them as GPIO in Arduino?
Thank you for your help!

my experimentation notes say you can use GPIO 10 (S3) as an input, but only after boot.

These pins have 2 functions: They are the connections to an SD card and/or to its internal flash chip. The ESP8266 has the feature of when you set GPIO15 HIGH during bootup, it will load the program from SD card and execute it. See here for reference. On the normal board, these pins are however connected to an internal flash chip.
Signal name meanings:

SK: Serial Clock
SC: SPI Chip Select
S0 to S3: Data lines (Quad-I/O mode).

This picture found here explains the pins:

But as @Majenko already said, only the chip documentation matters, which is here:

Now to answer the actual question: Can you use these pins for arbitrary purposes? That depends. On the board they are all internally connected to a Quad-SPI flash chip. If you re-assign these pins to GPIO pins during normal operation in Quad-SPI mode, the chip hang up as the you just cut off one of the important lines to flash chip. However, if you really want you can modify your chip and cut two connections from the flash chip. Quad-SPI uses 4 data lines, but you can also operate the chip in Dual-SPI with 2 data lines (refer to here).
That means that you are able to cut 2 of the 4 data lines, GPIO9 (SPI_HD, S2 on the board) and GPIO10 (SPI_WP, S3 on the board) on the PCB from the ESP8266 to the flash chip and then use these two GPIO pins arbitrarily. This is to avoid interference with the flash chip when you are driving random signals to it while the lines are still physically conencted to the flash chip. You will ofcourse need to tell your flash tool (esptool.py) to use Dual-SPI mode for all subsequent firmwares. See here for that.
All other Flash GPIO pins can not be re-purposed, these conenctions (such as SCLK, MISO, MOSI, CS) are always needed for the flash chip.
GPIO15, which is D8 on the board, is easier to repurpose: You just need to make sure it's LOW during startup as to not trigger the SD card bootup by using a pulldown resistor. After flash bootup you can re-purpose it for input and output. This is already done on the board for you and you just need to use pinMode to set it as INPUT or OUTPUT. This is also described in here.
Obviously that's a lot of trouble to get 2 GPIO pins. If you just want more GPIO, you will find an I²C GPIO port expander such as the MCP23017 much more suitable for that -- 16 more GPIOs at the cost of 2 GPIO pins (the I2C bus). If you're already using the I2C bus in a project then you don't even loose additional GPIOs, it's just one more device on the bus.

My guess is those are the SDIO pins. They're meant for use with an SD card - 4 data pins, a clock pin, and a select pin.
To find out what more you can do with them you should ignore the fact that it's a "LoLin" and instead just look for documentation on the ESP8266 or ESP32 (whatever it is on there) that powers that board.


text:
Send IR success but doesn't turn on the TV
My circuit is simple:
IR sensor (from left to right): PIN 11, GND, 5V
IR transmitter: GND, PIN 1 (via resistor). (BTW: all of the tutorials I read says that the PIN should be 3 but from some reason it sends only when it connected to PIN 1. How do I know? because I can "see" the light via the mobile's camera like the image below)

I'm trying to "record" an IR signal and sent it. The code come from gits I found:
#include <IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);
IRsend irsend;

boolean recording = true;
decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (recording) {
    if (irrecv.decode(&results)) {
      Serial.println("IR code recorded!");
      //irrecv.resume(); // Receive the next value
      Serial.print("Recorded ");
      Serial.print(results.rawlen);
      Serial.println(" intervals.");
      recording = false;
    }
  } else {
    // replay mode
    for (int i = 0; i < 3; i++) {
      Serial.println("Sending recorded IR signal!");
      irsend.sendRaw((unsigned int*) results.rawbuf, results.rawlen, 38);
      delay(40);
    }
    delay(2000);
  }
}

https://gist.github.com/jeje/3027236
Like you can see in the image, the signal is sent but it does nothing to the TV (I record the TV's remote of course)

Are you sure your remote runs at 38kHz?

@Majenko thanks! I'm not. I thought that it's kind of generic. How can I know? Can I print it somehow?

You can only really know by connecting a photodiode up to an oscilloscope and examining the actual waveform directly.

Can I use the arduino to exam it?

pin 1 is Serial TX. on Uno. what is your board?

Pin 3 is way more sensible on an Arduino Uno/Nano because it can do PWM. The library needs to pulse out a 38kHz PWM modulated waveform at a PWM capable pin. The reason you are able to see the infrered LED light up at pin 1 is because that is the TX of your UART at 9600 bits per second, way slower than the IR PWM. You must use the pins outlined in https://github.com/z3t0/Arduino-IRremote

Also double check the contents of results.rawbuf becore sendRaw, e.g. by serially outputting every byte. Maybe you're sending something different than what you want.

I believe, I see an receiver IC on your board. If it is one for 38kHz modulated IR signal and you receive pulses from it, then your remote definitely works with 38kHz

@MaximilianGerhardt the thing is I can't see the light in pin 3 and also, it doesn't work. I can see the light in all of the remotes I have. Why it's different in the arduino?

@chrisl I don't know what is receiver IC. Also, why do you think it's not working?

By the way, my arduino is uno r3 based on atmega328p-pu. And I can't find it in the list of the IR library.

Try attaching an visible led for debugging. Most remotes the the code multiple times, so that might explain why you can see those codes, but not on your own, is your own is just too short.

Your Uno R3 belongs to the ATMega328 section of that table, i.e. transmit on Pin 3 (and using Timer2). And you are right, you should see something there on Pin 3. I would exchange the IR LED for a normal red LED and look at in a dark room. You should see a very dimm light being emitted. What's the value of your resistor?

Can you tell us what is your TV model ?
Let me explain why: the freq and codes used in remotes are (almost) normalized. Therefore, by knowing your TV model, you could find the right IR protocol. There are libraries for IR codes in Arduino, if your TV model IR protocol matches one available in arduino IR lib, then you're done.

I will try to connect regular led to PIN 3. Thanks! I tried 220 and 1k resistors.


text:
Is it bad to power a arduino mega with 6V via USB?
I'm working on a project where there is no external 5V voltage regulator available but only 6V. I can not power it through the power jack because via this way I do not have enough current and get thermal shutdown.
Can I power it via 6V over USB? at the moment I'm trying this out and it works but what are the long term risks I'm prone to?

yes, it is bad.

The Absolute Maximum Operating Voltage of the ATMega2560 is 6.0V. The same applies to the ATMega8u2 that does the USB to Serial on the Arduino Mega board.
Recommended maximum voltage is 5.5V
So yes, you can run it at 6 Volts, but you are right on the edge, so I wouldn't recommend it.
Possible risks are a decreased lifespan of the Arduino, and there might be some stability issues.
If the application isn't safety critical, and you don't mind having to replace the board after it failed in, say, two year of operation, it could be an acceptable risk (if there are no easily available alternatives)
PS you might want to measure you power supply. It may say it's 6V but could give out 6.2V. The output voltage of some supplies also vary with the load that's across it.

The incomming voltage is actually indeed 6.2 voltage

put a diode (or two) on the incoming rail to drop it 0.6 (or 1.2)v.

We actually have a din rail inside the project. So we were planning on doing just that.

Voltage drop across a diode depends on the current, so it won't give a very stable voltage (like a regulator does). But it will probably be fine.

Is it bad to power a arduino mega with 6V via USB?

Yes, the Arduino Mega is not designed to be powered that way and you are probably abusing the USB specifications. USB can supply higher voltages than 5V but only if it is properly negotiated with the device.
The schematics (see Documentation tab) show a 5V regulator powered from the 2.1 mm Power-connector or from the "Vin" header pin. If the regulator specs say it can work from 6V, you should probably use that instead. However although the 1870_LD1117S50CTR seems to be a low-dropout (LDO) regulator, it has a dropout voltage of 1V. So I wouldn't power it from a 6V source - that seems equally marginal.
In short, I think you really need to find a more suitable power source.


text:
ESP32 reading analog 2.4Ghz
Is there a possibility to analog read on the 2.4Ghz band to just read how much activity is in the presence of your device? Not parsing the messages but just listening to how strong of a signal you are getting on a specific bandwidth?
All information is welcome.


text:
Cannot connect through /dev/ttyACM0 (Ubuntu 18.04)
I am using an Arduino UNO which worked fine until today. My system: Ubuntu 18.04
Now, the IDE can no longer connect to it:

Cannot do any sketch upload
Cannot ask for board info
No USB ports shown in tools --> port (only 2 serial ports shown)
ttyyACM0 not showing up in /dev

However, both lsusb and dmesg show that the board is recognized somehow.
lsusb output:
Bus 001 Device 012: ID 03eb:2fef Atmel Corp.
dmesg output:
[ 2922.171042] usb 1-1.3: new full-speed USB device number 12 using ehci-pci
[ 2922.282047] usb 1-1.3: New USB device found, idVendor=03eb, idProduct=2fef
[ 2922.282052] usb 1-1.3: New USB device strings: Mfr=0, Product=1, SerialNumber=0

The problem is the same on 2 different computers, which leads me to suspect that there is something wrong with the board. Is it possible that a board be shown by both dmesg and lsusb and still be malfunctioning ?

problem with 16u2 firmware?

The board was bad. I just replaced it and it now works.
So, to answer my own question, an Arduino board can show up on lsusb and dmesg and yet be faulty. This is what the dmesg output is for a healthy board:
[10492.388028] usb 1-1.4: new full-speed USB device number 13 using ehci-pci
[10492.500520] usb 1-1.4: New USB device found, idVendor=2341, idProduct=0043
[10492.500526] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=220
[10492.500529] usb 1-1.4: Manufacturer: Arduino (www.arduino.cc)
[10492.500533] usb 1-1.4: SerialNumber: 55736323739351010292
[10492.520354] cdc_acm 1-1.4:1.0: ttyACM0: USB ACM device
[10492.520832] usbcore: registered new interface driver cdc_acm
[10492.520835] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

And here is the lsusb output:
Bus 001 Device 013: ID 2341:0043 Arduino SA Uno R3 (CDC ACM)

Judging on the difference with the previous outputs from both commands (when the faulty board was connected), it seems that my board had reverted to the basic Atmel USB interface and that the Arduino specific USB handshake was not working. Can anyone confirm ?

the USB interface on Uno is an ATmega 8u4 or 16u4. it is an AVR MCU with native USB port programmed to send data to the main MCU of the board (328p). if the firmware in 16u4 is corrupted the native USB port connects but the virtual serial port is not created https://www.arduino.cc/en/Hacking/DFUProgramming8U2


text:
ESP8266 check if TCP client disconnected...informally
Hi with ESP8266WiFi library, I usually check for connection of a TCP client with client.connected().
But it seems to still return true if my TCP client in an unexpected way (like disconnect to WiFi/ Power loss/...). Which leaves my program stuck in a infinite loop.
Is there a more reliable to check for connection status?

You have the inherent problem that a TCP connection is terminated by an explicit "FIN" message from the terminating party, followed by a FIN-ACK and ACK.

Refer to here.
If your client (or server) just powers off without closing the connection properly, that's it. The connection hangs up and no data will be transfered if it is not explicitly handled.
If you must know whether the client is still there, you must use a heartbeat meachanism. That is, after some period time without a response has passed, query the connection party with a "heartbeat" message and see if it responds after a given maximum time. The other way around would be to make the client send a periodic "Keep Alive" message which holds up the connection as long as it is sent repeadetly.
Refer to here and here.

Thank to your answer I understood the general idea.  I can't find any way to check for the KeepAlive message in the ESP8266 library. So I manually send data to client after x idle seconds, close the connection if the client doesn't reply. On the back of my mind I feel like there would be an built-in way to do this, is there?

@MoonFan I couldn't easy find a general piece of code that does it in all cases. You'll have to implement one yourself using a timer to keep track of timestamps (last message received / sent, ...). Besides millis you could a more sophisticated timer library.


text:
Zero-ing Compass | Following Magnet Strip Robot
So my problem is purely programming, I understand the problem but can't figure out what to do, Is there a library? should I create my own code for Zero-ing my compass so I don't have value from earth field in my equasion?
I have a small robot that I want it to follow a refrigerator magnet strip that is incrustated in floor
The compass on its own works well but I want to be able to drive my robots by a positive or negative value that I would receive from a library/function I coded off values from library of compass
The actual problem is that earth magnetic field will offset my value
Lets say north is on the left and magenet is also on the left. I should receive for example -1000 Gauss
but then if I put the magnet to the right but keep the same oriantationg of the magnet I will receive -500 when I really wanted 500 for example.
Now id like to take a measurement of earth magnetic field first and from there subtract current value off the actual values i get.
But my understanding of vector is very limited.
Doing this for a compass that its oriantation don't change would be pretty simple but, in my case compass will be mounted on robot itself therefore orientation will change all the time
Im not looking for some code but more a general idea on how to do this, either by using a library or some maths idea on how to acheive that.

As you've noted, the fact that your platform rotates means that you can't directly do this.  First consider if the earth's field really makes enough difference when you are close to the strip.  If it does, you might need to add orientation tracking via wheel encoders and/or a gyroscope (tricky but getting surprisingly good in drones). Or perhaps you should look at using two sensors displaced left and right, or one near the ground and one raised in the air to detect the earth reference field with less influence from the strip.

Thanks @Chirs i could put one in the midle and the substract from this.  But i really feel like its posible to get a reading with nothing except earth mag field and use it as a calibration to substract and get only the actual magets around the sensor on each axis on all axis.  I just dont know where to start for this

It might be easier to use hall effect sensors instead of a compass. Use them like optical sensors for a normal line following robot.

@Majenko Yep I would do that, but i want to utilize the north and south pole of the magenet, so i can count where the robot is at in its trajectory.

@NicolasRacine analog hall sensors detect the polarity of the field not just the strength

i don't know if this would work, but you could try to orient the compass along one of the other axes. ... or use a separate compass along each axis

@jsotola What do you mean?  Can you elaborate ?

i used the compass app on my phone to detect the magnetic seal on my fridge .... i got a different response when i turned the phone sideways ... i was talking about the xyz axes in 3d space in my comment


text:
How does input from IR receiver to Arduino UNO board work?
I have a very simple circuit with an Elegoo IR receiver module connected to an Arduino UNO. The three wires are connected correctly with the data wire (Y) connected to pin 8. The code works fine, as every time I press button on the remote, the Serial Monitor displays the corresponding button description.
However, I do not understand how Arduino's pin 8 knows which IR button has been pushed. My understanding is that pin 8 can read either 5V or 0V, but to know which of 20+ remote buttons has been pushed it would have to read PWM. But pin 8 does not the PWM icon next to it and yet it works fine. Unless the PWM icon applies only to pin output? Or is there another way I have failed to find info about?
Thanks!

What do you actually mean by pwm "icon"?

@yannism mean that Pin 8 is not a PWM pin, look at a Arduino UNO pin layout.

Serial RX works on one pin too

The PWM icon says that the pin can be used as PWM output. The remote sends a series of pulses (for instance here there is a brief analysis on the NEC protocol - be aware that there exist many more). You will need to decode the pulses lengths to get a code which represent the key. The IRRemote library was done to help in this task (I used it once to control a robot with a remote controller)

You confuse the different technologies here.

PWM is only an output, not an input. So every pin marked with the PWM symbol can OUTPUT a PWM signal. Reading a signal is a totally different task with different hardware involved.
The IR receiver does not output a PWM (meaning Pulse Width Modulation) signal to the Arduino. It ouputs the demodulated IR signal.

So here is what happens: The remote a code, that consists of different periods of "light on" and "light off" (giving pulses of different length, which encode the data from binary format). Since you want to seperate the remotes signal from any other IR signal, that might roam through the air, the remote also modulates the pulses with a special frequency (often this is 38kHz, but might be another frequency around that). This means that every pulse will be chopped into shorter pulses at the specified frequency. This translates to something like: "light on and off with 38kHz for duration x" --> "light off" --> "light on and off with 38kHz for duration y" --> ...
The receiver module senses the IR light comming in and will electronically discard all signals, that don't have the special frequency, and does the demodulation on this. The outputted signal does not have the 38kHz frequency in it anymore. Just the pulses of different length, that encode the data, meaning
The Arduino then reads the length of the pulses (that only consists of sequences of 0V and 5V) and decodes them into a number. This number represents the pressed button.
A proper library for the Arduino can read the different data protocols used in common IR remotes.

Awesome! So basically my understanding was correct in that the Arduino input pin reads pulses, but I thought it was just another instance of PWM, which is not. Thank you!

The remote control emits encoded IR-bursts (each button has its own code) which are transformed into electrical pulses by the sensor (ref. 6. in here: http://eeshop.unl.edu/pdf/VS1838-Infrared-Receiver-datasheet.pdf). On the arduino those pulses are decoded using a proper library.
That means pin 8 is not reading any analog or pwm signal, but TTL-logic at 5V.

Thanks. Will read more on the TTL-logic.


text:
Problems when racing multiple IR controlled Arduino robots
We are attempting to race 3 IR-controlled Arduino robots (Elegoo IR kit), but the IR signal from each remote seems to be picked up by all three receivers. It is possible to create a unique bond between each IR remote and its receiver? Lego Mindstorms IR remote has channels to solve this problem. Anything I can do with Arduino?

With a regular IR (TV) remote, each button has a different code. What is stopping you from using different codes for the different robots?

For example, the directional keys of a remote for robot 1, the numerical keys for robot 2 and maybe a remote from a completely different manufacturer for robot 3.

Not familiar with Elegoo kit... Question is are they using 1 way or 2 way communication? If they use 1 way communication(which is most likely) there's not much you can do since multiple IR signals interfere with each other, and you would need the toys to send back acknowledge signals to the controller, to do error correction... In that case the most you can do is give them each a unique id, and make them ignore anything else then commands associated with their unique id.
If they do 2 way communication you can also make the controller only send a command when a button is pressed, and when it's released, instead of continuous transmission, while also making sure that the command is understood by the receiver. That minimizes interference for other controllers. And if the command was not understood then wait random milliseconds, and repeat it until the receiver understands it.

IR remote signals are OOK-modulated with different base frequencies (the most common are  36 kHz, 38 kHz and 40 kHz). Elegoo seem to use 38 kHz transmitters/receivers, so if you manage to find 36/40 kHz devices, you'll get 3 channels with somewhat reduced interference.


text:
How to convert digital signal to analog value
I have spwm output from arduino, and when i read on analogread it shows only 1023 and 0, because it is digital signal.
Is there any way to convert these spwm value into analog value reading

arduino had 10 bit ADC that means maximum value that you can read is 0-1023. It is an analog signal. or if you want to convert digital value into analog value use can DAC IC easily available in the market.

Thanks try to search it

The problem seems to be clear to you: for slow systems a pwm signal can be considered analog, but measuring at higher rates and without a filter reveales the digital nature behind pwm and all you see is either logic high (1023) or low (0).
Possible solutions are:

apply a filter in hardware (LC low-pass)
apply a filter in software (e.g. by calculating a running mean)
attach interrupts to the rising/falling edge of your signal and measure the high/low time to calculate the duty cycle

Which of those options to choose will mainly depend on the PWM frequency you want to measure. For low frequency I recommend option 3 (special cases are duty cycles around 0% and 100% as there are no edges), for higher frequencies I would use option 1/2.

Thanks very much helping


text:
Adafruit esp32 Feather Failing to compile
So yesterday, I was able to upload/compile given example code to the Esp32 Huzzah board. Today I couldn't even compile. Even carefully using the tutorial adafruit provides.
I was getting errors as given below. How do I fix this?
C:\Users\YbSeconds\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1/tools/sdk/lib\libesp32.a(cpu_start.o):(.literal.main_task+0x14): undefined reference to `app_main'

C:\Users\YbSeconds\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1/tools/sdk/lib\libesp32.a(cpu_start.o): In function `main_task':

/Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/esp32/cpu_start.c:503: undefined reference to `app_main'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o):(.literal._ZN14HardwareSerial9availableEv+0x0): undefined reference to `uartAvailable'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o):(.literal._ZN14HardwareSerial4peekEv+0x0): undefined reference to `uartPeek'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o):(.literal._ZN14HardwareSerial4readEv+0x0): undefined reference to `uartRead'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o):(.literal._ZN14HardwareSerial5flushEv+0x0): undefined reference to `uartFlush'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o):(.literal._ZN14HardwareSerial5writeEh+0x0): undefined reference to `uartWrite'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o):(.literal._ZN14HardwareSerial5writeEPKhj+0x0): undefined reference to `uartWriteBuf'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o): In function `HardwareSerial::available()':

C:\Users\YbSeconds\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1\cores\esp32/HardwareSerial.cpp:157: undefined reference to `uartAvailable'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o): In function `HardwareSerial::peek()':

C:\Users\YbSeconds\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1\cores\esp32/HardwareSerial.cpp:157: undefined reference to `uartPeek'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o): In function `HardwareSerial::read()':

C:\Users\YbSeconds\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1\cores\esp32/HardwareSerial.cpp:157: undefined reference to `uartRead'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o): In function `HardwareSerial::flush()':

C:\Users\YbSeconds\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1\cores\esp32/HardwareSerial.cpp:157: undefined reference to `uartFlush'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o): In function `HardwareSerial::write(unsigned char)':

C:\Users\YbSeconds\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1\cores\esp32/HardwareSerial.cpp:157: undefined reference to `uartWrite'

C:\Users\YBSECO~1\AppData\Local\Temp\arduino_cache_436740\core\core_b15e1ec95534e29a355269b84b798354.a(HardwareSerial.cpp.o): In function `HardwareSerial::write(unsigned char const*, unsigned int)':

C:\Users\YbSeconds\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1\cores\esp32/HardwareSerial.cpp:157: undefined reference to `uartWriteBuf'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Adafruit ESP32 Feather.

So it turns out the problem is that you're using the esp32 1.0.1 library provided by espressif. I'm assuming you're using the Arduino IDE board manager URL: https://dl.espressif.com/dl/package_esp32_index.json
To fix this, don't use 1.0.1. Use 1.0.0! Remove 1.0.1 and install 1.0.0. That should get it to compile properly without the uart, app_main errors.


text:
Is new.cpp programmed improperly? Arduino 1.8.9
I'm having trouble with my code and I'm not sure if it's a memory allocation issue. So I look at the new, delete to see if it throws errors, and finding the source code I find outrageously simple codes. So simple, I think it can't be right.
#include <stdlib.h>

void *operator new(size_t size) {
  return malloc(size);
}

void *operator new[](size_t size) {
  return malloc(size);
}

void operator delete(void * ptr) {
  free(ptr);
}

void operator delete[](void * ptr) {
  free(ptr);
}

Does this mean if I call customClass *ptr = new customClass[10]; it allocates only 10 bytes instead of sizeof(customClass)*10?

when you do new customClass[10] that doesn't mean size_t size = 10

@JaromandaX Yeah... I realized that after I posted the question...

http://www.cplusplus.com/reference/new/operator%20new[]/:

in C++, new[] is an operator with a very specific behavior: An
  expression with the new operator on an array type, first calls
  function operator new (i.e., this function) with the size of its array
  type specifier as first argument (plus any array overhead storage to
  keep track of the size, if any), and if this is successful, it then
  automatically initializes or constructs every object in the array (if
  needed). Finally, the expression evaluates as a pointer to the
  appropriate type pointing to the first element of the array.