message:
Convert comma-delimited Arduino String of hex values to array of bytes

<!-- language-all: lang-arduino -->

My apologies if this is a naive question. How do I convert a `String` which has hex values to a byte array that has those hex values?

This:

    String s = "0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff";

Needs to be converted to this:

    char test[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };

I used the following procedure. It does convert it, however, each character is saved as a character as opposed to hex value:

    unsigned int str_len = s.length() + 1;
    char charArray[str_len];
    s.toCharArray(charArray, str_len);

Any help will be appreciated. Thank you!

body:
<!-- language-all: lang-arduino -->

There are C functions that can convert text to number. For example, [`strtol()`](https://www.tutorialspoint.com/c_standard_library/c_function_strtol.htm) or `atoi()`. Here is a little snippet to get you started:

```
char *str = "FF";
char *ptr;
int result = strtol(str, &ptr, 16); //the 16 is the base the string is in (HEX -> base 16)

```
`result` will have `0xFF` or `255` by the end. You can use this to achieve what you are trying to do. Take a look at [this](https://www.arduino.cc/reference/en/language/variables/data-types/stringobject/) for functions you can use to manage your `String`.


sender: user

sender: assistant

body:
<!-- language-all: lang-arduino -->

You only convert the String object to a char array. It need to further split the char array into substring, and then convert it to number.

To split the char array, you can use [strtok()](https://www.cplusplus.com/reference/cstring/strtok/) function in c++ to do the job.

There is no str conversion function that can convert `"0xff"` into `uint8_t` directly. However, as @rubemnobre mentioned [strtol()](https://www.cplusplus.com/reference/cstdlib/strtol/) can be used to convert a c string to a `long` (in Arduino, it is 4-byte number) and further cast into a `uint8_t` and store in a byte array.

    String s = "0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff";

    // Convert String object to char array
    unsigned int str_len = s.length()+1;
    char charArray[str_len];
    s.toCharArray(charArray, str_len);

    uint8_t byteArray[7];
    int i=0;

    // split charArray at each ',' and convert to uint8_t
    char *p = strtok(charArray, ",");
    while(p != NULL) {
      byteArray[i++] = strtoul(p, NULL, 16);
      p = strtok(NULL, ",");
    }

    // Print the byteArray
    for (i=0; i<sizeof(byteArray)/sizeof(char); i++) {
      Serial.print(byteArray[i]);
      Serial.println(", ");
    }
    Serial.println();


message:
Upgrade ESP-01 firmware on MacOS

I recently bought an ESP-01 as well as an FTDI programmer (3.3v-5v) and after typing `AT+GMR` I noticed it said:

- AT version:0.40.0.0(Aug  8 2015 14:45:58)
- SDK version:1.3.0
- Ai-Thinker Technology Co.,Ltd.
- Build:1.3.0.2 Sep 11 2015 11:48:04

I have looked and looked on a way to upgrade its firmware (on MacOS) to no avail. How can I upgrade it? I want to be able to change the baud rate to 9600. A lot of examples to do it are in windows requiring another application or something like that but how can I do it in a Macbook? Thanks.

body:
You use `esptool.py` available [from github](https://github.com/espressif/esptool).

It's exactly the same usage regardless of which operating system you are using (apart from the serial port device name of course), so instructions for Linux (for example) are the same as instructions for Mac OS X.


body:
Here is the step-by-step on upgrade the ESP-01 AT Command firmware (for running on macOS).

## Wiring

For flashing the ESP-01 firmware, you need to have a USB-TTL adaptor as a programmer.

    +---------------------+---------+
    |                     | RxD Vcc |
    |       Top View      | IO2 RST |
    |                     | IO0 CPD |
    |                     | GND TxD |
    +---------------------+---------+

    ESP-01          USB-TTL Adaptor
     VCC   ---------- 3V3
     GND   ---------- GND
     TxD   ---------- RxD
     RxD   ---------- TxD
     CH_PD ---------- see note* below
     GPIO0 ---------- Connect to a push switch (Flash button) to GND
     RST   ---------- a push switch (Reset button) to GND

>Note: depend on whether you have ESP-01 or ESP-01S, for ESP-01, you will need to connect CH_PD either directly to 3v3 or via a 3k-10k resistor to 3v3. However, you don't need an extra pull-up resistor for ESP-01S as CH_PD already has on-board pull-up resistor. This [picture](https://github.com/e-tinkers/better-way-to-use-esp-01/blob/master/images/ESP-01_versus_ESP-01S.jpg) shows the different between ESP-01 and ESP-01S, visually ESP-01 has 2 LEDs on board near the antenna, while ESP-01S have two extra resistor between header pins and ESP8266EX chip, and with only one LED.

## Download and install esptool

Download and install esptool from https://github.com/espressif/esptool. `esptool` is a python application. You need to have python installed as well.

## Download firmware 2.1

Download [ESP8266 nonOS SDK - Release 2.1.x](https://github.com/espressif/ESP8266_NONOS_SDK/tree/release/v2.1.x), noticed that this is not the latest version as the latest version doesn't works for ESP-01 based on my experience.

## Upgrade the firmware

You will actually only need 4 files for the upgrade, I would suggest that you copy and paste those files into your esptool directory from the downloaded `bin/` directory. `cd` into your esptool directory and run the following commands to upgrade the firmware.

To put ESP-01 into programming mode:
1) Press and hold BOTH buttons;
2) Release the Reset button while keep holding the Flash button until the upload is completed;
3) Press Reset to start the newly uploaded program when all upgrades are done.

```
./esptool.py --port /dev/cu.SLAB_USBtoUART write_flash 0x00000 boot_v1.7.bin
./esptool.py --port /dev/cu.SLAB_USBtoUART write_flash 0x01000 user1.1024.new.2.bin
./esptool.py --port /dev/cu.SLAB_USBtoUART write_flash 0x7c000 esp_init_data_default.bin
./esptool.py --port /dev/cu.SLAB_USBtoUART write_flash 0x3e000 blank.bin
./esptool.py --port /dev/cu.SLAB_USBtoUART write_flash 0x7e000 blank.bin
```

***Please noted that `/dev/cu.SLAB_USBtoUART` is the USB port for my USB-TTL interface, yours might be different, run `ls /dev/tty.*` to find out your USB port***


message:
ESP8266 not responding after random intervals of time

**4th Update:**
I bought an ESP32 (the successor to ESP8266) and am getting the same problem. I used the same code except used the `Wifi.h` library instead, also removed the `ESP8266WiFiGratuitous.h` code. I added an LED flash at the start of the loop and can confirm the LED stops flashing, so I can confirm the `loop()` stops running.
This makes me think it must be something to do with my WIFI network.

**3rd update:**
I've removed all the code and instead uploaded a simple onboard LED blink sketch. The LED has been blinking for over 24 hrs which leads me to think there is something in the wifi code that is making the software crash.

**2nd update:**
I've even tried resetting the board at the start of the `loop()` body, every 10 mins, using the millisDelay.h library, calling this method to reset:

    void(* resetFunc) (void) = 0;

but that doesn't help either. The `loop()` method seems to completey stop running.

**Update:**
I've added `experimental::ESP8266WiFiGratuitous::stationKeepAliveSetIntervalMs();` but am still failing to get a response after 1hr, with about 15 requests made in that hour.

I have this code which works on my ESP8266:
```c++
    #include <ESP8266WiFi.h>
    #include <ESP8266WiFiGratuitous.h>

    const size_t input_buffer_length = 256;

    const char* ssid = "iiNetC2DAD7";
    const char* wifiPassword = "aM9PrxcbtkS";
    const char* passwordToOpenDoor = "/87"; //password should begin with a slash

    const int doorPin = 5;
    const int buzzerPin = 4;
    const int toneDuration = 700;

    int numOfRequests = 0;

    WiFiServer server(301); //Pick any port number you like
    WiFiClient client;

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

      pinMode(LED_BUILTIN, OUTPUT);
      digitalWrite(LED_BUILTIN, 1);

      pinMode(doorPin, OUTPUT);
      digitalWrite(doorPin, 0);

      pinMode(buzzerPin, OUTPUT);
      digitalWrite(buzzerPin, 0);

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

      WiFi.begin(ssid, wifiPassword);

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

      experimental::ESP8266WiFiGratuitous::stationKeepAliveSetIntervalMs();

      server.begin();
      Serial.println("Server started.");
      Serial.println(WiFi.localIP());
    }

    void loop() {
      client = server.available();
      if (!client) {
        return;
      }

      while(!client.available()){
        delay(1);
      }

      char request[input_buffer_length];
      client.readBytesUntil('\r', request, input_buffer_length);
      Serial.println(request);

      if(strstr(request, passwordToOpenDoor)) {//Is password correct?
        GenerateResponse("Password is correct");
        OpenDoor();
        CorrectPasswordSound();
      }
      //Got a GET request and it wasn't the favicon.ico request, must have been a bad password:
      else if (!strstr(request, "favicon.ico")) {
        GenerateResponse("Password is incorrect.");
      }
    }

    void OpenDoor() {
      digitalWrite(LED_BUILTIN, 0); //flash the onboard LED to help during testing.
      digitalWrite(doorPin, 1);
      delay(500);
      digitalWrite(LED_BUILTIN, 1);
      digitalWrite(doorPin, 0);
    }

    void GenerateResponse(const char *text) {
      Serial.println(text);
      client.print(
          "HTTP/1.1 200 OK\r\n"
          "Content-Type: text/html\r\n"
          "\r\n"
          "<!DOCTYPE HTML>\r\n"
          "<html>\r\n"
          "<br><h1><b>"
      );
      client.print(text);
      client.print("</b></h1><br><h1><b>Num of requests: ");
      client.print(++numOfRequests);
      client.print("</b></h1></html>\r\n");
      client.flush();
    }

    void CorrectPasswordSound() {
      //Play 1700, 1800, 1900Hz
      for(int i = 17; i < 20; i++){
        int frequency = i * 100;
        tone(buzzerPin, frequency);
        delay(toneDuration);
        noTone(buzzerPin);
      }
    }
```
- However, after a random amount of time, the software crashes and the device won't respond to HTTP requests anymore.

- I've tested this by printing to the serial monitor every loop. It seems as though it crashes and the `loop()` function stops running since it stops printing to the monitor.

- I noticed that it'll still reply to pings.

- It won't reconnect after restarting the router, I need to press the reset button on the ESP8266 to get it to start working again.

- I've tested it by sending an HTTP Get request every 5 mins for many hours (using a C# console app). Sometimes it failed after 45 mins, sometimes 7 hours.

- I initially thought it was because I was using String objects, but after getting an answer to this [question][1] and testing it out with only C-strings, I still have the same problem.

- I've been sending HTTP Get requests using Chrome on my phone and laptop, as well as the .NET Framework class `System.Net.Http.HttpClient`.

Spec:
* Board: AI-Thinker ESP8266MOD
* IDE: Arduino 1.8.12
* ESP8266 Boards version = 2.6.3
* IDE Settings:

[![enter image description here][2]][2]

I've tried resetting the connection using:

    server.stop();
    delay(1000);
    server.begin();

Then this:

    ESP.reset();

Then after those 2 didn't work, this:

    ESP.restart();

Resetting it frequently did nothing.

Is there anything in my code that stands out?
If there's nothing wrong withe code, then maybe my only option is to hard reset the board every 30 mins some how.

  [1]: https://arduino.stackexchange.com/questions/75450/how-to-replace-string-objects-with-char-arrays-while-still-using-string-methods
  [2]: https://i.stack.imgur.com/6oHsU.png

body:
This will be the "server unreachable after a while" problem, which is solved solved by sending gratuitous ARP requests. In the esp8266 Arduino core 2.7 they added functions for this. The main function is `experimental::ESP8266WiFiGratuitous::stationKeepAliveSetIntervalMs();`. Include `<#include "ESP8266WiFiGratuitous.h>`

Notes:

- You don't know if your loop stops. It doesn't print anything if no client can reach it.

- remove the flush() after readBytesUntil(). it doesn't do what you think it does.


body:
I don't know if this is your problem, but I'll leave it here because it is certainly a potential bug.

This code in loop:

      while(!client.available()){
        delay(1);
      }

can cause a deadlock if you have a client that drops or doesn't talk.  Turn that around and let the loop keep running.

    boolean haveClient = false;

    void loop() {
      client = server.available();
      if (client) {
        haveClient = true;
      } else {
        haveClient = false;
      }

      if(haveClient && client.available()){

         // The rest of your loop where you read
         //  from the client goes inside here.

That way if you get a client and then available keeps returning false you can at least keep checking for a client.

This may not be and is not intended to be a code solution. This is probably not the best way to code what I'm trying to say.  I don't know if server.available will keep giving you back the same client or if it is going to cut you off to call that again before the client disconnects.  There may be some method in there to check the connection.  Either way, that's not the point.  The point is to never capture your code into a locked up while loop.  That is always asking for a deadlock.  It's bad practice except for cases like fatal errors where you truly want to lock the thing up.  Let the loop keep looping.  Use if statements to decide which parts get run when.

If you want to check that this is where you are locking up, put some sort of output before and after that while loop.  Print something or turn a light on before and off after.  That way you can tell if this is the spot you're locking up.


body:
Thanks to Delta_G for pointing me in the right direction.
The trick was to not get stuck in the `loop()` function, ie. no while loops.

The problem was that after you run `client = server.available();`, the client needs some time before `client.available()` returns true, which is what the while loop is for, **however**, for some reason, the client would lose its connection every now and then and `client.available()` would never return true, in which case you get stuck in the while loop. You need to give it a second chance and let the process start again.

By delaying about 50ms, it seems to be enough time for the client to establish a connection, and if it doesn't, it loops and tries again so quickly that it appears as though the client always gets the connection and the code works fine.

Here's the working code:

    void loop() {
      WiFiClient client = server.available();

      if(client){
        delay(50);
        if(client.available()) {
            //rest of code here
        }
    }


body:
I'm facing the similar problem especially when the WIFI signal is weak. The connection drop prematurely, end up the software execution is stuck within the while(!client.available()) loop.

A fail-safe timer can be implemented to get out from this loop as follow:

      unsigned int u32FailSafeTimer = 3000;   /*Set 3s timeout*/
      while(!client.available())
      {
        u32FailSafeTimer--;
        delay(1);   /*pause for 1ms*/
        if (0 == u32FailSafeTimer)   /*Fail-safe timer elapsed, get out from unexpected error*/
        {
          Serial.printf("timeout (RSSI: %d dBm)\n\n", WiFi.RSSI());
          client.flush();   /*Kill and prepare for next session*/
          return;
        }
      }


body: I will take a SWAG and say it sounds like the watchdog may be getting you. I was getting similar problems but nothing to do with WiFi or anything like that. I determined that when it got stuck in a loop it would sit for a while and then crash. I was able to determine (guess) something was timing out and since the external hardware did not reset and yet it would run setup() again the processor was resetting itself. It would hang with some things appearing to work. After I dug down into it I found that I had to release my code to allow the watchdog to be reset by the internal ESP software. I based this on some information I found about the maximum time allowed for the delay() function. Hopefully this helps.


message:
Arduino Nano, DS3231 RTC clock module and 4 cascaded FC-16 led matrix modules

Like I said in the title, I am using a DS3231 real time clock module and 4 cascaded FC-16 modules(they are basically MAX7219 led matrices based modules). My goal is to display a timetable, a schedule for a classroom on the matrices. The purpose of the DS3231 module is to keep track of time(mainly hours) from 8:00AM to 20:00PM, to display the hour on the matrix and to change the subject when it hits even hours.
Eg: when it's 8:00AM we have subject A, when it's 10:00AM we have subject B etc

And after that I have to use a ESP8266 wifi module to change the schedule from distance.

EDIT1:
I managed to display the hour on the matrix, but now I really can't figure out how to display the text in 4 rows. I have 4 FC-16 modules and I want to put each of them on top of the other so I can have 4 rows of text. I managed to do this by inserting space between words but this is not optimal. I want this to be automated so the person changing the text in the program doesn't have to do the spacing thing by themselves.

```
#include "RTClib.h"
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

const uint16_t WAIT_TIME = 1000;

#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 16

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

MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

RTC_DS3231 rtc;

//char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup () {
  P.begin();

  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

 if (rtc.lostPower()) {
    Serial.println("RTC lost power, lets set the time!");
//     If the RTC have lost power it will set the RTC to the date & time this sketch was compiled in the following line
   rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));

  }
}

void loop () {
    DateTime now = rtc.now();

    char buffer[] = "hh:mm";  // hours and minutes
    P.print(now.toString(buffer));  // display

   // Serial.println();
    delay(1000);
}```

body:
> how do I display the time from the DS3231 clock module on the FC-16
> led matrix modules?

You can use the [`DateTime::toString()` method][toString] to convert the
current time to a string in the format of your choice, then `P.print()`
to display that string on the LED matrix:

```c++
void loop() {
    DateTime now = rtc.now();
    char buffer[] = "hh:mm";  // hours and minutes
    P.print(now.toString(buffer));  // display
}
```

> how do I use that hour of the day so that the microcontroller knows
> what text it should display next?

Condition your logic on [`now.hour()`][hour].

[toString]: https://adafruit.github.io/RTClib/html/class_date_time.html#a3753bf2ae254315a56f7ee38ff0b188b
[hour]: https://adafruit.github.io/RTClib/html/class_date_time.html#ac17441fb0c669bcf3be5de278335e8d0


message:
Changes to user included library

I've been putting a small helper library together which I'm just including manually via the libraries sub-directory. I've just made some changes to the library in the filesystem however when trying to compile a previous sketch referencing it (after making the appropriate changes), the compiler is complaining and it appears to still be using the old version of the library. What's going on here and what is the correct way to update such a library?

I have tried completely reloading the Arduino IDE to flush out any caches etc. but that didn't help

body:
Whatever compiler you are using (Arduino IDE?) should have a 'verbose' setting that you can activate.  This will give you a HUGE amount of output, but will also show you exactly what file is being accessed for the library in question.

When I do this, I copy/paste the entire output into Notepad++ and use its search capabilities to sort through all the chaff.

Frank


message:
Trying to do hello world app for Nokia 5110 LCD with arduino yun and johnny five

I have a Nokia 5110 LCD which is using this display `PCD8544`, I am using a arduino yun and johnny five I have hooked up the following pins. So far with my node app all that happens is the lcd lights up. I am not sure if maybe the lcd is not supported with johnny five, if I have a pin wrong. I followed this site for the pin setup https://lastminuteengineers.com/nokia-5110-lcd-arduino-tutorial/ Any help would be greatly appreciated. This is my first attempt with Johnny five and second attempt at hooking anything up to a bread board. Hope we can get this working. Thanks

Here is my code

```
const five = require('johnny-five');
const board = new five.Board();

board.on("ready", function() {

    lcd = new five.LCD({
      controller: "PCF8574"
    });

    lcd.print("Hello");
  });
```

Here is my configuration

```
blue         =  pin 7          sclk     (serial clock(CLK)) 10 om
white        =  pin 6          DN(MOSI) (Serial data in) 10om
grey         =  pin 5          D/C      (Mode select) 10om
orange       =  pin 4          RST      (Reset) 10om
yellow/red   =  pin 3          SCE      (Chip select) 10om
yellow-short =  power strip +  LED      (backlight supply) 1kom
green/black  =  gnd / strip -
blue/power   =  3.4v power + 330om
```
Here is are some images of the setup

[![arduino setup #1][1]][1]

[![arduino setup #2][2]][2]

[![arduino setup #3][3]][3]

Update so my configuration looks more like this now

```
blue         =  pin 7          sclk     (serial clock(CLK)) 10k
white        =  pin 6          DN(MOSI) (Serial data in) 10k
grey         =  pin 5          D/C      (Mode select) 10k
orange       =  pin 4          RST      (Reset) 10k
yellow/red   =  pin 3          SCE      (Chip select) direct
yellow-short =  power strip +  LED      (backlight supply) 330
green/black  =  gnd / strip -
blue/power   =  3.4v power powerstrip direct
```

  [1]: https://i.stack.imgur.com/besXf.jpg
  [2]: https://i.stack.imgur.com/IBaV2.jpg
  [3]: https://i.stack.imgur.com/axfWW.jpg

body:
Arduino Yun is a ATMega32U4-based board, like other ATMega32U4-based Arduino boards, such as Arduino Leonardo, Micro, the SPI is only available on the ICSP header:

    MOSI - Yun has it on ICSP Pin 4
    MISO - Yun has it on ICSP Pin 1
    SCK - Yun has it on ICSP pin 3
    SS - Yun has no dedicated pin, use any digital data pin

You can find out the ICSP header pin assignment at [Arduino SPI](https://www.arduino.cc/en/Reference/SPI) reference page. So here is the connection between Arduino Yun and LCD5110

    Yun               LCD 5110
    ICSP pin3         CLK(SCK)
    ICSP pin 4        DN(MOSI)
    any GPIO pin      D/C (see note 1)
    RST               RST
    any GPIO pin      SCE(SS) (see note 1)
    any GPIO pin      Backlight (via a 330 ohm resistor) (see note 2)
    GND               GND
    3v3               VCC

> Note 1: Although you could use any GPIO for D/C and SCE, you should consult the library that you are using to see what pin the library used for the data/command line and SS line.

> Note 2: Connecting to a GPIO pin allows you to turn on and off the LED backlight, you could ignore the connection if you don't want the backlight, or you could connect it directly to 3v3 via a resistor if you want backlight on permanently

If you still have problem in using the LCD5110, please update your question with complete code and the library that you are using.


message:
Is it possible to overload the digital pins for an Arduino?

I worked on an Arduino project for school that was a self-driving security robot that also acted as a smart home system.

It was essentially a self-driving Roomba-like car that included several LED's(resembling home appliances), three distance sensors, an LCD screen, a motion sensor, an audio amplifier with a speaker, an SD card module to store .wav files, a Bluetooth module to connect with MIT App Inventor, and a motor driver that controlled two electric motors. It's a long list of modules so the Arduino Mega was required. When assembling all of these modules and building the code, I would perform intermittent tests that would isolate the obstacle avoidance and driving, turning on appliances(LED's), and sending and receiving data from the phone app. Every aspect of the project worked in isolation until I combined everything.

When everything was combined, instead of simply driving forward until an obstacle is detected as its programmed, the car would jitter around and not react to walls or obstacles. Also, the LCD screen was heavily dimmed as opposed to when the Arduino was running off of laptop power. Especially when the phone app called for turning on heat or AC, the proper LED's would turn on, but the whole system seemed to respond to the initial load required to read a .wav file and play the corresponding audio and made the jitter worse.

So my question is this, with all these modules plugged into an Arduino, is it possible that the number of modules all needing some input from the digital pins has highlighted a current limitation? All of these issues were exacerbated when the laptop power was replaced with a 9v battery. I was able to confirm that the code was not the issue as I would simply comment out major portions but leaving all the pins initialized. Also, if there is a current output limitation, is there any way to explain why? Thank you for reading my lengthy post and for giving feedback.
[![enter image description here][1]][1]  [![enter image description here][2]][2][![enter image description here][3]][3]

  [1]: https://i.stack.imgur.com/ppWJh.jpg
  [2]: https://i.stack.imgur.com/9etGs.jpg
  [3]: https://i.stack.imgur.com/uuzo0.jpg

body:
As mentioned in the comments, you cannot power your robot from a 9V block battery. These are made for low power projects (like a smoke detector) and cannot provide enough current to drive even only the motors correctly. Using 2 of them does not really help much. You need to change to a different battery type. If you want to stay with alkalines, you could use six AA batteries or C cells, like jsotola suggested. But you might want to upgrade to a fitting LiPo/LiIon battery (in combination with a fitting battery charger module). That would give you enough power for all your needs, while being rechargable.

A different issue: It seems to be, that you provide all the components (sensors and motors) with power through the 5V pin of the Arduino. But especially with motors you can easily reach the current limitation of the voltage regulator on the Arduino. When drawing more current through it, than recommended, the regulator will go in emergency shutdown (with a genuine Arduino; with the cheap clones, the regulator will melt and be destroyed).

Instead you need to be sure, that the drawn current does not exceed the maximum current for the voltage regulator (depends also on the voltage provided). At least the motors should be provided with power parallel to the Arduino, so that the motor current will not flow through the Arduino. It is unclear, how you are controlling the motors. If you are using a motor shield, then look for the terminal for external power supply on it. Most motor shields have them. Depending on the batteries, you will use in future, and on motors and shield, you maybe an directly connect the battery voltage to the shield. Or you need to buy an extra (switching) voltage regulator, which brings the battery voltage down to 5V. In that case be sure, that the regulator can provide the needed current plus some overhead clearance.


message:
ATtiny85 - report error "Device reports version as: 2.2"

I've bought ATtiny, from [see link][1].
Trying to upload a basic `Blink` sketch I get this error: `Device reports version as: 2.2`.

1) Board manager was updated using `http://digistump.com/package_digistump_index.json`

2) Board selected as `Digispark (Default -16.5MHz )`

3) Programmer set to `Micronocleus`

Tried using some guides on-line, but some were old, some were for windows, while I'm using Ubuntu machine.

Appreciate any help,
Guy

  [1]: https://www.aliexpress.com/item/32584084654.html?spm=a2g0o.productlist.0.0.459ed540M9V5c7&algo_pvid=e91a8f78-fe84-44a2-9aab-859c070bbf1f&algo_expid=e91a8f78-fe84-44a2-9aab-859c070bbf1f-0&btsid=0be3743b15889238058037747e8a9d&ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_

body:
It sounds like you have a newer board than the version of Micronucleus in the Arduino package.

As I discovered [here](http://digistump.com/board/index.php/topic,1834.msg8364.html#msg8364) you basically need to upgrade micronucleus in your Ardino installation, which you can download from [here](https://github.com/micronucleus/micronucleus)

* Download the zip file from Github and extract it.  Then in a terminal (if you're not already in one) go to the directory you extracted.
* Build the executable by typing "make"
* Copy the compiled executable to `~/.arduino15/packages/digistump/tools/micronucleus/<version>/`

where `<version>` is the currently installed version number (e.g., `2.0a4`).  There should already be a `micronucleus` executable in there that you would replace with your newly compiled one.


message:
Is there possible implement websocket using AT Command?

For example I have a `sim800l` module to communicate to a server using `websocket` (socket.io) but that module allows AT Command to operate.

I have successfully made an HTTP request, but I don't know how to make a request via WebSocket using AT Command.

thank you.

body: Yes, you can @Imanuel. You just need to establish a Simple TCP connection and then send the HTTP headers for upgrading the normal HTTP connection to WebSockets.


body: After implementing the necessary changes, I was able to successfully resolve the issue. My code is now working seamlessly in both sending and receiving data through WebSocket and SIM800 module. As per the WebSocket protocol, I made sure to establish the initial handshake before sending any data. This helped to ensure that the data transmission was in accordance with the WebSocket standard.


message:
FC-16 led matrix module based on MAX7219

EDIT:

```
const char  *pc[NUM_ZONES] =
{
  "ROOM", //0
  "SUBJECT", //1
  "GRADE",//2
  };
```

I did this and I can't get them to display every row simultaneously.

```
void loop(void)
{

 DateTime now = rtc.now();
 char buffer[] = "hh:mm";  // hours and minutes

 for (uint8_t i=0; i<NUM_ZONES; i++){
   P.displayZoneText(0,now.toString(buffer), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
   P.displayZoneText(1, pc[1], PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
   P.displayZoneText(2, pc[2], PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);  // display
   P.displayZoneText(3, pc[3], PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
 }
}
```

I can only display one row at a time like this, now it only displays the hour:min.

Tell me what am I doing wrong

EDIT2:

Or like this:

-this is my goal, to change the text based on hour

```
void loop(void)
{

 DateTime now = rtc.now();
 char buffer[] = "hh:mm";  // hours and minutes

   P.displayZoneText(0,now.toString(buffer), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);

   if(now.hour()==21){
   P.displayZoneText(1, pc[1], PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
   P.displayZoneText(2, pc[2], PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);  // display
   P.displayZoneText(3, pc[3], PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
   }
   P.displayAnimate();
}
```

And at the moment with this code it only displays the hour and minutes

body:
I haven't used this library, but reading through the documentation it seems it operates on the concept of zones.

1. Create a zone for each row (a zone is a contiguous block of modules forming a kind of sub-display)
2. Perform operations on the zones with the zone-specific functions.

For example, setting up your zones would be:

```
P.begin(4); // We will have 4 zones
P.setZone(0, 0, 3); // Modules 0-3 in zone 0
P.setZone(1, 4, 7); // Modules 4-7 in zone 1
P.setZone(2, 8, 11); // Modules 8-11 in zone 2
P.setZone(3, 12, 15); // Modules 12-15 in zone 3
```

Then you can clear a zone with:

```
P.displayClear(2); // Clear zone 2
```

And write text to a zone with:

```
P.displayZoneText(3, "P03", PA_CENTER, 0, 0, PA_NO_EFFECT, PA_NO_EFFECT);
```

I'm not certain about what all the parameters mean, but the prototype is:

```
void displayZoneText(uint8_t z, const char *pText, textPosition_t align, uint16_t speed, uint16_t pause, textEffect_t effectIn, textEffect_t effectOut = PA_NO_EFFECT);
```


message:
UNIX time in ms to human date time

Been struggling with something for a few days.

Loading data from a website via JSON and it includes an updated date time in milliseconds. This is an EPOCH date and I can get the right value using some of the online convertor sites, epochconvertor.com

That said when I try and parse it in my sketch it’s not retuning the correct date.

JSON
“currentupdatedms”:1588312648603

Convertor Shows as:
1 May 2020 05:57:28.603

My sketch is showing:
1 May 2020 02:33:00

That’s in the JSON and I can’t use a Long as it’s 13 digits. Tried Long Long and it accepts the value but when I later divide by 1000 to get seconds the number changes completely when I try printing it to serial or the OLED.

Plan is to use the Timeh library to display it as a human date time.

Any thoughts be appreciated.

Here is my code and I have tried various methods:

    #include <ESP8266WiFi.h>
    #include <ESP8266HTTPClient.h>
    #include <ArduinoJson.h>
    #include <TimeLib.h>
    #include <time.h>
    #include <Wire.h>
    #include <Adafruit_GFX.h>
    #include <Adafruit_SSD1306.h>

    #define SCREEN_WIDTH 128 // OLED display width, in pixels
    #define SCREEN_HEIGHT 64 // OLED display height, in pixels

    // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
    #define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
    Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

    #define ARDUINOJSON_JSON_LONG_LONG 1 //Not needed???
    #define   ONE_HOUR   3600
    const size_t capacity = JSON_OBJECT_SIZE(8) + 140;
    DynamicJsonDocument doc(capacity);

    /*Notes
       Need to look at conversion of Update and Changed times as they are not showing correctly
       Move the conversion of time datetime in ms to a seperate function
       Move the get request and JSON section to seperate function
    */

    const char* ssid = "SSID";
    const char* password = "PWD";

    void setup () {

      Serial.begin(4800);

      Wire.begin(2, 0);           // set I2C pins (SDA = GPIO2, SCL = GPIO0), default clock is 100kHz

      // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
      if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
        Serial.println(F("SSD1306 allocation failed"));
        for (;;); // Don't proceed, loop forever
      }

      display.clearDisplay();
      display.setTextColor(SSD1306_WHITE);

      WiFi.begin(ssid, password);

      display.setCursor(0, 0);
      display.println(F("Connecting to Wifi..."));
      display.display();

      while (WiFi.status() != WL_CONNECTED) {
        delay(1000);
        Serial.println("Connecting to Wifi...");
      }

      display.setCursor(0, 10);
      display.println(F("Wifi Connected..."));
      display.display();
    }

    void loop() {

      if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status

        display.setCursor(0, 20);
        display.println(F("Requesting Data..."));
        display.display();
        delay(2000); // Pause for 2 seconds

        HTTPClient http;  //Declare an object of class HTTPClient

        http.begin("http://corona.tuply.co.za/DataHandler.ashx?w=s&uq=8f1fp8p5jdxi84481");  //Specify request destination
        int httpCode = http.GET();                                                                  //Send the request

        if (httpCode > 0) { //Check the returning code

          String payload = http.getString();   //Get the request response payload
          Serial.println(payload);                     //Print the response payload

          deserializeJson(doc, payload);

          int TotalCases = doc["TotalCases"];
          int TotalCasesToday = doc["TotalCasesToday"];
          int TotalDeaths = doc["TotalDeaths"];
          int TotalDeathsToday = doc["TotalDeathsToday"];
          int TotalRecovered = doc["TotalRecovered"];
          int TotalTerritories = doc["TotalTerritories"];
          long long CurrentUpdatedMS = doc["CurrentUpdatedMS"];
          long long CurrentChangedMS = doc["CurrentChangedMS"];

          //delay(10000);

          time_t CurrentUpdateMS_t = (CurrentUpdatedMS/1000) + ONE_HOUR; //ONE_HOUR added for BST

          char buffUpdateMS[32];
          sprintf(buffUpdateMS, "d/d/d d:d:d", day(CurrentUpdateMS_t), month(CurrentUpdateMS_t), year(CurrentUpdateMS_t), hour(CurrentUpdateMS_t), minute(CurrentUpdateMS_t), second(CurrentUpdateMS_t));
          Serial.print("U:");
          Serial.println(buffUpdateMS);
          Serial.print("ctime: ");
          Serial.println(ctime(&CurrentUpdateMS_t));

          time_t CurrentChangedMS_t = CurrentChangedMS/1000 + ONE_HOUR; //ONE_HOUR added for BST

          char buffChangedMS[32];
          sprintf(buffChangedMS, "d/d/d d:d:d", day(CurrentChangedMS_t), month(CurrentChangedMS_t), year(CurrentChangedMS_t), hour(CurrentChangedMS_t), minute(CurrentChangedMS_t), second(CurrentChangedMS_t));
          Serial.print("C:");
          Serial.println(buffChangedMS);
          Serial.print("ctime: ");
          Serial.println(ctime(&CurrentChangedMS_t));

          display.clearDisplay();

          display.setCursor(0, 0);
          display.print(F("T Cases: "));
          display.println(TotalCases);

          Serial.print("Total Cases: ");
          Serial.println(TotalCases);

          Serial.print("Total Cases Today: ");
          Serial.println(TotalCasesToday);

          display.setCursor(0, 10);
          display.print(F("T Deaths: "));
          display.println(TotalDeaths);

          Serial.print("Total Deaths: ");
          Serial.println(TotalDeaths);

          Serial.print("Total Deaths Today: ");
          Serial.println(TotalDeathsToday);

          display.setCursor(0, 20);
          display.print(F("T Recov: "));
          display.println(TotalRecovered);

          Serial.print("Total Recovered: ");
          Serial.println(TotalRecovered);

          Serial.print("Total Territories: ");
          Serial.println(TotalTerritories);

          display.setCursor(0, 30);
          display.print(F("U T: "));
          display.println(buffUpdateMS);

          display.setCursor(0, 40);
          display.print(F("C T: "));
          display.println(buffChangedMS);

          display.display();

        }

        http.end();   //Close connection

      }

      delay(60000);    //Send a request every 60 seconds

    }

If I run that now I get this JSON string:

{"TotalCases":4036128,"TotalCasesToday":26837,"TotalDeaths":276825,"TotalDeathsToday":849,"TotalRecovered":1400460,"TotalTerritories":214,"CurrentUpdatedMS":1589027095790,"CurrentChangedMS":1589026765665}

CurrentUpdateMS = 1589027095790 which is Sat May 09 2020 13:24:55, granted there may be an hour difference with BST.

Instead I am getting:

Sat May  9 13:23:32 2020

Also appears to stay the same after refreshes which I have set to 60 seconds.

I tried the Time.h library with same results.

Thankful for any input or suggestions.

body:
It's hard to know what is wrong with your code... because you are not
showing it in the question! Here is a basic test I tried on my Uno:

```c++
#include <time.h>

const uint64_t ms = 1588312648603;

void setup() {
    time_t t = ms/1000 - UNIX_OFFSET;
    Serial.begin(9600);
    Serial.println(ctime(&t));
}

void loop(){}
```

It's output is:

```c++
Fri May 01 05:57:28 2020
```

Note that this <time.h> comes from the avr-libc. It uses an epoch
different from the Unix epoch, hence the `UNIX_OFFSET` correction.

**Edit**: I tried replacing avr-libc's `<time.h>` by [Adafruit
RTClib][RTClib] (declaring `DateTime t(ms/1000);`) and [Paul
Stoffregen’s Time library][Time] (with `time_t t = ms/1000;`). In all
cases I get the same time displayed.

[RTClib]: https://github.com/adafruit/RTClib
[Time]: https://github.com/PaulStoffregen/Time


message:
motor controll holding ir remote button

im controlling some small dc motors using arduino uno and tle94112el shield. currently, i can independently controll motors by pressing remote's buttons, but i wanna keep one motor rotating by holding a button. for example, by holding "unu" button, i wanna power the motor with 50% duty cycle, as i currently do by just pressing "unu".
thank you!

    #include <TLE94112.h>
    #include <Tle94112Motor.h>
    #include <IRremote.h>

    #define unu 0x1
    #define patru 0x4
    #define sapte 0x7

    int RECV_PIN = 2;

    // Tle94112 Object
    Tle94112 controller = Tle94112();

    // Tle94112Motor Objects
    Tle94112Motor motor1(controller);
    Tle94112Motor motor2(controller);
    Tle94112Motor motor3(controller);

    IRrecv irrecv(RECV_PIN);

    decode_results results;

    void setup()
    {
      // Enable MotorController Tle94112
      // Note: Required to be done before starting to configure the motor

       irrecv.enableIRIn();
      controller.begin();

       // Connect motor1 to HB1 and HB3
      motor1.connect(motor1.HIGHSIDE, controller.TLE_HB1);
      motor1.connect(motor1.LOWSIDE, controller.TLE_HB2);

      // Drive HB1 with signal from PWM1
      // Note: This allows to control the speed of the motor

      motor1.setPwm(motor1.HIGHSIDE, controller.TLE_PWM2);

      // Set PWM Frequency, default is 80 Hz
      motor1.setPwmFreq(motor1.HIGHSIDE, controller.TLE_FREQ200HZ);

      motor1.begin();
    }

    void loop()
    {
      if (irrecv.decode(&results)) {
        Serial.println(results.value, HEX);
        irrecv.resume(); // Receive the next value

        if (results.value == unu)
        {
          motor1.start(127);
        }

        if (results.value == patru)
        {
          motor1.start(255);
        }

        if (results.value == sapte)
        {
          motor1.start(0);
        }
      }

    }

---

thanks for replying. i followed your instructures. when i hold the button, my remote sends continuously the same code it sends for a single press too. so in the brackets of second "if", i used the same condition that i used in first "if". following your instructions, when i prees the button, motor starts, even if i release or keep holding the button, the motor keeps rotating, but when i press the same button second time, the motor stops. so instead of "timestamp = millis()", i used "timestamp < millis()", so in this situation, the motor was rotating as long as i kept the button pressed. now the problem is that the motor is powered with pulses, aprox. 2 impulses per second, it doesnt rotate smoothly. i tryed incresing and decreasing TIMEOUT with no effects. i also used all the pwm frequencies (80, 100, 200 hz) that the shield provides, and different duty cycles, also with no effects. but when i add 2 more motors, to controll them in the same way, each with it's own button, the pulses period was even bigger, with aprox one impuls on second. do you have any ideea about this? sorry, but its my first arduino project, i also have no experience on engineering forums. thaks for your time.

here is the code im using now:

    #include <TLE94112.h>
    #include <Tle94112Motor.h>
    #include <IRremote.h>

    #define unu 0x1

    unsigned long timestamp = 0;
    #define TIMEOUT   200

    int RECV_PIN = 2;

    // Tle94112 Object
    Tle94112 controller = Tle94112();

    // Tle94112Motor Objects
    Tle94112Motor motor1(controller);

    IRrecv irrecv(RECV_PIN);

    decode_results results;

    void setup()
    {
      // Enable MotorController Tle94112
      // Note: Required to be done before starting to configure the motor

       irrecv.enableIRIn();
      controller.begin();

       // Connect motor1 to HB1 and HB3
      motor1.connect(motor1.HIGHSIDE, controller.TLE_HB1);
      motor1.connect(motor1.LOWSIDE, controller.TLE_HB2);

      // Drive HB1 with signal from PWM1
      // Note: This allows to control the speed of the motor

      motor1.setPwm(motor1.HIGHSIDE, controller.TLE_PWM2);

      // Set PWM Frequency, default is 80 Hz
      motor1.setPwmFreq(motor1.HIGHSIDE, controller.TLE_FREQ200HZ);

      motor1.begin();
    }

    void loop()
    {
      if (irrecv.decode(&results)) {
        Serial.println(results.value, HEX);
        irrecv.resume(); // Receive the next value

        if (results.value == unu)
        {
          motor1.start(127);
          timestamp < millis();

        }

        if(results.value == unu){
          timestamp < millis();
        }

        if(millis() - timestamp > TIMEOUT){
          motor1.start(0);
        }
      }
    }

body:
As I understood you want the motor to run only while you are pressing the button, stopping as you release the button. IR remote controls normally don't send a "release" signal. But they often send a "repeat" signal in a defined frequency. The value of this signal depends on the remote, that you use. A quick search showed [this forum thread][1], where the value is `0xFFFFFFFF`.

So to check, if the button is still pressed, you need to regularly check, if the repeat code was received. When receiving the `unu` signal, turn on the motor and start a timeout counter. Every time you receive the repeat signal, you reset the timeout counter. If the timeout hits (meaning, that no repeat signal was received anymore), stop the motor.

The timeout counter is best done with the `millis()` function, which returns the number of milliseconds since startup. Refer to the `BlinkWithoutDelay` example, that comes with the Arduino IDE. Basically you save the time in a variable, when the `unu` code is received (the receive if statement is pseudo code). You reset the timestamp in the same way for every repeat code. Then you check, if the different between the current time (returned by `millis()` and the timestamp is over the timeout value (here 200ms). If yes, turn the motor off.

    unsigned long timestamp = 0;
    #define TIMEOUT   200

    void loop(){
        if(unu was received){
            // turn on motor here
            timestamp = millis(); //take timestamp
        }
        if(repeat was received){
            timestamp = millis();
        }

        if(millis() - timestamp > TIMEOUT){
            // turn off motor here
        }
    }

---

In your new version you replaces the `=` with a `<` to make it work. That is wrong. The lines, where you did it,  will just do nothing then. Instead the problem lies at a different place:

The `millis()` if statement

    if(millis() - timestamp > TIMEOUT)

has to be placed directly in `void loop()`, outside of the receive if statement. In your current version the timeout will only take effect, when something was received, which was not `unu`. But you want it to take effect also when nothing is received. In that case the receive if statement will not execute. So just move the `millis()` if statement outside of that receive if statement:

    #include <TLE94112.h>
    #include <Tle94112Motor.h>
    #include <IRremote.h>

    #define unu 0x1

    unsigned long timestamp = 0;
    #define TIMEOUT   700

    int RECV_PIN = 2;

    // Tle94112 Object
    Tle94112 controller = Tle94112();

    // Tle94112Motor Objects
    Tle94112Motor motor1(controller);

    IRrecv irrecv(RECV_PIN);

    decode_results results;

    void setup()
    {
      // Enable MotorController Tle94112
      // Note: Required to be done before starting to configure the motor

       irrecv.enableIRIn();
      controller.begin();

       // Connect motor1 to HB1 and HB3
      motor1.connect(motor1.HIGHSIDE, controller.TLE_HB1);
      motor1.connect(motor1.LOWSIDE, controller.TLE_HB2);

      // Drive HB1 with signal from PWM1
      // Note: This allows to control the speed of the motor

      motor1.setPwm(motor1.HIGHSIDE, controller.TLE_PWM2);

      // Set PWM Frequency, default is 80 Hz
      motor1.setPwmFreq(motor1.HIGHSIDE, controller.TLE_FREQ200HZ);

      motor1.begin();
    }

    void loop()
    {
      if (irrecv.decode(&results)) {
        Serial.println(results.value, HEX);
        irrecv.resume(); // Receive the next value

        if (results.value == unu)
        {
          motor1.start(127);
          timestamp < millis();

        }

        if(results.value == unu){
          timestamp < millis();
        }
      }

      if(millis() - timestamp > TIMEOUT){
        motor1.start(0);
      }
    }

That way the timeout will be checked at every `loop()` iteration. As you described, that you get the code about 2 times per second, I increased the timeout value here to 700ms, which then should be enough to not let the motor stop between the receiving of the `unu` command.

---

Btw: To stop the motor you are using `motor.start(0);`. While it works perfectly, you might want to write your code more speaking. The used library internally just calls it's `motor.coast();` function, when the parameter is zero. So to make it more obvious in your code, what you are doing there, you could replace `motor.start(0);` by `motor.coast()`. That can help others to understand your code better and also yourself, when you are revising the code yourself after some time, when you may have forgotten, what you thought at that time about the code. It is always better to write code, that speaks by itself about what it is doing.

  [1]: https://forum.arduino.cc/index.php?topic=361047.0


message:
Arduino 5V pump digital pin

I am trying to control a 5V pump with arduino and ultrasonic sensor however i can't make it work with the pump connected to a pin.

I saw on the forum that you need transistor or relay but i don't understand why ?

Thanks !

body:
Probably because the pump will use more current (mA) than a GPIO pin of the Arduino can deliver.

A GPIO pin on the Arduino can deliver 20 mA, or 40 mA max (but not advised for longer time).

Therefore, a separate power supplyis used, where the base pin of a transistor is connected to a GPIO pin (with a resistor) to 'switch' the transistor on and off.
The transistor base can be very low current (way within a GPIO's current range), which result in a much bigger current from the collector (connected to the power supply) to the emitter (connected to GND). The pump is somewhere between the external power supply and GND).

If you search for 'transistor as a switch' you will find many examples.

You also can use a relay if you don't need to switch it on often. Relay's are typically used for net-powered devices (110+ volts) and/or high current. See also Duncan's comments for additional notes regarding relays.


body:
@michel-keijzers has pointed you in the right direction. Depending upon the power requirements for your pump, you might consider looking specifically at [logic-level power MOSFETs](https://arduinodiy.wordpress.com/2012/05/02/using-mosfets-with-ttl-levels/) as the type of transistor in your circuit.

You might also investigate the use of a pull-up resistor to fully turn on a MOSFET.


message:
PWM Input Pins Never Receive a Value from Working Receiver?

I have a very simple sketch that's supposed to intercept the signal from an RC receiver and print the pulse duration from that channel.

Sketch

    int PwmPin = 9;
    unsigned long duration;

    void setup() {
      pinMode(PwmPin, INPUT);
      Serial.begin(9600);
    }

    void loop() {
      duration = pulseIn(PwmPin, HIGH);
      Serial.println(duration);
    }

Output

    0
    0
    0
    ...

My setup is the normal one that would occur without an Arduino, and only the battery is connected through the ESC to provide power to the receiver. The Arduino is connected via USB because I'm just trying to read values.

[![wiring][1]][1]

I have been trying to plug between the receiver's data pin to the Arduino's PWM pin and read the pulses from the rudder channel. (I have previously tested the channel with a servo and know that it works correctly). However, no signal (`0`) is being printed to the serial monitor. I have difficulty understanding why.

I checked the documentation for `pulseIn()`, and it seems simple enough. I tested PWM pins `D3`, `D5`, `D10`... none of them works. I don't understand where the problem is at this point. *Update: I am now connecting from the receiver's negative pin to one of the Arduino's `GND`s.*

This is a simplistic scenario, so I don't see what's going wrong (my programming experience is good, but my experience with Arduino is near nil).

The goal of this experiment is to program lights to change according to throttle input, and asymmetric thrust through two motors for a boat. I know that [pulseIn][2] isn't the best function to use, but for the moment I just want to do some quick development before getting into the weeds.

**Update:**
I am attempting to follow [this video][3], except that connecting the Arduino to the receiver didn't work, possibly because the ESC's BEC sends some sort of power signal that arms the receiver. (The receiver's LEDs usually make a visual signal, but they just turn on without a signal when connected through the Arduino).

According to [the manual][4] on page 6 and page 8, "receivers have an operational voltage range of 3.5 to 9 volts", with an ideal voltage being above 4.8V (because servos tend to brownout sooner). This should fall within Arduino range at 5V.

  [1]: https://i.stack.imgur.com/dF1Il.jpg
  [2]: https://www.arduino.cc/reference/en/language/functions/advanced-io/pulsein/
  [3]: https://www.youtube.com/watch?v=ncBDvcbY1l4
  [4]: https://www.spektrumrc.com/ProdInfo/Files/SPMAR6210_Manual.pdf

body:
What misled me is the pin numbers. I was referencing this diagram:

[![NANO pinout][1]][1]

I thought that all the pins were numbered sequentially, so that `pinMode(9, ...)` would set `D6` *(09 in the diagram)*. However, this sets `D9`. Connecting to the correct pin works fine.

  [1]: https://i.stack.imgur.com/M8smd.jpg


message:
Load Adafruit GFX bitmap fonts on desktop for pixel-level design

I am designing UI for 160x128 ST7735-based TFT display which will be displayed using Adafruit's GFX library (and the driver in `Adafruit_ST7735.h`). I am using the default bitmap font (custom fonts don't provide the white-out functionality, causing flicker) and would like to load it in some desktop pixel editor (like Gimp or some pixel-art editor) so that I can work the design out on desktop.

There are many posts about converting regular (TFT, OTF) fonts to the c-style array, I need to do the opposite. If possible, including the scaled variants, so that I have 1:1 corespondence :)

Any tips on this?

body:
As explained [here](https://learn.adafruit.com/creating-custom-symbol-font-for-adafruit-gfx-library/understanding-the-font-specification) and [here](https://glenviewsoftware.com/projects/products/adafonteditor/adafruit-gfx-font-format/) the font format in the GFX-library is GFXglyph, you can use the [free tool from the second link adafonteditor v1.0.3](https://glenviewsoftware.files.wordpress.com/2018/10/adafonteditor_v1_0_3.zip) on the desktop.
**EDIT**
Ok so its actually decompile the gfx header file to something on the desktop. Take a look at the [Adafruit GFX Font Customiser](https://tchapi.github.io/Adafruit-GFX-Font-Customiser/) Source can be used as basis for own projects or compiled to the designated OS.


message:
How to use this Toggle Switch?

I purchased this [toggle][1] switch recently because I want to use it in my project:

[![enter image description here][2]][2]

But I don't know what to connect up the three pins to and I can't find any information about it online. Nor can I find sample code. Can someone show me how to wire it up and provide sample code please?

  [1]: https://www.adafruit.com/product/1684
  [2]: https://i.stack.imgur.com/yd2DW.jpg

body:
It's basically a push button. Possible examples depend on what you want to do. As it seems, you simply want to start interfacing it with Arduino, just use it as a normal push button. Use the `DigitalInputPullup` example, that comes with the Arduino IDE:

    Middle pin to pin 2 on the Arduino
    One of the other pins to ground (depending on which state you want to be reflected with a HIGH in the Arduino)
    The other pin unconnected

Look at these two schematics. The left one is a normal push button. It connects, when pressed and disconnects, when released. The right one is your button. When pressed it disconnects the upper  pin and connects to the lower pin. When released vice versa.  When you don't use the upper pin, your button behaves just like the push button on the left.

<!-- Begin schematic: In order to preserve an editable schematic, please
     don't edit this section directly.
     Click the "edit" link below the image in the preview instead. -->

![schematic](https://i.stack.imgur.com/6Ydxx.png)

<!-- End schematic -->


message:
Does Adafruit PowerBoost 1000 Charger support data transfer?

As the title says - Does [Adafruit PowerBoost 1000 Charger][1] support data transfer?
I mean that if I connect USB on one side to PC and Arduino on other side - can I still program it and get serial monitor communication?
Are the data lines connected??

  [1]: https://www.adafruit.com/product/2465#technical-details

body:
No it doesn't.

As you can see from [the schematic](https://learn.adafruit.com/adafruit-powerboost-1000c-load-share-usb-charge-boost/downloads) the incoming data lines aren't connected, and the outgoing are wired through appropriate resistors to set the current availability.


message:
Connect multiple pins to same VCC using breadboard

Ok so I am pretty green as far as AVR programming is concerned so bear with me.

I am doing a project with an ATmega32 MCU on a dev board which has 4 VCC pins.
The project includes a GPS, SD card and a TFT display. Currently, the GPS and SD card take up 2 out of the 4 VCC pins for powering themselves up. I have two free left.

The display controller I have is the SSD1289:

[![SSD1289][1]][1]

I've connected it to my MCU, the VCC pin on the display took up one more VCC pin so I have one VCC left.
I've been reading up and I've found that the LED_A and RD pins need to be connected to 3.3V, that is VCC.
The LED_A pin should also have a resistor on the line connecting it to VCC.

First question - can someone confirm this is the way to connect it?

Second question - Is it possible to, for example, connect the VCC and RD pins of the display to the same VCC using a breadboard? So then I have one VCC left to connect to LED_A pin through a resistor? I don't know if multiple pins can share the same VCC. Will the voltage drop if I connect two pins to it?
Is this safe to do?

  [1]: https://i.stack.imgur.com/uy2br.jpg

body:
You have basic misconceptions there:

1. Vcc is the power input (!) for the Atmega, not an output to provide current to other parts. Your power supply (whatever you use as one) should be connected to every Vcc pin at the same time. Sure, the Vcc pins are internally connected, but the Atmega has multiple of them, so that the needed current does not have to flow through a single pin. Also you don't want to draw the current for peripherals through the Atmega chip itself (which would happen, when you connect the power source to one of them and the peripherals to another). So every device in your circuit, including the Atmega, has it's own Vcc pin, which needs to be connected directly to the power supply. That is ok and correct, as long as the power supply can provide enough current for all components. If it doesn't, you need to buy a power supply, that can.

2. When connecting device to one pin, the number of devices is not imporant. The current draw is what is important. For example let's take simple digital output pin of the Atmega. It can provide up to 20mA (recommended value; max. 40mA for a short time). We must no exceed that value. So we can connect 1 device, that draws 20mA, or 2 devices, that draw 10mA each. Or 100 devices, which draw 0.2mA each. The number is not important, only the total power draw. The current will drop, when you draw more current, that the source can provide. In that case often the source will be damaged or at least go into thermal emergency shutdown (as for the voltage regulator of a genuine Arduino).

So the Todo for you: Connect every Vcc pin, that you have, directly with the power source.


message:
How can I understand which arduino I need to run some code?

I want to build this project (but any other project would give me the same uncertainty):
https://github.com/ltpitt/arduino-n64-controller-library

But I cannot understand which arduino I can buy that will be compatible and also very small / easy to program / cheap.

There are countless possibilities but I cannot understand how can I match available code and compatible hardware.

body:
In this case, the description on Github says specifically that it is compatible with the Uno:

> Based on the work in
> http://www.instructables.com/id/Use-an-Arduino-with-an-N64-controller/
> here comes a comfortable library for usage with e.g. Arduino Uno.

If you know in advance that you intend to write a very large body of code, of which this library is only a part, you can anticipate needing an Arduino with more memory at some point, but an Uno will get you a long way there. And, with all due respect, the fact that you're asking this question also suggests that an Uno will be more than adequate.

Genuine Italian Unos just barely exceed U$D 20 and Uno clones are about 2/3 of that price. Some of the clones may not be quite up to quality of the genuine boards, but reputable board makers' products are usually quite good. The best advice I can offer would be to buy a genuine Uno for your first board, both for the most likely best experience starting out, as well as to support the folks who did the upfront work and released the design as open source. Then maybe branch out to other board-makers' products for price, or especially, for added features (assuming those are useful to you) that some of them have engineered into their versions of the product.

Update:

> My final goal is to put it into a Nintendo 64 so its size is really
> important. Something like this could be ok?
> kiwi-electronics.nl/beetle-arduino-leonardo

The Beetle's processor, AtMega32U4, has a similar memory complement as the Uno's AtMega328. In fact it has a little bit more RAM than the Uno. It should be quite doable to compile it for the Beetle.


message:
My Arduino smokes every time I connect an AC/DC wall adapter to it. Can someone help me to fix it?

I copied the schematic below and when I ran the code from my laptop, it worked well but every time I unplug it to my laptop and connect an ac dc wall adapter, my Arduino smokes. Why does it smoke and how to fix it so that I can connect an AC/DC wall adapter to power my Arduino? <br>**EDIT** from the comments: My AC/DC adapter has 19.5V DC out.

[![schematic][1]][1]

  [1]: https://i.stack.imgur.com/yjmMn.png

body:
As already stated in the comments, the voltage of your power supply is the problem. The Arduino has a linear voltage regulator at the Vin pin. It dissipates the excess voltage as heat. The higher the supplied voltage, the lower the current, that you can draw before it overheats. The regulator on a genuine Arduino should go into thermal shutdown, while the regulators on most cheap clones will just get destroyed.

19.5V is too high for the Arduino. The Vin pin is meant for  6 to 12V max. You need a power supply, that can provide a voltage in that range. Or you can buy a regulated power supply, that directly gives you the 5V, that the Arduino needs.

Also you should be really carefull with powering the motor through the Arduinos 5V pin. Motors can easily draw a big amount of current. When drawing too much current through the Arduino (to be specific: through the voltage regulator or the protection diode), the same as explained above will happen. Only very small motors can be supplied through the Arduino. As you use a relay to control it, I guess the motor draws a lot of current. You need tp connect it directly to a fitting power supply, so that the current for it does not flow through the Arduino.

And always be sure, that the used parts can work with the voltage, that you want to supply, including the motor.


message:
Can two electronic speed controllers be connected to the same ground pin?

I have a setup to read two sets of signals from a radio control receiver using an Arduino NANO: the throttle channel and the rudder channel. With some programming knowledge (which I have) this isn't too difficult, but I need help on the electrical side of things. This is the current setup I have (it works, [though I'm told there is the possibility that my computer is acting as a ground for the PWM signal wires from the receiver][1]):

[![Arduino, remote control receiver, and ESC circuit][2]][2]

OK, great. I'm able to control the motor programmatically, mix values from the receiver, etc. See [this video for what I'm doing][3]. However, this setup leaves some gaps:

**Question 1**
I actually need two motors for dual thrust. Each motor is to be controlled individually by the program (for asymmetric thrust). Since there are only two grounds on the Arduino, [can I plug both ESC grounds to the same pin?][4] Currently, the receiver is getting power from the Arduino, and grounds back. The speed controller grounds to the second ground pin. Diagram below:

[![two ESCs on same ground pin][5]][5]

**Question 2**
All that is great, but the NANO is still powered by USB: obviously I'm not putting my laptop in the RC boat just to supply a few volts! Incidentally, both electronic speed controllers (ESCs) have battery eliminator circuits (BECs), usually used to power the receiver. Would I be able to connect one of them to the VIN pin of the Arduino?

I tried something like that, but the Arduino got very hot near the pin, and it smelled. Unfortunately, I don't have my circuit at the time. The [Arduino's Amazon page][6] states support for 5V to 12V external power supply. Each ESC can supply 5V at 3A. Maybe there's a way to plug them to make 10V?

**Question 3**
My idea also calls for three sets of LEDs, which will be lit also based on inputs from the receiver. Can these be grounded to the same wire, like I was suggesting above for the ESCs?

  [1]: https://arduino.stackexchange.com/questions/75549/pwm-input-pins-never-receive-a-value-from-working-receiver
  [2]: https://i.stack.imgur.com/6aa1I.jpg
  [3]: https://www.youtube.com/watch?v=ncBDvcbY1l4&list=WL&index=50&t=0s
  [4]: https://arduino.stackexchange.com/questions/9918/use-same-ground-with-2-wires
  [5]: https://i.stack.imgur.com/683Wm.jpg
  [6]: https://www.amazon.com/gp/product/B07G99NNXL/ref=ppx_yo_dt_b_asin_title_o05_s01?ie=UTF8&psc=1

body: You can connect all the grounds together and the circuit will be safe. If the BEC outputs 5V, you can feed it directly to the Arduino's 5V pin. Any more volts and you'll need to feed the BEC output to the Arduino's VIN pin.


message:
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](https://www.alibaba.com/product-detail/1-51-inch-Transparent-OLED-Screen_62356046434.html?spm=a2756.order-detail-ta-ta-b.0.0.49882fc2kEiqxv) to [arduino nano](https://store.arduino.cc/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!

body:
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.


message:
NeoPixel Gradient sweep function

[![enter image description here][1]][1]

  [1]: https://i.stack.imgur.com/4qmg3.jpg

I'm trying to create a function that takes two colours and creates a smooth gradient between them one colour at the beginning and one at the end

I just can't figure the math of mixing them evenly

I'm using neopixel library

body:
I can think of two ways of doing this.

One is to use the H channel of the HSV colour space (as I show in the answer to [this question](https://arduino.stackexchange.com/questions/75446/rgb-led-color-control-with-a-single-value/). This would give you a smooth transition between two colours through the pre-defined spectrum of the hue range.

The second is to simply specify two colours and then mix them at different percentages depending on how far along the length you are.

For example, here's a (untested) small function that "mixes" two individual colour channels together and returns the result:

```
uint8_t mix(uint8_t a, uint8_t b, int pct, int range) {
    if (pct <= 0) return a;
    if (pct >= range) return b;
    return (((uint32_t)a * (range-pct)) / range) + (((uint32_t)b * pct) / range);
}
```

`pct` is the led number in your chain, and `range` is the total number of LEDs.

So you could (hypothetically):

```
uint8_t red1 = 0, green1 = 255, blue1 = 0;
uint8_t red2 = 255, green2 = 100, blue2 = 100;

for (int i = 0; i < 50; i++) {
    uint8_t red = mix(red1, red2, i, 50);
    uint8_t green = mix(green1, green2, i, 50);
    uint8_t blue = mix(blue1, blue2, i, 50);
    setLedColor(i, red, green, blue);
}
```


message:
Inductive spikes upset Interrupts

[![enter image description here][1]][1]I am using an Arduino Uno to create a kinetic sculpture with magnets and electromagnets (EMs). I have a setup with two externally debounced buttons using resistors,capacitor and CMOS 4584 hex inverter. All non-used inputs of the 4584 are grounded. These buttons deliver a clean signal to the board and trigger the two interrupts which set flags to turn LEDs on or off and trigger one or both optoisolators (OIs).
These connect to another board with a separate 12V supply. One of the OIs turns a BUZ71 power mosfet on and the other triggers a relay which can reverse the polarity of the power to a small 30 ohm EM coil. This can make the magnet suspended above like a pendulum fly away from the coil...

This works perfectly well with the buttons,  the LEDs and the two inputs to the OIs  But when I connect the relay/mosfet board  to the output of the OIs it stops working properly. button 2 turns off button 1  as well as itself. Button one always turns off and on cleanly But button two triggers ISR2 about 10 times and ISR1 a couple of times, leaving both off. If I disconnect the EM coil the buttons work properly. It seems that switching the polarity is somehow interfering with the Uno maybe due to a fairly hefty inductive spike generated by switching the relay. I have tried using shielded coax to the coil. I have 47000 uF caps on both boards. I tried a crude faraday cage around the relay board - no luck. Could the spike be coming through the household power supply somehow even though the Uno board and the relay board have different power supplies and are fully seperated by the OIs?
Here is the sketch I am using:
```
    //  Coding by Jeremy 070520
//  development for ricochet module

const int coilButton = 2;
const int directionButton = 3;
const int coilPin = 8; //coil driver
const int directionPin = 9; //direction driver
volatile bool coilFlag;
volatile bool directionFlag;
int coilLedState = LOW;
int directionLedState = LOW;

void setup()
{
  pinMode(coilButton,INPUT);
  pinMode(directionButton, INPUT);
  pinMode(coilPin, OUTPUT);
  pinMode(directionPin, OUTPUT);
  digitalWrite(coilPin,LOW);
  digitalWrite(directionPin, LOW);
  attachInterrupt(digitalPinToInterrupt(coilButton), ISR1, FALLING);
  attachInterrupt(digitalPinToInterrupt(directionButton), ISR2, FALLING);
  Serial.begin(9600);
  }

void loop(){
  if(coilFlag)
  {
    coilFlag = false;
    coilLedState = !coilLedState;
    digitalWrite(coilPin, coilLedState);
  }
 if(directionFlag)
  {
    directionFlag = false;
    directionLedState = !directionLedState;
    digitalWrite(directionPin, directionLedState);
  }
delay(1);   //I'm desperate I will try anything ....
} //end loop

void ISR1()
{
  Serial.println("ISR1");
  coilFlag = true;
  }

void ISR2()
{
  Serial.println("ISR2");
  directionFlag = true;
  }
```

  [1]: https://i.stack.imgur.com/EZJgZ.jpg

body:
I'd suggest building a Faraday cage around the inductive coil. It's probably inducing enough current in all the wires around it to trigger logic level voltages in your signal wires, in the board, etc.

It sounds like the goal is for the coil to fling a magnet away, so you might have to settle for a "Faraday bowl" (an open-topped Faraday cage). Some magnetic field would leak out the top of the bowl, but if you place the control board below the bottom and several feet away it might be enough.

You might need to shield everything separately: Faraday cage around the Arduino. "Faraday Bowl" around the coil. Coax cables for everything, where the power to the coil is in a coax cable that's grounded separately, etc.


message:
Atmega Millis with Quartz crystal

I followed https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard this tutorial to program my Atmega 328p to run on a breadboard with a 16 MHZ Quarz crystal and two 22pF capacitor.
I want to program a digital clock without a RTC (code below). So I wrote my code by using millis(), and set the time exactly to the time of my mobile. After two minutes the Atmega was about a quarter minute early, but it seems to stay there. Why is that? Doesen't it use the crystal? Do I have to program it differently? Or will it stay at this time difference and run more or less accurate now?

My code:

    #define ZERO 0b01110111
    #define ONE 0b00000110
    #define TWO 0b10110011
    #define THREE 0b10010111
    #define FOUR 0b11000110
    #define FIVE 0b11010101
    #define SIX  0b11110101
    #define SEVEN 0b00000111
    #define EIGHT 0b11110111
    #define NINE 0b11010111
    #define SECOND 1000
    static int changed = 0;

    static int led01 = 1;
    static int led02 = 3;

    static int led11 = 4;
    static int led12 = 5;

    static int state = 0;
    static int selP = 0;

    static int blink = 0;
    static int btn_1 = 0, btn_2 = 0;

    static long last = millis();
    static long tm = 0;

    static int seconds = 0, minutes = 45, hours = 13;

    static const int DATAH1 = 2, ST_CPH1 = 3, SH_CPH1 =4;
    static const int DATAH2 = 5, ST_CPH2 = 6, SH_CPH2 =7;

    static const int DATAM1 = 11, ST_CPM1 = 12, SH_CPM1 =13;
    static const int DATAM2 = A0, ST_CPM2 = A1, SH_CPM2 =A2;

    static const char numbers[10] = {ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE};
    void setup()
    {
      pinMode(DATAH1, OUTPUT);
      pinMode(ST_CPH1, OUTPUT);
      pinMode(SH_CPH1, OUTPUT);

      pinMode(DATAH2, OUTPUT);
      pinMode(ST_CPH2, OUTPUT);
      pinMode(SH_CPH2, OUTPUT);

      pinMode(DATAM1, OUTPUT);
      pinMode(ST_CPM1, OUTPUT);
      pinMode(SH_CPM1, OUTPUT);

      pinMode(DATAM2, OUTPUT);
      pinMode(ST_CPM2, OUTPUT);
      pinMode(SH_CPM2, OUTPUT);

      pinMode(9, INPUT_PULLUP);
      pinMode(10, INPUT_PULLUP);
    }

    // main loop
    void loop()
    {
      long curr = millis();
      tm += curr-last;
      if(tm < 0 || tm > 900000){
        tm = 0;
      }
      last = curr;
      if(digitalRead(9) == LOW){
        if(!btn_1){
          if(state == 0){
            state = 1;
            selP = 0;
          }else{
            if(selP >= 3) state = 0;
            else selP++;
          }
          tm = 0;
          blink = 0;
        }
        btn_1 = 1;
      }else btn_1 = 0;

      if(state == 0){ //ZEIT LAEUFT
        if(tm >= SECOND){
          seconds+=tm/SECOND;
          tm = tm%SECOND;
          changed = 1;
        }
        if(seconds >= 60){
          minutes += seconds/60;
          seconds = seconds`;
        }
        if(minutes >= 60){
          hours += minutes/60;
          minutes = minutes`;
        }
        if(hours >= 24){
          hours = 0;
        }
      }else{ //UHR STELLEN
        if(tm>=500){
            blink = blink?0:1;
            tm = 0;
            changed = 1;
          }
        if(digitalRead(10) == LOW){
          if(!btn_2){
            changed = 1;
            switch(selP){
              case 0:
                hours+=10;
                if(hours >= 24) hours -= 20;
                break;
              case 1:
                if(hours/10 < 2){ //in else case zaehlt man die 2. Ziffer nur noch bis 3, da 24 kein Bestandteil mehr ist
                  if(hours == 9){
                    hours-= 9;
                  }else hours++;
                }else{
                  if(hours == 3){
                    hours-= 3;
                  }else hours++;
                }
              break;
              case 2:
                minutes+=10;
                if(minutes >=60) minutes = 0;
              break;
              case 3:
                 if(minutes == 9){
                  minutes-= 9;
                }else minutes++;
            }
          }
          btn_2 = 1;
        }else btn_2 = 0;
      }
      if(changed){
        led01 = hours/10;
        led02 = hours;
        led11 = minutes/10;
        led12 = minutes;
        byte str[4];
        str[0] = numbers[led01];
        str[1] = numbers[led02];
        str[2] = numbers[led11];
        str[3] = numbers[led12];
        if(blink){
          str[selP]=str[selP]|(1<<3);
        }
        digitalWrite(ST_CPH1, LOW);
        shiftOut(DATAH1, SH_CPH1,MSBFIRST, str[0]);
        digitalWrite(ST_CPH1, HIGH);

        digitalWrite(ST_CPH2, LOW);
        shiftOut(DATAH2, SH_CPH2,MSBFIRST, str[1]);
        digitalWrite(ST_CPH2, HIGH);

        digitalWrite(ST_CPM1, LOW);
        shiftOut(DATAM1, SH_CPM1,MSBFIRST, str[2]);
        digitalWrite(ST_CPM1, HIGH);

        digitalWrite(ST_CPM2, LOW);
        shiftOut(DATAM2, SH_CPM2,MSBFIRST, str[3]);
        digitalWrite(ST_CPM2, HIGH);
      }
    }

body:
I don’t see anything in this code that allows you to set the time.  You set it by hard coding the numbers.  That’s fine but it takes some time to compile and load to the board and the board is going to start at that time you hard coded.  If the board doesn’t get to start running the program for a few seconds while you upload then it’s obviously going to be a few seconds off.

It’s going to be nearly impossible to guess exactly what time the program starts running.  Maybe you could set the time for several minutes into the future, upload, and then unplug and wait until exactly that time to plug the board in and start it.  Remember there’s a couple seconds for the boot loader before the program starts to run.  It may take some trial and error.

Or you can write code there that allows you to set the time through the serial monitor or something.


message:
What is the meaning of the term FQBN?

So I'm reading the [Platform specification][1] and doing some programming and I'm getting the error:
```
Error missing FQBN
```

So what does FQBN mean?

  [1]: https://arduino.github.io/arduino-cli/platform-specification/#custom-board-options

body:
My guess: Fully Qualified Board Name

I.e., a descriptor that uniquely identifies a board and its configuration.


message:
How send method POST with JSON? Arduino UNO R3 + SIM900

Why is the server side of php not loading any data from arduino? What did I do wrong?

```
  String reading="{\"latitude\": 12.983027,  \"longitude\": 80.2594}";
  mySerial.println("AT+HTTPINIT");
  toSerial(1000);

  mySerial.println("AT+HTTPPARA=\"CID\",1");
  toSerial(1000);

  mySerial.println("AT+HTTPPARA=\"URL\",\"http://gerro.usermd.net/updateData.php\"");
  toSerial(1000);

  mySerial.println("AT+HTTPPARA=\"CONTENT\", \"application/json\"");
  toSerial(1000);

  mySerial.println("AT+HTTPDATA=" + String(reading.length()) + ",100000");
  toSerial(5000);

  mySerial.println(reading);
  toSerial(1000);

  mySerial.println("AT+HTTPACTION=1");
  toSerial(15000);

  mySerial.println("AT+HTTPREAD");
  toSerial(1000);

  mySerial.println("AT+HTTPTERM");
  toSerial(500);
```
**Result:**
```
AT+HTTPINIT

OK
AT+HTTPPARA="CID",1

OK
AT+HTTPPARA="URL","http://gerro.usermd.net/updateData.php"

OAT+HTTPPARA="CONTENT", "application/json"

OK
AT+HTTPDATA=46,100000

DOWNLOAD

OK
AT+HTTPACTION=1

OK

+HTTPACTION:1,200,55
AT+HTTPREAD

+HTTPREAD:55
array(0) {
}
array(0) {
}
nic ciekAT+HTTPTERM

OK
```

**EDITING**
```
void toSerial(int delay_ms)
  {
    delay(delay_ms);

    while(mySerial.available())
    {
       Serial.write(mySerial.read());
    }
  }
```

**PHP**
```
<?php
var_dump($_POST);
if (isset($_POST['latitude']) && isset($_POST['longitude']) && $_SERVER['REQUEST_METHOD'] === 'POST') {
//code
} else {
echo 'nic';
}

body:
You had to change the php file:
```
var_dump($_POST);
```

to:

```
echo print_r(json_decode(file_get_contents("php://input")));
```

Thank you !


message:
Print connection password typed by user on NodeMCU Lua ESP8266 ESP-12E

I want to make a WiFi Access point created with the ESP8266. Let's say that the SSID is '**net_work**' and the password is '**12345678**'.

When a client tries to connect with a **wrong** password, I want to print that wrong password in the serial console. But nowhere in the docu I can find an event listener or something to do this... The only thing i can find in the docu is how to start the AP and wait for a successfull connection.

body:
You can't.

The password does not exist.

In short:

* The password is used to create a key
* The key is used to encrypt the connection
* If both ends agree on the encryption then it's "connected" and packets can travel back and forth.

There is no password for you to print, only the fact that encryption didn't agree.

It actuality it's more complex than that, but that's the rough outline of how it works.


message:
very small PWM when timer says zero

I'am getting a little PWM signal when my potentiometer is at zero and OCR2B always reads zero on the serial monitor.  My LED has low forward voltage but I still get a little PWM on the pin when I prob it. I use timer 1 and it works good. I have a picture of the scope.
<!-- language-all: lang-cpp -->

    #include "RTClib.h"
    RTC_DS3231 rtc;

    #include <ResponsiveAnalogRead.h>
    ResponsiveAnalogRead analog0(A0, true, .001);

    unsigned int nowHour;

    int analogOutPin3 = 3;
    int sensorValueTimer2Pin3;

    long z;

    int analogOutPin9 = 9;
    int analogOutPin10 = 10;

    void setup() {
      Serial.begin(9600);
      //===============mode 5 pin 3,11==================//
      TCCR2A |= (1 << COM2A1);
      TCCR2A |= (1 << COM2B1);
      TCCR2A |= (1 << WGM21);
      TCCR2A |= (1 << WGM20);
      TCCR2B |= (1 << WGM22);
      TCCR2B |= (1 << CS22);
      OCR2A = 249;   //1KHz frequency
      TCNT2 = 0;
      //====================mode 5 pin 3,11==============//

      pinMode(3, OUTPUT);

      rtc.adjust(DateTime(2014, 1, 21, 7, 0, 0));
    }

    void loop() {
      DateTime now = rtc.now();
      nowHour = now.hour();
      analogWrite(9, LOW);
      analogWrite(10, LOW);
      analog0.update();
      sensorValueTimer2Pin3 = ((analog0.getValue() * 249L) / 1024);
      if (nowHour >= 7 && nowHour <= 21) {
        z = sensorValueTimer2Pin3;
        OCR2B = z;
        Serial.println(OCR2B);
      }
    }

[![enter image description here][1]][1]

  [1]: https://i.stack.imgur.com/j3Oap.jpg

body:
When `analogWrite` writes 0 or 255 value, it actually disables PWM output and sets the output to 0 or 1 correspondingly (maybe just one of them).
That's because there is just 256 values, but with both fully off and fully on PWM you'll need 257 values to archieve it.
If you're using direct access into `OCRx`, you have to make a choice if you want to have not fully on pwm or not fully off pwm (by setting polarity with `COM2Xx`)

Btw, you should clear `TCCR2A`/`TCCR2B` as all of the timers are configured by Arduino core to be running and prepared for the analogWrites...


message:
DHT11 is returning nonsensical values

I am trying to get humidity and temperature readings (eventually to trigger a misting system), but the values keep returning as 0C and 0%humidity (in general).  Originally, I was using an am2320 sensor and using the analog pins.  Here, I used the following code:

    #include "dht.h"
    #define dht_apin A2 // Analog Pin sensor is connected to
    #define MIST 7
    #define LIGHT 2

    dht DHT;

    void setup(){
     pinMode(MIST, OUTPUT);
     pinMode(LIGHT, OUTPUT);
      Serial.begin(9600);
      delay(500);//Delay to let system boot
      Serial.println("DHT11 Humidity & temperature Sensor\n\n");
      delay(1000);//Wait before accessing Sensor

    }//end "setup()"

    void loop(){
      //Start of Program

        DHT.read11(dht_apin);

        Serial.print("Current humidity = ");
        Serial.print(DHT.humidity);
        Serial.print("%  ");
        Serial.print("temperature = ");
        Serial.print(DHT.temperature);
        Serial.println("C  ");

        delay(5000);     //Wait 5 seconds before accessing sensor again.

      }

      //Fastest should be once every two seconds.

    // end loop()
    }

  Thinking the sensor may have not been working, I tried using a different sensor (DHT11), and following the tutorials got the same result using this code:

    #include <dht11.h>
    #define DHT11PIN 4

    dht11 DHT11;

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

    }

    void loop()
    {
      Serial.println();

      int chk = DHT11.read(DHT11PIN);

      Serial.print("Humidity (%): ");
      Serial.println((float)DHT11.humidity, 2);

      Serial.print("Temperature (C): ");
      Serial.println((float)DHT11.temperature, 2);

      delay(2000);

    }
    // end loop()

The Arduino is being powered by a wall wart and is also connected to my computer via USB (I read that sometimes the USB doesn't supply enough power).  The weird part is that for about 1 minute I got reasonable results (humidity ~50%, temp 22C).  Then, I tried adding an if loop to turn on an LED if the humidity dropped below 60% (thinking I could use the same code to operate a relay to turn on a misting system).  The LED lit up, but the readout went back to the 0%humidity and 0C.  I have since deleted this loop but cannot seem to get reasonable measurements.  If I change the signal pin, I sometimes get a new readout 255% humidity and 255C, but I haven't been able to repeat this reliably.

For the wiring:  S to pin, + to 5V, - to GND

Note:  I have tried every analog pin and "regular" pin, so the code may designate something that is different in my picture.  When testing, I have triple checked that the signal pin in the code is correct for my wiring configuration.  I've also tried with a different Arduino with the same result.  I'm pretty new at this, but the code is pretty much copy-paste and there are only 3 wires.  I've read that there are many DHT libraries, so I'm thinking my issue has something to do with that, but I have no clue how to judge the appropriateness of a library for my application.

[![Order of pins = S, +, -][1]][1]
[![My wiring][2]][2][[[[[[[[[[[[p

  [1]: https://i.stack.imgur.com/cBP4P.jpg
  [2]: https://i.stack.imgur.com/JQcFr.jpg

body:
Connect the sensor as in this diagramm (including a 10k resistor!):
[![DHT sensor to UNO][1]][1]
<br>Watch the empty connector opposite to your breadboard plug-in
and use the following test sketch with [this library](https://github.com/adafruit/DHT-sensor-library):

    // Example testing sketch for DHT humidity/temperature sensor

    #include "DHT.h"

    #define DHTPIN 4     // Digital pin connected to the DHT sensor

    #define DHTTYPE DHT11   // DHT 11

    // Connect pin 1 (on the left) of the sensor to +5V
    // NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1 to 3.3V instead of 5V!
    // Connect pin 2 of the sensor to whatever your DHTPIN is
    // Connect pin 4 (on the right) of the sensor to GROUND
    // Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

    // Initialize DHT sensor.
    // Note that older versions of this library took an optional third parameter to
    // tweak the timings for faster processors.  This parameter is no longer needed
    // as the current DHT reading algorithm adjusts itself to work on faster procs.
    DHT dht(DHTPIN, DHTTYPE);

    void setup() {
      Serial.begin(9600);
      Serial.println(F("DHTxx test!"));

      dht.begin();
    }

    void loop() {
      // Wait a few seconds between measurements.
      delay(2000);

      // Reading temperature or humidity takes about 250 milliseconds!
      // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
      float h = dht.readHumidity();
      // Read temperature as Celsius (the default)
      float t = dht.readTemperature();
      // Read temperature as Fahrenheit (isFahrenheit = true)
      float f = dht.readTemperature(true);

      // Check if any reads failed and exit early (to try again).
      if (isnan(h) || isnan(t) || isnan(f)) {
        Serial.println(F("Failed to read from DHT sensor!"));
        return;
      }

      // Compute heat index in Fahrenheit (the default)
      float hif = dht.computeHeatIndex(f, h);
      // Compute heat index in Celsius (isFahreheit = false)
      float hic = dht.computeHeatIndex(t, h, false);

      Serial.print(F("Humidity: "));
      Serial.print(h);
      Serial.print(F("%  Temperature: "));
      Serial.print(t);
      Serial.print(F("°C "));
      Serial.print(f);
      Serial.print(F("°F  Heat index: "));
      Serial.print(hic);
      Serial.print(F("°C "));
      Serial.print(hif);
      Serial.println(F("°F"));
    }

  [1]: https://i.stack.imgur.com/tanVZ.gif


body:
You need to add the following line of code in the setup() function:
```
    dht.begin();
````