texts: ESP8266 cannot create TCP connections to this particular server

texts:
EDIT: I have created an issue about this here: https://github.com/esp8266/Arduino/issues/4593

I have this server: 185.205.210.197
(Check that it works: http://185.205.210.197/)

And I have this code in my ESP8266:

#include <ESP8266WiFi.h>

#define HOST "185.205.210.197"
#define PORT 80
#define WIFI_SSID "SSID"
#define WIFI_PSW "PASSWORD"

const char* ssid = WIFI_SSID;
const char* password = WIFI_PSW;

void setup () {
  Serial.begin(115200);
  WiFi.begin(ssid, password);

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

  while(!pingServer()) {
    delay(3000); //Send a request every 3 seconds
  }
}

void loop() {}

bool pingServer() {
  WiFiClient client;

  if (!client.connect(HOST, PORT)) {
    Serial.println("connection failed");
    return false;
  }

  Serial.println("connection success!");
  return true;
}

The expected result: Connection success, but got connection failed.

If I try connecting with my PC, it works, only with ESP8266 it doesn't.

Tapping with Wireshark I suspect that there is a problem with ESP8266 TCP packets, here I leave them for you to analyze:

PC TCP connection request (which works):

000030006b081c001a48ea4c0000000010009e098004dba400000000800401009e090b221f000000c603000004000000880254009801a7ad45b7000af5f4e90c000af5f4e90c603c0000aaaa0300000008004500003c000040003706cb37b9cdd2c5c0a82b490050df312dfea1498c6ac92aa0120000079c00000204058c0402080a336f35554aeb0fe90103030700ead7d1

ESP8266 TCP connection request (which receives no response from server):

000019006f080000952a9f520000000012049e098004daa1000801a200000af5f4e90c2c3ae80f137f000af5f4e90c5000aaaa0300000008004500002c00030000ff06431dc0a82b70b9cdd2c5c00100500000196d000000006002086040f80000020402189ccdd933

What I've also checked:

The ESP connects fine to other servers.
There is no firewall blocking the connection between ESP and the server.
I've tried this in different networks and conditions, the error persists.
Other computers can connect to the server, so ESP should be able as well.
Tried with different ESP8266 boards to rule out hardware malfunctioning.
I am using NODEMCU V0.9 board (original firmware) with Arduino IDE and this ESP8266 library.

How to replicate:

Using the latest Arduino IDE and ESP8266 library.
Check that the test server works at http://185.205.210.197:80/ (just open this link basically and see that is running nginx).
Copy and upload the code above to your ESP8266 (NODEMCU or similar).
Open the Arduino IDE console/monitor and confirm that no connection is established to port 80.
Rage in admiration for such a strange bug.

I've opened an Issue for this: https://github.com/esp8266/Arduino/issues/4593


texts: Is volatile qualifier needed if shared variable cannot be changed externally during complete function call?

texts:
Consider the following example:

int i { 0 };

void incInt() {
    ++i;
}

int readInt() {
    return i;
}

setup() {
    Serial.begin(9600);
    attachInterrupt(digitalPinToInterrupt(D1), incInt, CHANGE);
}

loop() {
    noInterrupts();
    int currI = readInt();
    interrupts();

    Serial.println(currI);
}

By wrapping the call to readInt() with noInterrupts() and interrupts() it is ensured that i cannot be changed externally during the execution of readInt(). i also cannot be changed externally during the execution of incInt(), as long as it is only called as ISR (interrupt service routine). Do I still need to declare i as volatile?

Does the situation change if i is accessed directly in the main loop:

loop() {
    noInterrupts();
    int currI = i;
    interrupts();

    Serial.println(currI);
}

In other words: What is the context in which the compiler expects a variable to not be changed externally if it is not declared volatile?


texts: How to power Arduino only when light is on

texts:
I want Arduino to conserve energy and turn it on automatically only when the lights is on. Can I use some kind of light sensor and put it in between power supply and arduino somehow? Ideally light sensor will power from the same power source, if possible.
I'm not an electrical engineer - just enthusiast, so please explain your idea as detailed as possible. Many thanks!


texts:
I am having trouble to get Sim800L-v2.0 to work. I believe that I am supplying the necessary amount of current (5.0V, 2.1A máx power source, using solid copper wires - circuit photo). The Net LED keeps blinking every second, meaning that it was unable to connect to the network.
Serial monitor readings:
15:57:32.630 -> AT
15:57:32.630 -> OK

16:02:15.391 -> at+cops=?
16:02:23.775 -> +COPS: ,(0-4),(0-2)
16:02:23.775 ->
16:02:23.775 -> OK

16:02:29.075 ->  AT+CPIN?
16:02:29.075 -> +CME ERROR: SIM not inserted

16:02:51.008 -> AT+CREG?
16:02:51.008 -> +CREG: 0,0
16:02:51.008 ->
16:02:51.008 -> OK

16:02:59.639 -> AT+CSQ
16:02:59.639 -> +CSQ: 0,0
16:02:59.639 ->
16:02:59.639 -> OK

16:08:09.354 -> +CFUN: 1
16:08:09.354 ->
16:08:09.354 -> OK

Inspecting the readings, it indicates that the sim card is not inserted at all, which is odd. While searching for some tips on the subject, I did encounter one or another claiming that the problem might be related to the incorrect capacitor used in the circuit module, not really sure though...
Any ideas to solve the issue? Is it a module problem, or am I missing some steps?
Thanks in advance!

#include <SoftwareSerial.h>

//Porta do Arduino onde o pino TX do Módulo GSM esta conectado
#define TX_PIN 10

//Porta do Arduino onde o pino RX do Módulo GSM esta conectado
#define RX_PIN 11

//Cria comunicacao serial via software nas portas digitais definidas acima
SoftwareSerial serialGSM(TX_PIN, RX_PIN);

void setup() {
  //Begin serial comunication with Arduino and Arduino IDE (Serial Monitor)
  Serial.begin(9600);
  while(!Serial);

  //Inicia comunicacao serial com o GSM
  serialGSM.listen();
  serialGSM.begin(9600);
  delay(1000);

  Serial.println("Setup Completo!");
}

void loop() {
  //Le as mensagens vindas do GSM para escrevê-las no monitor serial
  if(serialGSM.available()){
    Serial.write(serialGSM.read());
  }

  //Le as mensagens vindas do monitor serial para copiá-las para o GSM
  if(Serial.available()){
    serialGSM.write(Serial.read());
  }
}


texts: I need to make button to turn off my alarm on clock

texts:
well I get task to make school project alarm clock using arduino, xd as you can see im not very good at it i mean i know something but not everything so please can someone help me, i copied this code somewhere from net and i do little changes on it but there is only thing i cant get right, i just want to add when i press button it stop alarm from beeping, now it beeps until, for example i set alarm on 08:05 it will ring until 08:06, my question is how can i make that when i press button alarm goes off , can someone give me some tips i would be really grateful
i copied original code from here: http://roboticadiy.com/how-to-make-arduino-alarm-clock/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
#include <DS1302.h>
int Hour;
int Min;
int pset = 8; // pushbutton for setting alarm
int phour = 9; // pushbutton for hour
int pmin = 10; // pushbutton for minutes
int pexit = 11; // pushbutton for exit of set alarm
int buzzer = 6;
int h;
int m;
int buttonforset = 0; // pushbutton state for setting alarm
int buttonforhour = 0; // pushbutton state for hour
int buttonformin = 0;// pushbutton state for minutes
int buttonforexit = 0;// pushbutton state for exit of set alarm
int activate=0;
 Time t;

// Init the DS1302
DS1302 rtc(2, 3, 4);

void setup()
{
 pinMode(pset, INPUT);
 pinMode(phour, INPUT);
 pinMode(pmin, INPUT);
 pinMode(pexit, INPUT);
 // Set the clock to run-mode, and disable the write protection
 rtc.halt(false);
 rtc.writeProtect(false);

 // Setup LCD to 16x2 characters
 lcd.begin();

// The following lines can be commented out to use the values already stored in the DS1302
 //rtc.setDOW(SATURDAY); // Set Day-of-Week to FRIDAY
 //rtc.setTime(10, 0, 0); // Set the time to 12:00:00 (24hr format)
 //rtc.setDate(11, 11, 2017); // Set the date to August 6th, 2010
}

void loop()
{
 if (activate == 0) {

// Display time on the right conrner upper line
 lcd.setCursor(0, 0);
 lcd.print("Time: ");
 lcd.setCursor(6, 0);
 lcd.print(rtc.getTimeStr());

 // Display abbreviated Day-of-Week in the lower left corner
 //lcd.setCursor(0, 1);
 //lcd.print(rtc.getDOWStr(FORMAT_SHORT));

 // Display date in the lower right corner
 lcd.setCursor(0, 1);
 lcd.print("Date: ");
 lcd.setCursor(6, 1);
 lcd.print(rtc.getDateStr());
 t = rtc.getTime();
 Hour = t.hour;
 Min = t.min;
 buttonforset = digitalRead(pset);
 } // setting button pressed
 if (buttonforset == HIGH) {
 activate =1;
 lcd.clear(); }
 while(activate== 1){
 lcd.setCursor(0,0);
 lcd.print("Set Alarm");
 lcd.setCursor(0,1);
 lcd.print("Hour= ");
 lcd.setCursor(9,1);
 lcd.print("Min= ");
 buttonforhour = digitalRead(phour); // set hour for alarm
 if (buttonforhour == HIGH){
 h++;
 lcd.setCursor(5,1);
 lcd.print(h);
 if (h>23){
 h=0;
 lcd.clear(); }
 delay(100);
 }
 buttonformin = digitalRead(pmin); // set minutes for alarm
 if (buttonformin == HIGH){
 m++;
 lcd.setCursor(13,1);
 lcd.print(m);
 if (m>59){
 m=0;
 lcd.clear();}
 delay(100);
 }

lcd.setCursor(5,1);
 lcd.print(h);
 lcd.setCursor(13,1);
 lcd.print(m);
 buttonforexit = digitalRead(pexit); // exit from set alarm mode
 if (buttonforexit == HIGH){
 activate = 0;
 lcd.clear();
 lcd.print("Postavljanje");
 lcd.setCursor(0,1);
 lcd.print("alarma...");
 delay(2000);
 lcd.clear();
   }
 }

 if (Hour== h && Min== m) {
 lcd.clear();
 lcd.print("Budenje...");
 tone(6,5000);
 delay(1000);
 noTone(6);}

}


texts:
We have an LED strip connected to output 6 and is powered by the Uno board itself.  Shouldn't be drawing too much current, only have 10 elements on the LED strip.  While this LED strip is connected to the Uno, I noticed that the regulator is getting very hot.

One thing we haven't done yet is to power the LED strips from an external source, which will be necessary since there will be many strips.  At the moment, the students are simply trying to debug their program with the small strip.


texts: In interfacing arduino with nrf module,the output at serial monitor is only question marks

texts:
I have two nrf24l01. The receiver and the transmitter are arduino uno. When I turn them on, the arduino uno at transmitter side doesn't flash any led but the arduino uno at receiver flashes the tx led very fast. On the serial monitor I only see question marks.
My code:
Receiver:
*
* Arduino Wireless Communication Tutorial
*       Example 1 - Receiver Code
*
* by Dejan Nedelkovski, www.HowToMechatronics.com
*
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8 ); // CE, CSN
const byte address[6] = "00001";
void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}
void loop() {
  if (radio.available()) {
    char text[32] = "";
    radio.read(&text, sizeof(text));
    Serial.println(text);
  }
}

Transmitter:

/*
* Arduino Wireless Communication Tutorial
*     Example 1 - Transmitter Code
*
* by Dejan Nedelkovski, www.HowToMechatronics.com
*
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8 ); // CE, CSN
const byte address[6] = "00001";
void setup() {
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}
void loop() {
  const char text[] = "Hello World";
  radio.write(&text, sizeof(text));
  delay(1000);
}

Wiring (same on both arduinos)


texts:
I'm new to Arduino and I'm doing an ultrasonic project where I test for the speed of sound. My code is below and for some reason, this is what the serial port returns:

This is the measured speed of sound: inf m/s
This is the measured speed of sound: 0m/s
This is the measured speed of sound: 0m/s
etc...

Here's my code. Any help's massively appreciated:)

int trig = 13;
int echo = 11;
float target_distance = 0.3;
float recieved;
float speed_of_sound;

void setup() {
    Serial.begin(9600);
    pinMode(trig, OUTPUT);
    pinMode(echo, INPUT);
}

void loop() {
    digitalWrite(trig, LOW);
    delayMicroseconds(2000);
    digitalWrite(trig, HIGH);
    delayMicroseconds(10);
    digitalWrite(trig, LOW);

    recieved=pulseIn(echo, HIGH);
    recieved = recieved*1000000.0;
    speed_of_sound = (2*target_distance)/recieved;
    Serial.print("This is the measured speed of sound: ");
    Serial.print (speed_of_sound);

    Serial.println("m/s");
    delay(3000);
}


texts:
Is it possible to use an Arduino, connected to a 3 axis accelerometer, to estimate a platform's continuous change in position and orientation? I have a small mobile robot, and given an initial position and velocity vector and sequence of acceleration changes, I'd like to calculate the current position and velocity vector.

From this question, it sounds possible, but I can't find any reference to projects or code to accomplish it with an Arduino. I understand the main problem will be the build-up of errors over time, but that's ok, as a rough estimate is acceptable. I'm also using wheel encoders to calculate the same values, and I want to use the accelerometer to account for errors in the encoders, like slippage. e.g. If the encoders say we're accelerating at 1cm/sec but the accelerometer says we're at a constant speed, then I know to ignore the encoders because the wheels are probably slipping.

I understand the math behind this, so the problem is how to write it in C to run on an Arduino. Is anyone aware of existing open source code for something like this? I'd like to avoid reinventing the wheel in-case anyone's implemented a similar system.


texts: How to update multiple outputs simultaneously

texts:
I need to update simultaneously all the outputs of a specific port.

I am familiar with using micro-processors assembly language. After initializing a port (Data Direction Register), I can write to that port and all outputs will update simultaneously.

In the Arduino commands  : I am aware of how to configure pins, such as pinMode(pin, mode), to make a pin an output or input.

I know of the digitalWrite(pin, value) , but this only updates one pin per command.

For timing reasons, I need to update several (same port) outputs without any time delay.

Normally (using assembly language) , I would keep a register with the data I desire on the output port, and write that register's data to the port.

Is there a command I can use in Arduino to accomplish the same thing?
If not a single command, what other choices do I have?

I use Arduino  micro,  UNO,  but I think the question might be valid for most Arduino


texts: Circuit diagram interpretation and electrical flow

texts:
I'm new to Arduino and consequently, to circuits. I've been reading Arduino Robotics by Warren and this was a circuit present in the book.

From what Warren has said, electricity in the circuit travels from the negative pole to the positive, BUT to imagine it as going the other way for simplicity. So, looking at this circuit... it seems useless to have the resistor placed after the LED, based on the + --> - model. Wouldn't the LED turn on before going through the resistor, rendering the resistor useless?

Sorry if this seems like a basic concept, I'm entirely new to this.


texts: Moving an item on a pole, can an Arduino work for my project?

texts:
I'm a computer programmer, but I've never done anything with Arduino. I'd like to build something that holds a polisher (this one, in specific: http://www.homedepot.com/p/BLACK-DECKER-6-in-Random-Orbit-Waxer-Polisher-WP900/202516385) on a metal pole, and moves the polisher up and down (vertically) on the pole at varying speeds (I'd like to use arduino to control the motor/speed)?

Is this the sort of thing Arduino would be able to do? If so, can anyone point me to any motors that would work? If not, any tips on where else I should look?


texts:
I went to upload my sketch to my Uno (r3), but unusually, the Upload Console returned this error:

avrdude: ser_open(): can't open device "\\.\COM4": Access is denied.

Just started seeing this, cannot upload.


texts: ESP8266 sending GET Request and getting 408 Timeout error

texts:
I am using esp8266 to send a GET Request but I am getting 408 Timeout error.

Here is a screenshot of my output.


texts:
So I have a Duemilanove board and am utilizing 7 output pins, I power a Pixy camera and pan/tilt servos from the ICSP header, i also power an HC-SR04 sonar snsor directly from the board.
Of those 7 output pins, 4 are PWMs for the motors (don't ask why), 3 are for servo control (tower pro mg-995)
when I try to output these 7 pins simultaneously things don't work, i get "components at a time" behavior. Like servos turn first, then the motors spin (servos stopped).
Initially we thought it must be a power supply problem (8 1.2v NiMh bat series) which powers the l298n h bridges (two of them) and also powers the board and servos. But now im starting to fear that it's the board itself and that it can't handle simultaneous outputs.
I've read from here (method #10) that taxing the board more than 200mA is a problem. But what exactly happens if you do just that? And is my case exactly like this one? If so, how to fix it?

Edit +

Here's how the circuit looks.

Edit:
Yes i do think there is a need for decoupling capacitors but im not sure where to put them. They dont seem to work. The bounty goes to the best answer on the proper decoupling of this circuit.
Edit:
Here's some images on the Pixy camera

Edit:
Actually from the original problem I noted when I posted this question, things don't work as expected. WHen the big servos move, the pan/tilt camera don't move when they are supposed to, or the motors briefly stop. I'm wondering if is also an Arduino idiosyncrasy because when I don't run the servo.attach(servo_pin)  code everything works fine.


texts: Electronically, should single or several ground pins be used?

texts:
I have heard two theories of grounding: pretty much ground a board at single point, or ground everything in sight.

With the Mini Pro, is it better to provide one source of ground through the Gnd pin next to the Vraw pin, or ground with multiple Gnd pins on the board?


texts:
I have extracted the following code from the multiwii project. It generates a ~490-500hz pwm signal on pin 6 which is used to drive an esc.

I want to change this frequency down to 50Hz to drive a servo instead. But ive had next to no experience at this level of avr programming, and dont want to loose anymore days to it, if its a dead end. (ie not possible) (i have tried reading various websites on the topic)

void setup() {
    pinMode(6, OUTPUT);
    TCCR4E |= (1<<ENHC4); // enhanced pwm mode
    TCCR4B &= ~(1<<CS41); TCCR4B |= (1<<CS42)|(1<<CS40); // prescaler to 16
    TCCR4D |= (1<<WGM40); TC4H = 0x3; OCR4C = 0xFF; // phase and frequency correct mode & top to 1023 but with enhanced pwm mode we have 2047

    TCCR4C |= (1<<COM4D1)|(1<<PWM4D); // connect pin 6 to timer 4 channel D

}

void loop() {
    //write out
    int value = 1500;
    TC4H = value>>8;
    OCR4D = (value&0xFF);
}

here is the new code so far working off the solution provided below:

void setup() {
    pinMode(6, OUTPUT);
    TCCR4B &= ~(_BV(CS43) | _BV(CS42) | _BV(CS41) | _BV(CS40));
    TCCR4B |= _BV(CS43) | _BV(CS41);
    TCCR4D &= ~(_BV(WGM41) | _BV(WGM40));
    TC4H = 624 >> 8; // B10 0x2
    OCR4C = 624 & 0xff;//B1110000 0x70
    TCCR4C |= (1<<COM4D1)|(1<<PWM4D);
}
void loop() {
    //write out
    //30 - 60 gives 1000 to 2000 us, but that only allows 30 increments between ??
    int value = 30;
    TC4H = value >> 8;
    OCR4D = value & 0xff;
}

the wave form i want:


texts:
I was modifying this ADC Touch implementation, namely switching analogRead and pinMode to what I thought would be port manipulation equivalents.

I get very different readings (better and more stable in my case).

So, what I think is equivalent is actually quite different. Can someone point the differences to me?

Original:

    pinMode(ADCChannel, INPUT_PULLUP);

    ADMUX |=   0b11111;
    ADCSRA |= (1<<ADSC); //start conversion
    while(!(ADCSRA & (1<<ADIF))); //wait for conversion to finish
    ADCSRA |= (1<<ADIF); //reset the flag

    pinMode(ADCChannel, INPUT);
    _value += analogRead(ADCChannel);

Modified:

    DDRC &= ~(1 << ADCChannel);
    PORTC |= (1 << ADCChannel);

    ADMUX |=   0b11111;
    ADCSRA |= (1<<ADSC); //start conversion
    while(!(ADCSRA & (1<<ADIF))); //wait for conversion to finish
    ADCSRA |= (1<<ADIF); //reset the flag

    DDRC &= ~(1 << ADCChannel);
    _value += analogRead(ADCChannel);


texts: Docs for using i2C LCD with Newliquidcrystal_1.3.5 library?

texts:
I bought a 20x4 I2C LCD from OddWires. (https://www.oddwires.com/20x4-lcd-display-with-i2c-interface/) It came with ZERO specs or documentation. After some hair-pulling I was able to figure out how to get it working. (I had to use the commands

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address and pin assignments, including the backlight pin and polarity

and

  lcd.begin(20,4);               // initialize the lcd to 20 characters, 4 lines

To get the LCD working (The tricky bit was figuring out the pin assignments. They're not documented.)

I'm assuming this LCD unit is a lot like all the others out there.

It works, and If found the basic commands to clear the screen, position the cursor, and print text.

I've also found commands lcd.cursor() and lcd.noCursor() that let me show/hide the cursor.

I'd like to know if I can do things like blink characters between normal and inverse, underline text, etc using the standard LCD library (I've seen code that uploads custom character maps, so I assume I could upload an alternate underlined character set, but that sounds like a LOT of work for something I'm hoping is built in to the library.)

Can somebody point me to docs on the full suite of commands commonly available for these LCD units in the Arduino Newliquidcrystal_1.3.5 library?

(Sorry to be vague on the specifics of my LCD module. I did not get specs from the vendor, so I have had to guess as to how to use it.)

I'm using the I2C LCD NewLiquidCrystal LCD library. (https://github.com/fmalpartida/New-LiquidCrystal)


texts: Parsing HTTP get response to extract values

texts:
Basically I created a web page to control 4 channel relay, then I made an HTTP get request from that page and got the following response:

Linked

T+CIPSEND=4,50

> GET /ard/sensor.html HTTP/1.1
Host: localho
SEND OK

+IPD,4,351:HTTP/1.1 200 OK
Date: Sat, 07 Apr 2018 01:22:58 GMT
Server: Apache/2.4.9 (Win32) PHP/5.5.12
Last-Modified: Sat, 07 Apr 2018 01:17:13 GMT
ETag: "72-56937eec1c277"
Accept-Ranges: bytes
Content-Length: 114
Content-Type: text/html

<p> Relay1 = 1#  </p> </br>
<p> Relay2 = 0#  </p> </br>
<p> Relay3 = 0#  </p> </br>
<p> Relay4 = 1#  </p> </br>
OK

OK
Unlink

Now I want to store Relay1 status (which is 1 here) in a variable, also all other Relays in order to control them high or low
Note : # is supposed to be the separator
and here is my code:

    #include <SoftwareSerial.h>

const int LED_PIN = 13;

String ssid = "ABC";
String password = "a14102016a";
const byte rxPin = 6;
const byte txPin = 7;

SoftwareSerial ESP8266 (rxPin, txPin);

unsigned long lastTimeMillis = 0;

void setup() {

  Serial.begin(9600);
  ESP8266.begin(9600);
  reset();
  connectWifi();
  delay(2000);
}

//reset the esp8266 module

void reset() {

  ESP8266.println("AT+RST");
  ESP8266.println("AT+CIOBAUD=9600");
  delay(1000);

  if (ESP8266.find("OK") ) Serial.println("Module Reset");

}

//connect to your wifi network
void connectWifi() {

  String cmd = "AT+CWJAP=\"" + ssid + "\",\"" + password + "\"";
  ESP8266.println(cmd);

  delay(4000);

  if (ESP8266.find("OK")) {

    Serial.println("Connected!");

  }

  else {

    connectWifi();

    Serial.println("connect to wifi");
  }

}

void printResponse() {
  while (ESP8266.available()) {
    Serial.println(ESP8266.readStringUntil('\n'));
  }
}

void loop() {

  if (millis() - lastTimeMillis > 30000) {
    lastTimeMillis = millis();

    ESP8266.println("AT+CIPMUX=1");
    delay(1000);
    printResponse();

    ESP8266.println("AT+CIPSTART=4,\"TCP\",\"192.168.1.161\",80");
    delay(1000);
    printResponse();

    String cmd = "GET /ard/sensor.html HTTP/1.1\r\nHost: localhost";
    ESP8266.println("AT+CIPSEND=4," + String(cmd.length() + 4));
    delay(1000);

    ESP8266.println(cmd);
    delay(1000);
    ESP8266.println("");
  }
  if (ESP8266.available()) {
    Serial.write(ESP8266.read());

Byte R[ ] = ESP8266.read () ;
Serial write (R[ ]);

//    if (readString.indexOf("Relay1=1">0))
{
    Serial.write("found");
}
  }

}

Any suggestions ?


texts: Looking for link to Double Pole Single Throw (DPST) relay for Arduino

texts:
Need to find a DPST relay that is 'Arduino' friendly and that is capable of 30A at 240VAC. Anyone can share links ?

Not looking for recommendation, just ideas on what you saw or used in the past.

Thanks.


texts:
I'm trying to use an Arduino UNO board with Assembly on MacOS, but I couldn't find any documentation about it.

How can I compile and upload Assembly files to the Arduino with MacOS?


texts: two dimensional array with 3 characters per entry?


texts: Infinite loop if Serial.println() is not used

texts:
I'm trying to reset my program from software using the third method described here: Reset an Arduino Uno in code

The function is basically showing some data on an OLED display and afterwards should reset the processor

void setup() {
  MCUSR = 0;
}

void showCharacter(int char_number) {

  // [...]

  display.println(character_buffer);
  display.display();

  for (int j = 0; j < 3; j++) {
    enableLED(x, y);
    publishLEDs();
    delay(500);
    clearLEDs();
    publishLEDs();
    delay(500);
    Serial.println(j);
  }

  keyscan.sleep();

  // Reset system
  wdt_enable(WDTO_15MS); // turn on the WatchDog and don't stroke it.
  for (;;) {}
}

For whatever reason it makes a difference if the Serial.println() line is there. If the line is there, the code behaves as expected. The LED blinks three times, afterwards the Arduino is reset.

If I remove that line however, the LED continues to blink infinitely and the code does not reset. I really have no idea why that line has such a big difference, I wouldn't expect any difference to be honest. Anybody has an idea what's going on?

Edit:

I got a hint from a friend of mine that using the volatile keyword in the for loop could fix the problem. He vaguely remembered having a similar problem somehow related to compiler optimisation. And indeed, the following code works as expected:

for (volatile int j = 0; j < 3; j++) {
  enableLED(x, y);
  publishLEDs();
  delay(500);
  clearLEDs();
  publishLEDs();
  delay(500);
}

So let me rephrase my question a little bit - what is happening here, why is the volatile keyword needed?


texts: What is the most accurate sensor for detecting ping pong ball?

texts: What is the most accurate proximity sensor for a ping pong ball? I will be using this to calculate 3D positioning of a ping pong ball in flight. I only need to detect the ball within 0-5 feet (basically on one side of ping pong table).


texts: How to automatically reset the NRF24L01 module

texts:
For my home-automation project I'm using several arduino nano's with each a NRF24L01+ module. Each module is able to both receive and transmit with one another. Everything seemed to be flawless for a couple of hours, but after a couple of hours it either stops transmission (completely frozen) of receives the last data repeatedly. In my design I'm using the RF24 and RF24Network libraries, I was wondering whether someone managed to automatically reset the NRF24L01 module using code, when one of these errors occured, and could share his/her code?

I already found this form, but this is only using the standard RF24 library, whereas I'm also using the RF24Network library. Furthermore, in this form it is having a seperate TX and RX side, whereas I like to have each module to be able to both send and receive.

Some extra side information, I use a stable power supply with a capacitor connected to the module, also the wires are soldered to the module.

I hope somebody can help me with this,

Guido


texts: When using an Arduino as an ISP, is the capacitor required or not?

texts:
Looking at Arduino as ISP and Arduino Bootloaders, it is stated

  The 10 µF electrolytic capacitor connected to RESET and
  GND of the programming board is needed only for the boards that have
  an interface between the microcontroller and the computer's USB, like
  Mega, Uno, Mini, Nano. Boards like Leonardo, Esplora and Micro, with
  the USB directly managed by the microcontroller, don't need the
  capacitor.

Some of the Fritzing diagrams show the electrolytic capacitor connected between the RESET and GND pins:

But it is not shown in all of the images on that page.

Nor it is shown in this image from Nick Gammon's Atmega bootloader programmer (see original image):

So, is the capacitor really needed, when using a Mega or Uno as an ISP, and if so, why exactly?

I was wondering after having written this answer to the question How to install new ATMEGA firmware via the ISP pins? for a 3D Printer control board.


texts: Can I implement a LFM method on an Arduino?

texts:
Can I implement a LFM method for autocorrelation process using an Arduino?
For example if I have a signal input LFM as a real signal and other signal as an imaginer signal.

My question is can I correlate the real signal and imaginer signal using an Arduino?


texts:
I'm using arduino with analog pressure sensor, temperature sensor and a relay to control water pump. The simple code I wrote works, but I want better control.

#include <OneWire.h>
#include <DallasTemperature.h>

 const int pinCidlaDS = 2;
 int pinA0 = A0;
 int teplota;
 int rele;
 float tlak = 0;  //ideal 290+-

OneWire oneWireDS(pinCidlaDS);
DallasTemperature senzoryDS(&oneWireDS);

void setup() {
 senzoryDS.begin();
 rele = 3;
 pinMode(3, OUTPUT);
 Serial.begin(9600);
}

void loop() {
 tlak = analogRead(A0);
 teplota = (senzoryDS.getTempCByIndex(0));
  if ((tlak < 285) && (teplota < 30)) {
   digitalWrite(rele, LOW);
   delay(7000);
 }
   else {
   digitalWrite(rele, HIGH);
   delay(500);
 };
 Serial.print("Tlak: ");
 Serial.println(tlak);
 Serial.print("Teplota: ");
 senzoryDS.requestTemperatures();
 Serial.print(senzoryDS.getTempCByIndex(0));
 Serial.println(" stupnu Celsia");
 teplota = (senzoryDS.getTempCByIndex(0));
 delay (200);

}

So now I'm using delay to get away from the treshold value. And I wanted to write a code that would work like:

Pressure is lower than 'x', relay ON.
Pressure rises to 'Y', relay OFF until Pressure is lower than 'x'.

What should I use? Could you please give me a example, if there is?
Thank you very much! :)


texts: Taking String Input from NodeMCU Webpage and Printing it on Serial Monitor

texts:
I've started working with NodeMCU recently. I've very little knowledge about this device and how a website works. I'm trying to take a long string input from a website hosted by NodeMCU, store it on a variable and then print in on NodeMCU Serial Monitor.

I've got the following program. Here I only have created a text box for typing. But I don't know how to take that input inside a variable and use it later for serial printing.

#include <ESP8266WiFi.h>

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

WiFiServer server(80);

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

WiFi.begin(ssid, password);

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

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

    Serial.println("new client");
    while(!client.available()){
    delay(1);
    }

    String request = client.readStringUntil('\r');
    Serial.println(request);
    client.flush();

    client.println("HTTP/1.1 200 OK");
    client.println("Content-Type: text/html");
    client.println("");

    client.println("<!DOCTYPE HTML>");
    client.println("");

    client.println("Serial Printer (Put Text here: ): ");
    client.println("

");
    client.println("<input type='text' id='name' name='name' required minlength='0' maxlength='800' size='100'>");
    client.println("");

    delay(1);
    Serial.println("Client disonnected");
    Serial.println("");

}


texts: Understanding flashing with bash in Ubuntu

texts:
I am following the instruction from this DIY tutorial to set up the firmware for my dust sensor on Arduino board (NodeMCU): https://luftdaten.info/en/construction-manual/#feinstaubsensor-konfiguration

One line of code has me stumped to import the firmware onto the Arduino board:

Linux: ~ / .arduino15 / packages / esp8266 / tools / esptool / 0.4.9 / esptool -vv -cd nodemcu -cb 57600 -ca 0x00000 -cp /dev/cu.wchusbserial1410 -cf /path/to/firmware/file (the port behind, -cp ‘ may need to be adjusted)

EDITED FOR CLARITY

Environment

Ubuntu Bionic Beavers 18.04
Python 3.6.8
pyserial 2.21.0
ESP8266 NodeMCU (Arduino UNO)

Desired Behaviour
I'm trying to import Luftdaten’s designated firmware onto the Arduino Board.

Current Behavior
The following line of code provided on Luftdaten’s website does not work:

  ~ / .arduino15 / packages / esp8266 / tools / esptool / 0.4.9 /
  esptool -vv -cd nodemcu -cb 57600 -ca 0x00000 -cp
  /dev/cu.wchusbserial1410 -cf /path/to/firmware/file (the port behind,
  -cp ‘ may need to be adjusted)

Error Message

esptool: error: argument --chip/-c: invalid choice: 'd' (choose from 'auto', 'esp8266', 'esp32')

SOLUTION

Step 1: cd into the hidden file directory where esptool is located

cd ~/.arduino15/packages/esp8266/tools/esptool/0.4.9

Step 2: install the bootloader software (i.e. esptool)

pip install esptool

Documentation: https://github.com/espressif/esptool/blob/master/README.md

Step 3: Run the command to flash the firmware on Arduino

esptool --port /dev/ttyUSB0 write_flash 0x0000 ~/Downloads/latest_en.bin

Make sure to specify the correct port; open the ArduinoIDE and check Tools > Port, then Tools > Get board info to check whether the Arduino is recognized.
Make sure to write the correct directory path to the firmware.
In the template provided, "nodemcu" corresponds to "esp8266", and can be left blank since esptool can determine it automatically.

IF THE FOLLOWING ERROR ARISES: [Errno 13] could not open port /dev/ttyUSB0: [Errno 13] Permission denied: '/dev/ttyUSB0' then change permission privileges with sudo chmod 666 /dev/ttyUSB0


texts: Arduino Mega Hall sensor interrupt for a speedometer

texts:
I am having difficulty setting up an interrupt to count how many times the magnet passes so that I can count something like every 100 ms the actual speed.

I have a little code put together from the Internet:

const byte LED_pin =13;
const unsigned long wheel_circumference = 431800UL * 2UL * 31416UL; // = 94,248,000
unsigned long Speed = 0;
unsigned long PrevSpeed = 0;
volatile byte hall_rising = 0; // interrupt flag
volatile unsigned long irqMicros;
unsigned long startMicros;
unsigned long elapsedMicros;
unsigned long ledFlashStartMillis;
const unsigned long ledFlashWaitMillis = 10;
unsigned long displayStartMillis;
const unsigned long displayWaitMillis = 100;

void wheel_IRQ()
{
  irqMicros = micros();
  hall_rising = 1;
}

void setup()
{
  pinMode( 2, INPUT_PULLUP ); // pin # is tied to the interrupt
  pinMode( LED_pin, OUTPUT );
  Serial.begin( 9600 ); // can this be faster? faster would be better
  delay( 1000 );

  attachInterrupt( 0, wheel_IRQ, RISING ); // pin 2 looks for LOW to HIGH change
}

void loop()
{
  if ( hall_rising == 1 )
  {
    elapsedMicros = irqMicros - startMicros;
    startMicros = irqMicros;
    hall_rising = 2;
  }
  else if  ( hall_rising == 2 )
  {
    if ( millis() - ledFlashStartMillis >= ledFlashWaitMillis )
    {
      hall_rising = 0;
    }
  }

  // print speed 1000/Wait (10) times per second
  if ( millis() - displayStartMillis >= displayWaitMillis )
  {
    Speed = wheel_circumference * 0.0009 / elapsedMicros;

    displayStartMillis += displayWaitMillis;
    if ( Speed != PrevSpeed )
    {
      Serial.print(Speed); // this shows mm/sec with no remainder
      Serial.println(" kmh");
    }
    PrevSpeed = Speed;
  }
}

But when I use this code in U8glib to display the value on a GLCD . Values are totally wrong. Can someone help me?


texts: How to calculate the time it takes before the water valve stops dispensing water in an Automatic Water level controller?

texts:
I am making a project about an automated water level controller using ultrasonic, potentiometer and Arduino board. I need a mathematical calculation on how it works. So here's a simple scenario:

I have an open top cylindrical container with a radius of 7cm. The ultrasonic sensed that the half height of the container, which is 15cm, is filled with water. At the bottom part of it, a tube with a radius of 1cm is connected alongside with the water valve. How can I calculate the time needed for the water valve to stop dispensing water if I set the potentiometer to keep the level of water at 9cm only? Can you give me a mathematical formula??

I really need a help, please. Any answer will be highly appreciated. Thank you in advance.


texts: Suggest me an Arduino development board, with a removable ATmega chip?

texts:
I want to buy an arduino development board which has facility to remove its chip and insert a new one anytime. I want to use multiple chips in a single board for different purposes.

If it is not possible, Please suggest me any alternative.


texts:
So I need some tips on working with long strings with the arduino. I have a barcode scanner working. This barcode scanner reads a persons driver license. the result is a lengthy character string of varying length that's 300+. Using substring doesn't work when looking for a certain section of the string and indexOf results in a -1 in most spots. Is there anyway getting around this? Right now I have the data just stored in a string variable.

Thanks.


texts:
To write text on a dot-matrix or LC display with an Arduino you need to have a pixel font in byte format (i.e. typically 1 bit = 1 pixel).
On the Internet I have found surprisingly few resources for this.

Most of the results when searching for pixel fonts return true-type fonts (or similar) which are rather complicated to convert to obtain a satisfying result.
Also, most of the fonts are rather high resolution.
Any good resources I have missed?


texts:
Arduino IDE is throwing this error when uploading sketches - avrdude: stk500_recv(): programmer is not responding

The problem arose just after I uploaded a blink sketch to my Arduino Mini, which worked absolutely fine. After the successful upload I tried to upload a different sketch and got the error.

I thought I had destroyed the boot loader somehow and was about to get out the Bus Pirate for ICSP but I decided to try another Arduino Mini I had lying around (albeit from another manufacturer) and got the same error.

So I'm convinced it's a driver issue as I successfully uploaded a sketch (it still runs as we speak!) then just magically without changing ANYTHING I can no longer upload.

In a futile attempt to get back to work I've done the following:
Switched the RX-TX lines (clearly not the issue as the first upload worked)
Used a different FTDI cable
used a  different programmer
(FTDI 5V/3.3V USB to TTL Basic FT232 FIO Programmer)
(USB to TTL Serial UART RS232 Adaptor (PL2303HX)
I'm fairly certain these use different drivers - FTDI and Prolific

Please help me I'm about to murder something :'(

Screencaps of error and device manager - Imgur


texts:
On this page on Arduino's website, it states

  "HUNDREDS OF COMPANIES AROUND THE WORLD ARE USING IT [Arduino Software] TO PROGRAM THEIR
  DEVICES, INCLUDING COMPATIBLES, CLONES, AND EVEN COUNTERFEIT."
  (Emphasis Added)

With open source electronics, what is the difference between a clone, and a counterfeit?


texts: What is touch_pad_get_status() supposed to return?

texts:
What I want to do:
I have 7 touch buttons on my board (ESP32 TTGO T-Display) and I want to attach interrupts to everyone, calling the same function.
In this function I would like to use touch_pad_get_status() or other to get which button was touched. Then a switch case would do the rest.
What I'm facing:
This code
  Serial.print("Button ");
  uint32_t touch = touch_pad_get_status();
  Serial.println(String(touch));

always returns 0, no matter what.
What I've tried:
Including this part of code to the setup
  touch_pad_init();
  touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER); //tried the SW MODE too
  touch_pad_io_init(TOUCH_PAD_GPIO15_CHANNEL);

But nothing seem to work. I don't want to make 7 different functions...
Thanks in advance.


texts: I have a simple code, part of which contains the calculation 800/1000, which seems to return a value of zero for some reason (even though I store it in a float variable). When I replace the calculation with the expected result (0.8) the code works as expected, I just wonder why the calculation doesn't produce the same result.


texts: Is the supply voltage made available anywhere on the Arduino Uno Board?

texts:
I need to power an OpAmp based circuit that will be connected to my Arduino Uno input. Since I have a 12V adapter for the Arduino board, I want to draw power from it for this opamp(LM358).

Does anybody know if there is any way I can do this from the Arduino board(pins?)is as opposed to having to solder wires directly to the bottom of the DC jack?


texts:
I am using I2C communications to control a AD5694RBRUZ (http://www.analog.com/media/en/technical-documentation/data-sheets/AD5696R_5695R_5694R.pdf) with my Arduino Nano. If i enter two bytes it wil Wire.write only the first line from top to bottom. In the datasheet it is shown that you muust first fill the command byte, then the high and last the low byte. How can i fill the low byte? I have now scraped the idea to input two bytes separately and decided to input one uint16_t byte. How do i fill the low byte at the same time as the high byte, or if it possible how to input the uint16_t value?

My code is as follows:

#include <Wire.h>

#define Address 0x0D

void setup()
{
Serial.begin(9600);
Wire.begin();
AddressWrite(0x3F,0x05B0);
Serial.print ("Biti = ");
Serial.println (AddressRead(0x01));
}

void loop()
{
}

void AddressWrite (byte Naslov, uint16_t Cifra1)
{
byte Hi, Lo;
Hi = highByte(Cifra1);
Lo = lowByte(Cifra1);
Wire.beginTransmission(Address);
Wire.write(Naslov);
Wire.write(Cifra1);
Wire.endTransmission();
Serial.print ("Biti Hi = ");
Serial.println (Hi);
Serial.print ("Biti Lo = ");
Serial.println (Lo);
Serial.print ("Biti Cifra = ");
Serial.println (Cifra1);
}

byte AddressRead (byte naslov)
{
Wire.beginTransmission(Address);
Wire.write(naslov);

Wire.requestFrom(Address,2);

while(!Wire.available())
  {
  }

return Wire.read();
}

Thank you for your time and help.


texts: Question about configuration EEPROM or Flash

texts:
I want to make an external (not related to Arduino) computer application that creates a big 'setup file' (like max. 64 KB). This setup file contains lookup tables (which are configurable and the tables with data themselves).

This 'setup file' needs be stored in the Arduino.

Now I thought of the following alternatives:

Somehow let end users use the computer application to store the setup file they created into the Arduino's extended EEPROM (I will add a 64KB EEPROM for this). However I don't know if a computer application can be made that can do this (i.e. store the information to EEPROM).
Do like above, but store it in Flash (as far as I know, only the Arduino computer application can do this, to send a sketch to USB).
Create an application that 'adds' the setup file to the sketch. However, probably end users cannot store it in the Arduino without the Arduino software which is unwanted.
Use a SD card and read information from there; however, I read 512 bytes SRAM is needed.

To make it more complicated, I want the Arduino sketch to handle like reading on average 50 random bytes from the storage the setup file is stored, and perform several algorithm (not so difficult but still) and do this in max. 10-20 ms.

Can you please give me some more information which alternative would work or not? Or maybe I missed out something trivial or an alternative is impossible?


texts:
I'm working on a project for a robot and I'm trying to make a menu that can run on start up where the user can calibrate the mid-point for the servos (so they're stationary) and the ldrs so it can tell between black lines and white paper. So, I've made the menu a switch case where it calls the calibration when user enters a value, the calibration routines are their own functions.

What I want to know how to do is how to make it so when the user is finished with a calibrator it will go back to the menu function and also how to get the menu to exit on user input. So far when the menu calls a function it will just loop on it.

The menu:

void Menu(){

  Serial.println("|****************************|");
  Serial.println("|**|Ardnoid Configuration |**|");
  Serial.println("|**|        Menu          |**|");
  Serial.println("|****************************|");
  Serial.println("");
  Serial.println("Select one of the following options:");
  Serial.println("1 LDR configuration");
  Serial.println("2 Servo calibration");
  Serial.println("3 Exit configuration menu");

  while(!Serial.available()){}
  int i = Serial.parseInt();

  switch(i){

  case 1:
    break;
  case 2:
    while(srvConOn == true){
      srvConfig();
      }
    break;strong text
  case 3:
    Serial.println("Leaving configuration menu");
    break;
  default:
    Serial.println("Unrecognized command, try again!");
    }
 }

and the servo calibration:

void srvConfig(){

Serial.println("");
Serial.println("Begin servo stop calibration routine");

int x = 0;

  while(x == 0){

    Serial.println("Enter values for servos until both are stationary");
    delay(100);

    Serial.println("Enter value for left servo");
    while (!Serial.available()) {;}
    left = Serial.parseInt();
    Serial.println(left);
    delay(100);

    Serial.println("Enter value for right servo");
    while (!Serial.available()) {;}
    right = Serial.parseInt();
    Serial.println(right);
    delay(100);

    srvR.write(right);
    srvL.write(left);

    Serial.println("have both servos stopped?");
    Serial.println("1 = Yes | 2 = No");

    int j;
    while (!Serial.available()) {;}
    j = Serial.parseInt();

    if (j == 1) {
      Serial.println("Saving calibration");
      EEPROM.write(leftMid, left);
      EEPROM.write(rightMid, right);
      srvConOn == false;
      x == 1;
      } else if (j == 2) {
        Serial.println("Try again");
        Serial.println();
        }
  }
}


texts:
I'm new Arduino user and I'm trying out a SPI protocol to interface a SRAM, specifically, the 23LCV512.

I have found the instructables steps to interface a SRAM using the SPI bus on an Arduino UNO very helpful (http://www.instructables.com/id/Interface-an-SRAM-bus-to-your-arduino/), but there is one  point that i would like some explanation for:

In the mem_demo.ino and other various SPI.h code, I have seen variations of the following, however I do not understand why you would have to do this? I think here that we are communicating the right shifting of an input address 16 places along with 8 bits of '1'.

SPI.transfer((uint8_t)(address >> 16) & 0xff);
SPI.transfer((uint8_t)(address >> 8) & 0xff);
SPI.transfer((uint8_t)address);

Commenting these lines out for the write did not effect the writing to the SRAM, but reading caused it to return mostly 0's.

I really appreciate any help iIget, I do not have a lot of experience with memory addresses and electronics, thank you.


texts: Ethernet TCP communication between two arduinos not working

texts:
So I've got two arduinos Leonardo ETH, both plugged into a local network I host on my computer, and I'm trying to make them communicate through ethernet.

One of my arduinos is collecting data from 2 sensors and sending it on a server, the other one reading. I started by creating an HTTP page with the first and reading it with the second; it worked (more or less).

Then I realised it was overkill and decided to strip down my code to get TCP communication, rather than going through http. The arduino that sends data to the server now works really well; if I connect to the server through chrome the data gets updated each time I connect. But the one that reads it doesn't manage to connect to the server anymore.

Here is the code for the publisher (which seems to work):

#include <SPI.h>
#include <Ethernet.h>

bool objectDetected=0;
bool objectDetected2=0;

byte mac[] = {
  0x90, 0xA2, 0xDA, 0x11, 0x34, 0x5C};

IPAddress ip(192, 168, 1, 30);
EthernetServer server(80);

void setup() {

  Ethernet.begin(mac, ip);

  server.begin();

//  Serial.begin(9600);
//  while (!Serial) {
//    ;
//  }
//  Serial.println("Foreign object detection started");

}

void loop() {
  // --- PULSE DETECTION ---
  // This part of the code gets data from the sensors and stores it in objectDetected and objectDetected2. I've removed the code for clarity as it has no impact on the question

  // --- SENDING IT ON THE SERVER ---
  EthernetClient client = server.available();
  if (client) {
    if (client.connected()){
      if (client.available()){
            client.print("Sensor1: ");
            client.print(objectDetected);
            client.println();

            client.print("Sensor2: ");
            client.print(objectDetected2);
      }
    }

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

}

And here is the code for the receiver (which doesn't seem to work):

#include <SPI.h>
#include <Ethernet.h>
#include <TextFinder.h>

byte mac[] = { 0x90, 0xA2, 0xDA, 0x11, 0x34, 0x86};

IPAddress ip (192, 168, 1, 40);
IPAddress server(192, 168, 1, 30);

EthernetClient client;
TextFinder finder( client );

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

  Serial.println("Sensational Sensor Detection");

  Ethernet.begin(mac,ip);

  Serial.println("Connecting...");
  delay(2000);

  while (client.connect(server,80)!=1){
    Serial.println("Connection failed. Trying again...");
    delay(500);
  }
}

void loop() {

  long sensorValue=5, sensor2Value=5;
  int sensor3Value;

  while (client.connected()){
    if (client.available()){

      finder.find ("Sensor1: ");
      sensorValue=finder.getValue();

      finder.find("Sensor2: ");
      sensor2Value=finder.getValue();

      break;
    }
  }

  Serial.print("sensorValue: ");
  Serial.println(sensorValue);

  Serial.print("sensor2Value: ");
  Serial.println(sensor2Value);

  client.stop();

  delay(1000);

}

The code just prints "Connection failed. Trying again..." over and over.

If you can identify the problem... Please shout in my general direction!
Thanks


texts:
I am trying to solder arduino nano onto a perfboard/solderable breadboard using rosin core solder. The connection is only working some of the time, when I check with a multimeter (+) at pin 29 (in image below) I and (-) at pin 17 there is power at the top of the pin sticking out of the via/hole but there is 0 volts if I check at the actual joint (lower portion of the pin). I see a little flux residue around pin 29 that could indicate a little burning around the area could that be causing this, it is only very minor .. anyway I can fix it?

Also is it normal  to have a little yellow residue left over on the joints? I am new to soldering so not sure if a little flux reside is a bad thing on the joint...


texts:
I'm working with an Adafruit LSM303DLHC Accelerometer Sensor hooked up to an Arduino.  I've downloaded the appropriate libraries to make it work and uploaded the example sketch "accelsensor.pde".  I then placed my sensor at rest on a flat surface and obtained the following acceleration vector values on average, in units of meters per second:

X: -0.24  Y: -0.71  Z: 10.47

At rest, each of these three values fluctuate approximately +-0.04 on average.

As I see it, the values are off a bit.  At rest, the X and Y components should hover closer to 0m/s^2 while the Z component should be closer to 9.8m/s^2.

What is the best way to compensate for this biased measurement?  Should I simply add back the average observed bias?  Or is there a more robust method to calibrate the sensor values?


texts:
I am doing a project where, for troubleshooting reasons, I find myself often swapping components to different serial ports. Maybe one time it's in Serial, then in Serial1, maybe I need to try if software serial works.
But changing every line where Serial.print or Serial.write is written for the new port is a hassle and easy to screw up.
Would it be possible to either create a definition at the beginning of the code that lets me rename Serial to SensorSerial so just by changing that definition I am sure it will use the correct port?


texts:
I want to use the 3.3v on a cheap Arduino Nano clone as my ADC analog reference voltage. The 3.3v comes from a regulator inside the CH340 USB serial chip.

I've measured the voltages (My DMM is NOT calibrated) on seven different Nanos and the voltages vary (2.96-3.38v).

I'm happy to calibrate each board to this voltage, but are there any figures available on how stable this 3.3v supply is? Long term and temperature wise?


texts: ESP32 can't enter interrupt anymore after interrupt appears during delayMicrosecond function

texts:
I have a strange problem with my ESP32 project. I use an ADPS-9960 for gesture control which triggers an external interrupt. In the interrupt handler itself I only set a variable that causes the execution of a function in the loop. When I trigger an interrupt during the delay function the interrupt stops working. This means the loop is still running, but the interrupt routine doesn't get executed anymore.
#include <Arduino.h>
#include <Wire.h>
#include <SparkFun_APDS9960.h>
#include <ESP32Servo.h>
// Pins
#define APDS9960_INT    25 // Needs to be an interrupt pin

#define SERVO 4

// Constants
// Global Variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
int isr_flag = 0;
void IRAM_ATTR interruptRoutine();
int detectorPin = 19;

Servo myservo;

void setup()
{
  // Set interrupt pin as input
  pinMode(APDS9960_INT, INPUT_PULLUP);
  // Initialize Serial port
  Serial.begin(9600);
  Serial.println();
  Serial.println(F("--------------------------------"));
  Serial.println(F("SparkFun APDS-9960 - GestureTest"));
  Serial.println(F("--------------------------------"));

  // Initialize interrupt service routine
  attachInterrupt(digitalPinToInterrupt(APDS9960_INT), interruptRoutine, FALLING);
  // Initialize APDS-9960 (configure I2C and initial values)
  if ( apds.init() )
  {
    Serial.println(F("APDS-9960 initialization complete"));
  }
  else
  {
    Serial.println(F("Something went wrong during APDS-9960 init!"));
  }
  apds.setGestureGain(GGAIN_1X); // ohne diese Zeile geht es nicht zuverlässig

  // Start running the APDS-9960 gesture sensor engine
  if ( apds.enableGestureSensor(true) )
  {
    Serial.println(F("Gesture sensor is now running"));
  }
  else
  {
    Serial.println(F("Something went wrong during gesture sensor init!"));
  }

  myservo.attach(SERVO);
  myservo.write(20);

  pinMode(detectorPin, INPUT);
}

void loop()
{
  if( isr_flag == 1 )
  {
    detachInterrupt(digitalPinToInterrupt(APDS9960_INT));
    handleGesture();
    isr_flag = 0;
    attachInterrupt(digitalPinToInterrupt(APDS9960_INT), interruptRoutine, FALLING);
  }

  if(digitalRead(detectorPin))
    Serial.println("ON");

  else
    Serial.println("OFF");
}

void IRAM_ATTR interruptRoutine()
{
  if(isr_flag == 0)
    isr_flag = 1;
}

void  handleGesture()
{
    if ( apds.isGestureAvailable() )
    {
      if( apds.readGesture() == DIR_FAR )
      {
        Serial.println("FAR");
        myservo.write(165);
        delayMicroseconds (5000000);
        myservo.write(20);
      }
      else
        Serial.println("FALSE");
  }
}


texts:
I couldn't find any library for can bus for STM32duino (Maple Mini) on arduino or even on STMcubeIDE
I found one library on github but it doesn't compile it has a lot of error (its a fork of the stm32duino github library)

I hope that someone could provide a working library or a simple example on how to implement can bus peripheral on STM32F103


texts:
Where can I see outputs from such instruction in an ino file ?

Serial.println("my message");


texts: Current mouse pointer position with Digispark attiny85

texts:
I am trying DigiMouse library for attiny85 Digispark board.

It allows to emulate the mouse quite well.
However, I also need to know the current cursor position. Is there a way to get it?


texts: Using a SPI based ADC (ADE7912) with Arduino

texts:
I'm trying to use Analog Devices' isolated ADC ADE7912 to build a native product for voltage and current sensing, using an Arduino as a microcontroller. The IC communicates with the Arduino using SPI (and SCK frequencies of 8,4,2 and 1 MHz), and I have followed the datasheet and written down some basic code using SPI-transactions and all, which seems to be giving correct results when I apply a positive voltage to the inputs of the ADC. I have two problems here:

When I try to display the SCLK, MISO and MOSI signals on an oscilloscope, the clock seems to have trouble maintaining its value (it becomes erratic and hence the SPI communication also misses some values etc.) Why is this happening?
When I apply a negative voltage to the ADC inputs, the IC does not really show any response to that even though it clearly supports negative voltage inputs to the ADC, as mentioned in the datasheet. This might be an IC related problem, but I am not sure.

Also, is there anyone who has built a library for this IC? Would be greatly obliged if they could share it.


texts: Advice on setting up a real-time audio equaliser

texts:
First time Arduino user here.
We have a microphone set-up which feeds back loudly on particular frequencies and need an equalizer to (preferably automatically) detect spikes in particular frequency bands and attenuate them before sending them on to the speakers. The dB level that has been cut from that frequency channel would then be displayed on an LED matrix such as this one:

Does the Arduino have the processing capabilities to keep up with the audio without noticeable lag? As the LEDs will only be a visual indication of the affect the attenuation is having on the frequencies, it is not particularly important that these be fast. Unfortunately, as the audio stream will be vocals, even a slight delay will render the thing useless. What delay might I expect with a single mono channel going through the arduino?
I expect that I will eventually have to revert to the less-interesting project of an RTA which takes a split of the audio sends to the speakers and simply displays the frequency band intensities rather than altering them.
I'd appreciate any thoughts.


texts: How do I change PGA gain in this Arduino program?

texts:
Below is the link to three files I am using with a 32 bit ADC from TI, ADS1262, plus a link to it's datasheet. It works fine but I'm not getting any better voltage resolution than with a 16 bit ADC. I am using it for small voltage, from 0 to 0.070 volts. For example, for a known stable voltage of 0.01000 volts from a Fluke thermocouple calibrator I get 0.010000 to 0.010006. I get this same 0.000006 volt jitter if I short the ADS1262 input pins together. I suspect it may be a programmable gain amplifier issue. I can put 2.5 volts into it and not damage it. There is a line in the .ino file, #define PGA 1. On a guess, I changed this to #define PGA 32 but it had no effect on the results, it's like my attempted program change didn't take. I read in the ads1262 datasheet that the PGA Gain is in the MODE2 Register, address 05h. A gain of one is set with 000 and a gain of 32 is set with 101. But I do not know how to proceed. Perhaps somebody can help me out.

https://github.com/Protocentral/ProtoCentral_ads1262/tree/master/Libraries
http://www.ti.com/lit/ds/symlink/ads1262.pdf


texts: Ethernet Shield - Not Working Properly Always

texts:
I'm working on a school project and using Arduino Uno. The basic working method for the project is as follows:

Read temperature from LM-35.
Read CO2 level in air using MH-Z14A.
Upload data to server via an HTTP request.

Now each piece of functionality above works fine when tested alone (If I only read temp it reads correctly. If I send data to database it gets sent correctly.) But when reading values and trying to send them to the database the HTTP request doesn't succeed. Also sometimes the Serial Monitor stops printing logs and the sketch stops executing.

I tried adding some delay between things but that didn't work also. Here is my code:

#include <SPI.h>
#include <Ethernet.h>

// Global Variables:
EthernetClient client; // Initialize the Ethernet client library.
const int cyclesLimit = 250;
int cycles = 0;
int temp = 0; // Initial value for temperature.
int co2Level = 0;

float getTemp(){
  const int TEMP_PIN = 0; // Analog.
  Serial.println("Reading Temperature...");
  float tempSensorRawReading = analogRead(TEMP_PIN); // Reading directly from sensor.
  Serial.print("Raw LM35 Reading in mV: ");
  Serial.println(tempSensorRawReading);
  float tempCelsius = (5.0 * tempSensorRawReading * 100.0) / 1024.0; // Convert LM35 reading into celsius.
  Serial.print("Celsius Temperature: ");
  Serial.println(tempCelsius);
  return tempCelsius;
}

int getCO2Level(){
  const int CO2_PIN = 1; // Analog.
  Serial.println("Reading CO2 Level...");
  int ppm = analogRead(CO2_PIN); // Reading directly from sensor.
  Serial.print("CO2 Level in ppm: ");
  Serial.println(ppm);
  return ppm;
}

void updateFirebaseData(int temp, int co2Level){
  const char server[] = "NAME-ADDRESS";
  const String query = String("QUERY-TEXT");
  // Call API.
  Serial.println("Sending request to Database...");
  if (client.connect(server, 80)) { // Default port for HTTP is 80.
    Serial.print("Connected to ");
    Serial.println(client.remoteIP());
    // Make an HTTP request:
    client.println(query);
    client.println("Host: NAME-ADDRESS");
    client.println("Connection: close");
    client.println();
    Serial.println("Data sent to database successfully.");
  } else {
    // If you didn't get a connection to the server:
    Serial.println("Connection failed. Database not updated.");
  }
}

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

  byte mac[] = {0xE2, 0xBA, 0xFE, 0xAD, 0x16, 0x23}; // This should be unique for every chip.
  // Start the Ethernet connection:
  Serial.println("Initializing Ethernet with DHCP...");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP.");
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
      Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware.");
    } else if (Ethernet.linkStatus() == LinkOFF) {
      Serial.println("Ethernet cable is not connected.");
    }
    // No point in carrying on, so do nothing forevermore:
    while (true) {
      delay(1);
    }
  }
  // print your local IP address:
  Serial.print("IP address: ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  cycles++;
  Serial.println(cycles);
  if(cycles >= cyclesLimit){
    Serial.println("Time is up...");
    temp = int(getTemp());
    co2Level = getCO2Level();
    updateFirebaseData(temp, co2Level);
    cycles = 0;
  }
}

I really find this so weird as every piece works alone but when combining things together everything gets messed up.


texts: analogRead seems to freeze some seconds the program

texts:
I have the following code that reads a RFID reader, it was working perfect without any dealy and then I try to an analog read from a potentiometer using analogRead.

The analog read works fine but then when I hover the card over the RFID it takes about 7 seconds or so to go into the line where I turn on a LED.

Im sure Im doing something wrong with analogReader because this is the first time I use it.

  I really appreciate any help

    #include <MicroView.h>

    MicroViewWidget *widget;        // create widget pointer

    #define MAX_BITS 100                 // max number of bits
    #define WEIGAND_WAIT_TIME  3000      // time to wait for another weigand pulse.

    unsigned char databits[MAX_BITS];    // stores all of the data bits
    unsigned char bitCount;              // number of bits currently captured
    unsigned char flagDone;              // goes low when data is currently being captured
    unsigned int weigand_counter;        // countdown until we assume there are no more bits

    unsigned long facilityCode=0;        // decoded facility code
    unsigned long cardCode=0;            // decoded card code

    int sensorPin = A1;    // select the input pin for the potentiometer
    int sensorValue = 0;  // variable to store the value coming from the sensor

    // interrupt that happens when INTO goes low (0 bit)
    void ISR_INT0()
    {

      bitCount++;
      flagDone = 0;
      weigand_counter = WEIGAND_WAIT_TIME;

    }

    // interrupt that happens when INT1 goes low (1 bit)
    void ISR_INT1()
    {

      databits[bitCount] = 1;
      bitCount++;
      flagDone = 0;
      weigand_counter = WEIGAND_WAIT_TIME;
    }

    void setup()
    {

      pinMode(2, INPUT_PULLUP);     // DATA0 (INT0)
      pinMode(3, INPUT_PULLUP);     // DATA1 (INT1)
      pinMode(5, OUTPUT);           // LED

      Serial.begin(9600);

      // binds the ISR functions to the falling edge of INTO and INT1
      attachInterrupt(0, ISR_INT0, FALLING);
      attachInterrupt(1, ISR_INT1, FALLING);

      digitalWrite(sensorPin, HIGH);      // Internal Pull-up
      pinMode(sensorPin, INPUT);          // make pin as INPUT

      uView.begin();                      // start MicroView
      uView.clear(PAGE);                  // clear page
       uView.setCursor(5,0);
      uView.print("TEST");
       uView.setCursor(0,20);
       uView.print("RFID READ");
      widget = new MicroViewSlider(0, 35, 0, 1024);    // make widget as Slider
      //widget2 = new MicroViewSlider(0, 20, 0, 1024, WIDGETSTYLE1);    // make widget as Silder STYLE1
      uView.display();                    // display the content in the screen buffer

      weigand_counter = WEIGAND_WAIT_TIME;
    }

    void loop()
    {

      // This waits to make sure that there have been no more data pulses before processing data
      if (!flagDone) {
        if (--weigand_counter == 0)
          flagDone = 1;
      }

//****** THIS IS THE NEW CODE THAT FREEZE FOR ABOUT 7 SECONDS THE PROGRAM ***//
      sensorValue = analogRead(sensorPin);    // read sensorPin
      widget->setValue(sensorValue);          // set value of sensorPin to widget
      //widget2->setValue(sensorValue);         // set value of sensorPin to widget
      uView.display();

//****** THIS IS THE NEW CODE THAT FREEZE FOR ABOUT 7 SECONDS THE PROGRAM ***//

      // if we have bits and we the weigand counter went out
      if (bitCount > 0 && flagDone) {
        unsigned char i;

        Serial.print("Read ");
        Serial.print(bitCount);
        Serial.print(" bits. ");

        if (bitCount == 32){

          // **** AFTER 7 SECONDS I GET INTO THIS CODE ****///

          uView.clear(PAGE);      // clear the page buffer
          uView.setCursor(0,0);

          digitalWrite(5, HIGH);

        }

         // cleanup and get ready for the next card
         bitCount = 0;
         facilityCode = 0;
         cardCode = 0;
         for (i=0; i<MAX_BITS; i++)
         {
           databits[i] = 0;
         }
      }
    }


texts: How to rotate 3 servo motors when 6 led lights are lit using EMG signals

texts:
I am completely new to arduino and trying to do a school project where i will be able to more 3 fingers with the help of a servo motor using EMG signals.
Right now i am able to read the signals. I just want to modify the code in such a way that when all 6 lights are lit on my emg reading device the servo with rotate by 90 degree. And when all leds are off the servo motor will go back to its initial position, that is will rotate back by 90 degree.
I badly need help over here. Here is the code:

 #define NUM_LED 6  //sets the maximum numbers of LEDs
#define MAX 45     //maximum posible reading. TWEAK THIS VALUE!!
int reading[10];
int finalReading;
byte litLeds = 0;
byte multiplier = 1;
byte leds[] = {8, 9, 10, 11, 12, 13};

void setup(){
  Serial.begin(9600); //begin serial communications
  for(int i = 0; i < NUM_LED; i++){ //initialize LEDs as outputs
    pinMode(leds[i], OUTPUT);
  }
}

void loop(){
  for(int i = 0; i < 10; i++){    //take ten readings in ~0.02 seconds
    reading[i] = analogRead(A0) * multiplier;
    delay(2);
  }
  for(int i = 0; i < 10; i++){   //average the ten readings
    finalReading += reading[i];
  }
  finalReading /= 10;
  for(int j = 0; j < NUM_LED; j++){  //write all LEDs low
    digitalWrite(leds[j], LOW);
  }
  Serial.print(finalReading);
  Serial.print("\t");
  finalReading = constrain(finalReading, 0, MAX);
  litLeds = map(finalReading, 0, MAX, 0, NUM_LED);
  Serial.println(litLeds);
  for(int k = 0; k < litLeds; k++){
    digitalWrite(leds[k], HIGH);
  }
  //for serial debugging, uncomment the next two lines.
  //Serial.println(finalReading);
  //delay(100);
}

Thanks :)


texts: How should I customize UIPEthernet constants?

texts:
I am using UIPEthernet to get an Arduino Nano to drive an ENC28J60 Ethernet Shield for a UDP-based application. I'm customizing a number of its #define parameters to change default settings to save space, but I'm not sure I'm doing it correctly.  It's clearly designed to facilitate per-sketch customization, but things aren't quite working for me, and I can't tell if it's me doing it wrong, or if the customization doesn't quite do what I'm expecting.

Specifically, the comments at the top of utilities/uip-conf.h say:

  uIP has a number of configuration options that can be overridden  for each project. These are kept in a project-specific uip-conf.h file and all configuration names have the prefix UIP_CONF.

So that sounds great - I've copied uip-conf.h into my sketch (into the top directory next to my other sources), adjusted it appropriately, and ... nothing changes.

Now, I'm #including <UIPEthernet.h> into my source files, and everything compiles using the Arduino IDE (v1.8.10). Looking in the library, I can see <UIPEthernet.h> includes <utilities/uipopt.h>, which in turn includes "uip-conf.h" (note the quotes). So I think it's intended to be picking up my local one. But it doesn't - it uses the original one from the library.

My understanding of #include "example.h" is that it looks for example.h relative to the current file location, (ie <utilities/uipopt.h>, so utilities/), so I'm actually seeing correct inclusion behaviour and now I don't see how this customization approach could ever work!

I tried adding the #include "uip-conf.h" to my own sources, and that sort of works for my sources, but of course doesn't affect the library .cpp files themselves which still see the original version.

I could probably drag the entire lib into my sketch and fix up the includes, but that seems like the wrong answer. It's extensively designed to be customizable. Do you know what steps need to be taken to do it please? (Or a pointer to some docs would be fine!) Thanks!


texts: Ethernet shield or Wifi sheild - Arduino?

texts:
To control some LEDs through internet using Arduino UNO, which type of connection  is better ? Ethernet or Wifi? (Later, I may connect some relays instead of LEDs, and control (turn on and off) some devices using this setup).
The only difference I know is the wired and wireless connectivity.
Is there any other difference?


texts: PLs help me Debug i am using arduino mega 2560 , rc522 (library working) , servo (library working)

texts:
https://drive.google.com/file/d/16Qp2kUNgmyA32UKJtOwV7nQdMlSIQyle/view?usp=sharing (.ino)
Arduino File
https://drive.google.com/file/d/1QjBEOfvFiWJFmaAyShyTmwxzlS0NshjT/view?usp=sharing (.txt)
Text File
sorry if I wrote the code here it wont be arranged and thus would be tough to read. Hope this works :)


texts:
I followed this ArduinoToBreadboard and I just added a 5V regulator just to be on the safe side.

So my questions are:

When I connect a Nokia LCD 5110 to the DIY arduino, nothing really happens but when I take out the AtMega328P-PU chip and place it to the official arduino board the screen works normally, why does this happen? (The pins are connected on the same way, it is not this kind of problem)
How can I make this DIY arduino to work with a 3.7V Li-op battery? Because the DIY board works only when I power it up with 5 or more Voltage it works perfect, so any ideas?


texts: Wiring for Arduino Mega and multiple MPU 6050/Gy 521?

texts:
I have an Arduino Mega 2560 that I need to connect 4 MPU 6050/Gy 521's to.

I found some resources on the Mega and Uno, however I'm having trouble piecing them together.

This resource gives great detail for connecting a single MPU to a mega.
http://dummyscodes.blogspot.com/2014/07/mpu6050-gy-521-breakout-arduino-mega.html

This resource gives a trick for connecting multiple to an UNO.
https://playground.arduino.cc/Main/MPU-6050

My problem is that the wiring for the Uno and Mega are different. The resource I have for the UNO describes using the MPU AD0 (output) connecting it to different output pins for each MPU. The resource talking about the MEGA doesn't even use the AD0, and uses INT but I'm not sure if I can use the same concept.

Plus, I still don't actually understand how to connect/what other pins to use for the other 4.

I'm pretty new to Arduino, definitely new to anything with wiring.

Please help! I'm really confused about using multiple together, and about how to properly wire them.


texts: LED strip problem... getting red when expecting white with lots of pixels. Fine with 1 pixel

texts:
I have an Arduino Uno.  I bought this LED strip:  https://www.amazon.com/gp/product/B019DYZNO6/ref=oh_aui_detailpage_o08_s02?ie=UTF8&psc=1

Starting initially using FastLED library. When I tried to set the entire strip to white (255,255,255), it was coming out red. Any color close to white was coming out red.

I thought maybe there was an issue with the library, so I tried the neopixel library. Same thing until... If I just set one pixel to 255,255,255 and don't set any other, it comes out white!  If I set about 10 pixels, they still look white. As I set more pixels, they start to loose their whiteness and become red.

I want to say that maybe this was a power issue... but I tested this both when it was running off my PC and running standalone with a power supply (supplying 5V).

Any suggestions??  I also thought that maybe it's a bum strip, but I also bought https://www.amazon.com/gp/product/B01AG923GI/ref=ask_ql_qh_dp_hza and did the same experiment, and am getting the same results...


texts:
I am writing a code for ARDUINO UNO in arduino 1.8.1 and the following error is coming
How to remove it?

C:\Users\Mahe\Documents\Arduino\sketch_mar09b\sketch_mar09b.ino: In function 'void updateState(byte)':

C:\Users\Mahe\Documents\Arduino\sketch_mar09b\sketch_mar09b.ino:243:60: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

   DisplayInfo("RFID Scanner", "Starting up", HIGH, HIGH);


texts: compensate weight due to acceleration (loadcells)

texts:
I'm trying to make a weighing scale that works in a lift. I'm using load cells to measure the weight, let's say it's F. Then I use that weight F and g which i know is 9,81 m/s^2 to calculate the mass of the object like this.
F = m*g <=> m = F/g

This works when the lift is in rest (or when moving with constant speed) but when it accelerates the weight F increases and because of that the mass also increases. Is there a way to compensate this weight(/extra force) due to acceleration?


texts: How can I change global variables as come EEPROM data? I should write codes in loop. But i dont know anything about changing global variable. Have you an idea?


texts:
I am trying to develop a class for a pump that works on a stepper motor, it should be simple but its not working the way I thought it would. Once I move the timer object into the class the code wont compile I have tried a lot of things but nothing seems to work correctly. The goal of this whole thing is getting the stepper motor to step on its own based off of the calls from the timer object.

pump.h

#include "TimerObject.h"`
#ifndef Pump_h
#define Pump_h

class Pump
{
  public:
     Pump(char pin_, char dir_);
    void pumpstep(void);
  private:
    char pin;
    char dir;
    TimerObject *pumptimer;
};

#endif

pump.cpp

Pump::Pump(char pin_, char dir_)
{
    pin = pin_;
    dir = dir_;
    pumptimer = new TimerObject(100, &this->pumpStep); //PROBLEM IS HERE

  pinMode(pin, OUTPUT);
  pinMode(dir, OUTPUT);
}

void Pump::pumpstep(void) {
     Serial.println("Stepping");
}

my .ino simply creates the class passing in the needed parameters but everything binds up when I try to compile because of the callback in the constructor for the timer, for some reason It wont let me use the address of a non-static method here but I cant make the method static each pumpstep() method must be separate depending on which pump is running.
I have tried using &Pump::pumpstep, &(Pump::pumpstep) and many more pointers but cant seem to get the one I need.

outside this class the timer was working great I used this line below:

pumptimer = new TimerObject(100, &pumpStep);

The library for the timer can be found here:
https://playground.arduino.cc/Code/ArduinoTimerObject

Any help would be greatly appreciated.


texts: Problem controlling a Stepper motor with AccelStepper

texts:
I have an Arduino connected to a stepper motor with an Easy Driver as follows:

I am controlling the position of the stepper motor using the Serial. This is my code:

#include <AccelStepper.h>
AccelStepper stepper(1, 9, 8);

void setup()
{
  Serial.begin(9600);
  stepper.setMaxSpeed(10000);
  stepper.setAcceleration(5000);
}

void loop()
{
  char c;
  if(Serial.available())
  {
   int steps = Serial.parseInt();
   Serial.print(steps);
   stepper.moveTo(steps);

  }
  stepper.run();
}

The code works well but I'm facing a problem, when I set a high position value, it starts turning in the opposite direction, like if there was a limit on the steps. Does anyone know why it starts turning to the opposite direction?

I have tried to solve this problem by using:

if (stepper1.distanceToGo() == 0)
         {
            stepper1.setCurrentPosition(0);
         }

so I can set lower values to the serial. But the problem goes back again when the value goes up to the power of 6 (like 1000000).

Any idea?

Thanks!


texts: How to connect/call to the PSTN network using Arduino?

texts:
For a few months I made an alarm for my house, it is very simple: it is based on magnetic sensors DC-1561 (for windows and exterior doors), a few PIR sensors for rooms, buttons, LEDs and (of course) an ArduinoNano v3. Something simple!

The question is that lately I do not spend much time in my house and I would like it when I'm away from home the alarm calls me (when is activated) to my cell phone using the public switched telephone network (PSTN) because I live in Cuba and it's the easiest way and cheaper (the GSM modems/modules are very expensive for me). I do not want to leave any message or sound record, just call me and receive the call on my cell phone, using the RJ-11 connector (in my country only 2 pins are used) to connect it with the Arduino/some_IC.

I have been investigating since yesterday and have found quite a bit of information. The most recommended/successful that I found (remember that I want to continue using the system that I already have, I just want to add to the Arduino the ability to use the mark through the PSTN) is to use an IC (HT9200B) that is a generator of DTMF codes (as see in the figure) with serial AND parallel connection, aparently, compatible with the electronic logic of the Arduino (5V).

But of all the information that I found is to connect to this IC (HT9200B) a speaker and reproduce the DTMF codes. This is not what I want, what I want is to connect directly to the phone line and be able to "call" from it.

Anyone have any ideas, links, projects in progress, or anything that can help me?


texts:
This is not a code error I have been using DS3231 RTC module with battery. When I bought this module It worked perfectly now when I get it to use, The time is running perfectly. when I set the current time of my location, it has been running along with that time but the problem is when I unplug the power of my Arduino Nano and again when I give the power I can see the time is running from its start, I could not see any current time value my location but I have attached CR2032 battery along with DS3231 module? what is the problem with this? I changed another battery too but It shows same problem my DS32321 haven't kept the time when I unplug and re-plug the power
This is the code I'm using for set the time
#include <DS3231.h>

// Init the DS3231 using the hardware interface
DS3231  rtc(SDA, SCL);

void setup()
{
  // Setup Serial connection
  Serial.begin(115200);
  // Uncomment the next line if you are using an Arduino Leonardo
  //while (!Serial) {}

  // Initialize the rtc object
  rtc.begin();

  // The following lines can be uncommented to set the date and time
  rtc.setDOW(WEDNESDAY);     // Set Day-of-Week to SUNDAY
  rtc.setTime(12, 0, 0);     // Set the time to 12:00:00 (24hr format)
  rtc.setDate(1, 1, 2014);   // Set the date to January 1st, 2014
}

void loop()
{
  // Send Day-of-Week
  Serial.print(rtc.getDOWStr());
  Serial.print(" ");

  // Send date
  Serial.print(rtc.getDateStr());
  Serial.print(" -- ");

  // Send time
  Serial.println(rtc.getTimeStr());

  // Wait one second before repeating :)
  delay (1000);
}

This is the code I'm using to make Interrupt
 #include <DS3231.h>

int Relay = 4;

DS3231  rtc(SDA, SCL);
Time t;

const int OnHour = 21;
const int OnMin = 46;
const int OffHour = 21;
const int OffMin = 48;

const int On2Hour = 14;
const int On2Min = 54;
const int Off2Hour = 21;
const int Off2Min = 48;

void setup() {
  Serial.begin(115200);
  rtc.begin();
  pinMode(Relay, OUTPUT);
  digitalWrite(Relay, LOW);
}

void loop() {
  Serial.println("Time:  ");
  Serial.print(rtc.getTimeStr());
  Serial.print('\n');

  Serial.println("Date: ");
  Serial.print(rtc.getDateStr());
  Serial.print('\n');

  t = rtc.getTime();
  Serial.print(t.hour);
  Serial.print(" hour(s), ");
  Serial.print(t.min);
  Serial.print(" minute(s)");
  Serial.println(" ");
  delay (1000);
  //can be set lcd display alspo
  if(t.hour == OnHour && t.min == OnMin){
    digitalWrite(Relay,HIGH);
    Serial.println("LIGHT ON");
    }

    else if(t.hour == OffHour && t.min == OffMin){
      digitalWrite(Relay,LOW);
      Serial.println("LIGHT OFF");
    }
  if(t.hour == On2Hour && t.min == On2Min){
    digitalWrite(Relay,HIGH);
    Serial.println("LIGHT ON");
    }

    else if(t.hour == Off2Hour && t.min == Off2Min){
      digitalWrite(Relay,LOW);
      Serial.println("LIGHT OFF");
    }
}


texts:
I have an Arduino Uno connected to a motor controller over I2C. The Arduino accepts commands from a Raspberry Pi via the USB serial line.

I'm trying to diagnose a problem where the Arduino will become completely unresponsive. It's programmed to respond to a "ping" request every N seconds, and for some reason I can't identify, it seems to crash and no longer respond to any commands. However, the motor controller continues powering the motors.

Everything is powered from a 12V Li-Po battery, but everything is located behind 5V regulators. When this problem happens, the battery is fully charged and the motors aren't sourcing much current, and neither the motor controller or Raspberry Pi are effected, so I've ruled out a brownout.

My theory is there's some subtle programming error in my Arduino code that's causing an "exception", but I don't know how to identify it. I've tried adding special code to allow me to trigger one of these, by indexing an array outside of its limits or calling a null function pointer, but the Arduino stubbornly refuses to crash when I try to explicitly make it.

How do I diagnose an Arduino becoming unresponsive?


texts: Help! Interfacing LCD with Arduino using 8255A Intel peripherals

texts:
I'm new to all this stuff and for the past two days, I have been trying to interface a 16x2 LCD to an Arduino Uno using an Intel 8255A component without any luck. The problem is, how can I attach or set the LCD's pins <> to the unknown pins of the 8255A.

Is it even possible?

Thanks for any kind of help.


texts: Diode lights generate false interruptions

texts:
I have spent quite a considerable time debugging my code that was triggering false interruptions. I have found out that the source of the error were the diode lights (on the picture). I would like to ask if anyone can point me to the possible source of such behaviour.

I will try to explain really briefly what the issue was providing only needed (from my point of view) details. If you would require more - tell me.

So, I have a board that looks like this:

You can see two reed switches (close circuit in the presence of a magnet) which leads the INT0 (pin 2) and INT1 (pin 3) on arduino to trigger an interruption on their RISING behaviour. The pull down resistors are 1kOhm. This cirquit works perfectly.

The original version of this circuit had lights in positions D5-D10 and D19-D24 (between the reed switches and the connections to the interruptor pins). The lights are these:

The part of the circuit with the red light (connected to INT1) worked flawlessly, while the circuit with the green light (connected to INT0) every once in a while triggered a false interruption in INT1. The lights, however were always blinking correctly.

I have nearly no experience with circuits and hardware, so a pointer on where to start reading to understand the issue is also welcome. Hope to hear from someone who knows what the cause could have been. I would still like to use the lights somehow, because they give a nice feedback on what is happening to the system.

Thanks!

PS. I do not think the code is necessary here, but I will post it too if you like. I am however quite confident that the bug is not on the software side.


texts: Manually added boards doesn't work in 1.8.5…?

texts:
I'm trying to manually add board definitions in a boards.txt file in hardware subfolder of my sketches folder as per instructions here for instance: https://www.arduino.cc/en/Tutorial/ArduinoISP

They however do NOT show up in my board selection.

My sketches location where hardware subfolder should be placed:

Board defs:

~/D/Arduino ❯❯❯ cat ~/Documents/Arduino/hardware/boards.txt
##############################################################

atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.protocol=arduino
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05

atmega328bb.bootloader.file=atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F

atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino
atmega328bb.build.variant=arduino:standard

atmega328bb.bootloader.tool=arduino:avrdude
atmega328bb.upload.tool=arduino:avrdude

BUT nothing show here:

I have restarted Arduino IDE.


texts:
how can i store serial port available test to a two dimensional array. strings are separated with Z and end of text with #
pls help if anyone alrdy a solution

i am posting my program here

  String readstr;
  String finalstr;
  char *messages[][20] = { "" };
  int i, k = 0, lp;
  char chArray[] = "hai";
  String str(chArray);

  void setup() {
      Serial.begin(9600);
      Serial.println("System ready........"); // so I can keep track of what is loaded
  }

  void loop()
  {
      int flag = 0;
      while (Serial.available() > 0)
      {
          char c = Serial.read();  //gets one byte from serial buffer
          if (c == '#')
          {
              finalstr = readstr;
              readstr = "";
              flag = 1;
          }                 // I am getting data here on #
          else    // and is available with finalstr
          {
              readstr += c;     //makes the string readstr
          }
      }

      if (flag == 1)    // once data is available and terminated with #
      {
          int j = 0, l = 0;
          flag = 0;
          //Serial.print(finalstr.length());
          for (i = 0; i < finalstr.length(); i++)     //want to split in to strings
          {
              //Serial.println(finalstr.length());
              // Serial.println(i);
              if ((finalstr[i] != 'Z'))          // if any char is Z, then split
              {
                  // Serial.println(finalstr[3]);
                  messages[j][l] = finalstr[i];          // rearanging in to String messages
                  chArray[j] = finalstr[i];
                  messages[j][l] = '\0';
                  Serial.println(messages[j][i]);    // here it is not working
                  l++;
                  // Serial.println(j);
              }
              else
              {
                  l = 0;
                  j++;
                  String str(chArray);
                  // strncpy(messages[k],chArray,str.length());   // this is not working need help
                  //  Serial.println(messages[0]);
                  //delay(2000);
                  Serial.println(k);
                  k++;
                  //Serial.println(str);
              }

          }
          for (i = 0; i < j; i++)
          {
              Serial.println(messages[i]);    // I am getting here garbage value
          }
          k = 0;
          j = 0;
          l = 0;
      }
  }


texts: How do I set a constant in setup() that I can use in loop()?

texts:
I am new with coding, and I was wondering how I could run something once and define it as a constant. Here is my code:

int sensorValue1 = analogRead(A0);
int sensorValue2 = analogRead(A1);
int g0 = 9.81*9.8;
int h1 = 48;
int R = 287.06;
int a = -0.0065;

void setup() {
    Serial.begin(9600);
    int p1 = (1.09512*sensorValue2-22.105)*133.3225;
    int t1 = (-0.08126*sensorValue1+65.6597)*274.15;
}

void loop() {
    String t = "Temperature:    ";
    String tt = " Celsius";
    String p = "Preassure:    ";
    String pp = " Pascal";
    float celsius = -0.08126*sensorValue1+65.6597;
    float kelvin = celsius*274.15;
    float pascal = (1.09512*sensorValue2-22.105)*133.3225;
    float height = (t1/a)*((pascal/p1)^((a*R)/g0))-1)+h1;
    Serial.println(t+celsius+tt);
    Serial.println(p+pascal+pp);
    Serial.println(kelvin);
    Serial.println( );
    Serial.println(height);
    delay(1000);
}


texts: My RTC is returning a sporadic date/time

texts:
RTC seems to be sporadically returning bogus date/times. Here are the logs from my serial monitor:

2016/3/23 8:19:46
2017/3/23 8:19:46
2016/3/23 8:19:46
2016/3/23 8:19:46
2016/3/23 8:19:46
2016/3/23 8:19:46
2016/3/23 8:19:46
2016/3/23 8:19:46
2016/3/23 8:19:46
2165/165/165 15:19:46
2016/3/23 8:19:46
2016/3/23 8:19:46
2016/3/23 8:19:46
2016/3/23 8:19:46
2016/3/23 8:19:46
2016/3/23 8:19:46
2016/3/23 8:19:46
2016/3/23 8:19:46
2016/3/23 8:19:46

That 2165/165/165 15:19:46 appears throughout the logs.

Here's the relevant code:

#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 rtc;

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

  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }
  if (! rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(__DATE__, __TIME__));
  }
}

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

  Serial.print(now.year(), DEC);
  Serial.print('/');
  Serial.print(now.month(), DEC);
  Serial.print('/');
  Serial.print(now.day(), DEC);
  Serial.print(" ");
  Serial.print(now.hour(), DEC);
  Serial.print(':');
  Serial.print(now.minute(), DEC);
  Serial.print(':');
  Serial.print(now.second(), DEC);
  Serial.println();
}

I have a Grove RTC module.


texts: Arduino Serial.println() keeps transmitting data even when conditions are imposed

texts:
I am using Arduino UNO and a bluetooth module.  I have used an if condition so that Serial.println() happens only once but it keeps on printing.  Please help. Below is the code.

//Begin CODE
char str;
String fnal;
int i;

void setup()
{
  Serial.begin(9600);
  fnal="";
  i=0;
}

void loop()
{
  i++;
  if(i<2)
  {
    Serial.print('#');
    Serial.print('1');
    delay(10);
  }
}

According to this code # and 1 should be printed only once but in serial monitor the printing continues infinitely.


texts: WiFi101 vs WiFININA - reliability issues

texts:
I've got the same code running on 2 different boards:

MKR1010
Adafruit Feather M0

I'm using WiFiNINA on the former, and WiFi101 on the latter.
Other than that, the code that's exactly the same: every 10 seconds connects to WiFi, sends an HTTPS Request, and then sends a response back to the server (response is a bunch of metrics: memory, counter, time & day).
I am also using a WDT to reset the board if it hangs.
After a lot of refinement and experiments, the Adafruit board is able to run for days with no hangs (indicated by no WDT triggers), and no visible degradation (e.g. memory stays stable over time).
The MKR1010 board, on the other hand, resets several times per day.
What I've done?
I've been able to narrow down issues to the network stack (I think). I've randomly injected a bogus hostname to the WiFikSSLClient::connect method (e.g every n calls, where n is random,  I will switch the real hostname with something that will not resolve, simulating a longer latency).
In reviewing the WiFi101 codebase I've found a long, hardcoded, non-customizable timeout here.
...
while (_info[sock].state == SOCKET_STATE_CONNECTING && millis() - start < 20000) {
        m2m_wifi_handle_events(NULL);
    }
...

20 seconds is greater than the max WDT timeout (16 seconds). You can argue that for network operations, 20 seconds would be reasonable, but I'm expecting connections in my network to happen much faster, so I tweaked the library (WiFi101) to 10 seconds and the reliability increased significantly. Every once in a while I get a connection error, but that is fine. The system recovers nicely on the next attempt.
I have not been able to find similar timeouts in WiFiNINA (looks like a much more complex codebase too, but that is my first impression. I'm not an expert)
If I disable the WDT around the connect method, then the MKR1010 will hang after some time. If I leave it, it will recover through a WDT reset.
I'm making sure the firmware on both boards is up to date.
While the WDT solves the issue of ensuring the board recovers, I'd love to fix it properly.
Questions

Is this consistent with anyone's experience?
Are there alternatives to WiFiNINA for the MKR1010?
Is there something obvious I'm missing when configuring the WiFI stack (e.g. a timeout someplace else)?


texts: Use an Arduino Mega in a incubator (high humidity)

texts:
I wonder whether it is possible to use an Arduino Mega in a cell incubator.

In the incubator there is a temperature of 37°C, 5% CO2 in the atmosphere and a high relative humidity of around 95% - 98%. I think the temperature (specs of ATmega2560, temperature range: -40 °C to 85 °C) and the CO2 is no problem.

But I am concerned the condensation due to the high humidity will cause damage.

One mitigation could be, that I first pre-warm the Arduino Mega so it doesn't condensate.

(There is a possibility that I don't put the Arduino in the incubator at all, but it would be easier if I could).