text:
Stoplight Simulator - White LED not turning on with button press
I am working on a relatively simple stoplight simulator that uses four LEDs - red, green, yellow, and white - in addition to a button. The 3 colored stoplight LEDs cycle as a real stoplight would. If the button is pressed while the green LED is on, the white light should turn on while the green light is still on (this can only be allowed to happen once). Previously, the stoplight cycle didn't work, but now the white light isn't turning on with the button press (see below)
Edit: The stoplight cycle now works, thanks to all your input, but the white light still doesn't come on when I press the button. This could be an issue using delay instead of millis(), but I'm not sure the easiest way to implement a fix. Any tips? My code is below. Thank you!
const int g_led = 3;
const int y_led = 4;
const int r_led = 5;
const int w_led = 6;
const int g_delay = 4000; //adjust test timings to reqs
const int y_delay = 2000;
const int r_delay = 3000;

int g_ledState;
int buttonState;
bool counter = false;

const int buttonPin = 2;

//green led function with conditional for white led
void green_light(){
  digitalWrite(g_led, HIGH);
  digitalWrite(y_led, LOW);
  digitalWrite(r_led, LOW);
  digitalWrite(w_led, LOW);
  g_ledState = 1;
  buttonState = digitalRead(buttonPin);
if (buttonState == HIGH && g_ledState == 1 && counter == false){
  digitalWrite(w_led, HIGH);
    counter = true;
  }
  else{
    digitalWrite(w_led, LOW);
    counter = true;
  }
}

void yellow_light(){
  digitalWrite(y_led, HIGH);
  digitalWrite(g_led, LOW);
  digitalWrite(r_led, LOW);
  digitalWrite(w_led, LOW);
  g_ledState=0;
}

void red_light(){
  digitalWrite(r_led, HIGH);
  digitalWrite(y_led, LOW);
  digitalWrite(g_led, LOW);
  digitalWrite(w_led, LOW);
  g_ledState=0;
}

void setup() {
  // put your setup code here, to run once:
  pinMode(g_led, OUTPUT);
  pinMode(y_led, OUTPUT);
  pinMode(r_led, OUTPUT);
  pinMode(w_led, OUTPUT);
  pinMode(buttonPin, INPUT);
}

void loop() {
//main stoplight cycle
  green_light();
  delay(g_delay);
  yellow_light();
  delay(y_delay);
  red_light();
  delay(r_delay);
}

forget about your code for now ... write simple code to turn on one LED ... then change your code to turn on next LED .... when all LEDs are confirmed to work, then update your post to say that LEDs were tested

Your delays are very short - 20 and 50 msec. I would suggest you increase them, e.g. g_delay = 5000; for testing. You should see the green LED light up if it is wired correctly. Then you can move onto the other parts.

g_ledState will never be high at the time you are testing it in the conditional statement because it is set to low by the preceding red_light() call. Also counter is always forced to zero before you test its value. Maybe counter should be global or static.  Normally such exercises are designed to preclude the use of delay() for timing and require the explicit use of millis() instead. Have you external pull down resistors on the button pins?

That makes sense; the light cycle is working now but the white light still does not come on when I press the button. The counter is now global, and I have a pull down resistor on the button. I'm guessing using delay() is the issue, but I'm not very experienced in using millis(). Any tips on how that would work in this instance? I updated my code in the original question. Thank you all so much!

You need to try it this way
allowed to happen once). My code compiles, but none of the lights turn on when I run it. I'm pretty sure I set the circuit correctly, so I want to see if I'm missing any issues in my code (below). Thank you!

//variables
const int g_led = 3;
const int y_led = 4;
const int r_led = 5;
const int w_led = 6;
const int g_delay = 1000;
const int y_delay = 500;
const int r_delay = 1000;
int g_ledState;
int buttonState;

const int buttonPin = 2;

//LED functions
void green_light(){

  int counter=0;

// conditional to let button turn on the white LED IF green LED is on and the white LED cycle hasn't already been run
if (buttonState == HIGH && g_ledState == 1 && counter == 0){
  digitalWrite(w_led, HIGH);
    counter =1;
  }
  else{
    digitalWrite(w_led, LOW);
    counter=0;
  }

  digitalWrite(g_led, HIGH);
  digitalWrite(y_led, LOW);
  digitalWrite(r_led, LOW);
  digitalWrite(w_led, LOW);
  g_ledState=1;
  button state=digitalRead(buttonPin);

}

void yellow_light(){
  digitalWrite(y_led, HIGH);
  digitalWrite(g_led, LOW);
  digitalWrite(r_led, LOW);
  digitalWrite(w_led, LOW);
  g_ledState=0;
}

void red_light(){
  digitalWrite(r_led, HIGH);
  digitalWrite(y_led, LOW);
  digitalWrite(g_led, LOW);
  digitalWrite(w_led, LOW);
  g_ledState=0;
}

void setup() {
  // put your setup code here, to run once:
  pinMode(g_led, OUTPUT);
  pinMode(y_led, OUTPUT);
  pinMode(r_led, OUTPUT);
  pinMode(w_led, OUTPUT);
  pinMode(buttonPin, INPUT);
}

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

//main stoplight cycle
  green_light();
  delay(g_delay);
  yellow_light();
  delay(y_delay);
  red_light();
  delay(r_delay);

}

Note that using delay is not that advisable but this way might help.
Here is another method using millis(), note that it hasn't been tested with arduino. If the compiling gives an error try modifying some things
//variables
const int g_led = 3;
const int y_led = 4;
const int r_led = 5;
const int w_led = 6;
const int g_delay;
const int y_delay;
const int r_delay;
int g_ledState;
int buttonState;
int oldbuttonState;
const int buttonPin = 2;

/* you can remove this one
Switch (white){
case 1:
//do nothing
break;

case 2 :
   buttonState=digitalRead(buttonPin);

   // conditional to let button turn on the white LED IF green LED is on and the white LED cycle hasn't already been run
if (buttonState == HIGH && counter == 0){
  digitalWrite(w_led, HIGH);
    counter =1;
  }
  else{
    digitalWrite(w_led, LOW);

  }
counter=buttonState;
//switch to case 3
 white=3;
break;

case 3 :
//switch back to case two and continue reading the button
white=2;
break;
*/

}
//LED functions
void green_light(){

  digitalWrite(g_led, HIGH);
  digitalWrite(y_led, LOW);
  digitalWrite(r_led, LOW);
  digitalWrite(w_led, LOW);

// start reading the button
  // I added this for better performance
int rep=millis;
while((millis-rep) < 3000){
digitalRead(buttonpin);
if (buttonState == HIGH && counter == 0){
  digitalWrite(w_led, HIGH);
    counter =1;
  }
  else{
    digitalWrite(w_led, LOW);

  }
counter=buttonState;

}
  g_delay=Millis();

}

void yellow_light(){
//stop button reading
  white=1;
  digitalWrite(y_led, HIGH);
  digitalWrite(g_led, LOW);
  digitalWrite(r_led, LOW);
  digitalWrite(w_led, LOW);
  y_delay=millis();

}

void red_light(){
 //stop button reading
  white=1
  digitalWrite(r_led, HIGH);
  digitalWrite(y_led, LOW);
  digitalWrite(g_led, LOW);
  digitalWrite(w_led, LOW);
  r_delay=millis();
}

Switch (cases){
//main stoplight cycle
case 1 :
  green_light();
  /// wait for 3 seconds
  if (millis() - g_delay >=3000){
     yellow_light();
}
 cases=2;
 break;

case 2 :
  /// wait 2 seconds
  if (millis() - y_delay >=2000){
     red_light();
}
cases=3;
break;

 case 3 :
 // wait 5 seconds
  if (millis() - r_delay >=5000){
      cases=1;
}
cases=1;
break;

}

void setup() {
  // put your setup code here, to run once:
  pinMode(g_led, OUTPUT);
  pinMode(y_led, OUTPUT);
  pinMode(r_led, OUTPUT);
  pinMode(w_led, OUTPUT);
  pinMode(buttonPin, INPUT);
}

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

}

It haven't been tested but just try it out

Thank you, this helped a lot! I've been messing around with the first version of your modifications, as it seems to work the most smoothly. Although the light cycle is working now, the white light still does not come on on the button press. Could it be because the delays are interrupting the conditional in green_light() from executing? I'm not very experienced in using millis(), but if that would be the solution, I'd appreciate some guidance on how to implement it. Thanks!

You don't have any circuit details... SO...
Where most indicator LEDs need 2 to 2.2 volts and 8 to 25mA,
white LEDs typically need 3.1V and 25mA minimum to turn on.
Also micro processors have limits to the current a pin can deliver
If you are using a 3.3v micro not all the voltage will make it to the LED.
look up the spec sheets on the micro and white LED.  I have a feeling you are going to find either the micro pin or the supply an issue.
Try switching out a colored LED for testing the code.
If the LED works then try going to some driver circuit to power the white LED.


text:
How to upload firmware to my board
I am using platformio to develop ESP32-S2-MINI-2. I want to send it to factory to test it and they are not using platformio to upload. Do they also need to flash bootloader.bin and partition.bin? in which address? is firmware.bin to 0x0?
They are getting error of invalid header: 0xefffffff while flashing it.

source: Stack Exchange

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

sort: votes


text:
Arduino simulator that allows program custom inputs with code
Does anyone know whether there exists simulator that lets you write code that simulates the Arduino inputs?
I need to simulate two microphones connected to Arduino and would prefferably write my own code that uses two PC microphones for that purpose.
So far I've seen that for most emulators you're limited to components delivered by their authors and there is no way to write your own ones or at least custom code for inputs.

This can be done with simavr, but I have never tried, and it can only work for AVR-based Arduinos.

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


text:
Error while uploading "A fatal esptool.py error occurred: Write timeout"
I have constantly been getting this error while trying to upload a sketch on Wemos D1 Mini R1 & R2 type board.

A fatal esptool.py error occurred: Write timeout

I've recently updated my Arduino IDE, so I assumed that it might be due to a bad installation. But after reinstalling everything including the Board Manager lib for ESP, Arduino IDE itself nothing worked. When I click on the Board Info, it displays an error "Native serial port, can't obtain info".
I've also tried different type of ESP boards (e.g. NodeMCU) but for all boards the problem is same. When I plug an Arduino to the same USB Port, it auto-detect the board, but when I plug-in the ESP boards, it doesn't recognize the boards automatically. So my guess is it has something to do with the CH34X driver. However I have tried reinstalling few versions of the driver from authentic sources, but nothing made an impact.
Any help is appreciated.
Following is the full trace of log getting printed:
. Variables and constants in RAM (global, static), used 28104 / 80192 bytes (35%)
║   SEGMENT  BYTES    DESCRIPTION
╠══ DATA     1496     initialized variables
╠══ RODATA   920      constants
╚══ BSS      25688    zeroed variables
. Instruction RAM (IRAM_ATTR, ICACHE_RAM_ATTR), used 59667 / 65536 bytes (91%)
║   SEGMENT  BYTES    DESCRIPTION
╠══ ICACHE   32768    reserved space for flash instruction cache
╚══ IRAM     26899    code in IRAM
. Code in flash (default, ICACHE_FLASH_ATTR), used 232148 / 1048576 bytes (22%)
║   SEGMENT  BYTES    DESCRIPTION
╚══ IROM     232148   code in flash
esptool.py v3.0
Serial port COM8
Connecting...

A fatal esptool.py error occurred: Write timeout

Following is the IDE Settings while uploading:

The "most common reason" mentioned in this answer was actually the problem I had. Unfortunately I was using a charge only cable even though the cable package clearly said it was a data-cable. At times, these cheap electronics products confuses us a lot and we often miss to critically scrutinize the most obvious problems. As described in this Adafruit tutorial this problem seems to be a very common one.

I've run into this a bunch recently, and typically, but not always, the cause is that I was using a GPIO pin that was reserved and couldn't be used during boot up. It's surprising how many of the pins cannot be used.
Check out this chart I found and saved, unfortunately I do not know the source, but I have found it to be very accurate, and I reference it a lot:

For my case, a simple Blink program is not getting uploaded. I am not sure how
failure to upload a program to the board can be caused by a reversed GPIO pin. Do you mean the board is damaged and it can't be used? I do not see an solution or conclusion to the problem, in your answer. Still need help.

I had the same problem.
My solution:
Program for blinking led ESP8266MOD (cheap Chinese esp8266mod module)
I used Arduino IDE 2.1.0
info from https://vimalb.github.io/IoT-ESP8266-Starter/Lesson_01/lesson.html
Connect resistor 220 Ohm and LED in serial. Connect resistor on D8 and the LED
on G (Ground). I used a breadboard and connect 5V pin on the esp board and
the pin G on the esp board to the Red en Bleu line on mij breadbord.
Write the program.
// Base ESP8266

#include <ESP8266WiFi.h>

WiFiClient WIFI_CLIENT;

#define LIGHT_SENSOR A0

#define LED 15    // this is pin D8 on the board

#define BUTTON 4

void setup() {

  // Initialize the serial port

  Serial.begin(115200);

  // Configure light sensor pin as an input

  pinMode(LIGHT_SENSOR, INPUT);

  // Configure LED pin as an output

  pinMode(LED, OUTPUT);

  // Configure BUTTON pin as an input with a pullup

  pinMode(BUTTON, INPUT_PULLUP);

}

void loop() {

  // Turn the LED on (HIGH is the voltage level)

  digitalWrite(LED, HIGH);

  // Wait for 1000 milliseconds

  delay(1000);

  // Turn the LED off by making the voltage LOW

  digitalWrite(LED, LOW);

  // Wait another 1000 milliseconds

  delay(1000);

  // Send a message over the serial port

  Serial.println("Finished loop");

}

Compile the program.
If Fault check the program.
Go to Tools -> Port  (I used com6)
Push the reset button on the espboard and keep it.
Connect the usb-cable on the espboard.
Release the reset button.
Besure everthing is connect.
Upload the program by using the upload button arduino IDE.
Start the serial monitor and check text "Finished loop" every 2 seconds.
Maybe this will help


text:
Access non contiguous RAM slots in Arduino Nicla Vision
I'm working on a TinyML project with an Arduino Nicla Vision and I need to store a model with size 608kB in RAM. In the Nicla Vision datasheet, it is stated that 864kB of SRAM are available, but it is segmented in three non contiguous parts (AXI SRAM, SRAM1-3, SRAM4).

When I try to load the model in RAM, I get the error 'linker_script.ld:110 cannot move location counter backwards (from 240aa610 to 2407fc00)' because only the AXI SRAM (524kB) is used.
Is there a way to distribute the model over all the available non contiguous RAM?


text:
How much readable text can fit inside an ATTINY85? Feasibility of scrolling a booklet on a 0.91-inch OLED display
I'm a total beginner, so I've been talking with Chatgpt regarding the capabilities of the Attiny85 microcontroller. But the AI would hallucinate a lot and give only partially right answers (because it relies on patterns and knowledge from its training data or something). So I came here to ask for some guidance and insights on the following questions:

How much readable text can the Attiny85 accommodate considering variables such as the programs, libraries, and fonts?
Is it possible to create a mini text reader using an Attiny85 and a 0.91-inch OLED display, where the text can be scrolled and read like a booklet?

I understand that the Attiny85 has 8kb of flash memory, but I'm unsure about the actual capacity for storing and displaying text, especially considering the potential impact of the compression of the code.
Any advice, experiences, or suggestions on how to optimize the usage of the Attiny85 and the OLED display for this purpose would be greatly appreciated.
Note: Feel free to correct any misconceptions or assumptions I may have made in my questions due to my limited knowledge in this field.

start with one of the menu programs that you can find on the internet ... add text to it until memory is full ... your first question is not really answerable ... the second one is yes

If you keep it at simple ASCII (not some multibyte format), one character is exactly one byte. How much of the 8kB is available besides your program depends on how you write the program. Nobody can tell you that, since you haven't written it yet. And when you have written it, you can test yourself by just compiling it (the Arduino IDE will tell you the programs size). Though driving an OLED display uses rather much spaces probably. And you probably will run out of pins. Is there a reason why you are trying this with such a small controller (in terms of resources, not physical size)?

Hmmm, i dont think i can tell you why i am trying to make this device as tiny as possible... Well, here is a hint: I never graduated from high school.

I will take a SWAG, the approach I would use would be to add external memory such as I2C FRAM. It is not expensive and will work just fine with the I2C bus. I use the 32K x 8 devices. You could connect 8 of them. FRAM can be acquired in SPI as well. I have assumed you are using the I2C for the display so no additional pins on the processor will be needed.

How does the text get onto the FRAM?

By writing it there, this can be done in passes as FRAM is non volatile. I wrote a specific program to do this.  I use a Mega to program mine as it has a lot of flash that I just transfer to the FRAM. I have also done it with UNOs and Nanos, they work just fine. Initially I used a Nano and many #ifdef statements. Then each time I would select different tables and program them into FLASH. The table addresses were predefined for the FRAM. Once the FRAM was loaded I then worked on my program with more FLASH and RAM available depending on where the messages were.

The AtTiny85 has 8KB of program memory, which you could store strings in. The more data you store, the less room you have for program code and vice-versa.
For only slightly more money you could use an Atmega328P which has 32KB of program memory, giving you somewhat more scope for storing data.
For some kind of text reader you might want to consider an external disk (like, a micro-SD card) which can be easily attached with a modest amount of extra hardware. The hardware might be a couple of voltage-level converters, if you are going to run the processor at 5V rather than 3.3V.
The code to interface to the SD card might be too large to fit into 8KB of memory (I'm not sure about that) but certainly would fit into 32KB.
You also need the code to interface with the OLED — I'm not sure how much program space that would take up.
You might do it with the AtTiny85, with no external disk, but you would probably only get a couple of K of text, once you had your code and your OLED interface. You could compress the text, but then you need code to decompress it, which might outweigh the advantage of compressing it.
For some sort of "booklet" I think the external disk is the most practical solution. This is what one looks like, with its voltage-level converter, hooked up to my Uno:


text:
What library does the Beetle BLE utilize for BLE commands?
I am trying to pair two gloves containing beetle BLE's on each, one set to a peripheral role and one to central to control leds for kids' party jewelry.
The Arduino.BLE library does not work with this board.  Is there another BLE library that is compatible with the Beetle BLEs, that will allow me to use the NOTIFY command?

AT commands https://wiki.dfrobot.com/Bluno_SKU_DFR0267#Configure_the_BLE_through_AT_command


text:
Blackpill stm32F411 doesn't enter boot mode anymore
I cannot enter boot mode with my BlackPill F411 board anymore. It's currently running one my sketch successfully uploaded few weeks ago but now, I don't know what's happen.
I've read this post which unfortunately doesn't help me.
Blue led doesn't blink, CubeProgrammer 2.14 doesn't detect any DFU mode and Arduino says
      -------------------------------------------------------------------
                   STM32CubeProgrammer v2.14.0
      -------------------------------------------------------------------

Error: Target device not found
Establishing connection with the device failed
Failed uploading: uploading error: exit status 1

I try to upload via USB here is my setting:

Get_PnpDevice says in PowerShell: "BLACKPILL_F401CC CDC in FS Mode".
Isn't it strange? So do you have any idea please?
I use STM32 MCU based boards 2.6.0, IDE 2.1.1. don't know if it occured after some release.


text:
How to flash plcc 32 chip with arduino
The specific model is the W39V080FA and I'm quite a noob when it comes to flashing.
I've already prepared the circuit to divide the voltage and use a proper 3.3V.
I have an plcc to dip adapter, but I really don't know how to wire each pin, really need some tips. Thanks.

you have to determine which signals are required to write data to the chip ... then you have to write a program that generates those signals ... determining the required signals is in no way related to the Arduino ... your question would be related to the arduino only when you know which signals to generate, but have problems generating those signals with the arduino

it sounds like a lot of work, but thankfully there's a great project called Flashrom that get rid of those assignments, and their official docs point that this chip is supported. My barrier is building the circuit (assigning the pins to Arduino). Also, thanks for your response

Welcome to SE/Arduino! Please take the [tour] to learn how this site works, and read "[ask]". Then come back and [edit] your question, adding the link to the mentioned project. Also add what specifically stops you from assigning pins. You don't want us to guess, do you?


text:
Salvaging Arduino board from Google ADK 2012
I found an old Google ADK 2012 in my closet and remembered it came with a Arduino board (?), an ARM 32-bit Cortex M3 micro-processor available at the time (possibly the DUE).
The ADK 2012 design files and source code were included as part of a software download at the event which is no longer available on the Android site, but I found a mirror here:
https://stuff.mit.edu/afs/sipb/project/android/docs/tools/adk/adk2.html
You can also see the kit in action from the Google I/O 2012 event where these kits were given out:
https://youtu.be/ZUaKSs3utrs
Here's my issue(s):

When I try to set up and run the ADK 2012 IDE, I get an error stating "ADK2012.app" needs to be updated and disabled overlay on the icon.

When I try to use the ADK Alternative Build System, I get an error stating ld: symbol(s) not found for architecture i386, which makes sense because Apple removed the ability to compile 32 bit programs on macOS starting with Xcode 10 (my Xcode: 13.4.1; macOS: 12.6.7)

After connecting the board to my computer via USB to micro-USB, when I open the Arduino IDE, I'm able to select the port, but there is no option for this particular board, although from everything I've gathered, its essentially a custom version of the Arduino DUE made just for that event, and others have managed to load the ADK 2012 onto a regular DUE. So I've been trying it with both Arduino DUE boards (native and programmable)

When I try to "Get Board Info" in Arduino IDE, the board name is "Unknown board", but all the other information is available (VID, PID, SN).

After importing the ADK2 library into Arduino IDE and updating the demo code from the source download, I'm able to get the project sketch file to compile and verify without errors, however when I attempt to upload the changes to the board, I receive the following error: No device found on cu.usbserial-AH015U12 Failed uploading: uploading error: exit status 1. The device appears connected to my computer the whole time, including before and after the error.

I think I've exhausted all of my known options and just want to know whether & how it's possible to salvage a 10+ year old (modded but virtual identical) Arduino board.
TLDR; want to tinker with old Arduino board, custom IDE no longer works, Arduino IDE disconnects when attempting upload. Still salvageable or too old?


text:
Emulator for Arduino Nano 33 BLE Sense and TinyML
I am learning to work with TinyML, and I have Arduino Nano 33 BLE Sense board connected to my desktop.
I would like to continue working from my laptop(s) even when I don't have a board with me.
Do you know if there is an emulator for this board that I could use to dome basic programming and exercises?


text:
Arduino MKRZero "This device cannot start" (Code 10), and Keyboard.h
I have bought my brand new Arduino MKRZero to emulate a keyboard. When I plug it in, I get the following on COM6, which is listed as "Arduino MKRZero".
"This device cannot start" (Code 10)

I also get a new COM port connection, COM3, listed as a generic USB Serial Device.

In my IDE (2.1.0) I am given the following:

COM 3 opens on the Serial Monitor, while COM 6 gives a port monitor error:

Attempts
I have tried a few things based on the following:
https://forum.arduino.cc/t/solved-arduino-uno-this-device-cannot-start-code-10-at-hardware-manager/298777
https://forum.arduino.cc/t/this-device-cannot-start-code-10-arduino-leonardo/897137
https://www.lifewire.com/how-to-fix-code-10-errors-2623181

Updating drivers
Rolling back drivers
Using a different USB connector
Restarting laptop

Context
The reason why I ask is because I am attempting to use the following code in an Arduino, which, per my understanding, should print the letter "F" every second with my keyboard.
#include <Keyboard.h>

void setup() {
  // open the serial port:
  Serial.begin(9600);
  // initialize control over the keyboard:
  Keyboard.begin();
}

void loop() {
    Keyboard.write('F');
    delay(1000);
}

However, no response is received.
Please let me know if more information is required, or if this is a code issue. I am on Win 10.0.19045, and attempted both the latest version and an alleged, more stable version of the MKRZero driver (Arduino SAMD Boards [32-bits ARM Cortex-M0+] version 1.8.13 and 1.8.9).

if you upload Blink or some other sketch without Keyboard library, everything is normal? one com port? which one?


text:
Teensy 4.1 Synchronized PWM - ADC sampling
I'm looking to drive a high side driver at PWM frequency of 200Hz on a Teensy 4.1 with variable duty. The high side driver current sense pin is connected to an analogue pin on the Teensy. I want to sample an analogue reading only when the PWM output is low (HSD is on). I'll also likely need to read the analogue input with some delay after the PWM output has gone low (approximately 200uS).
How can I achieve this and guarantee synchronisation?


text:
A fatal error occurred: Could not open /dev/ttyUSB0, the port doesn't exist (UART bridge CP2102)
I can't upload my program to ESP32-CAM. It just keeps saying the port doesn't exist. But I can see it in /dev/ttyUSB0 (By the way, I'm on linux, Fedora)
The UART bridge is CP2102 Silicon Labs.
What I've tried:

Using both IDE 1, 2
Removing everything, trying again on IDE 1
upgrading permissions

Any help will be appreciated.

After sudo dmesg -wT | grep cp2102 as suggested by @timemage, I got this:

Please check if your user has access rights to /dev/ttyUSB0. You can add yourself to the dialup group or take similar actions.

@gbg After Posting the question, I did come across some posts suggesting the same. I did that but it didn't help. Is there a need to install any driver of the UART (CP2102) even in Linux? I can get it to work on windows by updating the driver.

@44yu5h It's not going to be a lack of a driver unless you're running some obscure build of the kernel. Post sudo dmesg -wT output from the first line of after insertion downward. Besides diagnosing other options it will also allow you to convince yourself that a driver is loading when you see something like cp210x <bus numbers>: cp210x converter detected

@timemage Thanks for answering. I did sudo dmesg -wT | grep cp2102 did not get anything. I didn't take a screenshot. I will update my question with the ss soon. In a lecture right now.

grep cp2102 in not going to find cp210x. Anyway, I'm sure you have that. The real point of posting it is the potential to see other diagnostically useful things that grepping is only going to remove.

@timemage Yes! sorry my bad. I've attached the screenshot. Still, it returns the same error A fatal error occurred: Could not open /dev/ttyUSB0, the port doesn't exist The RX led is constantly on (as it was on Windows before I updated the driver, so I was just linking things but anyway) Any suggestions?

Not a good suggestion. Because it's an easy test, I would disconnect the ESP32 and perform a loopback test on the cp2102. This would at least eliminate a bunch of stuff, although pretty much everything "arduino" about your question. But on the other hand you'd be able to ask it to a wider audience of Linux users without being shunted right back here.

@timemage Actually I have 2 cp2102. Both don't work. Tried both Arduino 1 and 2. Tried removing the braille screen reader as suggested in some posts. No help. You are right, let me just ask it on linux forum. Thanks

A post by Bee_HapBee on Reddit solved my issue! Thank you!
sudo chmod 666 /dev/ttyUSB0

Yep, I wish esptool.py would've told me that I needed permissions, rather than the port doesn't exist

chmod 666 - "(U)ser / owner can read, can write and can't execute. (G)roup can read, can write and can't execute. (O)thers can read, can write and can't execute"

What about the security implications? Isn't it more standard to use the dialup user or some udev rules?


text:
Respond to all WiFi probe requests with ESP8266?
I'm wondering if there's a way to program an ESP8266 such that it responds to all WiFi beacon probe requests. For example, if a device sends a probe request for a WiFi network name, e.g. "homewifi", the ESP8266 will send a response frame to that and have that device connect to it. Is this possible to do?


text:
Image capture at QSXGA resolution by OV5640 in ESP32s3
// Include necessary libraries
#include "WiFi.h"
#include "esp_camera.h"
#include "Arduino.h"
#include "soc/soc.h"           // Disable brownout problems
#include "soc/rtc_cntl_reg.h"  // Disable brownout problems
#include "driver/rtc_io.h"
#include <SPIFFS.h>
#include <FS.h>
#include <Firebase_ESP_Client.h>
#include <addons/TokenHelper.h>
//#include <ArduinoJson.h>      // JSON library

// Replace with your network credentials
const char* ssid = "SSID";
const char* password = "PASSSS";

// Replace with your Firebase project details
#define API_KEY "API"
#define USER_EMAIL "EIMAI@gmail.com"
#define USER_PASSWORD "PASS"
#define STORAGE_BUCKET_ID "esp32cam-AAA.appspot.com"
#define FILE_PHOTO "/photo.jpg"

#define CAMERA_MODEL_ESP_EYE  // Has PSRAM
#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 15
#define SIOD_GPIO_NUM 4
#define SIOC_GPIO_NUM 5
#define Y9_GPIO_NUM 16
#define Y8_GPIO_NUM 17
#define Y7_GPIO_NUM 18
#define Y6_GPIO_NUM 12
#define Y5_GPIO_NUM 10
#define Y4_GPIO_NUM 8
#define Y3_GPIO_NUM 9
#define Y2_GPIO_NUM 11
#define VSYNC_GPIO_NUM 6
#define HREF_GPIO_NUM 7
#define PCLK_GPIO_NUM 13

// Flags and variables
boolean takeNewPhoto = true;
FirebaseData fbdo;
FirebaseAuth auth;
FirebaseConfig configF;
bool taskCompleted = false;

void initCamera() {
  // OV2640 camera module
  camera_config_t config;
  config.ledc_channel = LEDC_CHANNEL_0;
  config.ledc_timer = LEDC_TIMER_0;
  config.pin_d0 = Y2_GPIO_NUM;
  config.pin_d1 = Y3_GPIO_NUM;
  config.pin_d2 = Y4_GPIO_NUM;
  config.pin_d3 = Y5_GPIO_NUM;
  config.pin_d4 = Y6_GPIO_NUM;
  config.pin_d5 = Y7_GPIO_NUM;
  config.pin_d6 = Y8_GPIO_NUM;
  config.pin_d7 = Y9_GPIO_NUM;
  config.pin_xclk = XCLK_GPIO_NUM;
  config.pin_pclk = PCLK_GPIO_NUM;
  config.pin_vsync = VSYNC_GPIO_NUM;
  config.pin_href = HREF_GPIO_NUM;
  config.pin_sccb_sda = SIOD_GPIO_NUM;
  config.pin_sccb_scl = SIOC_GPIO_NUM;
  config.pin_pwdn = PWDN_GPIO_NUM;
  config.pin_reset = RESET_GPIO_NUM;
  config.xclk_freq_hz = 20000000;
  config.frame_size = FRAMESIZE_QSXGA;
  config.pixel_format = PIXFORMAT_JPEG;  // for streaming
  //config.pixel_format = PIXFORMAT_RGB565; // for face detection/recognition
  config.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
  config.fb_location = CAMERA_FB_IN_PSRAM;
  config.jpeg_quality = 12;
  config.fb_count = 1;

  // if PSRAM IC present, init with UXGA resolution and higher JPEG quality
  //                      for larger pre-allocated frame buffer.
  if (config.pixel_format == PIXFORMAT_JPEG) {
    if (psramFound()) {
      config.jpeg_quality = 10;
      config.fb_count = 2;
      config.grab_mode = CAMERA_GRAB_LATEST;
    } else {
      // Limit the frame size when PSRAM is not available
      config.frame_size = FRAMESIZE_SVGA;
      config.fb_location = CAMERA_FB_IN_DRAM;
    }
  } else {
    // Best option for face detection/recognition
    config.frame_size = FRAMESIZE_240X240;
#if CONFIG_IDF_TARGET_ESP32S3
    config.fb_count = 2;
#endif
  }

#if defined(CAMERA_MODEL_ESP_EYE)
  pinMode(13, INPUT_PULLUP);
  pinMode(14, INPUT_PULLUP);
#endif

  // camera init
  esp_err_t err = esp_camera_init(&config);
  if (err != ESP_OK) {
    Serial.printf("Camera init failed with error 0x%x", err);
    return;
  }

  sensor_t* s = esp_camera_sensor_get();
  // initial sensors are flipped vertically and colors are a bit saturated
  if (s->id.PID == OV3660_PID) {
    s->set_vflip(s, 1);        // flip it back
    s->set_brightness(s, 1);   // up the brightness just a bit
    s->set_saturation(s, -2);  // lower the saturation
  }
  // drop down frame size for higher initial frame rate
  if (config.pixel_format == PIXFORMAT_JPEG) {
    // s->set_framesize(s, FRAMESIZE_QVGA);
    s->set_framesize(s, FRAMESIZE_XGA);
    Serial.println("Frame UXGA..");

  }

#if defined(CAMERA_MODEL_M5STACK_WIDE) || defined(CAMERA_MODEL_M5STACK_ESP32CAM)
  s->set_vflip(s, 1);
  s->set_hmirror(s, 1);
#endif

#if defined(CAMERA_MODEL_ESP32S3_EYE)
  s->set_vflip(s, 1);
#endif

// Setup LED FLash if LED pin is defined in camera_pins.h
#if defined(LED_GPIO_NUM)
  setupLedFlash(LED_GPIO_NUM);
#endif
}

// Initialize WiFi connection
void initWiFi() {
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
  Serial.println("Connected to WiFi...");
}

// Check if photo file is valid
bool checkPhoto(fs::FS& fs) {
  File f_pic = fs.open(FILE_PHOTO);
  unsigned int pic_sz = f_pic.size();
  return (pic_sz > 100);
}

// Initialize SPIFFS file system
void initSPIFFS() {
  if (!SPIFFS.begin(true)) {
    Serial.println("An Error has occurred while mounting SPIFFS");
    ESP.restart();
  } else {
    delay(500);
    Serial.println("SPIFFS mounted successfully");
  }
}

// Initialize camera
void capturePhotoSaveSpiffs() {
  camera_fb_t* fb = NULL;
  bool ok = false;

  Serial.println("Taking a photo...");
  fb = esp_camera_fb_get();
  if (!fb) {
    Serial.println("Camera capture failed");
    return;
  }

  Serial.printf("Picture file name: %s\n", FILE_PHOTO);
  File file = SPIFFS.open(FILE_PHOTO, FILE_WRITE);
  if (!file) {
    Serial.println("Failed to open file in writing mode");
  } else {
    file.write(fb->buf, fb->len);
    Serial.print("The picture has been saved in ");
    Serial.print(FILE_PHOTO);
    Serial.print(" - Size: ");
    Serial.print(file.size());
    Serial.println(" bytes");
  }
  file.close();
  esp_camera_fb_return(fb);
  //ok = checkPhoto(SPIFFS);
  File imageFile = SPIFFS.open(FILE_PHOTO, FILE_READ);
  if (imageFile) {
    //if (Firebase.ready() && !taskCompleted) {
    // taskCompleted = true;
    Serial.println("Uploading picture...");

    if (Firebase.Storage.upload(&fbdo, STORAGE_BUCKET_ID, FILE_PHOTO, mem_storage_type_flash, FILE_PHOTO, "image/jpeg")) {
      Serial.printf("Download URL: %s\n", fbdo.downloadURL().c_str());
    } else {
      Serial.println(fbdo.errorReason());
    }
  }
  // } else {
  //   Serial.println("Failed to open image file in reading mode");
  // }
  imageFile.close();
  SPIFFS.remove(FILE_PHOTO);  // Remove image after upload
}

// Setup function
void setup() {
  Serial.begin(115200);
  initWiFi();
  initSPIFFS();
  initCamera();
  configF.api_key = API_KEY;
  auth.user.email = USER_EMAIL;
  auth.user.password = USER_PASSWORD;
  Firebase.begin(&configF, &auth);
  Firebase.reconnectWiFi(true);
}

// Main loop
void loop() {
  if (takeNewPhoto) {
    capturePhotoSaveSpiffs();
    takeNewPhoto = false;
  }
  delay(1);
}

How to set image resolution at QSXGA level by OV5640 camera in ESP32S3 module. Everything is working for low resolution but if going to highest resolution it is not working


text:
ESP32 Camera driver VSYNC query
We are new to ESP32 and Camera. We are facing issue in getting VSYNC event. We observed that if we change fb_count (frame buffer count) value the VSYNC behavior is changing.
Our understanding is, VSYNC event is received when capture is completed and captured data is available in DMA for processing.
We observed that:

If fb_count = 1, it is taking 2 VSYNC events  to raise DMA event.
If fb_count = 2, it is taking 1 VSYNC event to raise the DMA event.

We observed same behavior with ESP32 Wrover and ESP32-S3 Wroom.
We  observed this on Oscilloscope.
two queries are there:

Can you please help us to understand this behavior?
why 2 VSYNC events are required to get DMA interrupt?


text:
Measuring 2 Pi radians in a full rotation of MPU-6050, regardless of the pivot point
The Project:
I want to measure orientation of the MPU-6050 in z-axis for a mobile robot powered with the Arduino Mega 2560, so I need an accurate and reliable rotation measurement for the robot's movement.
I decided to use the gyroscope feature of the MPU-6050 sensor to measure orientation of its z-axis, by using its rotational velocity measurements.
I got the readings from Adafruit's MPU6050 library because it measures gyroscope using rad/s instead of raw data, so I can use the readings easily.
The Implementation:
I would really like to provide the source code with this question, but unfortunately while i'm writing this, I cannot get acces to the source code, and I will provide it as soon as I get access to it.
My implementation is, I used the z-axis velocity by dividing the current reading by 100 to get velocity per 10ms, then run a 10ms delay, and after that I add and assign the value to a variable (the += operator). And I run that in a loop.
The code might look something like this:
float currentReading;
float orientation = 0;

void loop() {

    g = doMpuReadings();
    currentReading = g.gyro.z / 100;

    delay(10);

    orientation += currentReading;
 }

For those who might wonder why I delayed the code by 10ms is to wait the sensor to travel a distance before defining its orientation.
The code worked quite like how I expected it to work. When I rotate it at some point, the orientation value adds, and when I rotate it back to its initial value, the orientation value goes back to near zero, and the values are pretty consistent.
The Issue:
But if I hold the sensor and rotate it by its center, it doesn't read 2 Pi or 6.28 rad, but it reads around 2 rad instead regardless of how fast or slow I rotate the sensor. When it is attached to the robot in which it doesn't rotate by its center, it reads around 5 rad. So like, the bigger circle it travels means more radians and vice versa?
Is that how it supposed to work?
Any possibilities to consistently measure 6.28 rad in a full rotation regardless of the pivot point?

I am not aware of any MEMS gyroscope that work with no offset or magnitude calibration. With out offset calibration you will drift (appear to be rotating) when not moving. Without magnitude calibration you will not measure the amount of rotation accurately.


text:
RF24Network not compiling
I am trying to run a simple test of RF24Network which requires to use nrf_to_nrf library.
My compiler is pulling all the libraries and when is trying to compile I can see the object NRF_RADIO not being found/declared.
I tried to look around the doc in case I needed to include something extra but nothing... anybody has a simlar issue?
To clarify, I just tried any of the examples from the official library
https://github.com/nRF24/RF24Network/tree/master/examples
Oddly using Arduino IDE, the compiler is not throwing any errors but platformio is not able to compile.
Yes I checked that all the libraries were present when building. It seems like there is an extra library that Arduino automatically download? I can't find any reference of NRF_RADIO in any of RF24, RF24network and nrf_to_nrf.
                                                                                ^~~~~~~~~~~~~~~~~~~~~~ .pio/libdeps/huzzah/nrf_to_nrf/src/nrf_to_nrf.cpp:1172:155: error: 'RADIO_PCNF1_BALEN_Pos' was not declared in this scope
     NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | ((a_width - 1) << RADIO_PCNF1_BALEN_Pos) | (pSize << RADIO_PCNF1_STATLEN_Pos) | (staticPayloadSize << RADIO_PCNF1_MAXLEN_Pos);
                                                                                ^~~~~~~~~~~~~~~~~~~~~ .pio/libdeps/huzzah/nrf_to_nrf/src/nrf_to_nrf.cpp:1172:190: error: 'RADIO_PCNF1_STATLEN_Pos' was not declared in this scope
     NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | ((a_width - 1) << RADIO_PCNF1_BALEN_Pos) | (pSize << RADIO_PCNF1_STATLEN_Pos) | (staticPayloadSize << RADIO_PCNF1_MAXLEN_Pos);
                                                                                ^~~~~~~~~~~~~~~~~~~~~~~ .pio/libdeps/huzzah/nrf_to_nrf/src/nrf_to_nrf.cpp:1172:239: error: 'RADIO_PCNF1_MAXLEN_Pos' was not declared in this scope
     NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | ((a_width - 1) << RADIO_PCNF1_BALEN_Pos) | (pSize << RADIO_PCNF1_STATLEN_Pos) | (staticPayloadSize << RADIO_PCNF1_MAXLEN_Pos);
                                                                                ^~~~~~~~~~~~~~~~~~~~~~ .pio/libdeps/huzzah/nrf_to_nrf/src/nrf_to_nrf.cpp: In member function 'void nrf_to_nrf::printDetails()': .pio/libdeps/huzzah/nrf_to_nrf/src/nrf_to_nrf.cpp:1182:20: error: 'NRF_RADIO' was not declared in this scope

You need to show the concerned source at least, optimally a minimal, complete, and reproducible example. BTW, each of us has a similar issue now and then, but I'm sure you don't want to know that.


text:
Make encoder work together with OLED display in Arduino Nano Every
I tried to sketch code to make an encoder to generate a number by each step and show it on OLED display. The OLED will connect with I2C, working on in Arduino Nano Every ATmega4809.
I separately made them for both encoder and OLED, they all work in separate code, encoder to generate Number and OLED display the text on screen.
But after combining them together, it seems to work only the OLED display. The encoder is not responding at all. The encoder will work again when I disable OLED.display() in loop section.
Anyone Please help me to them work together?
This is my sketch
//Display
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

// กำหนดขาต่อ I2C กับจอ OLED
#define OLED_RESET     -1
Adafruit_SSD1306 OLED(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

//Encoder
#define R_START 0x0
#define R_CW_FINAL 0x1
#define R_CW_BEGIN 0x2
#define R_CW_NEXT 0x3
#define R_CCW_BEGIN 0x4
#define R_CCW_FINAL 0x5
#define R_CCW_NEXT 0x6
#define DIR_NONE 0x0
#define DIR_CW 0x10
#define DIR_CCW 0x20

const byte pin1 = 10;  // DT
const byte pin2 = 11;  // CLK
int state = R_START;
int counter = 0;
int counter_ini = 0;
int potstep = 0;

const unsigned char ttable[7][4] = {
  // R_START
  {R_START,    R_CW_BEGIN,  R_CCW_BEGIN, R_START},
  // R_CW_FINAL
  {R_CW_NEXT,  R_START,     R_CW_FINAL,  R_START | DIR_CW},
  // R_CW_BEGIN
  {R_CW_NEXT,  R_CW_BEGIN,  R_START,     R_START},
  // R_CW_NEXT
  {R_CW_NEXT,  R_CW_BEGIN,  R_CW_FINAL,  R_START},
  // R_CCW_BEGIN
  {R_CCW_NEXT, R_START,     R_CCW_BEGIN, R_START},
  // R_CCW_FINAL
  {R_CCW_NEXT, R_CCW_FINAL, R_START,     R_START | DIR_CCW},
  // R_CCW_NEXT
  {R_CCW_NEXT, R_CCW_FINAL, R_CCW_BEGIN, R_START},
};

unsigned char process(){

  // Grab state of input pins.
  unsigned char pinstate = (digitalRead(pin2) << 1) | digitalRead(pin1);

  // Determine new state from the pins and state table.
  state = ttable[state & 0xf][pinstate];

  // Return emit bits, ie the generated event.
  return state & 0x30;
}

void setup(){
  pinMode(pin1, INPUT_PULLUP);
  pinMode(pin2, INPUT_PULLUP);
  Serial.begin(9600);

  //Display
  if (!OLED.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println("SSD1306 allocation failed");
  } else {
    Serial.println("ArdinoAll OLED Start Work !!!");
  }
OLED.clearDisplay();
OLED.setTextSize(2);
OLED.setTextColor(WHITE);
OLED.setCursor(5, 10);
OLED.println("   TEST   ");
OLED.println();
  OLED.display();
  delay(5000);
}

void loop(){

  unsigned char result = process();
  if(result == DIR_CW){
    counter++;
    //Serial.println(counter);
  }
  else if(result == DIR_CCW){
    counter--;
    //Serial.println(counter);
  }
  if(counter > counter_ini){
    potstep++;
    Serial.println(potstep);
    counter_ini=counter;
  }
  else if(counter < counter_ini){
    potstep--;
    Serial.println(potstep);
    counter_ini=counter;
  }
  if(potstep > 255){
    potstep = 255;
    //Serial.println(potstep);

  }
  else if(potstep < 0){
    potstep = 0;
    //Serial.println(potstep);
  }
//Display
    OLED.clearDisplay();
    OLED.drawRect(3,3,125,47,WHITE);
    OLED.setTextSize(4);
    OLED.setTextColor(WHITE, BLACK);
    OLED.setCursor(27,12);
    OLED.println(potstep);

    OLED.display();
}


text:
Setting flag for sending data through advertisements using hm-10 mlt bt05 and arduino uno
I have succesfully connected to my hm-10 device and started configuring it using AT commands. I would like to know if it is possible to modify the data sent in advertisement and read it on another hm-10 device in some way.
I am using AT commands specified here: http://denethor.wlu.ca/arduino/MLT-BT05-AT-commands-TRANSLATED.pdf
And some from here (working less consequently): https://www.rhydolabz.com/documents/37/datasheet%20HM-10.pdf
This is the device I am using: https://elextra.dk/en-gb/p/bluetooth-modul-til-arduino-ble-40-at-09-hm-10/H45653
I am using Arduino UNO R3.
I can configure the HM-10 module as a slave or master, and I can set name, and check characteristics. But I am having issues in setting a flag for the advertisement. How is it possible for me to set data that can be broadcasted to all nearby bluetooth devices (mainly other HM-10 modules). It does not need to be a lot. I think the flag is one byte, which is more than enough.
Anybody has the same problem? Is there anyway to broadcast and read data with this module without connecting?
This is my current code for sending AT commands:
/*
  Software serial multple serial test

 Receives from the hardware serial, sends to software serial.
 Receives from software serial, sends to hardware serial.

 The circuit:
 * RX is digital pin 10 (connect to TX of other device)
 * TX is digital pin 11 (connect to RX of other device)

 Note:
 Not all pins on the Mega and Mega 2560 support change interrupts,
 so only the following can be used for RX:
 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69

 Not all pins on the Leonardo and Micro support change interrupts,
 so only the following can be used for RX:
 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

 created back in the mists of time
 modified 25 May 2012
 by Tom Igoe
 based on Mikal Hart's example

 This example code is in the public domain.

 */
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(19200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop() { // run over and over
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
}


text:
How to bypass any on board circuitry when using an external LDO
I am using an ESP8266 NodeMCU (Amica) module.  I am powering it with a 3.7v rechargeable Li-Lion battery (18650).  I am regulating the voltage using a LDO circuit. https://randomnerdtutorials.com/esp8266-voltage-regulator-lipo-and-li-ion-batteries/
I want to avoid as much on board circuitry as possible.  For example I notice that there is a non-LDO regulator (AMS1117 chip) on board.
What pin on the module should I connect the regulator output to?
Thanks.


text:
UART - Different results between logic analyzer and an Arduino
I would like to decode a serial communication.
I have already found out how the protocol works. I can also send serial data with my logic analyzer and control the device this way.
I would like to integrate this function into an Arduino, but my Arduino Mega 2560 throws out completely different serial data than my Logic Analyzer.
The baud rate fits. 230400.
The first byte is 0x42. This is recognized correctly by the Arduino. After that, unfortunately, only gibberish comes out.
Does anyone have any idea how I can approach the problem?

What is the voltage of the signal? Which arduino pins are you using?

5V - Pin 18/19 (TX1/RX1)

In that case, simply attempt to read multiple bytes into a buffer.

It is better to post the code as text rather than a picture.  There's a formatting button in the question editor to properly format the code when you insert it.  Since the output is text, you can put it in the question the same way you do the program code.

@Abel I hate myself for that. I had measured the voltage. 5V.
I then ordered a Mega 2560 especially for this project because I didn't want to build a voltage divider.
Whatever I measured was wrong. The voltage is 3.3V.
I've been at it for half a day now. Such an unnecessary mistake.
Thanks for the hint.

@Jens1888 ATmega2560 data sheet says minimum Vih is 0.6Vcc so with 5V supply it should see a 3.3V signal just fine.

You get the first byte correctly but miss the next bytes because you are busy printing out the first byte instead of receiving the following bytes.
Your code cannot to all that at once, especially if you are using Arduino libraries like that.
This is the upsides and downsides of Arduino, it lets you do simple things easily, but either your requirements already grew out of being simple and suitable for Arduino, or you are using the Arduino libraries without considering what they are capable of and how.
So instead of waiting for first byte and immediately printing it out, it might make more sense to wait and read bytes until you have read some whole packet and have enough time to print the bytes before next byte arrives.
Another thing, how do you even know your Arduino can use 230400 bps rate? If it uses a 16 MHz clock source, you cannot get exacltly 230400 but the closes baud rate is 222222 bps, and that is already a 3.55% error to what you need. Usually the target is better than 1% error, but in a pinch many devices might work within 2% error because in theory it allows both devices to be within 2% of the nominal rate. Having an error of 3.5% is usually too large and very close to the point of not working at all.
Edit: OK, it cannot be a software issue because Arduino UART does use interrupts and uses a ring buffer for buffering data.
What is known is that a 16 MHz AVR cannot exactly hit 230400 bps and will have 3.5% error in the baud rate which exceeds recommendations for maximum baud rate error. What even makes the situation worse is that instead of a more precise crystal, the Arduino Mega2560 uses a ceramic resonator with additional 0.5% tolerance, 0.3% temperature stability, and 0.2% aging. A crystal would have in any case better than 0.01% tolerance for all scenarios. So the most likely cause is that the Arduino Mega2560 can be simply said not to support baud rate of 230400 reliably so that is why it does not work.
And also the Mega256 data sheet says that minimum input high voltage is 0.6*Vcc, so using a 5V MCU that will be 3.0V minimum, so it will be within specification to receive a 3.3V signal. So the voltage issue is extremely unlikely.

The Arduino Mega 2560 had a 64Byte Buffer for that. This allows the loop to run without interrupting the serial reception.

@Jens1888 Please explain where this 64 byte buffer is? It is not in the MCU for sure. Do you mean on the USB UART? Or is this a feature of Arduino code to provide you interrupt reception and transmission with a 64 byte buffer in code?

I don't know exactly how the buffer is realized. However, there is one.
Its a Arduino Feature for all Serial Comms.
https://www.arduino.cc/reference/en/language/functions/communication/serial/available/

@Jens1888 If there is no source code for the libraries, nobody knows how it really works. I do not understand why the Arduino libraries deliberately want to hide all the important stuff how it works so you can't see why it does not work when it does not work. But in this case it must use interrupts to read data into ring buffer. But I have never investigated how it receives data if baud rate mismatch causes framing errors.

@Justme: Here is the AVR implementation of the Arduino core. The “RX complete” ISR is implemented in HardwareSerial_private.h. Other bits of the serial communication library are in the other files named HardwareSerial*.

You need to understand the MCU you are using to be able to test and diagnose that the functionality meets your needs.

The accuracy of the baud/bit rate has to be considered for EACH serial link. In this case you have the serial link to your external device and the serial link to the Arduino console (a serial to USB converter implemented in an ATMEGA8).
Here is a good link to understand the problem of baud/bit rate generation: https://wormfood.net/avrbaudcalc.php

Notice here that you cannot actually set 230.4k because of the rough granularity as UBRR approaches 1.
You actually get 250k baud, which is used often for serial addressed DMX peripherals and works well on most Arduino variants.  In you case however, this is you first problem, a mismatch between your peripheral bit rate and the Arduino 2560.

There will be a difference between the baud/bit rate for your two serial connection since the console serial link is defined in a separate MCU (the ATMEGA8) and they have different crystals. You should examine the schematic for the Arduino Mega 2560 and try to understand the configuration.

Here there is an obvious answer to most of your problem, and that is to eliminate one of the two serial connections. You already discovered that the Arduino Zero works successfully, you just didn't go on to discover why (and it's not the clock rate for the MCU that is the issue).
In several Arduino variants they have a direct USB peripheral controller built in. Look at the Arduinos that use the ATMEGA32u4 or as you found the more modern variants such as the Arduino Zero. In these variants the console transfer actually happens at USB speeds for the serial transfer, this is a rate fixed at the USB connection state rate.
You should experiment with raising the baud/bit rate on the console higher than the peripheral bit rate you are using, that may solve your immediate problem with the MEGA 2560. I'd suggest you try setting the console to 500k or 1M, this may depend on what your IDE device is (PC or Linux) allows configuration for of course.
My suggestion would be to move to an MCU with inbuilt USB.

The Arduino core sets the UART to double speed mode (U2Xn = 1) when possible. For 230.4 kb/s, you get UBRR = 8, and an actual baud rate of 222.2 kb/s, (error = −3.5%). Not as bad as the 8.5% error you are showing, but still worrisome. 2. The two MCUs on the board (ATmega2560 and ATmega16U2) have the same type of UART, clocked at the same frequency. Their baud rate errors may be large, but they will match, ensuring trouble-free communication between them.

@EdgarBonet, agreed on U2XN, but it's still a sizeable error rate assuming the crystals are exactly the same frequency. In actuality the two crystals will differ slightly which could easily add another +/-1% variance. As I said, for the Arduino Mega 2560 with two separate async channels (one to the peripheral and one to the USB/serial converter it would be beneficial to raise the baud rate on the console uplink.

At that baud rate you have 23Kcps, giving you ~40us for each loop invocation.  IIRC the default serial buffer length is 16 characters, and you don't comment on the speed of the serial interface you are using for println() relative to the incoming data rate.  It is therefore possible that you might be simply getting behind on the incoming stream.
Your question asks for an approach to diagnosing.
If possible I'd start by changing the input stream to have the same bitrate, but with the characters spaced well apart.  See if that works.
If it does, the issue is likely either tied to loop timing and responsiveness, or could be related to the crystal/PLL accuracy at that rate.  (If may simply be the clock rate isn't a good match for the baudrate generator, with drift building up after the first character.)

I don't know how else to confirm a solution here. @Abel gave the decisive hint. I measured the voltage of the signal incorrectly.
Edit: I can't accept my own answer as a solution for another 2 days.

Actually it does not matter. The problem may be elsewhere. If you received the first byte correct, the voltage might just not be the issue, but your Arduino not buffering the data for you, or the fact that it cannot reach the required 230400 bit rate without too much error. The Mega2560 data sheet says at 5V, a digital input will see 3.0V reliably as logic high, so this may be the least of your issues.

I use an Arduino Zero that runs on 3.3V and it works perfectly.

You cannot compare those two. Of course a 32-bit ARM MCU running at 48 MHz clock can set the baud rate more precisely than 8-bit AVR running at 16 MHz. I believe the voltage of the MCU is not the problem, but hitting the correct baud rate. So simply because using an Arduino Zero works, it still does not prove it was a voltage problem to begin with.

That makes sense.
As already written, the 2560 should recognize the 3.3V as HIGH.


text:
Arduino uno r3 and wt901c ttl sensor to make compass and inclinometer
Currently I'm only able to read the raw data values from the wt901c ttl sensor.
How to convert the raw data to make a tilt compensated compass and inclinometer?

I'd suggest you concentrate on a single one of it's outputs and learn to convert that into something you consider "useable" - probably a conversion from the binary output into more familiar physical units. Each output will be one of a duple or a triple, so once you have converted one axis of one of the physical, you can easily convert the other 2. Then move on to another of the device's physical measurements and do the same; learn to convert one axis, then apply what you learned to the other axes.

I looked and did not find a opensource project for an Arduino and wt901c. That leaves reading the wt901c specifications and coding up a solution for your self. 2. Every magnetometer I have seen requires calibration. Depending on what you need it can be short and inaccurate or math / physically-intensive and accurate. 3. Using a gyroscope meas you accept dead reckoning errors and know how to deal w/them. 4. Most accelerometers can be used w/little calibration. 5. The accurate relation between orthogonal sensors is more important then calibrating them to match a particular unit of measure.

I took the liberty and added a real question to your post ... if you disagree with the change, then please edit your post ... your original question, do anyone know?, was a useless yes/no question


text:
5 Pin button to tell Continuous Servo to run for certain amount of time
I'm working with a 5 pin dome button, trying to get that to tell the motor to spin for a certain amount of time when it is pressed then stop until it is pressed again, where it would then run for the same amount of time. It's my first time doing anything with arduinos, wiring and coding. I have gotten the button to light up but I have no clue how to have it make the servo motor run once it's pressed. Can anyone advise on how to wire all of this up, along with some advice on the code? It's a school project, would be extremely helpful since my professor doesn't really have any interest in helping here. Thanks!
Using a red dome button (5 pin from Sparkfun.com), Arduino R3, continuous servo motor, and a mini breadboard

Hi, your question is currently not very specific. Have you searched the web foe something like "arduino read button tutorial" or "arduino servo tutorial" to learn how each part of your project can work individually? If yes, please explain where exactly you had problems understanding which tutorial. Also: please also provide a link to the buttons sparkfun product page, so that we can be sure we are talking about the same product

the button does not control the servo, the Arduino controls the servo ... the button only tells the Arduino that you pressed it ... it is the program that resoonds to the button press in some desired way


text:
ATtiny85 wireless transmitter using NRF24L01
I have an ATtiny85 microcontroller wireless transmitter to an Arduino Nano  receiver using the wireless module NRF24L01.
These are the sketches and wiring for both and the result is nothing in the serial monitor of the receiver (Nano board).
I'm using the Arduino Uno as an ISP programmer to upload the sketch to the ATtiny85 MCU.
I have updated the code and now the Nano (receiver) keeps disconnecting and connecting again and again... with the message "failed to connect!" in the serial monitor and there is no output for the sizeof(text).
Code:
Receiver Nano:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(9,10);

const byte address[6] = "00001";

void setup() {
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.startListening();
  Serial.begin(9600);
  Serial.println("Started!");
}

void loop() {

  if (radio.available()) {
    char text[32] = "";
    radio.read(&text, sizeof(text));
    Serial.println(sizeof(text));
    Serial.println(text);
  } else {
    Serial.println("Failed To Connect!!");
  }
}

ATtiny85 transmitter code:
//Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

//create an RF24 object
RF24 radio(3, 4);  // CE, CSN

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

void setup() {
  radio.begin();

  //set the address
  radio.openWritingPipe(address);

  // Set module as transmitter
  radio.stopListening();
}

void loop() {
  // Send message to receiver
  const char text[] = "Hello World";
  radio.write(&text, sizeof(text));

  delay(1000);
}

Wiring:
**Attiny85 ====>> nrf24l01**

D3/PB3   =====> CE

D4/PB4   =====> CNS

D2/PB2   =====> SCK

D1/PB1   =====> MOSI

D0/PB0   =====> MISO

VCC      =====> 3V BATTERY

GND      =====> 3V BATTERY GND

**Arduino nano ===> nrf24l01**

D9      =====>   CE

D10     =====>   CNS

D11     =====>   MOSI

D12     =====>   MISO

D13     =====>   SCK

VCC     =====>   3V3

GND     =====>   GND

do basic debugging ... serial.print a message,  like "start",  inside setup() ... does it show on serial monitor?

in loop() print the value of sizeof(text)

connecting again with the message (faild to connect!) in the serial monitor ... your post says that nothing is printed in the serial monitor

this site is not a forum ... please  do not add info in comments


text:
RFID-RC522 unable to detect some tags but correctly reads others
I'm trying to read an NFC/RFID tag using Arduino and an RFID-RC522 module.
Currently I'm able to successfully read the data from a key fob and from a card that were included with the RC522, but the tag I want to read is not detected at all.
Is the module I'm using unsuitable to read this kind of tags?
Tag:

Code:
    #include <SPI.h>
    #include <MFRC522.h>

    #define SS_PIN 10
    #define RST_PIN 9

    MFRC522 rfid(SS_PIN, RST_PIN);

    void setup() {
      Serial.begin(9600);
      SPI.begin(); // init SPI bus
      rfid.PCD_Init(); // init MFRC522

      Serial.println("Tag reader on");
    }

    void loop() {
      if (rfid.PICC_IsNewCardPresent()) { // new tag is available
        if (rfid.PICC_ReadCardSerial()) { // NUID has been readed
          MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak);
          Serial.print("RFID/NFC Tag Type: ");
          Serial.println(rfid.PICC_GetTypeName(piccType));

          // print NUID in Serial Monitor in the hex format
          Serial.print("UID:");
          for (int i = 0; i < rfid.uid.size; i++) {
            Serial.print(rfid.uid.uidByte[i] < 0x10 ? " 0" : " ");
            Serial.print(rfid.uid.uidByte[i], HEX);
          }
          Serial.println();

          rfid.PICC_HaltA(); // halt PICC
          rfid.PCD_StopCrypto1(); // stop encryption on PCD
        }
      }
    }

Output read on Serial Monitor when I scan the key fob and the card:
Tag reader on
RFID/NFC Tag Type: MIFARE 1KB
UID: BC 38 B4 12
RFID/NFC Tag Type: MIFARE 1KB
UID: 86 FB 35 B6

Wiring:

My RC522 module:

seems that way .

the tag I want to read is not detected at all - what tag, exactly?

Did you see on https://en.wikipedia.org/wiki/Radio-frequency_identification that there are multiple frequencies in use? The RC522 knows only 13,56 MHz...

@NickGammon the flat round one in the picture.

I was hoping for a part number, not a picture of some coils. As the busybee said, different RFID cards operate at different frequencies.

@NickGammon I see, thank you. Unfortunately I don't know the specification of the tag. It's on the package of consumable goods, whose production is now discontinued. These tags used to be read by a cooking device. Would you suggest me to try another RFID module according to the shape of the tag? Which one?

I did a Google Lens search of that image, and some results appear to suggest it is a 13.56 MHz tag, however I didn't see exactly a match on your image. Possibly another RFID module would work, or possibly that tag has failed. Those tags have a small microprocessor on them, conceivably it has gone bad.

@NickGammon thank you so much for your valuable help. If so, I should be able to read it (if the tag itself is not faulty). I suspect I may be affected by this issue.

Quite possibly. I buy stuff from eBay, and it often works, but I also wonder if I am dealing with seconds. You know, stuff the manufacturer discarded because it didn't work properly.


text:
RPi Pico board, using Earl Philhower RP204 library, SPI problem
I have tried a number of different programs, trying to get any of several SPI connected displays working with the Pico board.  All of them seem to not initialize the SPI port properly.  For instance, I use the Adafruit_GFX library.
The graphicstest demo program I tried unchanged except specifying the ILI9341 chipset, and the following code (obviously the void setup() and a few other lines, some commented out are original, to show context, and where in the code my lines have been placed).
The 'code' insert doesn't like the #defines and some of the other lines, sorry for the weird formatting
    #define TFT_DC 21

    #define TFT_CS 17

    #define TFT_RST 20

    #define TFT_MOSI 19

    #define TFT_SCK 18

    // Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
    Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
    // If using the breakout, change pins as desired
    //Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

    void setup() {
        Serial.begin(115200);
        delay(3000);
        Serial.println("ILI9341 Test!");

        bool ret;
        ////ret = setRX(pin_size_t pin);
        ret = SPI.setCS(TFT_CS);
        Serial.printf("setCS =%s\n", ret ? "T" : "F");
        ret = SPI.setSCK(TFT_SCK);
        Serial.printf("setSCK =%s\n", ret ? "T" : "F");
        ret = SPI.setTX(TFT_MOSI);
        Serial.printf("setTX =%s\n", ret ? "T" : "F");

What I get is nothing (0V) on the MOSI pin, and the SCK pin (18) shows the following:

Note that this is with no load, not even mounted on a circuit board, using multiple pico boards, all with the same issue.
I also tried using the TFT_eSPI library by Bodmer, which is designed for 32 bit processors including the RP2040, and specifically for displays, with roughly the same result, except that the MOSI pin is held high.
BTW, CS and DS pins, both not part of the SPI hardware seem to be working properly, and I did check, the code is compiling for Hardware SPI.
I'm doing something wrong, and I can't figure out what!

did you try it without doing the SPI.set... ? do you have tft.begin();?

The ttf.begin is the next line in the program, I didn't put the whole program in since it is an example in the Adafruit_gfx library.  Although I did see an example set of lines I added which just prints out the pin numbers for MOSI, SCK etc, and it turns out I didn't need to do the SPI.set... commands, since those were the default pin assignments.

For similar displays, I usually leave out the SPI.setCS() since I just use the software controlled CS pin. I'm not sure if it would help, but it's what I would try.

Arduino by default uses software SPI in the libraries.

I'd try using the second constructor (commented out line) that accepts the SPI pins (MISO/MOSI/SCK) and see if that helps. It might be possible the display thinks it is connected to the default SPI pins and so reconfigures the SPI prior to communication, replacing your setTX, setRX etc

Dig a bit deeper, looks like my suspicion could be correct .. the display does reconfigure the SPI port on demand based on the initial settings

Ok, my bad, I had two problems.  One was I didn't fully check the prototype board I made, there was a whisker short between the clock and the data line, causing the display to not work.  The other is that when I looked at the clock line when not plugged into the board, I didn't believe the signal was correct.
Apparently, the Pico has a bit of noise on the clock line sometimes when it starts to send data, which doesn't appear to affect anything, so I haven't looked at it too closely.
The second thing that really blows my mind, is that the clock signal is consistently no higher than between 1.38 to a maximum of 1.48 volts.  The Data line seems a bit better at just barely over 2V, but the displays I'm using don't seem to mind.  I thought these were 3.3 volt I/O, and expected something at least over 2.5V or so.  And since I had an issue with the wiring to the display, I never saw that it was "OK Anyway".
Thanks for everyone's suggestions.

The low voltages definitely sound odd. This post (or thread) might help, maybe? Try testing the voltages with nothing attached to the Pico (maybe some peripheral is dragging the voltages down). Or there is another short, that you've not found yet. Or maybe ask a new question to see if anyone knows why...

No, the reason I didn't immediately identify the short was because the pico is 1.46V in free air, connected to nothing but a scope.


text:
Arduino Nano ESP32 digitalread() frequency
for a project I'm trying to read an digital sensor signal with an Arduino Nano ESP32. I read on a different forum that the digitalread() function lasts 79 ticks, so with a clock speed of 16MHz this would result in a read frequency of 200KHz. My question is now, if i use the ESP32 which runs at 240MHz would this mean that the read frequency is around 3MHz?
edit:
time_per_tick = 1/clock_speed
read_freq = 1/(79 * time_per_tick)

You can't use measurements for completely different MCU. On AVRs there is lot of extra steps because of PROGMEM and those aren't needed on ARM architecture.


text:
Arduino Nano RP2040 Connect does not work with Nano Ethernet ENC28J60 shield
I modified a Robotdyn ENC28J60 shield for a 3.3 V Nano by removing the logic level conversion IC and bridging its contacts (2-3 for INT and 5-6 for MISO).
But the Nano RP2040 doesn’t start the sketch with the shield on it.

The Nano RP2040 Connect has the RP2040 BOOT pin instead of the classic's pinout RESET pin next to 5 V pin. The pin is labeled as REC.
The shield connects both RESET pins together so the RP2040 will always go into boot mode with the shield. You have to cut the pin or the PCB trace on the shield to disconnect the reset line from the BOOT pin.
pinout from www.arduino.cc


text:
MD Parola Animated Clock Help
I wanted to create a clock with the animation as shown in this article given below, please watch the video almost at the end to view the animation (if the first link doesn't work for some reason try the second link) :-
https://www.hackster.io/mircemk/esp8266-animated-clock-on-8x8-led-matrices-4867ae#code
https://www.youtube.com/watch?v=mO98BBGWHkg
The thing is he doesn't uses the same library as me so its hard to replicate his code because he has done everything manually (printing chars first and then creating a function to print strings) while mine handles everything on its own.
The problem I am facing is that if I were to use a string to store the time received from the rtc it will scroll the string entirely which is not desired.
I have tired zoning the display but that will not work because I quickly realized that although its technically possible to replicate the animation using zones with the Parola library it will be inefficient because each MSB and LSB of every time component will require a zone.
Then I stumbled on this discussion on the Arduino Forum :-
https://forum.arduino.cc/t/positional-control-in-md-parola/1143151/20
The creator of this discussion is experiencing a similar problem and the creator of the library Marco_C instructed him to try to work with the GetGraphicObject() functionality to implement the pushWheel example of another library. I was successful in doing what the library creator asked from the discussion owner but was unsuccessful in displaying the time. This is what I was able to do , this example below is from the MD_MAX7219 library but made to work with the Parola library using the getGraphicObject() function and works flawlessly :-
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include "RTClib.h"

#define MAX_DEVICES 8
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW

#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10

MD_Parola matrix = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
RTC_DS1307 rtc;

#define CHAR_SPACING 1            // pixels between characters
#define CHAR_COLS 8               // should match the fixed width character columns
#define ANIMATION_FRAME_DELAY 20  // in milliseconds

struct digitData {
  uint8_t oldValue, newValue;  // ASCII value for the character
  uint8_t index;               // animation progression index
  uint32_t timeLastFrame;      // time the last frame started animating
  uint8_t charCols;            // number of valid cols in the charMap
  uint8_t charMap[CHAR_COLS];  // character font bitmap
};

void updateDisplay(uint16_t numDigits, struct digitData *d)
// do the necessary to display current bitmap buffer to the LED display
{
  uint8_t   curCol = 0;

  matrix.getGraphicObject()->control(MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);
  matrix.getGraphicObject()->clear();

  for (int8_t i = numDigits - 1; i >= 0; i--)
  {
    for (int8_t j = d[i].charCols - 1; j >= 0; j--)
    {
      matrix.getGraphicObject()->setColumn(curCol++, d[i].charMap[j]);
    }
    curCol += CHAR_SPACING;
  }

  matrix.getGraphicObject()->control(MD_MAX72XX::UPDATE, MD_MAX72XX::ON);
}

boolean displayValue(uint16_t value)
// Display the required value on the LED matrix and return true if an animation is current
// Finite state machine will ignore new values while animations are underway.
// Needs to be called repeatedly to ensure animations are completed smoothly.
{
  const uint8_t DIGITS_SIZE = 2;
  static struct digitData digit[DIGITS_SIZE];

  const uint8_t ST_INIT = 0, ST_WAIT = 1, ST_ANIM = 2;
  static uint8_t  state = ST_INIT;

  // finite state machine to control what we do
  switch(state)
  {
    case ST_INIT: // Initialize the display - done once only on first call
      for (int8_t i = DIGITS_SIZE - 1; i >= 0; i--)
      {
        // separate digits
        digit[i].oldValue = '0' + value % 10;
        value = value / 10;
      }

      // Display the starting number
      for (int8_t i = DIGITS_SIZE - 1; i >= 0; i--)
      {
        digit[i].charCols = matrix.getGraphicObject()->getChar(digit[i].oldValue, CHAR_COLS, digit[i].charMap);
      }
      updateDisplay(DIGITS_SIZE, digit);

      // Now we wait for a change
      state = ST_WAIT;
      break;

    case ST_WAIT: // not animating - save new value digits and check if we need to animate
      for (int8_t i = DIGITS_SIZE - 1; i >= 0; i--)
      {
        // separate digits
        digit[i].newValue = '0' + value % 10;
        value = value / 10;

        if (digit[i].newValue != digit[i].oldValue)
        {
          // a change has been found - we will be animating something
          state = ST_ANIM;
          // initialize animation parameters for this digit
          digit[i].index = 0;
          digit[i].timeLastFrame = 0;
        }
      }

      if (state == ST_WAIT) // no changes - keep waiting
        break;
      // else fall through as we need to animate from now

    case ST_ANIM: // currently animating a change
      // work out the new intermediate bitmap for each character
      // 1. Get the 'new' character bitmap into temp buffer
      // 2. Shift this buffer down or up by current index amount
      // 3. Shift the current character by one pixel up or down
      // 4. Combine the new partial character and the existing character to produce a frame
      for (int8_t i = DIGITS_SIZE - 1; i >= 0; i--)
      {
        if ((digit[i].newValue != digit[i].oldValue) && // values are different
           (millis() - digit[i].timeLastFrame >= ANIMATION_FRAME_DELAY)) // timer has expired
        {
          uint8_t newChar[CHAR_COLS] = { 0 };

          matrix.getGraphicObject()->getChar(digit[i].newValue, CHAR_COLS, newChar);
          if (((digit[i].newValue > digit[i].oldValue) ||    // incrementing
             (digit[i].oldValue == '9' && digit[i].newValue == '0')) && // wrapping around on increase
             !(digit[i].oldValue == '0' && digit[i].newValue == '9'))   // not wrapping around on decrease
          {
            // scroll down
            for (uint8_t j = 0; j < digit[i].charCols; j++)
            {
              newChar[j] = newChar[j] >> (COL_SIZE - 1 - digit[i].index);
              digit[i].charMap[j] = digit[i].charMap[j] << 1;
              digit[i].charMap[j] |= newChar[j];
            }
          }
          else
          {
            // scroll up
            for (uint8_t j = 0; j < digit[i].charCols; j++)
            {
              newChar[j] = newChar[j] << (COL_SIZE - 1 - digit[i].index);
              digit[i].charMap[j] = digit[i].charMap[j] >> 1;
              digit[i].charMap[j] |= newChar[j];
            }
          }

          // set new parameters for next animation and check if we are done
          digit[i].index++;
          digit[i].timeLastFrame = millis();
          if (digit[i].index >= COL_SIZE )
            digit[i].oldValue = digit[i].newValue;  // done animating
        }
      }

      updateDisplay(DIGITS_SIZE, digit);  // show new display

      // are we done animating?
      {
        boolean allDone = true;

        for (uint8_t i = 0; allDone && (i < DIGITS_SIZE); i++)
        {
          allDone = allDone && (digit[i].oldValue == digit[i].newValue);
        }

        if (allDone) state = ST_WAIT;
      }
      break;

    default:
      state = 0;
  }

  return(state == ST_WAIT);   // animation has ended
}

void setup() {
  rtc.begin();
  matrix.begin();
}

void loop() {
  DateTime now = rtc.now();
  displayValue(now.second());
}

Now I need some help in implementing the same animation which this above code uses to display seconds to display time in this format "Hours:Minutes:Seconds" with each of the component MSB and LSB being animated individually. I have tried to make the example non blocking so that I can duplicate for hours and minutes as well but that is not the genius way of doing. Any help would be highly appreciated.
Below is the list of software as well as hardware I am using:-
-> Hardware Components :-

Arduino Nano
For now using only eight 8x8 Led Matrix Modules daisy chained(uses the MAX7219 chip).
A strong power supply for these hungry led(s) of 5 Volts and 10 Amps.
RTC DS1307.

-> Software Components :-

MD_Parola library by Marco_C.

This above code is a modified example named as push Wheel in the MD_MAX72xx library by Marco_C as well.
Both of the libraries can be found easily here :-
https://github.com/MajicDesigns

I am using the Standard RTC library found easily by the name RTClib.h in the arduino ide.

If any more information is required I am ready to provide. I Hope this is clear and any help would be highly appreciated :)

what animation are you taking about?  ... all I see is left scrolling text

@jsotola I don't know where the left scrolling text has come but the animation I am talking about is like that of a numerical counter it scrolls the existing digit upwards and scrolls a new digit from below. You can also click the first link I have provided and watch the photo or the video in that article.

@jsotola I see now, you saw the text at the very start of the video. That is not a issue for me, kind sir I request you to skip the video (The first one in the article under the title Story) to 1:02 seconds to see what animation I desire.

I looked at the second video at hackster.io again ... it is just a side scrolling YT subscriber counter ... no clock display ... the first image is not clickable for some reason

@jostula Well that was quite unfortunate. Check out this video
https://www.youtube.com/watch?v=mO98BBGWHkg
Please watch the left side of the display which is based on the code I have shared here :) I wanted to implement this scrolling up/down animation  to display time.

it makes more sense to add the link to the question,  instead of writing a comment ... comments are not for adding info to your post


text:
How do I make my stepper or servo move a certain way when a button on my ir remote is pressed?
Hi i am making a robot arm and I am trying to get my stepper and servo to move the direction that is pressed on the ir remote. I am using a sg90 and a stepper motor with 2048 steps. The ir receiver is picking up a ton of 0s in the serial monitor only when the code is run and everything is plugged in. Maybe that's the issue.
this is my code
#include <IRremote.h>
#include <Servo.h>
#include <Stepper.h>

const int in_4 = A0;
const int in_3 = A1;
const int in_2 = A2;
const int in_1 = A3;
int motorspeed = 5;
#define IR_RECEIVE_PIN 9

#define UPpin 70
#define DOWNpin 21
#define LEFTpin 68
#define RIGHTpin 67

int command; // Declare command variable

Stepper LR(2048, in_1, in_3, in_2, in_4);
Servo servo; // Add semicolon here

void setup() {
  Serial.begin(9600);
  servo.attach(2);
  LR.setSpeed(motorspeed);
  IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK); // You should initialize IrReceiver object
}

void loop() {
 if (IrReceiver.decode()) {
    IrReceiver.resume();
    command = IrReceiver.decodedIRData.command; // Assign value to command
    Serial.println(command);
  }
  if (command == RIGHTpin) {
  LR.step(1);
  }
}

It is frowned upon to created a second account and gain reputation by editing your own posts. You seem to have two accounts:  zachlikestech and zachlickstech123. You can merge accounts, see I accidentally created two accounts; how do I merge them?


text:
how to store images to a folder from OV7670 camera in a web server using ESP32
I'm a beginner at this, but I need to figure out how to store images in a folder from an OV7670 camera on a web server using ESP32 for a school project. Any help will be greatly appreciated!

is the ESP32 also a web server, or is the web server somewhere  else? ... please edit your question to clarify

First, take an image and store it on the ESP32. Second, use the ESP32 to POST the image data to a web site. There are numerous tutorials and examples on both of these subjects.


text:
Receiving data as an array from BLECharacteristic on Arduino Nano BLE Sense
I'm encountering an issue while working with the Arduino Nano BLE Sense and the nRF Connect app. I am trying to receive data from a BLECharacteristic as an array. However, regardless of the size of the data sent from the nRF Connect app, I consistently get a valueLength of 1.
Sketch
#include <Arduino.h>

#include <ArduinoBLE.h>

#define SERVICE_UUID "6e400001-b5a3-f393-e0a9-e50e24dcca9e"
#define CHARACTERISTIC_UUID_RX "6e400002-b5a3-f393-e0a9-e50e24dcca9e"
#define CHARACTERISTIC_UUID_TX "6e400003-b5a3-f393-e0a9-e50e24dcca9e"

BLEService watchService(SERVICE_UUID);
BLEByteCharacteristic pCharacteristicTX(CHARACTERISTIC_UUID_TX, BLENotify);
BLEByteCharacteristic pCharacteristicRX(CHARACTERISTIC_UUID_RX, BLEWrite | BLEWriteWithoutResponse);

void onConnect(BLEDevice central)
{
  // central connected event handler
  Serial.print("Connected event, central: ");
  Serial.println(central.address());
}
void onDisconnect(BLEDevice central)
{
  // central connected event handler
  Serial.print("Disconnect event, central: ");
  Serial.println(central.address());
}

void onWrite(BLEDevice central, BLECharacteristic characteristic)
{
  int len = characteristic.valueLength();

  Serial.print("Received Data, len: ");
  Serial.println(len);

  for (int i = 0; i < len; i++)
  {
    Serial.print(" 0x");
    Serial.print(characteristic.value()[i], HEX);
  }
  Serial.println();
}

void setup()
{
  Serial.begin(115200);
  while (!Serial)
    ;

  delay(2000);
  Serial.println("Starting ble sketch");
  BLE.begin();
  BLE.setLocalName("Nano BLE");

  // Create the BLE server
  BLE.setAdvertisedService(watchService);

  // Set up characteristics
  pCharacteristicRX.setEventHandler(BLEWritten, onWrite);
  // pCharacteristicTX.setEventHandler(BLEWritten, )

  BLE.setEventHandler(BLEConnected, onConnect);
  BLE.setEventHandler(BLEDisconnected, onDisconnect);

  // Start the service
  watchService.addCharacteristic(pCharacteristicTX);
  watchService.addCharacteristic(pCharacteristicRX);
  BLE.addService(watchService);

  // Advertise the service
  BLE.advertise();

  // Additional settings for iPhone connection issues
  BLE.setConnectable(true);
  BLE.setAppearance(0x01); // Generic Watch
}

void loop()
{
  BLE.poll();
}

Data sent with NRF Connect app
0xABCDEF123456

Serial Monitor
Starting ble sketch
Connected event, central: xxxxxx
Received Data, len: 1
 0xAB

Expected
Received Data, len: 6
 0xAB 0xCD 0xEF 0x12 0x34 0x56

what is your specific question? ... please add a focused, answerable question to your post


text:
RP2040 1.28 WAVESHARE TOUCH LCD
I'm using this library successfully for almost a year now. I used GC9A01 & GC9A01 with touch and it is great. Lately I purchased a RP2040 1.28 WAVESHARE TOUCH LCD which I thought it would be easy to manage as it uses the same hardware , but ... no luck.
I tried the clock example and used the Dev-Device-Declaration#waveshare-rp2040-lcd-128 but nothing comes on the screen.
Does anybody had any experience with this module? Any help would be appreciated.
Lucas

Your question seems to be "Does anybody had any experience with this module?" How will an answer to that help you?

Very simple,This is a way to start a good conversation if the answer is positive.

That is the difficulty. This is a Q&A site. There are places that can work like that. The Arduino Forum, Reddit, Discord, etc. Here the idea is to ask questions that are answerable with little to no back-and-forth discussion. I doubt you want people post answers that say "yes" or "probably." If you edit your post to contain a single clear answerable question you're more likely to have luck getting a useful answer. If you re-post this on the Forum or wherever, still you're better off providing the next step on the assumption that someone is familiar with it. Just means one less round trip.

Got it, I understand your spirit. Nevertheless there should be space (depend on the question) for generic questions because this improves knowledge, this is my point of view of course and I do not expect to change the rules. Thanks for been polite and honest.


text:
if statement for changing serial output breaks the integer used for rest of code
I want to get back in to coding so i am re-teaching myself some basics before i tackle a bigger project.
This fault is confusing the . out of me.
I have modified the fading LED code from the beginner pages to now include a dual colour led and now serial and lcd screen output of the current state of the led.
(My project will include all of these hence the combo).
All was well with the fading led.
It starts off,  fades up in green, when at max brightness, turns off green, switches to red then fades down.
Switches back to green and repeats.
Then i added serial and LCD output and now, the led colour part of the code breaks when ever i try and reference the currently active led pin to write that colour (As a string) to serial.
My code is below.
#include <LiquidCrystal_I2C.h> ///LCD library

int ledr = 6;         // the PWM pin the red LED is attached to
int ledg = 5;         // the PWM pin the green LED is attached to
int led;              // the active LED pin
int brightness = 0;   // how bright the LED is
int fadeAmount = 10;  // how many points to fade the LED by
//char colour;           // to use for displaying led colour as string in serial and lcd
LiquidCrystal_I2C lcd(0x27, 20, 4); //I2C LCD display address 0x27 with 20 cells x 4 rows display

void setup() {
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0,0);
  pinMode(led, OUTPUT);                                   // setup pin for led
  Serial.begin(9600);                                     // start serial
  analogWrite(13, 0);                                     // turn off led 13
//  Serial.println("Green fade up - Red fade down");       // write this to serial
//  delay(1000);                                           // wait 1 sec to see it in serial
  led = ledg;                                             // set led active pin to ledg

  }

void loop() {
  if (brightness <= 0) {                // if brightness <= 0,
  led = ledg;                           // set active led to ledg (green)
//  colour = 'Green';
 };

  if (brightness >= 255) {              // if brightness >=255, turn off last led (ledg, green), acivate ledr (red) with one cycle crossover.
  led = ledr ;                          // set active led to ledr (red)
  analogWrite(led, 255);                // set active led (ledr, red) to 100%
  led = ledg;                           // set active led to ledg (green)
 analogWrite(led, 0);                   // set active led ledg (green) to off
 led = ledr;
// colour = 'Red';                            // set led to ledr (red)

 };

  analogWrite(led, brightness);         // set active led to current brightness

  brightness = brightness + fadeAmount; // change the brightness for next time through the loop:

  if (brightness <= 0 || brightness >= 255) {   // reverse the direction of the fading at the ends of the fade:
    fadeAmount = -fadeAmount;
  };

                                   // below is outout to serial
  Serial.print(led);               // print the current active led pin and brightness to serial in the format (pin" - "brightness")
  Serial.print("  -  ");           // print " - "
//  Serial.print(colour);            // print the current colour of the led

// if (led = 5); {
//  Serial.print("Green");
//   };

//if (led = 6); {
// Serial.print("Red");
//  };

  Serial.print("  -  ");          // print " - "
  Serial.println(brightness);     // print the brightnesss of the led

                                  // below is outout to LCD
  lcd.setCursor(0, 0);            // move cursor the first row
  lcd.print("LED Pin + Colour");  // print message on the first row
  lcd.setCursor(0, 1);            // move cursor to the second row
  lcd.print(led);                 // print active led pin on the second row then
  lcd.print(" : ");               // print "+" then
//  led.print(colour);              // print the colour of the currently active led
  lcd.setCursor(0, 2);            // move cursor to the third row
  lcd.print("LED PWM (0-255)");   // print message on the third row
  lcd.setCursor(0, 3);            // move cursor to the fourth row

  if (brightness <= 99) {         // if to check for <100 brightness value and clear 3rd cell if true.
    lcd.setCursor(2, 3)  ;        // move cursor to line 4, cell 3
    lcd.print(" ");               // clear cell
    };                            // end if

  lcd.setCursor(0,3);             //move cursor back to start of row 4
  lcd.print(brightness);          // print message the fourth row
  delay(50);                      // wait for (x) milliseconds to slow the dimming effect
}

Please ignore the references to char colour. thats a different issue i'm having :(
When i un-comment either or both of the if statements below ** Serial.print(colour); ** it breaks. the led still fades in and out but the colour change stops working and it will only fade using the colour of the if statement i'm using.
Below is a good led switch without either if statements active
Led 6 (red) fades out and led 5 (green) fades up
6  -    -  40
6  -    -  30
6  -    -  20
6  -    -  10
6  -    -  0
5  -    -  10
5  -    -  20
5  -    -  30
5  -    -  40

Below is with the first if active active
5  -  Green  -  40
5  -  Green  -  30
5  -  Green  -  20
5  -  Green  -  10
5  -  Green  -  0
5  -  Green  -  10
5  -  Green  -  20
5  -  Green  -  30
5  -  Green  -  40

(green (string) is now shown as the if is active).
Green (5) was on when it should have been red.
Same thing with only the other if active but it would have been Red.
with both active,
6  -  GreenRed  -  40
6  -  GreenRed  -  30
6  -  GreenRed  -  20
6  -  GreenRed  -  10
6  -  GreenRed  -  0
5  -  GreenRed  -  10
6  -  GreenRed  -  20
6  -  GreenRed  -  30
6  -  GreenRed  -  40

Now, both colours are displayed despite the if statements and apart from the brief switch from 6 to 5 and back to 6 (It is supposed to, see code), the led is stuck on pin 6 (red)
I have tried if/else and two if statements and it has no effect.
from what i can tell, it is just the reference to (led = 5) or (led = 6) that causes the issue.
please help. I've spent 2 days trying to work it out and i am not very very confused.
Thanks.

The thing you've asked about (now answered) the commented out code colour = 'Green'; (not a string) are both things you should get warnings for if you increase the warning level in the IDE. May have saved you the two days.

i am not very very confused ... isn't  that a good thing?

your code is very messy... it is not not indented correctly ... please format your code sobthat each block is clearly delimited

You have an issue with = vs. ==.  One equal sign for assignment, two for comparison.  You also shouldn't have a semicolon on an if statement.  That semicolon acts as the only thing controlled by the if.  It translates to "if this then do nothing".  You want the stuff in brackets to be controlled by the if statement.  So no semicolon.
 if (led == 5) {
  Serial.print("Green");
 }

Awesome. thank you. I did not know the difference between = and ==.
I did know about the semicolon. I missed that one. Much appreciated.


text:
Fade loop glitch
I am working on a little sub program to run a PWM LED. I have a larger program that gives me a non-blocking 10 ms delay.
It mostly works well, but I get a -1 thrown during the code execution that causes my LED to flicker. Any insight into where this comes from or a better way to do this would be appreciated.
int pulse = 9; // the PWM pin the LED is attached to
int pulsebrightness = 0; // how bright the LED is
int fadeAmount = 1; // how many points to fade the LED by
int holdpulseon = 0;
int holdpulseoff = 0;
int totalcycle = 0;

void setup() {
  pinMode(pulse, OUTPUT);
  Serial.begin(115200);
  Serial.println (" ");
  Serial.println ("Momentum Booting");
}

// the loop routine runs over and over again forever:
void loop() {
  delay(10);

  analogWrite(pulse, pulsebrightness); // set the brightness of pin 9:

  if (holdpulseon == 0 && holdpulseoff == 0) {
    pulsebrightness = pulsebrightness + fadeAmount; // change the brightness for next time through the loop:
  }

  if (pulsebrightness <= 0 || pulsebrightness >= 255) { // reverse the direction of the fading at the ends of the fade:
    fadeAmount = -fadeAmount;
  }

  if (pulsebrightness == 0 ) {
    holdpulseon++;
    if (holdpulseon == 50) { // 50*10ms cycle
      holdpulseon = 0;
      Serial.print (holdpulseon);
      Serial.println (" hold on");
    }
  }

  if (pulsebrightness == 255) {
    holdpulseoff++;
    Serial.print (holdpulseoff);
    Serial.println (" hold off");
    if (holdpulseoff == 5) { // 5*10ms cycle
      holdpulseoff = 0;
      totalcycle++;
    }
  }

  constrain(pulsebrightness, 0, 255);
  Serial.println(pulsebrightness);

  if (totalcycle == 2) {
    delay (500000);
  }
}

0
0
0
0
0 hold on
0
-1
0
0
0
0
0

which line prints the -1?