text:
How to connect naked camera from mobile phone to Arduino Uno
Okay, guys. I have this 3 cameras(middle from the iPhone 6s, 2 at the side I found, and I think there are from modern phone). I need some information how to connect Arduino Uno to them. I know c/c++, assembler, but noob in microcontrollers, if this knowledge can come useful.

No chance. Sorry. Think again.

About fingerprint sensor, but the answer is fitting also this question: https://arduino.stackexchange.com/questions/71753/can-i-connect-a-android-phone-fingerprint-scanner-to-arduino-or-a-raspberry-pi

sounds like a call, thx

I don't think an UNO could do anything useful with any of those cameras

Can u offer something else?

https://randomnerdtutorials.com/esp32-cam-video-streaming-face-recognition-arduino-ide/

This is a demo code with a proximity sensor on how to Trigger the camera of your cell Phone by Arduino. You can make Ultrasound Motion sensor or PIR sensor to work as a Motion sensing anti theft Camera system. * It's just an Idea , The Sky is the Limit */
int trig = 13;
void setup() { pinMode(trig,OUTPUT); Serial.begin(9600); // initialize serial communication at 9600 bits per second:
}
void loop() // the loop routine runs over and over again forever:
{ int sensorValue = analogRead(A0); // read the input on analog pin 0: Serial.println(sensorValue); // print out the value you read: delay(1); /

You need either a memory extension for your UNO - projects like Arducam did this way back 2016 and then used an OV2640 module. If you want to develop something yourself these are the steps (hurdles) to take:

Get a datasheet of the camera
Design a circuit including

plug for Camera and a
memory module (min 512Kb)

Attach it to the UNO
Write a library/function module (see datasheet for details) and
bring it to life

My tip save ca. two years of your life and get for 6-8$ an ESP32cam
This will cost you enough of your time, but be much more rewarding


text:
nRF24L01 continuously reading closed pipe
I am testing communication between two nRF24L01 modules. The receiver is getting the transmitted message but is also continuously reading (null) data from a closed pipe? I am using the RF24 by TMRh20 version 1.3.12 library on an Arduino Pro Mini with some modified example code. Has anyone else experienced this phenomenon or have any fix for the issue?
Transmitter:
/*
* Arduino Wireless Communication Tutorial
*     Example 1 - Transmitter Code
*
* by Dejan Nedelkovski, www.HowToMechatronics.com
*
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <printf.h>
RF24 radio(9, 10); // CE, CSN
const byte address[6] = "00001";
void setup() {
  Serial.begin(9600);
  printf_begin();
  while (!Serial);
  Serial.println("[radioSend]");
  if (radio.begin()) {
    Serial.println("Radio Receiver starting");
  } else {
    Serial.println("Radio Receiver start failed");
    while (1);
  }
  radio.setChannel(120);
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
  radio.printPrettyDetails();
}
void loop() {
  const char text[] = "Hello World";
  radio.write(&text, sizeof(text));
  delay(10000);
}

Receiver:
/*
* Arduino Wireless Communication Tutorial
*       Example 1 - Receiver Code
*
* by Dejan Nedelkovski, www.HowToMechatronics.com
*
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <printf.h>
RF24 radio(9, 10); // CE, CSN
const byte address[6] = "00001";
long counter = 0;
void setup() {
  Serial.begin(9600);
  printf_begin();
  while (!Serial);
  Serial.println("[radioReceive]");
  if (radio.begin()) {
    Serial.println("Radio Receiver starting");
  } else {
    Serial.println("Radio Receiver start failed");
    while (1);
  }
  radio.setChannel(120);
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
  radio.printPrettyDetails();
}
int dpls3;
char text3[32] = "";
void loop() {
  uint8_t pipeNum;
  if (radio.available(&pipeNum)) {
    int dpls = radio.getDynamicPayloadSize();
    char text[32] = "";
    radio.read(&text, sizeof(text));
    if (pipeNum != 3) {
      Serial.print("[Pipe=");
      Serial.print(pipeNum);
      Serial.print("|Size=");
      Serial.print(dpls);
      Serial.print("|");
      Serial.print(text);
      Serial.print("] [Pipe=3|Size=");
      Serial.print(dpls3);
      Serial.print("|");
      Serial.print(text3);
      Serial.print("|Count=");
      Serial.print(counter);
      Serial.println("]");
    } else {
      memcpy(&text3, &text, 32);
      counter += 1;
      dpls3 = dpls;
    }
  }
}

Transmitter output:
[radioSend]
Radio Receiver starting
SPI Frequency       = 10 Mhz
Channel         = 120 (~ 2520 MHz)
RF Data Rate        = 1 MBPS
RF Power Amplifier  = PA_MIN
RF Low Noise Amplifier  = Enabled
CRC Length      = 16 bits
Address Length      = 5 bytes
Static Payload Length   = 32 bytes
Auto Retry Delay    = 1500 microseconds
Auto Retry Attempts = 15 maximum
Packets lost on
    current channel = 0
Retry attempts made for
    last transmission   = 0
Multicast       = Disabled
Custom ACK Payload  = Disabled
Dynamic Payloads    = Disabled
Auto Acknowledgment = Enabled
Primary Mode        = TX
TX address      = 0x3130303030
pipe 0 ( open ) bound   = 0x3130303030
pipe 1 ( open ) bound   = 0xc2c2c2c2c2
pipe 2 (closed) bound   = 0xc3
pipe 3 (closed) bound   = 0xc4
pipe 4 (closed) bound   = 0xc5
pipe 5 (closed) bound   = 0xc6

Receiver output:
[radioReceive]
Radio Receiver starting
SPI Frequency       = 10 Mhz
Channel         = 120 (~ 2520 MHz)
RF Data Rate        = 1 MBPS
RF Power Amplifier  = PA_MIN
RF Low Noise Amplifier  = Disabled
CRC Length      = 16 bits
Address Length      = 3 bytes
Static Payload Length   = 32 bytes
Auto Retry Delay    = 250 microseconds
Auto Retry Attempts = 15 maximum
Packets lost on
    current channel = 0
Retry attempts made for
    last transmission   = 0
Multicast       = Disabled
Custom ACK Payload  = Disabled
Dynamic Payloads    = Disabled
Auto Acknowledgment = 0b011111
Primary Mode        = RX
TX address      = 0x1010101010
pipe 0 ( open ) bound   = 0x1010101010
pipe 1 (closed) bound   = 0x2020270610
pipe 2 (closed) bound   = 0xc1
pipe 3 (closed) bound   = 0xc0
pipe 4 (closed) bound   = 0xc0
pipe 5 (closed) bound   = 0xc2
[Pipe=0|Size=32|Hello World] [Pipe=3|Size=0||Count=195500]
[Pipe=0|Size=32|Hello World] [Pipe=3|Size=0||Count=216665]
[Pipe=0|Size=32|Hello World] [Pipe=3|Size=0||Count=835055]
[Pipe=0|Size=32|Hello World] [Pipe=3|Size=0||Count=882618]
[Pipe=0|Size=32|Hello World] [Pipe=3|Size=0||Count=1168025]
[Pipe=0|Size=32|Hello World] [Pipe=3|Size=0||Count=1310725]
[Pipe=0|Size=32|Hello World] [Pipe=3|Size=0||Count=1405856]
[Pipe=0|Size=32|Hello World] [Pipe=3|Size=0||Count=1500987]

what is the issue specifically?

did you write the code?

@jsotola Did you actually read the title?  The program is doing what it is supposed to do, sure but the nRF24L01 is not.  If you look at the last few lines of the receiver output you will see that there is an extremely high number of null messages on pipe 3 being read on a closed pipe but not cleared.  I modified the original code to show the problem. If I had just printed what was read then there would have been thousands of blank lines interspersed with the occasional "Hello World". I do not want my code to waste time handling this "hardware" issue.

I think someone else is having the same issue here as I was able to find a fix by ignoring any data available on pipes above 1. https://arduino.stackexchange.com/questions/51741/trouble-with-nrf24l01/85881#85881

Another example where I tested and demonstrate a fix for this issue: https://arduino.stackexchange.com/questions/65249/nrf24l01-tmrh20-library-receiver-gets-blank-data

See also:  https://forum.arduino.cc/t/nrf24l01-clone-tester/902367  to quickly test a single unit.

source: Stack Exchange

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

sort: votes


text:
Add library to CLion project
I have a new project created with PlatformIO in CLion.  I've copied the Servo-1.1.8 library into the include directory.
#include <Arduino.h>
#include "Servo-1.1.8/src/Servo.h"

Servo servo;

void setup() {
}

void loop() {
}

I'm getting a compilation error though:
====================[ Build | Production | uno ]================================
C:\Users\USER_NAME\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\213.5744.254\bin\cmake\win\bin\cmake.exe --build C:\Users\USER_NAME\Documents\Arduino\MultiServoCallibration\cmake-build-uno --target Production
[1/1] cmd.exe /C "cd /D C:\Users\USER_NAME\Documents\Arduino\MultiServoCallibration && platformio -c clion run -euno"
FAILED: CMakeFiles/Production C:/Users/USER_NAME/Documents/Arduino/MultiServoCallibration/cmake-build-uno/CMakeFiles/Production
cmd.exe /C "cd /D C:\Users\USER_NAME\Documents\Arduino\MultiServoCallibration && platformio -c clion run -euno"
Processing uno (platform: atmelavr; board: uno; framework: arduino)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR (3.4.0) > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (avr-stub) On-board (avr-stub, simavr)
PACKAGES:
 - framework-arduino-avr 5.1.0
 - toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\uno\src\main.cpp.o
Linking .pio\build\uno\firmware.elf
C:\Users\USER_NAME\AppData\Local\Temp\ccmN7v6f.ltrans0.ltrans.o: In function `_GLOBAL__sub_I_servo':
<artificial>:(.text.startup+0x98): undefined reference to `Servo::Servo()'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\uno\firmware.elf] Error 1
========================== [FAILED] Took 1.18 seconds ==========================
ninja: build stopped: subcommand failed.

I've never used CMake before, so it might well be something super simple like adding a line to some config to include that library.

the Servo.cpp file is not compiled

@Juraj Aye.  If I comment out the Servo servo; line then it compiles.  It's not very useful without it though.

For what it's worth, I asked a similar question on StackOverflow, on the chance that the slightly different crowd might include someone who uses CLion + PlatformIO for non-Arduino embedded work and has a more authoritative opinion on the topic.
I have no idea whether it's actually safe or a good idea, but for what it's worth, I was able to add an Arduino library to my project by doing the following:

Install PlatformIO with bundled VS Code, install CLion, then configure CLion to use PlatformIO.
Using CLion, create a new PlatformIO Arduino sketch. Let CLion spin its wheels, do some things that might or might not have ultimately made a difference, and make sure it's in a state where it can build and deploy successfully using CLion. I personally just called Serial.start(9600) and Serial.println("something") to output to serial, then verified it actually worked.
Exit CLion, and launch VS Code. Add the folder containing the sketch created in step 2 to its workspace.
Use VS Code to add the library. Wait for it to finish downloading, and exit VS Code.
Relaunch CLion, and try to use the new library.

Be warned, I have absolutely no idea yet whether or not this is actually kosher. I'm under the impression that when you're using PlatformIO with CLion, 100% of everything is actually managed by PlatformIO, and all CLion itself does is stub through the call to launch CMake. Assuming VS Code is the same way, this should theoretically be OK... but until someone intimately familiar with PlatformIO and the way it integrates with both CLion and VS Code reassures me that it is, I'm a little bit nervous about it.
That said... if it actually is safe to do, it's probably the best way to add an Arduino library to a CLion-PlatformIO project since (AFAIK) CLion itself has absolutely no comparable functionality (via the PlatformIO plugin or otherwise), and I've encountered a few libraries for SSD1306 OLED use that are a major pain to copy into a project by hand from their Github repo (because the OLED library has dependencies on somebody else's graphics library, which itself has dependencies on somebody else's math library and menu library, the menu library has dependencies on one or two more libraries... well, you get the idea. Pain. The exact reason things like Gradle and Maven exist for Android & Java, and CMake theoretically now exists for C(++), even though it still seems to be pretty useless in Arduino-land. ;-)

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


text:
Serial Monitor in Arduino works, but other Serial Terminal work only one way
I have a Arduino code working on a Adafruit Feather STM32F405 Express, and as long as I test it with Arduino serial Monitor, everything works perfect. As I want to use a serial terminal (a C# application, or the "Terminal Br@y++") through the same COM port, then I can write my commands, there are executed (output pins send expected signal), but I don't received the serial feedback.
My Arduino code :
void setup() {
  Serial.begin(115200); // initialise USB Serial Port
  pinMode(pumpP, OUTPUT);  // Pump Pin is an output
}
void loop() {
    if (Serial.available() > 0) {
      command = Serial.readStringUntil('\n');
    }
    if (command == "do-it"){
        digitalWrite(5, HIGH);
        Serial.println("did it!");
    }
}

In my Arduino Serial Monitor, I write "do-it", and I recieved "did it!" and I can see the Pin 5 changing level.
In all serial application I could use, I can see the pin 5 changing level, but not the "did it!".
I configured Arduino as described on this Adafruit page :
https://learn.adafruit.com/adafruit-stm32f405-feather-express/arduino-ide-setup [ summary: use STM32F4 library, board number = "Adafruit Feather STM32F405", USB support = "CDC ( Generic Serial supercedes USART)", upload method = "STM32CubeProgrammer (DFU)" ]
And I connect the DFU pin to 3,3V during upload, and reset the board after it.
The worst in this story, is that at first time, it worked OK. Since a week or two, I don't get it to work again.

That sounds like a problem with the Serial Terminal programs. In the end they should exactly do the same: Connect to the COM port, configuring it and listening/sending on it.  So if they don't work, but the Arduino Serial Monitor works, that would mean that they are doing something wrong.

Check that your serial terminal program is asserting the DTR and RTS flags of the CDC/ACM port.

It "kind of work". I have to connect without RTS function, and after connection, I click on the RTS button and it works. When I connect with the RTS function on, then it does not get any message.
Seems a bit strange and not stable working thing.
Does the DTR should be actively put on/off before each expected message ? when I kept it high, it did not work (except for one or 2 messages)

Thank you @Majenko, you gave the solution :
I checked the box "RTS/CTS" in the "handschake" section of Terminal by Bray, and I got all my serial message back from the STM32.
I guess this is a common think on more that stm32?
how did you know, is that somewhere written in Arduino documentation?
for people like me who do not know what is RTS/CTS, here you are: http://www.brainboxes.com/faq/items/what-is-rts--cts-hardware-flow-control-
or not so straight-forward https://en.wikipedia.org/wiki/RS-232#RTS,_CTS,_and_RTR
Funny to figure out that this "5 pin communication" is virtualise in USB.
@Majenko: if you want to "own" the solution, I let you do write it yourself, I will set your answer as solution.

I had a similar issue on the Adafruit Feather M0 Express, which uses an ATSAMD chip, and enabling DTR (DtrEnable of the SerialPort class) in my C# program fixed the issue for me.


text:
NodeMCU with a 5V latching relay - LOW triggers relay
I am going to connect NodeMCU to a latching relay board like tis one (4 channel version): LINK
Both MCU board and relay board will be powered from the same 5V voltage regulator.
Now I have two problems to solve:
Problem 1 - logic levels
NodeMCU logic level is 3.3V and relays board works in 5V levels.
I can either use logic level converters or simple transoptors. Because I am going to attach NodeMCU to a custom PCB, I think transoptors will be simpler to solder.
Problem 2 - relay triggers with low pulse on the control pin
This relay boards works like this: every time the channel pin (T1 - T4) is connected to ground for few miliseconds - the relay flips to other state.
Here is the question: when the MCU board resets/reboots on power cycle, how do I ensure that the control pins are HIGH from the beginning? If they are not, the relay can flip randomly before my program starts and I will not know the initial state of relay.
What would be the best approch here ?

How do you ensure that the relay module is in a certain state at power-up? The linked resource says nothing concerning this.

It seems that my particular relay board is always in the same (NO) state after connecting 5V power. So there is no ambiguity at start, unless some random low-pulse is not send to control pins

Seems High Impedance won't trigger. So first set pin to HIGH, then pinMode OUTPUT.

Since ports commonly are configured as inputs at reset, you will need to add a pull-up resistor.
Then write your setup so that the pin is high before switching to output mode.
EDIT:
Some microcontrollers have internal pull-ups, that are even activated at reset, see the specific data sheet. (Thanks, Juraj. I don't know NodeMCU enough to go in details. Anyway, my answer might apply to other controllers and other loads, too.)
The value of the pull-up can be determined by the maximum input current for the relay module (or your adapting circuitry) and the respective voltages. To be sure, make it a bit smaller, for example to the next E-series value. Just an example: minimum supply voltage is 3.15V (3V minus 5%), the maximum input voltage to detect "high" is 2.4V and maximum input current is 10 µA. Then the resistor will need to be at most Rmax = (Vdd_min - Vin_max) / Iin_max = (3.15V - 2.4V) / 10 µA = 75kOhm. This value is part of the E24 series, but is can be 68kOhm that is in the E6 series.
However, it seems as if the circuit of the modules contains a simple PNP BJT, a pull-up will not work here, because the input needs to be pulled up to the supply voltage of the module. You need a level converter, this could be a simple transistor. How to design that circuit, is another issue. There are lots of information in the web how to do this.

Thanks! This seems as a solving answer!
Any hints what resistor values I should choose? What do I need to know before choosing resistors ?

esp8266 has internal pullup activated on io pins at boot

use pins 4 and 5, they are quieter during power-up than other GPIOs.


text:
Mediatek GPS periodic mode
I'm trying to build a low power GPS datalogger and I am trying to get the Mediatek based GPS module (Quectel L80-R) to run in periodic mode. I've sent the PMTK225 code to the module with various parameters, but it never seems to go into stand by or back up mode. Code below.
//Testing that commands sent to the GPS unit work

#include <NeoSWSerial.h>
NeoSWSerial gpsPort(3,2); // pins 3/2

#include <NMEAGPS.h>
NMEAGPS gps;

void setup() {

  // connect at 115200 so we can read the GPS fast enough and echo without   dropping chars
  // also spit it out
  Serial.begin(115200);

  gpsPort.begin( 9600 );
  gps.send_P( &gpsPort, F("PMTK605")); //firmware version
  delay(100);
  //gps.send_P( &gpsPort, F("PMTK314,-1")); //reset to default
  //gps.send_P( &gpsPort, F("PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0") ); // RMC_GGA
  //gps.send_P( &gpsPort, F("PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0") ); // RMC only
  delay( 100 );
  //gps.send_P( &gpsPort, F("PMTK220,200") );  // 5Hz
  //gps.send_P( &gpsPort, F("PMTK220,1000") ); //1hz
  delay( 100 );
  //gps.send_P( &gpsPort, F("PMTK225,0")); // normal mode
  //gps.send_P( &gpsPort, F("PMTK223,1,25,180000,60000")); // ephemeris data receiving
  gps.send_P( &gpsPort, F("PMTK225,2,3000,10000")); //period mode but not working
  //gps.send_P( &gpsPort, F("PMTK161")); //stand by mode
  //gps.send_P( &gpsPort, F("PMTK103")); //cold start
  delay(100);
  gps.send_P( &gpsPort, F("PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0") ); // RMC only

  //gps.send_P( &gpsPort, F("PGCMD,33,0") );   // No antenna status messages needed
  delay( 100 );

  Serial.println("Ready!");
}

void loop() {
  if (gpsPort.available())
    Serial.write( gpsPort.read() );
}

So what is the question?

Why will it not go into periodic standby with the code above?

Quectel L80-R does NOT have periodic mode, while the L80 does.


text:
Software Serial blocking Wifi Connection
I'm trying to connect my NodeMCU to wifi. It isn't finishing because software serial is interrupting it.
Sort of like Software serial conflict with WiFi on ESP8266.
Here's my code:
#include <SoftwareSerial.h>
#include "ESP8266WiFi.h"

const char* ssid     = "mywifi";
const char* password = "password123";

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

        connectWifi();

        SoftwareSerial pinSerial(1, 3);
        pinSerial.begin(9600);
}

void loop() {
    // send data received from serial port
}

// in separate function so I can reconnect in the loop
bool connectWifi() {
        WiFi.begin(ssid, password);
        while (WiFi.status() != WL_CONNECTED) {
                delay(500);
                Serial.print(".");
        }
        Serial.println("");
        Serial.println("WiFi connected");
        Serial.println(WiFi.localIP());
        if( WiFi.status() == WL_CONNECTED) {
                return true;
        } else {
                Serial.println("wifi connection failed");
        }
}

The console outputs the periods as it's connecting but never prints the IP and instead prints the serial data it received while trying to connect.
Can I delay the activation of the software serial port? Should I use another serial library?
Please don't focus on basic code errors, I'm still learning.

you start SoftwareSerial on pins of the hardware serial.

oh you're right! how do I read and write to the hardware pins, not the usb port?

the USB chip of NodeMcu is wired to pins io 1 and io 3 of the esp8266 and you write and read it over Serial

SoftwareSerial pinSerial(1, 3); in setup() is strange as it 1) uses the hardware serial pins, 2) is never used other than begin(), and 3) is destructed when returning. What are you trying to do exactly?


text:
Best way to ask Arduino for data from Python?
I'm trying to send numerical data from inertial sensors from my Arduino to a Python script via serial (PySerial).
I found that if I continuously send the data from the Arduino without stopping, the serial buffer fills up quickly and the sensor measurements that the Python reads becomes delayed.
To fix this, I thought of having the Python script send over a transmit command to the Arduino when it needs data. I'm sending a char 't' to signify this command, but the delay between Python sending the command and the Arduino sending the data is too large.
I'm wondering if there's a 'proper' way of doing this, as I'm sure it's probably been done before?

You should be able to get an instantaneous response to your commands. You must be doing something wrong in your code.

You're not trying to use readString on the Arduino to read one character from python are you?

ok, thinking about what you said ... it makes makes perfect sense to learn how to use a transmit command ... but it makes no sense to actually use it ... if the buffer overflows on Python side, then it will overflow on Arduino side if you pause comms .... does it really matter if some of the readings are lost? ... if lost data is not an issue, then frame data packets and simply ignore incomplete packets when they arrive on Python side

I'm reading strings on both sides Python and Arduino. I can't let the Arduino's output buffer overflow, because the buffer doesn't clear until I read from it on the Python side. I need the most recent sensor values (gyro, accel IMU), so if I let the buffer overflow and start reading from it, I'll get sensor data that is a few cycles old.

I'm wondering if it's possible that the baud rate I'm using is too high (19200-115200) for the IMU sensor? Maybe I'm reading data faster than the sensor can provide?

This is not a complete answer to your problem, but currently you seem to have some misconceptions, that prevent you from pin pointing the actual problem.
The data transmission from the sensor, over the Arduino to your python script on the PC has multiple places, where a bottleneck can appear. The total data rate will then be at maximum as large, as the smallest bottleneck allows it to be.
First you have a potential bottleneck in the communication between sensor and Arduino. You haven't stated, what kind of IMU chip you have and how it communicates. Typical IMU chips like the MPU series are interfaces via I2C or SPI. SPI can be sped up rather greatly, while I2C is not that easy to speed up. But it depends greatly on the capabilities of the used chip. You can find information about that in the corresponding datasheet of the chip.

The next interface is the Serial (UART) interface between Arduino and PC. This interface has a fixed baudrate. When you use Serial.write() or its siblings, you simply fill the send buffer of the Serial library. The data will then be send out automatically at the correct timing for your baudrate. The transmission always happens, if the python script is reading or not. The transmission also happens, when the serial buffer of the script is full. The Arduino does not know about the buffer being full. So in this case the data is not delayed, but lost.

The last - and probably most important - potential bottleneck is how you read and send the data on Arduino and in the python script. Here I'm covering the Arduino side.
You should not use functions like Serial.readString(), as they work with a timeout, which will slow down your code drastically. Instead you should read the Serial data byte by byte into a buffer, delimiting your message with a special character (for example the newline character \n). You check, if there is any data Serial.available(), and if yes, you read one byte into a char array, which is your own buffer. You are doing that repeatedly, until you read the delimiting character. Then you process the complete message. That way will give you some important improvements:

You can do things in the meantime (for example reading new data from your sensor)
It works without any arbitrary timeout, thus not slowing down your code unnecessaryly
The delimiting character frames a full message, so that you can distinguish two different messages from each other and thus easier process them

Considering the above, you should make the requirements clearer:

How much latency between the actual sensor measurements and the receiving in the python script is ok for you, meaning: How old can the measurements be, that the python script gets? (You just stated, that it is too large, but you have not mentioned how large)

Do you need continuous data transmission, or just one or a few sets of the IMU data?

Then you can check for the needed speed and data rate. Check, if all involved interfaces and codes can really handle your requirements.
Also it would be easier for us to help you, when you show your current code in your question.

Note that for single character commands you do not need message framing and buffering.


text:
Serial broken into two shorter shorter strings
I'm trying to do a serial read:
    if (Serial.available() > 0) {
  int inputValue = Serial.read();
  Serial.println();
  Serial.println("I got this:");
  Serial.print(inputValue, BIN);
}

However, it seems that what I receive is always 6 bits first and then followed by 4 bits. I'm really confused. I used a different board just to be sure that it's not just a problem with the board. Could it be the serial monitor I'm using? I'm using the Arduino serial. This is an example of the output:
21:31:02.021 ->
21:31:02.021 -> I got this:
21:31:02.021 -> 110101
21:31:02.021 -> I got this:
21:31:02.021 -> 1010

Can anyone shine a light as to what is happening here?

you are confusing what you receive with what you print

I guess you are sending 5 and have the line ending set to newline only. Then everything is correct and as expected. You see 2 bytes, that are transmitted. Serial.print() will cut out the leading zeros of the byte, so all other digits before that are just zero.
The first byte is the character 5 encoded in ASCII (53 is the decimal representation of the ASCII value here). The second byte is the newline character \n, which marks the end of a line or the end of the data message (depending on the interpretation of the data). If you don't want to send the newline character, select Nothing for the line ending (My Arduino IDE is in German, so I don't know, what exactly is the term in the english version here, but you need to set it for not using any line ending).
As it seems, that you don't know that currently: When you write a number into the serial monitor, you are not sending the direct binary value of that number. You are sending the ASCII representation of the individual digits. ASCII is a system, where the values of a byte represent a character. That includes decimal digits, the alphabet and some special characters. So when you type "255", you are not sending 0b11111111 (1 byte with all bits set --> decimal 255), you are sending 3 bytes with the ASCII byte value for the characters 2, 5 and 5. You can read the byte values for all the characters in tables, just by googling for "ASCII" and looking at the images found.


text:
Digital Pin won't ground when set to LOW
My friend and I are repurposing an old rc car for a project. When we connect the dc motors to 5V and ground, the motors spin. However, when we power the motors from 5v and ground it in the digital output pin set to LOW, nothing happens. The identical circuit works in tinkercad. We are using a nano, but have tried an uno and mega as well.

you possibly destroyed the arduino output pin

An output pin can't handle that sort of current.  I would suggest you do some reading on Ardunio and motors.  If you google as much you'll be hit right off the bat with the idea of a motor driver since the pins can't drive motors by themselves.  You've probably damaged your Arduino now.

The pin still works with leds and a small dc motor

there is a lot of info about driving motors on this site

You shouldn't try to source or sink more than 20 mA from an Arduino pin. The absolute max is 40 mA, but 20 is the recommended limit. Also you should never hook an inductive load directly to an Arduino pin. When you disconnect an inductor from power, there is a large reverse rush of current as the magnetic field collapses. This is known as back-EMF, and even if you don't exceed the current limits of a pin, the back-EMF may fry the pin, or the entire board.

Never directly connect a motor to an Arduino IO pin
You will destroy the Arduino.
An Arduino cannot source (or sink in your case) enough current to drive a motor, and if the motor did manage to turn the huge amounts of EMI it generates would literally blast holes in the silicon inside the chip.
You must use a motor driver of some form. If you only want one direction that driver can be a single NPN Bipolar transistor or N-channel MOSFET.  If you need it to change direction then an H-bridge is what you want.

Thanks. We ended up using a relay in the meantime

To the OP: If you do end up powering your motors with transistors, make sure to add a "flyback diode" to protect the transistor from back EMF. (This is a suitably rated diode wired backwards across the motor terminals. They're needed for any inductive load, not just motors.)

Use that diode for the relay, too. As it is an inductive load, it will generate flyback spikes when switched off.

Good point on the relay. I assumed the OP was using a "digital relay module" which has a transistor, diode, and usually an optic-isolator built into it.


text:
I want to program multiple arduino at once
I am aware that using a USB Hub you can attach multiple arduino to one computer and either upload code one by one or use bash script to upload code on all arduinos together. But you can attach only as many arduino to a computer. I need to prgram around 100 arduinos/atmega ICs at once. Is there a way to do so?
There are other methods that I found online like programming ICs over Wifi network. But that require a lot of WiFi chips connected to arduino. I cant setup that. Also that doesn't seems cost effective.
Also Arduino sells their uno and other boards with pre-installed blink program. They must be doing batch programming only (multiple ICs at once). Any idea how they do this?

What is the use case? Production line? I've made shield for the raspberry pi zero so with button, few status leds and two ISP lines to upload communucation 16u2 and 2560 firmware+bootloader in about minute. It's not so much time to do it in parallel. Btw you can chain USB hubs - one 16port -> 16x 16port (=256 if there is no limit on usb itself) and it'll be slow..

To program over USB you need 1 connection per Arduino. The Serial connection cannot just be shared I think. Small deviations in the timing could disturb the whole communication. For programming over ISP you need a programmer for each Arduino. I would think that the production uses individual ISP programmers to program a small batch of Arduinos at once, then moving on to the next batch. When already building a product line automation, why would they need to program 100 of them at once, when the automation could also easily move the programmers between the batches

Why do you need to program 100 Arduinos at once? Can you give a little context here?

@chrisl I actually made a prototype with multiplexing Chip select pin on arduino, which is connected to RESET pin of target board to program. When I am connecting one target board at once I am able to program it but when I am connecting multiple target boards then not even one is programming. I am using Nick gammon's code for programming the target arduino using the master arduino https://github.com/nickgammon/arduino_sketches/tree/master/Atmega_Hex_Uploader_Fixed_Filename
This is rough block diagram of multiplexing chip select pin - https://imgur.com/a/XX4Nyf8

Arduino, the company, may sell on enough volume to make it worthwhile to get the microcontroller manufacturer to program the microcontrollers durin the production process
This wouldn't cost them extra if they already get the bootloader pre-programmed. I've read programming ICs is a service available to high volume customers.
I guess low volume makers use fixtures that use the ICSP headers, pogo sticks or IC clips and which trigger the programming on contact using a microswitch etc.
I suspect Adafruit do something of this sort, see GIFs and video discussing testing at
https://www.adafruit.com/product/2458

I actually made a prototype with multiplexing Chip select pin on arduino, which is connected to RESET pin of target board to program. When I am connecting one target board at once I am able to program it but when I am connecting multiple target boards then not even one is programming. I am using Nick gammon's code for programming the target arduino using the master arduino https://github.com/nickgammon/arduino_sketches/tree/master/Atmega_Hex_Uploader_Fixed_Filename
This is rough block diagram of multiplexing chip select pin - https://imgur.com/a/XX4Nyf8

I recommend using optiloader, which uses a standalone arduino to program an arduino connected to it.  You can therefore create as many arduino programmers as you want, each of which can run without connecting to a host computer.  This is how firmware is loaded for high volume production.

Any idea how they do this?

You can buy gadgets that let you upload code in a second or so. For example, here. You plug in the target board, press a button, and it's done.
These program a board in a couple of seconds. While this is hardly literally "at once" it would take time anyway to connect 100 Arduinos to "something" so connecting and disconnecting every couple of seconds is roughly the same thing.
That board mentioned above uses code I wrote which can run on an ordinary Arduino. In other words, use one to program another, where the code to be uploaded is stored on a micro-SD card.


text:
Arduino/Genuino 101 - EOL / Junk the board(s)?
https://hackaday.com/2017/07/25/the-end-of-arduino-101-intel-leaves-maker-market/
https://downloadcenter.intel.com/download/25832/Arduino-101-Firmware-Package-1-0
https://community.intel.com/t5/Intel-Makers/Intel-Curie-End-of-Life-Scheduled/td-p/397068?profile.language=en
Intel EOL'd the Arduino/Genuino 101 board.  The end is so complete that you cannot download the drivers using the Board Manager.
To make matters worse, my old Ubuntu machine, with an old Arduino IDE, is unable to upload to my existing 101 boards (PRESS MASTER RESET error).

Should I junk these boards?
Is there a 3rd party site that is hosting the drivers?

Arduino's brief partnership with Intel was an abortion that should never have happened. Junk the boards and use something sensible.

Ugh... hate throwing electronics in the trash almost as much as I hate wasting my time on a dead end.

You could always put it on eBay for some other sucker to be disappointed with...

Maybe one day it'll be a collectors' item and be worth millions ;)

This raises the obvious question:  How does one determine which Arduino flavor will be supported in the future?  I don't need things to last forever, but this is one of the few pieces of electronics I need to throw into the junk heap.

You can pretty much guarantee that the AVR based ones will last for the foreseeable future. ARM ones will probably change rapidly. Anything form third parties, like Intel, or any of the million-and-one ARM boards there are now, well, it's anyone's guess. The manufacturer will always support the chip for as long as they are making it. Whether you have the tools to work with that chip without the Arduino framework though is down to your abilities. You can probably still use the 101 just not with Ardiuno, and using a proper programmer (JTAG?)

I've heard of JTAG, but never used it.  I thought JTAG was a hardware (almost cable) standard.  What is the IDE?

I'm getting the picture from:  https://learn.sparkfun.com/tutorials/arm-programming/all and https://www.instructables.com/id/JTAG-ICE-With-Arduino-IDE/ .  However, doesn't Atmel Studio need to know something about the Intel 101 to compile for it?


text:
Arduino HTTP Command - ESPEasy
I am new to Arduino and although I am starting with and creating some basic projects my end goal right now is to be able to turn my Sonoff on and off via a momentary switch attached to my Wifi enabled Arduino board (Particle Photon). I'm not looking for the code I would just like to pointed in the right direction.
I flashed my Sonoff so that it now runs ESPEasy and set it up so that I can control it from my browser using http://10.0.1.35/control?cmd=event,TurnOn to turn it on and http://10.0.1.35/control?cmd=event,TurnOff to turn it off. I have been reading about using POST or GET requests but none of the examples I find seem to send a similar command to how I currently have my Sonoff set up.
My question is what should I be looking at and reading about to be able to send these types of commands via the Arduino?
Any recommendations are greatly appreciated. I'm thoroughly enjoying getting into coding but finding this step quite challenging to say the least!
Thanks!

Particle Photon is not Arduino. with Arduino you would use a WiFi library for your WiFi adapter. the Arduino WiFi libraries have examples

My apologies, I suppose it isn't, but I'm working on the basis that the solution will be the same between Arduino and the Photon board I'm using.

https://www.arduino.cc/en/Tutorial/WiFiWebClient

Have you tried to perform a HTTP Get request with exactly the URLs, that you already used in your browser? The browser also simply does a Get request

Thanks for the heads up that the GET request was indeed the right way to go. I managed to work through this a bit today got the GET request to work. I also hooked up the button and got that to send the two requests on both press and release. I know this code is for the Photon but I hope it'll help someone else out
// TCPClient
#define LIB_DOMAIN "10.0.1.252"
TCPClient client;

// This constant won't change:
const int  buttonPin = D1;    // the pin that the pushbutton is attached to
const int ledPin = D7;       // internal LED pin

// Variables will change:
int buttonState = 0;         // current state of the button
int lastButtonState = 0;     // previous state of the button

void setup() {
  pinMode(ledPin, OUTPUT); // Initialize D7 pin as output
  pinMode(buttonPin, INPUT_PULLUP);
  // Initialize D1 pin as input with an internal pull-up resistor
  // initialize serial communication:
  Serial.begin(9600);
}

void loop() {
  // read the pushbutton input pin:
  buttonState = digitalRead(buttonPin);

  // compare the buttonState to its previous state
  if (buttonState != lastButtonState) {
    // if the state has changed, turn on or off
    if (buttonState == HIGH) {
        digitalWrite(ledPin, LOW);
        //TCPClient
        client.connect(LIB_DOMAIN, 80);
        client.println("GET /control?cmd=event,TurnOff HTTP/1.0");
        client.println("Host:" LIB_DOMAIN);
        client.println("Content-Length: 0");
        client.println();
    } else {
        digitalWrite(ledPin, HIGH);
        //TCPClient
        client.connect(LIB_DOMAIN, 80);
        client.println("GET /control?cmd=event,TurnOn HTTP/1.0");
        client.println("Host:" LIB_DOMAIN);
        client.println("Content-Length: 0");
        client.println();
    }
    // Delay a little bit to avoid bouncing
    delay(50);
  }
  // save the current state as the last state, for next time through the loop
  lastButtonState = buttonState;

}


text:
A problem in l led or arduino nano
When I am working on arduino nano and i uploaded a file that will blink led at 13th pin but rather than at 13th pin l-led is blinking. I even tried resetting it and uploading an empty file and again uploading the 13th pin blinking code but still l-led is blinking. What is the problem?

13th pin is pin12 ... the numbering starts at zero ... the LED is on the 14th pin

The L LED and pin 13 are one and the same thing. That LED is connected directly to pin 13. If you blink pin 13 then that LED will blink.

but the problem is the led that i connected to 13th pin is also not glowing

Did you connect it the right way around? Did you include the required resistor?

yeah i did that and now even the blank code is not uploading


text:
What are the applicable processor for the ATmega32u4? And what are higher versions of ATmega32u4?
Can arduino uno smd r3 version handle a Keyboard.h library?  it is not applicable for that arduino?

It is unclear, what you are asking.  The Arduino Uno cannot use the Keyboard library (unless you are hacking the USB to Serial chip). The Atmega32u4 has a native USB interface, thus it can use the Keyboard library, but the Uno only uses this chip as Serial to USB chip. The main chip is the Atmega328p, which doesn't have native USB

The ATMega32U4 is the ATMega32U4. There are no "higher versions" of it. What are you really asking?

Okay sir. But can arduino mega2560 use the keyboard library?

I am just clarifying if arduino uno can use keyboard library but now I know that it is not so, what type of arduino can you recommend on me sir for me to use the keyboard library?

The Arduino Uno cannot use the Keyboard library. The microcontroller needs to have a native USB interface. The Uno uses the Atmega328p, which does not have one.
You can use the Arduino Micro or Arduino Leonardo for this.

For more experienced hackers: If you need to use the Uno, but still want to use extended USB capabilities (more than USB to Serial), it is possible to reprogram the Atmega32U4 on the Uno, which is only used as USB to Serial adapter chip, but of course has native USB capabilities and could create a HID/Keyboard input on the USB interface. Since that is not a task for beginners, it is not applicable for this question, but should be mentioned for future readers.


text:
sim800l gsm module reboot command
i have a project to control a relay by sms and call by arduino and sim800L gsm modem
and i need to modify the code below to by adding command to reboot or reset the modem ever hour
i mean delete all sms and call history and reboot the modem because the modem is always on for long time and the modem after few days of operation becomes not responsive
any one can help me and solve the problem

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10,11);  // (Rx,Tx  > Tx,Rx)

char incomingByte;
String inputString;
int relay = 4; // Output for Relay Control
int LEDG = 8;
int buzzer = 5;
int LED = 6;
int buttonPin = 2;
int buttonState = 0;
void setup()
{
      pinMode(relay, OUTPUT);
      pinMode(buzzer, OUTPUT);
      pinMode(LED , OUTPUT);
        pinMode(LEDG , OUTPUT);
      pinMode(buttonPin, INPUT);
      digitalWrite(relay, LOW); // Initial state of the relay
       digitalWrite(buzzer, LOW);
        digitalWrite(LED, LOW);
        digitalWrite(LEDG, LOW);

      Serial.begin(9600);
      mySerial.begin(9600);

     while(!mySerial.available()){
        mySerial.println("AT");
        delay(1000);
        Serial.println("Connecting...");
        }
      Serial.println("Connected!");
      delay(30000);

      mySerial.println("AT+CMGF=1");  //Set SMS to Text Mode

      delay(1000);

      mySerial.println("AT+CNMI=1,2,0,0,0");  //Procedure to handle newly arrived messages(command name in text: new message indications to TE)
      delay(1000);
      mySerial.println("AT+CMGL=\"REC UNREAD\""); // Read Unread Messages
      delay(1000);
       mySerial.println("AT+CLIP=1");
        delay(1000);
      digitalWrite( LEDG , HIGH);
     }

void loop()
{

 m:
  if(mySerial.available()> 0){
      delay(100);

    inputString = mySerial.readString();
    Serial.println(inputString);

     if(inputString.indexOf("0000000") > 0)
      {
             mySerial.println("ATH");
             delay(250);
            digitalWrite(relay, HIGH);
            delay(250);
            digitalWrite( buzzer , HIGH);
            delay(250);
            digitalWrite( LED , HIGH);
            delay(300);
            digitalWrite( relay , LOW);

            while(1){
               inputString = mySerial.readString();
                    Serial.println(inputString);
                  if (inputString.indexOf("00000000")>0 && inputString.indexOf("OFF") > -1){

                     digitalWrite( buzzer , LOW);
                     digitalWrite( LED , LOW);
                     goto m;
                  }
            buttonState = digitalRead(buttonPin);
           if (buttonState == HIGH) {
                    digitalWrite( buzzer , LOW);
                     digitalWrite( LED , LOW);
                   goto m ;
                   }
                   }

          }

    if(inputString.indexOf("000000") >0 && inputString.indexOf("1") > -1 )
      {

            digitalWrite(relay, HIGH);
            delay(250);
            digitalWrite( buzzer , HIGH);
            delay(250);
            digitalWrite( LED , HIGH);
            delay(300);
            digitalWrite( relay , LOW);
               while(1){
                   inputString = mySerial.readString();
                    Serial.println(inputString);
                  if (inputString.indexOf("00000000")>0 && inputString.indexOf("OFF") > -1){

                     digitalWrite( buzzer , LOW);
                     digitalWrite( LED , LOW);
                     goto m;
                  }

           buttonState = digitalRead(buttonPin);
           if (buttonState == HIGH) {
                    digitalWrite( buzzer , LOW);
                      digitalWrite( LED , LOW);

                       goto m;
                   }

                   }

          }

  }
}


text:
How does erasing the EEPROM work?
The datasheet for the ATmega328P contains this table, which describes bits 4 and 5 of EECR:

EEPM1
EEPM0
Programming Time
Operation

0
0
3.4ms
Erase and write in one operation (atomic operation)

0
1
1.8ms
Erase only

1
0
1.8ms
Write only

I'm currently working on some non-blocking EEPROM-handling code and I'm wondering when and how I should erase the EEPROM.

What does erasing do? Does it set one byte to 0x0, or the entire EEPROM?
Should I erase it first whenever I want to write a byte?

If not, why is there an option to erase and write separately?

How do I initiate an erase?

Either the datasheet is rather lacking concerning the EEPROM, or I'm just not finding what I'm looking for. I tried using a search engine, but all results are either about the Arduino EEPROM library or <avr/eeprom.h>, both of which use polling instead of interrupts (and are therefore blocking).

"the datasheet is rather lacking concerning" Hmm, maybe link to the datasheet you're using, because I remember that these things are answered in it, unless you maybe you've wound up with a "summary" and not "complete" datasheet. There are also appnotes about using AVR EEPROM.

I tried using a search engine, but all results are either about the Arduino EEPROM ... don't be searching for arduino eeprom ... don't search for either of those

Your questions are answered in the AVR ATMega328 datasheet.
The procedure for erasing and writing the internal EEPROM is outlined in chapter 7.6 (Register Description).

The Erase operation erases 1 byte (erasing an EEPROM cell sets it to all 1s, i.e. 0xff).
The EEPROM address to be erased/programmed is pointed to by the EEARL and EEARH registers. The value to be programmed into that address is set by the EEDR. Reading a value from EEPROM returns the value in the same EEDR register.
Before writing a new value to the EEPROM, the old value must first be erased. You can do that as two separate actions or one single action. You could also leave the cell deprogrammed (erased) by only erasing it and not programming it again.
You initiate an erase of the EEPROM address pointed to by EEARH/EEARL, by setting EEPM1 to 1, EEPM0 to 0 and setting EEPE to 1 to start the erase operation. Setting EEPM1 and EEPM0 both to 0 will erase and program a new byte in a single operation.

As for making EEPROM writes non-blocking, you could set a (non-blocking) timer for the duration of the write, erase or erase/write operation. According to the datasheet these operations respectively take 1.8, 1.8 and 3.4 ms. Just make sure your code does not access the EEPROM while these operations are taking place.
You could also (non-blocking) periodically poll the EEPE bit until it is cleared, signalling the operation is finished.
The most elegant way, i.m.o. is to make use of the EERIE flag by setting it to 1, which will enable the ATmega to generate an interrupt when the EEPROM operation is finished.

If the new value sets bits to 0 that are 1 in the old value, no erase is necessary. For example, you can write 0x55 into a cell that contains 0xD7 without the need to erase the cell before.

@thebusybee, true, you can generally change an unprogrammed ("1") EEPROM bit to a programmed ("0") bit without erasing the cell. Changing bits from 0 to 1 again does require erasing the cell. This is not unique to the ATmega328 but works for many/most EEPROMs.

I switched to FRAM, 32K x 8 can be gotten for just a few $$$, generally less the imported Arduinos. It is as fast as the Arduino can access it, both read and write. You can use I2C or SPI depending on which unit you buy. There are some very nice libraries for it making it easy to use. It is non volatile, ie does not lost information when power fails. It will support in the range of a trillion memory cycles with no delay when writing or reading it so no blocking. Just a few extra processor cycles because of the SPI or I2C overhead. If you have code already written for the External EEPROM it should work as is but it will have an unneeded delay in it.

Interesting though your answer is, it is a bit like answering someone who is having problems with their Ford, telling them that a Cadillac works better.


text:
Wifi Scanning code for esp32 wroom 32
I am trying to scan wifi in sta_ap mode in my esp32 wroom 32 module but it is not scanning new wifi .Can anybody tell more about how does wifi mode works in this module and what's the problem in my code.Same code is working in esp8266.
CODE:
#include <WiFi.h>

const char *ap_ssid = "ESP32";
const char *ap_password = "";

const char *sta_ssid = "KKACT";
const char *sta_password = "kk25990418";
void setup() {
  Serial.begin(115200);

  WiFi.mode(WIFI_AP_STA);
  WiFi.disconnect();
  delay(100);
  Serial.print("Configuring access point...");
  WiFi.softAP(ap_ssid, ap_password);

  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);

  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(sta_ssid);
  WiFi.begin(sta_ssid, sta_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 loop() {
   Serial.println("Now scanning wifi continously");
   int n=WiFi.scanNetworks();
   for (int i = 0; i < n; ++i)
  {
      Serial.print(i + 1);
      Serial.print(": ");
      Serial.print(WiFi.SSID(i));
      Serial.print(" (");
      Serial.print(WiFi.RSSI(i));
      Serial.print(")");

  }
    delay(2000);
}

And if you disconnect before scanning?

I tried disconnecting at the end of void main loop ,but the results were same i was getting the wifi list but new wifi are not being detected or maybe not getting scanned

This is a issue raised on github about this:
https://github.com/espressif/arduino-esp32/issues/3294
And the issue seems to be that a failed connect prevent the scanning and the solution is:

So what i did was when entering the portal:
WiFi.mode(WIFI_OFF); // otherwise Wifi.Scannetworks() fails
delay(5000);
This seems to stop the processes that prevent the scanning.
After that an immediate scan works without problems.

so where should i add this line ,at the end of void setup like this?
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
WiFi.mode(WIFI_OFF);
delay(5000);```

You are not doing it correctly. In order to perform WiFi scan:

It must be in WIFI_STA mode;
It has to be disconnect from the AP;
After you done with the scanned SSID, BSSID and RSSI, you need to called WiFi.scanDelete() if you are going to do a scan again, otherwise you will get the same previous scanned result.

So in summary, here is the code:
#include <WiFi.h>

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

void loop() {
  Serial.println("Scanning WiFi Networks...");
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  int n = WiFi.scanNetworks();
  for (int i=0; i<n; i++) {
    Serial.printf("%2d SSID=%-20s RSSI=%d\n", i+1, WiFi.SSID(i).c_str(), WiFi.RSSI(i));
  }
  WiFi.scanDelete();

  delay(10000);
}

i tried  WiFi.scanDelete(); but it didnt work ,I know i can use wifi_sta mode but esp32 has wifi_sta_ap which has both the station and access point mode ,so it should work in this mode too.                                                                                I tried the same code in esp8266 and it worked,something in void setup is breaking the wifi scan.

Are you using your code by just adding WiFi.scanDelete() or you are using my example?

i am using your code only but with Wifi.mode(WIFI_AP_STA );


text:
DC motor phototransistor control
So basically I have a circuit with a phototransistor, and want to convert the phototransistor value into a PWM signal that can control the speed of the motor. The code I came up with is below, however it does not work. What have I done wrong in my code? I am using an l293d chip.
int photoTran = A1;
int reading = 0;
int forward=2;
int backward=3;
int motorspeed=0;

void setup(){
  pinMode(photoTran,INPUT);
  Serial.begin(9600);
  pinMode (backward, OUTPUT);
  pinMode (forward, OUTPUT);
}

void loop(){
  lcd.setCursor(0,0);
  reading = analogRead(photoTran);
  lcd.print(reading);
  lcd.print("  ");
  delay(100);
{
  if (reading<30){
    digitalWrite(backward,HIGH);
    digitalWrite(forward,LOW);
    motorspeed = map(reading, 30, 1023, 0, 255);
    analogWrite(backward,motorspeed);
  }
  else {
    digitalWrite(backward,LOW);
    digitalWrite(forward,HIGH);
    motorspeed = map(reading, 30, 400, 0, 255);
    analogWrite(forward,motorspeed);
  }
  }
}

You need to be a little more specific than that. Do you know that the phototransistor works on its own, and same with the motor driver? Also, what is not working? Is it not compiling, not showing a proper value on the lcd, not affecting the motor, etc? In your code I see "{" after your delay(100) which I don't see that purpose of that and why the if/else statements are inside it. I would get rid of that and test.

A phototransistor is hard to calibrate, and should rather be used as a switch (digitalRead)

If you are using l293d you must control the voltage on its ENABLE PIN rather than controlling it on other INPUT PINS (l293d). Here is simple tutorial on controlling the Motor using L293d. here.
And @VE7JRO is right about map() function as your are passing the values that are out of range please take care of that part as well.

analogRead() returns an integer between 0 and 1023. Using 30 and 400 in the map() function, then passing in a value outside of that range will cause strange results. Here is a sketch to illustrate my point.
void setup(){

  Serial.begin(9600);

  // Prints -20 to 684
  for(int i = 0; i < 1024; i++){
    Serial.println(map(i, 30, 400, 0, 255));
  }
  Serial.println();

  // Prints -7 to 255
  for(int i = 0; i < 1024; i++){
    Serial.println(map(i, 30, 1023, 0, 255));
  }
  Serial.println();

  // Prints 0 to 255
  for(int i = 0; i < 1024; i++){
    Serial.println(map(i, 0, 1023, 0, 255));
  }
}

void loop(){}


text:
Update time in RTC over I2c fails
I am communicating two arduinos using the I2C protocol and sending from the slave to the master the integer value of UTC to update the time in the RTC module. When the master receives the UTC value from I2C and tries to set the time by the RTC.set () command the Arduino hangs and needs to be restarted, however, if I use RTC.set () in the loop () method it works perfectly. I do not understand why the system for when it is updated by I2c, is there any conflict?
This is the code with the loop() and Wire.onReceive():
#include <Thread.h>
#include <ThreadController.h>
#include <SoftwareSerial.h>
#include <LinkedList.h>
#include <SPI.h>
#include <TimeLib.h>
#include <DS3232RTC.h>
#include <Wire.h>

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

  Wire.begin(1);
  Wire.onReceive(receiveEvent);

  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  setSyncProvider(RTC.get);
  if (timeStatus() != timeSet)
     Serial.println("Unable to sync with the RTC");
  else
     Serial.println("RTC has set the system time");

}

void loop() {

  digitalClockDisplay();
  delay(2000);

  // test only
  /*time_t t = processUTCFromI2c("1560810413");

  if (t != 0) {
    RTC.set(t);   // it's works
    setTime(t);
  }*/

}

// ================================ INIT ONRECEIVE ===========================================

void receiveEvent(int howMany) {
  char* vectorAction;
  char c;
  Serial.println(howMany);

  LinkedList<char> myLinkedList = LinkedList<char>();

  //while (1 < Wire.available()) { // loop through all but the last
  for (int i = 0; i < howMany; i++){
    c = Wire.read(); // receive byte as a character
    myLinkedList.add(c);
  }

  vectorAction = new char[myLinkedList.size()+1];

  for(int i=0; i < myLinkedList.size(); i++) {
    vectorAction[i] = myLinkedList.get(i);
  }

  vectorAction[myLinkedList.size()] = '\0';

  getParamsAndValues(vectorAction);

}

void getParamsAndValues(char* i2cValueString) {

  char* getValue;
  char* getParam;
  char* endValue;

  getValue = strchr (i2cValueString, '=');
  getParam = strchr (i2cValueString, '@');
  endValue = strchr (i2cValueString, '#');

  const size_t maxBuffLength = 15;

  char valueBuffer[maxBuffLength+1]; // allocate local buffer with space for trailing null char
  char paramBuffer[maxBuffLength+1];

  valueBuffer[0] = '\0';

  while(getValue && getParam && endValue && (getValue > getParam) && (endValue > getValue)) {
    Serial.println(i2cValueString);

    if (getValue && getParam && (getValue > getParam)) {
      size_t paramLength = getValue-getParam-1;
      valueBuffer[0] = '\0';

      if (paramLength <= maxBuffLength) {
        strncpy(paramBuffer, getParam+1, paramLength);// http://www.cplusplus.com/reference/cstring/strncpy/
        paramBuffer[paramLength] = '\0'; // properly terminate the c-string
      }
    } else {
      // handle Wrong Input
    }

    if (getValue && endValue && (endValue > getValue)) {
      size_t valueLength = endValue-getValue-1;
      valueBuffer[0] = '\0';

      if (valueLength <= maxBuffLength) {
        strncpy(valueBuffer, getValue+1, valueLength);// http://www.cplusplus.com/reference/cstring/strncpy/
        valueBuffer[valueLength] = '\0'; // properly terminate the c-string
      } else {
        // handle buffer too small
      }
    } else {
      // handle Wrong Input
    }

    getValue = strchr (getValue+1, '=');
    getParam = strchr (getParam+1, '@');
    endValue = strchr (endValue+1, '#');

    i2cActionReceived(paramBuffer, valueBuffer);
  }

}

void i2cActionReceived(char* param, char* value) {
  if(strcmp(param, "setTime") == 0) {
    time_t t = processUTCFromI2c(value);

    if (t != 0) {
      RTC.set(t);   // It's not works
      setTime(t);
    }
  }
}

// ================================ END ONRECEIVE ===========================================

// ================================ CONVERT UTC char* TO long ===============================
unsigned long processUTCFromI2c(char* utc) {
  unsigned long auxTime = 0L;

  if (strlen(utc)>0) {
    auxTime = atol(utc);
  }

  return auxTime;
}

The slave sends a string through I2C in the format @setTime=1560810413#.
In the loop() this commented the code that works onorata and on i2cActionReceived (char* param, char* value) is where the update fails by onReceive.

you are not using consistent data in your debugging effort ... in the first instance you use "1560810413"  ... in the second instance you use a parameter in a function

The symptom you are describing is: The RTC.set() method blocks in the onReceive callback of the Wire library, but not when used in the loop() function.
That sounds like an interrupt issue. The onReceive callback function is called from an ISR (Interrupt Service Routine) of the I2C hardware. It is no good to use any code, which utilizes interrupts, inside an ISR, until you know, what you are doing.
In this case the RTC.set() function (which you can find here at line 152) will call the method RTC.write(), which will do multiple I2C transactions (both sending and receiving as master). Doing these inside an ISR may already block the code from executing further.
But there is another problem. You have 2 Arduinos connected by I2C. The master Arduino talks only to the slave Arduino, while the slave Arduino is also a master for the RTC (You initialize this Arduino as slave, but it will become a master for the time, when you try to do master transmissions). Your slave code and the RTC library both use the Wire library, meaning the hardware I2C port of the Uno. So you have 2 masters on the same I2C port.
While the I2C standard supports multi-master setups via bus arbitration, the Wire library does not. In the case, when both masters start to transmit at the same time, it will block the bus (due to some blocking loops inside the Wire library, that cannot handle bus arbitration). So the setup, that you use is either not going to work at all or being very risky, depending on the amount of send data (When the bus is filled with more data, it get's more probable, that a collision between the masters happens).
With I2C on Arduino you should stick to single-master setups. For example you can set the first Arduino as slave, keeping the second Arduino as single master on the bus, which handles both getting UTC from the first Arduino and communicating with the RTC. On the first Arduino you would set up an onRequest callback, that fills the I2C buffer with the current UTC time, which then get's transmitted to the master Arduino, so that it can update the RTC's time with it.

EDIT:
I2C has a fundamental master-slave principle. The master generates the clock signal and initiates/stops any transactions on the bus. A slave cannot send anything over the bus, when the master didn't request data from it, including "calling" the master. Any communication start's with the master.
The Wire library gives you the possibility to initialize the Arduino as slave and then do master transactions. For this the I2C hardware is configured as master for the time of the transactions. So you can initialize both Arduinos as slaves with an address and let them change to master mode for any master transaction, that you need. That is the way, that you are talking about in your comment and what you use in the code in your question.
BUT you get a big problem, when both Arduinos try to send at the same time. That is called data collision. The I2C specification has the bus arbitration for this (basically the master that first sends a 1 has to back down from the transaction), so that collisions can gracefully be resolved. The Wire library doesn't implement this, so it will block in case of a collision. Then you have to reset the Arduino to get it going again.
You should again analyse your requirements and check, if you really need I2C for communication between the Arduinos, or if you really need individual bidirectional communication. That is often also a design choice.
If you really need individual 2 way communication between the Arduinos, I see 2 possibilities:

You can do it the hacky way and add an extra line between both Arduinos. You would set the Arduino with the RTC as I2C master and the other Arduino as slave. The slave Arduino can pull the extra line with a digital output pin to LOW, so that the master Arduino can sense this as signal at one of it's digital input pins (configured with internal pullup resistor). When the master Arduino senses, that the extra line goes to LOW, it can request data from the slave. So you are using the extra line for signaling the master, that new data is available at the slave.
If you are not bound to I2C, other communication interfaces might be better suited. UART (in the Arduino framework called Serial) implements bidirectional bytewise communication. No master/slave relationship. That would be a lot easier.

Thanks for the explanation and the hint of how to solve the problem! Because of the project specification I will not be able to set one of the Arduinos as master, the two need to be slave and communicate between them. To solve I set the variable time_t as global and another variable boolean also as global and when it arrives a value by I2C I assign the value to time_t and true to the other variable and do the update inside the loop().

I don't quite understand the project specification. In I2C communication there is always 1 master during a transmission. In a multi-master setup this role will just change between the devices. And the Wire library does not support multi-master. Why do you need multi-master? What exactly states the project specification about this?

I do not know much about the Wire library, but as far as I understand it, it is not possible for the slave to call the master because it does not have an address, so my "master" is at address 1 (Wire.begin (1);) and the slave in address 2 (Wire.begin (2);) and in this way one can call the other. Is there a way for the slave to call the master since it does not have an address?

@user2831852 I added more explanations at the end of my answer.

As explained by chrisl, the fact that the Arduinos communicate with I2c and the update of the RTC is by I2C, the update fails and locks the system. To resolve this I declare the global variables boolean updateRTC = false; and time_t setUTC; and in the method that processes UTC I assign the value true to updateRTC and the numeric value of UTC tosetUTC and do the verification in void loop().
// global vars
boolean updateRTC = false;
time_t setUTC;

// RTC update inside loop()
void loop() {
  digitalClockDisplay();
  delay(1000);

  if (setUTC > 0 && updateRTC == true) {
    updateRTC = false;
    RTC.set(setUTC);
    setTime(setUTC);
    setUTC = 0;
  }

}

// Method executed at the end of the onReceive() event
void i2cActionReceived(char* param, char* value) {
  if(strcmp(param, "setTime") == 0) {
    setUTC = processUTCFromI2c(value);

    updateRTC = true;
  }
}


text:
Atmega328p and cp2102 with error avrdude: stk500_getsync(): not in sync: resp=0x00
I recently bought a usb/ttl cp2102 converter for testing with a standalone Atmega328p, I made the DTR connection with the pin 1 in the Atmega  using a ceramic capacitor of 0.10uf (104) so that when I send my code to my Atmega standalone it save the code without having to worry about the reset. However, when trying to send it the first time it worked and the other attempts failed, it seems that whenever I restart the computer and turn it on again it sends the code to the Atmega and in the other attempts it fails.
To try to solve I tested with IDE Arduino 1.8.5 and 1.8.9 in Linux Mint and Windows 10 and gave the same problem, I recorded the bootloader again and did not solve.
The error that appears in the output of the IDE is this:
avrdude: stk500_getsync(): not in sync: resp=0x00

From what I read, this error is generic and hardly helps to solve the error.

What qualifies as "it works" and "it fails"?  It is hard to understand the meaning of your question.

Possible duplicate of "avrdude: stk500_getsync(): not in sync: resp=0x00," aka Some Dude Named Avr Won't Let Me Upload My Program

Researching a little and found the solution! In addition to capacitor 104, its necessari need to add a 10k resistor by connecting the 5 volts to pin 1.
This is the link of the GitHub project where I found the solution with the assembly scheme, I hope this helps somebody else!
https://github.com/leonvandenbeukel/Arduino-on-a-breadboard/blob/master/README.md

Your problem was that you left the reset floating.


text:
Checking size in flash memory Esp32
I recently purchased an Esp32 and am doing some tests using Arduino IDE.
In one of the tests, I am recording a lot of .txt files with some text inside them in the flash memory, however, I would like to know how I can check the remaining space in the flash memory. I'm checking the flash memory space with Serial.println(ESP.getFlashChipSize());, however, the returned value is always the same.
Is this the right command to check? Why is it always with the same value?

Is this the right command to check? Why is it always with the same value?

The only way that size can change is if you desolder the can from the top of the ESP32 module, then desolder the flash chip, and replace it with one that has a different capacity.
The free space is not a function of the flash chip. It is a function of the filesystem you are using to store your data - be that SPIFFS or FAT.
You should check the manual for the filesystem you are using to find what functions there are pertaining to space usage.

Looking the source code I find the methods!
https://github.com/espressif/arduino-esp32/blob/master/libraries/SPIFFS/src/SPIFFS.cpp

The file system on the ESP32 is stored in a portion of the flash memory, and managed by the SPIFFS (SPI Flash File System) library. You can use the SPIFFS.info() function to get information about the file system, including the total size and the used size.
Assuming you have SPIFFS:
#include <ESP.h>
#include <SPIFFS.h>

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

  // Initialize the SPIFFS file system
  if (!SPIFFS.begin(true)) {
    Serial.println("Initialization failed!");
    return;
  }

  // size of the compiled program
  uint32_t program_size = ESP.getSketchSize();

  // size of the file system
  FSInfo fs_info;
  SPIFFS.info(fs_info);
  uint32_t file_system_size = fs_info.totalBytes;

  // used size of the file system
  uint32_t file_system_used = fs_info.usedBytes;

  // free size in the flash memory
  uint32_t free_size = ESP.getFlashChipSize() - program_size - file_system_size + file_system_used;

  Serial.print("Program size: ");
  Serial.print(program_size);
  Serial.println(" bytes");

  Serial.print("File system size: ");
  Serial.print(file_system_size);
  Serial.println(" bytes");

  Serial.print("File system used: ");
  Serial.print(file_system_used);
  Serial.println(" bytes");

  Serial.print("Free space: ");
  Serial.print(free_size);
  Serial.println(" bytes");
}

void loop() {
  // Do Nothing Here
}

Serial.println(ESP.getFlashChipSize());
don't return the physical flash size, it just returns the flash size that you have selected in the Arduino IDE Flash size.
Just try to set Flash size "2MB (16Mb)"
And the result is '2097152'

And if you want a bigger file system size, you can create your own partition table. Look at partitions.csv


text:
CPP Function param use function with multi params
I want to specify a function with parameters for a function parameter, but it doesn't come together.
////////////////////////////////////////////////////////////////////////

// Example funch...
void fileLoad(String path, String type) {
  file = SD.open(path.c_str(), FILE_READ);
  server.streamFile(file, type) != file.size();
  file.close();
}

// This is how I want to use it, but it's not possible:
server.on("/homepage", fileLoad("app/homepage.html", "text/html") );

////////////////////////////////////////////////////////////////////////

// Currently, as it works, you need 1 extra funch...:
void homepage() {
  fileLoad("app/homepage.html", "text/html");
}
server.on("/homepage", homepage);

How you want it isn't how C++ works. Depending on how "on" is written, and what you're actually using, you might be able to use a lambda, or you could start playing C++ games a la https://stackoverflow.com/a/41528436/438992. But I wouldn't.

@DaveNewton, it does support std::function and so lambdas of the type that would be needed, so you could make that an answer.

@timemage I don't remember enough C++ to be coherent ;)

Well, I need more coffee, but I took a stab at it anyway. =)

You can find examples of this sort of thing in the library's examples.
The on() function does support std::function as a parameter, which in turn, means you can use a C++11-onwards lambda expression (which Dave Newton mentioned in comments) to proxy your two-argument function call through a no-argument function:
server.on("/homepage", [] () {
    fileLoad("app/homepage.html", "text/html");
});

The [] ("capture list") is something that would be used if you wanted to copy or refer to things within the scope of the on function call.  Since you're not doing that you could also just write a no-argument function which turns around and calls fileLoad with your two compile-time-known values.  But it is common for people using this webserver library to need to make references things in scope.

As as side note, I'd consider not using String as your received parameter type in void fileLoad(String path, String type).  When passing in a string literal, you're just causing dynamic allocation for no particularly good reason.

Thank you!!! :)


text:
Arduino I2C external 32Kb fram data organization
Hey guys I am a noob when it comes to data structures and storing types of data, I have been recently working on a project where I needed to store long term data for later retrieval. I decided to buy a Adafruit 10$ 32kb i2c fram Which works, it can store a byte Of data per address which I can successfully do, I can also read those bytes on any address no problem.
One issue I first came across was storing floats into the chip which only took bytes, After googling I managed to spit a float using a union successfully and also storing those in a 4 byte array. Now I did this with 3 different float values which means every 4 bytes stored is basically one split float value.
The second issue is how do I retrieve this data in an organized way and also as a float. I found out you can use a union to do the opposite as well. But how do I tell my code to read every 4 bytes and convert back to float?
Is there a system that can allow me to store data in a structured way using the arduino? Like a time stamped data using an external rtc? Such that when I click retrieve it will print that data in an organized fashion.

It is unclear to me, where exactly the problem lies. Reading all 4 bytes, that you need for your float, means just reading 4 bytes sequentially. Depending on how your FRAM does communication, you could maybe do that in one single reading transmission. You can easily write the read data into a union and then read the float from it. That's just exactly the opposite way of splitting the float up. And surely, you could save a timestamp with each float, but why? The FRAM is just a piece of sequential data storage, just like any other memory. Do you want a filesystem here?

It'll be easier if you use a struct, not a union. Store all the data you want to preserve in a struct, then cast a pointer to it to be a byte pointer and just treat it as an array of bytes and read and write those bytes to the FRAM.
The union you were using explicitly did the same thing, but it's not easy to scale to multiple items.
Some caveats about what you can safely keep in the struct:

do not store pointers in it. A char array is fine because the entire array will take up space in the struct. A char * is not because all you'll save is the value of the pointer, not what it points at.

do not store objects (like String) in it. You don't know (and shouldn't know) how the object is composed internally. If need to use objects, they should have serialize and deserialize methods which would store or restore the contents of an object into an array of bytes which you could then store or restore with the FRAM.

Also remember that the C/C++ sizeof function (used below) tells you the size of thing at compile-time. So if you use it on a struct it will tell you the number of bytes it takes to store the struct. If you use it on a char *, it will tell you the number of bytes in a pointer to a char, not the number of bytes in the C string that the char * points at. If you use it on an object - like String str; sizeof(str); - it will tell you how many bytes it takes to store the String object, which will include the length of the string it stores.
Psuedo-code follows. There are more compact ways to write this; I'm aiming for clarity here.
#include <Arduino.h>

struct program_data {
  float first_thing;
  unsigned long second_thing;
  char third_thing[55];
  char fourth_thing;
  uint16_t fifth_thing;
} data;

void save_data(struct program_data *data_ptr) {
  byte *ptr = (byte *)data_ptr;

  for(size_t i = 0; i < sizeof(struct program_data); i++)
    store_byte_in_fram(ptr[i], i);
}

void restore_data(struct program_data *data_ptr) {
  byte *ptr = (byte *)data_ptr;

  for(size_t i = 0; i < sizeof(struct program_data); i++)
    retrieve_byte_from_fram(ptr[i], i);
}

// call when you want to save your data
  save_data(&data);

// call when you want to restore your data
  restore_data(&data);

Dude you are incredible, first off thank you for replying. Second this was so easy to understand! Thank you dude I will try it out and tell you.

I have an external RTC that I want to add to it so that every 5 or 10 seconds it will save the struct of values and a time associated with it. Would this overwrite A specific sector or can it shift leaving the previous data?

Good question. RTCs usually use battery-backed static RAM where it wouldn't matter if it's overwriting the same addresses. It really depends on the system and the interface to it, though. If you're addressing memory directly then writing to the same address should be the same place in memory.

Small concern. That approach might fail if it is not granted that the structure is packed

@brtiberio why do you think that would be a problem?


text:
Wemos D1 mini and JSN-SR04T-2.0: Type of power supply affects the sensor readings
Pretty similar to what is described here I have the strange problem that my sensor readings are affected by the type of power supply I use.
Whenever I connect my D1 mini through USB with laptop everything works fine. The readings make sense and are quite accurate.
But as soon as I disconnect it from the laptop and use a USB power supply (I tested different ones) the readings do not make sense anymore.
I also tried to apply the sketch to a NodeMCU board. The results are the same. So I assume it has something to do with either the sensor or the ESP 12E.
Any suggestions?

How are you powering the sensor?

The sensor is powered by the 3.3V output of the Wemos/NodeMCU Board. But I also tested it with the 5V output. Always with the same results.

I'll bet your laptop's charger has 3 prongs that plug into the wall, but your USB power supplies only have 2 prongs. If so, try grounding to earth.

Easier said than done in this case :) But I'll try. Sounds like a good idea.

Try a different supply or computer, it sounds like that one has a lot of ripple and or noise on it.  Not all USB power supplies are clean and some do not have much filtering.


text:
Problem sending strings to another ESP
I am having some problems with retrieving data from another esp. I have two esp8266, one is the access point which has a nextion lcd hooked up to it. The access point reads button presses from the lcd then sends messages to the other esp(the station point) in order to turn on the respcetive digital pins. The station point has two dht22 sensors hooked up to it. I am now trying to sens the temperature data from one of the sensor to the access point to print the data to the screen but I am having some problems(either sending or retrieving the sensor data, not sure how to test it).
Here is the code for the access point:
//this is the acces point
#include <doxygen.h>
#include <NexButton.h>
#include <NexCheckbox.h>
#include <NexConfig.h>
#include <NexCrop.h>
#include <NexDualStateButton.h>
#include <NexGauge.h>
#include <NexGpio.h>
#include <NexHardware.h>
#include <NexHotspot.h>
#include <NexNumber.h>
#include <NexObject.h>
#include <NexPage.h>
#include <NexPicture.h>
#include <NexProgressBar.h>
#include <NexRadio.h>
#include <NexRtc.h>
#include <NexScrolltext.h>
#include <NexSlider.h>
#include <NexText.h>
#include <NexTimer.h>
#include <Nextion.h>
#include <NexTouch.h>
#include <NexUpload.h>
#include <NexVariable.h>
#include <NexWaveform.h>

#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
#include <Nextion.h>

//wifi stuff
WiFiServer server(80);
IPAddress IP(192, 168, 4, 15);
IPAddress mask = (255, 255, 255, 0);

//booleans for check
bool Red1=false;
bool Green1=false;
bool Blue1=false;
bool Red2=false;
bool Green2=false;
bool Blue2=false;
bool Relay1=false;
bool Relay2=false;
bool AmbientTemp=false;
//ints for temp data
//String tempOutside=" ";
String tempInside=" ";
String humOutside=" ";
String humInside=" ";
//buttons
// page id,id,""name"
NexButton b0 = NexButton(1,2,"b0");//red1
NexButton b1 = NexButton(1,3,"b1");//green1
NexButton b2 = NexButton(1,4,"b2");//blue1
NexButton b7 = NexButton(3,2,"b7");//relay1
NexButton b8 = NexButton(3,3,"b8");//relay2
NexButton b9 = NexButton(2, 14, "b9");
NexText t8 = NexText(2,10,"t8");//tremperature inside
NexText t9 = NexText(2,11,"t9");//temperature outside
NexText t10 = NexText(2,12,"t10");//humidity inside
NexText t11 = NexText(2,13,"t11");//humidity outside

NexTouch *nex_listen_list[] = {
  &b0,
  &b1,
  &b2,
  &b7,
  &b8,
  &b9,
  NULL
};
//led strip 1
void b0PushCallback(void *ptr) {
  Red1=true;

  }
void b1PushCallback(void *ptr) {
  Green1=true;
  Serial.println("Green1");
  }
void b2PushCallback(void *ptr) {
  Blue1=true;
  }
//relays
void b7PushCallback(void *ptr) {
  Relay1=true;
  }
void b8PushCallback(void *ptr) {
  Relay2=true;
  }
void b9PushCallback(void *ptr) {
  AmbientTemp=true;
  }

void setup() {
  Serial.begin(9600);
  nexInit();
  b0.attachPush(b0PushCallback,&b0);
  b1.attachPush(b1PushCallback,&b1);
  b2.attachPush(b2PushCallback,&b2);
  b7.attachPush(b7PushCallback,&b7);
  b8.attachPush(b8PushCallback,&b8);
  b9.attachPush(b9PushCallback,&b9);
  //wifi part
  WiFi.mode(WIFI_AP);
  WiFi.softAP("Wemos_AP", "Wemos_comm");
  WiFi.softAPConfig(IP, IP, mask);
  server.begin();
  Serial.println();
  Serial.println("accesspoint_bare_01.ino");
  Serial.println("Server started.");
  Serial.print("IP: "); Serial.println(WiFi.softAPIP());
  Serial.print("MAC:"); Serial.println(WiFi.softAPmacAddress());
}

void loop() {
  nexLoop(nex_listen_list);
  //wifi stuff again
  WiFiClient client = server.available();
  if (!client) {
    return;
  }
  //String request = client.readStringUntil('\r');
  Serial.println("********************************");
  //Serial.println("From the station: " + request);
  client.flush();
  //strip 1
  if (Red1==true){
    client.print("redOne\r");
    Serial.println("Red1");
    Red1=false;
    }
  if (Green1==true){
    client.println("greenOne\r");
    Green1=false;
    }
  if (Blue1==true){
    client.println("blueOne\r");
    Blue1=false;
    }
  //relays
  if (Relay1==true){
    client.println("relayOne\r");
    Relay1=false;
    }
  if (Relay2==true){
    client.println("relayTwo\r");
    Serial.println("Relay2");
    Relay2=false;
    }
  if (AmbientTemp==true){
    client.println("AmbientTemp\r");
    Serial.println("ambient temp");
    AmbientTemp=false;
    }
  String tempOutside=client.readStringUntil('\r');
  Serial.println("tempOutside: ");
  Serial.println(tempOutside);
  //t8.setText(tempOutside);
  //tempInside=client.readStringUntil('\b');
  //t9.setText(tempOutside);
  //humInside=client.readStringUntil('\e');
  //t10.setText(humInside);
  //humOutside=client.readStringUntil('\f');
  //t11.setText (humOutside);//halp
  //Serial.println(humOutside);
  //Serial.println("humoutside: ");
  //Serial.print("t11.txt=");
  //Serial.print(humOutside.toInt());
  //Serial.write(0xff);
  //Serial.write(0xff);
  //Serial.write(0xff);
  Serial.println("Byte sent to the station: ");
  //Serial.println(client.println("reeeeeeeeeeeeeeeeeeeee\r"));
  //Serial.println(client.println("IamAlive\r"));
  }

And here is the code for the access point:
#include <DHT.h>
#include <DHT_U.h>
#include <ESP8266WiFi.h>

#define DHTPIN 3 //outside
#define DHTPIN2 0 //inside
#define DHTTYPE DHT22//type of sensor that I am using
DHT dht(DHTPIN, DHTTYPE); //outside
DHT dht2(DHTPIN2, DHTTYPE); //inside

//pins
const int Red = 5;
const int Green = 4;
const int Blue = 14;
const int Relay1= 12;
const int Relay2= 13;
//booleans for on/off(state)
bool RedS=false;
bool GreenS=false;
bool BlueS=false;
bool Relay1S=false;
bool Relay2S=false;
bool AmbientTempS=false;

char ssid[] = "Wemos_AP";           // SSID of your AP
char pass[] = "Wemos_comm";         // password of your AP
IPAddress server(192,168,4,15);     // IP address of the AP
WiFiClient client;
void setup() {
  Serial.begin(9600);
  dht.begin();
  dht2.begin();
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, pass);           // connects to the WiFi AP
  Serial.println();
  Serial.println("Connection to the AP");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.println("Connected");
  Serial.println("station_bare_01.ino");
  Serial.print("LocalIP:"); Serial.println(WiFi.localIP());
  Serial.println("MAC:" + WiFi.macAddress());
  Serial.print("Gateway:"); Serial.println(WiFi.gatewayIP());
  Serial.print("AP MAC:"); Serial.println(WiFi.BSSIDstr());
  //pins
  pinMode(Red, OUTPUT);
  pinMode(Green, OUTPUT);
  pinMode(Blue, OUTPUT);
  pinMode(Relay1, OUTPUT);
  pinMode(Relay2, OUTPUT);
  digitalWrite(Red, LOW);
  digitalWrite(Green, LOW);
  digitalWrite(Blue, LOW);
  digitalWrite(Relay1, LOW);
  digitalWrite(Relay2, LOW);
}
void loop() {
  client.connect(server, 80);
  Serial.println("********************************");
  Serial.print("Byte sent to the AP: ");
  Serial.println(client.print("Anyo\r"));
  String answer = client.readStringUntil('\r');
  Serial.println("From the AP: "+answer);
  int h = dht.readHumidity(); //humidity for Outside
  int t = dht.readTemperature(); //temperaure for Outside
  int h2 = dht2.readHumidity(); //humidity for Outside
  int t2 = dht2.readTemperature(); //temperaure for Outside
  Serial.println("temp outside: ");
  Serial.println(t);
  Serial.println("Thing: ");
  //Serial.println("temp inside:");
  //Serial.println(t2);
  //client.print(String(t2)+'\b');
  //Serial.println("hum outside:");
  //Serial.println(h);
  //client.print(String(h)+'\e');
  //Serial.println("hum inside:");
  //Serial.println(h2);
  //Serial.println(client.print(String(h2)+"\f"));
  client.flush();
  //stuff
  client.println(String(t)+'\r');
  //stuff again
  if(answer=="redOne"){
    if (RedS==false){
      digitalWrite(Red, HIGH);
      RedS=true;
      Serial.println("Red1 ON");
      }
    else{
      digitalWrite(Red, LOW);
      RedS=false;
      Serial.println("Red1 OFF");
      }
    }
  if(answer=="greenOne") {
    if (GreenS==false){
      Serial.println("Green1 ON");
      GreenS=true;
      digitalWrite(Green, HIGH);
      }
    else{
      Serial.println("Green1 OFF");
      GreenS=false;
      digitalWrite(Green, LOW);
      }

    }
  if(answer=="blueOne") {
    if (BlueS==false){
      Serial.println("Blue1 ON");
      BlueS=true;
      digitalWrite(Blue, HIGH);
      }
    else{
      Serial.println("Blue1 OFF");
      BlueS=false;
      digitalWrite(Blue, LOW);
      }

    }
  if(answer=="relayOne") {
    if (Relay1S==false){
      Serial.println("Relay1 ON");
      Relay1S=true;
      digitalWrite(Relay1, HIGH);
      }
    else{
      Serial.println("Relay1 OFF");
      Relay1S=false;
      digitalWrite(Relay1, LOW);
      }

    }
  if(answer=="relayTwo") {
    if (Relay2S==false){
      Serial.println("Relay2 ON");
      Relay2S=true;
      digitalWrite(Relay2, HIGH);
      }
    else{
      Serial.println("Relay2 OFF");
      Relay2S=false;
      digitalWrite(Relay2, LOW);
      }
  if(answer=="AmbientTemp") {
    if (AmbientTempS==false){
      Serial.println("AmbientTemp ON");
      AmbientTempS=true;
      }
    else{
      Serial.println("AmbientTemp OFF");
      AmbientTempS=false;
      digitalWrite(Red, LOW);
      digitalWrite(Green, LOW);
      digitalWrite(Blue, LOW);
      }
   while(AmbientTempS==true){
    Serial.println("Ambient temp is on!");
    }

    }
  client.stop();
  delay(2000);
  }
}

Thank you and sorry for any mistakes, English is not my first language.

start at the beginning ... reduce your code to sending a single byte or character... when that works reliably, then expand to multiple bytes/characters ... keep adding code in small increments

Will definitely try, had a similar problem and it worked in the end, I still posted the question to see if I made some obvious mistake I didn't catch.

Figured it out, not too sure what was causing it to not send messages but below is the code that is working.

#include <ESP8266WiFi.h>
#include <DHT.h>
#include <DHT_U.h>

#define DHTPIN 3 //outside
#define DHTPIN2 0 //inside
#define DHTTYPE DHT22//type of sensor that I am using
DHT dht(DHTPIN, DHTTYPE); //outside
DHT dht2(DHTPIN2, DHTTYPE); //inside

//pins
const int Red = 5;
const int Green = 4;
const int Blue = 14;
const int Relay1= 12;
const int Relay2= 13;
//booleans for on/off(state)
bool RedS=false;
bool GreenS=false;
bool BlueS=false;
bool Relay1S=false;
bool Relay2S=false;
bool AmbientTempS=false;

char ssid[] = "Wemos_AP";           // SSID of your AP
char pass[] = "Wemos_comm";         // password of your AP
IPAddress server(192,168,4,15);     // IP address of the AP
WiFiClient client;
void setup() {
  Serial.begin(9600);
  dht.begin();
  dht2.begin();
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, pass);           // connects to the WiFi AP
  Serial.println();
  Serial.println("Connection to the AP");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.println("Connected");
  Serial.println("station_bare_01.ino");
  Serial.print("LocalIP:"); Serial.println(WiFi.localIP());
  Serial.println("MAC:" + WiFi.macAddress());
  Serial.print("Gateway:"); Serial.println(WiFi.gatewayIP());
  Serial.print("AP MAC:"); Serial.println(WiFi.BSSIDstr());
  //pins
  pinMode(Red, OUTPUT);
  pinMode(Green, OUTPUT);
  pinMode(Blue, OUTPUT);
  pinMode(Relay1, OUTPUT);
  pinMode(Relay2, OUTPUT);
  digitalWrite(Red, LOW);
  digitalWrite(Green, LOW);
  digitalWrite(Blue, LOW);
  digitalWrite(Relay1, LOW);
  digitalWrite(Relay2, LOW);
}
void loop() {
  int h = dht.readHumidity(); //humidity for Outside
  int t = dht.readTemperature(); //temperaure for Outside
  int h2 = dht2.readHumidity(); //humidity for Outside
  int t2 = dht2.readTemperature(); //temperaure for Outside
  client.connect(server, 80);
  Serial.println("********************************");
  Serial.print("Byte sent to the AP: ");
  Serial.println(client.print("Muie PSD\r")); //sending data to esp8266
  String answer = client.readStringUntil('\r');
  Serial.println("From the AP: " + answer);
  if(answer=="redOne"){
    if (RedS==false){
      digitalWrite(Red, HIGH);
      RedS=true;
      Serial.println("Red1 ON");
      }
    else{
      digitalWrite(Red, LOW);
      RedS=false;
      Serial.println("Red1 OFF");
      }
    }
  if(answer=="greenOne") {
    if (GreenS==false){
      Serial.println("Green1 ON");
      GreenS=true;
      digitalWrite(Green, HIGH);
      }
    else{
      Serial.println("Green1 OFF");
      GreenS=false;
      digitalWrite(Green, LOW);
      }

    }
  if(answer=="blueOne") {
    if (BlueS==false){
      Serial.println("Blue1 ON");
      BlueS=true;
      digitalWrite(Blue, HIGH);
      }
    else{
      Serial.println("Blue1 OFF");
      BlueS=false;
      digitalWrite(Blue, LOW);
      }

    }
  if(answer=="relayOne") {
    if (Relay1S==false){
      Serial.println("Relay1 ON");
      Relay1S=true;
      digitalWrite(Relay1, HIGH);
      }
    else{
      Serial.println("Relay1 OFF");
      Relay1S=false;
      digitalWrite(Relay1, LOW);
      }

    }
  if(answer=="relayTwo") {
    if (Relay2S==false){
      Serial.println("Relay2 ON");
      Relay2S=true;
      digitalWrite(Relay2, HIGH);
      }
    else{
      Serial.println("Relay2 OFF");
      Relay2S=false;
      digitalWrite(Relay2, LOW);
      }
  if(answer=="AmbientTemp") {
    if (AmbientTempS==false){
      Serial.println("AmbientTemp ON");
      AmbientTempS=true;
      }
    else{
      Serial.println("AmbientTemp OFF");
      AmbientTempS=false;
      digitalWrite(Red, LOW);
      digitalWrite(Green, LOW);
      digitalWrite(Blue, LOW);
      }
   while(AmbientTempS==true){
    Serial.println("Ambient temp is on!");
    }

    }
  client.flush();
  client.stop();
  delay(2000);
  }
}


text:
Reset HC-05 from within Arduino sketch
I have an HC-05 Bluetooth module attached to an Arduino Mega; the module is paired with a Raspberry Pi and fed data via a python program; there's roughly one send and one receive per second of about 35 bytes.
When I first power up the Arduino / HC-05, it flashes quickly, and then after pairing, it flashes twice every second indicating a successful pair & communication. All is good; data is flowing. Periodically (5 minutes? 3 hrs?) & unpredictably, the communication ends; I'm still trying to troubleshoot this; the python code on the RPi reports a not-helpful OSError: [Errno 5] Input/output error on the available() method of the pySerialTransfer library; though I welcome thoughts on that, I realize that question isn't for this forum.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/.local/lib/python3.7/site-packages/pySerialTransfer/pySerialTransfer.py", line 416, in available
    if self.connection.in_waiting:
  File "/home/pi/.local/lib/python3.7/site-packages/serial/serialposix.py", line 467, in in_waiting
    s = fcntl.ioctl(self.fd, TIOCINQ, TIOCM_zero_str)
OSError: [Errno 5] Input/output error

The HC-05 module continues to flash as if it's connected, even though it is not, and even if I restart the python program, I'm unable to repair with the HC-05.  The only way I can figure out to reconnect to the HC-05 is to power the Arduino / HC-05; then I can reconnect.
So here is the question: is there to reset the HC-05 from within the Arduino sketch? I realize I could attach the VCC to a digital pin to do a full power cycle on the HC-05, but I believe the HC-05 draws on the outer limit of safe current for an Arduino (40ma); I could go thru a relay to do the disconnect, but I wonder if there's a cleaner way with fewer moving parts, or if that is indeed the best way?
Thanks for any guidance!

You could use a logic level MOSFET with low RDSon (e.g. IRLZ44) to switch the supply of the HC-05 and use a digital pin to control it.

Thank you - I've ordered a few of those and will give it a shot!


text:
Help needed to check if my solenoid wiring is correct
I'm planning a new custom keyboard project which involves a solenoid being controlled by a Teensy2.0++, and i would like to power everything with just a USB cable.
I don't have much electronics or electrical engineering background but from my research, this is how I think i should be wiring my solenoid up.
I would appreciate if anyone can help me to check if this is correct and doesn't blow anything up.

Your question is not really about arduino. But your wiring is correct if you get the transistor polarity right. You should also consider adding a pulldown at the base to avoid that the solenoid acts randomly on power-up/-down.

Add the pull down resistor at the port pin thereby eliminating a dividing network to the base.