Arduino taking forever to upload sketch - arduino

I am using Arduino Uno board and programming it with a Windows 10 system. From the tutorials on Arduino website, I am trying to upload the following code:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
delay(1);
}
It had undergone a series of issues:
First,
avrdude: ser_open(): can't open device "\\.\com3"
I searched for his issue, and found that most common solution is to go to device manager and change the name of the port, then unplug and plug again the arduino board. I did that
Second,
C:\Program Files (x86)\Arduino\hardware\tools\axr\bin\avr-ar:
unable to rename 'core.a'; reason: file exists\\
I thought it could be a memory problem. I used the reset button on the board, and repeated steps from the solution to the first problem. I tried to upload the code again.
But now, I am not getting any error message. But the problem is that it is taking forever to upload the code. I see Uploading... status since a long while. The green progress bar is also complete, but no uploading completed till now.
Any help to understand and solve this will be appreciated.

The solution for me was to disable Apple's Bonjour service with the task manager.

Related

Error "avrdude: stk500_recv(): programmer is not responding" (macOS Monterey)

Recently, I started a project using an Arduino Uno. I am using the Arduino IDE on macOS v12.2 (Monterey). The IDE was compiling and uploading to the Arduino fine; however, recently it still compiles, but keeps sending me the "programmer is not responding error" when uploading.
Below is my code and the steps I have taken to debug so far.
void setup() {
Serial.begin(1000);
delay(50);
}
void loop() {
Serial.print("Hello, World!");
delay(500);
}
First, I tried unplugging, replugging, and resetting my board.
I also made sure that the correct port and board were selected in the IDE.
Furthermore, I deleted the IDE completely and reinstalled it.
Lastly, I switched out the board and wire for other ones and the error still remained.
None of these seem to be the issue as I tested the same program and board on a Windows laptop and it uploaded fine. Additionally, the RX light flashes every couple of seconds and the L light is constantly on, showing proper connectivity. This leads me to believe that there is something wrong with the macOS and Arduino IDE specifically.

ESP32 stucks in HardwareSerial initialization code after software restart

I am working in ArduinoIDE with ESP32 and TFP625A fingerprint sensor. The sensor is connected to UART2 and served by the FPM library using HardwareSerial. Everything works fine until a programmatically reboot is performed - ESP.restart(). After this command, the microcontroller reboots and stucks at the place of sensor initialization. I inserted some Serial.print() into the HardwareSerial source code file and saw that in the HardwareSerial::begin() function, the code does not go further than this place
_uart = uartBegin(_uart_nr, baud ? baud : 9600, config, rxPin, txPin, 256, invert);
As I understand it, after rebooting the microcontroller, information about the previously configured UART2 remains in its registers. Attempts to zero the UART before rebooting the microcontroller do not correct the situation. If I make hardware restart the microcontroller by the reset button, then everything works fine.
How to overcome ESP32 stuck?
Snippets of code:
#include <HardwareSerial.h>
#include <FPM.h>
HardwareSerial mySerial(2);
FPM fpm(&mySerial);
...
void freeFPM()
{
fpm = 0;
mySerial.end();
mySerial = 0;
}
bool fpm_setup()
{
freeFPM();
mySerial = HardwareSerial(2);
finger = FPM(&mySerial);
mySerial.begin(57600);
fpm.begin(0);
}
void restartESP()
{
freeFPM();
ESP.restart();
}
I think you need to include a hard reset of the sensor when the ESP32 restarts. I am not familiar with that particular sensor but I've had similar issues.
What I did was to wire the reset input of the sensor to a GPIO output on the ESP32 and then one of the first steps in the code is to pull down that pin for a short while to reset it.
I think what is happening is that when you first switch on the project the sensor is reset by its own power on reset mechanism but when you do the software reset of the ESP32 the sensor is not also reset, hence why I think you need to do it as I described above.

Arduino and Nextion won't communicate

I am developing a project using Arduino Uno with DTH Sensor AM2302 and Nextion 4024T032 for display. But after running the program I can't seem to find whats wrong with code. After following steps and process, I come to face an error like this, the Serial Monitor prompts the message " ⸮⸮⸮⸮⸮⸮bkcmd=1⸮⸮⸮page 0⸮⸮⸮ ". I don't know what it means or even what caused the error but due to this the adruino can't communicate with the nextion display.
I know it may seem a simple problem and I guess I just missed a crucial part for setting both of the device. But I really don't know where to start looking now. Wish you could all give me some advice or insights. Thanks.
Regarding on my code I noticed that the error is the result of nexInit() function in the void setup() . When I remove it the error disappears but leaving the arduino and nextion no communication whatsoever.
#include "Nextion.h"
#include "DHT.h"
NexText stat_text = NexText(0,1,"t0");
void setup(void) {
Serial.begin(9600);
nexInit();
}
void loop(void){
stat_text.setText ("Server Condition: Normal");
}
I expect the output would be visible in the display which correspond to the object name of GUI in the nextion display.
I have attached the Serial Monitor Error Output. Serial Monitor Error
If you are sure about your arduino code and you are using new library for nextion, you should delete new library and install old library. new library for nextion has problems.

Arduino: Detect code info

Is there any way to detect the code version or any info like last updated or size of code or size of binary code?
Here is example:
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
// turn the LED on (HIGH is the voltage level)
delay(1000);
// wait for a second
digitalWrite(LED_BUILTIN, LOW);
// turn the LED off by making the voltage LOW
delay(1000);
// wait for a second
}
If I upload code to Arduino board, can I detect any info inside Arduino regarding the size of the code or the last modified time or upload time etc?
Thanks.
Compilation date is stored in the __DATE__ macro, the current system time at compilation is stored in the __TIME__ macro. Also useful may be the __FILE__ macro, which stores the filename. Reference (and other relevant macros): http://www.atmel.com/webdoc/avrassembler/avrassembler.wb_preprocessor.Pre-defined_macros.html
There is some interesting discussion about something along these lines here:
https://github.com/arduino/Arduino/issues/5618
In that thread they're discussing ways to store the Git hash of the code at the time of the compilation/upload. If you're using Git version control that information would probably be more useful than last modified time or code size for determining which version is running on your microcontroller and being able to easily retrieve that version. I'm not sure how crazy I am about automatically doing a commit on every upload by you could always squash them later once testing is finalized. If you don't use Git, the same techniques could be adapted to adding any other version information you like and even doing automatic backups of the code at that version.
As explained by facchinm in that thread, recent versions of the Arduino IDE provide hooks throughout the build process that you can use to add additional actions. See:
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification#pre-and-post-build-hooks-since-ide-165
The original proposal is to store the version information in EEPROM. I believe the most common way to do this is via an .eep file. A problem with this idea is that the popular Optiboot bootloader used by the Arduino Uno as well as popular 3rd party hardware packages does not support writing to EEPROM during uploading (in order to fit the bootloader in a 0.5 kB boot section). You would also need to avoid conflicts caused by use of the same EEPROM addresses by the sketch.
The other thought was to instead store it in the code itself. I guess this would be done by using a hook to automatically update a header file "library" that is included by the sketch. e.g.:
#include <VersionTracker.h>
Now how do you access that information? You could have code in the sketch that sends out that information on request or startup. A simple example:
void setup() {
Serial.begin(9600);
Serial.print(F("Filename: "));
Serial.println(F(__FILE__));
Serial.print(F("Compilation timestamp: "));
Serial.println(F(__DATE__ " " __TIME__));
}
void loop() {}
Will print this information to the Serial Monitor on startup. Of course you could use any other method of communication. This sort of thing will add some significant overhead so it would perhaps be preferable (if less beginner friendly) to download the firmware from the microcontroller and then figure out a way to find the version information from the disassembly.
The time you cannot get. The Arduino doesn't have any clock or any way to know the time.
The code size you could get if you use AvrDude to read the hex code back off the chip and then just look at the size of what you read back.

My Arduino Uno Wifi, stops responding to wifi

My new Arduino Uno Wifi, stops responding to wifi if left inactive. To be more specific, after 2-3 hours of no wifi usage:
I cannot access the build-in configuration page of the Arduino's wifi section
Loaded programs which use Wifi are not receiving any commands via my browser
loop() continues to run just fine
It somehow seems that the wifi section of my Uno Wifi "sleeps" after some arbitrary interval.
Using code to periodically reset the board (by sending HIGH to the reset pin of the board) did not solve the problem. As soon as the reset takes place, loop() starts executing just fine, but wifi connection is still impossible to obtain.
Things I usually do to gain access to my board AFTER wifi is lost:
Hard reset the board (unplug power and plug it again) -> almost always works
Try to access arduino from several different wifi devices hoping that the board somehow "wakes up" -> occasionally works but only after 4 or 5 minutes (sometimes hours) of failed attempts
My router seems to be fine. Another web server which I have set up in a wifi-connected laptop has had no hiccups (even after a long time of inactivity). Moreover I've never had any connection problems with my router so far.
This is giving me a hard time! Could anybody be of any help?
Is my Arduino Uno faulty?
Many thanks in advance
George
Here's my configuration:
Arduino Uno Wifi Developer edition (built-in wifi support)
Arduino IDE 1.8.0 (I'm using the Linux version installed on Ubuntu 12.04 )
I have already connected my arduino to my home network and gave it a static IP 192.168.2.50
WIFI mode: STA
Wifi channel: 1
SLIP status enabled
MQTT status disabled/disconnected
code:
int i=0;
void setup() {
pinMode(13,OUTPUT);
}
void loop() {
if (i==1){
digitalWrite(13, HIGH);
i=0;
}
else{
digitalWrite(13,LOW);
i=1;
}
delay(1000);
}
It seems that I have been a victim of an extreme ambiguity caused by the .org fork of arduino.
Arduino.cc and Arduino.org boards are NOT 100% compatible with each other.
To be more specific, the examples that come with the IDE (and are based on the the wifi shield of arduino.cc) DO NOT function with aruduino-uno-wifi (the one with the embedded wifi section)
Apart from that, it seems that arduino-uno-wifi has firmware that is way behind the arduino.cc (in terms of features as well as code quality). This has frustrated several users as you can see here:
Issue 2: Rename this fork and use less confusing versioning
Issue 10: Please stop doing this !
Issue 6: Remove old licenses from sample code comments and take credit for everything
If you are interested of an arduino.org view of things visit here:
The full story
All of the above is information which I wish I had when ordering my new ardnino-uno-wifi board.
Moreover it is relevant with the question I've asked, since it indicates that my problem is most probably a bug of the uno-wifi board, so I should file a bug report (and keep hoping) instead of trying to fix my code.

Resources