text:
Connecting 5V arduino logic with 12V car logic

I need to connect arduino to K-Line in my car's OBDII port.
I used an L7805 to power the atmega but how can I interface 12V car logic with 5V arduino logic?
The problem is, the connection has to be bidirectional- sometimes the arduino will pull the line high/low and sometimes the car will - the purpose of this connection is to get throttle, rpm etc. data.
This would be easy if the connection was one directional - I could use a transistor to steer 12V to going IN the K-Line and voltage divider if I wanted to do the reverse. But how to do both?

here they use a voltage divider for the RX and a transistor for the TX.

These bi-directional logic level converters work with 5V and 12V, and cost 0.33CAD: https://www.aliexpress.com/item/4-channel-IIC-I2C-Logic-Level-Converter-Bi-Directional-Module-5V-to-3-3V-For-Arduino/32310628741.html

I found this that may be helpful to you.  this circuit allows for bidirectional communication between automotive K-line ECUs and an arduino.
 K-Line Interface circuit


text:
Secure HTTPS request fails 90% of the time
I'm using a NodeMCU, which is connected to an enterprise network at a school. The information given in the GET requests that the ESP8266 sends is sensitive, so naturally we want to make it secure and encrypted - enter SSL. We do the request like so;
HTTPClient http.begin(url, thumbprint)
However, on the network at the school, doing this request fails 90% of the time, so I did a few tests - 100 requests to the exact same IP and certificate, noting how many went through;

School network

HTTPS requests: 10/100 successful [10%]
HTTP requests: 100/100 successful [100%]

Private home network

HTTPS requests: 100/100 successful [100%]
HTTP requests: 100/100 successful [100%]

We have also tried using the WiFiClient class, and while 100% of the requests went through, each one took 15 seconds which is too long.
My question is; what would the problem be, and what can we do to fix it? Can I do something in the code, or on the network?

Do you get any error messages?

@Gerben No stack errors, the response contains nothing and the HTTP code is -11

Your school probably uses a proxy which tries to filter out phishing sites or something. It's possible that it only works fast for white-listed domains.

I asked about this, and they told me there was nothing blocking my site. Again, it works 10% of the time. They said there was no firewall...

Have you tried increasing the timeout (HTTPClient.setTimeout) until you get 100% success?

@Craig didn't think of this! The requests actually go through 100% of the time now (at a 100000 timeout, just for now), so that's great! Although each request takes about 4.5 seconds compared to the 300ms that the unsecure requests take. But I'll take it! Post it as an answer, and I'll accept it.

As to why there is a difference between the 2 networks I'm not sure. I would turn up the log level on your server and see if that points you toward the problem.

you should consider an ESP32 if you need to make fast HTTPS requests from an MCU

Increase the timeout for your request with HTTPClient.setTimeout(). Note the timeout is in milliseconds.
HTTPClient http;
http.setTimeout(15000); // 15 Seconds
http.begin(url, thumbprint);

source: Stack Exchange

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

sort: votes


text:
How to give an analog output of 0-5V
I'm trying to program an Arduino to control a motor at different intensities by giving a 0-5V reference value from the board. I have some programming experience, but have very little knowledge of manipulating an Arduino or about electricity. As I understand from reading this, I need to call the AnalogWrite function to output the signal, but how do I do this? How can I control when the voltage (and by extension, the motor intensity) is increased or decreased. Is it possible to do this without additional hardware?
Any help is much appreciated, it doesn't have to be code. I mostly want to understand how to use the Arduino, but code would also help a lot with that. I'm using an Arduino Due, which as I understand, has true analog out.

What is the motor you are trying to control?

I'll do my best to describe it, but essentially it is a robot that has a series of pressure regulators that supply air to pneumatic tubes in a mesh that act like muscles when pressurized. The regulators control which group gets pressure. The arduino will not be powering the motor, simply controlling the level of pressure the "muscles" are getting from intensities 0-5 based on what the board is outputting. I realize that's a bit different from what I wrote in the OP, but I explained it that way for simplicity.

The actual hardware used matters in this case. If the pressure regulator is only getting a "signal" and not drawing it's operating current from the Arduino, then you may not need to fool with MOSFETs. But it depends a great deal on the actual item the Arduino is connected to. Would you be able to provide a link to a datasheet for the pressure regulator or whatever device the Arduino would be connected to? It might also be that the device really requires a true Analog signal and not a PWM average voltage.

https://create.arduino.cc/projecthub/ArduPic/how-to-modify-analog-output-range-of-arduino-due-6edfb5

Why do you want true DAC? PWM can be amplified with MOSFET. For analog you need a voltage convertor.

You would indeed need to use analogWrite to send a PWM signal to the motor. PWM will turn on and off the power to the pin really fast. In effect powering the motor with pulses. The length of these pulses will determine how much power the motor receives.
The DUE also has a true analog output, but you don't want to use that for motors. The use of the word analogWrite is a bit misleading when it's used for generating a PWM signal.
analogWrite will ask for a value between 0 and 255 to indicate the pulse length. 0 is OFF, 255 is full ON, 127 is ON for 50% of the time.
Also note that most motors require more current that the Arduino pins can provide, so you need to use a transistor/mosfet to "amplify" the signal to a higher current.

So is there a way I can control the voltage output rather than pulse length?

@Gerben correct,  I missed the Due tag.

not only to amplify the current, but to go to 5 V

@Nyra why would you want to? Like I said; for a motor you’d want to use PWM instead.

You can't do it without additional hardware because Due output is max 3.3 V. You need to amplify PWM or the analog output. PWM can be amplified using a MOSFET. If you are new to electronics I would recommend Grove MOSFET module. I use it to amplify PWM of M0 to 5 V.
It is normal to use PWM for regulation. True analog output is used for sound and similar waves. If you really need true analog value to 5 V with Due, you must use a voltage converter like in the tutorial linked by Majenko in comments.
The Arduino core handles the DAC of the SAMD boards with analogWrite() too.
Quote from the analogWrite reference:

The Arduino DUE supports analogWrite() on pins 2 through 13, plus pins
  DAC0 and DAC1. Unlike the PWM pins, DAC0 and DAC1 are Digital to
  Analog converters, and act as true analog outputs.

And you can set the resolution with analogWriteResolution():

By setting the write resolution to 12, you can use analogWrite() with
  values between 0 and 4095 to exploit the full DAC resolution.

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


text:
Monitoring the state of AC relay, design considerations
I want to use a sensor and relay as a safety device to allow/deny power to an AC mains-powered electrical unit.
If the wall power is disconnected I loose the state of the relay which is stored in a variable on my Pro Mini.
My Arduino is powered from an AC-DC voltage regulator that is between the AC mains and the Power On switch of the electrical unit.
Apart from powering the Arduino with a battery/supercap, are there any circuit design tricks I'm missing?

Can you clarify your setup? Is the Arduino controlling the relay and also sensing the presence or absence of mains power (i.e., detecting a power loss?)

Yes the Arduino is controlling the relay. No, the sensor is a liquid-level sensor which indicates whether the Arduino should turn off the power on low liquid level.

When you change the state of the relay, save it to the EEPROM. In setup() read the value from EEPROM and apply it.

Ah... why didn't I think of that :-)

but is it necessary? Doesn't the state evaluate from the sensor value after the sketch starts?

If the state of the relay is fully determined by the instantaneous state of the sensor, then there is no need to store the relay state.

Yes, I think you are both right. What was confusing me was that I do need to store the relay state in a variable so that I only switch the relay when the sensor changes, and not on every iteration of the loop.

If you set a pin to HIGH and it's already HIGH, nothing happens. It's okay to "set" the relay on every iteration of the loop.

This is a latching relay and so the switching needs 3 lines of code: 1) set pin high; 2) delay for latching, 50mS; 3) set pin low

and how behaves this latching relay at Arduino restart? my changes state

@Owen Storing a separate var for anything controlled is good practice IMO. I always do so, and I won't trust reading back the value of a pin. Among other things, a separate var allows you to more easily track the time since a change was made. Besides statistics, that helps you prevent any condition  causing changes too frequently. It also offers a clue in case of circuit malfunction, if the var != the detected state. Detecting such dependencies also allows future circuit additions for a manual override.

I have run into a similar situation on a few occasions. Maybe my scheme will help. What I do is sense power loss early, so I can save a structure full of all my program states to EEPROM when the power is going away. Conversely, the first thing the program does on power up is restore the memory structure from EEPROM. Provided you save your relay state whenever it changes, this scheme should help you recover. You don't need a super cap. I use a circuit like this...
In this circuit, I use a diode to isolate a large (but not super) capacitor from the supply, and that circuit point also feeds my VIN (This is a NANO board). Then, that capacitor voltage is further isolated from a voltage divider, with another diode. The voltage divider brings down the 12V (only 11V after the diodes) to pretty near 5V. there's also a small (100nF) capacitor there to filter any noise.
If power is lost, that 2200uF capacitor will keep my NANO, a bunch of LEDs, an LCD display, and even a transistor driver and relay circuit(not shown) alive for nearly a second. But the voltage at the digital input (D2 in my case) will drop within milliseconds! So if you are polling that pin regularly, you'll have plenty of time to react by saving your states. If you doubt whether you can poll that fast, pin D2 can easily be tied to an interrupt. (that's overkill.. easier to just create you're owe version of millis(), so that whenever you have a timer wait, you can continually test the power detect pin, and react within a millisecond).
Now if for some reason you would like to ensure that the arduino doesn't lose power at all during short power line disturbances, you can add another diode to the 2200uF capacitor, and connect it to a battery pack. It the battery voltage is a little lower than the main supply, no current will flow out of it until its really needed.

Nice. I like your implementation - thank you for sharing.

You power your device and your controller from same AC source.
You loose that AC source and they both will go off line.
You get your AC source back - restart controller and check the current state of your device /relay.
What did I missed ?

You are correct and missed nothing, only the bit where I said I got confused :-)


text:
Correct wiring?
I'm doing some Home automation and am currently trying to automate my intercom system. My overall aim is to be able to detect when someone has pressed the buzzer and then to be able to open the door if I so wish. Below is the diagram of what I intend to do:

For reference, the buzzer board above is the is the Tegui 1378/1. The documentation can be found (in Spanish) here. I have been able to conclude the following so far about the pins:
1E: Buzzer
2: Common (12V dc)
3: Door lock
4: Microphone
5: Speaker
However, I have been unable to find any GND on this board. As a result, my diagram above makes use of the GND supplied on the NodeMCU instead; is this okay?
Whilst digging around, I found box in my main fuse box called a Tegui E-30. I believe that this takes in mains and drops it down to 12V for the intercom system. It has two pin outs simply labelled "9" & "10". Now, I am fairly sure that one of these is positive and the other negative; in which case, this would explain where the ground has been but I am unsure. It would be handy to know if it is the case that they are positive and negative respectively as it would be more convenient powering the NodeMCU from the 12V (after dropping it to 5V) rather than getting a massive USB cable from the other room.
I would really appreciate any more information people could give me. Both in terms of whether the above diagram would work but also whether someone can have more luck than me finding out exactly what the "9" & "10" pins on the E-30 are.
Thank you in advance for any help!
Kind regards, Rocco

are you sure it is 12 V  DC? door bells traditionally use 12 V AC to buzzzz

from the manual "Características: 12 Vac. y 880 mA." see "ac"

Thanks for your response! I hadn't seen that before; I'd simply done a "Find All" for 12 and had seen a few 12 Vdc but no 12 Vac leading me to assume it was DC but I appear to be incorrect. I've just seen that on the E-30 box, it reads PRIM 230V ~ 50/60Hz 20VA SEC 12V ~ 1A, I assume the ~ refers to AC, am I correct?

yes ~ is for AC. I am sure you can find and buy 12 VAC to USB power (5 VDC) adapter to power the NodeMCU.

I would use a relay to activate the lock and a current sensor or optocoupler to detect current to buzzer. this eliminates the need of common ground

Thanks for the advice! So would something like this be okay to power the NodeMCU from 12Vac (VIN)? I haven't heard of a current sensor before but that sounds like a great solution, would you be able to recommend a cheap one which would work for this use (I live in the UK)? Also, to confirm, are the "9" & "10" pins on the E-30 positive and negative or both positive? Thanks once again for all your help so far!

@Juraj For the current sensor, am I correct in saying that it would need to simply give out a Digital output but that the output would have to be 3.3v as the NodeMCU does not accept 5v logic? Also, the current sensors I have seen online have no reference to voltage (that they are detecting) and just refer to AMPS. Why is this and what would I need for this application? Thanks

current sensor would be analog input. NodeMcu has voltage divider on esp8266 1 V A0 to read to 3.3 V. the optocoupler is simpler. warning, I am not an electronics expert. with AC there is no positive or negative. only 'common' to close the circuit.

the power supply in the link is for DC input

Your diagram doesn’t work. You need a GND connection. Looking at the Dutch manual I think 1E isn’t really the buzzer, but the line selector. Each phone unit has a spectate line for 1E but all phones share lines 2-5. My guess is that 1E becomes GND when the number for you phone is pressed at the door. Which explains why you can’t buzz someone in without them ringing the bell first. So I think the relay needs to be between 1E and 3. But I think you just need to get a multimeter and measure the voltages between screw terminals a different states (beep; phone of hook; buzz door; idle).

found this .... http://www.intercomsrus.com/handset%20pdf/Tegui%20T-71E%20%20Audio%20handset%20Data%20Sheet.pdf


text:
what is wrong with my code for buttons
int "buttons"[6];

int "buttons"[0] = 2;

When i upload the code to the board it says:
exit status 1
expected unqualified-id before string constant

please, take a coding course

"buttons" is not a valid identifier (i.e., not a valid variable name) because it does not start with a letter or underscore.
You should not repeat the type when you want to refer to the already-declared variable.

You declare the variable like:
int buttons[6];  // A 6-element array of integers

And if you want to refer to a specific element in the array:
buttons[0] = 2; // Let the first element of the array be the value 2.


text:
Keep on getting scandone
I have a node server with express and socket io behind nginx reverse proxy at AWS.
I am try to connect remotely from my NodeMCU esp8266 through websocket io client to my server using WebSocketClientSocketIO (unsuccessfully).
I am new and don't know what I am doing wrong.
Following are my debug messages. I keep on getting scandone.
SDK:2.2.1(cfd48f3)/Core:2.4.2/lwIP:2.0.3(STABLE-2_0_3_RELEASE/glue:arduino-2.4.1-13-g163bb82)/BearSSL:6d1cefc
del if0
usl
mode : null
mode : sta(84:f3:eb:b7:4e:8c)
add if0

Connecting.....scandone
state: 0 -> 2 (b0)
.state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 1
cnt

connected with Zlink, channel 13
dhcp client start...
....ip:192.168.10.8,mask:255.255.255.0,gw:192.168.10.1
.
Connected to Zlink
IP address: 192.168.10.8

[SETUP] BOOT WAIT 4...
[SETUP] BOOT WAIT 3...
[SETUP] BOOT WAIT 2...
[SETUP] BOOT WAIT 1...
state: 5 -> 0 (0)
rm 0
scandone
scandone
scandone
scandone
scandone
.
.
.
.

`
My sketch:
/*
 * WebSocketClientSocketIO.ino
 *
 *  Created on: 06.06.2016
 *
 */
#include <Arduino.h>

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
#include <WebSocketsClient.h>
#include <Hash.h>
ESP8266WiFiMulti WiFiMulti;
WebSocketsClient webSocket;
const char *ssid = "MyWiFiName";
const char *password = "mypassword";
#define USE_SERIAL Serial
#define MESSAGE_INTERVAL 30000
#define HEARTBEAT_INTERVAL 25000
uint64_t messageTimestamp = 0;
uint64_t heartbeatTimestamp = 0;
bool isConnected = false;
void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
    switch(type) {
        case WStype_DISCONNECTED:
            USE_SERIAL.printf("[WSc] Disconnected!\n");
            isConnected = false;
            break;
        case WStype_CONNECTED:
            {
                USE_SERIAL.printf("[WSc] Connected to url: %s\n",  payload);
                isConnected = true;
        // send message to server when Connected
                // socket.io upgrade confirmation message (required)
                webSocket.sendTXT("5");
            }
            break;
        case WStype_TEXT:
           USE_SERIAL.printf("[WSc] get text: %s\n", payload);
                        // send message to server
            // webSocket.sendTXT("message here");
            break;
        case WStype_BIN:
            USE_SERIAL.printf("[WSc] get binary length: %u\n", length);
                        hexdump(payload, length);
            // send data to server
            // webSocket.sendBIN(payload, length);
            break;
    }
};
void setup() {
  delay(1000);
    // USE_SERIAL.begin(921600);
    USE_SERIAL.begin(115200);
  WiFi.mode(WIFI_OFF);        //Prevents reconnection issue (taking too long to connect)
  delay(1000);
  WiFi.mode(WIFI_STA);        //This line hides the viewing of ESP as wifi hotspot
 startWiFi();
    USE_SERIAL.setDebugOutput(true);
    USE_SERIAL.println();
    USE_SERIAL.println();
    USE_SERIAL.println();
      for(uint8_t t = 4; t > 0; t--) {
          USE_SERIAL.printf("[SETUP] BOOT WAIT %d...\n", t);
          USE_SERIAL.flush();
          delay(1000);
      }

   // WiFiMulti.addAP("SSID", "passpasspass");

    WiFi.disconnect();
    while(WiFiMulti.run() != WL_CONNECTED) {
        delay(100);
    }

```   // webSocket.beginSocketIO("192.168.0.123", 81);
      webSocket.beginSocketIO("http://www.myDomainName.com", 80, "/addr");
 //addr is address where I want to send messages
    //webSocket.setAuthorization("user", "Password"); // HTTP Basic Authorization
    webSocket.onEvent(webSocketEvent);
}
void loop() {
webSocket.loop();
testSend();
    if(isConnected) {
        uint64_t now = millis();
        if(now - messageTimestamp > MESSAGE_INTERVAL) {
            messageTimestamp = now;
            // example socket.io message with type "messageType" and JSON payload
            webSocket.sendTXT("42[\"messageType\",{\"greeting\":\"hello\"}]");
        }
        if((now - heartbeatTimestamp) > HEARTBEAT_INTERVAL) {
            heartbeatTimestamp = now;
            // socket.io heartbeat message
            webSocket.sendTXT("2");
        }
    };
};
void startWiFi() {
   WiFi.begin(ssid, password);
  USE_SERIAL.println("");
  USE_SERIAL.print("Connecting");
  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    USE_SERIAL.print(".");
  };
  //If connection successful show IP address in serial monitor
  USE_SERIAL.println("");
  USE_SERIAL.print("Connected to ");
  USE_SERIAL.println(ssid);
  USE_SERIAL.print("IP address: ");
  USE_SERIAL.println(WiFi.localIP());  //IP address assigned to your ESP
  };
void testSend(){
   webSocket.sendTXT("Hello from esp");
   delay(1000);
  };
`
My code on node server where I am trying to collect messages from esp8266 is very simple as bellow:

socket.on('addr1', function (req,res) {
   console.log(req);
   });

why call WiFi.disconnect()  towards the end of setup
, after you waited to connect?

Thanks fellows. I will consider both points and post results. I will remove wifi Multi cause I don't understand why we need to use access point while all I need is to use socket io CLIENT in my code?

it is not use of AP. you connect to an AP to join the WiFi network. with WiFiMulti more APs can be set to connect to. it is good if the esp8266 changes location (home, work, mobile hotspot, ... )

Try to use your Local IP as your client WebSocket.
...
...
const char* host = "192.168.x.x";
WifiClient wificlient;
...
...

void setup(){
  ...
  ...
  startWiFi();
  //WiFi.mode(WIFI_OFF);
  //WiFi.disconnect();
  if(!wificlient.connect(host, 80)){
    Serial.println(F("connection failed! "));
    return;
  }
  client.setClient(wificlient);
  ...
  ...
}

also add your host on the express NodeJS. I found a issue like your this
...
...
var http = require('http').Server(app);
var io = require('socket.io')(http);
var host = "192.168.x.x";
var port = "80";
...
...
socket.emit("<your-text>");
server.listen(host, port, function(){
  console.log("listening on http://"+host+":"+host+" ");
});
...
...

Hope this helps.

in the sketch 'simple WiFi begin() is mixed with WiFiMulti system. first the sketch connects to AP and then disconnects and starts WiFiMulti. but:
no AP is configured for WiFiMulti to connect

I removed following lines from my code above: WiFi.disconnect(), and WiFiMulti

and? is it better?

Now to connect to socket io server I have this line ''  ' webSocket.beginSocketIO("http://localhost", 8080 , "/espSocketSrvr2" ); ' But I am getting error //[WS-Client] connect ws...
[WS-Client] connection to http://myserver.com:80 Faild
[WS-Client] client disconnected.
[WSc] Disconnected! '

I also tried running simple socket server using ws library. I changed connection line to webSocket.begin("127.0.0.1", 8080 , "/" ); . Still I get  error [WS-Client] connect ws... [WS-Client] connection to 127.0.0.1:8080 Faild [WS-Client] client disconnected. [WSc] Disconnected! . Though I can connect to server through socket from browser in both cases. I guess I am missing some small thing, but what is that ...............,..

I am running node js server on local computer. I also tried   webSocket.begin("http://localhost", 8080 , "/" ); without success.

localhost of your esp8266 is your esp8266

Great point!!!! Let me try using my IP.

Still same problem.  [WS-Client] connect ws...
[WS-Client] connection to myip:8080 Faild
[WS-Client] client disconnected.
[WSc] Disconnected!

but the original question is solved or not?

Unfortunately not. Any way it is late night here. Will try again tomorrow. Lot of thanks dear Juraj.

but the esp8266 is connected to WiFi network or it is still "scandone"?


text:
Problem Uploading to the Arduino Nano board
]2I am using an Arduino Nano board. It has an ATmega 328P processor. For running the codes I use Arduino 1.8.6 Software. The issue is that when I am uploading my sketch to the board it shows me the following errors:
 Using Port                    : COM7
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x9b
avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x9b
avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x9b
avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x9b
avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x9b
avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x9b
avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x9b
avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x9b
avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x9b
avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x9b

avrdude done.  Thank you.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

I have turned on the show verbose output option turned on.
Also, sometimes the following errors pop up:
collect2.exe: error: ld returned 255 exit status

Using library SoftwareSerial at version 1.0 in folder: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.14.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SoftwareSerial
exit status 1
Error compiling for board Arduino Nano.

I have referred the following links to solve my issue:

collect2.exe: error: ld returned 5 exit status
Why I can't upload my programs to the Arduino board?

I am making an application wherein I have to control two DC motors via Bluetooth module HC-05
In one of the troubleshooting questions, the solutions contained the possibility of the bootloader not being installed where the problem can be verified by pressing the reset button and checking the bootloader LED to blink. Can someone help me with this?
Also, there are two processors shown for ATmega328P:

The ATmega328P
The ATmega328P (old bootloader)

I tried using then both options for uploading the sketch but still, the errors pop up.
I have also downloaded and installed the latest FTDI drivers from their site.

Can you tell which nano board you have? You can give a link to it or a photo of both sides.

Has this PC->cable->Nano combination ever worked, or is any of those components new? If these are new & untested, have you confirmed the settings: Tools > Board, Tools > Port, and Tools > Programmer? And if they once worked and now don't work, have you tried substituting each of them for known working ones? Will this Nano upload a Blink program from a different PC?

No, I tried for upload blink programme also but didn't work. Also, the components used are tested and are working or have been directly taken from the manufacturer website

The ch340g usb-serial chip is not officially supported by Arduino. You need an extra driver for your nano clone. For windows try this: http://www.wch.cn/downloads/CH341SER_EXE.html

A common solution is to actually switch the board type to the Arduino Uno. It is a known problem but I have yet to see any other viable fix.

the 'new' bootloader option is the same as changing board option to Uno


text:
Arduino Clock Speed effect on Stepper Speed
I am running a Pololu A4988 Stepper driver with two (soon to be three) steppers using the AccelStepper library. I have wired 1/8th microstepping on both as smooth running is important.
The motors run fine however, when running simultaneously, if Stepper 1 finishes its move before the Stepper 2, there is a marked increase in speed in the Stepper 2 (evident audibly and visually).
The code I use to run the motors is:
void MoveAccelXY(int Xm, int Ym) // function 6
{
  X_Axis.moveTo(Xm);
  Y_Axis.moveTo(Ym);
  while(X_Axis.distanceToGo() !=0 || Y_Axis.distanceToGo() !=0)
  {
    X_Axis.run();
    Y_Axis.run();
  }
  Xpos = X_Axis.currentPosition();
  Ypos = Y_Axis.currentPosition();
  Serial.print("X" + Xpos);
  delay(50);
  Serial.print("Y" + Ypos);
  delay(50);
  Serial.print("C");
}

I would like there to be no speed drop on any steppers. Increasing the input voltage does not have an effect.
Is the Arduino clock speed the culprit?

Do you set the maximum speed with setMaxSpeed() ?

Without seeing the rest of your code, the best guess - and I think it is quite likely - is the use of delay() and printing within the stepper function. With 2 motors running, and even ignoring the printing time, there will be a total of 200ms taken up by the delays. That means each motor gets serviced a maximum of 5x/sec. Stop one motor, and the other one can double that to 10x/sec.
Look at the Blink Without Delay example for one way of managing timed events without calling delay(). The SimpleTimer library provides another.
Update:

...run() events are triggered within a while() loop ...

Ah, yes, I see that. So it looks like only one motor could run at a time - the while() loop runs until this motor reaches its target. But you said you run two at a time. So yes, I think understanding the rest of the code will help.

This seems most likely. See the documentation for run() https://www.airspayce.com/mikem/arduino/AccelStepper/classAccelStepper.html#a608b2395b64ac15451d16d0371fe13ce

Thanks for the feedback. The function itself is called from the void loop() function when the correct format of bytes is received through the serial port. The actual run() events are triggered within a while() loop so the delay functions only trigger after the motors have moved. I can post the rest of my code if you think this will help?

@MJ2507 You may have the max speed (max steps/second) set too high. If it is too high it will be limited by the MCU clock speed. You can try reducing the max speed until the second motor doesn't speed up after the first stops.

Why would the clockspeed change when driving multiple motors at the same time?
How do you power the motors and Arduino?
I suspect that your power supply is the problem.
Running 2 motors likely doubles the current consumption. Try to measure the input voltage, does it drop when driving both motors?
You should check the current your motors can consume and compare with what your power supply may provide. (Also keep the 1A limit of the driver in mind)

I don't think this would be an issue with stepper motors. Since they move a fixed distance with every step they should only move as fast as the pulses arrive from the arduino.

it is powered by a 30V 2A DC power supply. There are no noticeable voltage drops when it is run. The maximum current of each stepper is 1A but i think both together I don't see anything higher than 1A total (running at around 12V).


text:
How many clients can connect to an ESP32?
I am using an ESP32 as my master and 10 ESP8266-07s are connected to the master that is in AP mode.
But I need at least 12 clients.
Please help me to increase the number of clients the ESP32 can handle in AP mode.
I have read this article but it did not help me
ESP32 AP max connections: 4 or 10?

have you considered ESP-NOW? it can handle more clients and traffic since it has lower overhead than wifi

esp-now is not secure to me.i think the better way is mesh.but its too force for me right now.so i add aother esp32 in my master and then connect both esp32 by serial to together.and then any of them can conect to 10 client and 1 on the esp32 control and calculate every thing

The max number of stations for SoftAP is a runtime setting available in Arduino.
ESP32 arduino WiFi library and esp8266 ESP8266WiFi library have it as last parameter in softAP() function which starts the SoftAP.
bool softAP(const char* ssid, const char* passphrase = NULL,
    int channel = 1, int ssid_hidden = 0, int max_connection = 4);

esp8266 arduino doc

max_connection - optional parameter to set max simultaneous connected
stations, from 0 to 8. Defaults to 4. Once the max number has been
reached, any other station that wants to connect will be forced to
wait until an already connected station disconnects.

ESP32 SDK doc

uint8_t max_connection   Max number of stations allowed to connect in,
default 4, max 10

this code is in the 254 i think,i changed it also.no result!!!

The SDK API documentation from Espressif directly notes:

uint8_t max_connection
Max number of stations allowed to connect in, default 4, max 4

EDIT
However, another area of the API documentation (The API Guide) notes:

max_connection
Currently, ESP32 Wi-Fi supports up to 10 Wi-Fi connections. If
max_connection > 10, soft-AP defaults the value to 10.

strange. I do not believe this. it must be a copy-paste error (from esp8266 doc?). it has two processors

Perhaps so. I found another place in the API Guide which implies that 10 is the max.

If you use softAP, you can set the max number of connections to 16 I believe.
WiFi.softAP(const char* ssid, const char* passphrase, int channel, int ssid_hidden, int max_connection);

i use soft ap ,and realy thiscode,and changed the code  max connection to 16,but didnt worked.is the chanel numer important?

i should do it,so i must try any idea which everyone suggest me


text:
Read only one line in SD card
I have some C++ code, but I cant convert it to Arduino language.
I just want to ask, what is the same as getline() (C++ code) function in Arduino?
I just wanted to get the first line in my SD card...
I can only display all text inside my SD card...
Example:
line1   <-   only this line should display(and this line will delete in text
             file... but that is another issue... i will just focus to get the
             line1 and get the value)

line2

line3

line4

line5

This code displays all lines
    #include <SPI.h>
    #include <SD.h>

    File myFile;

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

       Serial.print("Initializing SD card...");

       if (!SD.begin(4)) {
         Serial.println("initialization failed!");
         while (1);
       }
       Serial.println("initialization done.");

       // open the file. note that only one file can be open at a time,
       // so you have to close this one before opening another.
       myFile = SD.open("test.txt", FILE_WRITE);

       // re-open the file for reading:
       myFile = SD.open("test.txt");
       if (myFile) {
         Serial.println("test.txt:");

         // read from the file until there's nothing else in it:
         while (myFile.available()) {
           Serial.write(myFile.read());
         }
         // close the file:
         myFile.close();
       } else {
         // if the file didn't open, print an error:
         Serial.println("error opening test.txt");
       }
     }

     void loop() {
       // nothing happens after setup
     }

You'll be happy to learn that there is no Arduino language. Arduino's .ino files are C++! The only difference is the Arduino IDE automatically generates function prototypes if you don't provide them yourself, but that doesn't make it a different language.

There is no builtin way to do that but you got all the necessary tools at hand.
End of line should be signaled by a decimal 10, aka LF(Line Feed) character.
So what you do is keep reading until you encounter LF or end of file, which then is the entire line you want to read.
while (file.available() && file.peek() != 10) // peek returns the next character without incrementing the read index
    file.read();

This code does exactly that. Now you could either store the read bytes in a buffer (big enough!) right away or instead find out the number of bytes beforehand to create a precisely sized buffer afterwards and use the read(buffer, length) overload to read all bytes at once.
Please keep in mind that the LF character has to be there in order to be read. So if you are the one creating the files, be sure to place it. (most desktop text editors do that for you)
Example:
char buffer[20];
uint8_t i = 0;

while (file.available() && file.peek() != '\n' && i < 19)    // note how this also prevents the buffer from overflowing (18 max to leave space for '\0'!)
{
    buffer[i] = file.read();
    i++;
}
buffer[i + 1] = '\0';    // it is good practice to end strings with a terminating NULL character

i understand what you are saying but
im sorry @mystery, i dont even know what function should i used :(
im just new in arduino...

If I understand you correctly, it depends on what you want to do with that code. Do you want to execute lines of C++ code in/on the SD card or are you merely attempting to convert what you have in C++ to "Arduinoese?"
If you need to, you can actually execute microcontroler-based C/C++ code on your arduino if it has an AVR in it, and you have the proper AVR Toolchain.
Elliot William's "Make: AVR Programming" book is a great place to learn about this.

You can run C/C++ on any Arduino board, not only the AVR ones, and if you can use the board with the Arduino IDE then you already have the toolchain. This is certain because Arduino sketches are C++.


text:
Read analog port set as output
I have a PWM analog port that is outputting a frequency, is it possible to do an analogRead on the same pin and get a correct value? If so, will reading that port disrupt the freq output on the pin? This is being done on a Teensy 3.2 device. My goal is to output the freq visually on an OLED. Tnx.

Just store the PWM value in a variable every time you call analogWrite. Your oled-display routine can then just read that variable.

You want the voltage that would be read by a voltmeter? If you know what value you set for PWM, you know the voltage that is generated.
But if you are curious,  you can connect the PWM output to ADC pin and read for example a 100 values and calculate the average. You will see that at the same resulution of PWM and ADC, you get as average of ADC values the same value as you set for PWM.
This is for M0:
void setup()
{
  Serial.begin(115200);
  while (!Serial);

  analogWriteResolution(10);

  for (int i = 0; i < 1024; i += 10) {
    analogWrite(7, i);
    delay(100);
    long sum = 0;
    int n = 0;
    unsigned long start_time = millis();
    while (millis() - start_time < 100) {
      sum += analogRead(A1);
      n++;
    }
    Serial.print(i);
    Serial.print(' ');
    Serial.println(sum / n);
  }
}

void loop()
{
}

No, it's not possible.
PWM is not actually analog - it's digital, but switching on and off at a high speed.
If the pin were capable of reading an analog value at the same time as outputting a PWM waveform (which I highly doubt...) all you would get is alternating 0 and 1023 values (or whatever range the Teensy reads in).

You can create a parallel branch from PWM pin with a diode. And put a 0.1uF capacitor and parallel 1k resistor after the diode and connect analog pin between diode and resistor to read pwm avarage output voltage. But becareful it will give 0,6V below.


text:
ESP8266 fail to connect MQTT broker
I am using NodeMCU dev board with ESP8266 WIFI.
Every time I try to connect to my local broker it returns this error:
failed, rc=-2 try again in 5 seconds

I am using Ubuntu 18.04, my local brokers are Mosquitto and EQMTT. I tried both of them through pubsubclient library and it doesn't connect. Using MQTT Box works connecting to my local brokers. Connecting to my WiFi also works. When I connect to a MQTT broker using pubsubclient e.g. mqtt://test.mosquitto.org:1883/ it works. It just doesn't seem to work with local broker. This is the code:
#include <ESP8266WiFi.h>
#include <PubSubClient.h>

// Update these with values suitable for your network.

const char* ssid = "mywifi";
const char* password = "password";
const char* mqtt_server = "127.0.0.1";

WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
char msg[50];
int value = 0;

void setup() {
  pinMode(D7, OUTPUT);     // Initialize the BUILTIN_LED pin as an output
  Serial.begin(9600);
  setup_wifi();
  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);
}

void setup_wifi() {

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

  WiFi.begin(ssid, password);

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

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i = 0; i < length; i++) {
    Serial.print((char)payload[i]);
  }
  Serial.println();

  // Switch on the LED if an 1 was received as first character
  if ((char)payload[0] == '1') {
    digitalWrite(D7, LOW);   // Turn the LED on (Note that LOW is the voltage level
    // but actually the LED is on; this is because
    // it is acive low on the ESP-01)
  } else {
    digitalWrite(D7, HIGH);  // Turn the LED off by making the voltage HIGH
  }

}

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Attempt to connect
    if (client.connect("ESP8266Client")) {
      Serial.println("connected");
      // Once connected, publish an announcement...
      client.publish("outTopic", "hello world");
      // ... and resubscribe
      client.subscribe("inTopic");
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(1000);
    }
  }
}
void loop() {

  if (!client.connected()) {
    reconnect();
  }
  client.loop();

  long now = millis();
  if (now - lastMsg > 2000) {
    lastMsg = now;
    ++value;
    snprintf (msg, 75, "hello world #%ld", value);
    Serial.print("Publish message: ");
    Serial.println(msg);
    client.publish("outTopic", msg);
  }
}

Note: The brokers are running, I can even connect it through MQTT Box (attached picture).

127.0.0.1 is not the address of your computer.  That is the address of the "loopback" interface - a virtual interface that allows a device to talk to itself.
That means that when you are using the MQTT server itself you can connect, because it's all the same computer.  However the ESP8266 is trying to connect to itself, not the MQTT server.
You need to replace 127.0.0.1 with the actual IP address of your MQTT server.
The simplest way of getting your computer's IP address is to open a terminal window and type:
hostname -I

Thank you for responding. Where can I find the actual IP address of my MQTT server?

type ip address in a terminal and find the interface you are connecting with. It'll probably be 192.168.xxx.xxx.

Alternatively you can run hostname -I (that's a capital i) and it will give you all your non-loopback IP addresses.

It returned 192.168.100.3, I have replaced it in my code, but it still shows rc = 2. Any ideas? It's only like that using local broker.

What IP address is your ESP8266 being given?

ESP8266 is given 192.168.100.12

Try running netstat -an4 | grep 1883 | grep LISTEN and tell me what it tells you

Thank you. It suddenly worked, that is after your suggestion to hostname -I.

Can you help me again? It's not working suddenly. It seems to be very inconsistent. I haven't changed the code since yesterday (last time it worked).

netstat -an4 | grep 1883 | grep LISTEN gives me
tcp        0      0 127.0.0.1:11883         0.0.0.0:*               LISTEN      tcp        0      0 0.0.0.0:1883            0.0.0.0:*               LISTEN

The last line of that output is mosquitto listening on all interfaces, so that's fine. If it has worked, but isn't now, it may be something to do with your network or computer. It wouldn't be your sketch, since that doesn't change.

How would I able do diagnose it correctly? I am using Ubuntu 18.04 on WiFi connection.

However, I would handle your connection differently in your sketch.  Hold on, let me upload an example for you that I am using live in front of me right now (5 channel digital audio mixer controlled by MQTT)...

Another note, I listed all devices connected to my WiFi network, I tried pinging ALL online ones with their IP Address but it results in From 192.168.100.3 icmp_seq=3 Destination Host Unreachable. Only the ping to NodeMCU works 64 bytes from 192.168.100.12: icmp_seq=3 ttl=255 time=11.9 ms. May that be the problem?

Oh wow really weird! It's connected to MTTQ now. I just let it rest.

Here's an example: https://github.com/majenkotech/AmpControl/blob/master/AmpControl.ino - focus on what's in loop - the rest is pretty much irrelevant.

To give you an overview: you don't need to wait for a WiFi connection. You just need to see if it is connected or not - and if it is, then check if the MQTT is connected and connect it if it isn't, subscribing once the connection is established

Hm thanks for the help, but I don't really get the difference, it's basically linear with my logic. I just have trouble getting the MQTT connection, which I suspect has something to do with my WiFi/ host.

It takes about > 20 of these
Attempting MQTT connection...failed, rc=-2 try again in 5 seconds until it gets connected.

I would suggest getting rid of (or massively shortening) that 5 second delay.


text:
ESP32: Disable Brownout Detector
I have an ESP-WROOM-32 and I'm using Arduino IDE to push code on it. My ESP is powered via 2 AA batteries and got one power supply problem.
It works well on new battery but after a bit, I will always get this error repeatedly:

ets Jun  8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0,
  SPIWP:0xee
  clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
  mode:DIO, clock div:2 load:0x3fff0018,len:4 load:0x3fff001c,len:812
  load:0x40078000,len:0 load:0x40078000,len:11584 entry 0x40078a60
Brownout detector was triggered

So, I know that it's possible to disable that feature in ESP32. My question is how to do it?
What I have done that didn't work:
Add this code in my Arduino IDE:
#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"
setup(){
    WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
}

Change Arduino\hardware\espressif\esp32\tools\sdk\sdkconfig with:
CONFIG_BROWNOUT_DET=                //previous was "=y"
CONFIG_BROWNOUT_DET_LVL_SEL_0=      //previous was "=y"
CONFIG_BROWNOUT_DET_LVL_SEL_1=
CONFIG_BROWNOUT_DET_LVL_SEL_2=
CONFIG_BROWNOUT_DET_LVL_SEL_3=
CONFIG_BROWNOUT_DET_LVL_SEL_4=
CONFIG_BROWNOUT_DET_LVL_SEL_5=
CONFIG_BROWNOUT_DET_LVL_SEL_6=
CONFIG_BROWNOUT_DET_LVL_SEL_7=
CONFIG_BROWNOUT_DET_LVL=           //previous was "=0"

Why do you want to disable it? It's there for a reason: Your batteries are too flat to reliably power the ESP-32.

Because the manufacturer of the device told me to do it, but he's using ESP-IDF and I prefer to code with Arduino

What kind of batteries are you using?

I'm using 2 AA batteries each 1.5V

I asked what kind, not what size.  Alkeline? Zinc Carbon? NiMH?

Alkaline Plus Power by Panasonic

At 100mA average current you can expect those to last about 20 minutes before they go below the minimum voltage for the ESP-32.

Are there any batteries than I can use AA size that can power up my ESP-32 and last more than 20 minutes ?

For battery operation you have to use very aggressive power saving modes of operation.

I already have sleep mode for the device. It wakes up every 15 minutes to send data to a server via wifi then go back to sleep. Maybe LiFePO4 batteries will solve the problem ?

You might have more luck getting an answer by asking the authors of the ESP plugin for the Arduino IDE, since they are far more intimate with the internal workings of the ESP-32 and ESP8266 that we are here.

Alkaline battery will start at 1.5v but very quickly drop to around 1.2v and stay between 1.1 and 1.2 for most of its discharge depending on current until it's flat and it drops below 1.1v.  That means 2xAA is getting you 2.2V to 2.4V for most of the battery's life except the first little bit. You need 3xAA (alkaline, but also most other types) for reliable operation of a 3.3V MCU, plus an LDO. Disable brownout detection if you know what you're doing and know that your application can reach a certain undervoltage without consequence.

For me brownout issue was solved by removing the esp32 from Arduino IDE board manager + removing files from disk and use install procedure "Using Arduino IDE with the development repository" - https://github.com/espressif/arduino-esp32/
I guess it will use newer version of arduino-esp32 that has some brownout protection due to CONFIG_REDUCE_PHY_TX_POWER being activated by default. Also you should probably learn how to decrease wifi power + deep sleep for longer battery usage.

Maybe it's silly but I added a delay to my script before I got the error.
Serial.println("Delay 5s Brownout detector was triggered");
delay(5000);


text:
The right way to find and understand the libraries
I am working on a project to send sensor values from esp8266's Wemos D1 mini to MySQL.
I tried using the library MySQLconnection.h but I couldn't make it to connect to wifi. So I uploaded a simple program to connect the board to WiFi using ESP8266.h but I got the error that Unable to compile for Wemos D1 board.
Please tell me the right procedure to select the right library for the problem defined.

are you trying to program the ESP or an AVR connected to an ESP? if ESP directly, modify the examples to get started, they are well-documented and easy to adjust.

https://gist.github.com/pudelosha/5a42092bbcf0bfc9ddab20e6093e68b7 is a good example that might help you.

see examples in IDE File menu.  the ESP8266WiFi library. ESP8266.h is an empty library that exists only for included examples.

You should break your problem down into simple parts, which it seems you are on-track to do. Your ultimate goal appears to break down into the following sub-tasks (not in order):

Read sensor value
Connect to a WiFi network
Connect to a MySQL server
Send sensor data to MySQL database

You are unlikely to find a single library to do all of these tasks, but as progress in solving each step, any library that works is the "Right" one, in general. Choose a library that solves an individual task.
You say you tried to upload a simple program to only connect to WiFi, but that it did not compile. The clue to why it did not compile will be found in the actual compile error message. If you can update your question with the error message and the code to the simple program, you can get some guidance from the users of this site to solve that problem.

Okay, I will follow the above methodology. But what I wanted to know is that whether Arduino website provides a systematic approach to select libraries in their website (Although I didn't find anything there). Means that instead of googling the library, a more reliable way to do it.

I find the Arduino website to not be a good source of "what's available" for external libraries. The ones that are documented are often under-documented.

Ok, cool. Btw I just reuploaded the simple ESP8266 program and it worked. Thank you for suggestions.

But how can I know what are all the functions, objects available in a library?

Typically the best way is to find and read the source code of the library.

sources of information are examples in IDE in File menu,  "More info" link in Library Manager in Sketch menu in IDE, repository on GitHub, ...


text:
How can I detect which baudrate a virtual COM port is set to?
I would like my software running on Leonardo to behave differently depending on the baudrate of the USB Serial set by the PC. For example, I want to make a smart USB to UART converter which performs some processing of the data it transmits. It would be much more elegant to set the UART baudrate to whatever value the PC is requesting on USB side, rather than hardcoding a value.
AFAIK 32u4 chip is used as a USB to UART converter on Mega, where it supports different baudrates, so this should be doable.
I also have a Teensy 3.2 board, so if anyone knows how to detect the baudrate on this board I'm also interested.

From looking at the source it appears that on 32u4 based boards Serial  includes extra methods to access the settings from the USB host:
see: https://github.com/arduino/ArduinoCore-avr/blob/b7c607663fecc232e598f2c0acf419ceb0b7078c/cores/arduino/USBAPI.h#L129
From USBAPI.h:
// These return the settings specified by the USB host for the
// serial port. These aren't really used, but are offered here
// in case a sketch wants to act on these settings.
uint32_t baud();
uint8_t stopbits();
uint8_t paritytype();
uint8_t numbits();
bool dtr();
bool rts();

I tried it out. On Leonardo, Serial.baud() works right after the serial has started, inside setup. On Teensy, Serial.baud() seems to return 0 inside setup, so I wait inside loop until a non-zero value is returned.


text:
Bluetooth OBD2 ELM327 connectivity issues
I made a little project using an Arduino UNO, a 3.5" display, a HC-05 bluetooth module and an ELM327 (cheap ebay clone). I managed to establish communication, read the data, interpret and display it, but only one problem remains that keeps bothering me.
After some exchanges of data between Arduino and the OBD2 adapter, communication just drops.  I don't know if its from the HC-05 or ELM327. As far as I could debug it, the data from ELM327 comes incomplete. Usually the response from it, transformed into chars, is like "0103141 03 02 00 >" and I use the ">" char in the program as data exchange complete. When the problem occurs I receive fewer bytes from the OBD adapter and without the ">" char, something like "0103141 03 ".
I made a function that resets the HC-05 module and reconnects, but it takes a few seconds and I want my data to come as a continuous flow.
I tried a few methods of debugging, such as changing baud rate of the HC-05, and adding some delays, but I haven't come to a solution.
I believe that the problem might me one of these three:

The cheap ebay clone messing things up.
The HC-05 not sending the complete data.
A problem with my code.

Below I have attached the part of the code that does the sending of the command and reading the response. When the problem occurs, it gets stuck in the while loop because I have no terminating ">" char and I have to break it, call another function that re-establishes communication and so on.
So my question is: has anyone confronted this problem where ELM327 sends incomplete data that cannot be used?
 BTSerial.println("010F1");
 BTSerial.flush();
 delay(10);
  if (BTSerial.available()>0)
      busy = true;
  while(busy = true && inData != 62)
  {
      temp++;
      if (temp>500000){
          resetBT();
          BTSerial.println("ATWS");
          break;
      }
      if (BTSerial.available()>0){
          inData=0;
          inData = BTSerial.read();
          if(inData != 32) {
              buf[i] = inData;
              Serial.print(char(buf[i]));
              i++;
          }

      }

  }
Serial.println();
busy=false;
inData = 0;
i = 0;
memset(buf, 0, sizeof(buf));
temp = 0;

reduce your code to bare minimum ..... remove the whole while loop and just dump the received data to the terminal window .... analyze the data .... there may be something that you are overlooking ..... post the data into your question, if there is not way too much of it .... maybe some pattern may be found

I managed to solve the issue. After some more testing, I ended up noticing that the problem was somehow the data exchange through the HC-05 bluetooth module. I changed it from being via SoftwareSerial library to the main serial com port and I had no issues since then. I don't know how that library may have caused the problem, but that was it.

You can much more easily interface your Arduino with an ELM327 in software with the library ELMduino.h. It's downloadable through the Arduino IDE and includes examples.


text:
The need to use logic level converter
Why do we need level logic converter to have 5V or 3.3V?
Because in Arduino Uno/Mega (don't know about other boards), they already provide 5V and 3.3V for us to use.

please explain the context for your question?  (the reason for your question)

Is this about i2c?

Level logic converting for level shifting is different from powering a device.
Logic level is the state of a digital input/output. No voltage (or very little of it) is considered LOW.   Over the threshold voltage is HIGH. On a 3.3V system, if you set pin to HIGH, it has 3.3 V.  On a 5 V system, HIGH is 5 V.
A digital input pin reads HIGH once the threshold voltage is surpassed. If the input pin is for 3.3 V and doesn't have 5 V tolerance, feeding 5 V as HIGH could destroy it.  That is why you need level converter from 5 V to 3.3 V.
If the input pin is for 5 V and the threshold voltage is higher then 3.3 V,  3.3 V input will not be read as HIGH.  That is when you need level converter from 3.3 V to 5 V.
You must consult the 3.3 V device datasheet and check if the input pins are 5 V tolerant.   You should also check the digital pin threshold voltage on a 5 V device in case you want to communicate with it using 3.3 V.


text:
Use 5V SD-Adapter on 3.3V System
I want to use a Catalex Micro SD Card Adapter in Combination with my Arduino MKR GSM 1400. The problem is, that the Arduino uses 3.3V to operate but the SD Adapter needs 5V (or at least 4.5V) to operate properly. Can I just use the 5V output of my Arduino to power the adapter, or will a higher voltage destroy the arduino when using it over a longer period of time? And if so, how can I use my MKR GSM 1400 with a SD-module? Maybe by unsing a step up/down converter in my circuit or just switch to a module that uses 3.3V?

I have seen in several Catalex schematics that show pin 13 of the 74ABT125 is connected directly to GND. This would be correct?

The SD card is a 3.3 V device. The 5 V module with SD card adapter steps down the voltage for powering the card and has logic level conversion for card's SPI pins.
If you want to connect SD card to a 3.3 V board it is better to use a simple breakout board without power and signal conversion.
I do not recommend you to connect a 5 V SPI device to MKR SPI pins without logic level conversion.
EDIT: smajli analyzed in his answer the logic level conversion chip used on the adapter you use. it doesn't output more than 3.3 V and you can use it powered from 5 V. but it is still a workaround.

why is it a workaround if it has even bulit in such a chip? so can i use it safely and no 3.3v electronics can get damaged? of course if the wiring is right

it is a workaround because the voltage conversion is obsolete. you should us an adapter without conversion.

ok, thanks i'll buy a 3.3V sd adapter

Catalex Micro SD Card Adapter has built-in level converter in a form of 74LVC125A 3-state buffer. This buffer chip needs 1.65 to 3.6V voltage supply. The +5V from your Arduino is lowered to 3.3V by the adapter (as seen in the schematics, just change 74ABT125 to 74LVC125A).
Link to 74LVC125A
Link to Catalex Adapter schematic
To operate the adapter you would need a certain logic level. Your Arduino provides signals with 3.3V level. This fits perfectly to the adapter.
The answer is yes, you can connect your Catalex SD card adapter with your Arduino.
Good luck

So how should I wire it? Just connect to SD-VCC with the 5V output of the Arduino . And put both ground pins together and the arduino won't be affected by this higher voltage because on all the other pins (cs,mosi,miso and sck) it will send all the data with 2V high an 0.8V low? So nothing over 3.3V wich would harm this arduino?

You can use the adapter because:

the adapter uses an AMS1117 to generate 3.3V to supply the SD card and the level shifter
the level shifter is a 74LVC125 which uses 3.3V and works with 3.3V (and accepts up to 5V as input level)

The adapter works for 3.3V and 5V systems as long as 5V power is available.


text:
Passing HardwareSerial and SoftwareSerial as a Class Property
I wish to know if there is a way to use a single property Serial0 to hold a HardwareSerial or a SoftwareSerial or other class instances supporting basic methods such as available(), read() and write(), in order to make a CustomSerial Class (polymorphism?).
class CustomSerial{
    <GenericSerial??> Serial0;
    char c;
    void read(void){
        c=Serial0.read();
    }
};

The calls should be:
CustomSerial SerialCus;
int n=SerialCus.available();
char c=SerialCus.read();
SerialCus.write(c);

What should I use as GenericSerial class, or what should be the proper use? I tried the Stream class (as the answer pointed), but for some reason the functionality is not preserved (it writes unknown characters). Should indeed Stream be the generic class I need for this?

If you can not make a common class, then you can use a template. If the class (any class) has a .available() and .read() and .write(), then the compiler fills in the used class.

A base type for Arduino hardware serial classes, SoftwareSerial and other software serial classes and some other Arduino classes is Stream (reference). Stream.h on GitHub

class CustomSerial {

private:
  Stream &stream;

public:
  CustomSerial(Stream &_stream) : stream(_stream) {}

  int read() {
    return stream.read();
  }

  int available() {
    return stream.available();
  }

  int peek() {
    return stream.peek();
  }

  void write(byte b) {
    stream.write(b);
  }

};

SoftwareSerial Serial0(10, 11);
CustomSerial SerialCus(Serial0);

void setup() {
}

void loop(){
  if (SerialCus.available()) {
    char c = SerialCus.read();
    SerialCus.write(c);
  }
}

I indeed used Stream for defining the property, but for some reason, this do not work the same way as using HardwareSerial, hence i have been unable to extend it for SoftwareSerial instances.

@hyprfrcb, I added code to the answer

This setting works perfect!... And also address how to use the Stream references... :)

The AltSoftSerial uses the Stream as well.


text:
Use IR remote with arduino
I would like to use the IR remote with Arduino to turn on a LED and turn off the same LED when I push on the remote.
That is to say :

If I push on 1 I would like the LED turn on
If I push on 2 I would like the LED turn off

Here is my code :
#include <IRremote.h>

const int RECV_PIN = 7;
IRrecv irrecv(RECV_PIN);
decode_results results;

const int L1 = 13;

void setup(){
  Serial.begin(9600);
  irrecv.enableIRIn();
  irrecv.blink13(true);
  pinMode(L1, OUTPUT);
}

void loop(){
  if (irrecv.decode(&results)){
        unsigned int value = results.value;
        Serial.println(value);
        irrecv.resume();
        if(value == 12495){
        digitalWrite(L1, HIGH);
        delay(1000);
        }
        else if(value == 6375){
        digitalWrite(L1, LOW);
        delay(1000);
      }

  }
}

But the problem is when I push on 1 I just see the LED turn on but very quickly the LED turns off then whereas I don't push on the button 2.
Could you help me please?

Unrelated; there is no need to add the delay(1000); after turning the led on/off.

This line of your sketch irrecv.blink13(true); tells the IRrecv object to flash the LED on and off when an IR signal is received. boarddefs.h in the IRremote folder has pin number 13 defined as the default BLINKLED. The code you have written in loop() is trying to do something different with the same LED. I would remove this line irrecv.blink13(true); then try your sketch again. Once the LED is working correctly, try removing both of these lines delay(1000);.


text:
arduino firmware
Hi I was wondering if there is any way to/ how I might go about solving the following.
I am designing my own arduino board based on a mega32u4 chip and I want my arduino board to light up an indicator led depending on if an analog pin is in use. For example if a user uploads code that utilizes a certain pin say reading a voltage from A0, the arduino would light up an LED next to that pin.
I was thinking perhaps I could tie the analog pin to a digital pin in the firmware and have the digital pin go HIGH every time the analog pin is in use(is this possible/ could anyone point me to good examples online)?
The user needs to know whether or not the pin they think is writing is actually outputting a signal and/or if the pin they think is reading is reading a signal. This is beacause they will be hooking up outputs and inputs to the arduino board using conductive ink and if their circuit isnt working the indicator lights will let them know that their software is working but there is probably a break in the circuitry they drew out.

Sounds like you would like a LED per pin to indicate usage, mode, etc? You could do this with a shift register or GPIO port extender and then modify the Arduino core pinMode() and analogRead() so that the status is shown on the respective LED. If I remember correctly the mega32u4 has a few extra pins that are not used by the Arduino core. These could be used for the LED control.

First you will have to define "in use". Do you mean actively using analogRead(), or just that something is connected to the pin?

It takes about 100 microseconds (0.0001 s) to read an analog input. So I doubt you can see the leds flash that fast.

Mikael, this sounds like a feasible solution but could it be implemented behind the scenes such that the user does not see the code? Like I suppose I would have to implement my own modified core that the user would select my board in the tools>board menu. It feels like that might be bad practice to have those functions write to other pins (anyone want to weigh in?) but it is a solution.

Majenko, I was imagining that the user would have the pin mentioned in their code somewhere regardless of whether or not anything was connected. Would it be possible to have an indicator light turn on if something was connected (even if it was an input device)?

it may be possible to design a hardware solution for turning on a LED when something is connected to the pin

Any ideas @Jsotola?

using specialized connectors, such as a 2.5mm phono connectors .... one pin would be used for the signal ... the other pin would be for insertion detection  .........  pin mentioned in their code somewhere ...  this would be a problem, because having the code in the program and actually running the code are not the same thing ....... you would have to use an outside program to scan the code and find any references to any of the analog pins

i  think that you are underestimating people's level of inattention to detail ..... you can have all the flashing lights in the world, and they will still connect the wrong pin ..... also, there is this .... "Why did you connect the wire to pin 5?" .... "I don't know why, but the light told me to connect it."

@Chris, did you see my answer?

When you upload code that is the firmware. There isn't another lot of firmware (like an operating system) that is always there (excepting the bootloader which is only used for uploading new code).
Maybe you could connect an LED, via an op-amp as an amplifier, to the analog pin, so that if a voltage appears that it would light the LED. However it could be "in use" and reading zero volts so that wouldn't prove an enormous lot.

would it be ill advised to attempt a solution on the lines of what Mikael proposed in the comments?

You can make your own analogRead function and encourage your users to use it (or do it via a #define) however that will only work if people use your new function or header file.
It would also have the side-effect of making other pins not available (ie. the pins you are doing the LED on) which might be confusing for users who are trying to use all available pins.
I assume this is some sort of teaching gadget? It might be better to teach people to do an indicator LED themselves rather than trying to automate it for them.

Thanks for the clarification Nick, would it be ill advised to attempt a solution on the lines of what Mikael proposed in the comments?

See amended answer.

Create a library. User will include it and the h file will create a single instance of the handler object for your pin pairs. The handler will register a timer interrupt, and the interrupt will check the source pin and set the target pin.


text:
Is there any easy way to change Arduino Wifi shield to ESP8266?
As the title says, is there any easy way to replace WiFi shield with ESP8266, with as little as possible modification to code?
Here is my ESP:

for the esp-01 in link, use Serial connection and AT firmware with WiFiEsp library. it is the most common option and Internet is full of tutorials

next time your question gets put on hold, please edit the question .... do not post another question

The old question was about rtpmidi, this is more general I think

Consider porting your sketch to esp8266 board like Wemos D1. The API of the ESP8266WiFi library is same as the API of the WiFi library.
To use esp8266 as network adapter, you have two wiring options.
If you have or buy an esp8266 module with SPI pins, you can connect the esp8266 over SPI like the WiFi shield is connected. Then you upload the WiFiSpiESP firmware to esp8266 and you include in your sketch WiFiSpi library instead of WiFi library.
Second option is to connect esp8266 over Serial or SoftwareSerial. The esp8266 should have AT firmware installed. The you can include WiFiEsp library in you sketch and initialize it with the Serial interface of your choice. You can find the WiFiEsp library in Library manager. Most new esp8266 modules have AT firmware installed at default.
There is one more option for Serial connection, if WiFiEsp wouldn't work for you. WiFiLink firmware and library
All mentioned libraries WiFiSpi, WiFiEsp and WiFiLink have the same API as the WiFi library so the rest of the code should work without changes.

I have wemos d1 uno around, should not be hard to port over. But my thesis already included mega and esp8266... So i tried to avoid them.

Anyway, will buying this solve my problem? Afaik it is mega with esp8266 as wifi inside. https://robotdyn.com/mega-wifi-r3-atmega2560-esp8266-flash-32mb-usb-ttl-ch340g-micro-usb.html

for Robotdyn Mega + WiFi the Serial option with WiFiEsp library. use dip switch setting for esp8266 on Serial 3 of Mega.

Thanks! I gonna buy robotdyn one soon. Seems easy enough.

after a while : buying robotdyn mega was one of the worst mistake I've ever made.

@RinaldoJonathan, why? the esp8266 with Mega is good. I write a new WiFiEspAT library and most of the time I work with Mega with esp8266 on Serial3. I have AT firmware in esp8266

getting esp-01 + mega counterfeit/clone in separate are far cheaper. Mine never successfully connect to wifi and the dip switch somehow very buggy (sometimes it randomly disconnects)

@RinaldoJonathan, then sorry. I don't have this board but I have other Robotdyn boards and some modules and the manufacturing quality is good with them


text:
Sending data over two independently powered arduinos
I have multiple arduinos that are each powered by a 12v battery through a 5v regulator.  All arduinos share a common ground.  Can I simply connect the digital output from one arduino into the digital input of another?  I'm worried the (small) voltage differences between each regulator could cause a problem.

Can you tell more? Add the extra information to your question. How many is multiple? 3 or 3000? Please explain the distances and what else is going on. Do you use SoftwareSerial for the communication? Are there powerful motor or other things nearby? Is the digital signal in a wire next to other wires with current peaks? You could add a protection resistor of 1k at the input, but you can also try wireless or with a optocoupler.

Small differences in power supply will have no effect. Very long distances could have an effect though. How far apart are the Arduinos?

According to the datasheet, the input voltage on an input pin should be between -0.5V to VCC+0.5V. You you have 0.5V of margin. For added safety you could add a 1-10k resistor in between the two.

It's ok if the distance between the two devices are not too big. (couple meters)
Since the valid logic level (voltage) ranges are pretty wide a small difference won't affect the operation of the devices. Arduino uses TTL (5V) logic so let's see the level diagrams:

If you see the output level ranges (on the right) are more strict than on the input side (on left) so the logic value remains valid even if a small voltage drop or noise occurs on the wire.
Make sure you won't connect two outputs directly since it can damage the microcontrollers. Connecting two inputs are totally safe.
EDIT: If you want to cover longer distances you need to use a balanced line  e.g. differential I/O-s, RS-485 or CAN. These are not default Arduino features so you'll need additional electronic to use them.

Well "totally ok" is a stretch. Not all 0V is equal and if the common 0V is noisy, long or current carrying you could have false level shifts. An RS485 link would be better with its high CM range. This probably will work but universally ? No


text:
Using a analog multiplexer to use 9 serial input sensors?
I have 9 sensors, they will send a datastring to my Arduino through Tx/Rx (every 3½ seconds, pre-programmed). The only problem is that there's only one Tx/Rx port on an Arduino Uno. Is it possible to use an analog multiplexer to "make" more Serial ports? Because the sensors send something every 3½ seconds, there's no need to be fast.
EDIT: It's a Temperature and Relative Humidity Sensor

what sensor? can you add a link?

Not that it matters particularly, but every 3-5 seconds or 3.5 seconds?

exact model of the sensor please

No. Not unless you can change your communication protocol to be a "call-and-response" protocol.
Basically, the problem is this: when do you switch to which serial device? Unless all the devices have their timing synchronised there is no way of knowing - so how do you control your analogue multiplexer in that situation...?  You can't.
You would need to have some method of the master switching the multiplexer to a specific peripheral, then send a message to that peripheral saying "Send me your data now".
You would be better off investigating other boards with more UART ports, such as the Mega2560, and having multiple boards.
The Mega2560 has 4 UART ports. You can have 4 sensors per board (5, if you want to use SoftwareSerial or, better, AltSoftSerial), so you could get away with two boards.
One board acts as normal, communicating on the UART ports to 4 sensors, and also acts as an I2C or SPI master (the choice is yours). The second board communicates to 4 more sensors on UARTs and one further on using AltSoftSerial etc. It also acts as an I2C or SPI slave device.
The "slave" board just runs autonomously gathering data from the sensors it is directly connected to and storing those values.  The "master" then periodically asks the "slave" board for the latest data.

Thanks for the answer and my apologies for the late answer.
I just tried a multiplexer, because some people said that I would work. I can receive info from all the 9 sensors. The sensor sends a datastring and I filter the temperature and relative humidity and then I switch to the next sensor. It works quite well, the only problem is that you can't request the datastring, so you should wait till the datatstring is sent


text:
Can a DHT11+ESP8266 be powered by a Adafruit USB LiPo charger directly?
I have rigged up a small DHT11+ESP8266 combo which I'm currently powering from the 3.3v from an Ardruino. I've ordered a 3.7v LiPo battery and have a Adafruit usb micro LiPo charger, however, the battery will take two weeks to come.
Can I plug the usb charger directly into the DH11 while my battery arrives?

What kind of module is the ESP8266? Wemos? NodeMCU? AIThinker module only? Bare chip?

DHT11s use next to nothing, you can power it from a GPIO set to output HIGH...

It's an ESP-01S. "DHT11s use next to nothing" I'm more worried that the charger will fry it. Is the voltage the only thing I should be worried about?

No, you can't.
The charger circuit will only operate properly with a battery attached.
It is not designed to provide power to a system. It is designed for charging the battery and nothing else.  You are supposed to remove the battery from the charger and then attach it to your circuit.  Even with a battery attached you can't use it to power your circuit - the voltage will be too high, and your target circuit will confuse the charger and it will fail to charge the battery properly (or it may end up over-charging the battery).
To do what it sounds like you want to do you need:

A LiPo charge circuit
A 3.3V regulator (ideally a Buck/Boost combined regulator)
Bypass circuitry to power the 3.3V regulator directly from the incoming power when present or from the battery when no external power is present.

ok, - what is the difference between the power supply coming from the charger and the supply after the steps you've mentioned here? I Don't want to use the two in conjunction - when I have the battery I'll just be using that, as you suggest. So it looks like the only difference is the 3.3V regulator - is the only concern that the charger will not give out a steady 3.3V voltage?

The charger press out special voltages and currents depending on the state of the battery connected. With no battery it won't know what to do.


text:
Adafruit Huzzah ESP8266 Battery Power issue
I'm trying to connect a ~5.5V (2 x 3V coin cells in series, but their voltage drops a little) to the VBat (or V+) of my Adafruit Huzzah ESP8266 module (not the black Feather one, the smaller blue one: https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/pinouts)
Whenever I do that the voltage output from the 3.3V pin drops to ~0-1 V and thus the ESP stops working.
However when I use the FTDI cable (3.3 V) and connect it to my laptop, there is no problem, I get almost 3 V.
I also added a 1000mF capacitor to smooth out voltage signals and actually that also helps to increase the volt a little (without it I get almost a 0 V on the 3.3V output)
Any ideas?

After tinkering more, I figured out that the Huzzah module is happy to take in up 4.5V via a 3 AAA battery cell so I guess it's ok up to 5V since my previous battery input was over 5V.
That's a little weird considering that in Adafruit's page, it says

..to make it easier to power, we put a high-current-capable 3.3V
  voltage regulator on the board. It can take 3.4-6V in but you should
  stick to 4-6V since the ESP8288 has high current usage when WiFi is
  on.

Hope this may help someone else.


text:
Build an improved GSM antenna for arduino mkr gsm 1400
I want to use an Arduino MKR GSM 1400 in my area wich has a bad connectivity on mobile internet. On my phone it's very weak and if i drive to the next village it works sometimes on the arduino with the given standard antenna but I want it to work in a wider range. Is there any antenna available specifically for mobile connections wich you can put on a arduino? And how do you call them and where can I buy such a thing or even build it myself? Do you have any suggestions for such an antenna? And is there something I can improve with just using software to strengthen the signal?

On one end of the MKR GSM 1400 is a U.FL antenna connector.  To that you need to connect a U.FL To Female SMA Adaptor.  That adaptor can then screw into an SMA GSM Antenna of your choice.

Do you have any suggestions for such an SMA antenna wich has a wide range? And where can I find that specific adapter??

I get the adaptors from eBay. I can't recommend a specific antenna, but the ones with a long cable and a magnetic mount (that are intended to go on top of cars, etc) would allow you to place the antenna in a high location where you can get better signal.

@The_javascript_King The connector is one thing, but antenna performance is dependent on antenna type and gain. Try to compare gain values (in dBi) of the antennas you're buying -- the higher, the better.


text:
How to configure TinySine 3G module (SIM5320E) for HTTP GET request
I recently bought a 'TinySine 3G shield (SIM5320E) 900/2100Mhz' based on Adafruit_FONA libraries to use with Arduino Mega 2560 R3.  It successfully registered with Vodafone AU. Other functionality works (SMS, GPS) but not HTTP/TCP.

I'm following this TCP/UDP section of SimCom tutorial to receive data from a REST API. But I cannot set the APN for TCP as there is no support for AT+CSTT command as it seems.
I can see it's on WCDMA network.
    AT+CREG?
    +CREG:1,1

    AT+CPSI?
    +CPSI: WCDMA,Online,505-03,0x014E,xxxxxxx,WCDMA IMT xxxx,xxx,xxxx,0,12.0,97,12,18,500
    OK

Error comes here
    AT+CSTT="live.vodafone.com"
    ERROR

Is there a way to resolve this issue
 - With the same setup/libraries OR
 - By upgrading libraries/firmware of the module OR
 - Using any other set of commands
Please provide if any of you have a sample code to access a REST API. Appreciate your help very much.

did you follow the HTTP section of that tutorial? .... it uses commands that you did not mention in your post

Thanks for the comment. I corrected the link. I followed the TCP/UDP section to be exact.

CSTT works on GPRS modules like SIM900. I found a way to get SIM5320E working to download websites. Tested with TeraTerm and used <Ctrl M> and <Ctrl J> instead of '<CR> <LF> OR /r/n' characters.
Network setup
AT+CGDCONT=1,"IP","<your APN>","0.0.0.0"
AT+CGSOCKCONT=1,"IP","<your APN>"
AT+CSOCKSETPN=1

Start HTTP service
You can stop and start service if it's not responding properly.
AT+CHTTPSSTART
AT+CHTTPACT="www.iforce2d.net",80

HTTP GET request
GET /test.php HTTP/1.1  <-- don't hit enter, instead hit the below 2 keys
<Ctrl M>
<Ctrl J>
Host: www.iforce2d.net  <-- don't hit enter, instead hit the below 2 keys
<Ctrl M>
<Ctrl J>
Connection: close  <-- don't hit enter, instead hit the below 4 keys. This is useful when connecting to REST APIs to download the the respective result only.
<Ctrl M>
<Ctrl J>
<Ctrl M>
<Ctrl J>

To end the command and to receive results:
<Ctrl Z>

You will receive a lot of data here.
Stop HTTP service
AT+CHTTPSCLSE
AT+CHTTPSSTOP

You will get the contents of the website. Probably it should contain the data you need (I didn't test the content. May be you will need to tweek the result a bit.)


text:
Can the Arduino interface with a fingerprint sensor on my mobile?
I own a OnePlus 6 and it has a fingerprint sensor. Instead of using a fingerprint scanner module like the R305, could I just use my mobile for scanning the fingerprints? If yes, how do I implement this?
This is for creating a smart home security system.

JRobert has a good point in his answer. what for to send the fingerprint to arduino if the phone is already authenticated?

You'd need an app on your mobile to read the sensor and communicate the result to your Arduino in a secure way that cannot be spoofed by an intruder. That secure communication over an open channel (WiFi, I assume?) is not trivial to do right, so that would be a weak point in your security.
Blynk, an app+server+Arduino library combination provides an authentication token to pair with your Arduino in a relatively secure way. You quickly make (drag-and-drop) a control panel for your Arduino system with it. It doesn't offer fingerprint sensing directly, but if you keep your Blynk authentication token a secret, keep your Blynk app+token on your mobile, and the mobile is fingerprint-locked, you'd have essentially the same thing, and the pieces already exist. You'd only need to code the smart-home parts for the Arduino.

Technically, yes it is possible.

Write an app for your phone that scans your fingerprint and does "something" with it.
Decide on (and implement) some form of communication protocol between the phone and the Arduino and send data from the phone depending on what you decide the "something" above is.
Write a sketch for your Arduino that responds to that communication protocol and performs whatever task you require.

The Arduino side of things, effectively, has nothing at all to do with the fingerprint scanner - it just accepts data from your phone. The fact that the phone is generating that data using the fingerprint scanner as a stimulus is of no importance to the Arduino.
99% of the work for the fingerprint scanner will be done on the phone, and done using phone software. Not Arduino software.

Majenko in his answer described how to do it if you can code an application for phone. Other option is a little  overkill, but should be a ready solution. You could use 1Shield. It is a shield, a library and a phone app to use phone resources with Arduino. It supports fingerprint sensor. I have no experience with it, I only read about it.


text:
Project: Relay is ticking, but not actually switching
I'm trying to make an automatic planter for herbs etc. I finally got everything 3D printed and wired together. But for some reason, the relay I'm using refuses to switch or enable certain connections. I'm confused because it worked perfectly - continuity-wise - during my initial testing or installation.
The relay model HERE. The relay is to be controlling the ground connection of both an 12v indoor grow light and 12v small water pump. I was a bit confused with the relay's wiring itself. First time using this type of relay. Anyway, I got it working; well previously.
Here are some video to help explain the issue:
https://www.youtube.com/watch?v=GUiHs28bvK8
https://www.youtube.com/watch?v=-xaj8q537x4
(After uploading, I hear that my phone's mic stops the tone of the multimeter a few seconds into each video. But trust me, the tone is constant throughout the duration of both videos. You may be able to hear it?)

remove the relay board from the enclosure and check again

Tearing it all apart is the very last thing I'd want to do. It's all held together with hot glue lol. Will do if it gets to that point ... But if that was the situation, I'd just buy another relay module I'm familiar with instead of dealing with this one.

Listening to the sound of the relay, it does turn on and off. Therefor your 12v has enough power. Could there be a shortcut between the pins in the circuit? Remove the wires from the screw terminals. After that, remove the relay board. Is the multimeter okay? I often measure 0.1 or 0.2 instead of 0.0 ohm.

The first video indicates there is a short between the NO and the NC terminal.

I tried messing with it again today and got it working to some degree... So I moved the VCC on the relay to the other VCC, furthest from the JD-VCC pin. Afterwards, I was able to get the expected behavior from the first two terminals of each relay. The pump and lights are working great even at the same time. However, the first and third of each relay isn't working right. They only activate if both relays are on at the same time.... Obviously some sort of wiring issue here I'll have to figure out. Thanks for the advice everyone.


text:
how to make GPRS/GSM SIM900 shield work with gps neo-6M module using Arduino UNO board
I'm a beginer to arduino program.i will like to make a program that will send latitude and longitude on my mysql database.so since 3 days i try to learn how to use all this material(GPRS/GSM SIM900 shield, gps neo-6M).But i only success to make them work alone.i also learn that i cannot use SoftwareSerial for GPRS/GSM SIM900 shield and  gps neo-6M at the same time.
so how can i make GPRS/GSM SIM900 shield and gps neo-6M work together using arduino uno
thank you for you help

This should provide the answer you need link

I think you are searching for a solution like this Interfacing GSM and GPS Module using Arduino where GPS and GSM modules can run together and receive data at the same time.
I tried bringing up both inside setup() and it blocked the other device. Here is some extract of the code (Note that rx,tx and baud rates may differ according to the modules).
SoftwareSerial gsm(7,8);
SoftwareSerial gps(3,4);

void setup() {
    Serial.begin(9600);
    gps.begin(9600);
    gsm.begin(4800); <--- This stopped receiving GPS updates
}

If you look for an advanced way of handling this situation, you may need to implement some light-weight threads (e.g Protothreads) and assign GPS and GSM modules to run in separate threads, so one device may not block send/receive of the other device. These Arduino forum answers may help for such approach.

I will suggest you to use TinyGPS to connect only via GPS and get the position, make sure you are testing outside with good view of the sky or the gps will never get a lock down.
Then when you are familiar with TinyGPS and how to get the location, add the GSM module to send over this information to your mysql server.


text:
Arduino with 8 LEDs and a switch
I have an assignment wherein we have 8 LEDs connected to an Arduino Uno which has a switch. These LEDs light up according to the johnson counter but every time I turn the switch off it should reset back to the start. An example is if I turned the switch off while the pin is at 8 going back to 1 , then when i turn it on it should be back to 1 again. I got the 1 to 8 reset part right but the 8 to 1, I'm having trouble solving.
Here is my code:
int pin;
int sw3 = 10;

void setup() {
  // put your setup code here, to run once:
  for (pin = 2; pin <= 9; pin++) {
    pinMode(pin, OUTPUT);
  }
  pinMode(sw3, INPUT);
}

void loop() {
  pin == 2;
  if (digitalRead(sw3) == HIGH) {
    for (pin = 2; pin <= 9; pin++) {
      digitalWrite(pin, HIGH);
      delay(200);
    }
  }
  else {
    digitalWrite(pin, LOW);
  }

  delay(200);

  for (pin = 2; pin <= 9; pin++)
  {
    digitalWrite(pin, LOW);
  }
  delay(200);

  if (digitalRead(sw3) == HIGH) {
    for (pin = 9; pin >= 2; pin--) {
      digitalWrite(pin, HIGH);
      delay(200);
    }
  }
  else {

    digitalWrite(pin, LOW);
  }

  delay(200);

  for (pin = 9; pin >= 2; pin--) {
    digitalWrite(pin, LOW);
  }
  delay(200);
  {
    if (digitalRead(sw3) == LOW) {
      digitalWrite(pin, LOW);
    }
    else {
      digitalWrite(pin, LOW);
    }
  }
}

I'm not able to comprehend what your problem is. The code also doesn't seem to do a johnson counter. Could you rephase your question, and maybe mark in your code where your problem is?

Some fixes:
pin==2;  should only be 1 = here. == is a comparison.
pinMode(sw3,INPUT);  make this INPUT_PULLUP, to turn on the internal pullup resistor
if(digitalRead(sw3)==HIGH){  change this to LOW, and wire your switch/button to connect the pin to GND when pressed. The internal pullup will unsure the pin is HIGH when not pressed, and the button/switch makes it LOW when pressed. The pin is thus not allowed to 'float' and return a random HIGH or LOW.

I think they are using an external pull-down.

the pin == 2 is probably the problem.


text:
L9110H-bridge motor driver
So I have this old RC car which doesn't seem to connect to the joystick very well so im going to modify it with an Uno with 433 MHz receiver/transmitter.
Both the steer and drive motors work as intended so long as you can reverse their current. I've seen people use the dual channel drivers which is what I know I probably what I should use to drive the motors. I bought a starter kit a while back which came with a single L9110H Chip. I thought maybe I could order another one and just solder them to a PCB and mount the PCB along with the Uno inside the car that way I don't have an extra chip just collecting dust. I've looked at the data sheet for the L9110H and came up with a diagram on Fritzing.

I was hoping someone could tell me if I'm on the right track with this?

Yes, looks good to me. That looks to be identical to the "Application Circuit" on page 2 of the datasheet you link to.

Thanks for your reply. I'm currently trying find out if the motor is too much amperage for the chip I sent the circuit through a multimeter in amperage mode to the motor with it set to 200m and it read 1.36 not to sure if that's 1.36A or  136mA as I do have the lead(red wire) in the 10A plug on the meter

The results are probably meaningless. Measure the resistance of the motor winding.

Well I took a chance and hooked it up and got it working on the back tires gave the steer tires a go since they seem to work on the same principal and they work but there was a sound from the chip so I unplugged it right away haha

@GeraldLeese What kind of a noise?

kind of almost sounds like a buzzer beep.

I’m just testing it using a digitalwrite(pin1,HIGH) with a analogWrite(pin2, 100) maybe changing analogWrite to digitalWrite(pin2, LOW) will stop the beep. Still have to figure out PWM and speed control

Ahh so I started using analogWrite(pin1,  100) and digitalWrite(pin2, LOW) to control the speed the sound I believe is when the pwm is set too low because I when I set it below 50 on the drive motor it starts producing the sound right out of the motor


text:
SPI Digital Potentiometer not working on ESP32
I have an MCP4151 digital potentiometer chip. I have managed to get it to work using and Arduino Uno using the code below:
#include <SPI.h>

byte address = 0x00;
int CS= 5;

void setup()
{
  pinMode (CS, OUTPUT);
  SPI.begin();
}

void loop()
{
  for (int i = 0; i <= 128; i++)
  {
    digitalPotWrite(i);
    delay(10);
  }
  delay(500);
  for (int i = 128; i >= 0; i--)
  {
    digitalPotWrite(i);
    delay(10);
  }
}

int digitalPotWrite(int value)
{
  digitalWrite(CS, LOW);
  SPI.transfer(address);
  SPI.transfer(value);
  digitalWrite(CS, HIGH);
}

But when I try to get it to work using an ESP32 programmed using Arduino language it doesn't. I have connected like that

SCK -> 18
MOSI -> 23
SS -> 5

I also used the potentiometer inside like a voltage divider for test purposes. GND on one leg, 3.3v on the other and an LED on the wiper. Are there other settings that I have to implement in order the ESP32 SPI to work like an Arduino SPI? Did I miss something?

If I am using the SPI defaults (Serial.begin()) and print the variables on the serial monitor Serial.println(MOSI); Serial.println(SCK); Serial.println(SS); I got these defaults MOSI 23, SCLK 18 and SS 5 (VSPI).

I managed to get it to work in a strange way. I opened the example included in the ESP32 SPI Library and copied some points from there.
I first initialise a pointer to the SPI class, then I call begin() at that pointer and inside the digitalPotWrite function I call beginTransaction(10000,MSBFIRST,SPI_MODE0) and end the transaction before digitalPotWrite finishes. Full code here:
#include <SPI.h>

static const int spiClk = 1000000;
byte address = 0x00;
SPIClass * hspi = NULL;

void setup()
{
  pinMode(15, OUTPUT);
  hspi = new SPIClass(HSPI);
  hspi->begin();
}

void loop()
{
  for (int i = 0; i <= 128; i++)
  {
    digitalPotWrite(i);
    delay(10);
  }
  delay(500);
  for (int i = 128; i >= 0; i--)
  {
    digitalPotWrite(i);
    delay(10);
  }
}

int digitalPotWrite(int value)
{
  hspi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
  digitalWrite(15, LOW);
  hspi->transfer(address);
  hspi->transfer(value);
  digitalWrite(15, HIGH);
  hspi->endTransaction();
}

The ESP32 SPI library has defaults for the HSPI pins (14, 12, 13, 15). For VSPI pins, you must specify the pins in begin().
SPI.begin(18, 19, 23, 5);

I both tried to use the HSPI pins with SPI.begin(); and those pins using SPI.begin(18, 19, 23, 5); but nothing worked. Maybe ESP32 used an incompatible frequency for SPI?

Change the int for a void in the function...
That's it.
When you call that function is never going back, still waiting for a return.
int digitalPotWrite(int value)
{
  digitalWrite(CS, LOW);
  SPI.transfer(address);
  SPI.transfer(value);
  digitalWrite(CS, HIGH);
}