texts: Read the respiration data to Arduino serial console

texts:
Currently working with ADS1292rShield library.
Is there any way to read the value of the respiration and heart rate without using the Protocentral GUI. Printing DataPacketHeader to the console just results in corrupted ASCII.

DataPacketHeader[9] = s32DaqVals[0];            // 4 bytes Respiration data
DataPacketHeader[10] = s32DaqVals[0]>>8;
DataPacketHeader[11] = s32DaqVals[0]>>16;
DataPacketHeader[12] = s32DaqVals[0]>>24;

    for(i=0; i<15; i++)
    {
      Serial.write(i);
      Serial.write(DataPacketHeader[i]);     // transmit the data over USB
    }

Here is the output below of the Arduino serial monitor, is there any way to make sense of the data or how it is converted to a readable integer on the GUI?

⸮ < 0 p s | ` r I @ @ 9     ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ < 2 $ & O ` q ` 8 0 ! > ⸮ ⸮ ⸮ ⸮ ⸮  ! 8 ! | H a @  9 $  ! ⸮ 8 B x  ⸮ ⸮ ⸮ ⸮  y a ` p  f ⸮ ⸮ ⸮ ⸮ ⸮ 1 b N p ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ " D ` ` ` p
 ! ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ 0 ⸮ ' # 3 @ O ` D B @ @ ! ⸮ ⸮ ⸮ ⸮ ⸮ 0    a F ⸮ ⸮ ⸮ ⸮ ⸮ ⸮ " x p $ 0 ⸮


texts: Arduino Due Serial Port Not Showing - Mac

texts:
Using a Mac (Big Sur 11.1)
When trying to set up the IDE I was able to install the package that contained the Due board, but the serial port for my Arduino Due isn't appearing in Tools -> Port -> Serial Ports. I did some searching and it seems that other Mac users had this problem as well.
If anyone has any tips on how to get my computer to recognize and show the serial port I'd appreciate it. I'm just getting started with these.


texts: Why does Arduino IDE recommend storing 0-255 numbers in "byte" instead of "char"?

texts:
I bumped into byte datatype recently. My knowledge of C/C++ is shallow, but I know char and I couldn't find much on byte in C++ docs. I looked it up in the Arduino docs:

  It’s recommended to only use char for storing characters. For an
  unsigned, one-byte (8 bit) data type, use the byte data type.

Is byte datatype a solely Arduino construct? If so, why is it recommended over char? Both are 8-bit so why would it make any difference?


texts:
Is it possible to change pin operation from output to input within the Arduino loop (event-driven)?

I would like to change the operation of a couple of Arduino pins from input to output during execution of the Arduino loop in an event-driven way. Is this possible please?


texts: Arduino servo acts weird with photocell (lightsensor)

texts:
I have a weird thing with my servo, I really dont know what is wrong with my code, I tried everything. Either it is my connection on arduino or my code. Please help me guys, this is my code.

#include <Servo.h>

int servoPin = 9;
Servo servo;
int angle = 0;
int photocellPin = 0;

void setup() {
  servo.attach(servoPin);
}

void loop() {
  int reading = analogRead(photocellPin);
  Serial.print("Reading = ");
  Serial.println(photocellPin);
  int newAngle = reading / 2;
  servo.write(newAngle);
  delay(80);
}


texts: burn arduino bootloader and compiled sketch at same time

texts:
How can I write the bootloader and sketch code to an Arduino through the ISP and then write the sketch code again using the Arduino IDE later?

Currently, I can write the bootloader through the ISP and then write the sketch through the Arduino IDE.  This works just like normal.

I can also write the bootloader and sketch through the ISP.  The code runs like normal, but I can't load a new version of the sketch through the Arduino IDE.  It just timesout.

Here's what the IDE says when it attempts to upload the program:

avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM5
         Using Programmer              : wiring
         Overriding Baud Rate          : 115200
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

The Arduino IDE creates two hex files after compiling the sketch: one is just the compiled sketch (Sketch.ino.hex) and the other is the compiled sketch with the bootloader code appended to the end (Sketch.ino.with_bootloader.hex).  So, I feel like this should be possible because Arduino produces the file for me.


texts: Connecting ACS 712 30A to my Solar Panel with Arduino

texts:
I am trying to connect my Solar Panel (array of 2 x 265Wp 24v panels connected in series) to my Arduino UNO R3/Nano so that I can make a current/voltage measurement system that can be connected to the internet for remote data access.

I am not sure if an Allegro ACS712 30Amp chip could handle the voltage/current of my system which is usually over 60v dc and 4-5 amps. I can relate the ACS712 to a simple ammeter which is connected in series of the load where a shunt resistance is used between the two connecting ends of the ammeter.

The confusing part here for me is that the solar panel is connected via an MPPT charge controller to my 1.5 KVA inverter which in turn powers my house equipment, and I am not sure if the two connecting ends of the ACS712 can handle this load (which sometime exceeds to over 450 Wh) if connected in between the wire connecting the panel and charge controller.

Can anyone help me with a suggestion or better with a diagram showing the suggested system.


texts: Burning Arduino Leonardo Bootloader to ATmega32U4 with 8MHz internal clock

texts:
Burning question:

So, I'm trying to burn the Arduino Leo bootloader onto a ATmega32U4 that's on 3.3V and the internal 8MHz clock.  Do I have to modify and rebuild the bootloader to set the fuses correctly, and can this be done with AVR Studio?

All of the references on doing this are dated.  The folder structure for the Arduino IDE has changed. I've done it in the past with 5V 16MHz 32U4s using an Arduino as ISP, but never with the AVRISP mkII on the Arduino IDE.

On the good side, I do have it up and running Atmel Studio.

Thanks!

EDIT:  Sorry for double posting, I posted in electronics before I noticed there was an Arduino specific section.


texts: Arduino TCP Server establishes connection with client but does not receive data

texts:
I am trying to send and receive data with the TCP server but I am not receiving data.

#include <ESP8266WiFi.h>
#include <WiFiClient.h>

// Parametros de conexion a red WIFI.
const char* ssid = "bits";
const char* password = "12345";

// Start a TCP Server on port 5000
WiFiServer server(5000);

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid,password);
  Serial.println("");
  //Wait for connection
  while(WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
 Serial.println(WiFi.localIP()); // IP

  // Start the TCP server
  server.begin();
}

void loop() {
  TCPServer();
}

void TCPServer () {
   WiFiClient client = server.available();
    if (client) {
      Serial.println("We have a new client");
      Serial.println("Hello, client!");
        if (client.available() > 0) {
            char thisChar = client.read();
            Serial.println("We got data");
            Serial.println(thisChar);
            delay(200);
        }
    }
}

Test Capture: In the capture it is seen that the code is executed until the following instruction.

Serial.println("We have a new client");
Serial.println("Hello, client!");


texts: What is the most memory-friendly way to declare integer literals?

texts:
I'm having SRAM overflow problems with my 8bit atmega328p in my Arduino Uno, which has 2KB of SRAM, so I'm defining all my for loops with bytes as counters instead of ints. As in:

for(byte i=0;i<16;i++) buf[i]=(char)ap1[i];

Would it make any difference if I declared the integer literal 16 as a constant?

const byte BUFSIZE=16;

Or using the preprocessor:

#define BUFSIZE 16

There's also the macro PROGMEM which stores variables in flash memory, which I've decided to use for all my constants, but is it not the point of const to do this? as well as aiding the compiler in warning you if you screwed up changing the variable.

const byte BUFSIZE PROGMEM=16;

AFAIK, using const would save BUFSIZE in the flash memory, but how about using the preprocessor? Using the preprocesor would be the exact the same as using the literal 16, as far as i'm concerned.

This fear arose from the fact that string literals are saved in Flash and then transferred to SRAM, wasting twice the space, which you can solve using the arduino macro F("thisisastring"), which stores them in flash memory, and I don't want to waste 2 bytes of SRAM in every for loop I use


texts: I have a problem in calibration an LDR sensor. I want to let the sensor goes all day long and I'm using the LDR sensor as a presence sensor. The calibration values (min and max) changes all the day, and I need to detect only the peaks, or continuously change the min and the max values. Are there some defined pattern or algorithms to use?


texts:
I have a rotary encoder and 2 buttons to a. Store the encoder value b. Reset the encoder value to 0. The reset buttons work fine the issue is with the set/store button. Where the value changes without pressing the button as well. Any help is appreciated.
int encoderPin1 = 2;
int encoderPin2 = 3;

volatile int lastEncoded = 0;
volatile double encoderValue = 0;
long lastencoderValue = 0;

int lastMSB = 0;
int lastLSB = 0;

// buttons
int resetPin = 43;
int settPin = 22;
int val = 0;
int val2 = 0;

//reset-set
double setValue = 0.0;
double resetValue = 0.0;

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

  pinMode(encoderPin1, INPUT);
  pinMode(encoderPin2, INPUT);

  digitalWrite(encoderPin1, HIGH);
  digitalWrite(encoderPin2, HIGH);

  attachInterrupt(0, updateEncoder, CHANGE);
  attachInterrupt(1, updateEncoder, CHANGE);

  //buttons
  pinMode(resetPin, INPUT);
  pinMode(settPin, INPUT);

  pinMode(LED_BUILTIN, OUTPUT);

}
void loop(){
  //Serial.println(encoderValue); //print
  delay(1000);

  //
val = digitalRead(settPin);
if (val == HIGH){
  set();
  digitalWrite(LED_BUILTIN, HIGH);
}

/*val2 = digitalRead(resetPin);
if (val2 == HIGH){
  //reset
  encoderValue = resetValue;
  Serial.println(encoderValue);
  Serial.print("reset");
  delay(100);
}*/

}

void set(){
  //set the value
  setValue = encoderValue;
  Serial.println(setValue);
  Serial.print("setValue");
  delay(100);
}

 void updateEncoder(){
  int MSB = digitalRead(encoderPin1);
  int LSB = digitalRead(encoderPin2);

  int encoded = (MSB << 1) |LSB;
  int sum = (lastEncoded << 2) | encoded;

  if(sum == 0b1101 || sum == 0b0100 || sum == 0b0010 || sum == 0b1011) encoderValue ++;
  if(sum == 0b1110 || sum == 0b0111 || sum == 0b0001 || sum == 0b1000) encoderValue --;

  lastEncoded = encoded;
  }


texts:
I was testing out my new Servo FS5106B. Here is the code I used:

#include <Servo.h>

Servo servo;
void setup()
{
    servo.attach(10);
}

void loop()
{
    servo.write(0);
    delay(1000);
    servo.write(180);
    delay(1000);
}

After I upload the sketch, the console says:

  Sketch uses 2872 bytes (1%) of your device memory. Total available 253952 bytes. Global variables use 161 bytes (1%) of the dynamic memory, leaving 8031 bytes for local variables. Maximum 8192

The delay between the rotations wasn't 1 second (as I was expecting), but 13 seconds (when I connect only a LED and use the delay function, everything works perfectly). Why is that happening?

P.S The power source for the servo is my Arduino-Mega 2560, wich outputs 5V. The model I use for wiring is:

Edit 1:
I tried to execute the program that @ChrisStratton suggested, here an updated code

#include <Servo.h>
#define led 22

Servo servo;

void setup()
{
    Serial.begin(9600);
    while(!Serial)
        delay(10);

    Serial.println("Start!");
    pinMode(led, OUTPUT);
    servo.attach(10);
}

void loop()
{
    digitalWrite(led, HIGH);
    servo.write(0);
    delay(1000);
    digitalWrite(led, LOW);
    servo.write(180);
    delay(1000);
}

When this program loads, servo does 2 rotations in 0.4 seconds and the LED goes high and low really fast, then anything changes for another 10 seconds, then again the LED goes high and low and the Servo does 2 rotations


texts:
I can't connect to the network.
Hardware used: Arduino UNO and SIM900A GSM module
Tutorial used: https://www.instructables.com/id/GSM-SIM900A-With-Arduino/
Sim card used: Orange (I set it on 2G frequency and disabled pin code)
I am from Romania.

Based on the tutorial above, once the connection is established successfully, the status/network LED on the SIM900A will blink continuously every 3 seconds. This does not happen to me, so it is a problem from the start. It keeps on searching for a network to connect.

Would you mind helping me, please?

Thank you so much!


texts:
I'don't know if this is the right place to ask a hardware related question. I'm looking for an adapter to connect my servo motor to a shaft.
The only workaround I've found so far is to use two kinds of adapter. First connect this to the servo and then use a second adapter for the shaft, like this.
Are you familiar with a one-adapter solution?
Thanks!


texts: Arduino can't see any library I have installed for nrf905?

texts:
nrf905\
nRF905-All-In-One-Shield\
RadioHead-master\
RadioHead\

None any of them are compiled with their examples without getting errors.

Error message:

nRF905_RX.ino:4:20: fatal error: NRF905.h: No such file or directory
compilation terminated.
Error compiling.

Libraries used:

Elechouse
RadioHead Github
RadioHead Doxygen
zkemble/nRF905


texts:
I want to know how much time has elapsed since a certain event, and I do not want to use any external timers. It seems logical to reset an internal timer whenever the event occurs (using an interrupt). Unfortunately, as far as I can tell, millis() and micros() cannot be manually reset. Obviously, I could save a time stamp whenever the event occurs; however, I want to avoid overflow problems (micros() will overflow every ~71 minutes, and millis() will overflow every ~50 days).

Is there a way to manually reset these built-in counters? If not, how can I manage the overflow?


texts: How to clear output buffer of Arduino Uno?

texts: I have coded arduino for DHT11 which used to print humidity in first and temperature in second line. But some times when I open SerialPort I get absurd data.


texts: How to control a DC Motor with absolute encoder using Arduino and Motor Driver?

texts:
I am a beginner in Arduino, I have only basic knowledge and a big appetite :)

I'm working on my cable-cam project. I've made all the mechanical parts by myself, bought all electricity parts through eBay, and everything works fine so far. With the basic RC controller I steer forward / back and I also have a speed potentiometer.

Now there is a question of security:
Since cable-cam runing on a rope fastened to two hubs/buildings/trees/piers,
up to 40 mph.
I would like to have the opportunity to program two points through which the cable-cam cannot overdrive, so that it would not go to the end of the rope and break itself.

THE concept: cable-cam is driven to point A and is marked. Then it is driven to point B and also marked. When the cable-cam reaches point B, it stops and can not go further, but it can go back to point A. And vice versa. Something like a "operation range control points" that can be programmed. Something like this: end points with Hall sensor

THE idea: on a non-powered wheel (for avoiding slippage and incorrect reading of data on the encoder), I'll set an absolute encoder to measure axis rotations and thus calculate the distance in both directions. The encoder would then be connected to the Arduino that would send the ESC signal to stop the engine when it reached that point, A or B. Stopping should be soft, not at the moment. The speed of the cable cam can be significant, so abrupt stoppage would also be a problem.

So...am I pre-ambitious? I need help with code for Arduino.

Parts:
RC: Turnigy 9X
ESC:Syren 50A and it has an Arduino library,
and the encoder:Koyo TRD NA1024NW


texts: Sensor that detects when metal sieve is clogged with debris

texts:
I'm a newbie here and would really appreciate all kinds of suggestions and answers from the experts here.
I am trying to make a small grey water recycling system project, and for the my primary filtration process tank, I will be using a combination of Metal Sieve and Cloth filter medium.
The problem is, I will be making the system alert the user when filters are in need of changing and maintenance.

I made a quick sketch of my idea on paint, and as you can see, I am planning to make my grey water collection tank to look that way.
I am thinking of using pressure sensor to sense the change of weight in the sieve and cloth part of the tank for a minimum amount of time so that the system will not confuse water flow weight vs. the weight of the debris on the metal sieve, but I'm thinking that the pressure sensor is not waterproof.
I'm also thinking of like the laser module, and when the light breaks at certain level, meaning there is too much debris that has to be removed.
I also googled load cells or weight sensors, but I'm really sorry I'm new to this, I don't know what is the best sensor to use for my problem.
I'm thinking of a float switch a few inches on top of my metal sieve and cloth and when it does not go on a OFF state for a certain amount if time, then the sieve is clogged, but my tank could overflow..
I need something that, when the sieve is clogged, the tank will no longer accept grey water input to avoid overflow.
It has to be submersible in water too :'(
Is there a type of sensor that is most suitable for my problem?
Thank you so much everyone. Have a nice day.


texts: Arduino UNO IR blaster - storing codes in PROGMEM

texts:
I've setup an IR LED on my UNO, with the IRremote library, and have the code working to control an RGB LED strip from certain serial input, however as i'm storing the Raw infrared data in variables, i'm running out of RAM very quickly, and haven't managed to get code working that stores the IR data in PROGMEM, then buffers it to RAM for sending.

The current working code can be found at https://gist.github.com/dan-r/71294eaf9fe2354f1a0c7c13fc5f3bcd, and i've tried setting the int arrays as statics in PROGMEM, but whatever I do, I can't figure out how to buffer them into RAM, or even directly send them with irsend.


texts: Can the Arduino interface with a fingerprint sensor on my mobile?

texts:
I own a OnePlus 6 and it has a fingerprint sensor. Instead of using a fingerprint scanner module like the R305, could I just use my mobile for scanning the fingerprints? If yes, how do I implement this?

This is for creating a smart home security system.


texts: Newbe needing help with fixed string length

texts:
im trying to build a bit of test equipment that will talk to some software and it needs to send a fix string. when the voltage changes the string length does as well. i need to cap the results to 4 in length. (sorry for not knowing the correct terminology. this is the output i need -

Where,

X = Flag CP Value
_ = Space
P = Polarity
C = CP Received value
Y = Flag Field Gradient
F = Field Gradient Received value
Z = Flag Contact CP
T = Contact CP Received value

There is also a line feed and carriage return present at the end of each string.
The polarity indicator will only display a minus sign ‘-‘ if the received value is
negative otherwise no assignation will be transmitted. Although the overall string
length is constant the values for each measurement are right justified and hence a
space will be present should the value of the measurement not necessitate the
utilisation of all allocated character spaces.
Sample Outputs

< X -89 Y -1989 Z -1096 >
< X 1039 Y 8 Z 78 >

this is my code so far

#include <Wire.h>
#include <Adafruit_ADS1015.h>

Adafruit_ADS1115 ads1(0x48);     // Use this for the 16-bit version
Adafruit_ADS1115 ads2(0x49);

void setup(void) {

  Serial.begin(9600);

  ads1.setGain(GAIN_ONE);        // 1x gain   +/- 4.096V  1 bit = 2mV
  ads2.setGain(GAIN_ONE);        // 1x gain   +/- 4.096V  1 bit = 2mV

  ads1.begin();
  ads2.begin();
}

void loop(void) {

  int16_t results01,results02,results03;

  results01 = ads1.readADC_Differential_0_1();
  results02 = ads1.readADC_Differential_2_3();
  results03 = ads2.readADC_Differential_0_1();

  Serial.print("X ");
  Serial.print(round(results01 * multiplier));

  Serial.print(" Y ");
  Serial.print(round(results02 * multiplier));

  Serial.print(" Z ");
  Serial.print(round(results03 * multiplier));

  Serial.println();              // send a cr/lf
  delay(500);
}

Any help pointing me in the right direction would be Amazing.
Thanks in advance

Joe


texts: I cannot compile the Arduino sketch when I remove the void loop function?

texts:
#include <AFMotor.h>

AF_DCMotor motor(2,MOTOR12_64KHZ);

void movefor ();

void moveback();

    void setup()

    {

    Serial.begin(9600);

    Serial.println("Motor test!");` `motor.setSpeed(200);

    movefor ();
    moveback ();
    }

        void movefor( ){
        motor.run(FORWARD);
    delay(1000);
    motor.run(RELEASE);
     delay(100);
    }

    void moveback( ) {
      motor.run(BACKWARD);
    delay(1000);
    motor.run(RELEASE);
     delay(100);
    }

While trying to compile this the error message is error compiling for board Arduino Uno

I want the functions outside loop so removed it.

Even if I keep void loop and leave it blank then my motors will like run forward, backward and forward afterwards continuously .


texts:
I am trying to learn how to use ESP-01(AI-Cloud, Black Version) with arduino

Initially, I created an adapter for it that has 4 inputs: RX, TX, Vcc(3.3v), GND I checked it and the wiring seems fine then I attached TX of arduino to TX of ESP and same with RX but with a voltage divider (1k ohm,2kohm),I uploaded arduino with a blank sketch and tried to run commands like AT and AT+CWMODE? but I got no response on the serial monitor.I tried to look for a proper tutorial to do this but, all tutorials show how to upload a sketch to ESP rather than arduino. Then I searched and found this piece of code:

#include <SoftwareSerial.h>

#define DEBUG true

SoftwareSerial esp8266(2,3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.
                            // This means that you need to connect the TX line from the esp to the Arduino's pin 2
                            // and the RX line from the esp to the Arduino's pin 3
void setup()
{
 Serial.begin(9600);
 esp8266.begin(115200); // your esp's baud rate might be different

 sendData("AT+RST\r\n",2000,DEBUG); // reset module
 sendData("AT+CWMODE=2\r\n",1000,DEBUG); // configure as access point
 sendData("AT+CIFSR\r\n",1000,DEBUG); // get ip address
 sendData("AT+CIPMUX=1\r\n",1000,DEBUG); // configure for multiple connections
 sendData("AT+CIPSERVER=1,80\r\n",1000,DEBUG); // turn on server on port 80
}

void loop()
{
 if(esp8266.available()) // check if the esp is sending a message
 {
   /*
   while(esp8266.available())
   {
     // The esp has data so display its output to the serial window
     char c = esp8266.read(); // read the next character.
     Serial.write(c);
   } */

   if(esp8266.find("+IPD,"))
   {
    delay(1000);

    int connectionId = esp8266.read()-48; // subtract 48 because the read() function returns
                                          // the ASCII decimal value and 0 (the first decimal number) starts at 48

    String webpage = "
Hello
&lth2>World!
<button>LED1</button>";

    String cipSend = "AT+CIPSEND=";
    cipSend += connectionId;
    cipSend += ",";
    cipSend +=webpage.length();
    cipSend +="\r\n";

    sendData(cipSend,1000,DEBUG);
    sendData(webpage,1000,DEBUG);

    webpage="<button>LED2</button>";

    cipSend = "AT+CIPSEND=";
    cipSend += connectionId;
    cipSend += ",";
    cipSend +=webpage.length();
    cipSend +="\r\n";

    sendData(cipSend,1000,DEBUG);
    sendData(webpage,1000,DEBUG);

    String closeCommand = "AT+CIPCLOSE=";
    closeCommand+=connectionId; // append connection id
    closeCommand+="\r\n";

    sendData(closeCommand,3000,DEBUG);
   }
 }
}

String sendData(String command, const int timeout, boolean debug)
{
   String response = "";

   esp8266.print(command); // send the read character to the esp8266

   long int time = millis();

   while( (time+timeout) > millis())
   {
     while(esp8266.available())
     {

       // The esp has data so display its output to the serial window
       char c = esp8266.read(); // read the next character.
       response+=c;
     }
   }

   if(debug)
   {
     Serial.print(response);
   }

   return response;
}

I hooked pins according to the code and it worked serial monitor output some lines but with allot of garbage values, This also created a wifi hotspot 'AI-Thinker' which I connected to and opened Ip as shown on debugging. This made ESP try to send string 'webpage' but mostly was garbage.

so my question is, how to properly use esp with arduino to maybe just switch an led on or send data from sensors, super basics?

Is it better to use esp Library and upload sketches to esp and control arduino with it?

Can some one suggest the proper tutorial for this? because even after all this I am still confused that is RX of arduino connected to RX(which makes no sense but given in many of google images) or TX of ESP-01?


texts: Serial.print changes serial output before it is called

texts:
I'm making a project with an sd card where the user enters a file name over the serial port, and then the aduino does thing to that file. Right now i'm working on getting the serial input to work, but one Serial.print() is somehow changing a variable/output of another Serial.print(), but before it is even called.
Here is my code:
char input, output;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("Ready\nEnter input text");
  while (!Serial.available()); // wait till serial available
  delay(2000);
  byte avail = Serial.available() - 1;//extra newline char at end that we don't want
  char inBuf[avail];
  //Serial.println(avail);
  Serial.readBytes(inBuf, avail);
  Serial.read();
  Serial.print("'");
  Serial.print(inBuf);
  Serial.println("'");
  delay(1000);
  Serial.println(avail);//problematic line
}

void loop() {
  // put your main code here, to run repeatedly:

}

When i have the line uncommented, the output is:

Ready
Enter input text
'asd&.'
4

When all i have typed is 'asd' (no quotes).
With the line commented out, the output is as expected:

Ready
Enter input text
'asd'

I have no clue how it is happening, and should be physically impossible, since it is changing code before it is called.


texts:
I was wondering if the Arduino is applicable for Industrial monitoring, I want to make a real time status of the presses in our company. I haven't seen or read much about people using Arduino at an Industrial level, most of what I have seen or read are prototype projects.
I'm new in electronics and don't know if there is a better way of doing this rather than using Arduino. I was thinking of using Arduino Uno and Arduino Ethernet Shield or Wifi Shield.

Any help on some information on how to start on this is helpful.


texts: Modifying Arduino IMU library to rely on DSSCircuit's I2C Master Library

texts:
For an Arduino project I am working on, I am trying to modify the SparkFun 6 Degrees of Freedom IMU Digital Combo Board - ITG3200/ADXL345 to support DSSCircuit's I2C Master Library (https://github.com/DSSCircuits/I2C-Master-Library). This is to combat the known issue of the Arduino Wire library to often get hung up while trying to run the EndTransmission function.

I'm new to this and do not understand how the terms 'slave address' and 'register address' and 'bytes you want to send' are different, if they are. I also do not understand how buffering works in the base IMU library. Any information on those would be appreciated, but is not the focus of my question.

I use the example code of the IMU unit...

#include <FreeSixIMU.h>
#include <FIMU_ADXL345.h>
#include <FIMU_ITG3200.h>
#include <Wire.h>
#include <I2C.h>

int raw[6]; // x y z yaw pitch roll

// Set the FreeSixIMU object
FreeSixIMU sixDOF = FreeSixIMU();

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

  delay(100);
  sixDOF.init(); //begin the IMU
  delay(100);
}

void loop() {
  sixDOF.getRawValues(raw);
  Serial.print(raw[0]);
  Serial.print(" x | ");
  Serial.print(raw[1]);
  Serial.print(" y | ");
  Serial.print(raw[2]);
  Serial.println(" z");
  delay(100);
}

And I changed the selected IMU library functions as follows:

// Writes val to address register on device
void ADXL345::writeTo(byte address, byte val) {
  I2c.write(address, val);
  // send register address
}

// Reads num bytes starting from address register on device in to _buff array
void ADXL345::readFrom(byte address, int num, byte _buff[]) {
  I2c.read(address, (byte) num);
  // sends address to read from
}

void ITG3200::writemem(uint8_t _addr, uint8_t _val) {
  I2c.write(_addr, _val);   // start transmission to device
}

void ITG3200::readmem(uint8_t _addr, uint8_t _nbytes, uint8_t __buff[]) {
  I2c.read(_addr, _addr, _nbytes);   // start transmission to device
}

And added the #include <I2C.h> statements to the headers files where applicable.

When running the example code, the serial output will not change values based on how I move the accelerometer, which makes me think I used the wrong slave address to read data from, or some other issue.

Can someone help me modify the IMU library to include DSSCircuit's Master I2C Library?

Thank you Stack Exchange Community!
John

EDIT:

Please see PersonAGem's edit below. Using the wire library is known to have arbitrary hangups, and in this example PersonAGem lists the edits I should make to the other libraries I am using as well as gives me the code I should use in my .ino.

I ask a new question about this topic here.


texts: Is two modules using Serial Interface on one Arduino Uno possible?

texts:
I was wondering if I have both a Bluetooth HC-05 module and a GPS module (uBlox 7N) is it possible both for both to be using the serial interface?

I'm aware they cant be operating simultaneously with one another but if I using the RX TX pins for the GPS module, can I receive a location, store it in a variable then terminate the GPS serial usage and using software serial with 2 pins of my choice transmit data via the Bluetooth module which also requires the serial pins?


texts: MQTT PubSubClient connection problem with ESP32

texts:
I am experiencing some problems with string in Arduino application with ESP32.
I don't understand why this code works:

mqtt.setServer ("m20.cloudmqtt.com", port);  //is OK

and this does not work does not connect

String strSBM = "m20.cloudmqtt.com";
mqtt.setServer (strSBM.c_str (), port);  //no OK

I use library PubSubClient 2.7

Any of you can help me

Many thanks


texts: How to connect HC-06 BT module without pins?

texts:
So, from one popular Chinese  store I ordered a HC-06 module that I received... and due to some mistake from a store, I received a HC-06 without connecting pins. So usually HC-06 looks like this (with blue plate underneath where 4 pins are available to solder or connect):

I just received the one without this blue plate and pins:

How do I connect it to Arduino if there are no pins? Where are usual GND, TX, RX pins (is this schematics correct?)? Is it okay if I just solder a wire to some of them without this blue under-plate?
Also do I need to add some resistors or other components if I connect wires directly to these half-circle pins?
Thank you!


texts:
I am doing a data logger with an Arduino Mega2560 and I want to use a code to make it sleep when no measure is needed and wake it up with an RTC when time comes. The reason I want this is because I intend to run the code on a Pro Mini later so I need to save as much energy as I can. I am able to put the arduino to sleep using the alarm interrupt when a minute is passed but it doesn't wake up from sleep afterwards.

Here is the code I am using:

#include <Wire.h>
#include <RtcDS3231.h>
#include <avr/sleep.h>

const byte interruptPin = 2;
volatile bool alarm = 0;
volatile byte counter = 0;

RtcDS3231<TwoWire> rtcObject(Wire);

void setup() {

  Serial.begin(9600);
  Serial.println("Initialisation");
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), handleInterrupt, FALLING);

  rtcObject.Begin();

  RtcDateTime timestamp = RtcDateTime(__DATE__, __TIME__);
  rtcObject.SetDateTime(timestamp);

  rtcObject.Enable32kHzPin(false);
  rtcObject.SetSquareWavePin(DS3231SquareWavePin_ModeAlarmOne);

  DS3231AlarmTwo alarm2(
    0,
    0,
    0,
    DS3231AlarmTwoControl_OncePerMinute);

  rtcObject.SetAlarmTwo(alarm2);
  rtcObject.LatchAlarmsTriggeredFlags();

}

void loop() {
  if (alarm == true){
    handleAlarm();
    if (counter == 1){
      mesure();
      counter = 0;
      delay(100);
      sleepNow();
    }
  }
}

void handleInterrupt() {
  alarm = true;
  counter ++;
  Serial.println(counter);
}

void handleAlarm() {
  alarm = false;
  rtcObject.LatchAlarmsTriggeredFlags();
}

void mesure(){
  RtcDateTime timestamp = rtcObject.GetDateTime();

  Serial.print("time interrupt at: ");
  char time[10];

  sprintf(time, "%d:%d:%d",
          timestamp.Hour(),
          timestamp.Minute(),
          timestamp.Second()
         );
Serial.println(time);
}

void sleepNow() {
  Serial.println("Entering sleeping");
  delay(100);
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);    // sleep mode is set here
  sleep_enable();                         // enables the sleep bit in the mcucr register
  attachInterrupt(digitalPinToInterrupt(interruptPin),wakeUpNow, FALLING);  // use interrupt 0 (pin 2) and run function
  sleep_mode();                           // here the device is actually put to sleep!!
  // THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP

  sleep_disable();         // first thing after waking from sleep: disable sleep...
  detachInterrupt(digitalPinToInterrupt(interruptPin));      // disables interrupt 0 on pin 2 so the wakeUpNow code will not be executed during normal running time.
}

void wakeUpNow() {
  // execute code here after wake-up before returning to the loop() function
  // timers and code using timers (serial.print and more...) will not work here.
  // we don't really need to execute any special functions here, since we
  // just want the thing to wake up
Serial.println("Woke up");
delay(100);
}

I want to understand how to wake it up properly so I can later make it sleep first in the loop and wake it up only if an interrupt is detected from the rtc.

Thank you for your help !


texts: Is it possible for a HC-05 Bluetooth module to have multiple slaves

texts:
For a project I am interested in using the HC-05 Bluetooth module to control five LEGO Mindstorms Bricks simultaneously. For this to work the Bluetooth module will obviously have to be paired / connected with the five bricks at the same time. This means that the HC-05 Bluetooth module will have to be master in the piconet and the five bricks the slaves.

Is there anyone who has any experience with using the Arduino Uno and HC-05 Bluetooth module to send data to multiple, connected, slaves? If not, are there any alternative Bluetooth modules? And if Bluetooth modules compatible with the Arduino Uno cannot connect to multiple slaves at the same time, are there other ways that an Arduino can control multiple Bluetooth slaves at the same time?


texts:
I want to use the Serial Monitor for some debugging, but it prints something else.
Edit-
This only happens if  I use the attachInterrupt() function
I tried another program that does not use interrupts and there it works.
My code:-

/*
YF‐ S201 Water Flow Sensor
Water Flow Sensor output processed to read in litres/hour
Adaptation Courtesy: www.hobbytronics.co.uk
*/
volatile int flow_frequency; // Measures flow sensor pulses
unsigned int l_hour; // Calculated litres/hour
unsigned char flowsensor = 13; // Sensor Input
unsigned long currentTime;
unsigned long cloopTime;
void flow () // Interrupt function
{
   flow_frequency++;
}
void setup()
{
   pinMode(flowsensor, INPUT_PULLUP);
   Serial.begin(9600);
   attachInterrupt(0, flow, RISING); // Setup Interrupt
   sei(); // Enable interrupts
   currentTime = millis();
   cloopTime = currentTime;
}
void loop ()
{
   currentTime = millis();
   // Every second, calculate and print litres/hour
   if(currentTime >= (cloopTime + 1000))
   {
      cloopTime = currentTime; // Updates cloopTime
      // Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min.
      l_hour = (flow_frequency * 60 / 7.5); // (Pulse frequency x 60 min) / 7.5Q = flowrate in L/hour
      flow_frequency = 0; // Reset Counter
      Serial.print(l_hour, DEC); // Print litres/hour
      Serial.println(" Lhour");
   }
}

Data from Serial Monitor:-
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
⸮⸮⸮⸮⸮⸮ISR not in IRAM!

User exception (panic/abort/assert)
--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Abort called

>>>stack>>>

ctx: cont
sp: 3ffffef0 end: 3fffffc0 offset: 0000
3ffffef0:  feefeffe feefeffe feefeffe 00000100
3fffff00:  000000fe 00000000 00000000 00000000
3fffff10:  00000000 00000000 00000000 00ff0000
3fffff20:  5ffffe00 5ffffe00 3ffef0a4 00000000
3fffff30:  00000001 00000000 3ffee34c 40201e72
3fffff40:  40100402 40202e51 ffffffff 40201e84
3fffff50:  feefeffe 00000001 3ffee34c 40202399
3fffff60:  00000000 00000001 3ffee324 4020129c
3fffff70:  00000000 feefeffe feefeffe 3ffee38c
3fffff80:  3fffdad0 00000000 3ffee34c 40202448
3fffff90:  3fffdad0 00000000 3ffee34c 40201079
3fffffa0:  feefeffe feefeffe feefeffe 40201a80
3fffffb0:  feefeffe feefeffe 3ffe84e4 40100cfd
<<<stack<<<

Why is this happening?
Hardware-ESP8266 based NodeMCU


texts: Arduino based temperature sensing circuit

texts:
I've currently got a setup where I am using a 2 thermocouple setup using MAX31850 and the circuit looks exactly as mentioned here using the external power option. (https://learn.adafruit.com/adafruit-1-wire-thermocouple-amplifier-max31850k/wiring-and-test)

I take the data that is returned from this over serial and pass it over to a simple inverter circuit, which inverts the signal and fluctuates the voltage of a small CREE LED.
The problem that I am encountering is that the data being received from the thermocouples is incorrect when the LED is attached to the setup. And it becomes correct as soon as the LED is detached.

I have tried running my thermocouple set up over an external 5V
supply and using common ground with the Arduino, but it still does
not help.
I have tried using decoupling capacitors on the power rails
to remove any noise due to the LED, but again to no help. What else
can I try to ensure that I can read the data and modulate the LED
simultaneously?


texts: Arduino serial port eats data for 3 seconds before it sends?

texts:
With the source code below, I'm getting what I think to be strange behaviour with the serial port output.

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

int c = 0;
void loop() {
  Serial.println(c++);
}

Presumably what this will do is starting printing incrementing numbers, one on each line, starting from 0. However, my serial monitor only starts printing these numbers after the 3000 mark. I found this behaviour only after discovered in another sketch that I was losing data at the beginning.

Is this normal Arduino behaviour? Or a serial monitor problem? Or something else?


texts:
I've noticed most example snippets always have a delay in the loop even if it's not needed for proper execution of the program.

I can only assume this is added because people copy and paste without understanding what's going on but it got me thinking if adding a delay could possible save power too.

If I have a loop that checks some inputs for changes could it be possible that adding a delay(10) saves some cycles and thus power?


texts: I want turn the led off only when the input is low for a prolonged period of time and not when there are ups and downs in sound signal

texts: My project is baby cry detection,when the baby cries the led must turn on and when it stops it should turn off, but I want it to turn off only when the baby has stopped crying , not when there are ups and downs in the sound . When there is a high in baby sound the led turns on and when there is low the led turns off.  I want the led to stay on and turn it off only when the baby has stopped crying completely . If the input from sound sensor stays low for a prolonged period of time then the led should turn off , how should I write a code for this condition ?


texts: Set control register to low in ds3231 rtc

texts:
I have been using ds3231 rtc module for keep tracking and make alarm along with backup battery. when I used it for first time it worked fine. but now it doesn't keep track my time when the power lose it from main power but I have checked that my battrey is in safe. So I search in lot of forums they said EOSC bit was set high that would be stoped the clock as it stops the internal oscillator. also want to set it into low then only rtc keep track of the time
but in another some forums they instructed that put this following code for set it to low
DS3231 RTC;

  Wire.beginTransmission(0x68);
  Wire.write(0xF);                            // Address the Status register
  Wire.write(0x00);                           //  Zero the Status register
  Wire.endTransmission();
  Wire.beginTransmission(0x68);
  Wire.write(0xE);                            // Address the Status register
  Wire.write(0x00);                           //  Zero the Status register
  Wire.endTransmission();

  RTC.setA2Time( ADay, AHour, AMin, 0x00, true, false, false);
  delay(100);
  RTC.turnOnAlarm( 2 );

in another place showed the following code
// clear /EOSC bit to ensure that the clock runs on battery power
  Wire.beginTransmission(0x68); // address DS3231
  Wire.write(0x0E); // select register
  Wire.write(0b00011100); // write register bitmap, bit 7 is /EOSC
  Wire.endTransmission();

but now problem is that where should I want to place this code and how  to past it in proper manner for keep tracking the time when ds3231 loses power too? please any know about this problem because I finded so many people are strugling with this issue when they come forward to use this ds3231 rtc module. if any body know about how to solve this issue plese consider to share your idea this will definately help full for evryone because there is no one properly answer for this issue


texts: Powering an Arduino Uno using 2 (or as few as possible) AAA batteries

texts:
[Background] I'm constructing a water bottle rocket which is going to use apogee detection and a mechanism for the parachute release.

Connected to the Uno will be an accelerometer and a servo, now due to the need to minimise the dry mass of the rocket I want to use as few and as light batteries as feasible. Would it be possible to power this setup with 2 AAAs? If not how many would be necessary? Would other types of Arduino such as a micro work on fewer batteries?

Thanks for the help


texts: Receive whole string in serial sending data?

texts:
I connect my NodeMCU to Arduino Uno. The goal is to receive the whole string for example "12", every 1 sec.

This is my code on Arduino Uno side ( the sender)

int mock = 0;

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

void loop() {
    //Write mock to NodeMCU
    s.print((int)mock,DEC);
    s.println();

    mock++;
    delay(1000);
}

On NodeMCU side ( the receiver)

 char data; //Initialized variable to store recieved data
 String line;
 void setup() {
   Serial.begin(115200);
   s.begin(115200);
   while (!Serial) {
    ;
  }
}

void loop() {

    if( s.available() >= 2) {
        for (int i = 0; i< 2; i++ ) {
            data = s.read();
            line += data;
        }
        delay(1000);
    }

    Serial.print(line);

}

But the result on the serial panel is not what I expected

How can I make it so that I can receive something like

12
(wait one sec)
13
(wait one sec)
....

Node MCU just prints the whole thing, I can't delay it.


texts: Use server.arg results as a function parameter?

texts:
I've got an ESP8266 (NodeMCU) and I am trying to understand the ESP8266WebServer library, as how to use the results across functions.

In my setup function, I have the following:

   server.on("/marquee", []() {
      varOne = server.arg("baseColor");
      varTwo = server.arg("marqueeColor");
      server.send(200, "text/html", webPage);
      Serial.println("Marquee  activated");
      state = true;
      ledMode = "marquee";
    });

In my loop, I detect the ledMode and if it is set to marquee then it runs the following FastLED function, amongst others:

fill_solid(leds, NUM_LEDS, 0xFF0000);

What I am trying to figure out is how I go from taking a hex color code of say FF0000 from the URL parameter, and use that in my fill_solid function.

server.arg stores get the parameter as a string, so I am not sure what needs to be done.  Also, using a variable name in place of the Hex code in the fill_solid function results in an error due to not expecting the variable


texts:
I have an Arduino GSM Shield mounted on an Arduino Uno. Can I stack this GPS shield above Arduino GSM shield? Will there be any pin configuration problem?

In GSM Shield hardware pin’s configuraton are as below:

0 - Not connected
1 - Not connected
2 - GSM Rx
3 - GSM Tx
7 - Modem reset

If there is any problem, how can it be solved? I would be happy if there are any alternatives for the GPS shield.

Addendum

The schematic of the Arduino GSM shield:

The schematic of the SparkFun GPS shield:


texts: How to connect accelerometer, GPS, microphone and a GSM module to a Arduino?

texts:
I am a noob in the Arduino world and have only started reading about it. I have zero experience with Arduino some suggestions to increase my level will also be highly appreciated. But I have a lot of ideas, I want to work on.

I want to measure the velocity and noise levels with the GPS coordinates of a moving vehicle and send it to my phone using gsm or wifi.
Should I include a small LCD also? again suggestions will be highly appreciated.


texts:
I am trying to amplify a piezo sensor per the instructions found at the link below.  I am not trying to trigger a buzzer only print to the serial monitor whether the vibration was detected or not.  I am a NOOB with respect to circuits and unable to understand why my circuit is not working.

The piezo is either giving a positive (sensing) reading or  giving a negative (not sensing) reading depending on where the poteniometer is set.  There is no state where-if all is quiet-the piezo is quite and if there is a vibration the piezo senses it and reports to the serial monitor.
I see from the blog that if the piezo get stuck on a state to lower the feedback resistor of the op-amp from 220k to 160k but again, there is never a case where it is working then get struck in state.  It is always stuck in a state!

The blog post mentions a 0.1uf capacitor in the hand-drawn sketch but the Fritzing diagram shows a 10uf capacitor.  I am using the 10uf capacitor.  Will switching out the 10uf for a 0.1uf capacitor test potentially damage the Arduino? Is this the cause of the +-state of the piezo? Do I just have a wiring flaw?
Any advice is appreciated.

Here is a link to the post including the Fritzing diagram.
http://davidhoulding.blogspot.com/2014/02/high-sensitivity-vibration-sensor-using.html

Here is a picture of my circuit.

And the Sketch...

#define VIBRATION_DIGITAL_IN_PIN 8
int DurationMillis = 1000;

void setup()
{
  Serial.begin(9600);
  pinMode(VIBRATION_DIGITAL_IN_PIN,INPUT);
}
void loop()
{
  if(digitalRead(VIBRATION_DIGITAL_IN_PIN)==HIGH)
  {
    Serial.println("I felt that");
    delay(DurationMillis);
  }
  else
  {
  Serial.println("I don't feel anything...");
  delay(DurationMillis);
  }
}


texts:
I am programming an ESP8266 module via Arduino IDE. I basically have to use it as a server that can light up a led when a client sends a request.

This is okay but I have to implement it with a NONCE and AES encryption system to prevent replay attacks. My problem is that my esp server has to send a value to a client but I only saw the ESP as a data receiver and I can't send custom strings.
This is my code but it does not work because I have problems with the serverClients[i].write(randomstr,4); function

I highlighted the non working part of the code

#include <ESP8266WiFi.h>

#define RANDOM_REG32  ESP8266_DREG(0x20E44)
#define MAX_SRV_CLIENTS 3
const char* ssid = "********";
const char* password = "********";

WiFiServer server(7000);
WiFiClient serverClients[MAX_SRV_CLIENTS];

void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
delay(5000);
Serial.print("\nConnecting to "); Serial1.println(ssid);
server.begin();
server.setNoDelay(true);
Serial.print("Ready! Use 'port ");
Serial.print(WiFi.localIP());
Serial.println(" 7000' to connect");
}

void loop(){
uint8_t i;
if (server.hasClient()){
for(i = 0; i < MAX_SRV_CLIENTS; i++){
if (!serverClients[i] || !serverClients[i].connected()){
if(serverClients[i]) serverClients[i].stop();
serverClients[i] = server.available();
continue;
}
}
//no free spot
WiFiClient serverClient = server.available();
serverClient.stop();
}
for(i = 0; i < MAX_SRV_CLIENTS; i++){
if (serverClients[i] && serverClients[i].connected()){
if(serverClients[i].available()){
while(serverClients[i].available()) Serial.write(serverClients[i].read());

//THIS IS THE NON WORKING PART
long randNumber = RANDOM_REG32 % 10000;
 Serial.println(randNumber);
String randomstr = String(randNumber);
 serverClients[i].write(randomstr,4);
}
}
}

if(Serial.available()){
size_t len = Serial.available();
uint8_t sbuf[len];
Serial.readBytes(sbuf, len);

for(i = 0; i < MAX_SRV_CLIENTS; i++){
if (serverClients[i] && serverClients[i].connected()){
serverClients[i].write(sbuf, len);
delay(1);
}
}
}
}

I guess I have some problems with char arrays, strings, etc... but I can't make it work


texts: Getting the DS18B20 detected and temperature read

texts:
I'm quite new with the electronics part of Arduino, but I thought that this was the basic way to get the DS18B20 temperature device hooked up. However, I can't detect it in my program using OneWire and DallasTemperature.

This is an image of my connections:

Basically my approach was like this:

Connect ground on ground on the DS18B20.
Connect 5V from the Arduino to both DQ from the DS18B20 and Port 2 on my Arduino (the two yellow cables).
Between the 5V and the two yellow cables, I connected a 4.7K resistor.
Vdd on the DS18B20 is not connected to anything.

Anyone have any idea why this is not working as expected for me?

Thanks in advance!


texts:
I have a simple sample of code that i want to convent a time_t to char array in order to concatenate it after, in an other array.
Code:

time_t unixt;
char exm [40];

unixt = RTC.get();
Serial.println(unixt);
dtostrf(unixt, 10, 0, exm);
Serial.println(exm);

The problem that i face is that, the console is printing different the second one every time like this:

1548258220
1548258200

I tried also with unsigned long with no result either. Can someone point me what's wrong or an other way of doing this?


texts:
I am using the pin 4 as an OUTPUT and pin 8 as an INPUT to turn on/off the light, but for some reason it is not working. Light is on all the time, but when I try to input something it gets brighter and doesn't turn off when I don't give anything to pin 8.

LED is connected to pin 4 with a 220 R, and the other side to GND. When pin 8 is connected to 5V pin then the light should come on, and off when I disconnect them.

Here is the code:

void setup()
{
  Serial.begin(9600);
  pinMode(4, OUTPUT);
  pinMode(8, INPUT);
}

void loop()
{
   bool on = digitalRead(8);
   if(on)
   {
     digitalWrite(4, HIGH);
   }
   else
   {
     digitalWrite(4, LOW);
   }
}

What am I doing wrong?


texts: Serial.begin(): Why not always use 28800?

texts:
In a lot of the sample code online people add the line Serial.begin(9600) in the setup block.

When I look up what Serial.begin() is on the official documentation, it says that it controls the bit per second data transfer.

So the obvious question is, why not use 28800, the highest transfer rate? Why do people settle for 9600? What is the limitation here?


texts: Can I turn off a device using the 5V and analog pins?

texts:
Could I connect a device that requires minimum 5V 1A from the 5V Pin to the Ground and somehow turn it off inside  a sketch?

edit: I'm using a Due based boad, the digix http://digistump.com/wiki/digix/tutorials/basics


texts: Need assistance with program for POV Project

texts:
I've created a very basic POV project.

It has a 12V DC motor with a piece of wood on it.
The wood has 6 LEDs on it as well as a copper ring.
The power is delivered to the LEDs from brushes connecting to the copper ring and from the shaft of the motor (the ground is attached to the base of the motor.) I'm using a TCRT5000L Sensor to count the RPM and have attached the LEDs to pin 13 and ground of the Arduino. (I've attached white tape to one side of the wood so that the sensor only counts one rev.)

I need help (please) with the program.

This is the code that I am using:

int pin = 13;
volatile  int tcnt = 0;
volatile  int lastcount = 0;
volatile int state = LOW;

void setup() {
  Serial.begin(9600);
  pinMode(pin, OUTPUT);
  attachInterrupt(1, blink, RISING);
}

void loop() {
  Serial.println(tcnt);
  if (tcnt != lastcount)
  {
     digitalWrite(pin, HIGH);
     delay(10);
     digitalWrite(pin, LOW);
     delay(10);
     lastcount = tcnt;
  }

   delay(10);

}

void blink() {
  tcnt = tcnt + 1;
  state = !state;
}

My first issue is that the when I use the code above, the lights don't seem to switch on / off on the exact same area. They are within 30 degrees but certainly not precise.

The second issue (and the biggest) is that I'm sure that this code is not the best way to do what I need. For example, if I wanted to use this as an analog clock, so that the lights would only show on the current hour / minute, how would I do this?

Any help is greatly appreciated.


texts:
I'm kind of stuck with strange behaviour of my code and I really hope, someone could help me..

Objective
I'm trying to build a (multiple) magnetic stirring device with which I can either control the speed via potentiometer or via serial commands from a python script from pc (usb).
When the speed is set via serial, it shouldn't be possible to interfere with the potentiometer unless a button is pressed to unlock it.

Code

// Constants

const int FanPin[7] = {2,3,5,6,7,8,9}; // PWM Pins 2,3,5,6,7,8,9 for fan
const int PotiPin[7] = {A0,A1,A2,A3,A4,A5,A6}; // Analoge Pins 0,1,2,3,4,5,6 for potentiometers
const int SwitchPin[7] = {30,31,32,33,34,35,36}; // Digital Pins 30, 31, 32, 33, 34, 35, 36 for switches

// Variables
boolean ManualLock = false; // will be true if locked by serial input
int Fan[7][2] = { // [x][] for number of fan, [][0] for fan speed, [][1] for ManualLock
  {0, ManualLock},
  {1, ManualLock},
  {2, ManualLock},
  {3, ManualLock},
  {4, ManualLock},
  {5, ManualLock},
  {6, ManualLock}
};
int temp = 0; // Variable for temporary data
int FanSpeed[7] = {0,0,0,0,0,0,0}; // Variable fan speed
int PotiVar[7] = {0,0,0,0,0,0,0} ; // Variable for saving poti-input
byte bfr[2] = {7,7}; // Buffer for serial data

void setup() {

TCCR2B = TCCR2B & 0b11111000 | 0x01; // Timer2 (Pin 9, 10) @ 31000Hz
TCCR3B = TCCR3B & 0b11111000 | 0x01; // Timer3 (Pin 2, 3 und 5) @ 31000Hz
TCCR4B = TCCR4B & 0b11111000 | 0x01; // Timer4 (Pin 6, 7 und 8) @ 31000Hz

Serial.begin(9600);
delay(100);

// Declaration of Pin Modes
for (int i = 0; i < 7; i++){
  pinMode(FanPin[i], OUTPUT);
  pinMode(PotiPin[i], INPUT);
  pinMode(SwitchPin[i], INPUT);
  }
}

void loop() {
for (int i = 0; i < 7; i++){
  // ManualLock not active -> manual mode
  if (!Fan[i][1]){
    //Serial.print(i);
    //Serial.println(" ManualLock not active");
    PotiVar[i] = analogRead(PotiPin[i]);
    Fan[i][0] = map(PotiVar[i], 51, 1023, 60, 255);
    //Serial.println(Fan[i][0]);
  }
  //ManualLock active -> unlock by pressing button
  if (Fan[i][1]){
    temp = digitalRead(SwitchPin[i]);
    if (temp == HIGH){
      Serial.print(i);
      Serial.println(" ManualLock will be deactivated");
      Fan[i][1] = false;
      Serial.print("Fan[i][1]: ");
      Serial.println(Fan[i][1]);
    }
  }

  // fan off @ low poti setting
  if (PotiVar[i] < 50){
    Fan[i][0] = 0;
  }
}

// look for serial data

if (Serial.available()){
  Serial.println("Something's there!");
  Serial.readBytes(bfr, 2);
  delay(1000);
  Serial.print("Serial data: ");
  Serial.println(bfr[0]);
//  Serial.flush();
}

//Serial.print("before loop bfr[0]: ");
//Serial.println(bfr[0]);

for (int i = 0; i < 7; i++){
  if (i == int(bfr[0])){
    Serial.print("i: ");
    Serial.println(i);
    Fan[i][0] = int(bfr[1]); //set fan speed variable
    Fan[i][1] = true; // activate ManualLock variable
    byte bfr[2] = {7,7}; // clear buffer
    Serial.print("bfr[0]: ");
    Serial.println(int(bfr[0]));
  }
}

for (int i = 0; i < 7; i++){
  analogWrite(FanPin[i], Fan[i][0]); // write fan speed
  }
}

Error(s)

When I send a command via my python script, the speed is set correctly and I get the following output:

Something's there!
Serial data: 0
i: 0
bfr[0]: 7
i: 0
bfr[0]: 7
...and again and again and again...

Which means, although i "reset" my buffer variable to something that should prevent entering the if-statement, it will somehow fulfill the "if (i == int(bfr[0]))" condition.. but why?
If any further information is needed, i'll happily provide that.


texts: Reading JSON from Arduino over serial in python and writing to a JSON file on computer

texts:
I'm fairly new to Arduino so I used a sample code before integrating this into my main code. I'm printing my value in a JSON format over serial. My Arduino outputs this and the python receives this and prints it in the same format
{

"value" : 5

}

but when I use python to try writing to a JSON file on my computer, I'm not getting the same JSON format. Can anyone figure out what's wrong? I need to write to my JSON file in JSON format, but instead, I'm getting this format written in my JSON file "  \"value\": 5\r\n" instead of {"value: 5"}. Another problem I'm getting is that sometimes the values I get in my JSON get cut off so sometimes I end up with \r\n" or other parts of the current output. My goal is to get the python code to overwrite the JSON file in real-time, so whenever I open the JSON file, the entire output should be there in the correct JSON format. Any help is appreciated, thank you.
Arduino Code:
#include <ArduinoJson.h>

int analogPin = 3;
int data = 0;
char userInput;

StaticJsonDocument<100> testDocument;
char buffer[100];

void setup(){

  Serial.begin(9600);          //  setup serial

  StaticJsonDocument<100> testDocument;

  testDocument["sensorType"] = "Temperature";
  testDocument["value"] = 10;

  char buffer[100];

  serializeJsonPretty(testDocument, buffer);

  Serial.println(buffer);

}
int(i)=1;
void loop(){

    testDocument["value"] = i;

    serializeJsonPretty(testDocument, buffer);

    Serial.println(buffer);

    i=i+1;
 }

Python Code:
import serial
import json
import time

ser = serial.Serial('COM4', baudrate = 9600, timeout=1)

while 1:

    data = (ser.readline().decode('ascii')) #split('\r\n')

    #j = json.loads(data)

    file = "C:/Users/Mike/Desktop/test.json"

    my_data_file = open(file, 'w')

    with open(file1, "w") as my_data_file :
        json.dump(data, my_data_file)

    print(data)


texts: Difference between ISR and other functions in AVR twi library

texts:
I was studying the ISR for twi and I want to know how is it working.

I have two questions about the code handling for ISR and the other functions and what they do exactly:

My first question is about how ISR for twi is working? The following example shows a piece of the ISR for twi library. My concern here is how switch statement is working?

And probably I have to understand how TWSR works; for example, I think when twi module sends or receive an address, the TWSR is updated according to TWSR Status codes. But I really don't understand exactly what is happening?! Which happens first?

The programmer issue the twi operation; like, sending a start address. Then, the TWSR is updated with the code 0x08 which means according to the datasheet "A START condition has been transmitted". If that so, then why in the following ISR code. The status code is called as a switch result for twi operation, then it issue an action based on that??!! that what is confusing to me!
So, is the procedure of twi:
1. Send start address.
2. TWSR is updated with 0x08 as a confirmation for the start action.
3. Here the ISR issues another action based on the TWSR again? This is what I didn't understand.

ISR(TWI_vect)
{
  switch(TW_STATUS){
    // All Master
    case TW_START:     // sent start condition
    case TW_REP_START: // sent repeated start condition
      // copy device address and r/w bit to output register and ack
      TWDR = twi_slarw;
      twi_reply(1);
      break;

My second question is about the relationship between ISR and other functions. For example,

  if (true == twi_inRepStart) {
twi_inRepStart = false;
do {
  TWDR = twi_slarw;
} while(TWCR & _BV(TWWC));
TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE);
}
else
TWCR = _BV(TWINT) | _BV(TWEA) | _BV(TWEN) | _BV(TWIE) | _BV(TWSTA);
while(wait && (TWI_MTX == twi_state)){
continue;
}

Here is another start send address operation. So which one is the real one? The start send in the ISR or this one?


texts:
Im trying out this membrane from Adafruit that i bought last week but i have a little issue. ITS SO SENSITIVE! i as so just touch it with my finger and it transmits!. Anyone that has worked with this membrane have the same issue? is there some sort of "fix"?

UPDATE

Its really simple. But one weird thing, not sure if its supposed to be like that, but by default, the buttons are on HIGH. i used Serial.println(digitalRead(one)); to verify that and the output was 1.

int two =  8;
int one = 9;
int four = 10;
int three = 11;

void setup() {
  pinMode(one, INPUT);
  pinMode(two, INPUT);
  pinMode(three, INPUT);
  pinMode(four, INPUT);
  Serial.begin(9600);
}

void loop() {
  if(digitalRead(one) == LOW){
    Serial.println("One");
  }else if(digitalRead(two) == LOW){
    Serial.println("Two");
  }else if(digitalRead(three) == LOW){
    Serial.println("Three");
  }else if(digitalRead(four) == LOW){
    Serial.println("Four");
  }
}


texts: How to use Arduino Pro Mini without Programmer

texts: I'm a software engineer, but I'm not too skilled at understanding hardware design yet. I'm trying to learn how to use an Arduino Pro Mini board without the programmer connected, so I can actually make fun toys, etc. Currently, the software will only run when connected to the programmer (or at a minimum with the SCK pins connected to each other). I have been searching online for days, and I think I need a crystal or resonator hooked up somehow, but I can't figure out how to hook them up (which pins). I bought 5 16 MHz ceramic resonators, and I have them right here with me, but I can't find the answers online how to hook it up and have the board run stand alone. Any ideas? Thank you in advance.


texts:
I'm configuring an ESP8266 using Arduino Uno.

I have several MQTT topics I wish it to subscribe, and I do not want to repeat code 3 or 4 times ( in Python I would have created a list - and make a for loop to subscribe all )

These are my topics:

//MQTT topic
const char* deviceName = "Sonoff1";
const char* deviceTopic = "HomePi/Switches/Sonoff1";
const char* msgTopic = "HomePi/Messages";
const char* groupTopic = "HomePi/All";

This is the function registering a single topic:

void reconnect() {
        // Loop until we're reconnected
        while (!client.connected()) {
                Serial.print("Attempting MQTT connection...");
                // Attempt to connect
                if (client.connect(deviceName,user, passw)) {
                        Serial.println("connected");
                        pub_msg("Power On");
                        client.subscribe(deviceTopic);
                } else {
                        Serial.print("failed, rc=");
                        Serial.print(client.state());
                        Serial.println(" try again in 5 seconds");
                        // Wait 5 seconds before retrying
                        delay(5000);
                }
        }
}

Appriciate you kind help,

Guy


texts: Can 2 or more LED strobe Lights Flash in Sync?

texts:
I'm trying to build a strobe light that has at least 1 mode that can sync with another unit.

The strobe light has 2 colors, white and red which are driven by 2 qlite drivers which are controlled by an ATtiny13a processor.

The strobe light will be used on an ultralight aircraft. I want the ability to have the lights sync, so if there are a few aircraft flying, each strobe would be in sync and creating a better chance of being seen as a collective.

The easiest way to see this is from obstruction lights on windfarms. https://www.youtube.com/watch?v=bb7MWrBEZjU  They are mandated by FAA to be in sync. I believe they achieve this by matching internal processor clock speeds with the GPS clock data.

Or could I use a Real Time Clock to time the processors together?

If I'm already using Qlite flashlight drivers which use ATtiny13 chips, is there any way I can get the different lights to sync?

The body is a standard flashlight body.

Thanks in advance,


texts: Why a servo doesn`t move to angles properly

texts:
I've got to do a project which uses a servo to drive a turntable.
How much I adjusted the angle, the servo seemed to shift every time it spinned. For instance, the 0 degree angle was getting a bit bigger. I think it is caused by the imprecise PWM control of the Arduino or the bad translation using, I think, the map() function.

Could you fix this issue in code, or the servo doesn't work properly. I observed that every servo (that I've tried) creates a buzzing noice for angles bigger than 170 degrees.

By the way, my code is:

#include

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

#define pos0 0
#define pos1 23
#define pos2 48
#define pos3 164

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  Serial.begin(9600);
}

void loop() {
  for (pos = pos0; pos  pos0; pos -= 1) {
    myservo.write(pos);
    delay(30);
  }
  Serial.print("pos: ");
  Serial.println(pos);
  delay(5000);
}

Edit: Should I try with a more powerful Arduino, like the Mega, which I think will be the perfect option having more GPIO than the UNO.


texts: LCD display interfaced with Arduino Uno not displaying values

texts:
I am a beginner on Arduino. I have a project that I will only be using: a heart rate sensor whose values I am displaying on an LCD display. The code compiles and uploads once I set my project up, but the value doesn't appear on my LCD screen.
#include<LiquidCrystal.h>
#include <TimerOne.h>

LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
int HBSensor = 4;
int HBCount = 0;
int HBCheck = 0;
int TimeinSec = 0;
int HBperMin = 0;
int HBStart = 2;
int HBStartCheck = 0;

void setup() {
  lcd.begin(20, 4);
  pinMode(HBSensor, INPUT);//heartbeat sensor
  pinMode(HBStart, INPUT_PULLUP);
  Timer1.initialize(800000);
  Timer1.attachInterrupt(timerIsr);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Current HB: ");
  lcd.setCursor(0, 1);
  lcd.print("Time in Sec :");
  lcd.setCursor(0, 2);
  lcd.print("HB per Min :0.0");
}

void loop() {
  if (digitalRead(HBStart) == LOW) {
    lcd.setCursor(0, 3);
    lcd.print("HB Counting ..");
    HBStartCheck = 1;
  }
  if (HBStartCheck == 1) {
    if ((digitalRead(HBSensor) == HIGH) && (HBCheck == 0)) {
      HBCount = HBCount + 1;
      HBCheck=1;
      lcd.setCursor(14, 0);
      lcd.print(HBCount);
      lcd.print(" ");
    }
    if ((digitalRead(HBSensor) == LOW) && (HBCheck == 1)) {
      HBCheck=0;
    }
    if (TimeinSec == 10) {
      HBperMin=HBCount * 6;
      HBStartCheck=0;
      lcd.setCursor(14, 2);
      lcd.print(HBperMin);
      lcd.print(" ");
      lcd.setCursor(0, 3);
      lcd.print("Press Button again.");
      HBCount = 0;
      TimeinSec = 0;
    }
  }
}

void timerIsr() {
  if (HBStartCheck == 1) {
    TimeinSec = TimeinSec + 1;
    lcd.setCursor(14, 1);
    lcd.print(TimeinSec);
    lcd.print("");
  }
}


texts: I would like to make a hour counter for a particular machine.I have a problem in coding.arduino internal clock can work only till 49 days.my hour counter should calculate 150+ hours.I thought of using a condition to store a particular value and add with next value.How can I code adding values to a variable


texts: Communication between python script and Arduino sketch

texts:
I'm trying to transfer data beetween the two scripts. I'm already using the YunMesseger library (https://github.com/plotly/YunMessenger). But it only make the

Arduino -> Python

communication.
I would like to know how to make the reverse way.

I would like to point that I'm search for a solution that doesn't involve the use of the Bridge, because I don't want to have concurrency problems.


texts: Why is one part of my code being executed over the part before it?

texts:
The following code doesn't behave the way I would like it to. Inside the loop function im measuring the distance in front of the robot and if it is less than 15cm than the robot should move back and if it is less than 15cm on the left then move forward. When i run the program however only the left side is being checked and acted upon whilst the the if statement about the front and moving back is not doing anything. Something to note also is that when i swap the if statements and put the front checking ahead of the left checking it works but the left side is no longer being checked. Why is it that the if statement block in front is being executed over the previous one?

     void loop(){

     if(front.calculateDistance() < 15){
     MoveBack(200);
     }else{
      stopMoving();
     }

      if(left.calculateDistance() < 15){
     MoveForward(200);
     }else{
      stopMoving();
     }
   }

This is what the move methods do (move back and stopmoving just change input directions):

void MoveForward(int rspeed) {
 // turn on motor A
 digitalWrite(in1, HIGH);
 digitalWrite(in2, LOW);
 analogWrite(enA, rspeed);
 // turn on motor B
 digitalWrite(in3, HIGH);
 digitalWrite(in4, LOW);
 analogWrite(enB, rspeed);
}


texts:
I am trying to convert the signal from digital pin 2 on my Uno to 3.3V.  I set up a voltage divider with 3 x 1000 ohm resistors.  When connected to ground and 5V the divider circuit generates 3.3V correctly, with a calculated input current of 1.7mA.  However I connect it to a digital pin, the digital pin voltage drops from 4.8V to .37V.  I thought the digital pins were to support 40mA, I was assuming 40mA at the 5V supply voltage.  Is my Uno malfunctioning?

Thanks


texts:
I'm new to Arduino and I'd like to realize a system using Arduino One and SparkFun Electret Microphone Breakout (BOB-09964) to turn on/off lights clapping my hands. https://www.sparkfun.com/products/9964

What are the components I need? I'm going to buy them and I don't want to buy components which I will not use soon (so no starter kits but only a breadboard, resistors, LEDs, etc...).

Sorry for this basic question but as I said I'm new to this world.


texts: ESP8266 HttpClient recursive connections to URL to send sensor data

texts:
I am developing a project based in Arduino Nano and 2 sensors. In this projects is very important the energy because of the prototype is going to be powered by batteries or solar power.
In order to save energy in the
void loop(){....}

I am only getting the value of a temperature sensor continuously in a method that returns true / false.
When the method returns true, one relay is activated by Arduino, and it provides energy to the ESP8266-01 module and other sensor.
At this moment I need to connect the ESP8266 to WiFi network, and after the WiFi connection is successfully, I need to read other sensor value 50 times and make a connection with
client.connect(server, 80)

and send sensor data with GET method to upload every sensor value to server.
In this way I am able to send the first read, but for further sensor reads the connection to server gives error
My code resumed:
void setup(){
  // Setup sensors...
}

void initWifi(){
  // Open ESP8266 connection to WiFi network
}

boolean tempetarure_read(){
  // read continuously the temp sensor...
}

void loop(){
  if(tempetarure_read()){
    digitalWrite(relayPin, HIGH); //Open relay to give energy to ESP8266 module
    read_other_sensor_and_send_to_server();
    digitalWrite(relayPin, LOW); // Switch off the relay
  }
}

void read_other_sensor_and_send_to_server(){
  for (int x = 0; x < 50; x++) {
    string sensor_data = get_sensor_data();

    Serial.println();
    Serial.println("Starting connection to server...");
    // if you get a connection, report back via serial
    if (client.connect(server, 80)) {
        Serial.println("Connected to server");
        // Make a HTTP request
        //client.println("GET /asciilogo.txt HTTP/1.1");
        client.print("GET /sensor/store?");
        client.print(sensor_data);
        client.println(" HTTP/1.1");
        client.println("Host: my.server.com");
        client.println("Connection: close");
        client.println();
    }

    String res="";
    while (client.available()) {
        char c = client.read();
        res += c;
    }

    client.flush();
    client.stop();
    delay(1000);

  } // end for
}

I get
[WiFiEsp] Connecting to my.server.com
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] Disconnecting  3

but the module is connected to wifi and my.serever.com is online. Can anybody help me to solve this issue?
Thanks in advance


texts: Multiple libraries were found for "WiFiClient.h" using nodemcu

texts:
I am trying to send HTTP requests from nodemcu so I started by uploading the esp8266 library but when I run the following code

#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>

void setup() {

  Serial.begin(115200);                                  //Serial connection
  WiFi.begin("Iphone de elaa", "27343550");   //WiFi connection

  while (WiFi.status() != WL_CONNECTED) {  //Wait for the WiFI connection completion

    delay(500);
    Serial.println("Waiting for connection");

  }

}

void loop() {

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

   HTTPClient http;    //Declare object of class HTTPClient

   http.begin("http://localhost:8080/getallcadres/getnbpassage/5");      //Specify request destination
   http.addHeader("Content-Type", "text/plain");  //Specify content-type header

   int httpCode = http.POST("5");   //Send the request
   String payload = http.getString();                  //Get the response payload

   Serial.println(httpCode);   //Print HTTP return code
   Serial.println(payload);    //Print request response payload

   http.end();  //Close connection

 }else{

    Serial.println("Error in WiFi connection");

 }

  delay(30000);  //Send a request every 30 seconds

}

i got this error

Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Generic ESP8266 Module, 80 MHz, Flash, Disabled, All SSL ciphers (most compatible), ck, 26 MHz, 40MHz, DOUT (compatible), 512K (no SPIFFS), 2, nonos-sdk 2.2.1 (legacy), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

Build options changed, rebuilding all
In file included from C:\Users\ELA_HIDRI\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src/WiFiClientSecure.h:41:0,

                 from C:\Users\ELA_HIDRI\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src/WiFiServerSecure.h:20,

                 from C:\Users\ELA_HIDRI\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src/ESP8266WiFi.h:41,

                 from C:\Users\ELA_HIDRI\Desktop\PFE_ING\nodemcu\nodemcu.ino:2:

C:\Users\ELA_HIDRI\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src/WiFiClientSecureBearSSL.h:38:5: error: 'BearSSL::WiFiClientSecure::~WiFiClientSecure()' marked override, but does not override

     ~WiFiClientSecure() override;

     ^

C:\Users\ELA_HIDRI\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src/WiFiClientSecureBearSSL.h:41:9: error: 'int BearSSL::WiFiClientSecure::connect(const String&, uint16_t)' marked override, but does not override

     int connect(const String& host, uint16_t port) override;

         ^

C:\Users\ELA_HIDRI\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src/WiFiClientSecureBearSSL.h:46:12: error: 'size_t BearSSL::WiFiClientSecure::write_P(const char*, size_t)' marked override, but does not override

     size_t write_P(PGM_P buf, size_t size) override;

            ^

C:\Users\ELA_HIDRI\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src/WiFiClientSecureBearSSL.h:58:12: error: 'size_t BearSSL::WiFiClientSecure::peekBytes(uint8_t*, size_t)' marked override, but does not override

     size_t peekBytes(uint8_t *buffer, size_t length) override;

            ^

Multiple libraries were found for "WiFiClient.h"
 Used: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\libraries\WiFi
 Not used: C:\Users\ELA_HIDRI\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi
exit status 1
Error compiling for board Generic ESP8266 Module.

so what is this error why i am getting it
Edit
i switched to an other version of arduino ide 1.6.5 the error is gone but it looks like it is not connection i got


texts: Problems compiling with enum value PORT1-7

texts:
So I have this enum in a header file:

enum class ServoPort {PORT1 = 1, PORT2, PORT3, PORT4, PORT5, PORT6};

The trouble is that when I try to use it in the primary file (by doing MyClass::ServoPort::PORT1) I get a compile error:

exit status 1
expected unqualified-id before numeric constant

However, if I change the enum to be like so:

enum class ServoPort {PORT8 = 1, PORT9, PORT10, PORT11, PORT12, PORT13};

Then I do not get a compile error. What the heck? Can someone please shine some light on why this is happening?

Board: UNO R3
IDE: v1.8.5


texts: Problem in AT+CIPSEND(CTRL-Z) GPRS GMS A6

texts:
I am using GPRS GSM A6 with arduino uno to post data to web server. After sending AT commands to module I get OK response after every command,

AT+CIPMUX=0

OK
AT+CGATT=1

OK
AT+CSTT="internet","",""

OK
AT+CIICR

OK
AT+CIFSR

10.65.87.210

OK
AT+CIPSTART="TCP","xxx.xxx.xxx.xxx", 80

CONNECT OK

OK
AT+CIPSEND

> POST http://xxx.xxx.xxx.xxx/Code/ HTTP/1.1
Host: xxx.xxx.xxx.xxx
Content-Type: application/x-www-form-urlencoded
Content-Length: 18

Data=GPS Data Sent
AT+CIPCLOSE

>

To terminate AT+CIPSEND you have to send CTRL-Z. I am sending CTRL-Z using this statement in code,

Serial.write(0x1A)

But the module doesnot respond to this, and treats the next command (AT+CIPCLOSE) as data.

Please Help... Thanks in Advance!!!


texts: I am needing to combine the code for a GPS puck and a BME680

texts:
GPS Code:
#include <SoftwareSerial.h>

SoftwareSerial gpsSerial(10, 11); // RX, TX (TX not used)
const int sentenceSize = 80;

char sentence[sentenceSize];

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

void loop()
{
  static int i = 0;
  if (gpsSerial.available())
  {
    char ch = gpsSerial.read();
    if (ch != '\n' && i < sentenceSize)
    {
      sentence[i] = ch;
      i++;
    }
    else
    {
     sentence[i] = '\0';
     i = 0;
     displayGPS();
    }
  }
}

void displayGPS()
{
  char field[20];
  getField(field, 0);
  if (strcmp(field, "$GPRMC") == 0)
  {
    Serial.print("Lat: ");
    getField(field, 3);  // number
    Serial.print(field);
    getField(field, 4); // N/S
    Serial.print(field);

    Serial.print(" Long: ");
    getField(field, 5);  // number
    Serial.print(field);
    getField(field, 6);  // E/W
    Serial.println(field);
  }
}

void getField(char* buffer, int index)
{
  int sentencePos = 0;
  int fieldPos = 0;
  int commaCount = 0;
  while (sentencePos < sentenceSize)
  {
    if (sentence[sentencePos] == ',')
    {
      commaCount ++;
      sentencePos ++;
    }
    if (commaCount == index)
    {
      buffer[fieldPos] = sentence[sentencePos];
      fieldPos ++;
    }
    sentencePos ++;
  }
  buffer[fieldPos] = '\0';
}

BME680 Code:
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BME680.h"

#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME680 bme; // I2C
//Adafruit_BME680 bme(BME_CS); // hardware SPI
//Adafruit_BME680 bme(BME_CS, BME_MOSI, BME_MISO,  BME_SCK);

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

  if (!bme.begin()) {
    Serial.println("Could not find a valid BME680 sensor, check wiring!");
    while (1);
  }

  // Set up oversampling and filter initialization
  bme.setTemperatureOversampling(BME680_OS_8X);
  bme.setHumidityOversampling(BME680_OS_2X);
  bme.setPressureOversampling(BME680_OS_4X);
  bme.setIIRFilterSize(BME680_FILTER_SIZE_3);
  bme.setGasHeater(320, 150); // 320*C for 150 ms
}

void loop() {
  if (! bme.performReading()) {
    Serial.println("Failed to perform reading :(");
    return;
  }
  Serial.print("Temperature = ");
  Serial.print(bme.temperature);
  Serial.println(" *C");

  Serial.print("Pressure = ");
  Serial.print(bme.pressure / 100.0);
  Serial.println(" hPa");

  Serial.print("Humidity = ");
  Serial.print(bme.humidity);
  Serial.println(" %");

  Serial.print("Gas = ");
  Serial.print(bme.gas_resistance / 1000.0);
  Serial.println(" KOhms");

  Serial.print("Approx. Altitude = ");
  Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
  Serial.println(" m");

  Serial.println();
  delay(2000);
}

I have both sensors working separately but cannot seem to get the codes to work together.


texts: Arduino IDE in conflict with pyserial for use of serial port in OSX Yosemite

texts:
I'm trying to communicate with an Arduino Uno via pyserial using a code that I wrote for Ubuntu. However, when I try to use the same code in OSX Yosemite after identifying the serial port for the case of OSX, it doesn't work. This is the offending line:

In [32]: ser = serial.Serial('/dev/cu.usbmodem1421', 9600)

If I run the above line when the Arduino IDE is not running there is no error message, but the Arduino doesn't do anything (the Arduino IDE Serial Monitor must be open in order for the code to work). However, if I open the Arduino IDE and use the Serial Monitor (which works fine, i.e. it shows data that the Arduino is sending), I get the following error message:

SerialException: [Errno 16] could not open port /dev/cu.usbmodem1421: [Errno 16] Resource busy: '/dev/cu.usbmodem1421'

If I run lsof | grep /dev/cu.usbmodem1421 then I get that the only program using said port is Arduino IDE:

Arduino   2012 germanchaparro   94u     CHR               18,7   0t15249    1285 /dev/cu.usbmodem1421

Clearly OSX is not letting Arduino IDE and pyserial to use the serial port (to which the Arduino UNO is connected) at the same time. I don't know how to fix this, and it's especially frustrating since Ubuntu doesn't put up a fight.

Any ideas?


texts:
I have bought an Arduino UNO that turned out to be the Italian version (Arduino SRL) not the American one (Arduino LLC).

Now when I go to arduino.org and arduino.cc, they both have different versions of the IDE!

So, which one should I use (if they are even different) ?


texts: I have a genuine (purchased from Adafruit) Arduino Leonardo that I have had for 2 years and I have not had any issues with. However, I have always noticed that it seems to be running suspiciously hot for a low power microcontroller, sometimes even too hot to comfortably touch. I measured the temperature today with an infrared thermometer at 121 degrees Fahrenheit (~49C). Based on observations by feeling the board, the 32U4 seems to be what is getting hot and everything else is cool to the touch. This happens when it is powered over USB as well as through the power jack. The chip gets hot even when nothing is connected to the I/O or power pins. The board is entirely working and does not appear visibly damaged. I am a bit worried about this as I may use this board in a project where it will be inside in enclosure and running for long periods of time. Any ideas why this is happening and if this normal?


texts: Problem on multiple interrupts operation on Arduino Uno

texts:
I experimenting with the interrupt ISR using Arduino Uno. In my circuit, I am taking two switches which are connected with Uno's interrupt pins, pins 2 and 3, and also taking multiple LEDs which are connected with other pins.

My logic is when I press switch1 (which is connected to pin 3) LEDs should be turned on by the interrupt service routine and when I press switch2 (which is connected to pin 2) LEDs should be turned off by the interrupt service routine.

My problem is that when I pressed switch1 LEDs are turned on but when I pressed switch2 LEDs are not turned off.

Here's my code:

int switch1 = 3;
int switch2 = 2;
int led1 = 13;
int led2 = 12;
int led3 = 11;
int led4 = 10;
int led5 = 9;
int led6 = 8;
int led7 = 7;
volatile bool flag1 = false;
volatile bool flag2 = false;
//volatile byte state = LOW;

void setup()
{
  pinMode(switch1, INPUT_PULLUP);
  pinMode(switch2, INPUT_PULLUP);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led5, OUTPUT);
  pinMode(led6, OUTPUT);
  pinMode(led7, OUTPUT);
  attachInterrupt(digitalPinToInterrupt(switch1), &setFlag1, CHANGE);
  attachInterrupt(digitalPinToInterrupt(switch2), &setFlag2, CHANGE);
}

void loop()
{
  if (flag1)
  {
    off();
  }
  if (flag2)
  {
    blink1();
  }

}

void blink1()
{
  attachInterrupt(digitalPinToInterrupt(switch2), setFlag2, CHANGE);
  digitalWrite(led1, HIGH);
  blink2();
}

void blink2()
{
  digitalWrite(led2, HIGH);
  blink3();
}

void blink3()
{
  digitalWrite(led3, HIGH);
  blink4();
}

void blink4()
{
  digitalWrite(led4, HIGH);
  blink5();
}

void blink5()
{
  while (1)
  {
    digitalWrite(led5, HIGH);
    delay(10);
    digitalWrite(led5, LOW);
    delay(10);
  }
}

void off()
{
  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW);
  attachInterrupt(digitalPinToInterrupt(switch1), setFlag1, CHANGE);
}

void setFlag1()
{
  detachInterrupt(digitalPinToInterrupt(switch1));
  flag1 = true;
}

void setFlag2()
{
  detachInterrupt(digitalPinToInterrupt(switch2));
  flag2 = true;
}


texts: Is it possible to charge a battery using a water flow sensor?

texts:
Is it possible to use a water flow sensor to charge a battery? Since the water flow sensor measures water flow using pulses, could I charge a battery using these pulses(instead of using it to read water flow).

Heres an example of the product?
https://netram.co.za/1200-g-12-water-flow-sensor-13mm.html

Thank you


texts: I am very new to arduino and electronics in general. Can i use the NodeMcu Esp8266 as one of those usb wifi dongles? I want to use it as a monitor mode capable wifi card, for my linux laptop.


texts:
I'm building my first arduino project and I encountered a strange problems;

I build a haunted house based upon that instructables tutorial:
https://www.instructables.com/id/Control-Your-Halloween-Decorations-With-Arduino/

Every prop works, I tried to light them on and off (it works), but when I try to use all of them, a few doesn't work.

There is my code; Is it something I'm doing wrong?

int propSqueDans = 4;
int propClownImmo = 5;
int propClownJambes = 6;
int propSqueBal = 7;
int propSqueMini = 8;
int propSpider = 9;
int propChauSou = 10;
int propFantChai = 11;

int SensorPin = 3; // sensor connected to analog pin 3
int SensorVal = 0; // variable to store the value read

void setup() {
  pinMode(propSqueDans, OUTPUT);// sets the digital pin as output
  pinMode(propClownImmo, OUTPUT);
  pinMode(propClownJambes, OUTPUT);
  pinMode(propSqueBal, OUTPUT);
  pinMode(propSqueMini, OUTPUT);
  pinMode(propChauSou, OUTPUT);
  pinMode(propFantChai, OUTPUT);
  pinMode(propSpider, OUTPUT);
  Serial.begin(9600);

  }

void loop() {
    SensorVal = analogRead(SensorPin); // read the input pin

    if (SensorVal >100) {
    Serial.write("Danse + Clown Immo \n");
    digitalWrite(propSqueDans, HIGH);
    digitalWrite(propClownImmo, HIGH);
    delay(10000);
    Serial.write("Spider + Fangtôme + Clown jambes \n");
    digitalWrite(propSpider, HIGH);
    digitalWrite(propFantChai, HIGH);
    digitalWrite(propClownJambes, HIGH);

    delay(5000);
    Serial.write("Squelette balance + sque mini \n");
    digitalWrite(propSqueBal, HIGH);
    digitalWrite(propSqueMini, HIGH);

    delay(5000);
    Serial.write("Chauve souris \n");
    digitalWrite(propChauSou, HIGH);

    delay(20000);

    digitalWrite(propSqueDans, LOW);
    digitalWrite(propClownJambes, LOW);
    digitalWrite(propSqueBal, LOW);
    digitalWrite(propSqueMini, LOW);
    digitalWrite(propChauSou, LOW);
    digitalWrite(propFantChai, LOW);
    digitalWrite(propSpider, LOW);
    digitalWrite(propClownImmo, LOW);
    delay(5000);
    }

  }

Thank you for your help !


texts: Const Array still using dynamic RAM during compile, causing failure

texts:
Using win7 and arduino 1.6.7 IDE
I have a rather large CONST array of chars and upon compile using atmega2560, it fails and says:

Sketch uses 11,216 bytes (4%) of program storage space. Maximum is 253,952 bytes.
Global variables use 8,414 bytes (102%) of dynamic memory, leaving -222 bytes for local variables. Maximum is 8,192 bytes.
processing.app.debug.RunnerException: Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint.
    at cc.arduino.Compiler.size(Compiler.java:319)
    at cc.arduino.Compiler.build(Compiler.java:156)
    at processing.app.Sketch.build(Sketch.java:1108)
    at processing.app.Sketch.build(Sketch.java:1083)
    at processing.app.Editor$BuildHandler.run(Editor.java:2011)
    at java.lang.Thread.run(Thread.java:745)
Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint.

When I delete the CONST array the program compiles successfully, but when I put it back in, the compiler tells me that I'm using too much dynamic RAM.  If I am to understand correctly, consts should store in ROM not RAM.

Here's the even weirder part I put the program in Arduino IDE for Linux and it compiles, but it makes my robot act all crazy.

Any help would be much appreciated.


texts:
I'm planning a project where I'd like to control an RC car with Arduino and an Esp8266 module.

A software running on a computer would read the input from an USB analog controller and send the data to the Esp8266 module through the wifi network, and the Arduino would read this data and send signal to the ports accordingly.

What I'd like to know is: would ping/delay be an issue? Considering a dedicated wifi network for this, so the only devices connected to it would be the computer and the Esp8266 module.

I need to know what is the average response time of the Esp8266 module before I buy it, because if it is too high I'll think of something else since for this project I'd need a reasonably high response time.


texts: Connect an Arduino directly to RGB LED strip

texts:
I am totally new in this area. I have an Arduino mega 2560 and I have this LED RGB Strips. I would like to know if there is any way of connecting the Strips directly to the arduino. The strip has already solded 4 cables:

one cable on 12V
one cable on G
one cable or R
one cable on B

I don't have additional equipment. Also, I can't find anything online which uses the same type of strips as mine. Many thanks.


texts:
im trying to connect to my wifi with mit Nodemcu, i recently got a new router and since then i can't connect anymore. I use simple example sketches from esp library but it will not connect. Instead i get a lot of dots in the console. I disabled firewalls of my router, mac filter is disabled(as i tried to manually add the nodemcus mac to mac filter it said "invalid macadress" ) if intry to connect to my phones hotspot, everything is fine.but i can't connect to my home wifi, ssid and Passwort are 100% correct. My hardware is fine, i ordered a second nodemcu and it has the same problems as the old one.

Can someone help me please, i've set my entire rooms ligthing on the node mcu and now im living in the dark ...


texts: How to connect IR Transmitter and Receiver Module?

texts:
The IR Transmitter and Receiver module has both receiver and transmitter in same board. I tried Arduino IR Remote library example to decode Remote signal using below connection, but its not working.

IR MODULE:   ARDUINO
Ground   ->  Ground
5V       ->  5V
RXD      ->  PIN 11
TXD      ->  PIN 10

The board also has 3 pin connector (Gnd, 5v, S). How to connect pins to Arduino to receive/decode and send IR signals? (Can't able to find any tutorial for this type of board)

Example Code:

#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

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


texts: Access serial monitor on linux cli? Using arduino-cli?

texts:
I have an arduino uno connected via USB to a raspberry pi, the raspi is accessible via ssh only.
Just started a bit with arduino-cli ; I upload a sketch which reads my analog pins. How can I access the serial monitor to get the data??


texts: How to send data from an Arduino GPRS module to a Django application hosted on Heroku?

texts:
I have a Django web application hosted on a Heroku server. Currently I am using the free package for hosting. I want to send data from an Arduino using a SIM900L GPRS module to the web application. I want to know if it is possible. I have searched for a solution but couldn't find a proper guide or example for it. My web application accepts get requests and updates values in the database when url is entered. However if the Arduino sends data using the same url I get the following error:

  AT+CIPSTART="TipCP","https://.herokuapp.com",80
  ERROR

Any tested example or suggestions about what I am doing wrong or what I should be doing instead?

     void gprs(float *value1, float *value2, float *value3, float *AFR, float *value5, float *value6)
{

  String APN = "";
  String UNAME = "";
  String PWD = "";
  char fid[] = "";
  char nid[] = "";
  char s_ip[] = "https://<appname>.herokuapp.com";
  char apikey[] = "";

  wdt_reset();
  digitalWrite(A4, HIGH);
  Serial.println(F("GPRS-1 Function"));
  delay(5000);
  wdt_reset();
  delay(5000);
  wdt_reset();

  char buffer1[10];

  uint8_t GSMTries = 0;
  String res;

  //wdt_reset();
  // the below code establishes connection and if not successful
  // tries three times in total
  do {
    sendData(F("AT\r\n"), 1000, DEBUG);
    sendData(F("AT+CIPSHUT\r\n"), 2000, DEBUG);
    sendData(F("AT+CIPMUX=0\r\n"), 2000, DEBUG);

    sendData(F("AT+CSQ\r\n"), 2000, DEBUG);
    sendData("AT+CSTT= \"" + APN + "\", \"" + UNAME + "\", \"" + PWD + "\"\r\n", 2000, DEBUG);

    sendData(F("AT+CIICR\r\n"), 2000, DEBUG);
    sendData(F("AT+CIFSR\r\n"), 2000, DEBUG);

    sendData(F("AT+CSQ\r\n"), 2000, DEBUG);
    String scnt = "AT+CIPSTART=\"TipCP\",\"" ;
    scnt += s_ip ;
    scnt += "\",80\r\n" ;

    res = sendData(scnt, 10000, DEBUG);
    GSMTries++;

    wdt_reset();

  } while (((res.indexOf("ERROR") != -1) || (res.indexOf("CONNECT") == -1)) && (GSMTries < 3));
  /*
    if(res.indexOf("ERROR") != -1){
    delay(200);
    sendData(scnt, 10000, DEBUG);
    }
  */

  String api = "GET /value?apkey=" ;
  api += apikey;
  api += "&&fid=";
  api += fid;
  api += "&&nid=";
  api += nid;

  Serial.println(F("API......."));
  Serial.flush();
  Serial.println(F("here-1"));

  String Data1 = "";

  //wdt_reset();
  //Co ordinator data is compiled along with html commands
  //and sent through GPRS
  String sensor = dtostrf(*value1, 4, 2, buffer1);
  Data1.concat(api);
  Data1.concat(F("&field1="));
  Data1.concat(sensor);

  sensor = dtostrf(*value2, 4, 2, buffer1);
  Data1.concat(F("&field2="));
  Data1.concat(sensor);

  sensor = dtostrf(*value3, 4, 2, buffer1);
  Data1.concat(F("&field3="));
  Data1.concat(sensor);

  sensor = dtostrf(*AFR, 4, 2, buffer1);
  Data1.concat(F("&field4="));
  Data1.concat(sensor);

  sensor = dtostrf(*value4, 4, 2, buffer1);
  Data1.concat(F("&field5="));
  Data1.concat(sensor);

  sensor = dtostrf(*value6, 4, 2, buffer1);
  Data1.concat(F("&field6="));
  Data1.concat(sensor);

  Data1.concat(F("\r\n"));

  delay(1000);

  String cipSend = "AT+CIPSEND=";
  cipSend.concat(Data1.length());
  cipSend.concat("\r\n");
  sendData(cipSend, 8000, DEBUG);
  sendData(Data1, 8000, DEBUG);
  sendData(F("AT+CIPCLOSE\r\n"), 5000, DEBUG);
  digitalWrite(A4, LOW);

  wdt_reset();

}

The above is a part of code used in arduino to upload data to website. This code was being used before to upload data to thingspeak through its IP address and worked fine.


texts:
I'm playing with a 7 segment display.

The following works on my breadboard:

5V -> 330 Ohm Resistor (same row, row 9)
330 Ohm Resistor -> Com Port (row 9 to row 15)
h led (the dot/row 17) -> ground rail

I get the dot to light up.

However, the following does not light up:

5V -> h led (the dot/row 17)
Com Port -> 330 Ohm Resistor (Row 15 -> row 38).
330 Ohm Resistor to negative rail (row 38 -> negative rail)

I realize that the row numbers are meaningless -- things just need to be on the same row. I've included them to make it easier to visualize.

So basically, if the circuit goes:

5V -> Resistor -> Com, then I can use the ground wire to light up any part I want.

If the circuit goes Com -> Resistor to Ground, I can't use the 5V to light up any part.

I'm not sure why given that all the stuff is in serial?