texts: Will the arduino power autoselection logic short the regulated 5V and the USB 5V?

texts:
From the reference design of the Arduino UNO r3, I find that USBVCC will be connected to +5V via mosfet T1 if Vin is below 6.6V.
Doesn't this short the two sources if Vin is just below 6.6V?
The datasheet for regulator U1 (NCP1117) mentions input range as low as 6.5V for the 5V version.

This question came to mind when researching if I can simultaneously power the arduino with USB and the 5V-pin. There are many warnings not to do so, and some say its ok anyway. I realise that this will short the USB 5V with my external 5V if Vin/PWRIN is not connected or less than 6.6V/~7.3V, but how bad is that considering that this may happen anyway by design (if the theory above is correct)?


texts:
I'm trying to print a txt file from an SD card to a SSD1306 using the u8x8 library.
Here's the current code:
#include <SD.h>

#include <Arduino.h>
#include <U8x8lib.h>

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif

  U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE);

/*
  This example will probably not work with the SSD1606, because of the
  internal buffer swapping
*/
#define maxChar  128
#define rows 8
#define cols 16

File myFile;
int x = 0;
int y = 0;
char c;

void setup()
{
  /*Serial.begin(9600);
  Serial.print("Initializing SD... ");
  if (!SD.begin(10)) {
    Serial.println("initialization failed!");
    while (1);
  }
  Serial.println("initialization done.");*/

  u8x8.begin();
  delay(500);
  u8x8.setFont(u8x8_font_amstrad_cpc_extended_f);

  myFile = SD.open("target.txt", FILE_READ);
  u8x8.clear();
  u8x8.print("ciao");
  u8x8.print(myFile.read());
  delay(2000);
  printNewSet();
}
void loop()
{

}

void printNewSet()
{
  u8x8.clear();
  x = 0;
  y = 0;
  while (myFile.available() && y<rows)
  {
    c = (char) myFile.read();
    if (c == '\n') c = 'a';
    u8x8.print(c);
    stepCoords();
  }
}

void stepCoords()
{
  x++;
  if (x >= cols) newLine();
}
void newLine()
{
  u8x8.print('\n');
  x = 0;
  y++;
}

The function printNewSet() is supposed to print a batch of characters until either the file ends or the display limit is reached.
The file displayed correctly until i switched from while(myFile.available()) u8x8.print( (char) myFile.read()); to printNewSet(), at which point myFile.read() only returns -1 and myFile.available() is always false.
What is going wrong?
EDIT: While debugging i discovered that myFile fails to be initialized. Am I running out of memory?


texts: Running Arduino with 2 outputs and 2 inputs

texts:
Totally new to Arduino, 3 weeks old!
I am doing a project with 2 inputs (2 x ultrasonic sensors) and 2 outputs (buzzer and send SMS)
The code to run the buzzer and sms works perfectly individually. For the buzzer, it will stop buzzing after approx 5 seconds.
I would love them to run concurrently but it didn't work as planned when I upload the code on the board.
I've read on forums to use millis / blinkwithoutdelay but am unsure how I can incorporate those functions on my mode as the examples posted online are different from my project.
The following is the code I have created.
Would appreciate if I can get some help from the experienced folks here.
#define TRIG A0 //Module pins
#define ECHO A1
#define TRIG1 A2 //Module pins
#define ECHO1 A3
#define Buzzerpin 13

int ctn = 0;

void setup() {
  Serial.begin(9600); // Serial monitoring
  pinMode(TRIG, OUTPUT); // Initializing Trigger Output and Echo Input
  pinMode(ECHO, INPUT_PULLUP);
  pinMode(TRIG1, OUTPUT); // Initializing Trigger Output and Echo Input
  pinMode(ECHO1, INPUT_PULLUP);
  pinMode(Buzzerpin, OUTPUT);
}

void loop() {

  digitalWrite(TRIG, LOW); // Set the trigger pin to low for 2uS
  delayMicroseconds(2);

  digitalWrite(TRIG, HIGH); // Send a 10uS high to trigger ranging according to specs
  delayMicroseconds(20);

  digitalWrite(TRIG, LOW); // Send pin low again
  delayMicroseconds(2);

  digitalWrite(TRIG1, LOW); // Set the trigger pin to low for 2uS. Give a short LOW pulse beforehand to ensure a clean HIGH pulse
  delayMicroseconds(2);

  digitalWrite(TRIG1, HIGH); // Send a 10uS high to trigger ranging according to specs
  delayMicroseconds(20);

  digitalWrite(TRIG1, LOW); // Send pin low again
  delayMicroseconds(2);

  int distance = pulseIn(ECHO, HIGH, 26000); // Read in times pulse
  int distance1 = pulseIn(ECHO1, HIGH, 26000); // Read in times pulse
  distance = distance/58;
  distance1 = distance1/58;

  if (distance < 25) {
    Serial.print("\r");
    delay(1000);
    Serial.print("AT+CMGF=1\r");
    delay(1000);
    /*Replace XXXXXXXXXX to 10 digit mobile number & ZZ to 2 digit country code*/
    Serial.print("AT+CMGS=\"+YYXXXX\"\r"); // YY is the country code XXX is the number
    delay(1000); //
    //The text of the message to be sent.
    Serial.print("HELLO There");
    delay(1000);
    Serial.write(0x1A);
    delay(1000);
  }
  else {}

  if (distance1 < 25 && ctn < 150) {
    ctn += 1;
    digitalWrite(Buzzerpin, HIGH);
  }
  else {
    digitalWrite(Buzzerpin, LOW);
  }

  if (distance1 > 25 && ctn >= 150) {
    ctn = 0;
    digitalWrite(Buzzerpin, HIGH);
  }
}


texts:
I'm new to the arduino and to EE in general. I've built the basic examples and a, now trying to get a deeper understanding of what the physics is doing. As such, I'd like some help in understanding the diagram here:

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

Question 1:

Specifically,it seems that the flow is going from Pin 13 to Ground. Is the diagram using the conventional flow or the electron flow approach.

Specifically, is it the electrons flowing from Pin 13 to ground or does the diagram show protons flowing? It seems that its showing the electron flow as the diagram has the anode attached to the resistor so the electrons flow from the pin to the resistor to the positive end (anode) of the LED.

Question 2:
This is about bread boards, like one shown here:

https://www.google.com/search?q=arduino+breadboard&biw=1696&bih=988&tbm=isch&tbo=u&source=univ&sa=X&ved=0CFEQsARqFQoTCIjsw5WhkMgCFdWYiAodttcKIw#tbm=isch&q=breadboard&imgrc=KwnTrtjnYJdB1M%3A

1) Would I connect Pin 13 (or say the 5V pin) to the + (the red line). Then I would connect the blue line (the -) to the ground on the arduino? Do I need to connect the blue line?

2) Also, is it again the electron flow notation so that from Pin 13, the electrons flow to the + (red), then to one of the lettered columns and then to whatever component I have?

Thank you for your help! I realize these are basic questions but I want to go a little beyond building the examples and start trying things out myself. As such I want to make sure I'm getting the theory behind it right!


texts:
I've a project which i need to make a door open and close using the fingerprint.

I've successfully made fingerprint works just fine it reads and confirm the fingerprints stored in it but the servo doesn't act at all to my confirmed finger print.

    #include <Servo.h>
    #include <Adafruit_Fingerprint.h>
#include <SoftwareSerial.h>
Servo myservo;

int getFingerprintIDez();
int pos = 0;
int id ();
// pin #2 is IN from sensor (GREEN wire)
// pin #3 is OUT from arduino (WHITE wire)
SoftwareSerial mySerial(A12, A13);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&mySerial);

// On Leonardo/Micro or others with hardware serial, use those! #0 is green wire, #1 is white
//Adafruit_Fingerprint finger = Adafruit_Fingerprint(&Serial1);

void setup()
{
myservo.attach(10);
while (!Serial); // For Yun/Leo/Micro/Zero/...

Serial.begin(9600);
Serial.println("Adafruit finger detect test");

// set the data rate for the sensor serial port
finger.begin(57600);

if (finger.verifyPassword()) {
Serial.println("Found fingerprint sensor!");
} else {
Serial.println("Did not find fingerprint sensor :(");
while (1);
}
Serial.println("Waiting for valid finger...");
}

void loop() // run over and over again
{
getFingerprintIDez();
delay(50); //don't ned to run this at full speed.

}

uint8_t getFingerprintID() {
uint8_t p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
Serial.println("Image taken");
break;
case FINGERPRINT_NOFINGER:
Serial.println("No finger detected");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
return p;
case FINGERPRINT_IMAGEFAIL:
Serial.println("Imaging error");
return p;
default:
Serial.println("Unknown error");
return p;
}

// OK success!

p = finger.image2Tz();
switch (p) {
case FINGERPRINT_OK:
Serial.println("Image converted");
break;
case FINGERPRINT_IMAGEMESS:
Serial.println("Image too messy");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
return p;
case FINGERPRINT_FEATUREFAIL:
Serial.println("Could not find fingerprint features");
return p;
case FINGERPRINT_INVALIDIMAGE:
Serial.println("Could not find fingerprint features");
return p;
default:
Serial.println("Unknown error");
return p;
}

// OK converted!
p = finger.fingerFastSearch();
if (p == FINGERPRINT_OK) {
sweep();
Serial.println("Found a print match!");
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
Serial.println("Communication error");
return p;
} else if (p == FINGERPRINT_NOTFOUND) {
Serial.println("Did not find a match");
return p;
} else {
Serial.println("Unknown error");
return p;
}

// found a match!
Serial.print("Found ID #"); Serial.print(finger.fingerID);
Serial.print(" with confidence of "); Serial.println(finger.confidence);
}

// returns -1 if failed, otherwise returns ID #
int getFingerprintIDez() {
uint8_t p = finger.getImage();
if (p != FINGERPRINT_OK) return -1;

p = finger.image2Tz();
if (p != FINGERPRINT_OK) return -1;

p = finger.fingerFastSearch();
if (p != FINGERPRINT_OK) return -1;

// found a match!
Serial.print("Found ID #"); Serial.print(finger.fingerID);
Serial.print(" with confidence of "); Serial.println(finger.confidence);
return finger.fingerID;

}

void sweep()
{
 for(int pos = 0; pos < 180; pos += 25)  // goes from 0 degrees to 180 degrees
 {                                  // in steps of 1 degree
   myservo.write(pos);              // tell servo to go to position in variable 'pos'
   delay(122);                       // waits 122ms for the servo to reach the position
 }

 for(int pos = 180; pos>=1; pos-=25)     // goes from 180 degrees to 0 degrees
 {
   myservo.write(pos);              // tell servo to go to position in variable 'pos'
   delay(122);                       // waits 122ms for the servo to reach the position
 }
}


texts:
I'm still fairly new to the Arduino world. I got myself a kit with a clone board  couple of months ago and have successfully prototyped the project and got it to the state I want it to be. I now want to create 5 - 10 working models of what I've done.

I'd seen on Amazon that I could get 5 Nano clones for about £10 and this seemed ideal to me. Until I saw that people were complaining that some Nano's aren't quite a direct replacement for the Uno that I have working. There's some kind of problem with loading the software from the IDE.

I really don't want to do anything more than just load my software onto the Nanos "As Is" using the IDE I already have.

Can anyone recommend what I need to look out for to ensure that the Nanos I buy will work this way please?


texts:
im working on the following project kalman filter

and im working to implement in arduino.. i read the entire code and i succesfully implemented it into arduino but i couldnt implement the following function code line because arduino gives "not defined" error in PI_DIV_180

imu_MadgwickQuaternionUpdate(bUseAccel,elapsedTimeSecs,fax,fay,faz,fgx*PI_DIV_180,fgy*PI_DIV_180,fgz*PI_DIV_180,fmx,fmy,fmz);

it multiplies fgx with PI_DIV_180 but as i said arduino cant identify it

i looked into math.h to find the value of that define but there isnt anything in math.h related with this

the imu_MadgwickQuaternionUpdate function is in here IMU.cpp

can anyone help me please thanx..


texts: I am using Arduino stepper motor and pir sensor

texts:
my project about automated system I am using stepper motor to open and close the gate but my point is I want my code be like when the gate opened it stays 5 seconds then check the sensor if there is a motion the gate should not close and stay open when there is no motion the gate should close and if the gate is closing and there is a motion , motion should interrupt closing the gate and reopening the gate I am using Arduino uno

the code is :

#include <RH_ASK.h>//include radioHead ASK library
#include <SPI.h> // include dependant SPI libray
#include <Stepper.h> // Include the Arduino Stepper.h library:
// Define number of steps per rotation:

RH_ASK rf_driver; // create ASK object
int ledon = 13;
int ledoff = 5;
int sensor = 3;

const int stepsPerRevolution = 2048;// Define number of steps per rotation:

// Wiring:
// Pin 8 to IN1 on the ULN2003 driver
// Pin 9 to IN2 on the ULN2003 driver
// Pin 10 to IN3 on the ULN2003 driver
// Pin 11 to IN4 on the ULN2003 driver
// Create stepper object called 'myStepper', note the pin order:
Stepper myStepper = Stepper(stepsPerRevolution, 8, 10, 9, 11);

void setup() {

  rf_driver.init(); //initialize ASK object

  // Begin Serial communication at a baud rate of 9600:
  Serial.begin(9600);

  // Set the speed to 5 rpm:
  myStepper.setSpeed(5);
  pinMode(ledon, OUTPUT);
  pinMode(ledoff, OUTPUT);

}

void loop() {

  //set buffer to size of expected message
  //uint8_t buf[8];
  // uint8_t buflen =sizeof(buf);

  //check if recevied packet is correct size
  //  if (rf_driver.recv(buf,&buflen))
  //{
  // int i;
  // message received with valid checksum
  // Serial.print("id: ");
  // Serial.println((char*)buf);
  // String userid =(char*)buf;
  // Serial.println(userid);

  // }

  //delay(5000);

  // uint8_t buf2[8];
  // uint8_t buflen2 = sizeof(buf2);

  // if (rf_driver.recv(buf,&buflen))

  // {

  //  int i;
  // message received with valid checksum
  // Serial.print("password: ");
  // Serial.println((char*)buf);
  // String password = (char*)buf;
  //  Serial.println(password);

  // }
  // delay(5000);

  String pass = "1234";
  String id = "A00036757";

  if (pass == "1234" ) {
    Serial.print("car exists");
    digitalWrite(ledon, HIGH);
    delay(300);
    myStepper.step(stepsPerRevolution / 3); //clockwise -OPEN GATE
    delay(10000);

    //if(digitalRead(sensor) == HIGH){
    delay(500);
  }

  if (digitalRead(sensor) == LOW) {

    digitalWrite(ledon, LOW);
    delay(300);

    digitalWrite(ledoff, HIGH);
    delay(300);
    myStepper.step(-stepsPerRevolution / 3); // CLOSE AFTER 5s COUNTERCLOCKWISE -  close gate
    digitalWrite(ledoff, LOW);
  }
  else {
    Serial.print("NO CAR");
  }


texts: Where is the positive and negative holes on the arduino mini breadboard?

texts: I have the mini arduino breadboard. The pins go from A to J and 1 to 17. On the larger breadboard, there are symbols + and -. My breadboard doesn't have those two sections to put wires in. Does anyone know what to do?


texts:
A friend and I are working on building a smartwatch on a budget, so it’s a (very) low power project, but we are currently having a problem with the power supplying.
We already chose this board, because of its size and the BLE chip: RFduino BLE SMT
For now on, we are planning to use this battery 500 mAh LiPo battery (approx. 4V at full charge) with this voltage regulator Micrel MIC5209-3.6YS (the board supports 3.6V max.).

But the problem is that the Voltage Regulator will apparently drain by itself too much energy from the battery (by heating), reducing drastically the autonomy.

So we would like to know if you guys can help us, if you can tell us exactly what (type of) regulator would be the best or if we need to find another battery.


texts: How can i read serial data into a string until a certain character is recieved?

texts:
This is not a duplicate of my other question. This question deals with reading specific data within a serial stream. The other question deals with reading and adding data into a manageable data string.

What I'm trying to do is send a command to serial, get the response, and put it into a string, and then break that string up into usable parts of data.

The problem I'm having, is there is a delay between the time the serial command is sent, and the response. meaning the serial data isn't being captured before the function moves onto the next line. Using delay() doesn't appear to work, as i believe it halts everything for that delay period.

What I'm hoping to do, is read the data from serial and if the character '<' is received, place it, and everything after it into the buffer until the character ">" is received.  After the last character is received, and placed into the buffer, continue on with the script.

Unless of coarse someone has a better idea on how to approach this.
i would also like to note that this is just a part of a larger project. If you need to see the entire project, please let me know and i will provide a link where you can download it.

The string i'm expecting as a response would be similar to this:

<Alarm,MPos:0.000,0.000,0.000,WPos:0.000,0.000,0.000>

Here is the code i have so far:

float mx;
float my;
float mz;
float wx;
float wy;
float wz;
String dAlarm;
char buffer;
void gPos() {
  Serial1.print("?\n");
  buffer = Serial1.read();
  char string[80];
  string[buffer];
  char *alarm = strtok(string, ",");
  char *mposX = strtok(NULL, ",");
  char *mposY = strtok(NULL, ",");
  char *mposZ = strtok(NULL, ",");
  char *wposX = strtok(NULL, ",");
  char *wposY = strtok(NULL, ",");
  char *wposZ = strtok(NULL, ">");
  alarm += 1;
  mposX += 5;
  wposX += 5;
  mx = strtod(mposX, NULL);
  my = strtod(mposY, NULL);
  mz = strtod(mposZ, NULL);
  wx = strtod(wposX, NULL);
  wy = strtod(wposY, NULL);
  wz = strtod(wposZ, NULL);

  if (strcmp(alarm, "Idle") == 0) {
    dAlarm = "Idle";
  } else if (strcmp(alarm, "Run") == 0) {
    // Something to do when Busy
    dAlarm = "Run";
  } else if (strcmp(alarm, "Hold") == 0) {
    // Something to do when Busy
    dAlarm = "Hold";
  } else if (strcmp(alarm, "Door") == 0) {
    // Something to do when Busy
    dAlarm = "Door";
  } else if (strcmp(alarm, "Home") == 0) {
    // Something to do when Busy
    dAlarm = "Home";
  } else if (strcmp(alarm, "Alarm") == 0) {
    // Something to do when Busy
    dAlarm = "ALARM!";
  } else if (strcmp(alarm, "Check") == 0) {
    // Something to do when Busy
    dAlarm = "Check";
  }
  dispPos();
}

void dispPos() {
  int state = 0;
  int x = analogRead (0);
  if (x < 800) {
    state = 1;
  }
  if (state == 1) {
    dPos = false;
  }

  if (dPos == true) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("X");
    lcd.print(mx);
    lcd.setCursor(8, 0);
    lcd.print("Y");
    lcd.print(my);
    lcd.setCursor(0, 1);
    lcd.print("Z");
    lcd.print(mz);
    lcd.setCursor(8, 1);
    //lcd.print(" ");
    lcd.print(dAlarm);
    delay(3000);
  } else {
    mainMenu();
  }
}


texts: Visual clock with millisecond display refresh rate

texts:
I need to create a millisecond capable visual clock - I will use the clock for visual frame synchronization of multiple cameras. I found this project but it seems to use a LED display that only has resolution of one 1/100th of a second. Not sure if the digits can be shifted to show milliseconds.

I guess I need to use LED instead of LCD display because of the ms refresh rate? Can someone help with my project please? I am a SW programmer and have zero experience in HW programming. So I am new to Arduino too - I have not done any project at all yet. I do own neither Arduino nor LED display.

Thanks!


texts: Interesting issue with my wifi Car project

texts: Hello so i build a nodemcu wifi controlled car, everything works fine expect i have one small issue, currently i have 2 9v batterys, one of them is connected to motor controller and other one is connected to nodemcu.. but the nodemcu's 9v battery gets hot in a minute and stops working. What am i doing wrong? + is connected to vcc and - is connected to grnd on nodemcu.


texts: So I'm trying to use the GSM shield to communicate with my smart phone. The SIM card that came with the shield only works with other devices on that network, and it's an obscure latin network that I don't have so I cant use that one, and I bought another t-mobile SIM card activation kit, but I can't figure out how to activate it without having an actual T-mobile number. Somebody please help me! Either help me figure out a way to get the T-mobile SIM card to work or tell me what other SIM to use! If you used the GSM shield with a different SIM card, could you give me a link to where you bought it? Thanks!


texts: Adafruit Micro-SD breakout not initializing on MEGA 2560

texts:
]
[I am having quite a bit of trouble trying to get my Arduino MEGA 2560 to read my micro-SD card. My wiring is as follows:

Breakout    Arduino
5v            5v
Gnd           Gnd
CLK           52
DO            50
DI            51
CS            53
CD            Was not connected and then connected to 47 (neither worked)

Here is my code:

#include <Wire.h> //library necessary to use I2C communications bus
#include <Adafruit_Sensor.h>
#include <Adafruit_BME680.h>
#include <SD.h>
#include <SPI.h>

const uint8_t chipSelect = 53; //chipSelect pin for the SD card Reader
const uint8_t cardDetect = 47;

File CO2Data; //Data object you will write your sensor data to

void setup() {
Serial.begin(115200);//"begins" the serial monitor so you can print stuff out when connected to the computer (set baud rate to 115200)
Wire.begin ();//begins the I2C communications bus so it can talk to the K33

Serial.print("Initializing SD car...");
pinMode(53, OUTPUT);

if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
// don't do anything more:
while (1) ;
}
Serial.println("card initialized.");
File CO2data = SD.open("datalog.txt", FILE_WRITE);
if (! CO2data) {
Serial.println("error opening datalog.txt");
// Wait forever since we cant write data
 while (1) ;
}}

The SD card is formatted to FAT32.

Thank you for any help!


texts:
How to control two 12 V motors with the dual MAX 14870 Motor Drive Shield for Arduino?

I am a beginner and I need help on how to control two 12 V motors using the Pololu dual MAX 14870 Motor Drive Shield for Arduino Uno.


texts: Changing the servo motor operating direction using arduino

texts:
I want to turn the servo motor 90 degrees with the first double high inputs, then I want to turn the motor 180 degrees with double high inputs, but the motor turns 180 degrees with one high input.
thank you for all help
#include <Servo.h>
Servo myservo;
const int  buttonPin = 8;    // the pin that the pushbutton is attached to
const int ledPin = 13;       // the pin that the LED is attached to
int Newbuttoncounter;
int buttonPushCounter = 0;   // counter for the number of button presses
int buttonState = 0;         // current state of the button
int lastButtonState = 0;     // previous state of the button

void setup() {
  myservo.attach(9);
  myservo.write(90);
  delay(1000);
  pinMode(buttonPin, INPUT);

  pinMode(ledPin, OUTPUT);

  Serial.begin(9600);
}

void loop() {
  myservo.write(90);
  buttonState = digitalRead(buttonPin);

  if (buttonState != lastButtonState) {

    if (buttonState == HIGH) {

      buttonPushCounter++;
      delay(500); // darbeleri alması için nefesleme.bu olmasa her darbede yüksek olur
    }
    if (buttonPushCounter % 2 == 0) {
      myservo.write(0);   //sağa döner
      delay(500);
      myservo.write(90);
      delay(500);
      Serial.println("WHITE");
      Newbuttoncounter = buttonPushCounter;

    }

    else if (Newbuttoncounter % 2 == 0) {

        myservo.write(180); //sola döner
        delay(500);
        myservo.write(90);
        delay(500);

      }

      else {

        lastButtonState = buttonState;
      }
    }
  }


texts: How is this code working?? val3 is defined as constant

texts:
const int val3 = 7;
void setup(){
  Serial.begin(9600);
  int val3 = 8;
  int val4 = 4;
  Serial.print(calc(val3,val4));
}

void loop()
{}

int calc(int val1, int val2)
{
  return val1 + val2;
}

this code gives output as 12.


texts: MPU9250 and ESP8266 are not working together with Arduino Uno

texts:
I am trying to send IMU sensor data via WiFi using ESP8266. Both MPU9250 and ESP8266 worked individually with 3.3 V when tested, but are not working when interfaced together. I am not sure what the problem is; it looks like the ESP8266 is getting connected to WiFi, but the IMU is having a problem.

First I connected the ESP and the IMU parallel with 3.3 V from the Arduino, but it did not work.
Then I connected the IMU separately with 5 V but still unsuccessful.

Connections of MPU9250

Connection of ESP8266

note:-
3.3 supply is common to esp and imu
reset is connected to ground
board selected in Arduino IDE is 'generic ESP8266'

code:

#include <ESP8266WiFi.h>
#define PubNub_BASE_CLIENT WiFiClient
#include <PubNub.h>
#define PUBNUB_DEFINE_STRSPN_AND_STRNCASECMP
#include "MPU9250.h"

const char *ssid =  "mym404";     // replace with your wifi ssid and wpa2 key
const char *pass =  "786110786";

const char * pubkey = "pub-c-4a9cdbca-5688-4939-a852-f63cf6743980";
const char * subkey = "sub-c-9b4067ae-1293-11e9-b4a6-026d6924b094";

const char * pubchannel = "demo_keyset";
const char * subchannel = "demo_keyset";

MPU9250 IMU(Wire,0x68);
int status;

void setup() {
    /* For debugging, set to speed of your choice */
    Serial.begin(115200);

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

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

    /* Start the Pubnub library by giving it a publish and subscribe
       keys */
    PubNub.begin(pubkey, subkey);

    while(!Serial) {}

  // start communication with IMU
  status = IMU.begin();
  if (status < 0) {
    Serial.println("IMU initialization unsuccessful");
    Serial.println("Check IMU wiring or try cycling power");
    Serial.print("Status: ");
    Serial.println(status);
    while(1) {}
  }
}

void loop() {
    // read the sensor
  IMU.readSensor();
  // display the data
  Serial.print(IMU.getAccelX_mss(),6);
  Serial.print("\t");

    /* Publish message. You could use `auto` here... */
    PubNonSubClient *pclient = PubNub.publish(pubchannel, "String(IMU.getAccelX_mss())");
    if (!pclient) return;
    PublishCracker cheez;
    cheez.read_and_parse(pclient);
    /** You're mostly interested in `outcome()`, and,
        if it's "failed", then `description()`.
    */
    Serial.print("Outcome: "); Serial.print(cheez.outcome());
    Serial.print(' '); Serial.println(cheez.to_str(cheez.outcome()));
    Serial.print("description: "); Serial.println(cheez.description());
    Serial.print("timestamp: "); Serial.println(cheez.timestamp());
    Serial.print("state: "); Serial.print(cheez.state());
    Serial.print(' '); Serial.println(cheez.to_str(cheez.state()));
    pclient->stop();

    /* Wait for news. */
    PubSubClient *sclient = PubNub.subscribe(subchannel);
    if (!sclient) return; // error
    String msg;
    SubscribeCracker ritz(sclient);
    while (!ritz.finished()) {
        ritz.get(msg);
        if (msg.length() > 0) {
            Serial.print("Received: "); Serial.println(msg);
        }
    }
    sclient->stop();

    delay(1000);
}

I didn't get any error but here is the serial port message:-

.....
WiFi connected
IMU initialization unsuccessful
Check IMU wiring or try cycling power
Status: -1

Soft WDT reset

>>>stack>>>

ctx: cont
sp: 3ffffdf0 end: 3fffffc0 offset: 01b0
3fffffa0:  3fffdad0 00000000 3ffeec60 40206dd0
3fffffb0:  feefeffe feefeffe 3ffe8538 4010150d
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(1,7)

What could be the problem here?


texts: How to send Arduino Yún Post Request to localhost?

texts:
I've been trying to send data from my Arduino Yun to a local server using XAMPP. My code is shown below. In the serial monitor of the Arduino Yún, it shows connected and prints the data string, but in the server nothing is showing up. I don't know what's wrong. Maybe this doesn't work on a localhost? Any help would be much appreciated.

I've updated the Arduino code from something I found here.

send_data_ws.ino

#include <Bridge.h>
#include <Console.h>
#include <FileIO.h>
#include <HttpClient.h>
#include <Mailbox.h>
#include <Process.h>
#include <YunClient.h>

IPAddress server(192,168,1,200);
YunClient client;

String parametri="";
int x1,x2,x3;

void setup() {
  Bridge.begin();
  Serial.begin(9600);
  pinMode(A0,INPUT);
  pinMode(A1,INPUT);
  pinMode(A2,INPUT);
  String parametri ="";
  delay(2500);
  Serial.println("connecting...");
  x1 = analogRead(A0);
  x2 = analogRead(A1);
  x3 = analogRead(A2);
  if (client.connect(server, 80)) {
    Serial.println("connected");
    delay(2500);
    parametri="x1="+String(x1)+"&x2="+String(x2)+"&x3="+String(x3);
    client.println("POST /arduino/index.php HTTP/1.1");
    client.print("Content-length:");
    client.println(parametri.length());
    Serial.println(parametri.length());
    Serial.println(parametri);
    client.println("Connection: Close");
    client.println("Host:192.168.1.200");
    client.println("Content-Type: application/x-www-form-urlencoded");
    client.println();
    client.println(parametri);
 } else {
   Serial.println("connection failed");
 }
}

void loop() {
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;);
  }
}

index.php

<?php
echo 'running....';
if ($_SERVER["REQUEST_METHOD"] == "POST"){
    $x1 = $_POST['x1'];
    $y1 = $_POST['x2'];
    $z1 = $_POST['x3'];
    echo 'x1: ' . $x1 . '
x2: ' . $x2 . '
x3:' . $x3 . '
';
}
?>

The Serial Monitor shows the PHP code using client.read() and as you can see it displays the data I sent to the PHP file, but in my server nothing shows up, only the running.... line shows up.


texts: What type of connector does the GROVE system use?

texts:
What type of connector does GROVE use?

I'm interested in wiring some old sensors so they're compatible with GROVE, so I first need to identify the connector so I can buy the housing and pins to crimp. It looks to be some type of JST connector, but there are many different sizes, each with incompatible pitches and a lot of retailers often advertise them incorrectly. Unfortunately, I can't find any documentation of the connector on Seeedstudio's site.


texts: It is possible an Arduino generate 3d graphics on tft or vga

texts:
It is possible to an Arduino render 3d graphics like very low polygonal 3d models or generating lighting efects non realtime shadows or realtime shadows and reflections. Rendering like first 3d video game consoles.
Someone can ask why you don't use an Rasberry Pi. Beacuse Linux can be more complex. Also Rasberry Pi is a computer runs Linux .Linux is hard and some people can say you can install Windows but it doesn't give freedom as Arduino on Arduino you have more control on system.It doesn't run operating system but Rasberry pi runs and you needed write programs for it. You can't do much  anything ( at least i know) than Linux or Windows will allow.

My goal was running very basic 3d graphics on a Vga.
Theres no rule it can be like old dos games.Fake 3d effect like distorting sprites to look like 3d and rotate them move change coordinates change camera position like a 3d but it's actually generating fake depth.
Must camera position controllable . Like a video game.

Sprites,effects are completely pre rendered. Only realtime rendered thing was distorting sprites by camera position. Changing room (Square area will reset view that will make after another room it would show another room).

Is there a library can done that?

Your solution can be for another Arduinos.

Your solution can be Arduino dependent. Like only works for due,mega etc.

Theres a vga library for Due supports 256 colors your solution can use this library problary called DueVGA


texts: Consequences of dynamically changing input/output configurations of digital pin?

texts:
I am creating an IC checker for a large chunk of the 74ls series (basic TTL logic chips), which means that I have 14 pins running to the IC to verify its functionality. One pin is power (+5V) and another ground (GND), which are both consistently in the same seven and fourteen pin positions respectively, but the remaining 12 are various inputs and outputs that vary depending on the IC type.

With that stated, will there be any consequences to dynamically reconfiguring a pin from input to output -- or vice versa -- as different IC types are selected? Weird behavior or electrical failure? What if the IC remains plugged in while the the pins reconfigure? What if said IC is powered on and providing power to a pin as it reconfigures?

If you were curious, I am using a joystick and LCD display as an interface to selecting the appropriate IC to check.


texts: I am using a Arduino Pro Micro as a keyboard (USB HID device). Each time I press a key, the RX LED and TX LED light up. Can I switch them off in software?


texts:
I need to connect piezoelectric accelerometer to Arduino. Precisely, it's this one: http://www.pcb.com/Products.aspx?m=352C34

Specs show that it generates 100 mV/g, but when I connected it between ground and analog input with 1M pulldown resistor, analog input stays at 0.

Arduino analog input resolution and accuracy is absolutely fine for now.

Could someone point me to right direction in connecting this kind of sensor to Arduino?


texts: Using CoolTerm to receive Serial Data into a saveable file

texts:
Have functional code that reads data from sensors. Found that I need to use a terminal program to grab the data from the serial output using CoolTerm by Roger Meier.

Wasn't able to test it with my code yet because of this issue: (No Data Received on Serial Port & Unable to DFU Reset. Advice?).

Watched some videos and read some tutorials - does CoolTerm only come into play once I'm running the code? Can you write code for the arduino to automatically save stuff?


texts: What will happen if I supply greater than 1.1V to analogue inputs if analogReference set to INTERNAL?

texts:
I am reading a 50Hz AC voltage using the analogue inputs.

If I set the analogReference() to INTERNAL, meaning 1.1V on the Arduino Uno, what will happen if a voltage greater than 1.1V is supplied to the pin? Will the board be damaged? If not, what value will the ADC give?


texts: Why is 1020 steps used for crossfading colors on an RGB LED?

texts:
I'm looking into how to smoothly crossfade between colors on an RGB LED with the Arduino and I've found this piece of code for doing it:
https://www.arduino.cc/en/Tutorial/ColorCrossfader

I understand all parts of the code except for one thing.
The values for red, green and blue are changed incrementally through 1020 steps, because 255*4 = 1020.
But WHY 4? There are 3 colors, and 255 * 3 = 765. So why not 765 steps?


texts:
For a battery charging project, i am using an ARDUINO UNO which is driving a buck converter to provide the battery with the charging current. I am using external ADCs to measure the battery's charging voltage and current. The test setup is working fine, but right now i am just measuring the voltage and current at random time instants. However to measure it correctly, battery voltage reading should be done at an instant when the controller's PWM output is LOW (OFF duty cycle), and battery current reading should be done when PWM output is HIGH (ON duty cycle).

I looked into interrupts and learned about them that there are 2 types of interrupts in Arduino namely "external", and "pin change". So i downloaded the "PinChangeInt Library" to test it. I wrote a small test program where a PWM of 62.5kHz is being generated on pin3, and i am calling rising and falling edge triggered interrupts on this pin, i.e to display one value when rising edge occurs, and other value when falling edge occurs.  My code looks like following:

    #include <PinChangeInt.h>
    #define pw 3
    int pwm;

    void setup() {
      // put your setup code here, to run once:
      pinMode(pw, OUTPUT) ;
      pwm_setup();             // Set PWM to a frequency of 62.5kHz

      PCintPort::attachInterrupt(pw,rise,RISING);    // call void rise() when PWM is HIGH
      PCintPort::attachInterrupt(pw,fall,FALLING);   // call void fall() when PWM is LOW

      Serial.begin(9600);
    }

    void loop() {
      // put your main code here, to run repeatedly:
      pwm = 127;                                                // 50% duty cycle
      pwm_on(pwm);

    }
    void pwm_setup()
    {

      TCCR2A = 0x23 ;
      TCCR2B = 0x09 ; // mode 7, clock prescale by 1
      OCR2A = 256-1 ;  // 256 clock periods = 16us per cycle
      OCR2B =0 ;
      TCNT2 =0 ;

    }
    void pwm_on(double)
     {
        OCR2B = pwm ;
     }

    void rise()
    {
      Serial.println("RISE");
    }

void fall()
{
  Serial.println("fall");
}

But it is not working the way i think it should. It keeps on displaying "fall" every time, whereas according to me it should display "RISE" and "fall" alternatively, right ? However if i remove the "PCintPort::attachInterrupt(pw,fall,FALLING); " line, it starts to display "RISE" as it is supposed to.

Since its my first time programming with Arduino, and i am just a beginning level programmer, i might be making some stupid mistake here. So can anyone point it out please ?

Your helpful comments and suggestions would be appreciated.
Thankyou!


texts: How to find out if HX711(amplifier and 24-bit ADC) is damaged or not?

texts:
I'm using this ADC with a load cell for weight measurement, I had 4 strain gauges and mounted them on a cantilever structure that I made out of acrylic sheet, used calibration program from here: https://github.com/olkal/HX711_ADC/blob/master/examples/Calibration/Calibration.ino,
followed the steps but it gave calibration factor as 0.00 and the output was NaN or inf . I used another program from here: https://github.com/queuetue/Q2-HX711-Arduino-Library/tree/master/examples/simple_scale and the output was just hovering around 83868. So I thought that the mounting was the problem and used a load cell (green label, CZL 601) with the above and found the same results by doing the above.
Then I thought maybe the ADC is at fault , measured the power output from Arduino to the board and it was around 5 V , but when I measured between the E+ and E- , I got 0 V. Since it is the excitation voltage to the bridge, it should be around 5V too right?
Is this the right way of checking the board?
P.S. I measured the four wires of the load cell and connected the opp. ends of the bridge to the E+ , E- , A+ , A- (order doesn't matter here right? connected the pairs that showed the rated resistance to E's and A's separately)
Here's a [pic][1] of the connections
Between White and green wire the Resistance is 350 ohm
Between Bk( connected in the board ) and the red it is 408 ohm
Between White and red it was 263 ohm
Between white and bk it is 320 ohm
Between bk(not connected in the board) and all others it is around 1 MOhm (so ignored that)
[1]: https://photos.app.goo.gl/4HEmZaN1EwZ7Mjur7


texts: I have a circuit board / device that can be in different states. It indicates in which state it is by turning on one of three LED's. Now I want to use an ESP8266 to tell me (over the network) the current state. What kind of circuit would I need for this? (I have thought about using photodiodes, but I would much rather solder something directly to the board)


texts: this is the code , and it never connects to the wifi ,i dont know what to do , the code is an example in the blynk library


texts: Is it possible to have two serialEvent() in Arduino code?

texts:
I am developing a code on Arduino and need to implement a condition that if data is available form "serial2" then only get the input for "Serial" terminal of Arduino.

I have tried with below code, but its behavior is when I am sending something from "serial" terminal of arduino, control goes into the loop "serialEvent()" otherwise even if I am sending the data over "serial2" it is not entering in that loop.

Below is my code snippet:

void serialEvent()
{
  int DATAaddressMSb, DATAaddressLSb;
  digitalWrite(DIR485, LOW);
  delay(100);
  delay(10);
  while (Serial2.available()>0)
  {
    Serial.println("serial2 data available");
    int i = 0;
    int bufferIn1[9] = { int(0x00), int(0x00), int(0x00), int(0x00), int(0x00), int(0x00), int(0x00), int(0x00), int(0x00) };
    bufferIn1[i] = Serial2.read();
    Serial.print(bufferIn1[i], DEC);
    Serial.print(" ");
    if(i == 0){Serial.print("BUFFER VAL 0");
    Serial.print( bufferIn1[i], DEC);}
    if(i == 1){Serial.print("BUFFER VAL 1");
    Serial.print( bufferIn1[i], DEC);}
    if(i == 2){Serial.print("BUFFER VAL 2");
    Serial.print( bufferIn1[i], DEC);}
    i++;
  }

  while (Serial.available()&& pos < sizeof my_str - 1) {
    char c = Serial.read();
    if (c == '\n') {            // \n means "end of message"
            my_str[pos] = '\0';     // terminate the buffer
            pos = 0;                // reset to start of buffer
            String str((char*)my_str);    // converte char array in string
            if (str == "PCB-CODE") { Serial.println(SN_CODE); }
            if (str == "FW-VERSION") { Serial.println(FW_ver); }
            if (str == "STOP" ) { TESTcode = 0; IDcode = 999; }
            if (str == "TEST1") { TESTcode = 1; delay(6000); Serial.println("Enter ID "); }
            if (str == "TEST2") { Serial.println("Initialising Board ");  delay(6000); TESTcode = 2; }           // For all tests

            if (str == "ID0") { IDcode = 999; }
            if (str == "ID1") { delay(60); IDcode = 1; }       // Test for FW version
            if (str == "ID2") { IDcode = 2; }       // Test for 3.3V
            if (str == "ID3") { IDcode = 3; }       // Test for Main power
            if (str == "ID4") { delay(50); IDcode = 4; }       // Test for +15V
            if (str == "ID5") { IDcode = 5; }       // Test for +10V
            if (str == "ID6") { IDcode = 6; }       // Test for +8V
            if (str == "ID7") { IDcode = 7; }       // Test for +5.5V
            if (str == "ID8") { IDcode = 8; }       // Test for +1.2V
            if (str == "ID9") { IDcode = 9; }       // Test for +2.5V
            if (str == "ID10") { IDcode = 10; }     // Test for -15V
            if (str == "ID11") { IDcode = 11; }     // Test for POW_LIGHT
            if (str == "ID12") { IDcode = 12; }     // Test for +s_stab
            if (str == "ID13") {delay(50); IDcode = 13; }     // Test for +CELLA
            if (str == "ID14") { IDcode = 14; }     // Test for FPGA_GPIO
            if (str == "ID15") { IDcode = 15; }     // Test for DAC_OUT
            if (str == "ID16") { IDcode = 16; }     // Test for CURRENT_LOOP
            if (str == "ID17") {delay(50); IDcode = 17; }     // Test for Torque signal
            if (str == "ID18") { IDcode = 18; }     // Test for EXT_TRIGGER
            if (str == "ID19") { IDcode = 19; }     // Test for Encoder
            if (str == "ID20") { IDcode = 20; }     // Test for RAM
            if (str == "ID21") { IDcode = 21; }     // Test for SD Card
            if (str == "ID22") { IDcode = 22; }     // Test for Ethernet
            if (str == "ID23") { IDcode = 23; }     // Test for CAN
            if (str == "ID24") { IDcode = 24; }     // Test for I2C
     for( int i = 0; i < sizeof(my_str);  ++i )    // resetta la stringa ricevuta         // reset the received string
          my_str[i] = (char)0;
        }
        else {my_str[pos++] = c;}
  }
 }

Please guide. Thank you........


texts: Generate single pulse from timer 1 in arduino nano

texts:
i have a code that shot a single pulse from pin D5 timer 0 (based on josh levine code), it works fine. the code is below

#define OSP_SET_WIDTH(cycles) (OCR0B = 0xff-(cycles-1))
void osp_setup(uint8_t cycles) {
    TCCR0B =  0;
    TCNT0 = 0x00;
    OCR0A = 0;
    OSP_SET_WIDTH(cycles);
    TCCR0A = _BV(COM0B0) | _BV(COM0B1) | _BV(WGM00) | _BV(WGM01);
    TCCR0B = _BV(WGM02) | _BV(CS00);
    DDRD |= _BV(5);
}

void osp_setup() {
    osp_setup(1);
}

#define OSP_FIRE() (TCNT0 = OCR0B - 1)
#define OSP_INPROGRESS() (TCNT0>0)
#define OSP_SET_AND_FIRE(cycles) {uint8_t m=0xff-(cycles-1); OCR0B=m;TCNT0 =m-1;}

void setup()
{
    osp_setup();
}

void loop()
{
    OSP_SET_AND_FIRE(4);
    delayMicroseconds(20);
}

however, i want to generate the same pulse in pin 10 or 9 which is timer 1, so a change the code a bit just like this

#define OSP_SET_WIDTH(cycles) (OCR1B = 0xff-(cycles-1))
void osp_setup(uint8_t cycles) {
    TCCR1B =  0;
    TCNT1 = 0x00;
    OCR1A = 0;
    OSP_SET_WIDTH(cycles);
    TCCR1A = _BV(COM1B0) | _BV(COM1B1) | _BV(WGM10) | _BV(WGM11);
    TCCR1B = _BV(WGM12) | _BV(CS10);
    DDRD |= _BV(10);
}

void osp_setup() {
    osp_setup(1);
}

#define OSP_FIRE() (TCNT1 = OCR1B - 1)
#define OSP_INPROGRESS() (TCNT1>0)
#define OSP_SET_AND_FIRE(cycles) {uint8_t m=0xff-(cycles-1); OCR1B=m;TCNT1 =m-1;}

void setup()
{
    osp_setup();
}

void loop()
{
    OSP_SET_AND_FIRE(4);
    delayMicroseconds(20);
}

but it doesn't work, and i am stuck, any help? i use arduino nano

Thank you


texts: This specific code just refuses to compile?

texts:
I've been working on some software to do REALLY basic composition of music.
Here's my code so far:

#include "notes_sharps.h"

int notes[] = {NOTE_B0,NOTE_C1,NOTE_D1,NOTE_E1,NOTE_F1,NOTE_G1,NOTE_A1,NOTE_B1,NOTE_C2,NOTE_D2,NOTE_E2,NOTE_F2,NOTE_G2,NOTE_A2,NOTE_B2,NOTE_C3,NOTE_D3,NOTE_E3,NOTE_F3,NOTE_G3,NOTE_A3,NOTE_B3,NOTE_C4,NOTE_D4,NOTE_E4,NOTE_F4,NOTE_G4,NOTE_A4,NOTE_B4,NOTE_C5,NOTE_D5,NOTE_E5,NOTE_F5,NOTE_G5,NOTE_A5,NOTE_B5,NOTE_C6,NOTE_D6,NOTE_E6,NOTE_F6,NOTE_G6,NOTE_A6,NOTE_B6,NOTE_C7,NOTE_D7,NOTE_E7,NOTE_F7,NOTE_G7,NOTE_A7,NOTE_B7,NOTE_C8,NOTE_D8};

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

  for(int i = 0; i < 51; i++){
    Serial.println("%i's sharp is %i",notes[i], notes[i]+(notes[i]*0.05937));
  }
}

void loop(){}

This code just refuses to compile, no error messages, it simply leaves my computer dormant.
Here's the log:

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10604 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard C:\Users\anidude\AppData\Local\Temp\build38239327143584304.tmp\sharpscalc.cpp -o C:\Users\anidude\AppData\Local\Temp\build38239327143584304.tmp\sharpscalc.cpp.o


texts:
I am following this tutorial and have an MPU-6050 connected to an Arduino Micro with the following connections

  VCC - 5V/3.3V
  GND - GND
  SDA - A2
  SCL - A3

I'm trying to run the short example sketch:

// MPU-6050 Short Example Sketch
// By Arduino User JohnChi
// August 17, 2014
// Public Domain
#include <Wire.h>
const int MPU_addr=0x68;  // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;

void setup(){
  Wire.begin();
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x6B);  // PWR_MGMT_1 register
  Wire.write(0);     // set to zero (wakes up the MPU-6050)
  Wire.endTransmission(true);
  Serial.begin(9600);
}

void loop(){
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
  Wire.endTransmission(false);
  Wire.requestFrom(MPU_addr,14,true);  // request a total of 14 registers
  AcX=Wire.read()<<8|Wire.read();  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
  AcY=Wire.read()<<8|Wire.read();  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
  AcZ=Wire.read()<<8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
  Tmp=Wire.read()<<8|Wire.read();  // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
  GyX=Wire.read()<<8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
  GyY=Wire.read()<<8|Wire.read();  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
  GyZ=Wire.read()<<8|Wire.read();  // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
  Serial.print("AcX = "); Serial.print(AcX);
  Serial.print(" | AcY = "); Serial.print(AcY);
  Serial.print(" | AcZ = "); Serial.print(AcZ);
  Serial.print(" | Tmp = "); Serial.print(Tmp/340.00+36.53);  //equation for temperature in degrees C from datasheet
  Serial.print(" | GyX = "); Serial.print(GyX);
  Serial.print(" | GyY = "); Serial.print(GyY);
  Serial.print(" | GyZ = "); Serial.println(GyZ);
  delay(333);
}

But the output keeps showing -1 for all the fields.

Are these values actually correct or am I doing something wrong?


texts: Is it possible to do an OTA update using a GitHub link

texts:
I need to be able to download software updates through the internet without having my MKR1000 plugged in. Either that or have new code being pushed from my server (C++) to my MKR1000, and then rebooting with the new code.
Any help is useful.
Thanks.


texts: Arduino Mega, Ubuntu, Time.h: No such file or directory

texts:
I'm using an Arduino Mega with Ubuntu 15.10.

Sadly I've got an error during compilation, that the Time.h library cannot be found. The verbose compile output shows:

/usr/share/arduino/hardware/tools/avr/bin/avr-g++ -c -g -Os -Wall
-fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega2560
-DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105
-D__PROG_TYPES_COMPAT__
-I/usr/share/arduino/hardware/arduino/cores/arduino
-I/usr/share/arduino/hardware/arduino/variants/mega
-I/usr/share/arduino/libraries/LiquidCrystal
-I/usr/share/arduino/libraries/SPI
/tmp/build6998056390288565759.tmp/Home_Guard.cpp -o /tmp/build6998056390288565759.tmp/Home_Guard.cpp.o
**Home_Guard.ino:2:20: fatal error: Time.h: No such file or directory**
compilation terminated.

I've already tried to use "time.h" instead of "Time.h" but it doesn't help.


texts: Attiny85 microcontroller programming without arduino

texts: I have decided to make a simple project so thinked about arduino but that seems very worthy so i decided to use attiny85 ic for my project,but i don't have arduino or avr to program it. Is there any way to program the below ic without arduino or avr?.


texts: Arduino - manually ceate objects (e.g. WiFi library)

texts:
By default, if i include the WiFi library, the object WiFi will be registered globally. How can i disable this behavior without changing the library file itself? (removing the definition "extern ...")
Or is there a way to delete the objects right after the inclusion? I just want to create the object manually when needed to save memory.


texts: Arduino communicate between 2 different router in different location

texts:
I am on my final year project in I.T. my project is that i want to create a helicopter or quadcopter with a camera attached to it. And i want to control the copter via wifi from an android phone in another location. e.g, the copter is at home and i am somewhere else (work, university etc..). so i wanted to know if i can connect both via 2 different routers and control it and get the live video the camera is actually recording (the idea is to monitor your house when you are away). if that is possible, which arduino hardware will enable me to do that.
Thank you.


texts: Controlling 20 servo motors independently with a single Arduino

texts:
I am wondering if I can control 20 different servo motors with only a single Arduino Uno board. My motors must be able to rotate in both directions and I also should be able to define the speed for each of them independently. Also I am able to use integrated circuits or a device that connects to my Arduino board.

Is this a possible scenario?


texts:
So I recently bought an Arduino along with an LCD module and two extra ATmega328P-PU ICs. Yesterday it was working just fine then I disconnected everything and reconnected it and this happened.
What could possibly go wrong?
Setup:

with microcontroller that came with the board:


texts: Lag in fetching serial data from Arduino

texts:
I am working on a project based on Arduino and python3.6,two HC-SR04 sense the distance of palms and process the data using Arduino and send it through serial port to python3.6 ,python3.6 with the help of pyserial ,pyautogui based on data from arduino controls a game named supertuxcart,a racing game,basically the thought behind this is  controlling game with palms instead of keyboard or mouse .But the problem am facing is Arduino takes the distance measurement data from two HC-SR04(one for each hand) ultrasonic sensors, processes according and sends processed data through serial port to python3.6 ,there while running the my python script i open the game to check if its working ,it works, but there is lag in data received from arduino thus turn the game messy.

here is arduino code am using with NewPing library

#include <NewPing.h>
int trig1=9;
int echo1=6;
int trig2=7;
int echo2=5;
int R;
int L;
NewPing right(9,6,100);
NewPing left(7,5,100);
void setup() {

  pinMode(9,OUTPUT);
  pinMode(8,OUTPUT);
  pinMode(6,INPUT);
  pinMode(5,INPUT);

}

void loop() {
  Serial.begin(9600);
  //Serial.println("hi,am arduino");
  R=right.ping_cm();
  L=left.ping_cm();
  //Serial.println(R);
  //Serial.println(L);
  delay(0000);
 if (R==0 && L==0){
    Serial.println('0');
  }
  else if(R<L&&L-R>5){
    Serial.println('1');
  }
  else if(R>L&&R-L>5){
    Serial.println('2');

delay(3000);

  }

}

Here is python3.6 code am using

import serial
import pyautogui
import time

Arduino = serial.Serial('/dev/ttyACM0', 9600)
time.sleep(0)
print(Arduino.readline())
pyautogui.keyDown('up')
while 1:
    Data = Arduino.readline()
    print(Arduino.readline())

    if Data == b'0\r\n':
        pyautogui.keyUp('up')
        pyautogui.keyUp('right')
        pyautogui.keyUp('left')
        break
    elif Data == b'1\r\n':
        pyautogui.keyUp('left')
        pyautogui.keyDown('right')
    elif Data == b'2\r\n':
        pyautogui.keyUp('right')
        pyautogui.keyDown('left')


texts:
am stuck with something simple which is concating string not sure what am doing wrong , am getting exception (3 ) error due to it

3   LoadStoreErrorCause Processor internal physical address or data error during load or store

my code

    String HOST = "useotools.com";
    String API_URL = "/iot/api.php";   // API URL
    uint16_t HTTPS_PORT = 4000;  // HTTPS port
    uint16_t HTTP_PORT = 4001;  // HTTP port

void https_request_function(){
String HOST_URL = "http://"+String(HOST)+":"+String(HTTP_PORT)+String(API_URL)+"";

}

when first time https_request_function() is called then HOST_URL is displayed correctly and on 2nd time when this function is called by code it trigger exception(3) which is strange .


texts:
I am trying to write a simple program that will cycle through an array using push buttons. My current version of the program uses if statements and prints lines.

My goal is to have contact information for 4 people stored in an array. I can either have an array of strings per person or make different arrays of strings for the different type of information (ie names, phone numbers).

I would like one push button to cycle through the data in one direction and another push button to cycle through the data in the other direction. This is my code so far using the if statements. I modified the code from a traffic light tutorial hence you will see some of the variables named after colors.

//------------------------------- Declare variables
int ledPinOne = 2;
int ledPinTwo = 3;
int ledPinThree = 4;
int ledPinFour = 5;
int buttonPin = 6;
int state = 0;
char user_name_array[32];
char econ_one_name_array[32];
char econ_two_array[32];
char econ_three_name_array[32];

//------------------------------- Setup
void setup() {
  Serial.begin(9600);
  //------------------------------ Sets pins for I/O
  pinMode(ledPinOne, OUTPUT);
  pinMode(ledPinTwo, OUTPUT);
  pinMode(ledPinThree, OUTPUT);
  pinMode(ledPinFour, OUTPUT);
  pinMode(buttonPin, INPUT);
  Serial.println("ID");
  Serial.println(user_name_array);
}

//------------------------------- Main Program
void loop() {
  if (digitalRead(buttonPin)) {
    if (state == 0) {
      Serial.println("Athlete");
      Serial.println("John Smith");
      Serial.println("No allergies, no medications");
      Serial.println("  ");
      setLights(HIGH, LOW, LOW, LOW);
      state = 1;
    } else if (state == 1) {
      Serial.println("Emergency Contact - Sister");
      Serial.println("Eliza Smith");
      Serial.println("Cell - 333.888.777");
      Serial.println("  ");
      setLights(LOW, HIGH, LOW, LOW);
      state = 2;

    } else if (state == 2) {
      Serial.println("Emergency Contact - Hermosita");
      Serial.println("Jackie Smith");
      Serial.println("Cell - 777.888.7777");
      Serial.println("  ");
      setLights(LOW, LOW, HIGH, LOW);
      state = 3;
    } else if (state == 3) {
      Serial.println("Emergency Contact - Father");
      Serial.println("Michael Smith");
      Serial.println("Cell - 888.777.777");
      Serial.println("  ");
      setLights(LOW, LOW, LOW, HIGH);
      state = 0;
    }
    delay(1000);
  }
}

void setLights(int red, int yellow, int green, int blue) {
  digitalWrite(ledPinOne, red);
  digitalWrite(ledPinTwo, yellow);
  digitalWrite(ledPinThree, green);
  digitalWrite(ledPinFour, blue);
}

I also have a 4-LED setup. When the button is pushed one of the LEDs turns on and then when the button is pushed again it turns off and turns the second one on and so forth.

Thank you in advance for any help.

EDIT:

This question was asked again in a more detailed way and has more answers here:

Using a button to cycle an array


texts: DIfferent baud rates of 434 MHZ transceiver

texts: What are the different baud rates that I can set for 434 MHZ Transmitter? (I am using Arduino UNO and RadioHead lib to change the baud rates)


texts: Sending Variable to IFTTT via ESP32 using Asynchronous Web Server

texts:
I have been trying to send three variables to IFTTT from my ESP32 using Asynchronous Web Server. However, I couldn't set the "URL" that was supposed to be the response that will trigger my IFTTT. Here's is my code:

server.on("/ifttt", HTTP_GET, [](AsyncWebServerRequest *request){

String jsonObject = "{\"value1\":\"" + Global_T + "\"" + ",\"value2\":\"" + Global_H  + "\"" + ",\"value3\":\"" + Global_K +  "\"}";

AsyncWebServerResponse *response = request->beginResponse(200, "application/json", jsonObject);

response ->addHeader("Host", server_ifttt);
request ->send(response);
});

It shall get triggered every fixed interval that I have set, and enter here to send it to IFTTT, but this is how it looks like. I not sure where should I add in the "URL" so that the response could be directed to IFTTT.


texts:
Its being a few days i am trying to achieve something that I dont really know if possible.
Using the Samd21 chip(Arduino Zero), I am using a timer and a DAC to produce a sine wave.

The required frequencies are 100Khz to 3Mhz. I know its sounds too much, but according to my calculations its possible- I would like to know if I am wrong with my software approach.

Pseudo is this :

1.I create a look-up table of a sine wave = array of a sine samples that holds N samples
2.I use a timer with a pre scale of 1, where the clock speed is 48Mhz
3.Each timer tick I produce from the DAC 1 sample from the sine wave
4.To change frequencies I am changing the timer top counter value.

If we try to speak about the max frequency, according to Nyquist , a 3MHz sine must be sampled with at least 6MHz sample rate, and my sine array has 15 samples, means 45Mhz sampling rate.(=good)

Then the sine frequency is :

sineF= TimerF*sineSamples = TimerF*15

Than means I need a timer frequency of :

TimerF=15*sineF = 15*3Mhz=45MHz

So, both are good, the timer max f can be 45Mhz, and the sampling rate is good according to Nyquist.

The only concern here, is if the DAC can do that(speed), and if changing the timer frequency fast enough (even every period) is acceptable.

Is this whole software approach true ?
If its not, producing a square wave probably possible,since it requires much less speed, but then, can you turn it into a nice clean sin wave with filters?

Thanks.


texts: Infrared distance sensor picks up distances that are not there

texts:
I have connected an Infrared sensor to my Arduino Uno and I've set this code up to blink whenever a distance of less than 50 cm is picked up. If there is an object less than 50 cm away, it does pick it up. However, with nothing in front of it it still blinks at random intervals. The sensor is new. Where do you think the problem is?

int sensorPin = 0;
int ledPin = 13;

void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop() {
  float distance = 12343.85 * pow(analogRead(sensorPin),-1.15);
  if(distance < 50){
    digitalWrite(ledPin, HIGH);
    delay(1000);
    digitalWrite(ledPin, LOW);
  }
  delay(50);
}


texts: Interleave Assembly and Source for avr-objdump

texts:
Trying to get avr-objdump to generate a listing that interleaves the assembly with the source code. I've tried a bunch of debugging arguments in different configurations but I can't seem to get it. The best I could do was getting it to interleave the object with line numbers from the assembly (avr-objdump -lS spi.o)

Original Makefile

Here's my current Makefile:

PREFIX=avr-
CC=${PREFIX}gcc
OBJCOPY=${PREFIX}objcopy

BIN=knightrider
MCU=attiny85
OBJS=../src/tinySPI.o src/knightrider.o

PROG?=atmelice_isp
PORT?=usb

CFLAGS=-g -mmcu=${MCU} -ffunction-sections -fdata-sections
LDFLAGS=-mmcu=${MCU} -Wl,--gc-sections

${BIN}.hex: ${BIN}.elf
    @mkdir -p bin
    ${OBJCOPY} -O ihex -R .eeprom build/$< bin/$@

${BIN}.elf: ${OBJS}
    @mkdir -p build
    ${CC} ${LDFLAGS} -o build/$@ $?

install: ${BIN}.hex
    avrdude -c ${PROG} -P ${PORT} -p ${MCU} -U flash:w:${BIN}.hex:i -qq

clean:
    rm -f build/*
    rm -f bin/*

fuses:
    avrdude -c ${PROG} -P ${PORT} -p ${MCU} -U lfuse:w:0x62:m -U hfuse:w:0xDF:m -U efuse:w:0xFF:i -qq

What would I need to change in order to run avr-objdump and get an interleaved listing of an .o and its corresponding .c (e.g. spi.o and spi.c)?


texts: Is it problematic to 'check an input pin' or 'set an output pin' each step?

texts:
I am using an Arduino in an automation project which will be using a state machine to conduct a one-hour scenario.  Currently, the Arduino reads each input pin, runs its state update script, then sets each update pin.  99.99% of the time, each output pin will be set to the same state that it had in the last step.  Although it is better (in my opinion) to only set the pin when a setting changes, I was wondering if constantly checking and setting pins would have a big negative impact on the hardware?

Would checking a pin's current state (digitalRead or other method) before setting the pin improve anything?


texts: Analog Comparator works on Nano, but not working on Pro Mini 3.3v

texts:
I've coded an analog comparator to work on Nano, but the same code does not work on a brand new Pro Mini 3.3v 8MHz. The serial monitor just outputs the triggered interrupt continuously. Lines orange and yellow have the potentiometer.

The code is:

#define INDICATOR_PIN 8

volatile boolean triggered;
volatile boolean rising;
volatile byte acsr_value;

ISR (ANALOG_COMP_vect) {
  if (triggered) return;           // For testing purposes, ignore the interrupt if we haven't reported the last one yet.
                                   // This also effects some crude debouncing.
  cli();
  acsr_value = ACSR;
  rising = (acsr_value & bit(ACO)) > 0;
  triggered = true;
  sei();
}

void setup() {
  Serial.begin (115200);
  Serial.println ("Started.");

  pinMode(INDICATOR_PIN, OUTPUT);
  digitalWrite(INDICATOR_PIN, LOW);

  ADCSRB = ADCSRB & ! bit(ACME);   // disable Analog Comparator Multiplexer Enable
  ACSR =  bit(ACI)                 // clear Analog Comparator Interrupt Flag
        | bit(ACIE)                // set Analog Comparator Interrupt Enable
        | bit(ACIS1) | bit(ACIS0)  // select rising edge: ACIS1/ACIS0 Analog Comparator Interrupt Mode Select
        ;
}

void loop() {
  if (triggered) show_what_happened();
}

// just give an indication via Serial and LED that we handled an interrupt...
void show_what_happened() {
  digitalWrite(INDICATOR_PIN, HIGH);

  Serial.print ("Triggered! ACSR=");
  Serial.print (acsr_value, BIN);
  if (rising)
    Serial.println (" RISING EDGE (as expected)");
  else
    Serial.println (" FALLING EDGE .. wtf, didn't ask for this, but every so often one slips thru. Maybe a sync issue reading ACSR.");

  triggered = false;

  delay(100);
  digitalWrite(INDICATOR_PIN, LOW);
}

Why does it work well on Nano? I've read all the related sections in the datasheet and tested several ACSR configurations.

I'm seeing the voltage levels changes on a DSO, and it works as expected in the Nano.

I'd like to add that when loading the code to the board, it either prints nothing, or prints continuously RISING FALLING edge. Sometimes, when a connect the serial monitor, it just stops flashing the led. It is definitely an erratic behavior.

What am I doing wrong?


texts: Interruption triggered twice when set to FALLING

texts:
I have a simple sketch with a button that triggers an interruption set to happen when the button pin goes from HIGH to LOW. It has debouncing so no repetitions happen when the button is pressed, but sometimes when releasing the button the interruption also fires. Why would that be? Shouldn't the debouncing take care of any micro-rising during the release of the button?

volatile int contador = 0;
int n = contador;

long t = 0;
void setup() {

    pinMode(2, INPUT_PULLUP);
    attachInterrupt( 0, incrementaContador, FALLING);
}

void loop() {
    if (n != contador) {
        n = contador;
    }
}

void incrementaContador() {

    if ( millis() > (t + 50) ) {
        contador++ ;
        t = millis();
    }
}

This same code works correctly when set to LOW instead of FALLING.


texts: Does porting code to different MCU clock frequency affect serial baud rate?

texts: Tried to upload my Arduino Uno sketch that writes to serial UART at 9600 baud rate onto my ATtiny2313 running at 1MHz. Not getting the signal on the ATtiny, does this have to do with my clock frequency of the MCUs being 16 vs 1MHz?


texts: What does it mean when there are two addresses listed in the data sheet for a particular register?

texts:
I have been trying to grasp a better understand of registers and port manipulation. I have been looking through the ATmega 328P datasheet to look at the different registers.

For some of the registers, I see that there are two addresses listed. For example, for PORTB is listed at 0x05 (0x25). Similarly, for its DDRB and PINB, they are listed at 0x04 (0x24), and 0x03 (0x23), respectively. What does this mean for the register? Thank you.


texts:
I'm trying to make my chinese arduino (which use a chinese CH340G chip) speaks to itself via serial.
I have wired rx/tx together.

Then, I run the arduino IDE and go to the serial monitor.

When I write a message, the arduino should respond with the exact same message, right ? Actually, when I write a message, the arduino doesn't respond anything...


texts: External (pin change) interrupt and power consumption

texts: I want to write a lipoly powered arduino device that can be launched from sleep mode by pressing a certain key that is connected to ground. Usually, when no in sleep mode I enable the internal pull-up resistor for a definite level. But when in sleep mode, I assume this would drain to much power and hence I want to avoid it. Is it sufficient to just wait for a pin-change interrupt on the same port pin without the internal or an additional external pull-up resistor?


texts: The Arduino Uno (for some models) has the ability to dislodge its IC chip. You can mount this on a piece of perfboard and, in essence, have a permanent connection. I will need the beefier Arduino Due, but I do not know how to make permanent connections with this device. Is there any way to form some kind of permanent connection with this board?


texts:
Folks

I am planning to power my Arduino, which will be mounted on a motorcycle, using the motorcycle's battery. So the same battery will be starting the engine and powering other electrical components.

I am wondering if this circuit will work fine.

C1 - 1000uF 50V;
C2 - 1000uF 25V;
D1 - 1N4001 ;


texts:
Question: How does one prepare clothing with embedded electronics for washing?

Background: There are several Arduino boards/clones that are designed for "wearable tech."  (For example, the Lilypad.)  Wearable tech with LED light patterns, microphones, GPS, or other circuitry is an interesting concept, but water and electricity tend not to mix.

To prepare wearable tech for washing, I would assume people make large circuitry removable.  Yet, inevitably, some electronics will be more-or-less permanently affixed to the cloth.  What, if anything, can be done to these electronics (e.g. sewn-in Arduino Lilypad) to make them washing-machine (preferred--hand wash could be done, but it's so much easier to machine wash) safe?


texts:
Very broad question here.  I don't know exactly what the problem is but I'll edit this post as we narrow down the possibilities.

I think I'm running into memory constraints.

I'm running a sketch that records two temperature values every 60 seconds and transmits them to an AWS RDB via wifi.  It works well for about two hours then stops.  I don't know if it's a memory constraint but I suspect that it is.  What other common problems (often overlooked by newbies) can cause a sketch to end after a couple hours of run-time?

Is there a simple way to add an instruction to a loop to clear the SRAM?

Arduino UNO + WiFi 101

Edit #1 12/24/2015:It's the WiFi board.  It happily remains connected to my phone's hotspot but only lasts an hour or two on my home network.  Working on root cause...any ideas are welcome!

Edit #2 12/25/2015:Tried to Wifi.disconnect() and reconnect with no luck.  Why do some networks kick the board off while others work just fine?  Will look into the watchdog.


texts: Android Studio project for Redbearlab BLE Shield apps

texts: To interact with its BLE shield, Redbearlab published sample Android apps in the Play Store. The sources for the apps are available on GitHub. How can I build them in Android Studio?


texts: Using multiple sensors on ESP8266 Wifi module

texts:
I have an ESP8266 ESP-01 WiFi module.
I have a project where I need to use the following and send their data to a firebase database.

2x Force Sensitive Resistors(Sensor)

1x GPS module

My question is what GPS module can I use to send GPS location thru the ESP8266 Wifi module. My ESP-01 has only 2 GPIO. What should I do so I can use 2 FSR and GPS module at the same time send all 3 data to firebase realtime database.

Thanks


texts: Connecting Something Big to an Arduino - Sending more than 5V

texts:
So I am turning a relay on and off with my Arduino. I am using python to control it but wrote the simple basic code in the Arduino IDE. I am able to send 5 or 0 volts to the pin. My question is, how can I turn something on and off that requires more than 5 volts to turn on?

Thank you.


texts: Long range wireless communication between two arduinos?

texts:
I'm working on a project that will require two arduinos to be able to relay information to each other from long distances (up to about 10 miles or around 16 km).  WiFi won't be guaranteed to be available to either arduino as this is a wilderness application.

What are my options for long range wireless communication?  I haven't decided on an arduino model yet so if one particular model would be best for this application let me know.


texts: I have to reload Sketch every time I start my Yun

texts:
I am new to Arduino and IoT. I got my hands on a Yun and loaded a simple sketch to subscribe to a topic. I am receiving messages (I have set up a PHP script and broker on a server, which takes care of the messages) and can turn ON and OFF LED, L13. But when I disconnect the Yun from my PC and connect it again (to power it up), it stops receiving messages. I have to load the sketch again to make it work. Here is my code:

#include <spi.h>
#include <pubsubclient.h>
#include <yunclient.h>

byte server[] = { 192, 168, 1, 196 };
int port = 1883;
char* pubTopic = "fromYun";
char* subTopic = "sensor/light";

void callback(char* topic, byte* payload, unsigned int length) {
  //convert byte to char
  payload[length] = '\0';
  String strPayload = String((char*)payload);
  // handle message arrived
  if(strPayload == "ON") {
    digitalWrite(13, HIGH);
  } else if(strPayload == "OFF") {
    digitalWrite(13, LOW);
  }
}

YunClient yun;
PubSubClient mqtt(server, port, callback, yun);

void setup() {
  Serial.begin(9600);
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  Bridge.begin();
  if (mqtt.connect("arduinoClient")) {
    mqtt.publish(pubTopic,"hello world!");
    mqtt.subscribe(subTopic);
  }
}

void loop() {
  mqtt.loop();
}

Am I missing something?

I referred to this post and PubSubClient -> mqtt_basic.ino for making this ketch.

I don't understand what mqtt.connect("arduinoClient") is. I mean, what is this string "arduinoClient"? In one sketch on GitHub I saw it as "yun"...

Any help will be appreciated. Thanks in advance!

EDIT: I am using Mosquitto MQTT.


texts: Arduino IDE Board Selection for 32u4 on custom PCB

texts:
I am using a 32u4 on a custom PCB: 3.3v, 8MHz.

Are there any operational differences between using the Sparkfun ProMicro selection versus the Adafruit ItsyBitsy selection in IDE, since they are both for the 32u4?


texts: Error using nRF24L01+ with ATmega328P-PU. Works fine on Uno

texts:
I am trying to use a nRF24L01+PA with an ATmega328P minimal breadboard system. I first connected the module to my Uno and verified it with the "scanner" example sketch from the rf24 library, which showed:

STATUS       = 0x0e RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0-1     = 0xe7e7e7e7e7 0xc2c2c2c2c2
RX_ADDR_P2-5     = 0xc3 0xc4 0xc5 0xc6
TX_ADDR      = 0xe7e7e7e7e7
RX_PW_P0-6   = 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA        = 0x00
EN_RXADDR    = 0x03
RF_CH        = 0x4c
RF_SETUP     = 0x07
CONFIG       = 0x0e
DYNPD/FEATURE    = 0x00 0x00
Data Rate    = 1MBPS
Model        = nRF24L01+
CRC Length   = 16 bits
PA Power     = PA_MAX

It also shows the readings from each channel after; I just omitted that part.

Removing the chip and reconnecting it to my breadboard ATmega, which has been bootloaded and tested with the blink sketch, I get the following:

STATUS       = 0x00 RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=0 TX_FULL=0
RX_ADDR_P0-1     = 0x0000000000 0x0000000000
RX_ADDR_P2-5     = 0x00 0x00 0x42 0x42
TX_ADDR      = 0x1042082184
RX_PW_P0-6   = 0x00 0x00 0x00 0x00 0x00 0x00
EN_AA        = 0x00
EN_RXADDR    = 0x00
RF_CH        = 0x00
RF_SETUP     = 0x00
CONFIG       = 0x00
DYNPD/FEATURE    = 0x00 0x00
Data Rate    = 1MBPS
Model        = nRF24L01
CRC Length   = Disabled
PA Power     = PA_MIN

I double-checked all my wires against an ATmega328P pin map and everything checks out.

Furthermore, running the "gettingstarted" sketch on my Uno returns the correct result in the serial monitor where the chip starts in receiving mode and waits for instructions or to receive packets. And because I don't have the other chip set up yet, nothing shows up. However, when I run the exact same program on my breadboard ATmega, I get the following right after it finishes uploading.

RF24/examples/GettingStarted
*** PRESS 'T' to begin transmitting to the other node
Sent response 4194829060
Sent response 4194829060
Sent response 4194829060
Sent response 4294967295
Sent response 4294967295
Sent response 4294967295
Sent response 0
Sent response 4294967295
... yada yada yada

The fact that it is picking up any signals doesn't make sense as I am not transmitting from anything... yet.

The only MAJOR difference between my breadboard setup and the uno is the uno is running off USB 5V and the antenna is getting power from the 3.3V pin. On my breadboard, I have my usb2serial jumpered to 3.3V right off the bat and it is running the ATmega328P with a 16MHz crystal basically at 3.3V (waiting on my 3.3V regulators to arrive this Friday so I can run the chip at 5 and drop down to 3.3 just for the chip, as it is a potential solution I have in mind but in the meantime I am asking for other possibilities). Yes I know it is low but so far other sketches like the blink work, and I am running the chip in receive mode anyways.

I am lost and would appreciate some guidance.

Thank you.


texts: How do I get sensor values using transmitter and reciever

texts:
I used an HC-SR04 sensor and connected it to an arduino board (BOARD1) with a 433 mhz transmitter and the other board (BOARD2) is connected to the 433 mhz receiver but I don't know how to see the sensor value readings from the (BOARD1) and seen in the serial monitor.
HERE IS THE CODE OF THE TRANSMITTER
#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile

RH_ASK driver;
int echo=11;
int trig=9; int sensorval;
void setup()
{

    Serial.begin(9600);   // Debugging only

   driver.init();

}

void loop()
{
    digitalWrite(trig,LOW);
   delayMicroseconds(10);
   digitalWrite(trig,HIGH);
   delayMicroseconds(10);
   digitalWrite(trig,LOW);
   delayMicroseconds(10);
   sensorval=pulseIn(echo,HIGH);
     const char *msg = sensorval;

    driver.send((uint8_t *)msg, strlen(msg));
    driver.waitPacketSent();
    delay(200);
}

HERE IS THE CODE OF THE RECEIVER
#include <RH_ASK.h>

#include <SPI.h> // Not actually used but needed to compile

RH_ASK driver;
const int sensorval;
void setup()
{
    Serial.begin(9600);   // Debugging only
    driver.init();

}

void loop()
{
    uint8_t buf[4];
    uint8_t buflen = sizeof(buf);

    if (driver.recv(buf, &buflen)) // Non-blocking
    {
    Serial.print("message Received: ");
 Serial.println((char*)buf);
    }
}


texts: How to send Json to a webservice from pc/RPI with live data from Arduino(serial)

texts:
I'm making a project where my plan is to take sensor input from the Arduino, and then pass that info (by serial/usb connection) through either a laptop or a Raspberry Pi and convert it to Json and send it to a webservice in asp.net c#, where it gets stored in a database, and then the data can be shown on a website, so the visitor can see live data from the Arduino sensor on the site and also be able to see what the sensor measured yesterday, last month, or the average for a extended period of time, or a graph.

It might be easier to illustrate what I'm talking about:

The PC / RPI part is optional, it can be using either one.

There are a few options, as I see it, as to which methods could work. But I am unsure about how to implement them and what programs to use for it.

First one is to log data to a file on the PC/RPI and then have some shell script either listen for changes and then combine a Json string with the newly added info to the file and send it of to the webservice.

Second one is to somehow take the Serial data from the Arduino and have some shell script or program listen for any data coming from the Arduino and converting it to Json, and sending it of to the webservice. The pro's by this method would be omitting the extra "file-step", but it would make the system more vulnerable to any interruptions in the connection.

Does anyone have experience with doing something like this? Or maybe have an idea how I can do what I'm trying to do ? Or just a nudge in the right direction, as to which approach you think is best, or what programs I could/should use.
Any help is very much appreciated!

Best regards
Daniel


texts:
I am using SIM800L module. I am new to GSM modules. I have searched in many web sites about SIM800L, every where they mentioned baud rate 9600 for SoftwareSerial but it is not working at all in my case. So I started a trail and error method to match baud rate. Finally I found that its baud rate is 38400. With baud rate of 9600 for Arduino and 38400 I am able to communicate with SIM800L.

The problem is that I am unable to register to network. AT+COPS=? shows all available networks. Using AT+COPS="value" I am able to select network. But after that the SIM800L module still blinks every second.

In loop() I am continuously reading software serial and it's printing the following:

RDY
+CFUN: 1
+CPIN: READY
Call Ready
SMS Ready
RDY
+CFUN: 1
+CPIN: READY
Call Ready
SMS Ready

The above data is continuously printing on console.


texts: Ping IP address using ESP8266 connected to Arduino

texts:
I want to make a system using NeoPixels, an Arduino and an ESP8266 module to ping IP addresses on my network to determine if certain people are on our Wi-Fi (I'll be pinging mobile phones).

I'm finding it hard to find any help as to how to ping IP addresses from an Arduino using the ESP8266 module. I did find the ICMP Ping library, but it uses the Ethernet shield, and I'm quite new to Arduino so I don't even know if I could modify the library in any way.

If anyone could help me on my way, that'd be great!


texts: W5100 Ethernet shield DHCP fails with a Switch

texts:
we are using Arduino W5100 Ethernet shield. The code is to try DHCP first and if that fails, then try the static IP. we do the Ethernet Initialization and stop every time.  The library is Arduino Ethernet library.

when we try with a wireless router, everything works and we are able to contact our web server.
Now the wireless router is connected to a switch.
switch <======> router <=====> W5100

if we try to send data using the switch directly, DHCP fails, whereas a laptop using the same cable works.

Question is, even Arduino Library has DHCP functionality, why should a laptop work where the shield is failing? The network and topology and rules should be same for both the laptop and W5100 shield. Anything we can do to debug this issue more?

Edit1 : -  Switch which we are using is L3 in nature.

Below is the code which we are using at present.

    while(1) {

        KDEBUG("wait 10 seconds...\r\n");
        // wait 10 seconds
        for(loop = 10; loop > 0 ; loop--) {
            wait_millis(1000);
        }

        KDEBUG("Try transmitting data on ethernet...\r\n");
        transmit_data();

    }

    return 0 ;

}

void wait_millis(uint16_t num) {

    for(; num > 0 ; num-- ) {
        _delay_ms(1) ;
    }

}

// transmit data using Ethernet
static uint8_t transmit_data() {

    char request[256];
    uint8_t status = 0  ;

    // reset counter
    counter = (counter > 254) ? 0 : counter ;

    memset(&request[0], 0 , sizeof(request));
    memset(&bencode[0], 0 , sizeof(bencode));

    wait_millis(5000);
    // try DHCP
    if (Ethernet.begin(mac_address) == 0) {
        KDEBUG("Failed to configure Ethernet using DHCP \r\n");
        // use static IP. no return code.
        Ethernet.begin(mac_address, ip_address);

    } else {
        KDEBUG(" Got lease from DHCP \r\n");
    }

    // wait for ethernet to initialize:
    wait_millis(5000);

    // we got a connection?
    status = client.connect(server, port) ;
    KDEBUGF("ethernet client  status= %d \r\n", status);
    if(!status) {
        goto quit ;
    }

        KDEBUG("connected \n");
    // create an HTTP request
    strcat(request, "GET /api/gl868.php?data=");
    strcat(request,bencode);
    // 12 chars
    strcat(request," HTTP/1.1 \r\n");
    // 25 chars
    strcat(request,"Host: ");
    strcat(request,server);
    strcat(request," \r\n");

    // send GET request
    client.println(request);
    _delay_ms(1);
    client.println() ;

    wait_millis(1000);
    client.stop();
    wait_millis(1000);

    if(client.connected()) {
        client.stop();
    }

    return 1 ;

quit:

    wait_millis(100);
    if(client.connected()) {
        client.stop();
    }

    return 0 ;

}


texts:
I want to power down my Olimexino as much as possible and only wakeup on a pin-change interrupt. I removed the 3.3V/5V jumper (so the processor does not get power) and 3µA were displayed, so the voltage regulator is really a low power variant. What I have done:

#include <avr/power.h>

power_all_disable();
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
sleep_cpu();

This resulted in still using 220µA. Now I disable the ADC, too:

ADCSRA = 0;

which reduces it to 100µA. I've tried to disable further ADC-stuff using

ACSR = 0;
ADMUX = 0;

and tried to disable (?) the Watchdog Timer using

WDTCSR = 1 << WDP3;

but without any further improvements. The datasheet for the 32u4 suggests to disable the Brown-Out-Detector, too, but I don't seem to be able to do that using code, but only by setting some fuses which is not possible directly using the Arduino IDE. Any further ideas?


texts: AT firmware upgrade in ESP-01 using Arduino UNO R3

texts: I need to upgrade the AT firmware in ESP-01 by using Arduino UNO R3 serial interface. Do I need to remove the Microcontroller Chip from the DIP socket before burning firmware? Does it going to affect Arduino Bootloader?


texts: How to connect GPS Neo-6M module to GSM Shield SIM900 V2?

texts:
I'm doing my final year project, My project is based on "Arduino Real Time Gprs/Gsm & GPS Tracker". So Now I have purchased the hardware components such as:

Arduino UNO R3
GSM Shield SIM900 V2.0
Ublox GPS Neo - 6M Module

I'm a begginer to this project, I have a doubt connecting these components together. I have stack the GSM Shield with the Arduino Uno but I don't know how to connect the GPS module to the GSM Shield (How to wire the components). because as you see my pic you might see on the top of the GSM shield there are no female headers except one which comes for the display.

So do I need to implement a female header on the GSM Shield and solder it to conncet the GPS module?

Can't I connect the GPS module to the GSM Shield's UART Pins?
Please Help me Guys :)


texts: How to interrupt a Timer to Change position along a Colour Cycle

texts:
I want to have a loop of 4 colours which runs constantly (i.e. red -> green -> blue -> white) each of the colours having their own LED and pin on the Arduino board. There is a 7 second delay between switching the colour and this cycle should run continuously. When I press a button, I want the cycle to immediately switch back to green and continue the cycle (i.e. -> blue -> white -> red) again.

How should I go about this? Can you have a listener for a button press going at the same time as a delay? How do you interrupt the timer and change the active LED?


texts: Why do I get different results when compiling the same code with different ide?

texts:
I have a basic code about reading true rms.I compiled the same code with arduino ide and atmel studio, then ran it in a proteus simulation.I'm trying to measure how long the read_rms() function takes.
My mcu:attiny84
1.experiment)I have added board to arduino ide with board manager.And I chose attiny84 and internal 1Mhz from tools menu in arduino menu.
The result was that the read_rms() function took 23.25 milliseconds.
2.experiment)I compiled the same code without any changes in Atmel Studio.Device,attiny84 selected.
The result was that the read_rms() function took 44 milliseconds.
44 miliseconds vs 23.25 miliseconds. Why?
Note:The following settings are selected in the proteus.Internal RC Osc. 8 Mhz,and CKDIV8=Programmed.
My code:
#define F_CPU 1000000UL
#include <avr/io.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <stdint.h>
const uint8_t muxbits = 1<<MUX3 | 1<<MUX2 | 1<<MUX1 | 1<<MUX0;

void adc_init()
{
    ADMUX = 0;    //Vcc_ref_
    ADCSRA = (1<<ADEN)|(1<<ADPS1)|(1<<ADPS0); //adc_enable_and_prescaler_8_ 125000 Hz (1000000/8)
    //first_try
    ADCSRA |= (1<<ADSC);
    while ((ADCSRA & (1<<ADSC)) != 0);
}

uint16_t adc_read(uint8_t channel)
{
    ADMUX = (ADMUX & ~muxbits) | channel;
    // start_single_convertion
    ADCSRA |= (1<<ADSC);

    // wait for conversion to complete
    while ((ADCSRA & (1<<ADSC)) != 0);

    return (ADC);
}

double read_rms()
{
    uint16_t i=0;
    uint16_t a_data=0;
    uint32_t sum=0;
    float avarage=0;
    double rms=0;
    for(i=0;i<200;i++)
    {
        a_data=adc_read(1);

        sum=sum+(a_data*a_data);
    }
    avarage=(float)sum/200;
    rms=sqrt((double)avarage);

    return rms;

}

int main(void)
{

    DDRA|=(1<<7);
    PORTA &=~ (1<<7);
    adc_init();

    while(1)
    {

    read_rms();
    PORTA ^= (1<<7);// TOOGLE_PA7   for_measure_time_of_read_rms()_with_oscilloscope

    }
}


texts:
Does Fritzing support the standard 0.1" break-away header?

When I search for "header" in its parts database, I see several examples, and some even seem to reference 0.1 headers, but I can't actually seem to select the physical part.

For example, if I select the "Header 3" part, the description specifically refers to 0.1 break away headers, but the "package" field references a completely different part, causing it to render incorrectly. If I click that dropdown to try and select a different package, there are dozens listed, but none look like a 0.1 header.


texts:
I'm currently working on a project in which I'm supposed to make an Arduino car dodge any kinds of obstacles. I know how to do without using Interruptions but as I was searching online I found out that this is something that is used and would turn out better. Is it really possible? And if so, I don't exactly grasp the concept of using it to make (for example) the car stop once it senses an object. I know that it is supposed to be the first thing it will do if I program it that way but, can I program how the Interrupt will act upon the machine? And if so, how exactly?

Thanks


texts: Arduino Pro Mini RESET button suddenly stopped working

texts:
I am powering my Pro Mini(3.3V version) using an external battery (~6.5V 700mA) . I used to connect it to the RAW and GND pins on my pro mini and everything ran fine.

Today when I powered up my Arduino again, it didn't light up. A quick glance told me that I had connected the battery to the RST and GND pins mistakenly. Quickly pulled them out and put them into place, the Arduino worked perfectly until I discovered that the RESET button is no longer working. Without the RESET button I can't upload anything to my board.

Tried connecting the RST and GND Pins, didn't work.

The board is working fine though, I discovered a new procedure to upload as follows-
NOTE: I use the USB-to-TTL adapter by DSUN (picked up at a local electronics store).

Connect the RX, TX and GND Pins from the adapter to the Pro Mini.
(The green LED on the Pro Mini lights up dimly)
Upload the sketch from the IDE.
As soon as the IDE shows "Uploading", connect the +5V pin from the adapter to RAW pin on Pro Mini. Upload goes fine.

The above procedure is working just fine, and the board as well. But I'd like to have my RESET button back.
So what do I do?


texts:
I am building my Arduino project with a makefile:

BOARD_TAG = uno
ARDUINO_PORT = /dev/ttyACM0
USER_LIB_PATH = /home/prakhar/dev/alfred/arduino/libraries
CPPFLAGS=-x c++ -std=c++11 -Wall -DUNIX_ENVIRONMENT -DHAVE_NAMESPACES -DHAVE_STD
include /usr/share/arduino/Arduino.mk

I keep getting this error:

cc1plus: error: unrecognized command line option "-std=c++11"

I googled and this says that I need to update g++/gcc. I already have the newset versions:

prakhar@sim74stic ~ $ avr-g++ --version
avr-g++ (GCC) 4.9.1
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

prakhar@sim74stic ~ $ avr-gcc --version
avr-gcc (GCC) 4.9.1
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

prakhar@sim74stic ~ $ g++ --version
g++ (GCC) 4.9.1 20140903 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I installed arduino from the AUR (packages aur/arduino 1:1.0.6-1 and aur/arduino-mk 1.3.4-2).
Can anybody point out what I'm doing wrong?


texts:
I am using a L298N motor driver to connect a motor with NodeMCU. But i did a few tests since a few tests while learning how to control it now when i connect it the motor doesn't even work. Then i removed the nodemcu and just used the motor driver to control the motor, then also it did not work. I don't know why.
I am new to controlling motors and this is my first time.
Also I am using 9v battery to power the motor driver.
l298n- https://www.amazon.in/gp/product/B08SK2ZPYD/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1
nodemcu - https://www.amazon.in/Lolin-NodeMCU-ESP8266-CP2102-Wireless/dp/B010O1G1ES/ref=sr_1_2?dchild=1&keywords=nodemcu&qid=1617973657&s=industrial&sr=1-2


texts: Where are the digital and analog pins for the adafruit atmega 32u4 breakout board?

texts: Which pins are the analog and digital pins? I've been searching the internet for an hour and I could get an answer.


texts: Can I avoid having a bootloader if I use ISP to flash to an arduino?

texts:
My Trinket Pro waits about 10 seconds upon booting before starting the program that I have loaded on it.

Can I avoid this delay and the bootloader taking up space if I flash my program directly to the Arduino with ArduinoISP?


texts: Malloc with Objects in Arduino libraries

texts:
My understanding of using dynamic memory on the arduino is that new/delete are not available, only malloc realloc and such C functions, as mentioned here:

C++ & the AVR

I am creating a library that defines an object type that needs to contain a dynamic list of other objects. In C++ I would define it something like this:

class Container
{
std::vector<otherObjectType> otherObjects;
};

which obviously does not work in the arduino without the C++ standard library.

My next choice would be to create a dynamic array using new, ie

otherObjects = new otherObjectType[3]
{
    {   (arguments to constructor...)
    },
    {   (arguments to constructor...)
    },
    {   (arguments to constructor...)
    }
};

But this does not work as well, since new is not supported...

finally I could try to use malloc as laid out here, but that also wont work without new.

I am wondering if I should just rewrite everything as structs, since that wont require me to worry about whether the constructor for the object was called when the memory was allocated in malloc.


texts: Difficulties programming Arduino uno for 24 hour cycle

texts:
I am trying to program my Arduino Uno board for a 24 hour cycle.
I have the Arduino board and two relays.
The aim is; every 24 hours relay 1 has to switch on for 5 seconds, and 1 second later relay 2 has to switch on for 15 seconds.
I have a sketch for a 12 hour cycle, and that works fine, but when I try for a 24 hour cycle, by changing the const unsigned int totalTime from 43200 seconds to 86400 seconds, everything goes wrong.

24 hour sketch - what is wrong?

//turn relays on and off at certain times.
//when the digital output pin is HIGH, then the relay is off.
//when the digital output pin is LOW, then the relay is on.

enum actioEnum {
  RELAY1_ON,
  RELAY1_OFF,
  RELAY2_ON,
  RELAY2_OFF,
};

struct tableStruct{
  unsigned int time;
  actionEnum action;
}
const table [] = {
  {0,RELAY1_ON},
  {5,RELAY1_OFF},
  // remaining 86395 for a total of 86400.
  {0,RELAY2_OFF}, // not needed, it is already off.
  {6,RELAY2_ON},
  {6+15,RELAY2_OFF},
  // remaining 86379 for a total of 86400.
};

const unsigned int totalTime = 86400; // total amount for sequence
unsigned int seconds;

unsigned long previousMillis;
const unsigned long interval = 1000; // 1000 ms; // 1000 ms is one second

const int relay1Pin = 2;
const int relay2Pin = 3;

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

  // the relay is off when the pin is high.
  // turn output high before setting the pinMode.
  // then the output changes from a floating pin to high,
  // and the relays will not be activated.
  digitalWrite (relay1Pin, HIGH);
  pinMode (relay1Pin, OUTPUT);
  digitalWrite (relay2Pin, HIGH);
  pinMode (relay2Pin, OUTPUT);
}

void loop () {
  // a one second timer with millis
  if (millis() - previousMillis >= interval) {
    previousMillis += interval;
    // scan table
    for ( int i = 0; i < int (sizeof(table) / sizeof (tableStruct)); i++) {
      if (table [i] . time == seconds) {
        switch (table [i] . action) {
          case RELAY1_ON:
            Serial.println("Relay 1 on");
            digitalWrite (relay1Pin, LOW); // low is relay on.
            break;
          case RELAY1_OFF:
            Serial.println("Relay 1 off");
            digitalWrite (relay1Pin, HIGH); // high is relay off.
            break;
          case RELAY2_ON:
            Serial.println("Relay 2 on");
            digitalWrite (relay2Pin, LOW); // low is relay on.
            break;
          case RELAY2_OFF:
            Serial.println ("Relay 2 off");
            digitalWrite (relay2Pin, HIGH); // high is relay off.
            break;
          default:
            Serial.println ("Error, a bug in the scketch");
        }
      }
    }
    seconds++;
    if (seconds >= totalTime) {
      seconds = 0;
    }
  }
}


texts: Using ethernet, how do I navigate to a page on my local server

texts:
I want to access the following page on my local using my Arduino with ethernet shield"  192.168.1.2/zombie/arduino.php.  My arduino is conencted to a PC through a router. The system keeps timing out

I am using the following code:

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,1,3 };
char server[] = "192.168.1.2/zombie/arduino.php";

EthernetClient client;

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);

  delay(1000);

  Serial.println("connecting...");

  int res = client.connect(server, 80);

  Serial.println(res);

  if (res) {
    Serial.println("connected");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.println("data:");
    Serial.println(c);
  }else{
    Serial.println("NA");
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;)
      ;
  }
}


texts: How to produce rolling count per minute?

texts:
I have a counter attached to ISR:
void ISR_impulse() {
  CNT++;
}

and I want to calculate rolling count per minute with arbitrary update rate.
However I can only get it to update every minute:
void loop() {
  if (t - t0 > 60000) {
    CPM = CNT - CNT0;
    t0 = t;
    CNT0 = CNT;
  }

  t = millis();
  delay(100);
}

I'd appreciated if anyone can help me to create a rolling count with a window of 1 minutes that works with arbitrary update rate like 1 second ?
Thanks in advance !