text:
How to scroll text on an OLED display using only the SSD1306Wire library?
I'm a 13 years old boy and I am doing a project with esp01 and an OLED screen to display project ideas on the OLED with the ChatGPT API. The answer is displayed on the OLED but I would like it to scroll from bottom to top and so on to the next query so I can see the whole answer.I noted that the only library that worked for me for the esp01 was the SSD1306Wire library .My code is :
#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <Wire.h>
#include <SSD1306Wire.h>
#include <ArduinoJson.h>

const char* ssid = "WIFI_NAME";
const char* password = "WIFI_PASSWORD";

const char* apiEndpoint = "https://api.openai.com/v1/engines/text-davinci-002/completions";
const char* apiToken = "OPENAI_TOKEN";

SSD1306Wire  display(0x3c, 2, 0);
void setup() {
 Serial.begin(115200);

 WiFi.begin(ssid, password);
 while (WiFi.status() != WL_CONNECTED) {
   delay(1000);
   Serial.println("Connecting to WiFi...");
 }

 Serial.println("Connected to WiFi");

 display.init();
 display.flipScreenVertically();
 display.setFont(ArialMT_Plain_10);
}

void loop() {
 WiFiClientSecure client;
 client.setInsecure();
 HTTPClient http;
 http.begin(client, apiEndpoint);
 http.addHeader("Content-Type", "application/json");
 http.addHeader("Authorization", "Bearer " + String(apiToken));
 String payload = "{\"prompt\": \"TEXT_TO_QUERY\",\"temperature\":0.8,\"max_tokens\":40}";
 int httpResponseCode = http.POST(payload);
 String response = "";

 if (httpResponseCode == 200) {
   response = http.getString();
   int startIndex = response.indexOf("text\":") + 7;
   int endIndex = response.indexOf("\",\"index\"");
   response = response.substring(startIndex, endIndex);
   response.replace("\\n", "\n");
   Serial.println(response);
 } else {
   Serial.print("Error: ");
   Serial.println(httpResponseCode);
 }

 http.end();

 display.clear();
 display.drawStringMaxWidth(0, 0, 128, response);
 display.display();

 delay(18000000);
}

Could anyone help me?

have you looked at the example sketches?

The 5 hour pause is supposed to be 30 minutes, my mistake. The library doesn't seem to have example sketches.

then do an internet search for SSD1306Wire.h

But my problem is that the library does not support the scroll function

Are  you asking for smooth scrolling or jumping by a character or line of text?  Assuming the former, are you asking for horizontal scrolling or vertical scrolling.  I think horizontal scrolling is supported but is undocumented.  I'm not sure about vertical scrolling.

I would like the texte to scroll smoothly
From the bottom to the top

The library I think you are using is hosted at github.com and does not appear to support vertical scrolling as there has been discussion that looks to have ended about vertical scrolling in the issues.  It may support horizontal scrolling, but that discussion also points to a fork of the project on another github.com page. If you want to know more I suggest going there and reading these discussions.  Perhaps participating in them.

Ok thank you . Should I close the discussion or something like that?

You, or the person answering your question (@st2000) should convert the comments into an actual answer. Then it can be marked as accepted, in order to help others with the same query.

The SSD1306Wire code, its development history and discussions can be found here on github.com.
The Google search pattern "scroll
site:github.com/ThingPulse/esp8266-oled-ssd1306" can be used to find
all matches to "scroll" on these web pages. There appears to be
interest in vertical scrolling by others but no support as of yet.
There also appears to be some horizontal scrolling support or success as
discussed in this github.com issue for this project.
Also in that thread, there is a link to another DSS1306 github.com project
which explicitly states it supports horizontal scrolling.


text:
BLE disconnect during code "pause"
I have a code that should pause the script for a specific time (x_time). if x_time is above 30-40 sec the BLE connection to the android phone is lost. Any suggestions on how to avoid the lost connection and creating a pause in the script?
code:
#include "LSM6DS3.h"
#include "Wire.h"
#include <ArduinoBLE.h>  // Arduino BLE library

//Create a instance of class LSM6DS3
LSM6DS3 myIMU(I2C_MODE, 0x6A);  //I2C device address 0x6A
const char* UUID_serv = "75681d64-fd7e-40f7-874f-c6f2e7ec996c";

// UUids for accelerometer characteristics
const char* UUID_AccBLE = "75681d64-dd7e-40f7-874f-c6f2e7ec996c";

BLEService myService(UUID_serv);
BLEIntCharacteristic AccBLE(UUID_AccBLE, BLERead | BLENotify);

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

    pinMode(LEDB, OUTPUT);  // onboard led blue
    //Call .begin() to configure the IMUs
    if (myIMU.begin() != 0) {
      Serial.println("Device error");
    } else {
      Serial.println("Device OK!");
    }
    // init BLE
    if (!BLE.begin()) {
      Serial.println("BLE: failed");
    }
    Serial.println("BLE: ok");

    BLE.setAdvertisedService(myService);
    myService.addCharacteristic(AccBLE);
    BLE.addService(myService);
    AccBLE.writeValue(0);
    // start advertising
    BLE.advertise();
    Serial.println("Advertising started");
    Serial.println("Bluetooth device active, waiting for connections...");
  }
}
float accelerometerX;
unsigned long BreakPreviousMillis;
unsigned long timestamp = micros();

int x_time = 50000;
void loop() {
  BLEDevice central = BLE.central();
  if (central) {
    Serial.print("Connected to central: ");

    while (central.connected()) {
      accelerometerX = myIMU.readFloatAccelX();
      if (accelerometerX > 2) {
        BreakPreviousMillis = millis();
        while (millis() < BreakPreviousMillis + x_time) {
          Serial.println("pause");
        }
      }
      AccBLE.writeValue(accelerometerX);
      Serial.print("*************LOOP TIME[uS] = ");
      Serial.println(micros() - timestamp);  // 13HZ =79000-80000 uS   // used to check framerate
    }

    digitalWrite(LEDB, HIGH);  // High == turning off the Led
    Serial.print("Disconnected from central: ");
    Serial.println(central.address());
  }
}

Which core? There are two of them, one has RTOS and second mbed-os (like Arduino 33 nano ble), there might be some differences. Or it needs calling some method to handle events. For example BLE.poll(); or something

Thanks for the comment. I use the mbed-os core

One more thought - add some delay in that while loop, maybe the BLE service is running on lower priority thread and it's "starving" for resources

you can just use delay(x_time); instead of the while loop

Thanks for the response. I tried the delay(x_time) however it was even worse and disconnected  af 10-15 sec.

source: Stack Exchange

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

sort: votes


text:
Teensy 4.1 serial communication with 7N2 (7 databits no parity 2 stopbits)
I have ported a project from arduino Due to a teensy 4.1
In the project I read data from a sensor which speaks serial at 7 databits, no parity and 2 stopbits (no configurable).
Now it seems that teensy does not support this dataformat.
Could I read my sensor in a way using teensy 4.1? I could maybe use softwareserial but the format does not seem to be configurable.

maybe try to use SERIAL_7N1 | SERIAL_2STOP_BITS, I don't see why it shouldn't support it

Hi @KIIV I tried but it doesn't compile: 'SERIAL_7N1' was not declared in this scope. 7 databits with no parity is not listed in the supported dataformats.

Weird, how about  8N1 with masking that last bit to logic 1, so it'll look like 2 stop bits?

There is no difference between 7N2 and 8N1. You just have the most significant bit of your data value being the first of the two stop bits.
To transmit just set the most significant bit to 1.
To receive just ignore the most significant bit.
For example:
Serial.write(val | 0x80);

And:
uint8_t val = Serial.read() & 0x7F;

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


text:
Arduino + Codeblocks C++
I'm writing the code for my Arduino board using Code::Blocks editor. When I create a new project, there is AVR Project and Arduino Project under Projects category. Which one do I select?

@chrisl - This looks like an answer. Please make it an answer. Comments on questions are for clarifying the question. To "answer" like this make the SE software think no-one has answered.

You can select, what you want. If you want to build an Arduino Project, you should choose "Arduino Project". If you don't want to use the Arduino Framework, you can choose "AVR Project".

how do I set the path to arduino.h and other headers?

Under project build options, Arduino UNO (which is the version I have) I can see my path is set to $(ARDUINO_DIR)\libraries but isnt compiling


text:
How to use d0 and d1 pins of arduino uno (Others) as a digital output when I don't want to use Serial
I have searched this topic almost everywhere also got different results that couldn't satisfy me
My new project is a 4x4 LED cube
Of which
Will contain 4 Rows and each Row will contain 16 LEDs
So, I need to use all the digital pins 0-15 as digital output.
And other pins 16-20 for grounding.
But the problem is, this project needs d0 and d1 pin to be connected as a digital output pin. (Not Serial communication)
In some places I have seen that Experts saying

If you want to use Serial communication, then you can't use them.

You can't use it while your arduino is connected to PC.

You Can't do this ,as this may harm the device

You must turn off serial connection first.

OK, reading this, I got confused, I don't need to use any serial connection (console and others) in this LED cube project so I tried to turn off serial connection by not writing the code below.
Serial.begin(9600);

So, will that free those d0 and d1 pins as digital for me ? Or USB connection is also considered as a serial connection?
So, how can I do it? And will doing it really harm my board?

If you don't use the serial port, pins 0 and 1 are regular I/O pins.
It's just as simple as that.

If you want to use Serial communication, then you can't use them.

Correct.

You can't use it while your arduino is connected to PC.

Wrong. You can keep the USB cable connected as a power supply. You will
not be able to use it for communication though.

You Can't do this, as this may harm the device

What is “this”? The device can be harmed if you drive too much current
to/from an I/O pin, irrespective of whether it's a pin that could be
used for serial communication.

You must turn off serial connection first.

Only if you did turn it on before. If you never enable Serial, you
don't have to do anything more.

An LED consumes approximately 3 volts and 30 mA (maximum rate) and the output of arduino pins are 5 volt and 40 mA, so , this shouldn't harm my board, so, Not writing the code 'Serial.begin(9600);' code will solve my problem right?

@SubhaJeetSikdar: 40 mA is the “absolute maximum rating”. Under normal working conditions, you should normally not source more than 20 mA from a single pin. Note that there are also limits on the sum of the currents sourced by a  single port. See the datasheet.

The bootloader always turns UART0 on upon the loading of the code to your Arudino Nano.
So at the end of the day pins D0 and D1 are used for their alternate functions as a UART receiver and transmitter without you doing so in your code.
Copy the following code to whatever your sketch or C program to disable the UART0 module before you initalize pins d0 and d1 as digital IO, then you can set the two pins as digital I/Os as usual and they will work perfectly.
UCSR0B &= ~(1<<3);
UCSR0B &= ~(1<<4);

the Arduino init() does this https://github.com/arduino/ArduinoCore-avr/blob/24e6edd475c287cdafee0a4db2eb98927ce3cf58/cores/arduino/wiring.c#L383

Thanks for the information. I recommend using register accessing to be more generic for the ones -like me- who are developing code on Eclipse using C and loading it to the ATmega328P on the Arduino Nano. I'm not using the Arduino IDE.

then put that disclaimer in the answer so people don't start to put those two lines in Arduino sketches

FYI I tried putting the two lines of codes in an arduino sketch and it worked. Thanks for your concern.

of course it works, but it is redundant


text:
Problem connecting 2 74HC595 8 bit shift registers in cascading connection
I have now successfully learned how to control a single 8 bit shift register 74HC595 with Arduino UNO but whenever I tried to connect another one with the first shift resistor via cascading connection just like the image shown below (well I didn't use the 10uf capacitor between positive and negative terminal), the first shift register only outputs as desired but the second shift register, connected to a cascading connection, does not seem to work...

Here is the code.
    int latchPin = 10;  // Latch pin of 74HC595 is connected to Digital pin 5
int clockPin = 11;  // Clock pin of 74HC595 is connected to Digital pin 6
int dataPin = 9;    // Data pin of 74HC595 is connected to Digital pin 4

byte leds = 0;      // Variable to hold the pattern of which LEDs are currently turned on or off

/*
 * setup() - this function runs once when you turn your Arduino on
 * We initialize the serial connection with the computer
 */
void setup()
{
  // Set all the pins of 74HC595 as OUTPUT
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  Serial.begin(9600);
}

/*
 * loop() - this function runs over and over again
 */
void loop()
{
  leds = 0; // Initially turns all the LEDs off, by giving the variable 'leds' the value 0
  updateShiftRegister();
  delay(500);
  for (int i = 0; i <= 16; i++) // Turn all the LEDs ON one by one.
  {
    bitSet(leds, i);        // Set the bit that controls that LED in the variable 'leds'
    updateShiftRegister();
    delay(500);
  }

 /* The loop above should repeated 16 times as there are 2 shift resistors, each of them containing 8 and we need to lit up all 16 LEDs*/

}

/*
 * updateShiftRegister() - This function sets the latchPin to low, then calls the Arduino function 'shiftOut' to shift out contents of variable 'leds' in the shift register before putting the 'latchPin' high again.
 */
void updateShiftRegister()
{
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, LSBFIRST, leds);
   digitalWrite(latchPin, HIGH);
}

so is it my code or wiring problem?
I have read many articles on internet to make myself get it understood but unfortunately, none of the articles satisfied me.
many thanks for giving me a bit of your precious time...

connect the microcontroller output to the second 74HC595 to test it

add a second shiftOut. one sends only 8 bits. https://www.arduino.cc/reference/en/language/functions/advanced-io/shiftout/

someone please post a code, I really am unable to understand what to do, even after reading the article link by @Juraj, i have got a new mess inside my brain

add leds2 and send it before leds

You're (still) only shifting one byte (8 bits) of data out, so your second HC595 never receives any data. You should do what @Juraj wrote: add a leds2  variable to your code and insert a second ShiftOut(dataPin, clockPin, LSBFIRST, leds2); before the first shiftOut() in the updateShiftRegister() function. You should also set the appropriate bits in leds2 to control which LED is on and which is off.

As Juraj wrote add another line shiftOut(dataPin, clockPin, LSBFIRST, leds); to the updateShiftRegister() function, right above or beneath the other one. Currently you are only sending data for the first shift register. A second register would also need data, so you need to shift out another byte of data.

Oh, getting to understand it a little, i have to create another byte data type named 'led2' for the second shift register then repeat the same process? Right?

I am really very sorry to say that after a long inspection , i have found that
shift register clear (pin 10) pin of the second shift register remained inactivated due to loose connection of power, after fixing it, all shift registers are working very fine.
I do really apologize to all those friends who came to help me, for wasting their time, i am really very sorry for that...
all problems are solved now.


text:
Arduino uno weird behavior on a simple counter program
So I just got my first Arduino Uno board and the output on the serial monitor doesn't make sense to me. For this code
int counter = 0;

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

}

void loop() {
  counter++;
  Serial.println(counter);
  delay(1);
}

I'm expecting to see an increment once every 1ms. But what I see from the console is odd
First, I'm expecting to see the timestamp like this: 27.270, 27.271, 27.272...
Second, from 27.301 to 27.334, I only saw the counter increase by 7 instead of ~30.

If you do something like
Serial.println(580);

that is 5 characters printed (3 digits, then CR and LF to end the
line). Each character takes ten bits worth of transmission time (one
start bit, 8 data bits and one stop bit). The whole message is then
50-bit long on the serial line. At 9600 bits per second, this takes
about 5.2 milliseconds.
Note that the PC seems to be buffering the data, which is displayed in
batches, each batch having a single timestamp. Thus you see that, on
average there are 5.2 ms between increments.

So is there a quick fix to this?

@GotYaLoot: Fix for what? If the problem is, as stated in the question, “the output [...] doesn't make sense to me”, the fix is simply to understand this answer. Is there another problem that would need to be fixed?

I want the serial monitor show something like:
time 0.001 counter=1
time 0.002 counter=2
time 0.003 counter=3

How are you expecting to see a printout every ms when it takes over 5ms to print one line? Also as stated above, when working with serial communication to a PC, there are multiple buffers involved along with the non-real time os that your PC is running. This means there is no way to get ms precision of printed lines with this setup. Its going to be really hard for anyone to give much advise since we have no idea what you are trying to accomplish(big picture wise).

If you increase the baud rate from 9600 to 115200 you will see much faster prints, but you are still at the mercy of the the serial buffers and OS on your pc.

If it takes half an hour to bake a cake, setting a timer for 1 second after you bake the cake, will not make cakes appear every second.


text:
This DC Motor shouldn't have any current while I'm not pressing the button (pin 7 is LOW) but it has. (When I'm pressing the button its as intended)

I can't seem to find the problem, and I believe its not about the code but I will give you the code nevertheless.
const int pinOFswitch = 4;
const int motor_3 = 7;
const int pushbtn = 5;

void setup( ) {
  pinMode(pinOFswitch, INPUT);
  pinMode(motor_3, OUTPUT);
  pinMode(pushbtn, INPUT);

}
void loop( )
{
  byte pbtn;
  pbtn = digitalRead(pushbtn);
  while(pbtn == HIGH){
    int ValueOFswitch;
    ValueOFswitch = digitalRead(pinOFswitch);
    if (ValueOFswitch == HIGH){
        digitalWrite(motor_3, LOW);
        pbtn = digitalRead(pushbtn);
    }
    else
    {
        digitalWrite(motor_3, HIGH);
        pbtn = digitalRead(pushbtn);
    }
  }
        digitalWrite(motor_3, LOW);
}

It seems, that you are using an NPN transistor as high side switch (on the Vcc site of the motor). Try connecting the NPN transistor as low side switch (between the motor and ground).

When I'm pressing the button its as intended ... how do you know know this? ... maybe the button does not even work

Inverted polarity of the 18V motor supply? The voltage on the motor looks like 18V minus Veb breakdown voltage ~= 12V

This would benefit from a proper schematic, but it looks like the GND (-) of your motor is not connected to the GND of Arduino, but instead the +9 V going into the Arduino and the +18V feeding the motor are connected. Are you sure that's what you intended?


text:
Is std::array (from the C++ STL) safe to use on arduino? Does it use dynamic memory allocation?
I'd like to use std::array on a project that will need to be very stable, and have all memory pre-allocated to avoid heap fragmentation.
I am reading in characters from the serial port, following a known protocol. Each received byte will be written to a char array of ample size to hold the longest possible string I will receive. I will then perform some minor on the fly operations, (i.e. skipping certain characters, replacing one with another, etc.) and write those out another serial port.
This device needs to function indefinitely. I will not be calling malloc or new anywhere in my code. All of my control objects are singletons, (audible gasp from the high-level crowd!) created during setup, and never being destroyed.
Is the STL array template safe to use in this context?
After reading this post, and this post, the only potential issues I can see are exception handling. As far as I'm concerned, an exception is as fatal as an access violation. I would not expect to ever attempt recovery from an exception, so I don't care that Arduinos don't support them.
But what will happen if the program tries to throw one? Will the arduino compiler even allow the use std::array if it supports exceptions? Is there an Arduino-friendly array template that uses fixed size arrays and supports iterators?
Thanks!

I don't put it as answer, because it's not directly answering your question. It seems it is dynamic memory allocation safe to use std::array, however, you still don't know what's under the hood, maybe memory consumption is an issue (stack size of local variables of nested functions called by the public functions for replacing and iterating). If you need some minor functions, I would write them myself and stay in full control of both memory and performance decisions.

"I would write them myself and stay in full control of both memory and performance decisions"
That's the eternal question. My time spent writing it myself, or my potential time spent figuring out where my memory went. I'm working on other parts of the code in the mean time, but I hope someone who has already made this mistake can chime in before I commit to one or the other.

@Michel Keijzers Also, FYI, I am running this on a Mega, so it does have more memory. But still it isn't a lot, in the grand scheme of things.

std::array does not use dynamic memory allocations to store its elements. If you use static or stack-allocated std::arrays, you don't have to worry about memory fragmentation (contrary to std::vector or String, for example).
Of course, if you allocate arrays on the stack, you can have a stack overflow if you call too many functions, either by design, or because of a bug.
That brings us to the problem of exceptions. If you look in the standard, you'll see that most of the member functions of std::array are marked noexcept, with the notable exception of the element accessors. Obviously, the at() accessor can throw, but you'd expect that operator[] doesn't.
In practice, operator[] is marked noexcept in the version of the STL (GCC9) that I have on my computer, so if you check it in the STL implementation you're using, you can be pretty confident that it won't throw. Just keep in mind that this is not mandated by the standard.
/usr/include/c++/9/array
      // Element access.
      _GLIBCXX17_CONSTEXPR reference
      operator[](size_type __n) noexcept
      { return _AT_Type::_S_ref(_M_elems, __n); }

      constexpr const_reference
      operator[](size_type __n) const noexcept
      { return _AT_Type::_S_ref(_M_elems, __n); }

The debug version is also marked noexcept, but it can throw/abort if the index is out of bounds:
/usr/include/c++/9/debug/array
      // Element access.
      _GLIBCXX17_CONSTEXPR reference
      operator[](size_type __n) noexcept
      {
    __glibcxx_check_subscript(__n);
    return _AT_Type::_S_ref(_M_elems, __n);
      }

      constexpr const_reference
      operator[](size_type __n) const noexcept
      {
    return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n)
     : (_GLIBCXX_THROW_OR_ABORT(_Array_check_subscript<_Nm>(__n)),
        _AT_Type::_S_ref(_M_elems, 0));
      }

The STL implementations for Arduino I found online don't seem to have the <array> header.
Luckily, you can easily create your own array container, for example:
template <class T, size_t N>
struct Array {
    // Storage
    T data[N];

    static size_t length() { return N; }
    using type = T;

    // Item access
    T &operator[](size_t index) { return data[index]; }
    const T &operator[](size_t index) const { return data[index]; }

    // Iterators
    T *begin() { return &data[0]; }
    const T *begin() const { return &data[0]; }
    T *end() { return &data[N]; }
    const T *end() const { return &data[N]; }

    // Comparisons
    bool operator==(const Array<T, N> &rhs) const {
        if (this == &rhs)
            return true;
        for (size_t i = 0; i < N; i++)
            if ((*this)[i] != rhs[i])
                return false;
        return true;
    }
    bool operator!=(const Array<T, N> &rhs) const {
        return !(*this == rhs);
    }
};

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

  // Create an array
  Array<int, 5> myArray = {1, 2, 3, 4, 5};
  // On older compilers, use double braces:
  //    Array<int, 5> myArray = {{1, 2, 3, 4, 5}};

  // Iterate over the array
  for (int element : myArray)
    Serial.println(element);

  // Access elements of the array
  myArray[2] = 30;
  Serial.println(myArray[2]);
}

void loop() {}


text:
Trying to create a delay function whilst performing other functions, using Timer.h libraries. Arduino uno
I am having a compilation error saying invalid useof template-name 'Timer without an argument list.

First: What is your font dude? XD Second: Please don't show images of code here. Instead you should copy and paste the code as text into your question. Then select the code and click on the {} button to format it correctly. And third: You should include the complete error message (as text like the code) into your question. Also provide links to the Timer library, that you are using.

Second: Which timer library are you talking about? Have you looked at its doc/examples ?

i love the font ... what is its name?

Read, play with, and understand the Arduino BlinkWithoutDelay basic example.
Understand means learn that it does not only apply to blinking, but to any time related action without blocking the main loop().
It's better learning the basics than using libraries in a wrong way.

thank you for your avid response, it was my first time posting here. i will Read, play with, and understand the Arduino BlinkWithoutDelay.


text:
Privacy of a program
I have created a algorithm and using arduino harware, and I don't want that users of my hardware could read or copy the Program so is there any security code or something that I could use. But I must access it whenever I needed to. It should be like admin and users.

A quick search gave me this question. Maybe that is fitting for you

Chances are that I could pretty easily copy your algorithm without ever seeing your code.  I'd just need to play with the product for a little while.  Keeping the code a secret isn't the way to make money in this business anymore.

The code that's sent to Arduino is "compiled" which means it's changed from human readable form to a binary data that can be understood by the processor. The "code" you wrote remains on your computer only.
This itself is a way of encryption since it's impossible to retrieve the original source code from that binary data. That data can only be "decompiled". This is a process that takes the binary data and converts it automatically into a human readable code, but it's not the same code that you originally made. It doesn't have comments, and logical variable names. This makes it also hard to understand.
Decompilation is usually to difficult and time consuming to even bother doing that unless your hardware is a lock on a vault with million dollars inside. If that's the case don't use Arduino, but instead use a custom designed chip with cryptographic key built inside the hardware.


text:
Sketch works on Arduino nano but not Pro Mini
I have a simple test sketch to run for my led aquarium:
#include <IRremote.h>
#include <IRremoteInt.h>

IRsend irsend;
void setup() {

}

void loop() {

irsend.sendNEC(0xF7C03F, 32);
delay (2000);
}

I am using a 850nm Infrared LED and a 330Ohm resistor.
The connection:
Digital 3 to Resistor -> GND

On the Arduino nano it runs perfectly: the LED of my aquarium turns on and off like the sketch tells it to.
But on the Pro Mini nothing happens.
To be honest, it is my first time using the pro mini.
Maybe I forgot something???
I am using a FTDI232 (set to 5V) to flash it.
Hope someone can help me.
Kind regard
Daniel :)

Can you confirm, that the sketch really runs? You can use the Blink Sketch with a normal LED, so that you can see, if the sketch really runs, that you programmed onto the pro mini

Can you verify that the led lights up? I used the front-facing camera of my iPhone to see if my IR-led was blinking. Secondly; which pro-mini variant are you using? The 3.3V or the 5V one? Make sure you selected the correct one in the "boards" menu.

Yes, the blink sketch seems to run. The LED next to pin 9 turns on/off for 2 secs.

I think it is the 5V variant. (I measured VCC and GND and it gave me 5V).

how is that resistor connected on breadboard? in the same column?

Yes, the resistor is in the same colum. On the breadboard it is in "h" and "i" the led is in the same column in "j".

I checked with my phone, the led lights up. It is just a millisecond or so, but it lights up.

I recorded the signal, that was sent from the arduinos: pro mini: FA34C27F        nano: different signal every time it sends, nevertheless the led of my aquarium reacts to the nano signal.

the resistor in the same column does nothing. it is like it wouldn't be there


text:
OEM Arduino UNO not seen by COM port
Arduino UNO R3
My error code:
avrdude: ser_open(): can't set com-state for "\.\COM3"
An error occurred while uploading the sketch
This has been mentioned several times before here in the Stack.  I have been through several of them and followed the steps to delete/reinstall the CH340G Serial driver, change cables, and changed the USB port selection on the computer, all without success.  The computer will 'see' the UNO.
I use Windows 11.  I also learned that the card is a counterfeit from LAFVINTECH.COM.
At the moment, I have no answers.  I've tried everything I know of except taking it to the gun range.

Did you try turning the computer off then on again?

Have you seen this Q+A? https://arduino.stackexchange.com/questions/55301/avrdude-ser-open-cant-set-com-state

Here are the answers to the above comments.

Did you try turning the computer off then on again? –
VE7JRO
YES
Have you seen this Q+A? arduino.stackexchange.com/questions/55301/… –
VE7JRO
YES.
Did you assign USB on the Windows computer? Then Arduino IDE should be able to find the hardware when uploading the Sketch. This works for me. –
John
The Computer automatically assigns a COM port to the connection.  There are three USB ports on the front of the tower.  They are COM 3, COM 4, and COM5.  The computer has the correct Driver and then responds with a visible tie between card and PC.

I have more information that may be helpful - I connected an ATMEGA328P_U (call this one "A") to TWO different PCs and it worked fine.  I then connected an ATMEGA328P_U_TH (Call this one "B") to both PCs and it did not 'see' the card in the proper way.    "A" com port responded by adding 'Arduuino Uno' to the COM port number.  "B" did not.


text:
HC-08 Compatibility issues with iPhone
I am trying to connect my IPhone to an HC-08 Bluetooth module on an Arduino. The HC-08 is showing up in the new device section of android devices but it does not show up on an IPhone's Bluetooth device adding page. Also although it shows up on Android it will not successfully pair. I have an IPhone 13 which uses Bluetooth v5 and the HC-08 uses Bluetooth v4. I think Bluetooth v5 should be backwards compatible so that should not be the issue.
Here are my questions:

Could the problem be that I need to write some Arduino initialization code? Currently I am not writing any code and just trying to connect to the device to my phone.
Is it common that these modules will stop working over time? I have had this for several years and never used it.
Is there another common reason that this will not show up in the Bluetooth menu of an IPhone such as a security setting?

Have you tried to use Bluefruit Connect on the iPhone to see if it can detect your bluetooth module?


text:
Issues using mini microphone module off AliExpress
I have been trying to get a mini microphone module with an inbuilt microphone module I got from AliExpress to my Arduino to confirm if it is working. It was a four pin microphone with pins labeled V, L, and two G pins. The V represents voltage in and the L represents audio output positive.
Here is the link to the microphone:
https://www.aliexpress.com/item/1005004277353392.html?spm=a2g0o.productlist.main.23.61e36f2fBMHvFk&algo_pvid=15b05576-cd73-4eb7-a476-4503b8a706a7&algo_exp_id=15b05576-cd73-4eb7-a476-4503b8a706a7-11&pdp_npi=3%40dis%21USD%210.54%210.39%21%21%21%21%21%40211bf3f716869249882567444d07ba%2112000028601598840%21sea%21NG%214345576938&curPageLogUid=plaZEQWq7SRB
However, when I ran the code to check whether it works the value does not change that much, Is there something I'm doing wrong (I'm a beginner btw) or is the microphone not just working?
My code
const int audioPin = A0; // Analog input pin connected to the microphone module output

void setup() {
  Serial.begin(9600); // Initialize the Serial Monitor
}

void loop() {
  int audioValue = analogRead(audioPin); // Read the analog value from the microphone module

  Serial.println(audioValue); // Print the analog value to the Serial Monitor

  // Add a small delay to control the rate of readings
  delay(10);
}

I connected the output (L) to A0 and connected both the G pins to the arduino ground, I connected the V pin to the 3.3V pin on the Arduino Uno.

Does your Uno operate at 3.3V or 5V? If it's 5V, you can power the microphone module with 5V which may help. The images the seller provides do not show the bottom of the circuit board. Assuming there are no components on the other side of the board, the amplification provided by the components we can see will be limited. If you have access to an oscilloscope, you could verify the module is not defective.

What much exactly is "not much"? The module looks, like a raw microphone with a simple amplifier circuit, but without any further processing. Thus you would get directly the signal on your analog pin, which is an alternating voltage (probably around 0.5*V (aka 2.5V on 5V supply voltage), where you need to sample at least 2 times as often as the highest frequency, that you want to measure (nyquist frequency). Also this module will probably not provide enough gain to fill the full 5V range, that you have with the Uno.

The arduino operates by 5V btw, and when I say the value does not change much when I check my Serial Monitor, it gives a value of about 400 to 460 varying a lot and even when I speak to the microphone, it does not seems to go higher than that or change. I was thinking that it was noise. I am not so familiar with an oscilloscope, but when I connected it to the oscilloscope, it seemed to have a lot of noise, with repeating patterns even when I was not speaking to it and when I did speak to it, I could not tell if it was detecting it or not.

If you can't detect the sound on an oscilloscope, then the Arduino won't detect it either, so you would need to get a better microphone module. Also think about what you want to do with the sound module. The Uno is not really capable of audio processing (or at least very limited in it)

If you look carefully on the PCB, it has an AC-coupling capacitor on the L line which block the DC bias from the transistor, and you only get half of the signal. You need to connect the Arduino Analog input directly to the transistor output (i.e. to bypass the capacitor). You can measure the DC voltage at the output transistor, if it is at 1.5v without input signal, you will get +/- xxxmV swing against 1.5v that you can read with the Arduino analog input.

Have you checked to see if it is a hardware problem? It could be the fact that it is just off AliExpress. Usually, the display images are better than the actual product and if this is true, you can see a few bad soldering connections. I might want to go over some of them with a soldering iron.


text:
esp32 e-paper driver not working
I am trying to setup waveshare 7.5 display (Waveshare_7_5) with esp32 e-paper driver using ESP32-e-Paper-Weather-Display
My code is here https://pastebin.com/raw/2zQDe9a9, have corresponding owm_credentials.h, installed GxEPD2 & U8g2_for_Adafruit_GFX
Code gets uploaded to esp32 driver board using Arduino IDE, but Getting following in serial monitor & no display on e-paper
Busy Timeout!
Busy Timeout!
Busy Timeout!
Busy Timeout!
Entering 1675-secs of sleep time
Awake for : 44.518-secs
Starting deep-sleep period...

What is wrong here ?

your question is about interfacing the e-paper display ... why does your program contain code relating to weather and to wifi? ... reduce the code to minimum required to display something on the e-paper display

Maybe I have the same problem on a ESP32 NodeMCU with a waveshare 1.54 inch display. Did you solve the problem?


text:
publish json data to mqtt
I am trying to publish JSON data to mqtt with following code snippet
#include <Arduino_JSON.h>
JSONVar data;
data["temperature"] = temperature;
data["humidity"] = humidity;
data["pressure"] = pressure;
data["chipId"] = chipId;

String jsonString = JSON.stringify(data);
client.publish("esp32/data", jsonString);

But getting following error
/home/ubuntu/Arduino/libraries/PubSubClient/src/PubSubClient.h:144:12: note:   candidate expects 4 arguments, 2 provided
Multiple libraries were found for "PubSubClient.h"
 Used: /home/ubuntu/Arduino/libraries/PubSubClient
Multiple libraries were found for "Wire.h"
 Used: /home/ubuntu/.arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/Wire
Multiple libraries were found for "Adafruit_BME280.h"
 Used: /home/ubuntu/Arduino/libraries/Adafruit_BME280_Library
Multiple libraries were found for "Adafruit_Sensor.h"
 Used: /home/ubuntu/Arduino/libraries/Adafruit_Unified_Sensor
Multiple libraries were found for "SPI.h"
 Used: /home/ubuntu/.arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/SPI
Multiple libraries were found for "Arduino_JSON.h"
 Used: /home/ubuntu/Arduino/libraries/Arduino_JSON
Multiple libraries were found for "WiFi.h"
 Used: /home/ubuntu/.arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WiFi
 Not used: /opt/arduino-1.8.10/libraries/WiFi
exit status 1
no matching function for call to 'PubSubClient::publish(const char [11], String&)'

Whats is wrong here ?

What's your last error message?
no matching function for call to 'PubSubClient::publish(const char [11], String&)'

Read the documentation for the publish() method in PubSubClient:

int publish (topic, payload)
Publishes a string message to the specified topic.
Parameters
topic - the topic to publish to (const char[])
payload - the message to publish (const char[])

Look at the parameters you're using. You're passing a String as payload. publish() expects payload to be a char[] (essentially the same thing as a char*) - a C language string. This is the error you're seeing.
Read the documentation for String. How do you get a char* from a String? The c_str() method.
You need to change
client.publish("esp32/data", jsonString);

to
client.publish("esp32/data", jsonString.c_str());

As for your other warnings, it looks like your Arduino libraries are a mess with multiple conflicting libraries installed; if you want to get rid of the warnings, clean up your libraries.

is it possible to convert json to char* ?

@roy - I've given you the steps to do that in the answer. If you want to do it more directly, you're using the Arduino_JSON library. The declaration for the stringily() method is at https://github.com/arduino-libraries/Arduino_JSON/blob/master/src/JSON.h and it only shows a String as a return, so you cannot do it more directly using this library.

Arduino_JSON has this link https://github.com/arduino-libraries/Arduino_JSON, not much info here. Most of the example are based on ArduinoJSON.

My comment answered your question - I may have been editing it when you were replying. You can find the answer in the declaration of stringify() injson.h


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

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


text:
DS1820B only returns -127
ive used one DS1820B sensor in a AVR bread board circuit and it works there, now i tried attaching it to a arduino mega board with the code below and also another library below that.
currently the data pin is connected to pin 10 on the arduino board, but i also tried pin 2 as in this picture:
https://lastminuteengineers.com/wp-content/uploads/2018/12/Wiring-Multiple-DS18B20-Temperature-Sensors-With-Arduino.png
i changed: #define ONE_WIRE_BUS 10   accordingly.
So after that i put the chip back onto the bread board and it still works.
I also tried it with the 4.7k resistor on the data line as pullup....still -127.
Any ideas?
#include <SPI.h>
#include <SD.h>
/********************************************************************/
// First we include the libraries
#include <OneWire.h>
#include <DallasTemperature.h>
/********************************************************************/
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 10
/********************************************************************/
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
/********************************************************************/
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
/********************************************************************/

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

void loop() {

  Serial.print("Temperature is: ");
 Serial.print(sensors.getTempCByIndex(0)); // Why "byIndex"?
   // You can have more than one DS18B20 on the same bus.
   // 0 refers to the first IC on the wire
   delay(1000);

}

second code:
#include "DS18B20Events.h"

// Pin for DS18B20
#define ONE_WIRE_BUS 10

/********************************************************************/
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Init DallasTemperature
DallasTemperature dallasTemperature(&oneWire);

//Init thermometer with index 0 (default)
DS18B20Events thermometer(0);

// the setup function runs once when you press reset or power the board
void setup() {
  Serial.begin(9600);
  DS18B20Events::setup(&dallasTemperature); // Link DS18B20Events to DallasTemperature object
  DS18B20Events::setInterval(5000); // Set min interval in milliseconds between 2 measurements. Default 10000 set in setup() method.

  // subscribe to temperature changed event
  thermometer.onChange = temperatureChanged;
}

// the loop function runs over and over again until power down or reset
void loop() {
  thermometer.loop(); // Mandatory to measure temperature and fire an event if needed

  Serial.print(thermometer.getTempC()); // Get last measured tempC if needed.
  Serial.print(" measured ");
  Serial.print((millis() - thermometer.getMillis()) / 1000);
  Serial.println(" seconds ago.");

  delay(1000);
}

void temperatureChanged(uint8_t index, float tempC)
{
  Serial.print(tempC);
  Serial.print(" new tempC at index ");
  Serial.println(index);
}

Please post a photo of your wiring (including a clear view of the stripes on your pullup resistor).

You need a photo of your ACTUAL wiring to your Arduino, not the Fritzing diagram of what your wiring should look like.

Im not sure what it was, but its working now with the second code. the first one is probably right too. Maybe i was just to cool(-127C) a few hours ago...oh no. Theres probably a stackoverflow page for that too.

you probably forgot pull up resistor

I found this page because I was having a similar problem. I was trying to attach to an ESP01. I was unable to get it to read on GPIO3, GPIO1 or GPIO0 but I was able to get it to work with GPIO2. It seems it may be quite sensitive to the pullup resistance.

127 error is a connection error, check the wiring:


text:
Bluetooth module vs wireless module Arduino
My main question is, what is the main difference between HC-05 Bluetooth module and NRF24L0 wireless module?
Which should I buy?
Which makes these 2 modules different than each other?
Which one should I use in remote control arduino projects?
Which one is made for what purpose?

do you want to communicate between two arduinos or with a device which has bluetooth?

I m talking of Both of the cases @Juraj

what is the main difference between HC-05 Bluetooth module and NRF24L0 wireless module?

The main difference is the protocol they use. While some attempts have been made with varying success to get the nRF24L01+ to emulate Bluetooth it is not designed for that. You can only really get rudimentary beacon mode working and that only partially.
nRF24L01+ modules can only communicate with other nRF24L01+ modules. They use their own proprietary protocol that is incompatible with any other system. That's not to say they're bad - they're great modules, and the same RF core and protocol is used in many many other devices by Nordic that are used all over the place - the most notable of which is wireless keyboards and mice.
The HC-05 though is a Bluetooth module which is designed to talk to anything else that also talks Bluetooth - such as your phone or computer. It presents an "SSP" profile and gives "master" mode operation to emulate a serial port connection between your Arduino and any other device that knows about Bluetooth and SSP.
The biggest difference in how they work though is when it comes to connecting devices together. Bluetooth devices have to be "paired" before they will communicate. nRF24L01+ devices don't. This means that getting Bluetooth devices to talk to each other takes a certain amount of time and effort, but nRF24L01+ devices are ready to go the moment they are powered on. It's then just down to your software to set up addresses and such to target the communication.
For Arduino-to-Arduino communication the nRF24L01+ is far less trouble as you set everything simply in your code. There are "LNA+PA" variant boards available that include an amplifier and antenna for longer range communication (I have had 300m+ out of those quite happily).
If you want to communicate with anything else, like your phone or computer, then you will want Bluetooth. Otherwise you will have to add an nRF24L01+ to your computer or phone through USB and (probably) another Arduino, which just gets messy.

Very well explained, I choose HC05 then

NRF24L01+ module is a RF module and HC-05 is an Bluetooth module
It depends on the application you want to perform and what suits best for your application
nrf24l01+ is a great module but it can have issues if you want long distance communication also if you want to increase the distance then there is a module which comes with an antenna
On the other hand It seems that Hc-05 offers 10m range theoretically but according to one the arduino forum link its 15m when in line of sight but if there is some obstacle than it falls drastically
What is the distance you want to cover from the remote control it will specify which best suits you

Well u didn't mention what the max range is of the nrf24l01


text:
TPIC6B595 Output Unable to Allow Supplied Power to 7-segment Display
We have an Arduino Nano connected to 4 small (0.5") common-anode 7-segment displays and 2 large (3") common-anode 7-segment displays. We are trying to multiplex the displays. The larger one requires more power than the smaller one (9V) which the shift register cannot supply.
Therefore, we have supplied 9V to the open drain outputs of the shift register that are connected to the larger displays with a pull-up resistor (390ohm). However, more power (7.5V) goes to the resistor than the display (1.5V).
They are connected like in the ShiftDisplay library's schematic, with a pull-up resistor added according to this link on open drain.
How do we use the open drain outputs logic to supply power to the display?
The data sheet of the big 7-segment display can be found here. Each display requires 160mA of continuous current.

you should post a wiring diagram, your description is not sufficient. use the open drain outputs logic to supply power - you don't typically use pullup resistors to supply power to sth., maybe you confused that with urrent-limiting resistor?

You are getting confused. The pullup resistor is only needed on open drain when you are using it to generate logic levels. It turns the OD output into an RTL output.
You don't want that.
Instead you want your open drain outputs to act like a low-side switch transistor - which is infact what they are.
You can do that by simply placing your LEDs in series with your "pullup" resistor, thus:

simulate this circuit – Schematic created using CircuitLab
I have only shown two elements there (everything inside the dashed box is inside the shift register), but you can see now how when an output is "on" the transistor conducts, and the current flows through the LED, through the resistor, through the transistor, and down to ground.
Your resistor value is then calculated as simply
    9 - Vfled
R = ---------
      Iled

For 20mA and a 2V forward voltage that comes out as 350Ω - so your 390Ω resistors are perfectly fine.

Hi, I don't think this works for our specific 2-digit display (10 pin variant), your answer would require me to have one IC per display. Am trying to see how to use the open drain output on the anode side like in the miguelpynto GitHub.

It sounds like you have a multiplexed display. You don't want to use a shift register with one of those. You either need a multiplexing driver chip or to wire the display direct to the Arduino.

Can you use different resistors for each display group? If so that will solve your problem along with what Majenko said.


text:
Selection of module for person following shopping cart
I'm building a person following shopping cart with Arduino for my final year project. The cart is supposed to be able to follow its user while shopping use of Bluetooth module or wifi module will be feasible or not?or I should use IR sensors ?

It seems like this is a big/complicated project. Probably you need a multitude of modules (like WIFI or BlueTooth for the communication between the person and the cart, not sure what is best), an IR sensors to make sure the cart is not hitting something, and since safety is an issue (not bumping into people) you might need also probably one or more cameras, with vision intelligence, making an Arduino Uno not the best choice. But maybe I'm too pessimistic.

I agree with @MichelKeijzers ... perhaps the shopper could wear a vest with IR emitters ... each vest would transmit a unique code ..

@jsotola that could work, although much depends on the way the person with the vest walks (not too fast, not abrupt changes of direction/turning).

Bluetooth beacon. Use "bluetooth positioning arduino" as search terms.
Bluetooth beacon is a way to achieve the same as a GPS can do outdoor. By placing beacons around the room you can find your position in 3D space.
So a beacon locator on the shopping cart (Arduino with BLE module or a ESP32) and one on you (mobile phone) and then some central unit that can coordinate the two positions.
Just as a concept it would be feasible.


text:
OV2640 Camera example with Arduino
I searched for ov2640 with Arduino examples but only I could get the examples of Arducam. So I'm trying this example with OV2640 camera. As ov7670 and ov2640 have similar pinouts. But I'm not getting the image(output)(But I got the output while using OV7670 camera). I don't know why I'm not getting the output. Someone please let me know where do I go wrong(Reference image attached) and please let me know any other example you may know.
Thank you,
Roshan

There's no datasheet at the link you provided. From what I've been able to find out, the OV2640 works at 1.2V while it looks like you're supplying it with 1.8V. That might be a problem. Output I/O voltages might also be too low to be recognized by the Arduino.

As I seen in other project OV2640 camera with PIC microcontroller. They used to supply 1.8V. They used MIC550 IC to regulate(1.8V) the voltage. I used here lm317.                       https://www.circuitvalley.com/2019/06/opensource-diy-usb-webcam-ov7670-ov2640-pic32-USB-UVC-Video-device-class.html


text:
Parse char* mac-string to uint8_t array
I have to handle a String coming in over UART containing a bunch of information, part of it is a MAC-address that I get by using String.substring(a, b) returning a 12-char String representing a mac-address "B8C9A45BA770" <- (just an example).
I need the format of the mac-address to be a uint8_t array like so
{ 0xB8, 0xC9, 0xA4, 0x5B, 0xA7, 0x70 }.
So I need a function to convert a String to a uint8_t*. Sadly I have no clue how to convert this. There has so be an easy way right? its "C8" to 0xC8 and so forth...
Any ideas on this?

You can use sscanf

It would be easier to see you confusion if you actually showed some code.

Welcome to SE/Arduino! Please take the [tour] to learn how this site works, and read "[ask]". You are supposed to do a good part of research on your own. So please [edit] your question and add what your research revealed, and why it did not help you. Hint: a quick web search on "c++ convert string to integer" give a lot of good hits...

Personally I'd go with a basic implementation such as this one.
const uint8_t MAC_length = 6;
uint8_t* MAC_buffer[6];

uint8_t fromHexChar(char c)
{
    uint8_t result = 0
    if ((c >= '0') && (c <= '9'))
        result = c - '0';
    else if ((c >= 'A') && (c <= 'F'))
        result = 10 + c - 'A';
    else if ((c >= 'a') && (c <= 'f'))
        result = 10 + c - 'a';
    return result
}

uint8_t* toMAC(String s)
{
    for (uint8_t i = 0; i < MAC_length; i++)
    {
        MAC_buffer[i] = (fromHexChar(s.charAt(2*i)) << 4) | fromHexChar(s.charAt(2*i + 1));
    }
    return MAC_buffer;
}

Probably it can be optimized, but this is such a simple job and to be used so rarely that I think this is enough.
Important: I did not test this code, so there may be bugs inside.
If you need to start from an arbitrary point in the String instead of at the beginning, you simply have to modify it this way:
uint8_t* toMAC(String s, uint8_t startIdx)
...
        MAC_buffer[i] = fromHexChar(s.charAt(2*i + startIdx)) << 4 | fromHexChar(s.charAt(2*i + startIdx + 1));

Note for future me: I checked both on a simulator and in the code, and charAt is safe to use even when the index is outside the string boundaries (it simply returns 0).

Many thanks! Hopefully I can try it out within my code today, if not it's going to be next week :)

I have a question though: Why are you using globals in this case? Wouldn't it be better to have a pure function by removing the buffer from global scope and adding into the toMAC-function? That's what I changed anyways

@HaraldLesan: If you make MAC_buffer local to toMAC(), you have to make it static, otherwise you would be getting back a pointer to unallocated stack space, which you cannot dereference (it's undefined behavior). But then, toMAC() is not pure. If you really want it pure, make it return the array encapsulated inside a struct.

Thank you @EdgarBonet, as always your contributions are always a great addition :) never thought about encapsulating in structs, I'll have to dig a bit deeper

@HaraldLesan As Edgar said, putting it inside the function will remove it from memory when the function exits, so you won't be able to use it outside. If you really want to avoid that global, the solution I would use is to allocate it outside and pass it to the function: uint8_t* toMAC(String s, uint8_t *MAC_buffer, uint8_t MAC_length). But generally speaking I avoid dynamic memory on uC, so usually buffers are usually global in my code.

I might be nitpicking here, but charToHex should probably be called fromHexChar or similar. We're not converting anything to hex, we're converting from hex.

@tkausl honestly I had a similar thought when writing, then did not found any valid name (it is a char to an integer, but how to express that it needed to be in hex?). I did not think of naming it "from" something. I'm changing it :) thank you

@frarugi87: You can still allocate the buffer outside and pass it to the called function, without using heap. It merely has to have a lifetime longer than the called function. If the buffer is local to the calling function, a) it will still be invisible to other functions; b) will not use heap; and c) will be de-allocated when the calling function returns.

@JRobert Yes, the modification to allocate it outside and simply pass it to the function was what I wrote it in a comment above. Thank you for your comment :)

That was specifically to address "avoid dynamic memory".; that automatic memory is a another non-global option.


text:
Updating the firmware of Arduino Mega2560
I wanted to connect my Arduino board to MATLAB although it recognized the Arduino board, I kept receiving the error that said:
"Internal error: The initialization of the server code is incorrect."
I got the recommendation of updating my Arduino board's firmware;
So I connected my board to my pc and opened Arduino IDE; It said that the Arduino Mega or Mega 2560 on com6 is connected.
I even uploaded the blink example to my board to make sure that it was connected and fully functioning. Which it was.
But in the above bar in Arduino IDE, "Tools" menu, when I select the "WIFI101/ Firmware Updater" It says that no supported board connected.
What should I do now?
P.S:
I'm currently using Arduino IDE version 2.1.1 and MATLAB 2023a on Windows 11.
I'm sorry, I'm really new to this and would appreciate your help.

Do you have the WIFI101 shield on the Mega?  How are you wanting to use Wifi with the Mega?

I just want to update it's firmware
I don't know how...

The firmware you are trying to use is for the WiFi-101 shield.  It's not for an Arduino Mega.  The WiFi shield might go on a Mega, but this firmware does not.  Do you have that shield?  Or do you just have a Mega?

No I just have a Mega. As I have explained above, it gets detected in MATLAB but I can not fully connect it to MATLAB via its commands. So I got recommended to update my board. This is the link explained my MATLAB problem as well: https://www.mathworks.com/matlabcentral/answers/contributors/29688717-ava/questions/?s_tid=ans_lp_my_ques

OK, I think I understand your confusion from the other thread.  The WiFi101 Firware updater is for updating firmware on a WiFi101 shield.  It has nothing to do with the Arduino Mega.  In order to communicate with matlab you will need some code running on the Mega.  You need to find that sketch and load it on the board.  That will load like a normal sketch.  It will not involve anything that actually says the word "firmware".

Start here: https://www.mathworks.com/help/supportpkg/arduinoio/setup-and-configuration.html
Then here.  This shows how to upload the firmware to the arduino: https://www.mathworks.com/help/supportpkg/arduinoio/ug/configure-setup-for-arduino-hardware.html

https://www.mathworks.com/help/supportpkg/arduinoio/ug/configure-setup-for-arduino-hardware.html
This link has the instructions for connecting the Arduino board.  Look right at the first where it talks about the USB connection. Step 2 where you click program is the step where you are loading the server firmware onto the Mega.  That's the bit it sounds like you're missing.


text:
How to use Interrupt in Arduino to receive the data from Serial Input
Currently i have a project that forced me to make a program that receives several data from Serial Input using Interrupt in Arduino. I use Arduino as the receiver and ESP32 as the sender through Hardware Serial. The program i have written for Arduino is as posted at Serial Input Basics with a few changes as written below :
const byte numChars = 32;
char receivedChars[numChars];
char tempChars[numChars];        // temporary array for use when parsing

// variables to hold the parsed data
char messageFromPC[numChars] = {0};
unsigned long sendDataPrevMillis = 0;
int controlCondition = 0;
int droneCondition = 0;
int gasValue = 0;
int pitchValue = 0;
int rollValue = 0;
int yawValue = 0;

boolean newData = false;

void setup() {
  attachInterrupt(digitalPinToInterrupt(1), handleInterrupt, RISING);
  Serial.begin(57600);
}

void loop() {

  Serial.print("Control Condition :");
  Serial.print(controlCondition);
  Serial.print(" Drone Condition :");
  Serial.print(droneCondition);
  Serial.print(" Roll:");
  if(rollValue < 1500)Serial.print("<<<");
  else if(rollValue > 1500)Serial.print(">>>");
  else Serial.print("-+-");
  Serial.print(rollValue);
  Serial.print("  Pitch:");
  if(pitchValue > 1500)Serial.print("^^^");
  else if(pitchValue < 1500)Serial.print("vvv");
  else Serial.print("-+-");
  Serial.print(pitchValue);

  Serial.print("  Gas:");
  if(gasValue < 1500)Serial.print("vvv");
  else if(gasValue > 1500)Serial.print("^^^");
  else Serial.print("-+-");
  Serial.print(gasValue);

  Serial.print("  Yaw:");
  if(yawValue < 1500)Serial.print("<<<");
  else if(yawValue > 1500)Serial.print(">>>");
  else Serial.print("-+-");
  Serial.println(yawValue);
}

void handleInterrupt(){
    static boolean recvInProgress = false;
    static byte ndx = 0;
    char startMarker = '<';
    char endMarker = '>';
    char rc;

    while (Serial.available() && newData == false) {
        rc = Serial.read();

        if (recvInProgress == true) {
            if (rc != endMarker) {
                receivedChars[ndx] = rc;
                ndx++;
                if (ndx >= numChars) {
                    ndx = numChars - 1;
                }
            }
            else {
                receivedChars[ndx] = '\0'; // terminate the string
                recvInProgress = false;
                ndx = 0;
                newData = true;
            }
        }

        else if (rc == startMarker) {
            recvInProgress = true;
        }
    }
    if (newData == true) {

    strcpy(tempChars, receivedChars);
    char * strtokIndx; // this is used by strtok() as an index

    strtokIndx = strtok(tempChars, ",");
    controlCondition = atoi(strtokIndx);

    strtokIndx = strtok(NULL, ",");
    droneCondition = atoi(strtokIndx);

    strtokIndx = strtok(NULL, ",");
    gasValue = atoi(strtokIndx);

    strtokIndx = strtok(NULL, ",");
    pitchValue = atoi(strtokIndx);

    strtokIndx = strtok(NULL, ",");
    rollValue = atoi(strtokIndx);

    strtokIndx = strtok(NULL, ",");
    yawValue = atoi(strtokIndx);

    newData = false;
    }
}

The data will be sent from ESP32 to change the values of controlCondition, droneCondition, gasValue, pitchValue, rollValue, and yawValue.
I have tried it and the Interrupt cannot be triggered. The Interrupt should be triggered whenever the controlCondition, droneCondition, gasValue, pitchValue, rollValue, or yawValue change its value. Any idea what should I do? or is there something wrong with my code?
Note that the code that i showed in the void loop() is just an example code. The real code is more complex with so many calculations involved. The variables that I mentioned are the important variables for the calculations.

attachInterrupt(digitalPinToInterrupt(1), handleInterrupt, RISING) : which Arduino because pin 1 on say a Uno is not set up for edge triggered external interrupts.
The usual method for handling serial is in the loop() using Serial.available() to check if there is any data to process. Why are you attempting to do this in an interrupt service routine? Are you planning blocking code in the loop() or what?

https://stackoverflow.com/questions/53104440/how-can-i-implement-interrupt-for-serial-usart-communication-for-atmega328p-ardu#53105966

while (Serial.available()) ... if the arduino speed was scaled to human speed, then a serial character would arrive once a week

@jsotola I'm not sure what you are getting at, to be honest.

@NickGammon I don't either ... I was probably thinking that the ISR is waiting for multiple bytes

It should be nice having the possibility to get Serial Rx interrupt to call a function that listen Serial Port only when we receive data. The current method that consist to check in an infinite loop if data are available in the "software Rx Buffer" is not very  usable. In case, we have a feature that takes several seconds in the main loop, we could miss or delay an important message from the Serial port. HardwareSerial  library catches the Rx Interrupt but it also should allow to call a function we could override with our own code. We currently loose all the benefit of IRQ usage.

Why do you want to use an interrupt anyway? The serial hardware already generates an interrupt, and inside that ISR the incoming byte is placed into a buffer.
I presume you have a main loop where you are doing other stuff, and you want to react when some interesting serial data arrives.
I have an example of processing serial data without blocking on my page about serial processing which I reproduce below:
/*
Example of processing incoming serial data without blocking.

Author:   Nick Gammon
Date:     13 November 2011.
Modified: 31 August 2013.

Released for public use.
*/

// how much serial data we expect before a newline
const unsigned int MAX_INPUT = 50;

void setup ()
  {
  Serial.begin (115200);
  } // end of setup

// here to process incoming serial data after a terminator received
void process_data (const char * data)
  {
  // for now just display it
  // (but you could compare it to some value, convert to an integer, etc.)
  Serial.println (data);
  }  // end of process_data

void processIncomingByte (const byte inByte)
  {
  static char input_line [MAX_INPUT];
  static unsigned int input_pos = 0;

  switch (inByte)
    {

    case '\n':   // end of text
      input_line [input_pos] = 0;  // terminating null byte

      // terminator reached! process input_line here ...
      process_data (input_line);

      // reset buffer for next time
      input_pos = 0;
      break;

    case '\r':   // discard carriage return
      break;

    default:
      // keep adding if not full ... allow for terminating null byte
      if (input_pos < (MAX_INPUT - 1))
        input_line [input_pos++] = inByte;
      break;

    }  // end of switch

  } // end of processIncomingByte

void loop()
  {
  // if serial data available, process it
  while (Serial.available () > 0)
    processIncomingByte (Serial.read ());

  // do other stuff here like testing digital input (button presses) ...

  }  // end of loop

It looks to me like you are looking for an "end marker" which is when you want to react to what you have received earlier. Like in my example above, you could just pick up individual bytes in the main loop, and when the end marker arrives the whole line can be processed. I used a newline for and end marker, but you could change that to '>'.

The problems with an interrupt like you are doing are:

The interrupt will fire on the first bit (out of 10) and so there won't be any serial data yet, and your program will uselessly look for serial data which won't be there.

You are calling Serial.read() which won't return anything because while you are in your ISR the main serial ISR won't be able to fire.

Your ISR is doing too much.

Serial line is normally HIGH, and transitions to LOW (the start bit) when the byte starts, so you should be looking for FALLING and not RISING.

I strongly suggest you rework to just check for serial available in the main loop, as I have done, and process it when the end delimiter arrives.

Actually my project is building a Drone that can be controlled with an Android App, so the variables that I mentioned are very important for calculating the PID for the Drone. And the calculations are very large, so it can take a long time for the loop to read the values of the variables. I have tried the way that you showed before and it did not work. You can see my code here. Any idea?

Well, saying it "did not work" is not very helpful. Your code has many many serial prints in it. What are you seeing on the terminal? You seem to be calling showParsedData in the main loop. Wouldn't it be better to call it directly after parsing the data?

You left in the test for \n as the end of the data, but I thought you had ">" as the data delimiter. Is there also a newline?

Don't do anything in your loop() function except calling other functions, each of which decides - for one part of your process - whether or not it is time to do that part. If so, do that part; if not, return immediately to the loop function.
Read my answer to a similar question that talks more about how to do this. This technique is called non-blocking programming. Your code should poll rapidly for whatever it might need to respond to, but should not wait for any of those things to occur. If you do that, you will likely not need the kind of response that would require interrupts.
Also, the print statements in your loop() will slow down (block) execution and may keep your PID from responding adequately. If you need them for debugging your calculations, you can wrap them in #if DEBUG ... #endif statements so one #define DEBUG can easily include them them when you need to (knowing that your device control will be affected) and remove them for operational tests. If you must keep some print statements live, make only as few as necessary live at one time, make sure to use the highest baud-rate possible, and keep them as brief as possible.


text:
Make my Arduino (Mega or whatever is better for the task) to be able to read and write `Serial` data to a **rj45** port
I have a Chinese hybrid solar inverter that exposes an rj45 input which talks the serial protocol (Baud rate 2400, no parity, 8 bits, 1 stop bit). I need my Arduino (say, Mega or whatever, does not really matter) to talk to it. What would be the best option to connect an Arduino board to the rj45 input such that it would be available as Serial in the code?
Basically, I'd like the following piece to code to "just work":
    uint8_t query[] = {81, 80, 73, 71, 83, 183, 169, 13};
    Serial.write(query, sizeof(query)); // Write some bytes to a device, i.e. send a request.
    Serial.flush();

    while (!Serial.available()); // Wait for device to reply.
    String str = Serial.readString();
    // do someting with `str`...

In other words, I am looking for a hardware solution to connect my Arduino board to the rj45 input without introducing an unnecessary complication (if any).

the rj45 is irrelevant here because it is just an 8 pin connector ... the electronics behind the connector are the important part

@jsotola I know for sure it talks Serial with the params I specified. That is the only fact I know. I belive the protocol is r232 or something alike, I am far from being proficient in the hardware part of the things. Yet the bytes I am sending over the serial are correct.

You need to know the signal voltage level (Arduinos use 5V or 3.3V depending on model), whether control signals (DTR, DCD, DSR...) are used or needed (Arduinos do not use them), whether flow control is needed (Arduinos do not do flow control natively), and the pinout of the RJ45 connector. If all the stars align, it's just a matter of connecting the device's RX, TX, and GND to the appropriate Arduino pins. Otherwise you may need a level shifter.

@EdgarBonet I don't have necessary tools to get that data. Shall I hope it does align as expected and simply connect the named RX, TX and GND to a converter. The question is - how that conver is suppose to look like? I guess a would need a converter to be installed on the Arduino board AND I would also need a data cable that would carry the signal to the rj45 input. Where do I get these and how to choose them corretly? I don't really see another options except "give it a try" and pray.

You might consider having a few spare Arduinos, connecting them to the wrong voltage can fry them. There are interface ICs that to the translation from the micro to the serial cable. I am assuming that is a commercial inverter and it would surprise me if it were just a logic output.

Your best bet is most probably to get someone with a minimum of knowledge with serial communication and hardware to help you physically at your place. Or prepare for a steep learning curve, including purchasing some tools like an oscilloscope. You need to research the technical information for your inverter. Please [edit] your question to add all new information, at least brand and model of the inverter, optimally links to relevant documentation.

use a serial dongle on a computer to figure out the connections ... get one of these https://duckduckgo.com/?q=serial+dongle&iax=images&ia=images ... and maybe one of these https://duckduckgo.com/?q=serial+dongle&iax=images&ia=images ... cut length of lan cable end for the RJ45 connection ... make sure that the USB dongle can plug into the DB9 breakout ... buy one with female connector and the other with male connector

Look up the data sheet for the max232. It is an old chip that does what you need.  ARDUINOs serial work at 0 to 5v and the old fashioned standard for serial data works at +-12v.  Also, there will be a high low inversion.


text:
Can't upload sketches or flash Nodemcu 1.0 12E (CP2102) but have drivers and responds to RST on Serial monitor
I've been trying to get my nodemcu working for months and tried countless online references but none worked. I'm using the Arduino IDE to upload sketches and always get the error "Timed out waiting for packer header"
Here's my setup.
I'm trying to upload the example blink code for the nodemcu 1.0 12E.

My board does show up on device manager and here's proof.

When i press reset on the nodemcu and have the serial monitor on at 74880 baud the board spits out this.

I have tried pressing the reset and flash buttons while uploading
in the desired sequence but that didn't work.
I even went as far as reflashing the firmware through the nodemcu flasher but it's always stuck at waiting for MAC and STA address.
Please help me fix the problem and i'm sure not the only one facing this issue. Hoping for help :).

You must not have the serial monitor open while programming the board. The response from the board ends up going to the serial monitor instead of to the esptool.py process that's doing the programming.

no lol i never have the serial monitor open while i try to upload. i put the screen grab just to show the nodemcu can talk back .

Ok. Try selecting a different "Upload Speed" in the Tools menu.

um tried all , still nothing unfortunatley

did you try to put the mcu in bootloader mode manually? holding the flash button while resetting with the reset button?

yes i did and it doesn't fix the problem :( and even tried putting a 10uF capacitor between EN and ground.

did you solve it? what is printed in Serial Monitor at 74880 when you reset while holding the FLASH button?

Turns out it was a board problem. Switched it for an older version of the NodeMCU.
The newer ones are not known for the reliability it seems.


text:
I want to make mesh network with nodemcu (esp8266)
in this all the nodemcu are in both mode receiving and transmitting, if i made 6 nodemcu connected with each other as mesh network to control home appliances, using mac address.  suggest how i will start to reach the destination.

How will your nodes find / connect to each other? Basically, keep a table of which nodes connect directly to which other nodes, distribute updates to this table among all devices (for example when devices join, leave or links break) and use this table to find the shortest path to the destination node.

Can you provide some details (i.e. code) as to what you have done so far and what the problem is that you have encountered?

till now i only tested nodemcu range and communication from master to slave. but i wanted to extend more to communicate all the node mcu's with each other.

i got some ways to broadcast the data using MAC address of receivers. but the problem is how i connect all the nodemcu as STATION and AP mode at the same time. in mesh network in which all the nodemcu are communicating each other.

there are libraries for this already, i have used this one, but i have not tested the mesh function yet

im using painless mesh


text:
ESP-NOW with esp32 and esp8266
I want to use ESP-NOW with esp32 and esp8266. The esp32 will mostly send data to esp8266.I was not able to find any good tutorial on YouTube to achieve this. The only videos I found was for either communicating with esp32 to esp32 or esp8266 to esp8266. Is it possible to do this if yes how.

https://github.com/yoursunny/WifiEspNow

It is likely someone down voted you because you gave no indication you have tried something before asking your question.  Also, your question is perhaps a bit broader then you realize and would be easier to deal with on stackexchange sites such as this one if broken down into more specific inquires.  That said, I'm going to try and provide a GENERAL answer that will require you to follow up and read the links provided by @Majenko.

@majenko thanks

In general, ESP-NOW uses the WIFI radio in an ESP processor as a physical layer.  But uses it's own protocol which likely looks like garbage to a normal WIFI equipment.  So, it's like being in a meeting room with a bunch of people only knowing German and occasionally someone pipes up taking French.  As no one understands the French speaker, the French speaker is ignored.
Other things you need to know.  ESP-NOW is more like UDP.  There is not a higher layer looking out for you like in TCP.  Any number of reasons can cause your ESP-NOW "blurp" from being received.  For this reason ESP-NOW is better suited for periodically repeating information.  Like reporting the temperature.  Or for situations where the user can provide immediate feed back of success.  Such as a remote control.

The esp32 will mostly send data to esp8266

This infers reversing the direction of data flow over the ESP processor's WIFI radios.  While this may be possible it may not be a trivial task.

Is it possible to do this (communicate between an esp32 and esp8266) if yes how.

This shouldn't be problem.  This link provided by Majenko appears to be a good place to start.  Espressif them selves maintains this ESP-NOW web site.  Likely, after programming the ESP8266 and ESP32 using the correct libraries, they will be able to send data over an ESP-NOW link.


text:
ESP32 + Fastled + WS2801
I'm using the ESP32 DevkitC board with Fastlib and a WS2801 LED strip.
The LED strips works fine, i connected it properly (sometimes all LEDs are on, no flickering).
I Connected the light strip's Data cable (blue) to GPIO16 and Clock cable (red) to GPIO17.
Compiling works but at first shows this error:
"No hardware SPI pins defined.  All SPI access will default to bitbanged output"

When the script starts, only the first 3 LEDs are glowing in light blue (instead of blinking) - here's my code:
#include <FastLED.h>

// How many leds in your strip?
#define NUM_LEDS 42

// For led chips like Neopixels, which have a data line, ground, and power, you just
// need to define DATA_PIN.  For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
#define DATA_PIN 16
#define CLOCK_PIN 17

// Define the array of leds
CRGB leds[NUM_LEDS];

void setup() {
      // Uncomment/edit one of the following lines for your leds arrangement.
      // FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
      // FastLED.addLeds<APA104, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<UCS1903B, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<GW6205, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<GW6205_400, DATA_PIN, RGB>(leds, NUM_LEDS);

      // FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<SM16716, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<LPD8806, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<P9813, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<APA102, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<DOTSTAR, RGB>(leds, NUM_LEDS);

       FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<P9813, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<DOTSTAR, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
}

void loop() {
  // Turn the LED on, then pause
  leds[0] = CRGB::Red;
  FastLED.show();
  delay(500);
  // Now turn the LED off, then pause
  leds[0] = CRGB::Black;
  FastLED.show();
  delay(500);
}

Any ideas what's wrong?

This is hard to debug from afar...
Your sketch looks correct (hardly surprising, since it's just the Blink example). But I'd try to use IO18/SPI_CLK for clock and IO23/SPI_MOSI for data, as these are the hardware SPI pins of the ESP32. It might very well be that using these pins removes the warning about hardware SPI.
As I don't know all the variants of a WS2801 strip... is it maybe one of those strips that runs at 12V and can only be cut every three LEDs? This would explain why there are three LEDs lighting up instead of one (because then there would be one chip for three LEDs -- in other words, each "pixel" in your leds array corresponds to three physical LEDs)
Then there might be a problem with the voltage output of your ESP32 board. The ESP is running at Vcc=3.3V. The chips of the strip are running at Vcc=5V and expect 5V on their inputs. A logical 1 is assumed when the input in question is 0.7 * Vcc, i.e. the input signal may not be less than 3.3V. Now imagine that the power regulator on your ESP board drives the ESP at a teensy bit less (e.g. at 3.25V) and the power supply for the strip outputs a teensy bit more (e.g. 5.1V) -- suddenly, a logical 1 from the ESP is at 0.637 times the strips' Vcc and therefore in the undefined limbo between 0.3*Vcc (highest definition for logical 0) and 0.7*Vcc (lowest definition for logical 1). A level shifter module would help here to increase the ESP's output signal voltage (costs a few cents when ordered directly from China).
Then, at last, are you sure that the color order of the strip is RGB (as stated in your setup line)? I've seen more strips using GRB or BGR... which would explain why you see blue instead of red.


text:
ESPTOOL not recognizing ESP32-S2 chip for SPIFFs transfer
I have a spiff file that uploads fine using a regular esp32, but when I try on the esp32-32, with a fresh installation, I get:
esptool.py v3.0-dev
Serial port COM3
Connecting....
A fatal error occurred: This chip is ESP32-S2 not ESP32. Wrong --chip argument?
SPIFFS Upload failed!
Any ideas??
Thanks

you forgot to show the executed esptool command in question

Arduino does it for you, but I also tried: esptool.py -chip esp32s2 -port COM3 -baud 115200 write_flash -z ox110000 filename.spiffs.bin

maybe you have to specify the S2 for the spiffs tool

I tried, but no luck

Look at the espressif documentation here: https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-guides/build-system.html#selecting-idf-target and see if this provides a workable solution. MN

Actually we are at v3.1, cannot you upgrade to it? Maybe it's a bug..

Is the missing double dash?
esptool.py --chip esp32s2 --port COM3 --baud 115200 write_flash -z 0x110000 filename.spiffs.bin


text:
Connect output of Arduino DUE to input of Arduino Uno
I have a distance sensor connected to an Arduino DUE and I want to wire its output to an Arduino UNO.
In Arduino DUE, after calculating the distance, I convert a range of distances (0-10cm) to Volts (0-5V), then I map these to 0-255 values and I do AnalogWrite at the DAC pin.
In Arduino UNO, I AnalogRead from an analog pin (A0) which is connected with a jumpwire to the DAC pin of Arduino DUE. I was expecting to get values between 0 (when the distance is 0 cm) and 1023 (when the distance is 10 cm). But instead I get a weird and unstable range between 100 and 548.
The two Arduinos are connected with a jumpwire between grounds and a jumpwire between DAC and A0.
What am I doing wrong? I thought I had understood how to do this, but apparently not :)
Thank you for your help and time in advance!
Konstantina

why do you want to do this? Due is 3.3 V and Uno ADC reads 1023 at 5 V

I'm not too sure what you're end goal is but it sounds like your using this as a means of communication. If that's the case, use a level shifter and communicate via UART through the arduino. Here's a link for the level shifter https://www.adafruit.com/product/757

As said by @Juraj it is 3.3V, so it is normal to have a value from 0 to 550. Add a 1k resistor to ground if you want a better and stable output. Isn't there a better way to transmit the value? You will never be able to transmit the real value if you convert it to an analog signal.

Thank you very much guys! The reason I want to do this, is that the Arduino UNO is already part of a larger system that I cannot modify.  This Arduino UNO normally reads the analog signal from a potentiometer. I need to replace this potentiometer with a distance sensor. So I bought the ultrasonic HS sensor and I reasoned that I could do it through an Arduino DUE that does AnalogWrite to the Arduino UNO that does its AnalogRead. Do you think I could do it in a smarter way?   I am not super good with these so any help/suggestions are greatly appreciated!


text:
Run HEX program from SD with another program
I want to write a program in which I can select a HEX file recorded on a SD card (via a LED screen, etc.) and run it, i.e. transfer control to it, like launching programs on a PC. Is this possible and if so, how? I only found ways to directly run a sketch from an SD card without that "program"

this may work ... https://arduino-forth.com/

Bootloaders like Optiboot accept a program via UART and burn it into the flash of the MCU. That code is openly available: https://github.com/Optiboot/optiboot/blob/master/optiboot/bootloaders/optiboot/optiboot.c. With lots of effort, you too can write a bootloader which loads a compiled (or intel hex format) sketch from an SD card via SPI. The nearest project to that that aI could find is https://github.com/zevero/avr_boot which looks for a FIRMWARE.BIN on the SD card, programs the internal flash and runs it. You might want to modify that.. or, do it on another MCU with less restrictions

@MaximilianGerhardt, burn SD bootloader and then you use SD library to copy the selected file to firmware.bin and reset. the new firmware should have the same capability of selecting a firmware

@MaximilianGerhardt If you wish to answer the question, please post an answer.

The HEX files on SD card would have to be linked for a specific address in flash. Normal program is linked for address zero on ATmega, but the bootloaders are an example on how to link for specific address in flash.
Then you could use the do_sdm() function provided by Optiboot 8 (see the example) to write the bytes from the HEX file to the right location in flash memory. Next step would be to call the start address as function same way as do_spm() is made accessible with optiboot.h in the example.
typedef void (*loaded_function_t)();

const loaded_function_t loaded_function = (loaded_function_t)(ADDRESS_OF_LOADED_FUNCTION);

then you can use
  Serial.prinln("Execute the loaded code...);
  loaded_function();
  Serial.prinln("Loaded code finished.");

Sorry, but I don't understand how to link HEX files from SD card for a specific address in flash. How to do it?
I've not found do_sdm() function in Optiboot. What did you mean?

there is a link in the answer 1) see how bootloaders are compiled and linked for specific address

Not with an Uno, no, it's not possible. Or it's very very hard and the results would be less than desirable. You need a proper MCU with lots of RAM and the ability to run code from it, which you can't with an Uno.
It would be less work to write your own scripting language to control things from a text file.


text:
Communication b/w Arduinos, master(M) and slave(S) via Tx Rx pins. M sends query to S which shows the data in serialmonitor. S fails to send data to M
Slave code
int arr[10] = {0,1,2,11,4,5,6,7,8,9};
char id = '1';
char re[2];
void setup() {
// Begin the Serial at 9600 Baud
Serial.begin(9600);
}
int ia;
void loop() {
Serial.readBytes(re,2);// slave gets the query
ia = re[1] - '0';
if (re[0] == id){
Serial.println(arr[ia]);// slave print in serial monitor
}
delay(500);
}

Master Code
char mystr[2] = "13";
void setup() {
// Begin the Serial at 9600 Baud
Serial.begin(9600);
}

void loop() {
Serial.write(mystr,2); //sends query to slave
delay(3000);
}

check the result value of readBytes. before readBytes check available(). readBytes waits a second for a byte, the it returns count of bytes read. so it could be 0

Is Slave's Serial connected to Master or to SerialMonitor? Serial is not a bus.


text:
What is the advantage of a 3MP OV3660 sensor on the ESP32 M5Stack camera if it can only save upto 2MP images?
I am making a self-contained stills camera and the ESP32-based modules seem well-suited to my project due to the easy incorporation of a TFT viewfinder screen and TF card slot in one package. I am not interested in saving video or web streaming.
I have worked with the TTGO ESP32 camera that uses the OV2640 2MP sensor and can save full 2MP UXGA (1600x1200) resolution stills (albeit with mandatory JPEG compression turned on - I have only managed to get 1.3 MP images without compression).
I see now there is a version of ESP32 camera that uses the OV3660 3MP sensor (called 'M5Stack Timer Camera'). However, the specs for that camera https://docs.m5stack.com/#/en/unit/timercam say it can save upto a maximum of UXGA - i.e. 2MP images.
So what is the advantage of having a 3MP sensor chip if you can only save 2 MP images? Or is there a way of saving the full 3MP sensor resolution (i.e. 2048 x 1536) stills from this camera?
Thanks

I contacted the M5Stack people directly and they assured me that they made an error in their original web page specs and that the camera does indeed support full 3MP capture. So I bought one of these M5Stack Timer Cams and tested it. I can confirm that the device will save a 3 MP image at full QXGA resolution (2048 x 1536).
This option was not available on with the Win10 example app they provide but it was only possible with their official Arduino 'webcam' example. This is a web server WiFi example sketch and one of the options is QXGA and this does work.
So the definitive answer to my question (based on practical experience) is that the advantage of using the OV3660 is that it can provide 3MP pictures and the original specs provided by M5Stack were misleading hence the confusion expressed in my question.
It would also be interesting to hear if anyone has managed to get OV3660 working at full 3MP on other generic ESP32 boards. So far I have seen no other example published on the web.

The limit isn't the camera - it's the memory.
At 3 megapixels you have 3145728 pixels. At 3 bytes per pixel (8 bits each of red green and blue) it requires 9437184 bytes to store the image. That's more than can fit into the 8MB PSRAM.
1600x1200 will probably be one of the standard resolutions that the specific camera in use can capture, and is probably the biggest size that is below 8MB in size for a single frame.
So, what advantage of having a 3 megapixel camera? Well, none to you, other than the cost. It's probably cheaper to use a newer 3 megapixel camera than an older 2 megapixel camera.

It is perfectly possible to run at the resolutions you desire though. This resolution is known as QXGA and is supported by the OV3660 driver in the ESP32 Camera library.  There are some caveats though:

You must use JPEG compression. Not only is this to make the image small enough to fit into PSRAM but also to make it possible to write the whole frame into PSRAM fast enough that you don't miss bits of the data.
You will not be able to "do" anything with the image other than send it to somewhere else (such as an SD card or a web server). There just isn't enough room to uncompress the image.

Sure - but that assumes an uncompressed video stream at 3 bytes (24 bits) per pixel. These OmniVision sensors can output colour at 16 bits per pixel in YUYV format. So that would be uncompressed video at 6 Mb leaving 2MB for working stuff. Furthermore these OV sensors also have an inbuilt on-chip JPEG compression of the video stream before it hits the ESP32 - so the 8MB RAM should be sufficient at least for the more compressed streams. I'm guessing there must be some other reason the designers chose this 3MP chip. Possibly cost, as you say, or marketing - but I wonder if there is more to it.

@WildCat You know what you have to do to compressed images to do anything to them? You have to uncompress them. So compression is actually counterproductive, since you then have to accommodate both the compressed and uncompressed versions.

@Mejenko. Yes but you can just pump the compressed stream to TFcard without uncompressing it in RAM and you can use a low res version for viewfinder video - that is how the OV2640 in the TTGO ESP32 camera works. I can save compressed 2MP images but if I lower or switch off compression the PSRAM is insufficient. In theory they could make it work. I wonder if anyone has - and can tell us how.

@WildCat You also have to consider speed as well - writing to PSRAM is not fast, and you have to be able to write a whole frame to the PSRAM fast enough to capture it. Espressif recommend JPEG for anything larger than CIF and converting it afterwards.

QXGA is supported by the ESP-IDF so there's no reason why you couldn't do it. Just follow one of the examples and change the framesize to FRAMESIZE_QXGA

@Mejenko. Thanks for this answer. I have seen this option in the libraries but the fact that it exists does not mean necessarily that a particular hardware module can do it. I asked the question because the M5Stack manufacturer says the output resolution of the M5Stack Timer Camera is limited to 2MP. I need to know about this module in particular. Perhaps if I hook up an OV3660 sensor to a generic ESP32 board it might work but I need to know which to buy - so specifics are important. Have you actually tried with the M5Stack Timer Cam and it works?

@WildCat The M5Stack Timer Camera is just a generic ESP32 with an OV3660. There's nothing special about it. It may well be that they changed the camera module between versions and never updated that part of the website.

Your answers are reasonable in theory but practice can be different due to gaps in detailed knowledge. According to my searches a few people tried (and failed) to get OV3660 working e.g. [me-no-dev][https://github.com/espressif/esp32-camera/blob/master/sensors/ov3660.c] and some think it might be impossible [bkeevil][https://github.com/bkeevil/esp32-cam]. I have yet to see a 3MP image, from anyone, taken with an OV3660 and ESP32 - hence my question. But it may be that the folks at M5Stack have cracked this nut and missed a trick in marketing. I will do some more digging.

The m5stack timer camera X (OV3660) lacks support.
There is nothing on how to flash and use micropython in this device.
There is a cameratool you can download and take snapshots via serial port, there is the standard arduino software you can flash and that's it.
I miss some guides on how to flash micropython on it and make it work with mqtt and more complex setups. I'm not an arduino person, just want to code some python on it.
I bought 2 of those cameras and those are sitting in a shelf for 6 months with 0 use. One day when someone publish a full micropython firmware for that camera, i'll give it a try.
PS: I've tried to compile a micropython firmware with OV3660 support, but no luck on make it work.


text:
voltage regulator
This may not be the best pace to ask this but I have to use a 3.3v regulator with this esp12
. For that I have selected this regulator 3,3v regulator and in the discribtion it is saying to use two capacitors . so are the capacitors compulsory or not and what will happen if i dont use the capacitor

Yes, they are compulsory. They are to prevent oscillation of the regulator and to provide rapid delivery of current over short periods while the regulator adjusts to changing demands.

u guys are a company right and the account is not managed by an individual right.

I am an an individual and a company. What does that matter anyway?

just asking i checked ur profile and clicked on the links and found that u have a well maintained web site.

Not as well as it could be. I'm in the process of a complete re-write using Laravel and Vue.JS.

is the chip kit lenny made by you its a good and powerful board .

Yes, that's my design. Glad you like it.

Majenko is one of the top contributors to this message board. He knows of what he speaks. (And yes, a regulator chip is only part of a regulator circuit. You need capacitors to create the finished voltage regulator.)