text:
Strange Character In Tempurture Reading
Can anyone identify this character?

Thats an A with a circumflex. Does that answer your question? If you want to know why it is there you need to provide way more information, including your code

Everything @chrisl said. Plus you should know that there are multiple, at least two, Unicode sequences that will generate that same representation.

The degree sign (°) is Unicode character U+00B0 (i.e. code point 0xb0).
In UTF-8, it is encoded as the two-byte sequence 0xc2 0xb0. Your browser
is not aware that the page is encoded as UTF-8, and for some reason it
believed it is ISO-8859-1. This two-byte sequence, interpreted as
ISO-8859-1, represents the two characters “Â” and “°”.
The simplest solution might be to add
<meta charset="utf-8">

at the top of the <head> element of the Web page.

… or use the ° html entity.

OUTSTANDING!
Edgar's single line suggestion solved the problem! The ESP32 page looks perfect now.

@RachelR And Grimaldi's suggestion is the Only Right solution. ;-) Please mark the answer you see fit best as "accepted". You might want to take the [tour] to learn how this site works.

@thebusybee: Do you mean there is something Wrong™ in encoding Web pages in UTF-8?

It depends. ;-) Say you want to support the most systems, not only Win, Mac, and Linux, then you need to assume that not all of them know UTF-8. As someone living in a country with non-ASCII characters in written language, one of the more annoying problems is the lack of encoding such characters as HTML entities. Anyway, it's alright, if you accept rare cases of "strange characters".

@thebusybee: You know of a Web browser that understands ° but not ° written in UTF-8? Is that Mosaic, or some other retro-computing thing? It's 2023 now. UTF-8 has been around for 30 years, and is the undisputed de facto standard encoding of the Web over the whole planet. I firmly believe it's time to move on and leave pre-UTF-8 browsers to computer history museums.

Oh, it's not about web servers, but web browsers. And (without having tried) there are a lot of old and small computers still in use that cannot run a full-fledged browser like Firefox or Chromium. For example, I have an old (20+ years) notebook running Void Linux just fine on the work bench. It is perfect for most development tasks, but not for "modern" web surfing. Not to speak of hobbyists still working with their ZX81. :-D Yes, there are such, but granted, their number is small.

And the OP's use case is apparently something like environment values provided by a web server, well in the realm of IoT. To use limited devices as "display" is quite common with this. -- Final line: If a standard is more compatible, even old, why should one use a less compatible standard, just because it is newer? Both work with modern browsers. But only the old one works with limited browsers.

@thebusybee: I do understand it's about browsers. It would be interesting to test ° vs. ° on your old notebook. What browser does it run? Note that parsing UTF-8 requires less computing resources than parsing named references. IMO, the value of UTF-8 lies in the readability of the source, which I do value a lot.

Let us save the time, I cannot afford to investigate this detail. I just made a general remark targeting the usage of old standards compared to new standards just because of its broader support . It does not make your answer wrong, and I suggested to accept it.

@thebusybee: Only tangentially related to this discussion... I just stumbled on WebOne, a HTTP proxy that makes old browsers usable in the modern Web. Looks like a cool project, and I thought it may be of interest to you.


text:
delayMIcroseconds and micros execution time not explainable
i just experimented with the timing accuracy of my Arduino Uno R3 using this code:
unsigned long beginTime;
unsigned long endTime;

void setup() {
  Serial.begin(9600); // open a serial port
}

void loop() {
  beginTime = micros();
  delayMicroseconds(200);
  endTime = micros();
  delay(500);
  Serial.println(endTime-beginTime);
  delay(500);
}

The results I got are (just an excerpt):
200
204
200
200
204
204
204
200
212
208
212
204
204

I tried to understand this behavior, read this link Can I make delayMicroseconds more accurate?.
Due to the timing of micros (4 µs) I would understand values between 200 and 208. But why do I get occasional values of 212 microseconds? I'm kinda curious, since I bought the Arduino because of bare-metal programming and bounded execution times.

Maybe you good some interrupts running during your measurement occasionally. That would make the actual execution time longer.

try to add Serial.flush() to wait until Serial finishes

@Juraj: Thanks for the suggestion. I tried it (i.e. added a Serial.flush(); after the println, but it did not work.

@chrisl: Thanks, I added noInterrupts(); before the first micros(); and interrupts(); after endTime = micros();. I got consistend values, either 200 or 204 microseconds, which was expected :).
Do you know, which interrupts might be triggered  while running such a simple program?  I thought, Serial.flush(); might stop any possible interrupt, but that was not the case..

The Arduino core uses a timer interrupt for timekeeping.

The Arduino core uses hardware Timer0 with its ISR (Interrupt Service Routine) for timekeeping. While delayMicroseconds() directly uses the value of the hardware timer, delay() and millis() are handled by the ISR. It will be called regularly.
If the ISR is getting executed during your measurement, then the execution time of the ISR will add to the execution time of your measured code. Thus you get a higher count occasionally.
To prevent this you can either deactivate all interrupts (via noInterrupts()) or deactivate this specific interrupt, either by stopping Timer0:
TCCR0B &= ~( (1 << CS02) | (1 << CS01) | (1 << CS00) );

or by letting the timer run, but deactivating its interrupts:
TIMSK0 = 0;

For details about this have a look at the datasheet of the Atmega328p, which is the microcontroller on the Arduino Uno.

source: Stack Exchange

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

sort: votes


text:
How can I get servos to not brownout my Arduinos and power supply?
I have a problem with a project where one servo is resetting (browning out) two Arduino Pro Minis running 3.3v/8mHz. The two Arduinos are connected by SoftwareSerial on pins 9 and 10 and the slave sends yaw data to the master Arduino obtained from an MPU9250 breakout board. The power supply can supply 1 A of current. The servo is a small 2g servo that takes 3.3v at 50mA when moving (measured, not from the datasheet). Everything is hooked up on a breadboard. In case you're wondering, I am using an adaptation of the ServoTimer2 library to control the servos so as to not interfere with SoftwareSerial. I am baffled as to why one small servo is resetting two Arduinos. The Arduinos, along with the MPU9250, are only drawing 10mA. Could back EMF be causing the brownout?
In the past, I have done a similar circuit but with only one Arduino obtaining sensor data and not sending it over SoftwareSerial. This works completely fine with two servos, a Pro Mini, and an MPU9250 breakout board. This leads me to think it is some sort of software issue.
I have already received some guidance on the Arduino Discord stating to connect ceramic capacitors close to the servos, and this seems to sort of work, but I'm wondering if there might be a software way to do it with the least number of components possible.
Any help would be greatly appreciated!

RE: "Everything is hooked up on a breadboard" - How about some images of the breadboard setup?

RE: "This leads me to think it is some sort of software issue" - Can you show us the code, or is it top secret?

use a separate power supply for the motors

Note: Commonly you cannot use software to circumvent physics.
Your symptoms show that the initial current of the servo is too high for your power concept to maintain the voltage. Therefore your Nanos brown out.
An electric motor can easily take a multiple of its average current on acceleration. If blocked, and in the first moment it is blocked by the inertia, you can observe factors in low tens. From 50 mA to 1 A it's just a factor of 20...
Please note that servos often control their motors with PWM, and you measure only the average. During the "active" state the current is higher, and depending on the motor's inductive properties can have "strange" wave forms.
Additionally, each wire adds an inductive and resistive component in series with your Nanos and the servo. The shorter and thicker the wires, the better.
So your case looks quite simple, and you have options:

Decouple your power supply with appropriate capacitors. Ceramics with some tens of nF and an electrolyte or tantalum capacitor with some µF are common to provide the necessary current "reservoir" for the initial moment in different frequency ranges. Put them near the servo(s).
Use a separate power supply for the servo(s). Do not forget to connect the grounds. But also here you might need capacitor(s) to avoid browning out the servo.

You are seeing classic signs of power supply overload. Those motors can draw upto 10x there operating current when starting. Transients etc that are occuring are to fast for your meter to see but the electronics does. To view that you need a scope and a current probe. My recommendation is to get a larger power supply probably in the 3A range.

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


text:
UART SERCOM on Pins 11-13 Arduino M0 (SAMD21)
I am a newb at coding. Does anyone have any code laying around or some time to write some to send data over UART SERCOM on pins 11/12/13 on a SAMD21 board like the Arduino M0? I am trying to send a double from my LightAPRS W-2 board but can't use I2C and this is my only option.

why is your time more valuable than anyone else's time? ... what is preventing you from doing reasearch and trying to write your own code? ... there are many examples and tutorials available about Arduino serial communication ... please make an attempt to write the code and post the result of your effort ... describe any problems you are seeing and copy/paste errors here

See https://learn.adafruit.com/using-atsamd21-sercom-to-add-more-spi-i2c-serial-ports/creating-a-new-serial


text:
Cannot connect Arduino Mega 2560
I was able to work with the same Arduino on the same laptop yesterday. However, the Arduino IDE is unable to connect the Arduino Mega 2560 today. I tried with a different Arduino Mega 2560 but the Arduino IDE doesn't connect it. My laptop is able to recognize COM Port but in the Arduino IDE the "Tools - Ports option" is missing.

what is your question? ..... which version of Arduino IDE are you using?

I am using Arduino IDE 2.0.3. My question is that how do I connect my Arduino Mega 2560 to the Arduino IDE on my laptop? As the first picture shows, the Device Manager is able to recognize the device. However, in the Arduino IDE, it said "NO PORTS DISCOVERED". I have read most of the articles online and tried their methods but none of them works. I am wondering why my laptop can recognize the device while my Arduino IDE cannot. Furthermore, the Arduino IDE can connect with the device until yesterday. I changed nothing on my laptop.

2.0.3 may be broken ... try earlier versions ... or try the nightly build


text:
How to get an angle from two ultrasonic sensors
I am building a chair for a special 4 year-old with cerebral palsy, I thought it would be a good idea to add two distance sensors on each arm of the chair to measure the angle at which he presses buttons(a gaming chair).  Normally I would figure this out on my own but I don't have much time to finish so I thought i'd ask the experts.  What's the best way to use to ultrasonic sensors data to produce an angle?

angle at which he presses buttons ... please explain what this means

ultrasonic sensors measure distance ... the angle would have to be converted to distance mechanically

this question is not really about an arduino ... it is about an unspecified electro-mechanical device

Your question is unclear. You say you want "...to measure the angle at which he presses buttons". I don't know what that means.
If you're using ultrasonic sensors those measure distance. buttons tend to be fixed in place. Maybe you're  talking about having a joystick on the gaming chair? Two-axis joysticks should let you input an X and a y value.
If you're trying to calculate the angle between a pair of ultrasonic sensors and something that is in their "line of sight" (line of sound?) then you'd use trig.
You would have your sensors at a known distance from each other. You'd measure the distance to each sensor, form a triangle out of all 3 distances, and use the law of cosines to calculate the angles.
The formulas from that page are:
cos(C) =  a² + b² − c²/2ab
cos(A) =  b² + c² − a²/2bc
cos(B) =  c² + a² − b²/2ca
(Where upper case letters denote the angles of the triangle at a vertex, and lower-case letters denote the legs of the triangle. See the illustration on that page.)
 SensorA
    \
     \      SensorB
      \       /
       \     /
        \   /
         \ /
          V
        object

(one leg would be the SensorA-to-SensorB distance. Another leg would be the SensorA-to-object distance, and the 3rd leg would be the SensorB-to-object distance.)
However, all of that will only work if the object you are detecting is in the range of angles in which your sensors are able to detect objects, and in the range of distances they provide accurate readings.
Edit:
When I copied the formulas from the source site, the superscripts were lost. I've edited them back so the formulas are more readable.


text:
esp8266 set up?
A few weeks ago I was told to incorporate wifi with an arduino project so I ordered a few arduino ESP8266 boards but when I couldn't figure it out I switched to a simpler board AKA(Arduino Nano IOT 33).  Now that I am done with my time constrained project I would like to learn about the esp8266 can anyone please explain the different settings in the tools
See image down below for example.:


text:
Arduino - line follower car
I want to build a line follower car, but I dont have Infrared sensors, so want to run the car, without sensors as a test
I have Motor Driver on top of Arduino UNO R3, all connections as expected, but all wheels are not spinning. I have no idea on which one is Motor1, 2,...
Code: https://create.arduino.cc/projecthub/adamsstephen/controlling-an-l9100-motor-driver-board-using-arduino-cc5618#toc-step-1--placing-electronics-0
int Motor[8] ; // Array for all Motor Output pins, one more than required

void setup() {
  Motor[1] = 4; // Set output numbers for ports
  Motor[2] = 5;
  Motor[3] = 6;
  Motor[4] = 7;
  Motor[5] = 8;
  Motor[6] = 9; // Set up Port for LED on Head of Arm.
  Motor[7] = 10; // Forward / Reverse selection for ALL motors
  // Switch connected to GND and A0, to locally turn off motors while testing.
  pinMode(Motor[1], OUTPUT); // Open Port to operate Motor on Pincers Forward = In Reverse = Out
  pinMode(Motor[2], OUTPUT); // Open Port to operate Motor Up= High  Reverse = Down
  pinMode(Motor[3], OUTPUT); // Open Port to operate Motor Forward = Forward Reverse = Backward
  pinMode(Motor[4], OUTPUT); // Open Port to operate Motor Wrist Forward = Up Reverse = Down
  pinMode(Motor[5], OUTPUT); // Open Port to operate Motor base Rotate Forward = Right Reverse = Left
  pinMode(Motor[6], OUTPUT); // Open Port to operate LED on head of Arm HIGH = ON LOW = OFF
  pinMode(Motor[7], OUTPUT); // Open Port for Forward / Reverse selection for ALL motors
}
void loop() {
    digitalWrite(Motor[6], LOW); // Turn off LED.
    if (analogRead(A0)< 1){ // switch ON
    digitalWrite(Motor[1], HIGH); // Turn on Motor 1. HIGH turns it on! Pincers
    digitalWrite(Motor[7], LOW); // HIGH is Forward, Reverse is OFF.
   Serial.println(analogRead(A0));
}
    if (analogRead(A0) > 200  ){    // switch OFF
    digitalWrite(Motor[1], LOW); // Turn on Motor 1. HIGH turns it on!
    digitalWrite(Motor[7], LOW); // HIGH is Forward, Reverse is OFF.
   Serial.println(analogRead(A0));
}
    delay(200); // debounce the switch action
}

I commented the whole loop(), still some wheels are spinning. how is that possible? How can I know - which one is Motor1 ,...M4 and the corresponding Arduino pin numbers.
I want to spin all 4 wheels/ dc motors

Welcome to Arduino Stack Exchange. Please edit your question with add your schematics

why are you trying to control seven motors when you have trouble controlling one? ... reduce your sketch so that it controls only one motor ... figure out which pin you are controlling with your sketch and connect the motor to that pin .... when you get that working, then change to a different pin (edit the sketch) ... keep going until you tested all seven output pins using only one motor ... then try to run two motors  .... etc. etc.

@jsotola I have no idea, that is why I am here. I commented all lines except - PinMode Motor[4] and 3 wheels are spinning. It is literally 1 lines of code and 3 wheels spinning. One time same code - only 1 wheel spinning. So I am seeking for an expert to give a useful answer. thanks

Try to grounds all pinout motors exception one motor wire opened at 7404 chip. That's @jsotola means

no, that is not what I mean ... remove all motors ... remove all wires ... connect one motor ... connect only the wires necessary to run the one motor ... run a simple sketch that turns on the motor, pauses for 2 seconds, turns off the motor ... do not put any code in loop() ... put all code in setup()

Apologies, but the interface to me is the motor driver - Motor Driver Shield L293D. which I think supports 4 wheels [has M1/2/3/4], is placed on top of Uno R3. So, I do not know underlying Arduino  pins. Note: I am connecting via USB and testing, hoping that it has enough voltage. Cant believe how this 1 line -  pinMode(Motor[4], OUTPUT);  is spinning 2 wheels and my head too.

L9100 or l293d is same to me, you can try jsotola suggest. That's very helpful and provide us more informative with add your schematic

Looks like it is voltage issue. the car has, 4 dual shift motors. supplied 2 x 18650 and 3 wheels spinning, sometimes 4. sometimes 1, sometimes 2, sometimes all 4, sometimes only 1 in reverse. Inconsistent results. Not sure how much power needs to be supplied. Do dual shaft  require double the  single shaft ?


text:
Use NeoSWSerial instead of SoftwareSerial with Adafruit Fingerprint Library
I'm using the FPM10A fingerprint sensor together with the Adafruit Fingerprint Library. I also have a GPS and Bluetooth module on the board already (connected to an Arduino UNO) and I'm using the neoSWserial library to communicate with them. I would like to use neoSWserial to communicate with the fingerprint sensor.
I've replaced all the instances of SoftwareSerial with NeoSWSerial in the respective .h and .cpp files but now the program says
'Did not find fingerprint sensor'

For completeness here's the sketch, .h and .cpp file:
/***************************************************
  This is an example sketch for our optical Fingerprint sensor

  Designed specifically to work with the Adafruit BMP085 Breakout
  ----> http://www.adafruit.com/products/751

  These displays use TTL Serial to communicate, 2 pins are required to
  interface
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
 ****************************************************/

#include <Adafruit_Fingerprint.h>

// On Leonardo/Micro or others with hardware serial, use those! #0 is green wire, #1 is white
// uncomment this line:
// #define mySerial Serial1

// For UNO and others without hardware serial, we must use software serial...
// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino  (WHITE wire)
// comment these two lines if using hardware serial
NeoSWSerial mySerial(12, 13);

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

void setup()
{
  Serial.begin(9600);
  while (!Serial);  // For Yun/Leo/Micro/Zero/...
  delay(100);
  Serial.println("\n\nAdafruit finger detect test");

  // set the data rate for the sensor serial port
  finger.begin(57600);
  delay(5);
  if (finger.verifyPassword()) {
    Serial.println("Found fingerprint sensor!");
  } else {
    Serial.println("Did not find fingerprint sensor :(");
    while (1) { delay(1); }
  }

  finger.getTemplateCount();
  Serial.print("Sensor contains "); Serial.print(finger.templateCount); Serial.println(" templates");
  Serial.println("Waiting for valid finger...");
}

void loop()                     // run over and over again
{
  getFingerprintIDez();
  delay(50);            //don't ned to run this at full speed.
}

uint8_t getFingerprintID() {
  uint8_t p = finger.getImage();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image taken");
      break;
    case FINGERPRINT_NOFINGER:
      Serial.println("No finger detected");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_IMAGEFAIL:
      Serial.println("Imaging error");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }

  // OK success!

  p = finger.image2Tz();
  switch (p) {
    case FINGERPRINT_OK:
      Serial.println("Image converted");
      break;
    case FINGERPRINT_IMAGEMESS:
      Serial.println("Image too messy");
      return p;
    case FINGERPRINT_PACKETRECIEVEERR:
      Serial.println("Communication error");
      return p;
    case FINGERPRINT_FEATUREFAIL:
      Serial.println("Could not find fingerprint features");
      return p;
    case FINGERPRINT_INVALIDIMAGE:
      Serial.println("Could not find fingerprint features");
      return p;
    default:
      Serial.println("Unknown error");
      return p;
  }

  // OK converted!
  p = finger.fingerFastSearch();
  if (p == FINGERPRINT_OK) {
    Serial.println("Found a print match!");
  } else if (p == FINGERPRINT_PACKETRECIEVEERR) {
    Serial.println("Communication error");
    return p;
  } else if (p == FINGERPRINT_NOTFOUND) {
    Serial.println("Did not find a match");
    return p;
  } else {
    Serial.println("Unknown error");
    return p;
  }

  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);

  return finger.fingerID;
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
  uint8_t p = finger.getImage();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.image2Tz();
  if (p != FINGERPRINT_OK)  return -1;

  p = finger.fingerFastSearch();
  if (p != FINGERPRINT_OK)  return -1;

  // found a match!
  Serial.print("Found ID #"); Serial.print(finger.fingerID);
  Serial.print(" with confidence of "); Serial.println(finger.confidence);
  return finger.fingerID;
}

The header file:
#ifndef ADAFRUIT_FINGERPRINT_H
#define ADAFRUIT_FINGERPRINT_H

/***************************************************
  This is a library for our optical Fingerprint sensor

  Designed specifically to work with the Adafruit Fingerprint sensor
  ----> http://www.adafruit.com/products/751

  These displays use TTL Serial to communicate, 2 pins are required to
  interface
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
 ****************************************************/

#include "Arduino.h"
#if defined(__AVR__) || defined(ESP8266)
#include <NeoSWSerial.h>
#elif defined(FREEDOM_E300_HIFIVE1)
#include <NeoSWSerial.h>
#define NeoSWSerial NeoSWSerial
#endif

#define FINGERPRINT_OK 0x00
#define FINGERPRINT_PACKETRECIEVEERR 0x01
#define FINGERPRINT_NOFINGER 0x02
#define FINGERPRINT_IMAGEFAIL 0x03
#define FINGERPRINT_IMAGEMESS 0x06
#define FINGERPRINT_FEATUREFAIL 0x07
#define FINGERPRINT_NOMATCH 0x08
#define FINGERPRINT_NOTFOUND 0x09
#define FINGERPRINT_ENROLLMISMATCH 0x0A
#define FINGERPRINT_BADLOCATION 0x0B
#define FINGERPRINT_DBRANGEFAIL 0x0C
#define FINGERPRINT_UPLOADFEATUREFAIL 0x0D
#define FINGERPRINT_PACKETRESPONSEFAIL 0x0E
#define FINGERPRINT_UPLOADFAIL 0x0F
#define FINGERPRINT_DELETEFAIL 0x10
#define FINGERPRINT_DBCLEARFAIL 0x11
#define FINGERPRINT_PASSFAIL 0x13
#define FINGERPRINT_INVALIDIMAGE 0x15
#define FINGERPRINT_FLASHERR 0x18
#define FINGERPRINT_INVALIDREG 0x1A
#define FINGERPRINT_ADDRCODE 0x20
#define FINGERPRINT_PASSVERIFY 0x21

#define FINGERPRINT_STARTCODE 0xEF01

#define FINGERPRINT_COMMANDPACKET 0x1
#define FINGERPRINT_DATAPACKET 0x2
#define FINGERPRINT_ACKPACKET 0x7
#define FINGERPRINT_ENDDATAPACKET 0x8

#define FINGERPRINT_TIMEOUT 0xFF
#define FINGERPRINT_BADPACKET 0xFE

#define FINGERPRINT_GETIMAGE 0x01
#define FINGERPRINT_IMAGE2TZ 0x02
#define FINGERPRINT_REGMODEL 0x05
#define FINGERPRINT_STORE 0x06
#define FINGERPRINT_LOAD 0x07
#define FINGERPRINT_UPLOAD 0x08
#define FINGERPRINT_DELETE 0x0C
#define FINGERPRINT_EMPTY 0x0D
#define FINGERPRINT_SETPASSWORD 0x12
#define FINGERPRINT_VERIFYPASSWORD 0x13
#define FINGERPRINT_HISPEEDSEARCH 0x1B
#define FINGERPRINT_TEMPLATECOUNT 0x1D

//#define FINGERPRINT_DEBUG

#define DEFAULTTIMEOUT 1000 ///< UART reading timeout in milliseconds

///! Helper class to craft UART packets
struct Adafruit_Fingerprint_Packet {

  /**************************************************************************/
  /*!
      @brief   Create a new UART-borne packet
      @param   type Command, data, ack type packet
      @param   length Size of payload
      @param   data Pointer to bytes of size length we will memcopy into the
     internal buffer
  */
  /**************************************************************************/

  Adafruit_Fingerprint_Packet(uint8_t type, uint16_t length, uint8_t *data) {
    this->start_code = FINGERPRINT_STARTCODE;
    this->type = type;
    this->length = length;
    address[0] = 0xFF;
    address[1] = 0xFF;
    address[2] = 0xFF;
    address[3] = 0xFF;
    if (length < 64)
      memcpy(this->data, data, length);
    else
      memcpy(this->data, data, 64);
  }
  uint16_t start_code; ///< "Wakeup" code for packet detection
  uint8_t address[4];  ///< 32-bit Fingerprint sensor address
  uint8_t type;        ///< Type of packet
  uint16_t length;     ///< Length of packet
  uint8_t data[64];    ///< The raw buffer for packet payload
};

///! Helper class to communicate with and keep state for fingerprint sensors
class Adafruit_Fingerprint {
public:
#if defined(__AVR__) || defined(ESP8266) || defined(FREEDOM_E300_HIFIVE1)
  Adafruit_Fingerprint(NeoSWSerial *ss, uint32_t password = 0x0);
#endif
  Adafruit_Fingerprint(HardwareSerial *hs, uint32_t password = 0x0);

  void begin(uint32_t baud);

  boolean verifyPassword(void);
  uint8_t getImage(void);
  uint8_t image2Tz(uint8_t slot = 1);
  uint8_t createModel(void);

  uint8_t emptyDatabase(void);
  uint8_t storeModel(uint16_t id);
  uint8_t loadModel(uint16_t id);
  uint8_t getModel(void);
  uint8_t deleteModel(uint16_t id);
  uint8_t fingerFastSearch(void);
  uint8_t getTemplateCount(void);
  uint8_t setPassword(uint32_t password);
  void writeStructuredPacket(const Adafruit_Fingerprint_Packet &p);
  uint8_t getStructuredPacket(Adafruit_Fingerprint_Packet *p,
                              uint16_t timeout = DEFAULTTIMEOUT);

  /// The matching location that is set by fingerFastSearch()
  uint16_t fingerID;
  /// The confidence of the fingerFastSearch() match, higher numbers are more
  /// confidents
  uint16_t confidence;
  /// The number of stored templates in the sensor, set by getTemplateCount()
  uint16_t templateCount;

private:
  uint8_t checkPassword(void);
  uint32_t thePassword;
  uint32_t theAddress;
  uint8_t recvPacket[20];

  Stream *mySerial;
#if defined(__AVR__) || defined(ESP8266) || defined(FREEDOM_E300_HIFIVE1)
  NeoSWSerial *swSerial;
#endif
  HardwareSerial *hwSerial;
};

#endif

And the .cpp file:
/***************************************************
  This is a library for our optical Fingerprint sensor

  Designed specifically to work with the Adafruit Fingerprint sensor
  ----> http://www.adafruit.com/products/751

  These displays use TTL Serial to communicate, 2 pins are required to
  interface
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
 ****************************************************/

#include "Adafruit_Fingerprint.h"

//#define FINGERPRINT_DEBUG

#if ARDUINO >= 100
#define SERIAL_WRITE(...) mySerial->write(__VA_ARGS__)
#else
#define SERIAL_WRITE(...) mySerial->write(__VA_ARGS__, BYTE)
#endif

#define SERIAL_WRITE_U16(v)                                                    \
  SERIAL_WRITE((uint8_t)(v >> 8));                                             \
  SERIAL_WRITE((uint8_t)(v & 0xFF));

#define GET_CMD_PACKET(...)                                                    \
  uint8_t data[] = {__VA_ARGS__};                                              \
  Adafruit_Fingerprint_Packet packet(FINGERPRINT_COMMANDPACKET, sizeof(data),  \
                                     data);                                    \
  writeStructuredPacket(packet);                                               \
  if (getStructuredPacket(&packet) != FINGERPRINT_OK)                          \
    return FINGERPRINT_PACKETRECIEVEERR;                                       \
  if (packet.type != FINGERPRINT_ACKPACKET)                                    \
    return FINGERPRINT_PACKETRECIEVEERR;

#define SEND_CMD_PACKET(...)                                                   \
  GET_CMD_PACKET(__VA_ARGS__);                                                 \
  return packet.data[0];

/***************************************************************************
 PUBLIC FUNCTIONS
 ***************************************************************************/

#if defined(__AVR__) || defined(ESP8266) || defined(FREEDOM_E300_HIFIVE1)
/**************************************************************************/
/*!
    @brief  Instantiates sensor with Software Serial
    @param  ss Pointer to NeoSWSerial object
    @param  password 32-bit integer password (default is 0)
*/
/**************************************************************************/
Adafruit_Fingerprint::Adafruit_Fingerprint(NeoSWSerial *ss,
                                           uint32_t password) {
  thePassword = password;
  theAddress = 0xFFFFFFFF;

  hwSerial = NULL;
  swSerial = ss;
  mySerial = swSerial;
}
#endif

/**************************************************************************/
/*!
    @brief  Instantiates sensor with Hardware Serial
    @param  hs Pointer to HardwareSerial object
    @param  password 32-bit integer password (default is 0)

*/
/**************************************************************************/
Adafruit_Fingerprint::Adafruit_Fingerprint(HardwareSerial *hs,
                                           uint32_t password) {
  thePassword = password;
  theAddress = 0xFFFFFFFF;

#if defined(__AVR__) || defined(ESP8266) || defined(FREEDOM_E300_HIFIVE1)
  swSerial = NULL;
#endif
  hwSerial = hs;
  mySerial = hwSerial;
}

/**************************************************************************/
/*!
    @brief  Initializes serial interface and baud rate
    @param  baudrate Sensor's UART baud rate (usually 57600, 9600 or 115200)
*/
/**************************************************************************/
void Adafruit_Fingerprint::begin(uint32_t baudrate) {
  delay(1000); // one second delay to let the sensor 'boot up'

  if (hwSerial)
    hwSerial->begin(baudrate);
#if defined(__AVR__) || defined(ESP8266) || defined(FREEDOM_E300_HIFIVE1)
  if (swSerial)
    swSerial->begin(baudrate);
#endif
}

/**************************************************************************/
/*!
    @brief  Verifies the sensors' access password (default password is
   0x0000000). A good way to also check if the sensors is active and responding
    @returns True if password is correct
*/
/**************************************************************************/
boolean Adafruit_Fingerprint::verifyPassword(void) {
  return checkPassword() == FINGERPRINT_OK;
}

uint8_t Adafruit_Fingerprint::checkPassword(void) {
  GET_CMD_PACKET(FINGERPRINT_VERIFYPASSWORD, (uint8_t)(thePassword >> 24),
                 (uint8_t)(thePassword >> 16), (uint8_t)(thePassword >> 8),
                 (uint8_t)(thePassword & 0xFF));
  if (packet.data[0] == FINGERPRINT_OK)
    return FINGERPRINT_OK;
  else
    return FINGERPRINT_PACKETRECIEVEERR;
}

/**************************************************************************/
/*!
    @brief   Ask the sensor to take an image of the finger pressed on surface
    @returns FINGERPRINT_OK on success
    @returns FINGERPRINT_NOFINGER if no finger detected
    @returns FINGERPRINT_PACKETRECIEVEERR on communication error
    @returns FINGERPRINT_IMAGEFAIL on imaging error
*/
/**************************************************************************/
uint8_t Adafruit_Fingerprint::getImage(void) {
  SEND_CMD_PACKET(FINGERPRINT_GETIMAGE);
}

/**************************************************************************/
/*!
    @brief   Ask the sensor to convert image to feature template
    @param slot Location to place feature template (put one in 1 and another in
   2 for verification to create model)
    @returns FINGERPRINT_OK on success
    @returns FINGERPRINT_IMAGEMESS if image is too messy
    @returns FINGERPRINT_PACKETRECIEVEERR on communication error
    @returns FINGERPRINT_FEATUREFAIL on failure to identify
   fingerprint features
    @returns FINGERPRINT_INVALIDIMAGE on failure to identify
   fingerprint features
*/
uint8_t Adafruit_Fingerprint::image2Tz(uint8_t slot) {
  SEND_CMD_PACKET(FINGERPRINT_IMAGE2TZ, slot);
}

/**************************************************************************/
/*!
    @brief   Ask the sensor to take two print feature template and create a
   model
    @returns FINGERPRINT_OK on success
    @returns FINGERPRINT_PACKETRECIEVEERR on communication error
    @returns FINGERPRINT_ENROLLMISMATCH on mismatch of fingerprints
*/
uint8_t Adafruit_Fingerprint::createModel(void) {
  SEND_CMD_PACKET(FINGERPRINT_REGMODEL);
}

/**************************************************************************/
/*!
    @brief   Ask the sensor to store the calculated model for later matching
    @param   location The model location #
    @returns FINGERPRINT_OK on success
    @returns FINGERPRINT_BADLOCATION if the location is invalid
    @returns FINGERPRINT_FLASHERR if the model couldn't be written
   to flash memory
    @returns FINGERPRINT_PACKETRECIEVEERR on communication error
*/
uint8_t Adafruit_Fingerprint::storeModel(uint16_t location) {
  SEND_CMD_PACKET(FINGERPRINT_STORE, 0x01, (uint8_t)(location >> 8),
                  (uint8_t)(location & 0xFF));
}

/**************************************************************************/
/*!
    @brief   Ask the sensor to load a fingerprint model from flash into buffer 1
    @param   location The model location #
    @returns FINGERPRINT_OK on success
    @returns FINGERPRINT_BADLOCATION if the location is invalid
    @returns FINGERPRINT_PACKETRECIEVEERR on communication error
*/
uint8_t Adafruit_Fingerprint::loadModel(uint16_t location) {
  SEND_CMD_PACKET(FINGERPRINT_LOAD, 0x01, (uint8_t)(location >> 8),
                  (uint8_t)(location & 0xFF));
}

/**************************************************************************/
/*!
    @brief   Ask the sensor to transfer 256-byte fingerprint template from the
   buffer to the UART
    @returns FINGERPRINT_OK on success
    @returns FINGERPRINT_PACKETRECIEVEERR on communication error
*/
uint8_t Adafruit_Fingerprint::getModel(void) {
  SEND_CMD_PACKET(FINGERPRINT_UPLOAD, 0x01);
}

/**************************************************************************/
/*!
    @brief   Ask the sensor to delete a model in memory
    @param   location The model location #
    @returns FINGERPRINT_OK on success
    @returns FINGERPRINT_BADLOCATION if the location is invalid
    @returns FINGERPRINT_FLASHERR if the model couldn't be written
   to flash memory
    @returns FINGERPRINT_PACKETRECIEVEERR on communication error
*/
uint8_t Adafruit_Fingerprint::deleteModel(uint16_t location) {
  SEND_CMD_PACKET(FINGERPRINT_DELETE, (uint8_t)(location >> 8),
                  (uint8_t)(location & 0xFF), 0x00, 0x01);
}

/**************************************************************************/
/*!
    @brief   Ask the sensor to delete ALL models in memory
    @returns FINGERPRINT_OK on success
    @returns FINGERPRINT_BADLOCATION if the location is invalid
    @returns FINGERPRINT_FLASHERR if the model couldn't be written
   to flash memory
    @returns FINGERPRINT_PACKETRECIEVEERR on communication error
*/
uint8_t Adafruit_Fingerprint::emptyDatabase(void) {
  SEND_CMD_PACKET(FINGERPRINT_EMPTY);
}

/**************************************************************************/
/*!
    @brief   Ask the sensor to search the current slot 1 fingerprint features to
   match saved templates. The matching location is stored in fingerID and
   the matching confidence in confidence
    @returns FINGERPRINT_OK on fingerprint match success
    @returns FINGERPRINT_NOTFOUND no match made
    @returns FINGERPRINT_PACKETRECIEVEERR on communication error
*/
/**************************************************************************/
uint8_t Adafruit_Fingerprint::fingerFastSearch(void) {
  // high speed search of slot #1 starting at page 0x0000 and page #0x00A3
  GET_CMD_PACKET(FINGERPRINT_HISPEEDSEARCH, 0x01, 0x00, 0x00, 0x00, 0xA3);
  fingerID = 0xFFFF;
  confidence = 0xFFFF;

  fingerID = packet.data[1];
  fingerID <<= 8;
  fingerID |= packet.data[2];

  confidence = packet.data[3];
  confidence <<= 8;
  confidence |= packet.data[4];

  return packet.data[0];
}

/**************************************************************************/
/*!
    @brief   Ask the sensor for the number of templates stored in memory. The
   number is stored in templateCount on success.
    @returns FINGERPRINT_OK on success
    @returns FINGERPRINT_PACKETRECIEVEERR on communication error
*/
/**************************************************************************/
uint8_t Adafruit_Fingerprint::getTemplateCount(void) {
  GET_CMD_PACKET(FINGERPRINT_TEMPLATECOUNT);

  templateCount = packet.data[1];
  templateCount <<= 8;
  templateCount |= packet.data[2];

  return packet.data[0];
}

/**************************************************************************/
/*!
    @brief   Set the password on the sensor (future communication will require
   password verification so don't forget it!!!)
    @param   password 32-bit password code
    @returns FINGERPRINT_OK on success
    @returns FINGERPRINT_PACKETRECIEVEERR on communication error
*/
/**************************************************************************/
uint8_t Adafruit_Fingerprint::setPassword(uint32_t password) {
  SEND_CMD_PACKET(FINGERPRINT_SETPASSWORD, (password >> 24), (password >> 16),
                  (password >> 8), password);
}

/**************************************************************************/
/*!
    @brief   Helper function to process a packet and send it over UART to the
   sensor
    @param   packet A structure containing the bytes to transmit
*/
/**************************************************************************/

void Adafruit_Fingerprint::writeStructuredPacket(
    const Adafruit_Fingerprint_Packet &packet) {
  SERIAL_WRITE_U16(packet.start_code);
  SERIAL_WRITE(packet.address[0]);
  SERIAL_WRITE(packet.address[1]);
  SERIAL_WRITE(packet.address[2]);
  SERIAL_WRITE(packet.address[3]);
  SERIAL_WRITE(packet.type);

  uint16_t wire_length = packet.length + 2;
  SERIAL_WRITE_U16(wire_length);

  uint16_t sum = ((wire_length) >> 8) + ((wire_length)&0xFF) + packet.type;
  for (uint8_t i = 0; i < packet.length; i++) {
    SERIAL_WRITE(packet.data[i]);
    sum += packet.data[i];
  }

  SERIAL_WRITE_U16(sum);
  return;
}

/**************************************************************************/
/*!
    @brief   Helper function to receive data over UART from the sensor and
   process it into a packet
    @param   packet A structure containing the bytes received
    @param   timeout how many milliseconds we're willing to wait
    @returns FINGERPRINT_OK on success
    @returns FINGERPRINT_TIMEOUT or
   FINGERPRINT_BADPACKET on failure
*/
/**************************************************************************/
uint8_t
Adafruit_Fingerprint::getStructuredPacket(Adafruit_Fingerprint_Packet *packet,
                                          uint16_t timeout) {
  uint8_t byte;
  uint16_t idx = 0, timer = 0;

  while (true) {
    while (!mySerial->available()) {
      delay(1);
      timer++;
      if (timer >= timeout) {
#ifdef FINGERPRINT_DEBUG
        Serial.println("Timed out");
#endif
        return FINGERPRINT_TIMEOUT;
      }
    }
    byte = mySerial->read();
#ifdef FINGERPRINT_DEBUG
    Serial.print("<- 0x");
    Serial.println(byte, HEX);
#endif
    switch (idx) {
    case 0:
      if (byte != (FINGERPRINT_STARTCODE >> 8))
        continue;
      packet->start_code = (uint16_t)byte << 8;
      break;
    case 1:
      packet->start_code |= byte;
      if (packet->start_code != FINGERPRINT_STARTCODE)
        return FINGERPRINT_BADPACKET;
      break;
    case 2:
    case 3:
    case 4:
    case 5:
      packet->address[idx - 2] = byte;
      break;
    case 6:
      packet->type = byte;
      break;
    case 7:
      packet->length = (uint16_t)byte << 8;
      break;
    case 8:
      packet->length |= byte;
      break;
    default:
      packet->data[idx - 9] = byte;
      if ((idx - 8) == packet->length)
        return FINGERPRINT_OK;
      break;
    }
    idx++;
  }
  // Shouldn't get here so...
  return FINGERPRINT_BADPACKET;
}

Is what I'm doing at all possible or am I just doing it wrongly?

I got it to work with NeoSWSerial and some help from AdaFruit. For those in the future:

Write the blank example sketch to the arduino
Go to device manager and switch the COM port that the arduino is connected to COM1 (Right click > Properties) - This applies even if you're using an FTDI breakout
Download and extract the SFG Demo Software
Click Open Device and select COM1
Change the baud rate (lower left corner) to 19200 - anything else seems unreliable (from my testing)
Replace all instances of SoftwareSerial to NeoSWSerial in the .cpp and .h files as well as your sketch. Change the finger.begin(57600) to finger.begin(19200) in the example sketches and that's it

If it doesn't work go back to device manager and change the baud rate on the COM port to 57600
Hope this helps someone!

Why don't they have that library take a Stream object so it doesn't matter what sort of serial you use?  Seems like this is an unnecessary dependency.


text:
multiple working modes for motors
with this sketch i can independently control 4 dc motors cw, ccw, and rotating each of them until the hall sensor related to it detects an magnetic field. what im trying to do now is to create a mode of operation in wich:just pressing button "nine", and first motor starts rotating until its hall sensor detects a magnetic field, after five seconds, the second motor acts the same and so on, ather the fourth motor, after 5 seconds, the first motor starts again. i spent like 5 hours trying but still cant do it. maybe for a pro its not that big deal cose its my first serious Arduino project.
#include <TLE94112.h>
#include <Tle94112Motor.h>
#include <IRremote.h>

#define unu 0x1
#define doi 0x2
#define trei 0x3
#define patru 0x4
#define sound 0x55
#define picture 0x54
#define feature 0x50
#define install 0x52
#define cinci 0x5
#define sase 0x6
#define sapte 0x7
#define opt 0x8
#define tv 0x63
#define av 0x56
#define e 0x60
#define eo 0x42

int RECV_PIN = 2;
int hallSensorPin1 = 3;
int hallSensorPin2 = 4;
int hallSensorPin3 = 5;
int hallSensorPin4 = 6;
int state1;
int oldState1 = 1;
int runMode1 = 0;
int state2;
int oldState2 = 1;
int runMode2 = 0;
int state3;
int oldState3 = 1;
int runMode3 = 0;
int state4;
int oldState4 = 1;
int runMode4 = 0;

Tle94112 controller = Tle94112();
Tle94112Motor motor1(controller);
Tle94112Motor motor2(controller);
Tle94112Motor motor3(controller);
Tle94112Motor motor4(controller);

IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{ irrecv.enableIRIn();
  controller.begin();

  motor1.connect(motor1.HIGHSIDE, controller.TLE_HB1);
  motor1.connect(motor1.LOWSIDE, controller.TLE_HB2);
  motor1.setPwm(motor1.HIGHSIDE, controller.TLE_PWM2);
  motor1.setPwmFreq(motor1.HIGHSIDE, controller.TLE_FREQ200HZ);

  motor2.connect(motor2.LOWSIDE, controller.TLE_HB3);
  motor2.connect(motor2.HIGHSIDE, controller.TLE_HB4);
  motor2.setPwm(motor2.HIGHSIDE, controller.TLE_PWM2);
  motor2.setPwmFreq(motor2.HIGHSIDE, controller.TLE_FREQ200HZ);

  motor3.connect(motor3.HIGHSIDE, controller.TLE_HB5);
  motor3.connect(motor3.LOWSIDE, controller.TLE_HB6);
  motor3.setPwm(motor3.HIGHSIDE, controller.TLE_PWM2);
  motor3.setPwmFreq(motor3.HIGHSIDE, controller.TLE_FREQ200HZ);

  motor4.connect(motor4.LOWSIDE, controller.TLE_HB7);
  motor4.connect(motor4.HIGHSIDE, controller.TLE_HB8);
  motor4.setPwm(motor4.HIGHSIDE, controller.TLE_PWM2);
  motor4.setPwmFreq(motor4.HIGHSIDE, controller.TLE_FREQ200HZ);

  motor1.begin();
  motor2.begin();
  motor3.begin();
  motor4.begin();
}
void loop()
{
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume();

    if (results.value == unu || results.value == 0x801 || results.value == 0x2049) {
      motor1.start(63);
      runMode1 = 0;
    }
    if (results.value == cinci || results.value == 0x805 || results.value == 0x2053) {
      motor1.start(-63);
      runMode1 = 0;
    }
    if (results.value == tv || results.value == 0x63 || results.value == 0x2111 || results.value == 0x83F || results.value == 0x3F) {
      motor1.coast();
      runMode1 = 0;
    }
    if (results.value == sound || results.value == 0x55 || results.value == 0x2103 || results.value == 0x837 || results.value == 0x37) {
      motor1.start(63);
      runMode1 = 1;
    }
    if (results.value == doi || results.value == 0x802 || results.value == 0x2050) {
      motor2.start(63);
      runMode2 = 0;
    }
    if (results.value == sase || results.value == 0x806 || results.value == 0x2054) {
      motor2.start(-63);
      runMode2 = 0;
    }
    if (results.value == av || results.value == 0x56 || results.value == 0x2104 || results.value == 0x838 || results.value == 0x38) {
      motor2.coast();
      runMode2 = 0;
    }
    if (results.value == picture || results.value == 0x54 || results.value == 0x2102 || results.value == 0x836 || results.value == 0x36) {
      motor2.start(63);
      runMode2 = 1;
    }
    if (results.value == trei || results.value == 0x803 || results.value == 0x2051) {
      motor3.start(63);
      runMode3 = 0;
    }
    if (results.value == sapte || results.value == 0x807 || results.value == 0x2055) {
      motor3.start(-63);
      runMode3 = 0;
    }
    if (results.value == e || results.value == 0x60 || results.value == 0x2108 || results.value == 0x83C || results.value == 0x3C) {
      motor3.coast();
      runMode3 = 0;
    }
   if(results.value==feature||results.value==0x50||results.value==0x2098||results.value==0x832||results.value==0x32){
      motor3.start(63);
      runMode3 = 1;
    }
    if (results.value == patru || results.value == 0x804 || results.value == 0x2052) {
      motor4.start(63);
      runMode4 = 0;
    }
    if (results.value == opt || results.value == 0x808 || results.value == 0x2056) {
      motor4.start(-63);
      runMode4 = 0;
    }
    if (results.value == eo || results.value == 0x42 || results.value == 0x2090 || results.value == 0x82A || results.value == 0x2A) {
      motor4.coast();
      runMode4 = 0;
    }
    if (results.value == install || results.value == 0x52 || results.value == 0x2100 || results.value == 0x834 || results.value == 0x34) {
      motor4.start(63);
      runMode4 = 1;
    }
  }
  state1 = digitalRead(hallSensorPin1);

  if (state1 == HIGH) {
    oldState1 = 1;
  }
  if (state1 == LOW && oldState1 == 1 && runMode1 == 1) {
    motor1.coast();
    oldState1 = 0;
  }
state2 = digitalRead(hallSensorPin2);

  if (state2 == HIGH) {
    oldState2 = 1;
  }
  if (state2 == LOW && oldState2 == 1 && runMode2 == 1) {
    motor2.coast();
    oldState2 = 0;
  }

  state3 = digitalRead(hallSensorPin3);

  if (state3 == HIGH) {
    oldState3 = 1;
  }
  if (state3 == LOW && oldState3 == 1 && runMode3 == 1) {
    motor3.coast();
    oldState3 = 0;
  }
  state4 = digitalRead(hallSensorPin4);

  if (state4 == HIGH) {
    oldState4 = 1;
  }
  if (state4 == LOW && oldState4 == 1 && runMode4 == 1) {
    motor4.coast();
    oldState4 = 0;
  }
}

what problem are you having? ... unable to detect 9 being pressed? ... something else? ... we are not going to spend time guessing what you are observing

Timed things are normally done with the millis() or micros() function, like in the BlinkWithoutDelay example. There are tons of tutorials out there about that. For writing code for multiple modes, you should look into the structure of an FSM (Finite State Machine). That is a simple but powerful concept, also often described on the web. I have also once written a longer answer about FSMs here, with diagrams and all. Understanding that concept will really help you


text:
How can I connect an OLED display to arduino
I'm new on this!
So I want to know if is it posible to connect this oled display: oled display to arduino nano and if is it posible where can I found information of how to learn about connect this type of mini display.
And if you can share some links about good learning site would be cool too!
Thanks!

I think you'll have trouble connecting it, as it does not seem to come with an interface card, just with a bare small pitch connector that will be very hard to solder. It looks like there's no technical documentation, which for me would be a deal breaker. If you're a beginner I would advise against it.

Yes, you can. If you have the adaptor board for it as shown in the video.
The key item from the description to note is the driver chip: SSD1309
That is what you need to know to find a library and connection schema.

Thanks for the answer.
And is it posible to buy a generic adaptor or made one?
Because I ask to seller and the adaptor is to expensive more than 10 times the price of the screen...
Thanks in advance
PD: I find this new oled display that I think it would be better.

No, there's no such thing as a "generic" adaptor. Every display is different. The datasheet for the display should have a schematic for what the interfacing needs are. If there is no datasheet then don't buy it.

Don't do it. It is an expensive display as it is, and it's not made to be easily used with an Arduino, especially without an interface card and 5V / 3.3V conversion. If you want an OLED attached to an Arduino Nano there are displays that are much easier to interface and use.

@StarCat Ah, but it's "transparent".  Gotta charge 10x as much if you remove that back plate...

So this one: https://www.sparkfun.com/products/15173 would be better I imagine?
And of the first one I have the datasheet.


text:
Capacitive Moisture sensor only shows values 1 and 2
I'm new to Arduino and electronics in general. I'm trying to connect the Capacitive moisture sensor v1.2 to my arduino and get values in the serial plotter.
I connected the VCC to 5V, GRD to ground and AOUT to A0. However, I keep only getting values of 1, 2 or 3, while they are supposed to be in the hundreds. What could be a cause of such a problem. I'm using the chinese Wavgat board, but I have previously connected the moisture and humidity sensors and they displayed values normally.
Here's the code I used:
int val;
void setup() {
  Serial.begin(9600);
}

void loop() {
  val = analogRead(A0);
  Serial.println(val);
  delay(200);
}

What's a capacitive moisture sensor v1.2?

Assuming this is what you have, did you go through the OverView for this product including installing the Adafruit_seesaw library?

Ah, not the expensive digital board.  This board has an analog output. At this point you need to start testing and swapping out parts.  Test the voltage at AOUT to verify it does in fact change when dipping the sensor in water.  Try a different sensor.  They are cheep and maybe you have a defective one.  Try a different Arduino.   Maybe the ADC input is broken on the one you have.


text:
Same software on single ESP-12f slower than on NodeMCU
I have programmed a small software to control an LED strip using an esp. I've written a web app which sends a request to the esp which then applies the color. So far everything works, but I've got a weird problem:
When I'm running the software on the NodeMCU, everything is fast and snappy, the web app takes 500ms at max to load. When I'm running the software from an ESP-12f (schematic), it takes way longer to load, about 5 seconds. Sometimes it doesn't even load at all.
Another thing that's weird: I've got two ESP-12f, one of those won't even load very often.
I also have the feeling that the "normal" esps run hotter than the nodemcu, but that could be because they are close to the voltage regulator which gets hot
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ArduinoOTA.h>
#include <colorWheel.h>
#include <web_iro_js.h>

#define RED_LED 14
#define GREEN_LED 12
#define BLUE_LED 5

#define BUILTIN_LED 2

const char* ssid = "---";
const char* password = "---";

IPAddress ip(192,168,2,111);
IPAddress gateway(192,168,2,1);
IPAddress subnet(255,255,255,0);
ESP8266WebServer server(80);

int brightness_red      = 0;
int brightness_green    = 0;
int brightness_blue     = 0;

int presets[4][3]       = {{255,119,46},{46,0,39},{0,115,23},{0,0,0}};

boolean blinking        = false;
boolean fading          = false;
boolean jumping         = false;

int blinkDelay[]        = {50, 145, 240, 335, 430, 525, 620, 715, 810, 905};
int speedPosition       = 4;

int fadeOrder[]       = {RED_LED, GREEN_LED, BLUE_LED};
int lastFade          = 0;    //0~2, refers to fadeOrder[]
int thisFade          = 1;    //0~2, refers to fadeOrder[]
int fadeSpeed[]       = {1, 1, 1, 2, 3, 4, 5, 5, 7, 9};

boolean blinkHelper = false;

void handleRequest();
void handleGet();
void setupOTA();
void connectToWiFi();
void turnOff();
void turnOn();
void applyColor();
void applyPreset();
void blink();
void fade();
void jump();

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

    analogWriteRange(255);

    pinMode(BUILTIN_LED, OUTPUT);
    digitalWrite(BUILTIN_LED, LOW);

    pinMode(RED_LED, OUTPUT);
    pinMode(GREEN_LED, OUTPUT);
    pinMode(BLUE_LED, OUTPUT);

    analogWrite(RED_LED, 0);
    analogWrite(GREEN_LED, 0);
    analogWrite(BLUE_LED, 0);

    Serial.println();
    Serial.print("Connecting to ");
    Serial.println(ssid);

    WiFi.begin(ssid, password);
    WiFi.config(ip, gateway, subnet);

    while(WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
    }
    Serial.println();
    Serial.println(WiFi.localIP());

    setupOTA();

    server.on("/request", handleRequest);
    server.on("/get", handleGet);

    server.on("/", HTTP_GET, []() {
        server.send(200, "text/html", GUI);
    });

    server.on("/iro.min.js", HTTP_GET, []() {
        server.send_P(200, "application/javascript", IRO_JS);
    });

    server.begin();

    Serial.println("Setup done");
    pinMode(BUILTIN_LED, OUTPUT);
    digitalWrite(BUILTIN_LED, HIGH);
}

void loop() {
    if (WiFi.status() != WL_CONNECTED) {
        //Serial.println("no connection");
        connectToWiFi();
    }
    ArduinoOTA.handle();
    server.handleClient();

    if (blinking) {
        blink();
    }

    if (fading) {
        fade();
    }

    if (jumping) {
        jump();
    }

    if (blinking || fading || jumping) {
        delay(blinkDelay[speedPosition]);
    } else {
        delay(20);
    }
}

void handleRequest() {
    if (!server.hasArg("mode")) {
        Serial.println("no mode specified");
        server.send(400, "text/plain", "no mode specified");
        return;
    }

    String request = server.arg("mode");

    if (request.equals("color")) {
        fading = false;
        jumping = false;
        applyColor();

    } else if (request.equals("preset")) {
        fading = false;
        jumping = false;
        applyPreset();

    } else if (request.equals("blink")) {
        if (blinking) {
            blinking = false;
        } else {
            turnOff();
            fading = false;
            jumping = false;
            blinking = true;
        }
        server.send(200, "text/plain", "applied blinking");
    } else if (request.equals("fade")) {
        if (fading) {
            fading = false;
        } else {
            turnOff();
            blinking = false;
            jumping = false;
            fading = true;
        }
        server.send(200, "text/plain", "applied fading");
    } else if (request.equals("jump")) {
        if (jumping) {
            jumping = false;
        } else {
            turnOff();
            blinking = false;
            fading = false;
            jumping = true;
        }
        server.send(200, "text/plain", "applied jumping");
    } else if (request.equals("speed")) {
        if (!server.hasArg("newSpeed")) {
            server.send(400, "text/plain", "no speed specified");
            return;
        }
        int speed = server.arg("newSpeed").toInt();
        speedPosition = 9 - speed;
        server.send(200, "text/plain", "applied speed");
    } else {
        server.send(400, "text/plain", "argument not found");
    }
}

void handleGet() {
    if (!server.hasArg("arg")) {
        Serial.println("no argument specified");
        server.send(400, "text/plain", "no argument specified");
        return;
    }
    String request = server.arg("arg");
    String answer = "";

    if (request.equals("current")) {
        answer += (String(brightness_red));
        answer += (";" + String(brightness_green));
        answer += (";" + String(brightness_blue));
        answer += (";" + String(speedPosition));

    } else if (request.equals("presets")) {
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 3; j++) {
                answer += String(presets[i][j]);
                answer += ";";
            }
        }
    } else {
        server.send(400, "text/plain", "argument not found");
    }
    server.send(200, "text/plain", answer);
}

void setupOTA() {
    ArduinoOTA.setHostname("ESP8266");
    ArduinoOTA.setPassword("password");

    ArduinoOTA.onStart([]() {
        Serial.println("Start");
    });
    ArduinoOTA.onEnd([]() {
        Serial.println("\nEnd");
    });
    ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
        Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
    });
    ArduinoOTA.onError([](ota_error_t error) {
        Serial.printf("Error[%u]: ", error);
        if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
        else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
        else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
        else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
        else if (error == OTA_END_ERROR) Serial.println("End Failed");
    });
    ArduinoOTA.begin();
}

void connectToWiFi() {
  Serial.println("WiFi connection lost, reconnecting");
  WiFi.begin(ssid, password);
  WiFi.config(ip, gateway, subnet);

  while(WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("Wifi reconnected");
}

void applyColor() {
    Serial.println("applying new color ");
    brightness_red = 0;
    if (server.hasArg("red")) {
        brightness_red = server.arg("red").toInt();
    }

    brightness_green = 0;
    if (server.hasArg("green")) {
        brightness_green = server.arg("green").toInt();
    }

    brightness_blue = 0;
    if (server.hasArg("blue")) {
        brightness_blue = server.arg("blue").toInt();
    }

    turnOn();
    server.send(200, "text/plain", "applied new color");
}

void applyPreset() {
    if (!server.hasArg("index")) {
        Serial.println("no index specified");
        server.send(400, "text/plain", "no index specified");
        return;
    }

    int index = server.arg("index").toInt();

    if (server.hasArg("save")) {
        Serial.println("saving preset");
        presets[index][0] = brightness_red;
        presets[index][1] = brightness_green;
        presets[index][2] = brightness_blue;
        server.send(200, "text/plain", "preset saved");
    } else {
        Serial.println("applying preset");
        brightness_red = presets[index][0];
        brightness_green = presets[index][1];
        brightness_blue = presets[index][2];

        turnOn();
        server.send(200, "text/plain", "preset applied");
    }
}

has the esp-12f a good antenna and a good reception? sometimes rotating the module with antenna towards the location of the AP makes wonder

@Juraj when pinging the boards they take about the same time to respond, so I think yes


text:
How to properly handle the Arduino String
I've read that the Arduino String is bad as it causes memory fragmentation, so I try to avoid them mostly. But I still have some occurences where I'm not quite sure if they are ok after all.
The first is in print statements:
I have a function which prints a success or error message to the serial port, like so: Serial.println("Success");. Is this ok or should I (for example) pre define the String using #define SUCCESS "SUCCESS"?
Which leads me to the next case, defines:
I'm using MQTT and have the topics defined like above, e.g. #define TOPIC_COLOR "light/color". Is this fine?
A third one is with ArduinoJSON:
I'm using Strings as keys, like so lights["red"] = redVal;. This call is made at multiple places so I assume the string would be created multiple times? A workaround/improvement I've thought of is using an enum defining the properties and using that as key.
Thanks for all comments, tips and explanations!

You're confusing "strings" with the Arduino String class.

@Majenko So my usage of those strings is fine?

Strings, as in "this", are just chunks of static data. It's when you start messing with String objects that problems occur. I don't know what ArduinoJSON does with string indices, though. On smaller MCUs (AVR) you should use F("stringliteral") to reduce RAM usage whenever possible, though.

@Majenko alright thank you. I don't know either but it seems commonly used so I assume it handles them good enough.
Thanks for the tip! I'm on an ESP8266 right now so that won't be a problem for now

a couple points: using Strings is fine sometimes; in setup(), static globals, consts, etc. It's more that modifying Strings is the real silent killer. The ESP also has much more ram and I've seen them "stop sinking" on code that will inevitably sink an AVR. I'm not saying String is not without pitfalls, just that not every single use is a showstopper.

+1 to @majenko's comments. I tend to avoid the String class, as I like to know what is actually going on, and I stick to char * and char [] in general (and the stdlib functions like sprintf, strlen, etc).
Couple of notes on your question:

"foo/bar" is fine. Some characters have special meanings in the C language itself, so you need to escape them with the \. For example if " was part of your literal string, you'd write "foo\"bar\""

I tend to use ArduinoJSON to parse. If my app is just sending JSON payloads, I just build it with sprintf or print which results in smaller programs. But, I guess it is a matter of choice. It is a great library.

Thanks! I'm using ArduinoJSON to parse and send, but also to store the current state, it's quite handy that it does all those things. As of now, storage is enough, if it gets sparse I'll have to think of something else...


text:
ESP 01 lost its firmware when it disconnected

Hi I am using Arduino uno & ESP-01
ESP-01 is working well when I put firmware to ESP, for example, wifi spreading or AT command is okay.
but when I disconnect arduino from PC(disconnect USB connection)
ESP-01 suddenly do not work anything. no spread wifi, no AT command reaction..
so I always have to re-input the firmware to ESP again, for make it work again.
How can I make maintain ESP-01 's firmware?
picture is my connection status. thank you

You have io 0 puled LOW so the esp-01 firmware starts in flashing mode and the firmware starts immediately after flashing (no reset).
Remove io 0 to ground connection and add a pull-up for io 0 over a 10kOhm resistor if you want the esp-01 to start normally.
Note: powering the esp-01 from the 3.3 V pin of Uno (150mA max) could be insufficient for esp8266 WiFi operations at top transmit power (according to specs it can draw to 170 mA).


text:
How to get interrupt while in sleep mode?
I am using Arduino-uno, attached ESP-01 module
I want to give interrupt when I send some wifi-signal to arduino,
which is in sleep mode.
so I write this code:
SoftwareSerial esp(2, 3); // RX, TX

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

  esp.begin(9600);

  attachInterrupt(digitalPinToInterrupt(2),work,RISING);

  delay(1000);

  init_sleep(); // go to sleep
}

void work(){
    light = ! light;

    digitalWrite(12,light);

}

when I don't write down the init_sleep, this interrupt is able to work.
but when the arduino is in sleep mode, because of writing 'init_sleep'
It does not react signal by interrupt.
Is it impossible to wake up sleeping arduino by attachInterrupt() ?
please give me some solution.

Why the delay()? If the interrupt happens while in delay(), it won't wake up the Arduino that is not sleeping yet.

oh I had some mistake. but I deleted the delay, result is same.

Where does init_sleep() come from? I did my a little differently by directly accessing registers but I know you have to disable sleep mode in your "wake up" ISR as the first thing before anything will happen. Watch this tutorial, it is very good. https://www.youtube.com/watch?v=urLSDi7SD8M


text:
Arduino pro mini sampling rate
what are the possible sampling rate the user can set in Arduino pro mini using ADCSRA registers.
I want to set  my desired sampling rate through registers, is it possible?

maybe add a quote from the datasheet and explain what is what you don't understand

What sampling rate do you want, chances are you won't achieve it if you are trying to run a high level language on the device.

It depends on you accuracy requirement, as accuracy degrades with sampling speed.


text:
Controlling Arduino through python
How to set the registers of Arduino through python code to vary the sampling rate of Arduino?
Can we control Arduino through python?

what runs the python script?

If you mean can you run a python script on a "PC" and send messages to an Arduino then yes but you would need to write code that ran on the Arduino to receive messages from the "PC" and turn those into actions on the Arduino.
If you mean can you run a python script on an Arduino directly, well yes you can there are python implementations for Arduinos, but if you go down this route you need to remember you only have a small amount of memory and you are going off piste where there will be little or no help.
Honestly I would learn how to program the arduino in C++ and stick to that.

welcome back Code Gorilla. you could mention Firmata

Thank you very much :)  That was the one I had a quick look at, but I didn't investigate it in any detail so I didn't want to hint it might be any good.


text:
7-Segment Display w/ Potentiometer
(Backstory) So, I took an computer engineering class in high school (grade 11 level), where I learned a bit about breadboarding as well as arduinos (I would like to stress a bit). It has been 5 years, and I don't remember much; but the other day my little brother started taking the same class. He has the following assignment, which I have also endeavored to try for fun:
(Not Backstory) I need to make a potentiometer control a 7-segment display so that it displays a number (0-9) based on the potentiometers value. I hopped on to tinkercad to test stuff out before acuatally doing anything, and I came up with the following real quick:

I've tested the above model and I know it works, but the following code does not work.
int a = 2;
int b = 3;
int c = 4;
int d = 5;
int e = 6;
int f = 7;
int g = 8;
int potentiometer = 9;

void setup() {
  for(int pins = 2; pins <=8; pins++){
  pinMode(pins, OUTPUT);
 }
  pinMode(potentiometer, INPUT);
}

void loop() {
  int pRes;
  pRes = analogRead(potentiometer);
  if (pRes >=0 && pRes <=101){
    //0
    digitalWrite(a, LOW);
    digitalWrite(b, LOW);
    digitalWrite(c, LOW);
    digitalWrite(d, LOW);
    digitalWrite(e, LOW);
    digitalWrite(f, LOW);
    digitalWrite(g, HIGH);
    }
  else if (pRes >=102 && pRes <=203){
     //1
    digitalWrite(a, HIGH);
    digitalWrite(b, LOW);
    digitalWrite(c, LOW);
    digitalWrite(d, HIGH);
    digitalWrite(e, HIGH);
    digitalWrite(f, HIGH);
    digitalWrite(g, HIGH);
    }
  else if (pRes >=204 && pRes <=305){
     //2
    digitalWrite(a, LOW);
    digitalWrite(b, LOW);
    digitalWrite(c, HIGH);
    digitalWrite(d, LOW);
    digitalWrite(e, LOW);
    digitalWrite(f, HIGH);
    digitalWrite(g, LOW);
    }
  else if (pRes >=306 && pRes <=407){
    //3
    digitalWrite(a, LOW);
    digitalWrite(b, LOW);
    digitalWrite(c, LOW);
    digitalWrite(d, LOW);
    digitalWrite(e, HIGH);
    digitalWrite(f, HIGH);
    digitalWrite(g, LOW);
    }
  else if (pRes >=408 && pRes <=509){
    //4
    digitalWrite(a, HIGH);
    digitalWrite(b, LOW);
    digitalWrite(c, LOW);
    digitalWrite(d, HIGH);
    digitalWrite(e, HIGH);
    digitalWrite(f, LOW);
    digitalWrite(g, LOW);
  }
  else if (pRes >=510 && pRes <=611){
    //5
    digitalWrite(a, LOW);
    digitalWrite(b, HIGH);
    digitalWrite(c, LOW);
    digitalWrite(d, LOW);
    digitalWrite(e, HIGH);
    digitalWrite(f, LOW);
    digitalWrite(g, LOW);
    }
  else if (pRes >=612 && pRes <=713){
    //6
    digitalWrite(a, LOW);
    digitalWrite(b, HIGH);
    digitalWrite(c, LOW);
    digitalWrite(d, LOW);
    digitalWrite(e, LOW);
    digitalWrite(f, LOW);
    digitalWrite(g, LOW);
    }
  else if (pRes >=714 && pRes <=815){
    //7
    digitalWrite(a, LOW);
    digitalWrite(b, LOW);
    digitalWrite(c, LOW);
    digitalWrite(d, HIGH);
    digitalWrite(e, HIGH);
    digitalWrite(f, HIGH);
    digitalWrite(g, HIGH);
    }
  else if (pRes >=816 && pRes <=917){
    //8
    digitalWrite(a, LOW);
    digitalWrite(b, LOW);
    digitalWrite(c, LOW);
    digitalWrite(d, LOW);
    digitalWrite(e, LOW);
    digitalWrite(f, LOW);
    digitalWrite(g, LOW);
    }
  else if (pRes >=918 && pRes <=1023){
    //9
    digitalWrite(a, LOW);
    digitalWrite(b, LOW);
    digitalWrite(c, LOW);
    digitalWrite(d, HIGH);
    digitalWrite(e, HIGH);
    digitalWrite(f, LOW);
    digitalWrite(g, LOW);
    }
}

Can someone explain to me what I've done wrong (and offer corrections)?

In what way does it "not work"?

I think you wired the potentiometer incorrectly. The middle pin goes to an analog input pin (you used a digital pin on one of the outer pins), the outer pins to ground and 5V respectively.

i see no debugging code ... how do you know that the pot is being read as expected?

Only the pins with labels starting with “A” (A0 through A5 on the Uno)
can be used as analog inputs.
The pin of the potentiometer that is currently not connected has to
be connected to 5V.

Thanks for the help, can't believe I overlooked something like that.

Also I switched HIGH and LOW lol


text:
ESP8266: ESPASyncserver + client
I have project with an ESPAsyncWebServer with websockets working already. What I need to add is Client functionality to poll a site for a response. I looked at the ASyncTCP library and it has two different implementations that aren't well documented in how to use.
There's the SyncClient option that looks like this:
  SyncClient client;
  if(!client.connect("www.google.com", 80)){
    Serial.println("Connect Failed");
    return;
  }
  client.setTimeout(2);
  if(client.printf("GET / HTTP/1.1\r\nHost: www.google.com\r\nConnection: close\r\n\r\n") > 0){
    while(client.connected() && client.available() == 0){
      delay(1);
    }
    while(client.available()){
      Serial.write(client.read());
    }
    if(client.connected()){
      client.stop();
    }
  } else {
    client.stop();
    Serial.println("Send Failed");
    while(client.connected()) delay(0);
  }

I don't know if i'm supposed to put code after a client.connected() or client.available()? Of if I need the full structure as shown or just one of the commands. It also doesn't show all the commands and syntax available (such as an equivalent for client.write(), client.print or the like).
Then there is the simply named ClientServer > Client which only has the following:
static void replyToServer(void* arg) {
    AsyncClient* client = reinterpret_cast<AsyncClient*>(arg);

    // send reply
    if (client->space() > 32 && client->canSend()) {
        char message[32];
        sprintf(message, "this is from %s", WiFi.localIP().toString().c_str());
        client->add(message, strlen(message));
        client->send();
    }
}

/* event callbacks */
static void handleData(void* arg, AsyncClient* client, void *data, size_t len) {
    Serial.printf("\n data received from %s \n", client->remoteIP().toString().c_str());
    Serial.write((uint8_t*)data, len);

    os_timer_arm(&intervalTimer, 2000, true); // schedule for reply to server at next 2s
}

void onConnect(void* arg, AsyncClient* client) {
    Serial.printf("\n client has been connected to %s on port %d \n", SERVER_HOST_NAME, TCP_PORT);
    replyToServer(client);
}

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

    // connects to access point
    WiFi.mode(WIFI_STA);
    WiFi.begin(SSID, PASSWORD);
    while (WiFi.status() != WL_CONNECTED) {
        Serial.print('.');
        delay(500);
    }

    AsyncClient* client = new AsyncClient;
    client->onData(&handleData, client);
    client->onConnect(&onConnect, client);
    client->connect(SERVER_HOST_NAME, TCP_PORT);

    os_timer_disarm(&intervalTimer);
    os_timer_setfn(&intervalTimer, &replyToServer, client);
}

This doesn't tell me a whole lot about how to use this library.
I need some guidance on how to deploy the client alongside my server. I don't need much, just listen for server directive, parse it and then send a response (client.println) or upload a file (client.write). I'd like to implement the asynchronous version of this.

It is actually well-documented and plenty of examples online on how to use it. client.connect() establish a TCP connection, it is up to you implement your own http request with client.print or client.printf in according to http protocol, you can add http headers, POST or GET as per your need. The http response can be read with client.read(), it is up to you on how you want to capture it (e.g. reading into a buffer and parse it) or simple print it on Serial Monitor(as show in the example code).

If you don't want to handle the http creation and parsing, you can use ESP8266HTTP client which provide simpler API.


text:
How to make watchdog and automatically reset on esp8266
When my system is confronting at logical & hardwaretical problem,
I want to make system know It has some problem and reset automatically
because my esp8266(nodeMCU) is on the place where people usually cannot touch.
so I apply this 'ticker' code, but I think they are not working when it is on  problem status.
please see my code and give me some advice that how to make system know the problem status and do reset automatically.
//these are global values
Ticker ticker;
volatile unsigned int ISRcounter = 0;

void setup(){

ticker.attach(2,ISRdog);
//ticker always give Interrupt every 2 second.
//and when it get Interrupt, ISRdog function is called.
}

void ISRdog() {
  ISRcounter += 1;
//when ISR is called, ISRcounter is ++.

  if (ISRcounter == 10) {
    ESP.deepSleep(5e5); //reset
//and when it is 10, deepSleep for 5second and automatically wakeup.
//so it means, 'system reset'

  }

}

void loop(){

ISRcounter=0;
//when program running properly, system's flow always go to loop in final.
//so at the loop, make ISRcounter =0, for not making the system reset(ISRcounter==10)

.....
}

...and other functions ....

In short, this code is making reset until the system is not entering the  loop() over 20second.
so I expect when system get problem somehow, then system do not enter to the loop() and It means ISRcounter is getting 10, without =0. so system should be resetted.
but It did not worked. did not automatically resetted.

esp8266 always runs the watchdog

by iteself without my code? I saw. but when it resetted like that, it do not rework properly I think. for example, spreading wifi signal as a server...


text:
Powering Arduino with Thermostat Power
So I want to make an Arduino based thermostat controller. I'm good with the semantics behind this, there's just one detail I want to make sure I get right: Power
I know US thermostat power is 24VAC, but I'm not sure how to convert that to 12V 0.5A DC that the Arduino wants. I'd like to do this efficiently rather than generating a ton of heat in the process, too. I don't even know how many amps "24VAC" is, which is the only specification I can find on thermostat power.
I've found 24VAC to 12VDC converters (made for surveillance cameras) online, but most are rated for 1.5A, and I'd be concerned about frying the Arduino. I am not sure if the Arduino only pulls as much as it needs, or if it would try to pull the full 1.5A and destroy itself. I also do not know if these are relatively power efficient, either.
I'm generally hoping someone has been down this path before so that I don't have to reinvent the wheel.

" I don't even know how many amps "24VAC" is..." That doesn't really make sense. 24VAC isn't any number of amps. The 24VAC transformer is designed for some maximum current load. It's probably got enough extra current capacity to drive a modest 5VDC Arduino project, especially if you provide the 5V using a buck style power supply like the one I suggest in my answer. Those convert one voltage to a lower voltage at very high efficiency.

You should moniter the 24V AC line while the furnace is operating. When we bought our house in 1990, we replaced the mercury switch thermostats with Honeywell units designed to be powered from 24V.  Woke up one night with the house at 88F!  Turns out the furnace turned the 24V going to the thermostats on and off, and that messed up the thermostat, causing it to lose its programming.  Replaced the thermostat with a battery powered unit that controlled a relay to turn the heat off & on. No problems since then.

@DuncanC I know 24VAC says nothing about amperage. I was trying to making a tongue-in-cheek joke about lacking specification. Guess it didn't translate well to text. Oops. Thanks for your full reply! I'll pick up one of those converts and see what I can do.

I don't even know how many amps "24VAC" is

Exactly, because that's a voltage rating (24 Volts AC) and no information about the current capability is given.

I've found 24VAC to 12VDC converters (made for surveillance cameras) online, but most are rated for 1.5A, and I'd be concerned about frying the Arduino. I am not sure if the Arduino only pulls as much as it needs, or if it would try to pull the full 1.5A and destroy itself

The Arduino, as a semiconductor, will consume only the current it needs. What current it needs is determined by the processor core (if it's e.g. in sleep-mode or not), the activated peripherals (ADC etc) and devices powered externally via the Arduino's +5V or +3.3V pins.
The typical power consumption of an Arduino board running a sketch (no low-power mode + no external devices) is about 20mA, aka 0.020A.
Also note that what's happening is when you feed +12VDC into the VIN pin, it goes to a linear voltage regulator, which converts excess voltage into heat while keeping the current the same. The official Arduino Uno (not a chinese clone!) has a NCP1117ST50T3G, which is a 6.5V-20V (recommended limit:12V) to 5V linear regulator with I_out of minimum 1A, typical 1.5A (also note I_out is circa I_in, the regulator itself needs negligable current). Clones might use a cheaper (and worse) voltage regulator. Also note that this output capability might not be realisitically achievable without a heat-sink on the regulator; since excess voltage is converted into heat, converting +12V to +5V at 1A creates (12V-5V)*1A = 7W of heat(power). The package cannot sustain that for very long and the regulator shuts down due its built-in thermal protection.
In short it can be said that it's not a problem to connect a higher-rated power supply to an Arduino. The Arduino will pull what it needs to power itself and everything else on the +5V and +3.3V pins, if it's within the limits of the voltage regulator.
These videos might help your understanding of linear voltage regulators: https://www.youtube.com/watch?v=GSzVs7_aW-Y https://www.youtube.com/watch?v=giGRrODKJSE

If you're just running an Arduino and a few low power components, feeding the Arduino's voltage regulator 12V would be fine. However, if the 24VAC to 12VDC power supply is unregulated, it may well put out more than 12V.
If your Arduino system draws a lot of current from the 5V regulator then it will generate a lot of heat, and might overheat. What else are you driving from the Arduino's 5V and 3.3V lines?
A buck style power supply would be a good choice for this setup.
Here is an example that should work very well:
https://www.amazon.com/SMAKN%C2%AE-Converter-Voltage-Supply-Waterproof/dp/B00RE6QN4U
The picture on that supply says it will work with from 8-35V, so there is a lot of "wiggle room" in its supply voltage. Even if the doorbell draws enough current for the 24VAC to drop to 12VAC while the doorbell is ringing, the supply should still be able to keep the Arduino running just fine.
(You could feed the regulated 5V from that supply directly into the USB input on your Arduino)
That is a very high efficiency supply that will waste very little power as heat. You wouldn't need anything else other than that.

Would it be a bad idea, then, to put the Arduino in line with a 1A fuse just in case?

That would be fine, but an Arduino isn't going to draw 1A unless you have some high current loads plugged into it's 5V line, or if you short something.


text:
one Arduino with RS485 and Ethernet shields: does this work?
I'm planning to wire a few Arduinos together via RS485, and have one of them act as a hub that collects information from the others and presents it via http on an Ethernet connection.
For instance an Aduino MKR with ETH shield and 485 shield. Can I expect these to work together? My worry is having 2 shields that potentially need lots of bandwidth, timing issues etc.

no problem for MKR

Should be no problem.
The ETH shield uses SPI to communicate with a W5500 chip. That chip does most of the network processing for you.
The 485 shield just connects to the UART TX and RX pins. It's just serial communications with a couple of control pins from there on out.
Neither use any pins that the other one uses.


text:
How can I make this function take up less memory?
I've written a sketch that uses TimeLib to display elapsed time. I'm measuring how long it takes to drain a battery. The goal is to display the time as hh:mm:ss.
The code I use works well when I create a sketch that only contains this code.
But when I run it as part of the complete program, displaying the time fails: the getTime function seems to be returning an empty string.
Specifically:
String gTime = String(addZero(hour())) + ":";

this works, but when I add more,
String gTime = String(addZero(hour())) + ":" + String(addZero(minute()));

the returned string is incomplete: I get ":00" instead of 00:00"
I suspect a memory problem, so I'm looking for ways to make this sketch use less memory.
I've been reading that String variables take up a lot of space, and I should use char arrays instead. But every attempt I made to rewrite these functions has failed.
#include <TimeLib.h>

unsigned long previousMillis = 0;
const long interval = 1000; //in ms

void setup() {
  Serial.begin(115200);
  Serial.println("Start program");
  setTime(00,00,00,01,01,2024);
}

void loop() {
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    String Tm = getTime();
    Serial.print(Tm);Serial.println(";");
  }
}

String getTime(void) {
  String gTime = String(addZero(hour())) + ":" + String(addZero(minute())) + ":" + String(addZero(second()));
  return gTime;
}

String addZero(int digits) {
  String Dig = "0";
  if(digits < 10) {
    Dig = "0" + String(digits);
  }
  else {
    Dig = String(digits);
  }
  return Dig;
}

Here's my attempt so far. This produces correct output for 10 to 59, but fails for 1 to 9. And the function still returns a String instead of a char array.
String addZero(int digits) {
  char Dig[3] = "00";

  if(digits < 10) {
    itoa(digits,Dig[1],10);
  }
  else {
    itoa(digits,Dig,10);
  }
  return Dig;
}

I'm stuck. How do I get this to work?

did you see the TimeSerialDateStrings example of the TimeLib?

Yes, I saw that example and adapted it to get the time into a variable instead of just printing it.

Use snprintf() here for formatted printing instead of the String class. Leading zeros can sometimes be interpreted as OCTAL.
#include <TimeLib.h>

unsigned long previousMillis = 0;
const long interval = 1000; //in ms
char buf[20] = {0} ;

void setup() {
  Serial.begin(115200);
  Serial.println("Start program");
  setTime(00,00,00,01,01,2024);  // don't use leading zeros here !!
}

void loop() {
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    snprintf( buf, sizeof(buf)-1,"%02d:%02d:%02d", hour(), minute(), second()) ;
    Serial.println(buf) ;

    // if you want to copy it into another char array
    char newBuf[15] ;
    strncpy( newBuf, buf, sizeof(newBuf)) ;
    Serial.println( newBuf ) ;

    // if you want it in a String:
    String str1 = String( buf ) ;
    Serial.println( str1 ) ;
  }
}

That would take care of printing, but can I store the formatted time in a variable? I want to record the time at which the battery was drained.

I've added a couple of examples of getting the formatted string into a variable. Maybe you also want the date in the buffer ?

That's very helpful, thanks. This works in the test program. The full program still won't display the time, so I'll have to find more ways to reduce the memory footprint.

OK. Best to post the entire program (maybe as a separate thread) to get ideas on how to reduce the runtime size. One thing is this: Serial.println("Start program"); . You can do this instead: Serial.println(F("Start program")) ;. The F() macro in this case keeps the string "Start program" from using RAM. The compiler gives statistics on memory usage which can help but it can't see everything (Automatic variables, heap usage etc.)

snprintf adds 1 kB flash use

If the compiler/linker does not complain, "memory" problems are usually dynamic RAM, which cannot be checked at compile time. String objects are the first idea to remove when dealing with RAM issues. (BTW: A complete RTC timestamp is just 6 bytes)

I've made a new question with the entire program: https://arduino.stackexchange.com/questions/96625/how-can-i-make-this-program-take-up-less-memory

Couldn't you have amended this question? Two very similar questions are not in the spirit of how this site should be used. I'm going to close this question so that answers are not split between the two questions.

I followed the suggestion in 6v6gt's comment.

Mea Culpa. I did make the suggestion which I acknowledge was wrong in retrospect. I did, however, assume that the OP had  made a more comprehensive attempt to eliminate Strings, after the first answer, hence the suggestion to open a new thread including the full code which could flush out more general size reduction ideas.


text:
About the FFT library on Arduino
From the output results, i see that the arduinoFFT returns only positive frequencies, thus i think it self removes the negative sided values and compensates the lost energy by multiplying by 2. Is this correct?Ar

What's a "negative" frequency?

I don't know what you mean by a "negative" frequency.
FFT takes a set of samples and returns a group of "buckets", the number of buckets equal to half the number of samples. These buckets cover frequencies from 0Hz to F/2 where F is the sample frequency.
Each bucket contains the power magnitude of a block of frequencies in both the real and imaginary "axis" (effectively a pair of coordinates depicting a vector).
You compute the absolute power of a bucket through taking the square root of the sum of the squares of the real and imaginary components (basically good ol' pythagoras).
This "absolute power" value is the magnitude of a vector. A vector can never have a magnitude < 0. After all, if you have a vector of (1,1) and one of (-1, -1) they are both the same magnitude, just with a different angle (in this example a phase difference of 180 degrees).

thanks for the answer mister Majenko. Though I just found out  that in the arduinoFFT library, the paramter "FFT_FORWARD" does all the job(returns one sided energy spectrum, and also normalizes the amplitudes).

I'm not familiar with that specific library or what facilities it provides.

Last question sir: Would the DC component of the signal affect the amplitudes at other harmonics(components) of the FFT(the FFT is applied to the output signal of an amplified electrt microphone, for some purpose).

No, the DC component should only affect the DC bucket, if at all

God bless you. Thanks for the assist ;)

Please, another question sir: i've tried filtering the sampled data using the Running Mean before running the FFT on it, a way of reducing noise in the output signal of a sensor. However, i'm not sure if it does fit  for an audio signal, as the resulting FFT vector is nothing like the non-filtred one.

I mean the amplitudes that i get for a certain bin are very different from the ones where no filtering was applied.

@أيمنالفحصي: that's the whole point of filtering: to alter the amplitude of some frequency components. In the case of a running median, you will be strongly attenuating higher frequencies.

Actually i'm just interested in the range of 1-8 kHz. Also, the sampling rate that i see the most promising is 20480 Hz,(using the 1.28 factor and the Nyquist theoreme). Also, i'm not filtering the FFT data, but the sampled data(RMS sound pressure versus time). An thoughts on this one please?

Or maybe  it does have to do with the time that the median calculation takes?? However i can't see why amplitudes of the FFT will change as you mentionned before even runing the FFT.

You see if we were talking continuous time, things are more easy to get a grasp of. But with the discretized calculations, things aren't that obvious for me   :(


text:
Is it possible to use mathematical sets and their operations in arduino?
In python there is the object set that resembles a mathematical set, namely, you can remove elements from it, add elements to it, you can calculate the intersection/union between two sets, etc.
Is there a library or built-in functions that have those capabilities? I have been unlucky because when I use the word "set" as query term for the engine search, it always sends me to something related to the verb to set.

The Standard Template Library (STL) can be installed on the Arduino. It is not there by default. That includes things like sets.
One implementation is here.


text:
How fast are IR sensors with Arduino
For an industrial project which requires detecting whether some text is printed on the cable at regular intervals or not, I was wondering if Arduino with IR sensor could work? The cable would be typically black with white text printed at each metre and will be unwounding from a cylindrical drum (To give you an idea of text length, it will contain cable type, metre mark, etc., I'll update the question with the linear velocity of the cable soon).
My approach was to raise an interrupt if the colour change is not recognized in the predetermined time. For this, I think I need to check if I can measure light changes, let's say 4 or 6 times in a time it takes to unwind a metre of the wire. I however don't know how fast IR sensors are to judge whether this approach is feasible.
Also, let me know if this is unfeasible and I should instead move to Raspberry Pi with a camera.

They're fast enough to transfer meaningful digital information faster than the human eye can discern.

Using a camera with pattern detection will be slower than the IR sensor. You won't get numbers about the speed of IR sensors here. This entirely depends on the sensor, what phototransistors are used and if you have additional circuitry on the sensor. When you use a pure phototransistor without any circuitry connected to an analog input it will be limited by the sample rate of the ADC. This again depends on the used microcontroller/ADC, the chosen resolution (lower resolution gets faster) and the further processing of the data (slowest part of the chain dictates the total speed)

Thanks, that was useful!

https://www.instructables.com/IR-Transmitter-and-Receiver-Using-Arduino/
As demonstrated in the project linked above an IR sensor connected to an Arduino is capable of reading and decoding the signal from a typical IR remote sending at about 38 KHz. In the ones I've tried the signal is a burst of 10 or 11 digits.  Given that, sensing the presence or absence of a contrasting color sounds quite a bit less challenging.
I built the decoder in the linked Instructable with a Nano (author used a Mega) and it worked well.
I believe what you're proposing is feasible.

38KHz is the modulation frequency of IR, not the data rate it transmit. The transmission rate using 38KHz modulation is typically around 2400 baud.

I stand corrected. Thanks. Still should be fast enough to capture a 1 bit signal, i.e. a blob of white text on a passing cable.


text:
High frequency sampling with Arduino
I need to sample signals up to about 200 kHz using the Arduino as a kind of oscilloscope. I have already seen that by itself it is unable to do it, since the sample frequency is about 9.6 kHz. But would it be possible to connect it with an external ADC?
Thanks.

If the signal is about 200kHz, the sample rate must be greater than 400kHz.
So, you actually can use some external ADC with parallel interface, but what do you do next with this data stream?

The idea was to process them in the Arduino to obtain a graph

The rule of thumb for scopes is about 5X the frequency. 2X will give you some information but a lot will be missing. What is the voltage range of the input signals? How many bits of accuracy do you need. How about probes? Then there is memory.
You cannot access the internal memory of the Arduino so it will have to be external and dual ported. Dual ported indicates two different sources can access it. How are you going to refresh the memory if dynamic? Static would work but is more expensive.
I would highly recommend you purchase your scope unless this is a learning experience. You can get some very inexpensive scopes for under $100 or even a used one. I think these would work much better then anything you can build for for the same cost.
Many scopes have a interface to external devices can access them, this may be just what you need?

In the end it seems that I don't have to sample at such a high frequency. But, thanks for the information.


text:
How much current needed to power arduino uno?
I am planning to build an rc car based on arduino uno. I will use 3S 11.1 V Li-po to power whole circuitry. So my question is;
First, can arduino be powered directly with 11.1V from its Vin pin? Would it be a problem or not? If it is OK, then no need to answer the bold part below.
If it is not, then one solution comes to my mind is to use a voltage regulator which will convert 11.1 V to 5 V. But while choosing a regulator, I saw that max output current is one of the important specs. So what is the minimum amount of current needed to run Arduino UNO?

The maximum voltage at the Vin pin is 12V, so using your battery is fine!
Considering the current consumption:
The arduino itself will usually source less than 200mA, but your whole setup will probably sink more than that.

I was wondering just because of the current limitation of voltage regulator, I would use it only to power arduino. For exampe there was one with max 600mA output current so in that case, if 11.1 V wasn't be a valid input, then 600mA is also capable of supplying arduino based on what I understood from your answer. Thanks!