text:
4 Pelteir Plate Water Bottle wired to Arduino Uno
Note - I plan to use the Arduino Starter kit to make this project.
Hey everyone,
I've had an idea for a project recently and I would like to get some insight on its plausibility. Is it possible to heat and cool a bottle of water using 4 pelteir plates? I'd like to heat up or cool a bottle of water using 2 pelteirs for heating and 2 for cooling. Could the amount of power for the peltiers to function be supplied from a laptop, computer, or battery pack? The role of the Arduino is to program in some safety features or some things to help the circuit function better if necessary. For example, a feature I want to add in is if the cold pelteirs are on, the hot peltiers are off if nessecary. I might add an LCD to display which setting is on/off if I can (example: Cold: ON, Hot: OFF)
Thanks guys.

your question is not about arduino ... it is about supplying power to a peltier cell, so it is off topic here

From the positions of Arduino beginner it is unlikely for a beginner to be fully aware of where arduino ends. As this is a forum is targeting area for beginners and many people start with idea of switches, currents (rather then watts) with arduino, you cant expect standard of question on a leave of main stack-exchange...

You need a second power source, different than the laptop (USB provides up to 500mA in standard config, not enough for serious cooling)

There are no "heating" or "cooling" peltier elements. If you change the polarity of the power source, the hot and cold side changes too. The peltier element pumps the warmth from one side to the other. The temperature difference can not be more than 70 K. If one side gets cold the other gets hot and vice versa. Did you think of that, when you designed the water bottle. Also, peltiers are not very effective. You waste a lot of energy. So, I think too, you need a better power supply then a usb port ;-).

Yeah, I understand that, didn't word very well in my post. Thanks!

In a word, no. Laptop or desktop computer usually have USB ports, which put out like 10 watts of power for a "high current" USB port. That is not enough to do much heating or cooling. You want a high power supply. The pelteir plates I've seen run on 12V DC. Get a 5A 12V supply, or even higher.
You might be able to draw larger amounts of current from a USB-C port or a USB-C power supply, but why? Get a dedicated high current power supply that puts out the maximum voltage your peltier plates can handle.
Note that there is no reason to have 2 plates for heating and 2 plates for cooling. Run the current one way and they heat. Reverse the current and they cool.
Also I'm not sure of the value of using 2 plates to cool. A single plate able to handle more power would likely be more efficient, and easier to insulate. (With 2 plates you'd need 2 heatsinks, which will allow twice as much heat to leak through when the power is off. Doubling the current you feed into a single plate should give double he heating/cooling, without increasing the heat leakage when it's off. Just make sure you don't exceed the maximum rated current of your plate, and that you have a large enough heatsink to handle the heat transfer.)
You could use an H-bridge meant for controlling motors to provide either +12V or -12V under software control. Those generally handle high current.
You could also use a digital thermometer and make a thermostatically controlled system. You'd measure the temp in the bottle, and when it got to your desired temp range, turn off the power. When the temp moved outside the desired range, you'd turn the power back on.

Thanks for the suggestions. I'm currently looking into some battery packs I can use for this. Again, Thanks!

You need a battery pack that provides the voltage your peltier plates need, and then look at the total capacity of the battery, in amp-hours. For example, if the peltier plate draws 2 amps, and the battery is rated for 2 amp-hours, the battery will run it for 1 hour.

Heating and cooling uses a great deal of power, and anything but a large heavy battery like a lead-acid car battery is going to be depleted quite quickly.

When it comes for amount of power from laptop, then this is not realy reasonable to expect even USB3, maybe some older laptops PCMCIA, or hardware docks. When it comes to Desk, They would have to be adjusted to get the ATX from PSU (it would have to be upgraded for purpose) We are still talking about a small Can or Yacult botle...
Even then insulate, insulate (and same again)
Then its a question of speed and how hot or cold) Battery pack that charges even when not used, used as buffer might work (for a short time).Controlling it from Arduino is easy part using function that switches one on other off whenever you want and then calling the function itself to make sure both steps happen, rather then manualy editing or using one output for controlling power on/off and another on two way relay switching between sets (relay would increase consumption here).

Noted- thanks for your insight on this.


text:
Memory for inputs?
When a button is pressed, the Arduino might be busy with something (like drawing the screen). When the Arduino has finally time to check the button input, the uses might have release it already.
Is there a way that can store the input until the Arduino has time to check it?
It would be awesome if there was ic that could take care of this.
Thanks for the help!

It's called an interrupt.

I most cases, this isn't an issue. Humans are kind of slow, compared to an Arduino running at 16Mhz. Pressing a button takes tens to hundreds of milliseconds. An eternity for a CPU. Alternatively, you could add an RC circuit to the button. This has the added benefit of also debouncing the button signal.

Just a SWAG but it sounds like you are using the delay(); function, that is blocking the arduino not allowing it to do anything else until finished. Work with the millis(); function, you code will be non blocking.

The answer to your direct question, is there an IC to store an input, is yes. It's called a Set-Reset (or SR) Flip-Flop. I don't know if they're packaged standalone in an IC but they're really simple to make with a pair of cross-connected NAND gates.
But that's not really the right solution to your problem. Your code should not be so "busy" that it misses a slow input like a push-button. I quoted "busy" because it is usually delay() calls, not computations, that occupy the processor for any large amounts of time, and delay()s are to be avoided if your code has any more than 1 thing to do.
Look up the Blink Without Delay example-sketch in the Arduino IDE for the unvarnished, basic approach to doing this. Then there are libraries that can help with the low-level details of doing it - SimpleTimer, is one such. Or, if your code is stuck waiting for slow external events, don't wait for them but check for them frequently and move on immediately to something else, if they haven't taken place yet.

Is there a way that can store the input until the Arduino has time to check it?

No, there is no way to remember/buffer input changes within the Arduino (You could use a flipfop IC like JRobert wrote. That can give you that functionality). But there are interrupts, that you can use with pins. A triggered interrupt will really interrupt the main code from running and execute its corresponding ISR (Interrupt Service Routine), to handle the interrupt cause, and then returning to execute the main code. A microcontoller has many different interrupts, each one connected to its special hardware. There are interrupts for the Serial interface, for SPI, I2C, and also some connected to the External Interrupt pins or the PinChange Interrupt (these last two could be used with your button). So this would not "store" the input change, but it will interrupt the main code to immediately act upon the input change. So that's a different principle.
If you want to bind your button to an interrupt, you could just stay in the Arduino Framework and use the attachInterrupt() function. There are many tutorials online for that. Keep in mind, that you should never do long things inside an ISR, and functions like delay() won't work there.

That said, most likely it is not really needed to use interrupts with buttons. Humans are rather slow, thus each button press will last in the ballpark of 100ms or longer.
You could now say, that your code is doing things longer than 100ms. But here the rabbit is buried (literal translation of a german saying, meaning "there is the problem"). When starting with Arduino, one is doing many blocking things, like delay() or blocking while loops. These are often very easy to implement, but nothing else will be running during these things.
Instead you should divide up your actions into small parts. When it is time to do something, you are doing that small part and exit fast. This enables other code to run in between. A good example is the BlinkWithoutDelay example. The normal blink example uses delay(), which blocks everything else. Instead you can use the millis() function as a clock and only take action, when it is time to do so, otherwise to further fast. Much like you would bake a pizza in your oven. You won't sit in front of the oven, waiting for the pizza to be ready. You would do something else and regularly look at your clock, if it is time to take the pizza out.
You didn't show your code, so we cannot advice you more in that direction. But you can find many tutorials about it, if you search for terms like Arduino blink without delay or Arduino millis tutorial.

The basic guidance when writing Arduino applications is to do a small amount of work on every pass through the loop function, then do a little bit more on the next pass. Check all your inputs, execute logic in response to those inputs, set up unsigned long variables with future millis() values, check those values to see if a future time has arrived, and repeat.
Do not use delay(). It is the death of a cooperative system like an Arduino. When your Arduino executes a call to delay(), everything stops until the delay time has passed.

source: Stack Exchange

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

sort: votes


text:
What is the pinout of the Arduino MKR motor carrier when using external power supply, not the Li-Po battery
I see there is a blue terminal connector an the tags below the PCB Vin, 5V, 3,3V and GND, but I am unsure where should I supply voltage to power up the board.
Also, in the product page it says the power can range from 6.5 to 11v, so what is those 5V and 3.3V all about?
Thanks

Vin means "Voltage Input". That's where you provide your power. That is the input to the voltage regulator.
5V and 3.3V are what the board uses internally and are provided for you to also use should you want to. These are outputs from the voltage regulators.
It's exactly the same (though more efficient and higher current) as almost every other Arduino.

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


text:
RF sniffer with Arduino
Hello programmers out in the world.
I am doing a capstone project for an RF sniffer to capture RF signals from Key fobs within an OEM manufacturing plant. I want to be able to decode this RF signal to show me what the battery state of the key fob is. I have the protocol, so I know what data I should be receiving. However, I have tried many libraries on the Arduino UNO and none have worked.
This Key fob specs are FSK modulation. Frequency of 433 Mhz, Bit rate -> 9.6Kbit/s, baud rate of 19.2Kbaud/s and coding is manchester.
Any help would be greatly appreciated.

Which libraries have you tried how? Please include one or two simple code examples, that you tried, with the most promising libraries. And are you sure, that you have a fitting receiver module? The datasheet doesn't say 433MHz, but 433.92MHz. Your module might not be tuned to that frequency (433MHz is more a complete band instead of a singe frequency).

I actaully found this this week that I was suing ASK RF receiver module, when I needed FSK.
I have used RC Switch, and no luck, along with Radio head.
However as mentioned the key fob will not work with ASK. I am trying to find a library for FSK but no luck as of now.
-Pete


text:
This website in Arduino lists language references like functions and structures. What makes structures there different from functions?
https://www.arduino.cc/reference/en/
Language Reference
Arduino programming language can be divided in three main parts: functions, values (variables and constants), and structure.
functions
For controlling the Arduino board and performing computations.
variables
Arduino data types and constants.
structure
The elements of Arduino (C++) code.
I find it really confusing that they had to separate the structures but also call them functions in their descriptions. I kind of want to get a visualization or organization of the different language references present in Arduino, but this just confuses me. Are structures in the website also functions, and mainly syntax can be classified into functions and variables? Can someone present a organization of language references that doesn't involve terminologies being mixed up?

please provide an example of what confuses you

perhaps it may clear your thoughts if you review C++ programming

They're playing loose with terms.  If you want a clearer understanding of C++ the C++ standard itself is a better reference.

What the website names "Structures" are code building-blocks for the programs you write. The main part there are conditional (if-else) and loop instructions (for, while) as well as mathematical operators. You use these constructs within your functions to control program flow or compute results. Functions, on the other hand, are sub-programs you can call to have certain tasks done. They might be pre-defined (such as the ones described on the language reference page) or written by yourself.
Now there are two exceptions to this rule, and maybe that's what's a bit confusing in the documentation: The functions setup() and loop(). These are functions, but make up the structure of your program. They are the main building blocks of an Arduino sketch, and that's probably why they're mentioned under "Structures".

Yes, this is the kind of explanation I am looking for. Someone who has a clear visual of their own with how the hierarchy of how the types of code are. It makes it really clear that under programs, we can put functions and under that we can put structures. Yes, the set up and loop is confusing but I would prefer categorizing it as functions because you can put structures inside.
I'd like to ask, what references do you use for Arduino? You seem to have a good personal grasp on terminologies.

Actually, I use exactly that page for things that are arduino-specific, and any other resources I find for any C++ issues I come across. The Arduino compiler is a full-featured C++ compiler, with almost all the features the normal GCC also has. The library functions are also all there, so if you need help for things like malloc or free just use your preferred search engine. (One exception here: STL support is not available out-of-the-box).


text:
I have three pushbuttons where only one can be pushed at a time and want to set a variable for this. How?
Basically I have three push buttons that correspond to pins 1 to 3 and want to set an efficient code that sets a certain variable into the index whose digitalRead is equal to one. Let us assume that only one button can be pressed at a time.
void loop()
    {
    if(digitalRead(1) == 1)
        {
        Variable = 1;
        }
    if(digitalRead(2) == 1)
        {
        Variable = 2;
        }
    if(digitalRead(3) == 1)
        {
        Variable = 3;
        }
    }

Is there are more efficient way to do this, like for example using other loops?
I can't wrap around my head with doing this concept using the other loops such as for, do while, while and switch because the nature of the idea feels so unconventional for their uses.

"Efficient" is very subjective. Using a for loop will decrease code size, but increase execution time. Using discrete ifs like that will increase code size but decrease execution time.

What exactly is the role of the Variable in your code? Can the values be arbitrary, or are they pin numbers, or are they indices of the pressed buttons? You could use a for loop to go other an array of pins and assign the variable with the element of a second array. I'm not sure, what the actual goal is here, so it is difficult to suggest a good way.

And how is this question different from your previous one?

Okay it was pretty much the same, this one can be closed since you gave a good answer to the original question.

If you can only have one button pushed at a time, you can only end up with at most one of the if statements evaluate to true. In your code, you check button 2 and 3, even if button 1 is pressed. Your code can be a bit faster if you do this:
if(digitalRead(1) == 1)
{
  Variable = 1;
}
else if(digitalRead(2) == 1)
{
  Variable = 2;
}
else if(digitalRead(3) == 1)
{
  Variable = 3;
}


text:
What terminologies and concepts describe the codes that follow a format of Text1.Text2()?
I'm just really curious because some codes really follow a format like this. Examples include serial.begin(), serial.println() and when I used servomotors the left part was the name of the servomotor, which I declared. I want to know what concept does the code with a format of Text1.Text2() refer to? What do you call Text1 and Text2? Are there official or commonly used terminologies for the concepts and parts such as "variable", "statement", "code"?
To add to my understanding, it appears that Text1 refers to an object and that Text2 has the concept of "function" where it performs something related to the object. Though I would think that another terminology would be possessed by Text2 other than function to distinguish it from a function since it is required to be written in the format I mentioned, which next to the object with a period separating them and no spaces at all.

the names differ amongst different programming  languages ... your question has nothing to do with the Arduino, so it is off topic here .... look at details about a programming language of interest ... see what the names are

https://www.w3schools.com/cpp/cpp_classes.asp

@jsotola: It's not mainly the names that differ, but their semantic meaning. What Text1.Text2() could mean differs greatly by language, even if this may be a syntactically valid statement in many languages.

Text1 is an instance of some class xxx; xxx::Text2() is it's method function.

As @KIIV wrote, the overall concept is the class concept. A class is the build description of an object with its own member functions and member variables. From a class you can declare instances as variables in your code. Thats, what Text1 is here: An instance of a class. Text2() in turn is a member function of that class, which can act upon the variables of that particular instance. You can google tutorials about C++ classes to find out more. Note, that in C/C++ classes and structs are very similar. So you use a similar syntax to refer to member variables of a struct instance.

Class and method are probably the answers I need. Thanks! It's just so hard to search with Google if you don't have the correct keywords to obtain what idea you want clarified.

'Text1' is usually an object. Object is an instance of a class. https://en.wikipedia.org/wiki/Object-oriented_programming#Objects_and_classesg

The over-arching concept is Object Oriented Programming (OOP).
The terms I was taught at University - taking Serial.println() as an example:

Serial is an instance of a class (in this case HardwareSerial), sometimes called an object.
println() (a function in a class) is a method of a class.
A "variable" in a class is called a property of a class.

A commented code example:

class Foo { // This is the *class*

    public: // These symbols are accessible from outside the class

        int bar; // This is a public property

        void baz() { // This is a public method
        }

    private: // These symbols are only available from inside the class

       int meep; // This is a private property

       void moop() { // this is a private method
       }
};

Foo bar; // Instantiate an instance of the Foo class and call it bar.


text:
In multidimensional arrays, can you use variable arrays or their names instead of the actual data?
Referring to this thread
How to declare and use "Variabled arrays" inside arrays
Example
byte array[2][4] = { {1,2,3,4}, {5,6,7,8} };
Serial.println(array[0][2]); is equal to '3'.

Instead of using {1, 2, 3, 4} and {5, 6, 7, 8} I want to be able to declare separate arrays for each of them and just put the name.
Another big issue is putting arrays of different sizes for each entry and it would be wrong to do so. Is this really not possible? Do I have to use some other concept instead if I want to have an array that contains entries of arrays that have different sizes? I heard about pointers but not familiar with that.
Example,
byte arrayX[3] = {1, 2, 3}
byte arrayY[4] = {5, 6, 7, 8}

byte array[2][4] = { arrayX , arrayY };

Take note that the code was not taken from the link I mentioned, I just used the same array names. Also I changed arrayX from the link to 3 entries because I want to emphasize the part of my question if it is possible if arrays have different sizes and you would just use the biggest size?
Now I think this is wrong and I haven't tested it currently but I want to ask if there is a solution that makes use of what I have mentioned? The site I linked to gave a solution which feels very redundant in terms of declaration and I would not want that. This is the solution mentioned there.
byte arrayZ[2][4] = {
  {arrayX[0],arrayX[1],arrayX[2],arrayX[3]},
  {arrayY[0],arrayY[1],arrayY[2],arrayY[3]}
};

The issue I had when searching the internet is the same as the link. "Surfed on the internet to find a bunch of examples but the only difference is that they don't use arrays that have been declared to have a name inside array."

Here is everything you ever wanted to know about the relationship between arrays and pointers (and yet more). Note that it is about C, and C++ has some extra features alluded by the busybee in his answer.

Two-dimensional arrays come in two "flavours". Actually, multi-dimensional arrays are possible in any combination of these.

All elements in a rectangular grid, at least from the abstract view of the programming language;
A one-dimensional array of one-dimensional arrays.

If you declare:
byte array[n][m];

then you have reserved space for "n times m" bytes. From the programmer's view it is a rectangular grid, actually all bytes are in sequence in a one-dimensional array. This is because the memory of our computers are commonly organized as a big one-dimensional array of bytes. The compiler generates the correct calculation for the offset into this array, multiplying one index with the size of the width (or length, depending on your mental model) and adding the other index.
You can initialize such an array with the nested set of curly braces like this:
byte array[n][m] = {
    { /* ... */ },
    /* ... */
};

But you cannot initialize it as you show.
Otherwise, if you declare
byte* array[n];

then you have reseved space for "n" pointers to bytes, that is a one-dimensional array of pointers. Each of these pointers can point to a different or the same one-dimensional array of bytes, or to no array at all if it's nullptr.
Now you can set up the array as you like:
byte arrayX[m1] = { /* ... */ };
byte arrayY[m2] = { /* ... */ };

byte* array[n] = { arrayX, arrayY, /* ... */ };

The arrays arrayX and arrayY (and any further) don't need to have the same length. Each can have its own length. But beware, you need to trace the length somehow to avoid out-of-bounds accesses. And of course, you need to check or be sure that a pointer is not null before dereferencing it.
In both cases you can access a single element with:
byte element = array[i][j];
array[k][l] = 23;

This is because the syntax with the brackets is equivalent to the dereferencing operator:
x[y] == *(x + y)

Note 1: Since Arduinos are programmed in C++, there is another option. You can use references instead of pointers. Because it is really hard to create a null reference, some see it as a safety measure against null pointers.
Note 2: Again, since Arduinos are programmed in C++, you can implement an own class that provides the operator[]. With this option you can do any magical stuff, but it might break the user's expectation. Be careful if you go that route.


text:
How can I use GPIO pins on an esp12e UART?
I've bought an esp12e UART that unfortunately had some issues, but I was able to fix them.

This is how I connected it to the arduino. With this setup, I was able to host a simple web server and it worked, the code uploaded and everything worked fine as it should. However, then I tried to make it light the led up by declaring it as on pin 13, but it didn't work, so I don't really know how should I declare my pins for the code to work as it should. By the way, the board is selected as nodemcu 1.0 (esp-12e module) in the arduino IDE if that helps. Thank you in advance

please remove the esp12e UART and try again ... the arduino uno probably already has an LED on pin 13

the shields headers are Uno headers, not esp8266 headers

@jsotola I can't remove the esp12e UART, I want to use it with the arduino.

@Juraj I understand, so how can I use the Uno headers when programming the esp8266?

it is a WiFi shield. put a firmware into esp8266 and use in Uno a WiFi library for that firmware

@Juraj thanks for the help, I've tried that way, but it didn't work, i guess i gotta try more methods for it to make it work if it's the only way.

you can write two sketch and code the communication but working with WiFi library is simpler.  https://github.com/jandrassy/WiFiEspAT/blob/master/README.md


text:
Detect if a display is connected
I want to detect wether a display is connected or not.
This is the display: https://www.az-delivery.de/en/products/1-77-zoll-spi-tft-display
I read connecting a pin of the display with another pin with a pull up resistors. Unfortunetely nothing worked so far.
My microcontroller board is Arduino Mega.

What methods with which code have you tried? How have you troubleshot them?

Best thing is send a schematic, not a frizzy thing. What pin is connected to what pin is important, and only one setup is correct. Might as well post the code as well.

if the board is plugged in, then pin 1 and pin 14 are connected together

There is nothing immediately apparent on that display that can tell you if it's connected or not. If you had a full SPI interface (you are missing the MISO pin) you could query the display for the HWID, but alas not. And there's no pins at all that are outputs.
The only suggestion I can come up with is to connect a small (say 1Ω) resistor between the Arduino's 5V pin and the display's VCC / LEDA pins and use an analogue input to measure the voltage on the display side of it. When the display is disconnected it will give a 5V reading. When it's connected the reading will drop to a slightly lower voltage (depending on the current draw).
Schematic:

simulate this circuit – Schematic created using CircuitLab

As jsotola mentioned in his comment, pin 1 and pin 14 on the display are connected to each other (GND). You can connect pin 14 to an input pin with enabled INPUT_PULLUP. If no display is connected, this pin will be pulled high by the pullup, thus the pin will read high. If the display is connected, the pin will read low.


text:
What is the highest baud rate that can work between Android device and an Arduino connected to an HC05?
I see a lot of baud rates in the AT Command documentation for the HC05 however I am not sure what is the fastest that can work between the Arduino controlled embedded system and the Android phone. I also do not know of a way to change the baud rate of the Bluetooth communication in software. I am writing the application in Java with Android Studio IDE.
I read the documentation for HC05 and realize that it only operates with one Bluetooth profile. i.e the Serial Port Profile. The documentation says that this profile offers a maximum data-rate of 128000 bits/sec. However, the HC05 has a max baud rate option of 1382400 bits/sec. Why would this option be there if it is not possible to use? Can you please explain what I am missing and point me into the direction of some useful information? Thank you.

The HC-05 may only have implemented baud rates up to 1382400, even though the protocol is spec'd for up to 128000.
If you're using Software Serial to talk to the HC-05 from an Uno, 9600 baud is about as fast as SoftwareSerial can keep up with incoming bytes (I've heard from some people that 19200 will work).
If you're using one of the UARTs on a Mega, you may be able to use the full rate implemented by the HC-05. An experiment would be in order...
Update:

I did an experiment and found out that the maximum baud rate
achievable between the HC05 (communicated with by SoftwareSerial on
Arduino Nano) and the Android device is 115200.

I would guess you were transmitting from the Arduino? I've been able to transmit that fast with SoftwareSerial but its receiving ability is more limited. (This has enabled me to, f/ex, set an HC-05 or an ESP8266 to a slower baud-rate than it shipped with, by blindly transmitting an appropriate 'AT' command at the higher speed, then testing it at my intended speed to see if the command worked).

I did an experiment and found out that the maximum baud rate achievable between the HC05 (communicated with by SoftwareSerial on Arduino Nano) and the Android device is 115200. Any baud rate higher than this did not work for neither HC05 - HC05 nor HC05 - Android. Also, I could not find a way in the Bluetooth Documentation (https://developer.android.com/reference/android/bluetooth/BluetoothSocket) to change the baud rate used on the Android device with Bluetooth SPP. It was as if the device automatically adjusted to the baud rates I configured on the HC05. i.e. 9600 - 115200.

Seems logical, that Android will change the baudrate to be matched. The communication from HC-05 to Android is only a virtual serial interface. Baudrate doesn't have much meaning for it. Only the real UART interface between HC-05 and Arduino really needs a baudrate


text:
Pullup on compatible Arduino Mega
I've got an Arduino mega compatible board, called Ethermega, from Freetronics (ATmega2560).
Schematic here.
In setup, I've written this code:
Serial.begin(9600);
  pinMode(4, INPUT_PULLUP);
  digitalWrite(4, HIGH); // Optional, I tried with and without
  while (1)
  {
    if (digitalRead(4) == HIGH)
    {
      Serial.write("Up!\n");
    }
  }

(Don't worry about the fact I'm not using loop)
When I connect input 4 with 5V, I see "Up!". Rest of the time, I see nothing.
Considering I have enabled the internal pull-up, I'm expecting it should be up/high by default, and I would have to connect it to GND to get it low...
Another thing that puzzles me is I can find heaps of examples that use a tactile switch and no pullup/pulldown at all...
So what am I missing or doing wrong? Seems like whatever I do, I've got some kind of pulldown enabled...

pin 4 is CS pin for SD card an it has a voltage divider in the schematics

Generally you should not use digitalWrite on an input pin, it might not do what you think it does. If I remember correctly, the register that is used to set high/low in output mode us the same that sets the pullups in input mode. I don't know how the arduino core handles this, though. Just FYI...

@SimSon On AVR: pinMode(x, INPUT); digitalWrite(x, HIGH); is the same as pinMode(x, INPUT_PULLUP);. In general most cores will emulate that for you (I know chipKIT does) but you're right, it's best not to rely on it.

@SimSon Yes, I much prefer INPUT_PULLUP or writing the register, it was mostly out of desperation...

As @Juraj mentions, pin 4 is the CS pin for the SD card. That pin has a volage divider of 1kΩ + 2.2kΩ on it (a total of 3.2kΩ) to ground. So yes, you do have a pulldown on that pin. 3.2kΩ is about 1/10th of the value of the typical pullup resistor internal to the chip, so pulls the output low enough to be seen as LOW unless you manually override it.
You can't use that pin as an active low input on that board - choose another, or use it as active high.


text:
LEDs always dim with arduino nano
so I'm making an animated LED brake light using arduino nano, similar to this: https://www.youtube.com/watch?v=d5Ohzg3JKq0&ab_channel=IMEEMADE
I have 18 channels, with differet amount of series LEDs and resistor. All LED + are wired together, intended for 14.5V input, with individual resistor after the last LED cathode:
14.5V -> + LED - -> R -> GND
I have some channels with 1 LED, 2 LED and 4 LED, all tuned with different resistors so that each channel "pulls" ~20mA at 14.5V. 12V works fine as well just ever so slightly dimmer. On a power supply, I can ground any channel without cross talk, or ground all and all LEDs light up evenly (from what my eyes can tell).
I had originally planned on providing 5V input to the arduino using a buck converter and sinking each channel to a digital output pin (D2-D19 or D2-D13 + A0-A5). I ended up providing 12V to Vin and 12V to the LEDs as well as the arduino did not work at all as expected with 14.5V to the LEDs and 12V to the Vin.
My problem is that with this setup, no matter what I do in code, when the arduino is connected to Vin and ground, some LEDs are always lit dimly (D2-D13 oddly). They do indeed get brighter when pinMode is set to OUTPUT and digitalWrite({pin}, LOW) is called. But writing HIGH or setting pinMode to INPUT doesn't turn them off, just leaves them dim. I've tried adjusting Vin between 7-12V, setting the regulator to 5V and connecting directly to 5V. No change in behavior. Only thing that gets the LEDs to stop lighting dimly is lowering input voltage to the LEDs themselves. But then I don't have enough to drive the 4 series LED channels...
I know this can work because in the video I linked, there are 4 series LEDs driven in the same manner (though red, I'm using white), but not much is explained with the use of the arduino.
What am I doing wrong or how can I make this work? I need at least 12V to the LED board to ensure the 4 series channels light up properly. I've already maxed out the digital channels on the arduino nano from what I've read, so I can't use one as input (instead of Vin or 5V) if that matters or split the 4 series into 2 channels, etc...
Thanks in advance!

please draw a schematic diagram of the circuit ... the description is unclear

It sounds like you're using a 5V push-pull output as an open-drain one in a 12V circuit. So... yes you will get LEDs lighting up. You'll also get a dead Arduino if you're not careful.

This is basically how I have things wired up currently: https://www.circuit-diagram.org/circuits/de34ef54ab094db8b650731add9c1615

@Majenko I'm not quite sure tbh. I believe I only want to "pull" output from the LEDs. I don't fully understand the electronics behind the arduino, but they're cheap and don't require a special programmer, so I decided to use it as my controller.

Essentially what I'm trying to do is power the LEDs with the original voltage source (12-14.5V), and simply use the arduino to control when to ground each channel. I was not intending to put 12V through the arduino nor do I see why the voltage used to the power the arduino should matter in this case (aside from burning it out with too much on input).
And yeah, I'm pretty sure I killed one by trying to put >5V to pin A7 as an input instead of Vin :(

You can't drive LEDs from a source greater than 5V as a low-side switch with an Arduino directly. To do so you need an "open drain" output.
You can create them on the Arduino by adding a single transistor (N-channel MOSFET with "logic level" threshold, or NPN BJT) which the Arduino switches:

simulate this circuit – Schematic created using CircuitLab
R2 just exists to keep M1 turned off when the Arduino's not actively driving it (i.e., while the bootloader runs, etc).

Thanks @Majenko! I assume I need a separate resistor for each mosfet to ground otherwise if the gate pins are connected in parallel with one resistor I assume switching one output pin on the arduino will trigger signal all of mosfets?

For what to do see Majenko's answer.
This is regarding why you're seeing what you're seeing, or the nature of "What am I doing wrong" part of your question, and so why you need do something like what Majenko is suggesting.
Internal to the microcontroller, are diodes that protect it from voltage transients seen at the GPIO pin.  One of these connects from the GPIO pin to the VCC ("5V") pin(s) of the MCU.  This is pretty much the case with about any MCU, and so just about any Arduino's pins, with variations for things like 5V tolerant 3.3V parts.  The RESET pin on AVR-based Arduinos has an external diode on it for reasons that have to do with (not) wanting to enter high voltage programming.
When the GPIO is not OUTPUT-and-LOW, that is if it's HIGH, or INPUT, or INPUT_PULLUP, the current is going from your 12V nominal source, down through your load (LED and current limiting), into your GPIO pin, and through the protection diode onto the 5V rail of your Arduino.  From there it will compete with your 5V regulator (or USB host's regulator) to try to power everything on the Arduino, e.g. your "L" LED, the the serial transceiver, the 3.3v regulator, the AVR itself, etc. and whatever else you have connected to "5V".
So, your GPIO pins are only rated to whatever-VCC-is plus about a diode drop; somewhere around 5.5V in this case.  Above that voltage, the protection diode begins conducting and the GPIO doesn't appear high impedance to whatever is connected to it.
When you're lucky, there's enough resistance in your load to limit the current through the protection diode to:

less current than the continuous current rating of the protection diode, which is quite low, often under 1mA.  Otherwise, while this is going on you are likely trying to kill the protection diode and whatever else it can take out with it.

less current than the Arduino can make use of.  Otherwise the voltage at the "5V" well climb to the point of frying things.  It will be backfeeding whatever is supposed to be regulating the 5V on the Arduino, which may or may not be a problem depending on the design of whatever regulator that is.

If you'd done this with a larger load, it probably would have just popped things on your Arduino.  On the other end of the spectrum, putting a sufficiently large resistor in series with a GPIO pin is a common method of crudely accepting higher voltage input signals.
The circuit in Majenko's answer doesn't provide path would allow any current to speak of to travel from the 12V source into the GPIO pin.

Thanks for the explanation!


text:
JSON Parser fails because number of bytes is being sent
Sorry I am new with this.
I am trying to read a JSON response from my website using an ESP8266, but it keeps failing.  I am using the following code:
WiFiClientSecure httpsClient;    //Declare object of class WiFiClient
httpsClient.setInsecure();
httpsClient.setTimeout(15000); // 15 Seconds

if (httpsClient.connect(host, httpsPort)) {

  String Data ="/IOT/Device_Setup.php?MAC="+deviceMAC;

  httpsClient.print(String("POST ") + Data + " HTTP/1.1\r\n" +
   "Host: " + host + "\r\n" +
   "Connection: close\r\n\r\n");

  while (httpsClient.connected()) {
    String line = httpsClient.readStringUntil('\n');
    Serial.println(line);
    if (line == "\r") {
      Serial.println("headers received");
      break;
    }
  }
  String payload = "";
  while (httpsClient.available()) {
    char c = httpsClient.read();
    payload=payload+c;
  }

  Serial.println(payload);

  // Allocate JsonBuffer
  // Use arduinojson.org/assistant to compute the capacity.
  const size_t capacity = JSON_OBJECT_SIZE(3) + JSON_ARRAY_SIZE(2) + 60;
  StaticJsonDocument<200> jsonBuffer;
  // Parse JSON object
  DeserializationError error = deserializeJson(jsonBuffer, payload);
  if (!error) {

    const char* Switch = jsonBuffer["Switch"];
    const char* LED = jsonBuffer["LED"];
    const char* DHT = jsonBuffer["DHT"];

    // Decode JSON/Extract values
    Serial.print("Switch = ");
    Serial.println(Switch);
    Serial.print("LED = ");
    Serial.println(LED);
    Serial.print("DHT = ");
    Serial.println(DHT);
  }
}

When I print out the payload after the header I receive the following output:

22
{"Switch":"0","LED":"0","DHT":"1"}
0

I know the 22 is the hex value for the number of bytes being sent.  Is there a way of ignoring the numbers and just using the JSON code?

how is it failing?

it is then chunked transfer encoding. set content length on server to avoid it.

Agree, this is Chunked Transfer Encoding, use HTTP/1.0 to avoid it. See also JsonHttpClient.ino on arduinojson.org.

Thanks everyone. Adding the size in the header worked.


text:
My car only moves when it is plugged directly into both my pc and battery pack?
i built a car that works with four motors,one motor driver(specifically the l293d),the arduino and the battery pack with four AA-Batteries. The motors work fine though, but they only work when it is connected to the laptop and the battery pack.I've also removed the METAL insulation from the copper wire and now it is copper.Sadly i have also connected the two poles together and there was some lightning but no fire thankfully(by accident of course).if anyone else had the same issues and fixed them please contact me.
Thank you very much stranger.

If we imagine how you have all this wired together we will be solving imaginary problems.  I'm not sure what you mean by metal insulation.  Shielding? Metal armored cable?

the battery pack came with two copper wires one red and black and then there was some metal at the tip so i removed it to make it longer and now it doesn't work

look the problem is that it only works when it is plugged in both the laptop through the usb and the battery pack with four aa batteries

how do you make something longer by removing part of it?

look the copper wire had a metal tip and then i removed it and removed some insulation and now there is only copper out .

please have one of your friends read your post ... then ask them if they understand what you are describing

so, you have a piece of wire with a stripped end ... how is that a problem?

there is battery holder with two wires out positive and negative. And then i removed the metal tip that was transferring electricity onto the motor driver and along it some insulation to make the wire bigger.And now it only runs when it is connected to both the laptop and the battery holder.by it i mean the car

i don't know if this is the problem. i thought this was the problem.I have also disconnected the power while it was working

maybe you did not reconnect the wire properly or you broke something ... you did not describe anything clearly ... it is difficult to understand what you did if you use terms that make no sense, like make the wire bigger

Given that at least two of us don't understand your descriptions, it makes even more sense than usual that you include in-focus pictures of what you're talking about.

the orange arduino led is flashing and making a weird sound

ok i will try to put a picture

The best thing you can do is post a schematic, not a frizzy thing along with a picture of the parts that you modified and links to all of the other parts. You state: "orange arduino led is flashing and making a weird sound" How does a LED make a sound, they are not designed to. The best thing you can do for yourself is read the Arduino cookbook and do some online tutorials on basic electronics and the arduino.


text:
Why is my button not working?
I'm trying to making a traffic light for my school project but my button for the traffic light doesn't work. The traffic lights should light up normally but when the button is pressed all LEDs should go to LOW but that does not happen. Did I connect my buttons incorrectly?
Code:
int Pins[] {2,3,4,5,6};
int red =2;
int yellow=3;
int green = 4;
int GruenF =6;
int RotF=5;

int blaulichtTaster = 12;
int blaulichtTasterStellung = 0;

void setup() {
  for(int i=0;i<9; i++) {
  pinMode(Pins[i], OUTPUT);
}
  pinMode(blaulichtTaster, INPUT);

}
void loop() {

  blaulichtTasterStellung = digitalRead(blaulichtTaster);

  if(blaulichtTasterStellung == 0){
    digitalWrite(red, HIGH);
  delay(3000);
  digitalWrite(GruenF, HIGH);
  digitalWrite(RotF,LOW);
  delay(4000);
  for(int i =0;i<4;i++) {
    digitalWrite(GruenF,LOW);
    delay(500);
    digitalWrite(GruenF,HIGH);
    delay(500);
  }
  digitalWrite(GruenF,LOW);
  digitalWrite(RotF, HIGH);
  delay(3000);
  digitalWrite(yellow,HIGH);
  delay(4000);
  digitalWrite(red,LOW);
  digitalWrite(yellow,LOW);
  digitalWrite(green, HIGH);
  delay(10000);
  digitalWrite(green, LOW);
  delay(500);
  for(int i = 0; i<3; i++) {
    digitalWrite(green, HIGH);
    delay(500);
    digitalWrite(green, LOW);
    delay(500);
  }
  digitalWrite(green, HIGH);
  delay(500);
  digitalWrite(green, LOW);
  digitalWrite(yellow, HIGH);
  delay(4000);
  digitalWrite(yellow, LOW);
  }

  else{
    digitalWrite(red,LOW);
    digitalWrite(yellow,LOW);
    digitalWrite(green,LOW);
    digitalWrite(RotF,LOW);
    digitalWrite(GruenF,LOW);
  }

}

My circuit:

Assuming that the power rails in your breadboard are continuous, and you hold the button long enough for the entire light sequence to execute from start to finish (33 seconds?), then yes it looks like it should work. Are you expecting it to react instantly to you pressing the button or something?

Yes it schould react instantly.

Then you're going to have to re-think your program and get rid of all those delay() functions.

@fatihakan21, can you address the "Assuming that the power rails in your breadboard are continuous" part of Majenko's comment.  Have you in fact confirmed that they are continuous?

write a test sketch that turns on all the LEDs when the button is pressed and turns off the LEDs when the button is released ... after all, the question is about the button, not about the rest of the sketch ... you are assuming that the button is failing, so you need to test your assumption


text:
Atmega 328P U crash on 5V/1A
Atmega 328PU crash on 5v/1A. Why? It works on 5V/400ma but when i switch it to 5V/1A power it crash. Any idea or solution for this?

sure, don't use the defective power supply that causes crashes

You're asking why, but you're providing no details to enable us to answer your question. There's no reason a more powerful supply should crash your ATMega328P, so it's probably caused by a faulty supply or some other problem (which we can't help you with because you have not told us anything about your setup).

Thanks guys, yea the power supply was foulty. i get a new one and its working fine. thanks!

Nothing wong, if your power supply is trustworthy enough, then , if u even provide 100000 Amps of current with 5 volt,
your IC won't burn, in your case , it burnt because your power supply seems to be defective, and please check the voltage of the power supply which is supposed to be defective, so it output more than 5 volts burning or crashing your ic...
Note:
I have personally worked with 5 volt 6 amp power supply which is very well precise and my ic is working full fledged without any problems.

yea the adapter was faulty. i get new one (5V/1A) and it's working fine. Thank you @Subha Jeet


text:
Set interrupts that are not GPIO or Timer in ESP32
I am making a project on ESP32. It reads certain sensor values, stores them in RTC memory and sends them by MQTT after a certain time. I wish that it transmits data immediately if there is a difference of, say 10 units, via an interrupt. I suppose this is not possible by GPIO interrupts and obviously not by a timer as I wish it to happen only if a condition is true and not periodically.
I searched on the internet but couldn't find anything except GPIO and Timer interrupts.
I am working on Arduino IDE.
Is what I want possible and if yes, how. Please also give a certain example that is in Arduino language for me to study. Also, if it is possible using GPIO interrupts, please tell me how.
Thank you in advance

send it in loop()

There is no such thing as an "interrupt on a value changing" since that is something that only exists in software, and interrupts are things triggered by hardware.
All you can do is check the value in loop() and send the data if the value is above your threshold. If you want to wake from sleep then you will have to do that periodically through other means.

could one use the 32's low power co-cpu and an assembly routine to avoid the wakeup just to compute the difference?


text:
Connect ESP32 via MQTT
For a project I am working on, I need to connect my ESP32 board to another server via MQTT protocol. I am using the Mosquitto MQTT Broker and it is presently on my laptop. Following is the test code I am using, which I'll build around this program.

#include <WiFi.h>
#include <PubSubClient.h>

const char* ssid = "*****";              //WiFi Name
const char* password = "********";      //WiFi Password
const char* server= "***.***.**.***";    //RPi or Machine IP on which the broker is

WiFiClient espClient;
PubSubClient client(espClient);

int setup_WiFi(){
  delay(10);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  Serial.print("Attempting MQTT connection...");
  client.connect("esp32");
  if (client.connect("esp32")){
      Serial.println("connected");
    }
    else {
      Serial.print("failed, rc=");
      Serial.println(client.state());
    }
    return 0;
}

int reconnect() {
  unsigned long startAttemptTime = millis();
  while (!client.connected())
  {
    Serial.println("Attempting MQTT connection...");
    // Attempt to connect
    if (client.connect("esp32")){                 //if (client.connect("esp32", MQTT_USER, MQTT_PASS)) {
      Serial.println("connected");
    }
    else {
      Serial.print("failed, rc=");
      Serial.println(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
  return 0;
}

int send_mqtt(){
  setup_WiFi();
  char sss[15]="Hello World";
   if (!client.connected()){
    reconnect();
  }
  client.publish("esp32/test", sss);    //send message
  WiFi.disconnect(true);
  Serial.println("Sent");
  return 0;
}
void setup() {
  Serial.begin(115200);
  client.setServer(server, 1883);   //mqtt server details
  setup_WiFi();
  reconnect();
  send_mqtt();
}

void loop() {
  send_mqtt();
  delay(10000);     //Wait 10 secs before next transmission
}

I tried connection but got this error

Attempting MQTT connection...failed, rc= -2

What am I doing wrong? Any changes I need to make to the .conf file about which I don't know?
Guide me.
Thank You in advance

Here, const char* server= "...*"; , I'm putting the IPv4 address of the machine on which Mosquitto is installed.

Can your laptop ping the ESP32?

Can you connect with an MQTT client running on the broker itself? Do the log files on the MQTT Broker say anything? Are there other MQTT Clients successfully connecting?

@starcat I am able to connect to "localhost". I am using MQTT Explorer to see the connections. Don't actually know if the other devices are connecting, because I haven't tried that and nor do I have the resources. And I am trying to figure out what IP I should connect to.

@Majenko From within the same network, yes I am able to ping.  From a different network (different WiFi), No

From the same network can the ESP32 connect to the laptop?

@Majenko I actually don't know how to test that..could you guide me here? The ESP32 is able to connect to the WiFi and getting an IP too.

The code in your sketch is unlikely to be the problem. It works fine for me after I enter the IP addresses and password for my network.
According to the pubSubClient API documentation, the rc = -2 code returned by client.state() is due to the network connection having failed. As your code has already checked that it is connected to WiFi before trying to contact the MQTT broker, it is probably the communication between the two devices that is the issue, not the WiFi connection itself.  Things to check:

Are both devices are on the same network, and do they have a route to contact each other? From the laptop running the MQTT broker, try running ping XXX.XXX.XXX.XXX (replacing the XXXs with the IP address reported by the ESP32), and check you get a response. You might wish to comment out line 67 of your code so it doesn't disconnect from WiFi after every attempt at sending a message, otherwise you will see lots of lost packets.
Have you got the right IP address for the MQTT broker in your sketch? It should be the IP address for your laptop, not the loopback address, 127.0.0.1.
Can you use another device on the same network to connect to the MQTT server? (e.g. a cellphone running a MQTT dashboard app, or MQTT Explorer in Windows)
Is Mosquitto configured to listen out for remote connections? If you are running v2 of Mosquitto, you have to deliberately configure it to accept incoming connections, otherwise it will only listen to the localhost interface. You would also have to either set up an authentication mechanism or explicitly configure it to allow anonymous connections. This might be why you can connect from the laptop running the broker, but not from other devices.
On the MQTT server, can you see any connection attempts in Mosquitto's log file (/var/log/mosquitto/mosquitto.log)? There might be some error messages that give you further clues.

I tried all that you suggested. Except for "Ping" all the measures failed. I was able to ping.
Sorry for the late response.

So if you can ping the ESP32, and it's using the right address for the MQTT broker, the next thing to check is the broker itself. Could you update your question to include the version of Mosquitto you are running, and a copy of its mosquitto.conf file? What happens when you try to connect to it from a different device on the same wifi?

When connecting another device it gives an error "connection failed"

So it looks like the MQTT broker isn't working. Maybe it isn't configured to allow remote connections. Can you edit your question to include the Mosquitto version number and config file? That would help to debug the problem.

Version is 2.0.11 and link to conf file is here

In that conf file, all the settings are commented out, so Mosquitto is using its defaults. That means you can log on without any authentication, but only from the machine running Mosquitto. It's not listening to your wifi. You need to edit the conf file to allow connections from other devices, and to either set up authentication or explicitly allow anonymous connections. Read the link at Point 4 in my answer to see how.

Thank you so much for your help


text:
ESP32 send data while blinking LED
Can I program my ESP32 to send a string MQTT data while also blinking the InBuilt LED?
If yes, then how to do so
Thanks in advance

Sure you can. You can use something like the BlinkWithoutDelay example included in the Arduino IDE so that your program can run (for example sending MQTT data) while the LED is turned on and off with the correct frequency. As long as sending the MQTT data does not take longer than the on- or off period of the LED, this will work.

Take a look at the blink-without-delay example to get an idea of how "multitasking" can be implemented. But as @HigorMaiaConcessa mentioned, the ESP supports FreeRTOS where you don't have to care much about how it works.

My opinion is that using multiple cores for extremely simple tasks such as blinking an LED is unnecessarily complex.

The ESP32 have two core, each core can do diferents tasks. Then, you can send data with one core and blink the LED with another core.
To do this, you need to use a multicore programming. I recommend to use the FreeRTOS (ESP32 support this). See more.
Look the example "Let's multitask: Blink with Hello" here, is that what  you want.
Read the documentation about the FreeRTOS in ESP32.
Example in Arduino IDE:
#include <Arduino_FreeRTOS.h>

// define two tasks for Blink & AnalogRead
void TaskBlink( void *pvParameters );
void TaskAnalogRead( void *pvParameters );

// the setup function runs once when you press reset or power the board
void setup() {

  // Now set up two tasks to run independently.
  xTaskCreate(
    TaskBlink
    ,  (const portCHAR *)"Blink"   // A name just for humans
    ,  128  // Stack size
    ,  NULL
    ,  2  // priority
    ,  NULL );

  xTaskCreate(
    TaskAnalogRead
    ,  (const portCHAR *) "AnalogRead"
    ,  128 // This stack size can be checked & adjusted by reading Highwater
    ,  NULL
    ,  1  // priority
    ,  NULL );

  // Now the task scheduler, which takes over control of scheduling individual tasks, is automatically started.
}

void loop()
{
  // Empty. Things are done in Tasks.
}

/*--------------------------------------------------*/
/*---------------------- Tasks ---------------------*/
/*--------------------------------------------------*/

void TaskBlink(void *pvParameters)  // This is a task.
{
  (void) pvParameters;

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

  for (;;) // A Task shall never return or exit.
  {
    digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
    vTaskDelay( 1000 / portTICK_PERIOD_MS ); // wait for one second
    digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
    vTaskDelay( 1000 / portTICK_PERIOD_MS ); // wait for one second
  }
}

void TaskAnalogRead(void *pvParameters)  // This is a task.
{
  (void) pvParameters;
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);

  for (;;)
  {
    // read the input on analog pin 0:
    int sensorValue = analogRead(A0);
    // print out the value you read:
    Serial.println(sensorValue);
    vTaskDelay(1);  // one tick delay (15ms) in between reads for stability
  }
}

Reference.

Thank you for the help. Are there any Arduino IDE Examples available, since it is more understandable in it

Look this example. I added the example in the answer.

While true, it seems like a large increase in complexity for a relatively low gain (and there are multiple task schedulers for Arduino that don't involve an RTOS). It's also my understanding that unless tasks are specifically pinned to a core there's no guarantee regarding multicore-ness.

So I guess giving same priority to 2 small tasks will make them execute simultaneously. Am I right?

If run in diferents cores, then will execute simultaneously. If run in the same core with the same priority, will run merging each one.


text:
How to convert kitchen timer code into a countdown
I found this code for a kitchen timer, it was the closest thing to a countdown. The code is here:

#include <LiquidCrystal.h>

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

signed short minutes, secondes;
char timeline[16];

void setup() {

  lcd.begin(16, 2);
  lcd.print("Chronometre :");

}

void loop() {

  lcd.setCursor(0, 1);
  sprintf(timeline,"%0.2d mins %0.2d secs", minutes, secondes);
  lcd.print(timeline);

  delay(1000);
  secondes++;

  if (secondes == 60)
  {
    secondes = 0;
    minutes ++;
  }

}

How do I convert it properly for it to countdown from 1 minute and 30 seconds?

How about initializing the time variables secondes and minutes with the values for 1:30 and then instead of incrementing them decrementing? And of course checking for seconds to be below zero for decrementing the minutes. Have you tried that?

I didnt know how to initailize that. Could you offer some code?

You should really do some basic C/C++ and Arduino tutorials, when you want to do Arduino. Otherwise you will not have much fun. Also we are not a free coding service. Look at the code where the mentioned variables are defined. Give each a fitting value by writing an = after the name and then the value. In the loop() you replace the ++ after the variable names with -- to decrement them. Then in the if condition secondes < 0) and inside the if statement secondes = 59. Thats as far as I will go here. With some tutorials and experimenting you will be able to understand that code.

I didnt know how to initailize that.  ... what do you think that line such as secondes = 0; does?

"customize this code i found" is not why we're here. I mean, this is really trivial. Break the problem up into smaller steps and ask for help when you get stuck. Use Serial.println() a lot when you start coding. a lot.

@chrisl  I know this isn't a free coding service. It was a simple question. Is there anything wrong with that?

@JamesChristaldi No, absolutely nothing wrong with asking question. This wasn't to scold you. I just think, that your question leaves basically two ways of answering here: Writing the code for you or giving you a basic C/C++ course. The first one is frowned upon here for some good reasons. The second one is done way better by the many basic C/C++ tutorials/courses on the web. Thus I gave a comment about the needed steps and left it to you to learn the corresponding C/C++ syntax in one of the tutorials/courses.

But this is Arduino not C/C++

Right? Am I wrong on that?

Arduino code is basically C/C++ including Arduino.h, which defines the Arduino-related functions like digitalRead() and much more. If you're able to program C/C++ programming Arduino will be a lot easier because you understand how to initalize variables, use loops, etc.

As a start, you need to initalise the secondes and minutes variables to 30 and 1 respectively.
replace signed short minutes, secondes; with:
signed short minutes = 1;
signed short secondes = 30;

Next thing I notice is that the code you have provided counts up and you have requested that it count down.
Change secondes++; and minutes++; with:
secondes--;
minutes--;

Lastly you need to change the logic for when the secondes and minutes variables reach zero.
If the secondes variable reaches zero but the minutes variable is greater than zero, then you decrement the minutes (using the line of code provided above) and top-up the secondes with 59.
secondes = 59;

You will need to check the value of the secondes and minutes variables using a couple of if...else statements.
if (secondes == 0 && minutes == 0) {
    // insert your timer finished code here
}
else if ( secondes == 0 && minutes > 0) {
    minutes--;
    secondes = 59;
}
else {
    // Error - your code should not reach here.
    // Display an error message on the LCD
}

This if..else statement will need to go at the top of your loop instead of the end.

Thank you so much!!

The first thing I recommend is that you don't use sprintf(). Your sketch "program storage space" drops from 3502 bytes down to 1928 bytes by NOT using that function call, and dynamic memory used drops from 101 to 79 bytes.
I would recommend an OOP design that would make it easy to add functionality, like the ability to start, stop and reset the timer.
// Arduino Uno, IDE version 1.8.9
// 2330 bytes (7%) of program storage space.
// Global variables use 201 bytes (9%) of dynamic memory.
class CountdownTimer{

  private:

    byte m_hour;
    byte m_minute;
    byte m_second;
    byte m_timerActive;
    byte m_timerComplete;
    unsigned long m_previousMillis;

  public:

    CountdownTimer():
      m_hour(0),
      m_minute(0),
      m_second(0),
      m_timerActive(0),
      m_timerComplete(0),
      m_previousMillis(0){}

    bool Update(){

      if(m_hour == 0 && m_minute == 0 && m_second == 0){
        m_timerComplete = 1;
        return 0;
      }

      if(m_timerActive && (millis() - m_previousMillis >= 1000)){
        m_previousMillis += 1000;
        m_second--;
        if(m_second == 255){
          m_second = 59;
          m_minute--;
          if(m_minute == 255){
            m_minute = 59;
            m_hour--;
            if(m_hour == 255){
              m_hour = 0;
            }
          }
        }
        return 1;
      }
      else{
        return 0;
      }
    }

    byte GetIsTimerComplete(){
      return m_timerComplete;
    }

    void SetHour(byte hour){
      m_hour = constrain(hour, 0, 23);
    }

    void SetMinute(byte minute){
      m_minute = constrain(minute, 0, 59);
    }

    void SetSecond(byte second){
      m_second = constrain(second, 0, 59);
    }

    void Start(){
      m_timerActive = 1;
    }

    void Stop(){
      m_timerActive = 0;
    }

    void ReStart(){
      m_timerActive = 1;
      m_timerComplete = 0;
      m_previousMillis = millis();
    }

    void PrintTimeRemaining(){
      if(m_hour < 10){Serial.print("0");}
      Serial.print(m_hour);
      Serial.print(":");
      if(m_minute < 10){Serial.print("0");}
      Serial.print(m_minute);
      Serial.print(":");
      if(m_second < 10){Serial.print("0");}
      Serial.println(m_second);
    }

};

// Make a copy of the object to work with.
CountdownTimer myCountdownTimer;

void setup(){

  // Built in pin 13 LED timer completed indicator.
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);

  // Test output to the serial monitor.
  Serial.begin(9600);

  // Set the countdown timer values,
  // start the countdown timer and
  // print the initial timer setting.
  myCountdownTimer.SetHour(0);
  myCountdownTimer.SetMinute(1);
  myCountdownTimer.SetSecond(30);
  myCountdownTimer.Start();
  myCountdownTimer.PrintTimeRemaining();
}

void loop(){

  // Call the Update function as fast as possible.
  if(myCountdownTimer.Update()){
    myCountdownTimer.PrintTimeRemaining();
  }

  // Turn on the Uno's Pin 13 LED once timer is complete.
  if(myCountdownTimer.GetIsTimerComplete()){
    digitalWrite(LED_BUILTIN, HIGH);
  }

}


text:
AT command AT+CWJAP command always fail when connect to wifi

Refer to connect to wifi from https://www.cooking-hacks.com/mysignals-hw-ehealth-medical-biometric-iot-platform-arduino-tutorial.html
    #include <MySignals.h>
#include "Wire.h"
#include "SPI.h"

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

  MySignals.begin();

  //Enable WiFi ESP8266 Power -> bit1:1
  bitSet(MySignals.expanderState, EXP_ESP8266_POWER);
  MySignals.expanderWrite(MySignals.expanderState);

  MySignals.initSensorUART();

  MySignals.enableSensorUART(WIFI_ESP8266);
  delay(1000);

  // Checks if the WiFi module is started
  int8_t answer = sendATcommand("AT", "OK", 6000);
  if (answer == 0)
  {
    MySignals.println("Error");
    // waits for an answer from the module
    while (answer == 0)
    {
      // Send AT every two seconds and wait for the answer
      answer = sendATcommand("AT", "OK", 6000);
    }
  }
  else if (answer == 1)
  {

    MySignals.println("WiFi succesfully working!");

    if (sendATcommand("AT+CWMODE=1", "OK", 6000))
    {
      MySignals.println("CWMODE OK");
    }
    else
    {
      MySignals.println("CWMODE Error");

    }

    //Change here your WIFI_SSID and WIFI_PASSWORD
    if (sendATcommand("AT+CWJAP=\"WIFI_SSID\",\"WIFI_PASSWORD\"", "OK", 20000))
    {
      MySignals.println("Connected!");
    }
    else
    {
      MySignals.println("Error");

    }
  }
}

void loop()
{
  delay(5000);
}

int8_t sendATcommand(char* ATcommand, char* expected_answer1, unsigned int timeout)
{

  uint8_t x = 0,  answer = 0;
  char response[500];
  unsigned long previous;

  memset(response, '\0', sizeof(response));    // Initialize the string

  delay(100);

  while ( Serial.available() > 0) Serial.read();   // Clean the input buffer

  delay(1000);
  Serial.println(ATcommand);    // Send the AT command

  x = 0;
  previous = millis();

  // this loop waits for the answer
  do
  {

    if (Serial.available() != 0)
    {
      response[x] = Serial.read();
      x++;
      // check if the desired answer is in the response of the module
      if (strstr(response, expected_answer1) != NULL)
      {
        answer = 1;
        //MySignals.println(response);

      }
    }
    // Waits for the asnwer with time out
  }
  while ((answer == 0) && ((millis() - previous) < timeout));

  return answer;
}

I can't connect to router even i use the same SSID and password

print the response if answer is 0


text:
Arduino H-bridge for rc car
I've got an old rc car laying around, of which i would like to swap the insides, but re-use some of the parts that are already in there. The car runs 2 dc motors: one for steering, one for throttle. The dc motors are both connected to H-bridges in the original setup to make their direction switchable. This is done via 8 transistors. 4 for the throttle and 4 for the steering.
The transistors for steering are 2x S8050 (NPN) and 2x S8550 (PNP).
For throttle it uses 2x 2SD882 (NPN) and 2x 2SB772 (PNP).
I found a schematic in an online post of a arduino H-Bridge setup. It look promising, but it uses 2n4403 and 2n4401 transistors. I was wondering if I could copy the schematic, replace the Arduino 5v power source (as depicted in de schematic) with the battery voltage source of the car, and replace the transistors in the schematic with one pair of the transistors I described above (so 2x 2SD882 and 2x 2SB772 or 2x S8050 and 2x S8550) Would the arduino be able to switch the described transistors? Would the 1K ohm resistors in between the arduino and the transistors suffice?
I am planning on making this schematic twice, once for throttle and once for steering. The throttle output is max 11.5v and the steering uses around 5v. Therefore the throttle circuit would be powered from the battery voltage and the steering circuit would be powered of a 5v regulator.
Can this be done this way?

The 5 V (Steering) Version would not be a problem. But the 12V Version is a problem for the PNP transistor. You have 12 V on emmiter of the PNPs and only 5 V from the Arduino pin on the base to switch them off. That prevents the PNPs from beeing switched off and for a pin = HIGH the current flows through the PNP and NPN pair, but not trough the motor. Perhaps you could use MosFETs as a replacement. Or you use additional MosFETs  connected to the arduino with their gates and drive the 12 Volt to the bases of the NPN and PNP Transistors.

Thanks for the advice! Would a relay work for doing this as well? In my mind I'd switch the relay using 5V from the Arduino which then switches the transistor with Vbat.

It should be possible to use relays. But be sure to use flyback diodes with them. You should also check isf the relay can handle the current and voltage. A relay is a mechanical part, so it has a limitted amount of scwitch actions, it can perform. Especially with high current; the contacts burn out. Have you considered using a LM298 breakout board for the 12 V Motor?

Yes I did consider the LM298, but I don't think that it would be able to handle the amount of current that the 12v motor uses, since the LM298 has a 25W rating...?

Would the BTS7960 make a better option? (https://media.s-bol.com/mER770rAkPw9/550x309.jpg)

A 2SD882 has a 12.5 Watt rating. If you can use that NPN you could use the LM298 too. I don't know  BTS7960 and I don't know your motors, so if the ratings match - why not?

Just a comment about your diagram. The two transistors should not share an Arduino pin in that way. If the pin is pulled high the transistors saturate and your current 'shoots through' from supply straight to ground. Instead assign one Arduino pin to each transistor (using the base resistor in your diagram).

Sorry, but that is not good advice. It is much better to us one ARD pin on a NPN/PNP pair, becaus one transistor must be off and one transistor must be on for each state of the pin. That's how an H Bridge works. If you are able to switch both transistor on at the same time, the (fairly unlimited) current flows through both transistors and you'll see the famous smoke. ;-)


text:
How to receive commands to a running arduino program from a raspberry pi?
I have looked all over for a solution to this. I'm a noob in the arduino space and am really just getting my feet wet. It's possible that I am interpreting what I am reading wrongly. If so I apologize. Here is my problem/question. I want to create an autonomous driving small land drone. It would connect to some drive sensors, dc motors and do some stuff all by itself. In addition to this I want a raspberry pi with a camera surveying the scenery. Because it is unknown if/when the raspberry PI will see something that is interesting i want this default behavior to occur. The reason I want to do it like this is that I read it is better performance to drive from the Arduino because a linux based computer has so much stuff running on it there could be more lag in the response. In addition the python program will be making HTTP requests, doing image processing, and potentially doing even more. If the image processing software on the PI picks up something interesting then I want this functionality to override the Arduino default program. I was thinking to create a program in Arduino for the basic drive functionality but then be listening to a python process that is running on the PI. If it hears a command to go do something, then of course it will drop the default program, go complete the python generated task and once it is done then it will continue with the arduino default program.
How do I in effect listen to a python process from the Arduino? Or would the proper solution be to not even use the Arduino but drive it all from python on the PI? Any suggestions for how to solve this would be great to hear. I feel like there is an obvious best practice way to do this that I am not aware of. Thanks in advance!

You can connect the Arduino via USB to the Pi
The Arduino should show up as a serial device; and thus you'd be able to communicate from Pi to Arduino and vice versa.
But you may want to try and get it working on your PC first.
There should be plenty of comparable projects online, see if you can find one that looks a lot like what you're trying to achieve

What you are asking for is not completely trivial, and may be ill-suited
for a beginner's project. You will have to create a protocol for the
communication between the Raspberry Pi and the Arduino (your own
“command language” of sorts), and then implement on the Arduino a
command interpreter that understands this protocol and acts accordingly.
I highly recommend you use a text-based protocol, as this will be way
easier to debug than a binary protocol.
For the Arduino side of the project, you first have to learn how to
read the serial port from the Arduino. Then, you can take a
look at this very basic command line interpreter for
inspiration. Or you can search for Arduino libraries that provide
similar interpreters.
On the Python side, you have to open the serial port (/dev/ttyACM0)
and send your commands through it. The details on how to do that
would be a Python question, which is are out of scope here.

Thank you Edgar you clearly don’t know me very well as “not suitable beginner project” is my middle name


text:
Sparkfun Spectrum Shield no change in frequency
So i wanted to build a music visualizer using a MSGEQ7. As I just got started with electronics, I did some soldering beforehand and I think I am doing okish. While it might not be perfect, the contact should be fine.
I hooked my arduion MEGA 2560 Board up with the Spectrum Shield and ran the code according to this webpage
https://learn.sparkfun.com/tutorials/spectrum-shield-hookup-guide/all
My solders are fine, however, the serial output for the 7 freuquency bands never changes and stays at 150 once I plug in an aux cable. I checked if the audio is processed at all by connecting a speaker to the output and the music does play. However, there are no changes of the frequency bands when playing music.
Is my board broken? If needed, i can provide pictures of my soldering/circuit. I got pretty frustrated cause I am just getting started and I don't even know how to tell what's wrong.
I really appreciate any help.
Thanks!

please add your code to your post


text:
Electronics Laboratory
I would like to know if someone could explain to me how to create an arduino electronics laboratory with soldering iron etc. with a low budget <3

Go shopping on Ali Express.

https://majenko.co.uk/blog/top-6-things-every-engineer-needs

That question cannot be answered without knowing what you want to accomplish. It is like I want to go swimming in the water.  We have no idea of your skill set, what you want to build and or trouble shoot.  Your budget is less than 3 what? If $3 you could get a pad of paper and pencils.  Much more information is needed.

@Gil I thought the <3 is meant to be a heart, as emoticon at the end of the question XD But you have a point

For starters, I would avoid the soldering iron, if possible. It's much easier to work with breadboards. Soldering (modern) electronics is a skill on its own.

There won't be a really complete list, since there are many many tools, that one could use for an electronics/Arduino laboratory. Also low budget is relative, so you might wanna choose out of the below list based on your real budget and the actual price of the parts at your place. Also consider, that many tools can be bought very cheap, but these tools are often bad, which means, that you most likely will buy a better replacement product later (buying cheap means buying twice). Still a low budget can absolutely justify buying cheap at first (some bad tools is better than no tool).
Note: I will use Euro as currency here (as I'm from Germany), which can about be used interchangeably for US Dollar. Your mileage may vary.

Breadboards: For working with Arduinos you wanna first build your circuits on a breadboard for testing. You should at least get one. I've seen 3-Packs of breadboards on platforms like amazon for about 12€.

Jumper-Wires (male-male/male-female): These wires with attached dupont jacks will make it easier to prototype on breadboards.

Colored Wire spools: I have a few spools with 4 different colors of 0.2mm² wire. You can use these for your PCBs and for breadboards. The different colors help to color code your wires for better overview. They cost a few € each.

Multimeter: A simple multimeter, that can measure voltage, current and resistance and in best case has a continuity check mode. This is a very important base tool for all electronics. I think most multimeters from 15€ up would be ok.

Pliers and Wire cutter: These are good for pressing and for cutting things. If you train a bit, you can even use the wire cutter for removing the isolation at the end of your wires. Technically a proper wire stripper is better, but I think using a wire cutter for the low budget start is totally ok. A wire cutter can go as cheap as 10-15€ for a decent one.

Soldering iron: Don't buy one of these soldering irons, that go directly into the mains. Buy a little soldering station with basic temperature control and integrated holder and a sponge for cleaning the tip. It should also have the possibility to change the tip (when you need a smaller/bigger tip or when your tip is no good anymore). A few years ago I got one of these for about 15€. Going a bit higher will benefit you with a better solder station.

Solder wire: You need to buy the actual solder. You should buy a spool of solder wire with integrated flux. Though most little spools have that. Depending on the exact solder wire it can be useful to also buy some flux (I'm currently using a flux pen), if the solder isn't flowing good enough.

Third hand with magnifying glass: When soldering it is sometimes helpful, when you can put a part into a clamp (like the third hand) and then use your hands for soldering iron and solder wire. The magnifying glass (which is also hold by the third hand) can help with small parts and inspection of your soldering work. It often costs only a few €, but getting up a bit can give you better durability and stability.

Perfboard: To build PCBs yourself you can most easily use perfboards. That are simple boards with solder pads for through-hole components. You can solder the components to the and then connect the pads via solder/wires. These are available with each pad not connected to anything else, or already connected like on a breadboard (I use these ones, like in this answer), or in stripes,... Building better PCBs would involve a more complicated process with chemicals or sending the PCB files to a manufacturer.

Heat shrink tubing/sleeves for wires and cables: To isolate wires, you might want to get correspondingly sizes heat shrink tube. They slide onto the to-isolate place and then get heated with a heat gun or a lighter. They shrink down and so enclose the part for isolation.

Oscilloscope: This is normally one of the most expensive tools. A decent oscilloscope can cost 250€ and up (into infinity). But you can sometimes get the big old oscilloscopes second hand (for example from ebay) as others upgrade to a digital oscilloscope. Or you can buy an USB oscilloscope, which works with your PC. I got one of these for about 50€. Or there are simple kits for standalone oscilloscopes (with limited capabilities) for 35€ and up. An oscilloscope is important for analyzing analog signals.

Logic Analyser: This is used to analyze digital signals. Standalone logic analyzers are expensive, but you can get a USB version for about 10€. The opensource software sigrok can then be used to interface the logic analyser. This tools is really really useful in relation to its low price. For example: You can use it as debug tools by setting pins inside your code at special places. That gives a better view on the temporal code flow than the typical Serial output.

Hot glue gun: Seems pretty basic, but I really often use my hot glue gun. You can fix things, protect them, build a supporting structure,... They only cost a few € plus a few for the glue sticks.

Scalpel and box cutter: Cutting things is also important and these two are good at it. They only cost a few € and have interchangeable blades. Especially a fresh scalpel blade can make the cutting of light materials really smooth.

That's about, what I can think of currently.

Thank you, you were the only one that if I explained what I wanted

I can't help with the whole laboratory, but I can suggest the free ArduinOscope mini-app to turn an Arduino UNO into an oscilloscope that uses your computer as the display. Here's the link to the Help topic that describes controls, features, and performance: https://www.daqarta.com/dw_rroo.htm.  This is a large macro script that comes with my Daqarta software https://www.daqarta.com. Please note that you don't have to purchase anything to use the DaquinOscope; a license is needed (after the trial period) only to use your sound card inputs, not the Arduino.  (You also don't need a license to use the sound card outputs, so you can use the free Daqarta Generator to create test signals.)
Enjoy!

thank you very much: 3


text:
Spectrabloom LED light box
I'm looking to make a DIY version of Dan Conrad's Spectrabloom. I've got an Arduinio Uno, a piece of code that uses PWM to randomly fade three 1w LEDs (one red, one blue and one green) and a PicoBuck LED driver.
Question is - do I have to have two power supplies? One to power the PicoBuck and one to power the Arduino or can I have them all running off one supply? If the latter - can anyone give me pointers on the way to hook everything up?

Question is - do I have to have two power supplies?

No, you can use one power supply for both. But you need to make sure, that the LED current is not flowing through the Arduino, since that can kill the Arduino. To do that, you need to connect the power supply to the LED driver and the Arduino in parallel. For example, lets assume you have bought a 5V wallwart/power supply, which is can provide enough current for your whole circuit (and some headroom for further development). Then you can connect the positive lead to the 5V pin of the Arduino and the Vin+ (positive supply voltage) pin of the LED driver. Also connect the negative lead of the power supply to ground on Arduino and Vin- (negative supply voltage) of the LED driver. That way the current for the LEDs comes directly from the power supply and doesn't need to flow through the Arduino, but past it.

Thanks Chris - I have a wallwart + splitter that I intend to run into two dc jacks connected to the Arduino and the LED driver respectively - will this work?

Yes, if it has a fitting voltage rating

Yeh, neat - it does. All good. Thanks for your help.

Three 1 Watt LED could potentially draw 600 mA total, exceeding the maximum draw for the Arduino. Each LED could draw 200 mA, exceeding (by 10x) the draw of a pin driver. So, yes, you need to supply the LEDs separately from the Arduino. Also, that driver is a constant-current driver, at 330 mA per channel. Your LEDs would prefer a constant voltage, chopped by PWM.

I haven't quite understood, why a constant-current driver would be a problem. Isn't that a quite common way to drive LEDs, especially the high powered ones? Or do you mean, that 330mA per LED would be too much? The OP didn't specify, which LEDs he uses.

If constant current is usual, I wasn't aware of it. But yes, I wouldn't choose a supply that could overdrive my devices by 50% if I let the PWM get too high. Murphy is never far away...  :)

I know constant current drivers from laser diodes (which electrically are just LEDs). I think they are commonly used in that field, because the current is what actually determines the intensity. Also you can tune the intensity more easy via current, than via voltage because of the (I think exponential) non-linear rise of the diode characteristic. In the end it should not be important, if you use constant current or constant voltage, as long as you don't overload the LED. I think that overload is the important point in your argument. You are right with Murphy.


text:
SMBus on ATTiny204
So I want to connect multiple LED Panels with dynamic addressing to a Master Controller.
Seems like SMBus should be able to do that, however I don't find any Library for the Arduino framework.
Does SMBus require Hardware implementation and if if works in Software is there a library for that and does it even work on the ATTiny?

SMBus and I2C are almost the same. Just a few specs between them. So... why SMBus and not I2C which is by far more ubiquitous?

@Majenko Because I really want the ARP feature of SMBus that enables me to use dynamic adressing. If there's a simpler solution to have dynamic adressing I'd love to hear that too

The ATMega TWI Arbitration module only (afaict) works in master mode. So you would have to write a bit-banged slave emulation with arbitration built in. Doable, but not nice.

@Majenko so is there a better solution?

ARP's your big sticking point. However since you need to allocate a UUID to each device anyway you could just allocate a unique I2C address to each device instead? Then you can scan the I2C bus looking for what I2C addresses exist.

@Majenko yes I thought about that, but the 7bit/10bit adress range is too small for my application. Chances that I got two or more panels with the same ID are too high

I designed a system once based around a single direction of UART transmission (TX->RX) and one single pulse indication in return with 24 bit addresses. That allowed for 16 million unique addresses, and I devised a tree-like scanning method to find all the devices that were present on the bus fairly rapidly without having to cycle through all 16 million addresses. You can see my thoughts on the protocol here: https://github.com/MajenkoProjects/LIBus/blob/master/PROTOCOL.md

@Majenko Interesting Idea, I thought about UART but with factory set and delivered QR Codes that contain the Adresses for the Master. I wasn't sure if multi TX to one RX works electrically with UART. Thank you!

Multi tx to single rx can be done, but it's tricky. If you want that way around maybe RS485 would be a better choice.

The AVR chips lack hardware support for bus arbitration when operating as a slave device in I2C, which would be required for it to work as SMBus with ARP.
You would have to write your own bit-banged driver to act as a slave whilst monitoring the SDA pin whenever it transmits to look for bus collisions.
A better solution would be to allocate each device a unique address using an address space of your choosing (to give you enough addresses for uniqueness) at build / programming time. A bus of some design (maybe RS485 would be a good choice for this) can then be scanned looking for, and cataloguing, what addresses are in use.


text:
Using both FastLED and Webserver without glitches possible?
I'm using an ESP8266 to control a short strip of WS2812 LEDs. I also want some way of remote Control so I'm looking into using a Web UI with the ESPAsyncWebServer library.
However using that Webserver makes the LEDs flicker so I tried disabling Interrupts
#define FASTLED_ALLOW_INTERRUPTS 0
#define FASTLED_INTERRUPT_RETRY_COUNT 2

That does help a bit, the flickering is less frequent but now there's some color glitches aswell.
All in all not usable.
So is there a way to get rid of all that flickering or is it just not possible to use the LEDs and a Webserver together when maintaining a high refresh rate?

might try websockets instead of http. the client code is about as simple and the "requests" tend to execute much faster without all the http overhead. you can also use a 2nd ESP to do web, talking to the LED ESP via serial, which is buffered and also low-impact.

Alternatively upgrading to a dual-core ESP32 would remove the problem and give you a more capable chip into the bargain...


text:
How can I control 2 servos separately using a joystick on an ATTiny85?
Prelude
I haven't done a lot of work in programming chips. The ATTiny85 is the first chip I've programmed, and I have the hang of the basics I think, but I don't have an in-depth understanding of it's capabilities and how to perform complex circuits with it.
The Issue
I cannot get the following to work: utilize any combination of PWM Pins with 2 Servos, and ADC (Analog to Digital Converter) Pins connected to a Joystick to control the servos using an ATTiny85.
My code works fine with an Arduino Uno R3. Porting it over to the ATTiny85 only lets me control 1 servo with 1 axis of the joystick (x or y).
As far as I can see from ATTiny85 Pinout, there are 3 PWM pins (PB0, PB1 and PB4) that I can use for the Servo data line, and 4 ADC Pins (PB2, PB3, PB4 and PB5) that I can use to send output from the joystick.
Swapping servos works fine - so I know they're not causing issues.
Swapping joystick axis works fine - so that's not it.
Running the code on the Arduino and viewing in the Serial Monitor shows that the joystick is writing correctly for both the X and Y axis - and is correctly mapping the coordinates to the serial output.
I can list out the different pins I've tried to use for the servos and the joystick - but at this point I think this is a capability issue of the ATTiny85 - and the latest pins I've tried are in the code.
I can give pictures/diagrams of my wiring for the servos and joysticks to the ATTiny85 if someone needs them, or of the wiring I use to program the ATTiny85 if it's useful.
I'm currently still debugging this issue and trying to find what's going wrong - but so far no luck. I haven't tried debugging the ATTiny85 with the serial monitor, but I've just been reprogramming it and trying different combinations of pins and code commented out. I will update the question as I discover more information.
Something strange
In my setup() code - the S1_.write(S1_Center) works, and the servo moves to the center of it's set limitations - but after that it is not responsive to the joystick. At least that tells me every time I run it that the servo is attached and able to receive a write() and so is functional - and leads me to believe that I have an issue with the Analog/Serial side of things, but I'm not sure.
Questions
Is it possible to control 2 servos with a joystick (X-axis for one servo, Y-axis for another - essentially 2 potentiometers in lieu of joystick) using an ATTiny85?
Am I using incorrect pins for the ATTiny85 to do this? ADC and PWM?
Is the issue with the code I'm using or is this a hardware constraint for the ATTiny85?
If anyone has any advice at the least it would be helpful. I know this question is to a somewhat specific scenario - but in doing my (apparently not very good) research I can only find very basic - non analog/serial ways people drive servos which I already know how to do.
Here is the code I've written that works standalone with Arduino but not with the ATTiny85.
#include <Servo_ATTinyCore.h>

Servo S1_;  // create servo object to control a servo
Servo S2_;  // create servo object to control a servo

//Joystick 1 inputs (Joystick -> Arduino)
int J1_VRx = PIN_PB3; //Attiny85 PB3 (Physical pin 2) - as per SpenceKonde ATtinyCore Github 'You cannot use the Pxn notation (ie, PB2, PA1, etc) to refer to pins ... use PIN_Pxn (ex, PIN_PB2)'
int J1_VRy = PIN_PB2; // Attiny85 PB4 (Physical pin 7)
int J1_SW = PIN_PB4; // Attiny85 PB2 (Physical pin 3)

//Joystick 1 variables
int J1_xPosition = 0;
int J1_yPosition = 0;
int J1_SW_state = 0;
boolean J1_SW_pressed = false;
//int J1_SW_state_read = 0;
//boolean buttonPressed
int J1_mapX = 0;
int J1_mapY = 0;

//Servo output (Arduino -> Servo)
int S1_Output = PIN_PB1;
int S2_Output = PIN_PB0;

//Servo Variables
int S1_Limits[2] = {0,180};  // set limitations (min/max: 0->180)
int S2_Limits[2] = {0,180};  // set limitations (min/max: 0->180)
boolean refresh = false;  // toggle refresh on/off
int S1_Degree = 0;
int S2_Degree = 0;
int S1_Speed = 0;
int S2_Speed = 0;
int S1_Speed_Limit = 2; //controls how quickly the servo can move
int S2_Speed_Limit = 2; //controls how quickly the servo can move
int speedModes[3] = {1,2,3}; //Define the speeds which can be toggled between
int speedMode = 2; //Set initial speed mode (speedModes[1] if this value is 1)

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

  //Assign Joystick 1 pins
  pinMode(J1_VRx, INPUT);
  pinMode(J1_VRy, INPUT);
  pinMode(J1_SW, INPUT_PULLUP);

  //Assign Servo pin
  S1_.attach(S1_Output);
  S2_.attach(S2_Output);

  //Get center of Servo limitations
  int S1_Center = ((S1_Limits[0]/2) + (S1_Limits[1]/2));
  int S2_Center = ((S2_Limits[0]/2) + (S2_Limits[1]/2));

  //Send servos to center
  S1_.write(S1_Center);
  S2_.write(S2_Center);

  //Set servo current degrees as at center
  S1_Degree = S1_Center;
  S2_Degree = S2_Center;

  //Set servo initial speed limit
  S1_Speed_Limit = speedModes[speedMode - 1];
  S2_Speed_Limit = speedModes[speedMode - 1];

}

void loop() {

  //Reset servo direction speeds
  S1_Speed = 0;
  S2_Speed = 0;

  //Read Joystick 1 inputs
  J1_xPosition = analogRead(J1_VRx);
  J1_yPosition = analogRead(J1_VRy);
  J1_SW_state = digitalRead(J1_SW);
  J1_mapX = map(J1_xPosition, 0, 1023, -1024, 1024); //X-position of joystick
  J1_mapY = map(J1_yPosition, 0, 1023, -1024, 1024); //Y-position of joystick

  //Fix offsets for joysticks (custom fixes because these joysticks aren't perfect :/)
  J1_mapX += 6;
  J1_mapY += 20;

  delay(10);

  boolean J1_SW_toggled = false;
  //If the button is down
  if(J1_SW_state == 0) {
    J1_SW_pressed = true;
    //Joystick button pressed
  }
  //If the button was down and is now up
  if(J1_SW_pressed == true && J1_SW_state == 1) {
    J1_SW_pressed = false;
    J1_SW_toggled = true;
    //Joystick button released
  }

  //Cycle the speed mode for servos 1, 2 and 3
  if(J1_SW_toggled) {
    J1_SW_toggled = false;
    if (speedMode != speedModes[(sizeof(speedModes) / sizeof(int)) - 1]) { //This is how to get length of speedModes array of byte type int
      speedMode += 1;
    }
    else {
      speedMode = 1;
    }
    S1_Speed_Limit = speedModes[speedMode - 1];
    S2_Speed_Limit = speedModes[speedMode - 1];
  }

  int stutterSetting = 100; //+- buffer to keep servos from moving due to imperfect readouts from joysticks

  if(J1_mapY > stutterSetting || J1_mapY < -stutterSetting) {
    S1_Speed = map(J1_mapY, -512, 512, S1_Speed_Limit, -S1_Speed_Limit);
  }
  if(J1_mapX > stutterSetting || J1_mapX < -stutterSetting) {
    S2_Speed = map(J1_mapX, -512, 512, S2_Speed_Limit, -S2_Speed_Limit);
  }

  if(S1_Speed != 0) {
    if((S1_Degree + S1_Speed) < S1_Limits[1] && (S1_Degree + S1_Speed) > S1_Limits[0]) {
      S1_Degree += S1_Speed;
      S1_.write(S1_Degree);
      delay(10);
    }
  }

  if(S2_Speed != 0) {
    if((S2_Degree + S2_Speed) < S2_Limits[1] && (S2_Degree + S2_Speed) > S2_Limits[0]) {
      S2_Degree += S2_Speed;
      S2_.write(S2_Degree);
      delay(10);
    }
  }

//  Serial.print("J1_X: ");
//  Serial.print(J1_mapX);
//  Serial.print(" | J1_Y: ");
//  Serial.print(J1_mapY);
//  Serial.print(" | S1_Speed: ");
//  Serial.print(S1_Speed);
//  Serial.print(" | S1_Degree: ");
//  Serial.print(S1_Degree);
//  Serial.print(" | S2_Speed: ");
//  Serial.print(S2_Speed);
//  Serial.print(" | S2_Degree: ");
//  Serial.println(S2_Degree);
}

You could try to pinpoint the problem by outputting the data on the ATtiny over Serial (there are TX only Software Serial libraries, which are rather small and only need one pin, which you then can connect to the PC via an Arduino). Look at the ADC measurements and the results of your calculation. It will be way easier to fix, when we know, where exactly the problem occurs


text:
connecting a MPU6050 and sabertooth 2x12 to a single Arduino Uno
so im using the sabertooth speed controller to control the two motors on my lawn mower and im trying to use the MPU6050 to keep the lawn mower straight. The problem im facing is that im trying to use the sabertooth and the MPU6050 on a single Arduino and the sabertooth uses the baud rate of 9600 but the MPU6050 uses 115200 and im trying to use a single .ino file to control everything. I want to receive the data from the MPU6050 and based of that make a program to move the motor so that the mower will go in a straight line and such.

so, what's your question?

I know only of MPU6050 boards, that use I2C. Are you sure your MPU is using Serial (UART)?