texts: Same output on displays with different I2C-addresses (AdaFruit library, ESP32)

texts:
I've got two displays hooked up to a ESP32 via I2C and I'm using the AdaFruit library. All handling display output is packed in a own library. As I was testing I only had one display set up and everything looked fine. Now, in my actual setup with two displays, I only get the output of the first display on both screens. The displays are running on the same I2C-bus, different addresses are set. I also ran a address/portscanner that confirmed the different addresses (0x3C and 0x3D).

I have used separate displays with the AdaFruit library in such a setup before, but only on an Arduino uno and without having code moved to own libraries. So I can't tell if the ESP32 or having multiple files is messing things up or I'm missing something.

Here are parts of code in the cpp-file I used to initialize the displays and some functions I call:

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Wire.h>
#include <gfxfont.h>
#include <SPI.h>
#include "DisplayOut.h"
#include "Game.h"

    /* -------------esp32 Pin setup --------------------- */
    const byte displayData = 21;    // I2C SDA
    const byte displayClock = 23;   // I2C SCL
    /* --------------------------------------------------- */

// Define OLED
#define OLED_RESET displayData
Adafruit_SSD1306 display1(OLED_RESET);
Adafruit_SSD1306 display2(OLED_RESET);

/* some variables */

void DisplayOutClass::init()
{
    // Initialize each display with i2c-address

    display1.begin(SSD1306_SWITCHCAPVCC, 0x3C);
    display2.begin(SSD1306_SWITCHCAPVCC, 0x3D);
    display1.setTextWrap(false);
    display2.setTextWrap(false);
}

void DisplayOutClass::scorePlayer1(int score1)
{
    display1.clearDisplay();

    if (gameMode == 2)
    {
        display1.clearDisplay();
        display1.setCursor(0, 0);
        display1.setTextSize(2);
        display1.setTextColor(WHITE);
        display1.print(playerName[player1]);
    }

    display1.setTextSize(4);
    display1.setTextColor(WHITE);
    display1.setCursor(getCenteredPosX(3, String(score1)), 24);
    display1.print(score1);
}

void DisplayOutClass::scorePlayer2(int score2)
{
    display2.clearDisplay();

    if (gameMode == 2)
    {
        display2.clearDisplay();
        display2.setCursor(0, 0);
        display2.setTextSize(2);
        display2.setTextColor(WHITE);
        display2.print(playerName[player2]);
    }

    display2.setTextSize(4);
    display2.setTextColor(WHITE);
    display2.setCursor(getCenteredPosX(3, String(score2)), 24);
    display2.print(score2);
}

/* some more Functions */

DisplayOutClass DisplayOut;

I didn't post the complete code or the header file, because it exceeds a few hundred lines. But this should show how the I2C-addresses are used. If necessary, I of course can post the rest of the code.

My next approach would be either trying the U8g2 library or trying start a second I2C bus. Since I already have a finished circuit board, so this would be my least preferred option.


texts: How to make Arduino communicate with MySQL?

texts:
I am trying to send data from my Arduino to my database but it seems that the process is not successfully beginning. Here is my code for Arduino:

#include <Process.h>
#include <Bridge.h>
int temperature;
void setup() {
  Bridge.begin();  // Initialize Bridge
}
void loop() {
  int temperature = random(0, 100);
  Process p;
  p.begin("143.248.181.36/db.php");// 143.248.181.36 address of localhost.
  p.addParameter(String(temperature));
  p.run();
  delay(5000);
}

I am using xampp and I put db.php inside the htcocs folder. Can anyone point out why it does not work?


texts: Why I'm getting this error: invalid conversion from 'const char*' to 'char' [-fpermissive]?

texts:
Why I'm getting this error?

invalid conversion from 'const char*' to 'char' [-fpermissive]

Here is my simple sketch:

const char data = "should";

//I have also tried:
//const char* data = "should";

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

void loop() {
  Serial.print("this " + data + " work");
}


texts: I am making smart highway project and its like there is two checkpoint and car must be register data on device and add timer on it and at checkpoint2 it should delete data My questions is which sensors must i use which can collect cars data even its in speed Please help me to complete my project


texts: (Arduino + official GSM shield + ultrasonic HC-SR04 sensor) inaccurate measuring

texts:
I'm using an Arduino Uno, 1.0.5 r2 version of the IDE with and ultrasonic HC-SR04 sensor for measuring a tank water level. I want to send the data obtained over internet using the official arduino GSM shield sending them on the plot.ly servers with their API using a GPRS connection. When I'm doing all the tasks I get inaccurate values as these:

When I use the only ping sensor without the GSM shield all works well getting good data. The same using a potentiometer + GSM shield + plot.ly.

The function I use for getting the distance is:

long distCalc() {
  long durata, distanza;
  digitalWrite(TRIG_PIN, LOW);  // TRIG_PIN = pin 12
  delayMicroseconds(2);
  digitalWrite(TRIG_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG_PIN, LOW);
  durata = pulseIn(ECHO_PIN, HIGH);  //ECHO_PIN = pin 11
  distanza = durata / 29.1 / 2 ;
  return distanza;    // in uscita la distanza in [cm]
}

and the one for posting the data on plot.ly servers is (loop function):

void loop() {
  long distanza;
  distanza = distCalc();  //fase di calcolo distanza
  Serial.print(distanza);
  Serial.println("cm");
  graph.plot(millis(), int(distanza), tokens[0]);  //fase di invio su plot.ly
  delay(20);
}

Could it be a software serial interrupt that hangs the pulseIn measurement?
How could I avoid this?


texts: How does one set attributes for SD files?

texts: How does one set file attributes, e.g., creation date, for a file being created on an SD?


texts: Problem with analog pins' name when trying to connect Arduino board and Processing

texts:
I am trying to use Processing with Arduino Uno board to read the change of voltage done by a potentiometer. The code is simple:

import processing.serial.*;
import cc.arduino.*;

Serial myport;
Arduino arduino;

color off = color(4, 79, 111);
color on = color(84, 145, 158);
int val=0;
float value=0;
void setup() {
  size(600, 600);
  println(Arduino.list());
  arduino = new Arduino(this, Arduino.list()[0], 57600);
  arduino.pinMode(0, Arduino.INPUT);
}

void draw() {
  stroke(on);
  value = arduino.analogRead(0);
  println(value);
  ellipse(300,300,value,value);
  delay(100);
}

My question is: For analog pins in Arduino IDE one should type A0, A1, ... but here in Processing IDE it is an error to type so. Is it possible that Processing reads the wrong pin? Because in Serial output I always get zero, however, for the same circuit in Arduino IDE the values change as I turn the potentiometer knob.
Thanks


texts: Adafruit_LSM303 tilt compensated compass

texts:
I am having troubles with tilt compensating my compass.

I am using the LSM303DLHC accelerometer/compass in combination together with the Adafruit_LSM303_U.h.

I was able to get my compass to the right direction withthis little snippet:

  float heading = (atan2(event.magnetic.y,event.magnetic.x) * 180) / Pi;

I also was able to get my roll and tilt angle with converting my X and Y of my accelerometer to angles:

   headingNew = asin(eventA.acceleration.x/10);
   float tilt = headingNew*180/PI/90*100;
   headingNew = asin(eventA.acceleration.y/10);
   float roll = headingNew*180/PI/90*100;

Now I need to compensate my angle to get a new x and y for inside my heading calculation but the problem is that I can't seem to get the right functions.
Online I found the functions below from a large tutorial about the sensor but this gives me completely wrong values.

    //Xh = event.magnetic.x*cos(tilt)+event.magnetic.z*sin(tilt);
    //Yh = event.magnetic.x*sin(roll)*sin(tilt)+event.magnetic.y*cos(roll)-event.magnetic.z*sin(roll)*cos(tilt);

or in the code itself:

   Xh = event.magnetic.x*(eventA.acceleration.z/10)+event.magnetic.z*(eventA.acceleration.x/10);
   Yh = event.magnetic.x*(eventA.acceleration.y/10)*(eventA.acceleration.x/10)+event.magnetic.y*(eventA.acceleration.z/10)-event.magnetic.z*(eventA.acceleration.y/10)*(eventA.acceleration.z/10);

I actually get the right angle on a flat surface. But it is even more inaccurate at an angle as the normal heading.
Does anybody have any experience with this sensor? Already a big thanks for the help.


texts: Atmega8 with Arduino bootloader - wrong serial characters

texts:
I recently flashed bootloader of Arduino to Atmega8. Unfortunately I stumbled on a problem I can't solved.

I am testing SerialEvent example on Atmega8. I modified it but started debugging it on my code (I think the same problem stops SerialEvent example from working).

I think the Atmega8 reads the characters sent through serial wrongly. That's why SerialEvent 'if' condition doesn't work also. Because it never gets '\n' symbol (it receives it but wrongly interprets it).

boolean prevState = true;
boolean OnOff = false;
boolean stringComplete = false;
String inputString = "";
String OnString = "on\n";
String OffString = "off\n";

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

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

    // reserve 200 bytes for the inputString
    inputString.reserve(200);

    DDRD |= 0b00001100;
    PORTD |= _BV(PD2);

    // synchronization info for RPi
    Serial.println("ARD - OK\n");
}

void loop() {
    // turn on
    if (OnOff == true && prevState == false){
        PORTD |= _BV(PD2);
        prevState = OnOff;
    }
    // turn off
    if (OnOff == false && prevState == true){
        PORTD &= ~_BV(PD2);
        prevState = OnOff;
    }

    if (stringComplete) {
        Serial.println(inputString);
        // clear the string:
        inputString = "";
        stringComplete = false;
    }
}

void serialEvent() {
    while (Serial.available()) {
         // get the new byte:
        char inChar = (char)Serial.read();
        // add it to the inputString:
        inputString += inChar;
        // if the incoming character is a newline, set a flag
        // so the main loop can do something about it:
        Serial.println(inputString);
        if (inChar == '\n') {
            stringComplete = true;
            Serial.println("test\n");
        }

        if (stringComplete && inputString.equals(OnString)){
            OnOff = true;
            Serial.println("Turning on.\n");
        }
        else if (stringComplete && inputString.equals(OffString)){
            OnOff = false;
            Serial.println("Turning off.\n");
        }
    }
}

I tested a lot of behaviors. Below I attach one of the tests from Realterm:

First I reset the board - it responded with 'ARD - OK\n' - expected behavior.
Then I sent 'on\n' and it responded with two lines but the characters aren't the same as 'on\n'.
Then I sent 'test123\n' but once again got wrong characters.
It prints multiple lines because it sends the string in which it accumulates the data every time SerialEvent() is fired.

Also sending for example variabl OnString works ok.

I really don't know why is it acting like that... Help would be appreciated :).


texts: How can I connect my Arduino so that it shows up on the COMM port in the IDE?

texts:
I'm new to Arduino and I currently have an Uno R3 that when connected to my computer shows up in my device manager (as ATmega16U2) but doesn't show up as connected to the COMM port in the IDE.

To test the Arduino I plug in the Arduino to my computer through USB, boot up the IDE and try to upload the sketch that comes up when you start the IDE.

What I have tried

Using a different cable
Using a different computer (The main computer I have tested this out on is my desktop, the COMM issue occurred on my laptop as well)
Reinstalling the drives (My desktop says the best drivers are already there, I don't recall trying this on my laptop)
Plugging it into the exactly port it calls (COMM3 is what it looks at and with my desktop I have plugged it into Port_3 on Hub_3, I'm not sure whether or not the Hub matters)
I have experimented with using the reset button. I would hold it down as the IDE tried to upload. I did this only a few times.


texts:
my project involves:
1 ultrasonic sensor.
1 servo motor.
3 leds.
when a person comes in range of ultrasonic sensor (7 to 20),servo turns by 150 degree.
then ultrasonic sensor check again if the person is in range, if yes then led1 turns on for 10sec n turns off, still if the person in in range then led2 turns on for 10sec and turns off, still if the person is in range then led3 turns on for 10sec and this keep on repeating for the leds(led1, led2, led3 but servo is still in 150)
once detected and the person is not detected the leds should not glow and servo should return to 0

code:

if ((distance1>7)&&(distance1 <= 20))
 {
  myservo1.write(150);
  delay(1000);
 }
 {
  if ((distance2>7)&&(distance2 <= 20))
   {
   digitalWrite(led1,HIGH);
   delay(1000);
   digitalWrite(led1,LOW);
   }
  if ((distance1>7)&&(distance1 <= 20))
   {
   digitalWrite(led2,HIGH);
   delay(1000);
   digitalWrite(led2,LOW);
   }
   if ((distance1>7)&&(distance1 <= 20))
   {
   digitalWrite(led3,HIGH);
   delay(1000);
   digitalWrite(led3,LOW);
   }
else
{
 myservo1.write(0);
  }

but this code does not work the way i want.
it blink the leds even when there is no person in range.
need help in programing so that the leds blink only when ultrasonic detects the person in range and stops when person is not detected.
thank u in advance


texts: What Driver IC to use for 40v 2amp DC motor?

texts: I am using a 40v 2amp 3300rpm DC motor for my motor control project via arduino. But i don't know what driver ic to use for driving the motor.any help would be appreciated..


texts:
Using a socket server on a Teensy 4.1, I am sending and receiving data in a loop from a Windows socket client (WinForms C#.NET).
I am sending or receiving 530 bytes of data. In each direction, it takes approximately 1.6 seconds to read or write and I think I've narrowed this delay down to the Teensy end when either client.read() or client.write(buffer, 530) are called by using Wireshark and a stopwatch in my C#.NET code on the Windows side.
The read code on the Teensy looks like this:
byte buffer[530];
int idx = 0;

while (client.available() > 0)
{
   buffer[idx] = client.read();
   idx++;
}

The write code is simply a byte array of 530 elements written like so: client.write(buffer, 530);
Is this typical? If not, is there some way to reduce this bottleneck?
Update
I found the issue - it was to do with some scanning function on the I2C bus taking up processing time. Isolating the socket server code allows it to execute very fast.


texts: How can I know if I can stack some shield on another shield?

texts:
Yesterday I tried to stack a motor shield on a servo motor shield already stacked on my Arduino Uno.

But I realized that I have some problem when I try to use both of them. It seems like some energy is lost or the stepper motor connected to my servo motor shield move weirdly slowly.

I already checked online, and I found some explanations about stacking many shields. About making sure the shields don't use the same pins or SS. As a beginner, help would be very helpful. Thank you.

Here are the two shields I use.

Smart Servo Shield for dynamixel
https://store.arduino.cc/arduino-motor-shield-rev3
Smart Arduino Digital Servo Shield for Dynamixel AX
https://www.dfrobot.com/product-958.html

wiki : https://www.dfrobot.com/wiki/index.php/Digital_Servo_Shield_for_Arduino_SKU:DRI0027

On these links, you can find all the specs with the pins used. I think I have some pinß shared by both of them... But not sure.

Does anyone have a solution please? Many thanks in advance.


texts: Arduino writes only one time on SD card - Data log

texts:
I connected the SD card to Arduino as it's explained here. The problem is that the Arduino writes only once to the SD card and I don't understand the reason.

#include <SD.h>
#include <SPI.h>

int CS_PIN = 4;

File file;

void setup() {
  Serial.begin(9600);
  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);
  Serial.print("Initializing SD card...");
  if (!SD.begin(CS_PIN)) {
    Serial.println("Card failed, or not present");
    return;
  }
  Serial.println("card initialized.");
}

void loop() {
  String dataString = "TEST";
  File dataFile = SD.open("datalog.txt");
  if (dataFile) {
    dataFile.println(dataString);
    dataFile.close();
    Serial.println(dataString);
  } else {
    Serial.println("error opening datalog.txt");
  }
  delay(1000);
}

The output on Serial Monitor:

  Arduino write only one time on SD card error opening datalog.txt error
  opening datalog.txt error opening datalog.txt error opening
  datalog.txt error opening datalog.txt error opening datalog.txt error
  opening datalog.txt error opening datalog.txt error opening
  datalog.txt error opening datalog.txt error opening datalog.txt error
  opening datalog.txt error opening datalog.txt

I also tried to use:

SD.open("file.txt", O_RDWR | O_APPEND);
SD.open("file.txt", O_RDWR | O_CREAT);

As I saw Adding data to an SD card file, but it doesn't work.


texts: 2,5m cable too long for LCD connected to Arduino UNO?

texts: So i got that 2,5m cable wired with the LCD and the arduino, but i keep getting those weird characters showing up on the LCD. Clearly there is a signal loss between the components but there has to be a solution to the problem. Perhaps by connecting capacitors/resistors to the wires will help? Is there any solution other than not using this long cable?


texts: servo.read() starts at negative value, no matter where servo actually is

texts:
I don't like how my servo quickly jumps to the default middle position, so I commented out the line where DEFAULT_PULSE_WIDTH is set in Servo.cpp:

//servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH);

Unfortunately while this stopped the servo from moving on execution of attach, the position of the servo is now showing up as -52!

Just running the following in setup() is enough to generate the bug:

int servo_pin = 53;
servo.attach(servo_pin);
Serial.print("Initial position: ");
Serial.println(servo.read());  //returns -52

This last line returns -52 no matter what position the servo is actually in, which has bad consequences (its initial movement is way off).

Note I get the same behavior when I set the DEFAULT_PULSE_WIDTH to 0 in Servo.h.

I am using a Mega -- an Elegoo clone -- on Windows 10.

Note I got the ideas for stopping the servo from moving on initialization from these threads:

https://stackoverflow.com/questions/40892922/how-to-stop-an-arduino-servo-from-moving-during-the-myservo-attach-command?noredirect=1&lq=1
https://stackoverflow.com/questions/26695670/attach-arduino-servo-without-moving


texts: EEPROM put and get not working on ESP8266 (NodeMCU)

texts:
The Arduino documentation provides two examples to store data in the EEPROM.

https://www.arduino.cc/en/Reference/EEPROMPut stores data in the EEPROM and the EEPROMGet example reads the data back and writes it out.

These examples work fine on my Arduino Uno, but on my ESP8266 (NodeMCU) the EEPROMGet example code is unable to retrieve the data EEPROMPut should have stored previously. Instead it's just returning some random bits and bytes.

Any ideas? I haven't found anything about known incompatibilities related to the ESP8266 boards...


texts: Wake up ESP8266 from deepSleep with a button

texts: I have a button with two isolated tracks. I want to be able to wake up esp from deepSleep with this button, and also detect that it was clicked. So i can't connect it to reset, because esp won't work if i don't release a button. And if it's not at deepSleep, it will reset, and i don't want it. How to do this?


texts:
We had used a voltage sensor unit to measure the voltage of the odroid board using an Arduino Uno. wWhen I uploaded the sketch and got the output, the value which was being displayed was around 4.7 to 4.9V, but when I measured the top of the voltage sensor module using a multimeter, it had a stable voltage of 5.08V. Is their any particular reason why this is happening?

Voltage sensor module

int analogInput = A0;
float vout = 0.0;
float vin = 0.0;
float R1 = 30000.0;
float R2 = 7500.0;
int value = 0;
void setup() {
pinMode(analogInput, INPUT);
  Serial.begin(9600);
  Serial.print("DC VOLTMETER");
}
void loop() {
  // read the value at analog input
value = analogRead(analogInput);
vout = (value * 5.0) / 1024.0;
vin = vout / (R2 / (R1 + R2));
Serial.print("INPUT V= ");
Serial.println(vin, 2);
delay(500);
}


texts: declaration of 'varDay' as array of references error

texts:
I am trying to write a function to store the date and time data from an RTC module. I have used char arrays to implement the function. I get "declaration of 'varDay' as array of references" error upon compilation.
I am still learning about char arrays and manipulating them so may be I am making a very obvious mistake. Could you please explain what I am doing wrong?
#include <RTClib.h>

RTC_DS3231 rtc;

void setup() {
  Serial.begin(115200);
#ifndef ESP8266
  while (!Serial); // wait for serial port to connect. Needed for native USB
#endif

  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    Serial.flush();
    abort();
  }

  if (rtc.lostPower()) {
    Serial.println("RTC lost power, let's set the time!");
    // When time needs to be set on a new device, or after a power loss, the
    // following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }

}

void loop() {
  unsigned long newTime = millis();
  static unsigned long oldTime = 0;

  char varYear [] = "1234";
  char varMonth [] = "00";
  char varDay [] = "00";
  char varHour [] = "00";
  char varMinute [] = "00";
  char varSecond [] = "00";
  unsigned int varEpoch;
  char varDate [] = "123456789";
  char varTime [] = "12345678";
  char dash [] = "-";
  char colon [] = ":";

  if (newTime - oldTime >= 60000) {
    oldTime = newTime;

    getDate(varDay, varMonth, varYear, varDate, dash, colon);
  }

}
void getDate (char &varDay[3], char &varMonth[3], char &varYear[5], char &varDate[11], char &dash[2], char &colon[2]) {

  DateTime now = rtc.now();
  strcpy (varDay, now.day());
  strcpy (varMonth, now.month());
  strcpy (varYear, now.year());

  strcat (varDate, varDay) ;
  strcat (varDate, dash);
  strcat (varDate, varMonth);
  strcat (varDate, dash);
  strcat (varDate, varYear)

  Serial.println(varDate);
}


texts: Read temperature (DS18B20) with the ATTiny85

texts:
I'm trying to read the temperature of a DS18B20 with my ATTiny85 - but I'm getting rubbish data :D

I should have gotten ~22 degrees, but I'm getting 129! I followed this tutorial i found here, but maybe there is something funky with the ATTiny85?


texts: I am tying to split a float variable into bytes and then re combine to the original float

texts:
Here is the code I am currently using, there have been many and various alternatives I have tried all so far without success, this being the latest incarnation sitting within my main program loop (void loop)...
// get temperature from Dallas Temperature Sensor
  sensors.requestTemperatures();
  sen0_data = sensors.getTempC(sensor_0_address);             // read temperature sensor0

// split float
  float f1 = sen0_data;
  byte* fb = (byte*) &f1;

  Serial.println(f1);
  Serial.println(fb[0]);    // Take a look at the bytes
  Serial.println(fb[1]);
  Serial.println(fb[2]);
  Serial.println(fb[3]);

// rebuild float
  temp = (fb[0] << 24) + (fb[1] << 16) + (fb[2] << 8) + (fb[3]);
  Serial.println(temp);

Now for the result as seen in the serial monitor - original float, split byte 0, byte 1, byte 2, byte 3, and finally rebuilt float. What am I doing wrong? as no doubt can be seen from the dirty coding I am a relative newbe
The starting float value -127.00 is because I currently have no temperature sensor connected to the Arduino, but I would still expect the rebuilt float to be the same and not -318.00. Even if I connect a sensor the rebuilt float does not mirror the original...
-127.00
0
0
254
194
-318.00

I look forward to any advice...
Regards,
Simon.


texts: Using 5V microphone module with Wemos D1 Mini Pro 3.3V analog pin

texts: I want to read values from this microphone module using Wemos D1 Mini Pro analog pin. Unfortunately, this module operates on 5V, but the analog pin on Wemos has range 0-3.3V. I have tried to use a voltage divider on microphone module output, but I am getting very low values which don't reflect sound power (to get values greater than zero I have to knock on the microphone). In the voltage divider R1 = 500 Ohm and R2 = 1000 Ohm. Is there some way to make this work correctly?


texts: How do I properly convert a pointer (uint8_t* or void*) to a "normal" integer?

texts:
I'm writing a program for arduino that needs dynamic memory allocation frequently, but as I don't want the memory to get fragmented, I'm also writing a "memory handler" for it. This memory handler would need to do calculations involving both pointers and size_t variables, like this (example code is not part of program, but the structure of the calculations is the same):

size_t freeMemSize = nextPointer - currentPointer - currentSize;

Which would calculate the size of free memory between two reserved spaces.

Of course, arduino doesn't want to swallow this code, as it compares incompatible types. My questions are:

Is a cast to the correct integer type enough to solve the problem?
If it is, what is the "normal integer" counterpart of a pointer?

I guess this varies from processor to processor, so I should look for something like size_t, but for memory indices instead of sizes.

Board: Uno, Nano
IDE version: 1.8.2


texts:
I'm trying to compare a char array that I'm assembling to a string and I'm having trouble comparing the strings.
I'm getting the data for the char array as a set of bytes and I'm compiling it into a char array like this:
void messageHandler(char *topic, byte *payload, unsigned int length)
{
  char buffer[length];
  for (int i = 0; i < length; i++)
  {
    buffer[i] = (char)payload[i];
  }

So grabbing each of the ASCII codes and converting it into a character as I add it to the buffer.
After I do that I'm trying to print the buffer to the monitor and then compare it to a string. Though it's not working:

I know I'm getting all of those extra characters in the println b/c the buffer doesn't end in 0 so print keeps reading out memory bytes till it hits the zero, but I don't know why strcmp isn't showing the buffer matching the string "ravenclaw".
I'm sure it's for the same "missing the null terminator" issue, but I'm not sure how to fix it. Help is appreciated!!


texts: Which type of Motor Drivers to drive Unipolar Stepper Motors?

texts:
I hope this question is specific enough. Basically I want to know if it matters a great deal what kind of Motor Driver IC(s) or pre-assembled kits you use to drive a Unipolar Stepper Motor.

For example: Can the following Driver be used to control this Stepper Motor?

Driver: https://www.sparkfun.com/products/9670

Motor: http://www.jaycar.com.au/productView.asp?ID=YM2754

Thanks!


texts: Sending data from txt file over serial connection

texts:
I'm trying to send data saved on a txt file to arduino over serial connection. I wrote this simple sketch

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

void loop(){
  while (Serial.available() > 0) {
    Serial.write(Serial.read());
  }
}

When I try to send serial data from bash by typing cat input.txt >> /dev/cu.wchusbserial1a1340 while the Arduino's serial connection window is open. It gives an error message "resource busy: /dev/cu.wchusbserial1a1340". Then I tried cat input.txt >> /dev/tty.wchusbserial1a1340. Now it hangs. Bash is busy, and it is not possible close Arduino IDE or serial connection window. What is wrong here?


texts:
I'm using an ESP 12E with a usb connector.
I'm curtain the usb cable is working fine since I'm able to use it on other boards.
When unplugging and plugging in the use, the port picks up the board as expected.
I don't see any lights on the board at all when plugged in.
While trying to upload code, I'm getting the following error and the board is not flickering any lights indicating it's uploading:
Executable segment sizes:
IROM   : 228252          - code in flash         (default or ICACHE_FLASH_ATTR)
IRAM   : 26380   / 32768 - code in IRAM          (ICACHE_RAM_ATTR, ISRs...)
DATA   : 1248  )         - initialized variables (global, static) in RAM/HEAP
RODATA : 688   ) / 81920 - constants             (global, static) in RAM/HEAP
BSS    : 24840 )         - zeroed variables      (global, static) in RAM/HEAP
Sketch uses 256568 bytes (24%) of program storage space. Maximum is 1044464 bytes.
Global variables use 26776 bytes (32%) of dynamic memory, leaving 55144 bytes for local variables. Maximum is 81920 bytes.
esptool.py v2.8
Serial port /dev/cu.usbserial-0001
Connecting........_____....._____....._____....._____....._____....._____.....____Traceback (most recent call last):
  File "/Users/altus/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/upload.py", line 65, in <module>
    esptool.main(cmdline)
  File "/Users/altus/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/esptool/esptool.py", line 2890, in main
    esp.connect(args.before)
  File "/Users/altus/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.1/tools/esptool/esptool.py", line 483, in connect
    raise FatalError('Failed to connect to %s: %s' % (self.CHIP_NAME, last_error))
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
_
the selected serial port _
 does not exist or your board is not connected

When I try to flash the board, the port picks up in the flasher, but nothing happens when clicking on flash. Could the board be faulty? How would I debug this?


texts: Im trying to power an Arduino Uno from a pack of 8 AA batteries (so 12V) and it just doesn't turn on. When I connect the barrel jack, it works! Any idea why the VIN doesn't work? Thank you in advance.


texts:
My goal is not upload sketch to Arduino Pro mini through bluetooth module HC06. I have made a breadboard version of DTR signal simulator which takes LED status pin as a source. The output from the detector goes to RST pin of Arduino. When connection is initiated the status LED stops blinking and output pin goes low and than high which leads to Arduino rebooting. This part works fine. Unfortunately avrdude from Arduino IDE does not see the bootloader and shows the following error in the console:

avrdude: stk500_recv(): programmer is not responding

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

I have noticed that HC06 stops blinking with some delay after a connection is initiated. I suspect that this might be a problem. To overcome this issue the boot loader should probably be changed. Unfortunately I am not familiar with the embedded C programming, thus if someone has experience in changing the bootloadder, please help me to solve this puzzle.

The following is a scheme of detector:


texts: How to install several IDE version on my PC

texts: How can i install old version of IDE, without uninstalling the other version?(How can i install several IDE version in same laptop).


texts: Broken serial connection corrupting Arduino values

texts:
I have a problem with my homemade fan speed controller powered by an Arduino Nano, which reads a value from Serial (Arduino serial monitor, or Processing sketch) and uses the 0~255 value to set a variable fanspeed1 to set a PWM pin to control the fan speed.

The problem is when I close the Processing sketch, or the Arduino serial monitor, fanspeed1 is changed to max value (the fan speeds up to full speed).

I would like to send serial to set the value and then close the serial monitor, or Processing sketch and the value of fanspeed1 should not change.

If I need to post some code I can simplify my sketch down to a send serial, receive serial, make pin pwm = serial(0~255), but I am guessing there is a simple solution to this unfindable with my googling.

Help please, these fans need controlling...


texts: How to drive a strip of 12 V no-addressable LEDs?

texts: I recently bought this LED Strip. I got the 5M 3528 300LEDs SMD RGB Non-waterproof ones. However, I am not sure how to use them. On the strip there is four wires. I have tried supplying power to the wire that says it needs power and then I put ground to each of the other wires, but that only turns on a colour. How do I make it so I can choose what colour to use (Wiring, Code, etc.)?


texts:
Have both an Arduino Uno R3 and a Blend Micro that I have used to prototype a number of projects. Just got a new MacBook Pro and cannot get it to recognize the boards through the USB serial port.

I am using the same USB cable as before so I know it is not power only.

Have tried both USB ports. Have also tried them with other devices, so I know they work.

I have tried installing both the FTDI and CH34x drivers (both the older and the new signed one).

Don't know what to try next... any help?


texts:
I have this tea kettle, which requires pressing two buttons one after the other ("on" and "prog") to start.

I'd like to automate that action (tying it to Tasker on my phone), and am wondering what's my simplest/cheapest option. My communication options are either WiFi or Z-Wave/ZigBee.

I'm assuming Arduino Uno Wifi is an option, but that seems like a huge overkill given how simple what I want to do is. Are there any other simpler/cheaper tools that I could use to do this?


texts: Is this Bluetooth module cool for Arduino?

texts:
I am making a basic project that will have 4 or 5 arduino nodes. Each arduino will have a bluetooth module attached. The thing I want is, I want to be able for each one of these arduinos to know the other is present in the room (let's say, 5 meters). For my experience in the cellphone, I don't even have to pair bluetooth devices to know about their presence, as long as they are in visible mode. Since I just need to know their presence, and no exchange of information will ever happen, I probably will never have to pair them right?

For this project I need a bluetooth (BT) module that:

1) Enables me to change the ID of each arduino, so that, even if I use my cellphone to scan for BT devices I will see (Arduino1, Arduino2, etc...) instead of default-factory-names.

2) Enables me to scan around for existing devices every time each X seconds, because I want each arduino to know if the others are in the room.

Will this module do the trick? http://www.ebay.co.uk/itm/Interface-Base-Board-Serial-Transceiver-Bluetooth-Module-For-Arduino-UNO-R3-/111482008102?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item19f4d87226

Later I will probably hang around with batteries so I will want a low power BT module, having the same 2 capabilities mentioned. Will NRF8001 do the trick for me? http://www.nordicsemi.com/eng/Products/Bluetooth-Smart-Bluetooth-low-energy/nRF8001

Thanks!


texts: Is analogWrite() not affected by blocking codes and/or Interrupts?

texts:
Well just as the question say, is the analogWrite() function will continue generating near-consistent PWM when it encounters blocking codes or signal interrupts?

Is it the same case for both the classic arduinos(atmega chips) and the new arduinos(SAMD21 chips).

If analogWrite() does get affected by blocking codes, is there a way to create a uninterruptible PWM signal?


texts: How do I make a toggleable Infrared motion detection module

texts:
I just got an Arduino and an Infrared motion detection module. What I tried making is, that if the module detected movement, a led would turn on, and if it detected movement again, it would turn off. So I wrote this code and tried looking online for solutions, but couldn't find it. I really don't know what to change about my code to make it work. Does anyone have solutions for this?

(Sensor value can be 0 or 1, 0 means nothing detected, 1 means something detected. After detection the value automatically goes back to 0 in a few seconds)

int Sensor = 4;
int led = 13;
bool bool1 = false;

void setup() {
pinMode(Sensor, INPUT);
pinMode(led, OUTPUT);
Serial.begin(9600);
}

void loop() {
int SensorValue = digitalRead(Sensor);

if(SensorValue == 1){
  bool1 = !bool1;
  }

if(bool1 == true){
  digitalWrite(led, HIGH);
  }
if(bool1 == false){
  digitalWrite(led, LOW);
  }
}


texts:
I'm just got a Galileo Gen2 and wanted to try a simple blinking-led. The firmware have been updated to 1.0.4. My problem is whenever I try to upload the code I get this error:

Sketch uses 83,775 bytes (0%) of program storage space. Maximum is 10,000,000 bytes.
...
echo "Sending Command String to move to download if not already in download mode"
echo "~sketch downloadGalileo" > $tty_port_id

Deleting existing sketch on target
#Move the existing sketch on target.
echo "Deleting existing sketch on target"
"$fixed_path/lsz.exe" --escape -c "mv -f /sketch/sketch.elf /sketch/sketch.elf.old" <> $tty_port_id 1>&0
Login timed out after 60 secondsPoky 9.0.2 (Yocto Project 1.4 Reference Distro) 1.4.2 clanton /dev/ttyS1clanton login:`


texts: What is the overhead time of using Serial library compared to coding it up in AVR C (not using Arduino code)?

texts:
I am using an Arduino UNO to drive a UART throughput test and to also test the latency of the slave microcontroller.

The setup is as follows:

Arduino|---UART--------------------------|MCU2

Arduino|---FLOW_CONTROL_PIN---|MCU2

I am sending data to the MCU2 over the UART with a specified delay between writes, and in MCU2 I have a certain buffer threshold where I set an overflow pin indicator back to the Arduino (using INT0), where when the interrupt is triggered, I stop sending data (hardware based flow control).

At this point I log the amount of bytes sent and compare that to the buffer threshold level.  If the bytes sent are equal to the threshold point, I know the latency of the path (threshold-->toggle flow pin-->Arduino interrupt and stop transmit) is ok (if not, we are having latency issues and probably need to do a software based flow control). I then do the whole process again, with a shorter delay.  I then can find the delay point that will result in the fastest continuous transfer rate (this is testing throughput as well as latency of the slave MCU).

A problem can arise if the Arduino api is providing more latency than the path under test.  I believe this is most likely the case, but wanted to see if there has been any concrete numbers on the overhead of Arduino, particularly in regard to its Serial api.  I used Arduino to get something running quickly, but if it doesn't allow me to actually test the system, need to go to using all AVR C or use another MCU for the transmit side.


texts: State change in Arduino Using Adafruit display

texts:
if(menustate == 1310){menustate ++;Serial.println("Execution:");Serial.println(menustate);}
             if(menustate == 1311){menustate ++;if (hr==0) menustate ++;else{aCount++;gpArray[aCount]=hr;}Serial.println("Execution GP:");Serial.println(menustate);}
             if(menustate == 1312){menustate ++;if (minu==0) menustate ++;else{aCount++;gpArray[aCount]=minu;}Serial.println("Execution GP:");Serial.println(menustate);}
             if(menustate == 1313){menustate ++;if (seco==0) menustate ++;else{aCount++;gpArray[aCount]=seco;}Serial.println("Execution GP:");Serial.println(menustate);}
             if(menustate == 1314){menustate ++;if (dates==0) menustate ++;else{aCount++;gpArray[aCount]=dates;}Serial.println("Execution GP:");Serial.println(menustate);}
             if(menustate == 1315){menustate ++;if (months==0) menustate ++;else{aCount++;gpArray[aCount]=years;}Serial.println("Execution GP:");Serial.println(menustate);}
             if(menustate == 1316){menustate ++;if (years==0) menustate ++;else{aCount++;gpArray[aCount]=years;}}
             if(menustate == 1320){menustate ++;}

I am trying to get different time inputs from users by using the menustate value , but here in this code the menustate starts from 1311 and without pressing anything the state goes directly to 1320 .and i cant get to the inbetween states


texts: Adafruit feather M0 wifi firmware update

texts:
I just noticed that the firmware on the m0 wifi might need updating but says not to use the provided updater, how do you update the firmware so ?

Thanks


texts: How can I remove the delays in this code for sweeping the servo?

texts:
I know this is probably a very asked question, but I am building a fairly basic radar type thing which sweeps left and right and uses an ultrasonic sensor to determine the distance to an object and a buzzer is set off if something is detected.
The device itself works  but I've noticed that because I have used delay() to allow the servo to complete its full movements, it is holding up the rest of the code, and as a result the buzzer and returning of the distance is extremely unresponsive and sluggish.
So far I have looked at simply returning a value whenever the motor reaches a certain step but it doesn't achieve exactly what I'm looking for, and I have looked into using millis() for timing asynchronously, but I'm struggling to wrap my head around it a bit in terms of how it will work for a servo.
My current working but sluggish code:
//Servo Stuff
#include <Servo.h>
int servoPin = 12; // Pin for interacting with servo defined
int servoStart = 0; //Starting position of servo motor
int servoEnd = 90; //End position of servo means it rotates 90 degrees
int waitTime = 1000; // Allows servo to fully rotate before moving again
int servoPos = 20; // For incrementing the position of the servo
int servoStep = 20; //amount to increment servo position by
Servo myServo; // Creates an instance of a servo object

//Ultrasonic stuff
int trigPin = 9;
int echoPin = 10;
long duration;
int distance;
int maxDistance = 329; // The max range of the ultrasonic sensor

//Buzzer stuff
int buzzerPin = 11;
int buzzerWait = 200;

void setup(){

//Attach the servo object to the pin and begin serial monitor with
// polling rate of 9600
Serial.begin(9600);
  myServo.attach(servoPin);
  pinMode(buzzerPin, OUTPUT);

    pinMode(trigPin, OUTPUT); // Trig pin set as output
    pinMode(echoPin, INPUT); // echo pin set as i
      }

    void loop()
    {

      // Moving servo
      myServo.write(servoStart); //Moves servo to the starting pos
      //delay (waitTime); //allows servo to fully move before next move
      //myServo.write(servoEnd); //Moves to end position
      //delay (waitTime); // waits before reverting back to start pos

    //myServo.write(servoStart);
    //delay(waitTime);
    //myServo.write(20);
    //delay(waitTime);
    //myServo.write(40);
    //delay(waitTime);
    //myServo.write(60);
    //delay(waitTime);

     // Using ultrasonic sensor

      // Clears the trig pin
      digitalWrite(trigPin, LOW);
      delayMicroseconds(2);

    // Sets the trigPin on HIGH state for 10 microseconds
      digitalWrite(trigPin, HIGH);
      delayMicroseconds(10);
      digitalWrite(trigPin, LOW);

    // reads echoPin and returns the travel time of the wave in microseconds
      duration = pulseIn(echoPin, HIGH);

    // Calculating distance
      distance = duration*0.0343/2;

    //Prints the distance to the Serial Monitor
      Serial.print("Distance: ");
      Serial.println(distance);
      Serial.println(distance);

      if (distance < maxDistance) {
      digitalWrite(buzzerPin, HIGH);
      //delay(buzzerWait);
      //digitalWrite(buzzerPin,LOW);
      //delay(buzzerWait);

      }else digitalWrite(buzzerPin, LOW);

    }

Any pointers to some good resources for this would be very appreciated, thanks.


texts:
Does anyone know how to configure the Atmega32u4 to run using an external 8MHz oscillator ?

I needs to still be responsive to the Arduino IDE

Thanks


texts: Sequencing air pistons proble - Help please?

texts:
I am a beginner trying to activate 2 sets of 3 air pistons sequentially by going through the YouTube Tutorials... Help, please, pretty please?? :-)
There are 3 sets of 2 pistons, each set working in opposition.
So I have P1/P2, P3/P4, and P5/P6, each set working in opposition to squeeze at the center sequentially -
Initial state at turn-on/Reset must be:
// Step 1 Run Once:
P1 Down/P2 Up  // Move simultaneously (joining at the center) and HOLD in position -
P2 Up/P3 Down  // Move simultaneously and HOLD -
P5 Up/P6 Down  // Move simultaneously and HOLD -
// Wait for Start button -

I need to start/stop the sequencing with a toggle push-button -
I have reed-switch sensors that will give me a set of two TRANSIENT contact closure for each piston moving to the Up and Down positions -
Once started, the sequence needs to be as follows:
// Loop until Reset button is pushed -
// STEP 2: -
P1 Down/P2 Up (HOLD) // Old Initial State, unchanged -
P3 Down/P4 Up (MOVE) // Piston 3 moves Down/Piston 4 moves Up and HOLDS -
P5 Up/P6 Down (HOLD) // Still Old Initial State, unchanged -

// PROBLEM:  P3 Down AND P4 Sensors only give me a TRANSIENT closure:  These two transients MUST occur to initiate Step 3, but  they are not always exactly synched together, so my initial try by putting them in series fails... -
// I need to use that set of contact closures to trigger the next command: -
// Step 3: -
// The transient closures of P3 Down/P4 Up Sensors is the trigger needed for -
P5 Down/P6 Up (MOVE) // P5 moves Down/P6 moves Up and HOLD -
P1 Up/P2 Down (MOVE) // P1 moves Up/P2 moves Down and HOLD -
P3 Down/P4 Up (HOLD)  // P3/P4 HOLD -

// Back to Step 2 until the Reset button is pushed -

I can send you my attempt at coding for this, but it does not work unless the two sensors close simultaneously, which only happens in simulation...  ARGH..  :-(
Can someone send me a piece of code that will work for this, please?
I would really, really appreciate that...  Very frustrated right now!
You can email me at XXXXXXX.XXXX@XXXXX.XXX or text/call at (XXX)XXX-XXXX
Thanks either way.
Sincerely,
Michael
PS:  I tried to wire for a separate toggle switching for each sensor, but I run out of pins on my Arduino UNO R3... Looking into it via YouTube https://www.youtube.com/watch?v=cAT07gy4DII "Increase the digital outputs on an Arduino (PART 1 & 2)" but that is way more complex...  Trying to wade my way through that now...


texts:
I'm running a sample code from ESP32 examples and I'm scanning available BLE devices. I can see device MAC address etc. But for few devices I can't see their names.I am using ESP-WROOM-32 with hardware support checked out directly from their github (some bugs were fixed earlier on github than via lib manager)When I use LightBlue app for discovery of BLE Devices I can see names for more devices that ESP. What can I change to see the names correctly? OR Can how can I parse device name from the data I'm receiving?

This callback code

class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
    void onResult(BLEAdvertisedDevice advertisedDevice) {
      Serial.printf("Advertised Device: %s \n", advertisedDevice.toString().c_str());
      Serial.print(" RSSI: ");
      Serial.println(advertisedDevice.getRSSI());
    }
};

produces this output:

Advertised Device: Name: , Address: 1d:0c:c7:3a:fb:c6, manufacturer data: 4c0009060378c0a81f12, payload: 1073609632
 RSSI: -75


texts: utility/spi_com.h error when compiling Marlin for Arduino mega with Ramps 1.4

texts:
I am using win 8.1 and trying to load Marlin 2.0.x onto Arduino Mega with an attached Ramps 1.4 board fitted with 3 8825 Drivers. Unfortunately everytime I try to compile It concludes with the following error. Can anyone please help.
Alternatives for utility/spi_com.h:
[]ResolveLibrary(utility/spi_com.h)  -> candidates: []In file included from C:\Users\Dad\AppData\Local\Temp\arduino_build_750275\sketch\src\HAL\STM32\MarlinSPI.cpp:23:0:C:\Users\Dad\AppData\Local\Temp\arduino_build_750275\sketch\src\HAL\STM32\MarlinSPI.h:28:12: fatal error: utility/spi_com.h:
No such file or directory   #include <utility/spi_com.h>

compilation terminated.
Using library SPI at version 1.0 in folder: C:\Users\Dad\Downloads\arduino-1.8.13-windows\arduino-1.8.13\hardware\arduino\avr\libraries\SPI
exit status 1
Error compiling for board Arduino Mega or Mega 2560.


texts:
Please help. I am learning a lot about Arduino. Most all in lightning. I am a newbie. I play with nano and LED ws2812 and use fastled library.

What ask is to make effect like fill effect. For example with larson scanner/chaser.

for (int i = 0; i<NUM_LEDS; i++)
{
  leds[i]=CRGB::Red;
  FastLED.show();
  leds[i]=CRGB::Black;
  delay(50);
}

From that code above how to make LED stop and lit up and loop again and stop and lit up.  I want every LED stop the LED lit up even LED looping start again from first LED. It like this:

  10000 01000 00100 00010 00001 10001 01001 00101 00011 10011 01011
  00111 10111 01111 11111


texts: To reduce the Attiny85 current consumption

texts:
I am using Attiny85 to control 4 LEDs parallelly with a programmable switch. But even though when the LEDs are in OFF state, current consumption is around 7-8mA.
I am using a 200mAh battery in my project and it is draining up the whole battery in 24hrs (when the LEDs are in OFF state)
Below is the schematic image of my attiny85 circuit:

Code:
//Absolute maximum current of each pin of Attiny85 is 40mA
//So each LED has been given to seperate pins

const int buttonPin = 2;    // the pin that the pushbutton is attached to
const int ledPin1 = 0;      // the pin that the White LED1 is attached to
const int ledPin2 = 1;      // the pin that the Blue LED1 is attached to
const int ledPin3 = 3;      // the pin that the White LED2 is attached to
const int ledPin4 = 4;      // the pin that the Blue LED2 is attached to

// Variables will change:
int counter = 1;             // 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() {
  pinMode(buttonPin, INPUT);
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
  //Serial.begin(9600);
}

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

  if (buttonState != lastButtonState) {    // compare the buttonState to its previous state
    if (buttonState == HIGH) {             // if the state has changed, increment the counter
      counter++;                           // if the current state is HIGH then the button went from off to on:
    }
    delay(50);                    // Delay a little bit to avoid bouncing
  }

  lastButtonState = buttonState;  // save the current state as the last state for next time through the loop

  if (counter == 2) {
    digitalWrite(ledPin1, HIGH);  //turns on White LED1
    digitalWrite(ledPin2, LOW);
    digitalWrite(ledPin3, LOW);
    digitalWrite(ledPin4, LOW);
  }
  else if (counter == 3) {        //turns on White LED2
    digitalWrite(ledPin1, LOW);
    digitalWrite(ledPin2, LOW);
    digitalWrite(ledPin3, HIGH);
    digitalWrite(ledPin4, LOW);
  }
  else if (counter == 4) {        //turns on both White LEDs
    digitalWrite(ledPin1, HIGH);
    digitalWrite(ledPin2, LOW);
    digitalWrite(ledPin3, HIGH);
    digitalWrite(ledPin4, LOW);
  }
    else if (counter == 5) {        //turns on Blue LED1
    digitalWrite(ledPin1, LOW);
    digitalWrite(ledPin2, HIGH);
    digitalWrite(ledPin3, LOW);
    digitalWrite(ledPin4, LOW);
  }
    else if (counter == 6) {       //turns on Blue LED2
    digitalWrite(ledPin1, LOW);
    digitalWrite(ledPin2, LOW);
    digitalWrite(ledPin3, LOW);
    digitalWrite(ledPin4, HIGH);
  }
  else if (counter >= 7) {         //turns on both Blue LEDs
    digitalWrite(ledPin1, LOW);
    digitalWrite(ledPin2, HIGH);
    digitalWrite(ledPin3, LOW);
    digitalWrite(ledPin4, HIGH);
    counter = 0;
  }
  else if (counter == 1){         // turns off all the LEDs after one button push
    digitalWrite(ledPin1, LOW);
    digitalWrite(ledPin2, LOW);
    digitalWrite(ledPin3, LOW);
    digitalWrite(ledPin4, LOW);
  }
}

For each time push button is pressed, respective LEDs get ON and there are 6 such cases. In 7th case, it goes back to case 1.
So, is there a way to reduce the current consumption?
Is there any commands where we can,

Reduce the clock frequency
Disable all the interrupts
Disable all modules etcc.....when not in use

If the current consumption goes less than 1mA that would be great.


texts: "'serial' not declared in this scope" error

texts:
I'm trying to make a basic potentiometer with a startup kit using the following code:

const float referenceVolts = 5.0;
const int batteryPin = 0;

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

void loop()  {
  int val = analogRead(batteryPin);
  float volts = (val / 1023.0) * referenceVolts;
  Serial.println(volts);
}

It worked on one computer, however on my primary laptop it refuses to work and displays an error message "'serial' not declared in this scope". Can anyone recommend a solution?


texts: PROGMEM: do I have to copy data from flash to RAM for reading?

texts:
I have got some difficulties understanding the memory management.

Arduino documentation says, it is possible to keep constants like strings or whatever I don't want to change during runtime in program memory. I think of it as embedded somewhere in the code segment, which must be fairly possible inside a von-Neumann-architecture. I want to make use from that to make my UI menu on a LCD possible.

But I'm bewildered by those instructions to just read and print data from program memory:

strcpy_P(buffer, (char*)pgm_read_word(&(string_table[i]))); // Necessary casts and dereferencing, just copy.
    Serial.println( buffer );

Why on earth do I have to copy the damn content to RAM before accessing it? And if this is true, what happens to all the code then? Is it also loaded to RAM before execution? How is the code (32kiB) handled then with only 2kiB RAM? Where are those little goblins carrying floppy disks?

And even more interesting: What happens to literal constants like in this expression:

a = 5*(10+7)

are 5, 10 and 7 really copied to RAM before loading them into registers? I just can't believe that.


texts:
I have this code and it is a reaction light game. When you press the button on pin 11 it starts the game and the lights should osculate back and forth. The main goal is to press the button when it hits the middle led and the osculating will slow down. I cannot get the leds to turn on help?

    int ledPin;
    int direction;
    int isChanging;
    unsigned long lastChange;

void setup() {
   //set pins 2 to 10 to be output
  // and LEDs off
   int pin;
    for (pin = 2; pin <= 10; pin++) {
       pinMode(pin, OUTPUT);
       digitalWrite(pin, LOW);
    }
     //set pin 11 to be input
     pinMode(11, INPUT);

     ledPin = 2;
     direction = 1;
     lastChange = millis();
  }

 void loop() {
    if (isChanging) {
    if (millis() - lastChange > 500) {
        //turn off old LED
        digitalWrite(ledPin, LOW);
        //reset time
        lastChange = millis();
        //change the led
        ledPin = ledPin + direction;
        if (ledPin > 10) {
          direction = -1;
        ledPin = 9;
      } else (ledPin < 2); {
        direction = +1;
        ledPin = 3;
     }

       //turn on new LED
        digitalWrite(ledPin, HIGH);
     }
       //check for button
       if (digitalRead(11)) {
        isChanging = 0;
     }
     }
    else {
       //wait for them to let go of the button
       while (digitalRead(11)) {
     }
       //wait for it to be pressed again
       while (!digitalRead(11)) {
     }
       //wait for them to let go of the button
       while (digitalRead(11)) {
     }
    }
   }`


texts: Reading values from Wiznet w5500 chip over SPI

texts:
I am trying to get the MAC address that is stored on the Wiznet w5500 chip.

On page 29 - click here, it has the address of the values. It state that "This block can be selected by the BSB[4:0] value of SPI Frame". Then it lists the addresses of the MAC block from 0x001E to 0x0023.

How do I read these blocks using the SPI library? What does the BSB[4:0] mean?

EDIT 1: I am looking through the Wiznet Arduino library and it looks like there is a way to access the mac address through


texts: Problems returning char array from function, value gets messed up

texts:
I use the Base64 library for Arduino (but I don't think the problem is related to the library) and have the following function definition:

char* decodeImage(char inputString[], unsigned int inputStringLength) {
  int decodedLength = Base64.decodedLength(inputString, inputStringLength);
  char decodedString[decodedLength];
  Base64.decode(decodedString, inputString, inputStringLength);
  Serial.printf("%s",decodedString); // prints "Base64DecodeExample"
  return decodedString;
}

Later on, I use the following snippet to access the function:

  char inputString[] = "QmFzZTY0RGVjb2RlRXhhbXBsZQA=";
  char* output = decodeImage(inputString, sizeof(inputString));
  Serial.printf("%s",output); // prints garbage

The problem is, that the result of the decoding INSIDE the function seems to be correct, but when I return the value to the calling code, the value get garbled somehow.

I suppose this has something to do with pointer magic or "decaying" of references. Has someone a suggestion?


texts:
I am a new learner on Arduino. I am trying to learn how to control the LCD. I looked in the article, "Hello World!", and followed the instructions but it did not work (I checked it many times). The result I got is shown below (the text is not showing).

Please help me. Any help is appreciated.

Here is my code:

    #include <LiquidCrystal.h>
    LiquidCrystal lcd(12, 11, 5,4,3,2);

    void setup() {
      // set up the LCD's number of columns and rows:
     lcd.begin(16, 2);

    lcd.print("hello, world!");
    }

    void loop() {
      // set the cursor to column 0, line 1
      // (note: line 1 is the second row, since counting begins with 0):
      lcd.setCursor(0, 1);
      // print the number of seconds since reset:
      lcd.print(millis() / 1000);
    }


texts:
I have a gamepad which I want to treat as a sensor for my Arduino board. I want Arduino to trigger a certain action based on button pushes from the gamepad. Different buttons, different actions.

The gamepad comes with a USB connector. I cut the the USB cable open, solder it with pluggable pins which are then connected to a breadboard. I supply the gamepad with 5V power from Arduino and connect the USB's Data+ to Arduino's analog input pin (A0). Please check the images below.

I thought by observing the voltage coming from the gamepad's Data+ pin, I can probably determine if a button is being pushed. However, the observable input voltage in Arduino's A0 do not produce any meaningful difference between button push and release.

My question: Is it possible to detect Gamepad's button pushes with this arrangement? If it's possible, where do you think I'm doing wrong?

simulate this circuit – Schematic created using CircuitLab


texts: How to configure TinySine 3G module (SIM5320E) for HTTP GET request

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

I'm following this TCP/UDP section of SimCom tutorial to receive data from a REST API. But I cannot set the APN for TCP as there is no support for AT+CSTT command as it seems.

I can see it's on WCDMA network.

    AT+CREG?
    +CREG:1,1

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

Error comes here

    AT+CSTT="live.vodafone.com"
    ERROR

Is there a way to resolve this issue
 - With the same setup/libraries OR
 - By upgrading libraries/firmware of the module OR
 - Using any other set of commands

Please provide if any of you have a sample code to access a REST API. Appreciate your help very much.


texts:
I am onto a simple project with Arduino, SR04 and a buzzer for "Car reverse parking assistance". The aim here is to make a buzz when the car gets too close to the objects.

I was thinking what if it's raining when a person is driving (assuming I somehow achieved to water proof the sensor) - will the buzzer make continuous sounds?

Is there any alternative solution for ultrasonic sensors?


texts: Difference between simple wifi transceiver and arduino yun

texts: I am debating over getting arduino yun or 2pcs nRF24L01+ 2.4GHz Wireless Transceiver. Here is the link to the transceiver on amazon  amazon description. I do not know much about wifi but why would someone get the 70 dollar yun instead of the basic transceiver and a uno. In particular for my project I want my arduino to use Web API's like twilio to send messages to my phone. Can both products do that?I know the yun has linux but I don't know if I need that for my project.Is their a better option (price is part of my decision)


texts:
I am working on a project that I am supplying with voltage an LED through a digital pin (26) and I want the LED to be switched off after 4 seconds.

I am using Arduino Mega2560 and I am programming it using Arduino's IDE version 1.6.10. I have installed the SimpleTimer library .zip method but it does not seem to function.

Code

#include <SimpleTimer.h>

SimpleTimer timer;

void setup() {
pinMode(26, OUTPUT);
digitalWrite(26, HIGH);

timerId = timer.setTimeout(4000, switchOff);
}

void switchOff() {
  digitalWrite(26, LOW);
}

void loop() {
}

The problem is that the LED stays just on (digitalWrite(26, HIGH);) instead of going to the switchOff function and turning off (digitalWrite(26, LOW);). I have also tried using Timer1 and Timer libraries but they also do not work. Can someone who has made any of the libraries work, provide me with some guidance?


texts: how can i conect a lipo charger to a teensy 4.0?

texts:
I have the battery charger product https://www.adafruit.com/product/2124
and a teensy 4.0, that I would like to use to power it.
what, if any pin would I connect from bat, to the teensy?
Its my understanding that the Lion backpack is a voltage regulator, and thats it. it takes Vin, ground, and Vout.
I understand the 5v output goes to the 5volt pin of the teensy.
the gnd goes to gnd. should Vin go someplace? Or should I leave it off?
Please assist.


texts: Switching 4.2V circuit with 3.3V Arduino GPIO

texts:
I am trying to learn about MOSFETs and see this p channel MOSFET and this tutorial.  I am trying to use a 3.3V arduino GPIO pin to control a load that is powered from a 4.2V battery in much the same configuration as the circuit drawn in that tutorial.  Most other tutorials I see say the Gate Voltage needs to be equal or greater than the Source Voltage, but the tutorial I cited describes that actually the Voltage between the Gate and Source just needs to be more negative than the Threshold Voltage.  The P channel mosfet I cited is Vthreshold -2V to -4.  So my question is whether this P channel MOSFET would allow me to use a 3.3V arduino GPIO to control whether that 4.2V source is closed or open to the drain/load.  Looking at how that tutorial does the math, it seems in my case the GPIO being off would mean Vgs is 0 - 4.2 = -4.2 and therefore the MOSFET is in the ON state.  If GPIO is on at 3.3V then Vgs is 3.3 - 4.2 = -0.9 and therefore the MOSFET is OFF.  However, the tutorial doesn't say what happens when Vgate < Vsource but by an amount less than the Vthreshold so I don't know if my math is right.
In sum my questions are:

Is my math and prediction of the MOSFET states correct when that 3.3V GPIO is on or off?
If not, is it because of some other quality in this MOSFET and a different P MOSFET would work?
I presume that if I keep out of the Vgs upper and lower bounds then I avoid issues where the MOSFET is in a partially on and partially off state, is that correct?
Is it just impossible to use P MOSFETS in this way?

Note:  My questions only pertain to P MOSFETs.  For my project (switching a 1-2A disco light toy), it has to be a high side switch and that's even besides the point because I am more importantly trying to understand how the P channel mosfets work.


texts:
I have multiple ESP8266 units programmed using Arduino SDK and I would like each one of them to adjust the transmission power to lower the power requirements.

Arduino allows setting the TX power of the ESP8266 using the function WiFi.setOutputPower(), however it is not clear to me how to choose that value.

I know that RFM69 using the LowPower library has automatic gain control using the ACK packet sent by another RFM69 module. However, with ESP8266 there is a standard AP and a similar approach would not be obvious.

How can I perform optimal gain control?

This question is independent from the choice of the WiFi mode b/g/n using WiFi.setPhyMode().

Edit

An idea could be to detect AP station signal strength and transmit at a power level offset by a fixed amount, decreasing that delta by one tick at every wake up, until no connection is achievable. At that point the delta should be increased by an amount corresponding to a sort of hysteresis, to jump above the no-connection threshold, and kept.

After a predefined amount of successful wake ups, for example 100, the process of decreasing the calculated delta would be tried again.

For example: AP strength -60 dB, transmission +12 dB: success -> delta 48 dB is good.

Next wake up, delta 48.25 dB: is AP is at -55 dB, transmission would be 55-48.25 dB = 6.75 dB. If success, delta increased to 48.50 dB.


texts:
Platform

Hardware:                 [nodemcu amica ESP8266MOD]
Core Version:         [nodemcu-master-21-modules-2018-03-17-17-09-10]
Development Env:      [Arduino IDE|]
Operating System:     [Windows|]

Settings in IDE

Module:           |Nodemcu]
Flash Mode:           [qio|dio|other]?
Flash Size:       [1MB]
lwip Variant:   [v2 Lower Memory]
Reset Method:     [nodemcu]
Flash Frequency:  [40Mhz]
CPU Frequency:        [80Mhz]
Upload Using:     [SERIAL]
Upload Speed:   [115200] (serial upload only)

Problem Description

hi, in my code i did a simple thing. i get the data from jSon object and write them to the EEPROM. once i write them to eeprom i can read the relevant data from that writing function handleFinishWizard()  (i have put reading functions here n there to find where is the problem) .When i write data and finish it i can read the data.once its over when the program moved to the loop, eeprom data are corrupted and it doesnt display anything. i attached the output in debug message. whats the problem here?

[MCVE] Sketch

code in github CODE LINK

Debug Messages

```
add 1
aid 1
station: c0:ee:fb:ed:3b:0e join, AID = 1
value on EEPROM ADD:
OnePlus 3T
test123@abc
test.com

value on EEPROM ADD:
OnePlus 3T
test123@abc
test.com

value on EEPROM ADD:
OnePlus 3T
test123@abc
test.com

value on EEPROM ADD:
OnePlus 3T
test123@abc
test.com

value on EEPROM ADD:
OnePlus 3T
test123@abc
test.com

value on EEPROM saveBefore:
⸮?

⸮?

value on EEPROM saveBefore:
⸮?

⸮?

value on EEPROM saveBefore:
⸮?

⸮?

value on EEPROM saveBefore:
⸮?

⸮?

value on EEPROM saveBefore:
⸮?

⸮?

value on EEPROM save:

value on EEPROM save:

value on EEPROM save:

```


texts:
I've reached the limit on available SRAM memory. I need to "cut down" some variables, but I actually don't know how far I need to go with it.

Is there a way on measuring current available memory on program execution?


texts:
I installed an Eclipse Version: 2018-12 (4.10.0) for Arduino.

I’ve got an CDT Core Builder error  when I try to compile.

I’ve searched but cannot fix the problem.


texts: I am working with RFID-RC522 and Arduino UNO. I have check pin configurations again and again tried different libraries. It is not reading card and red led on RC522 is consistently on.


texts:
I need to write a program that takes a user inputted HEX value and converts it to binary, then an LED blinks according to the number of 1's in the binary. For instance, if the value is 0xABC then there are number of 1's are 7 so LED will blink 7 times.

I only just started Arduino so not sure how to let user input a value nor do I know how to convert HEX to BIN but I'm assuming that once I convert the HEX to BIN I can just use a loop to count the number of 1's yet I'm unsure as to actually how to do that. This is what I've written so far.

  byte val=0xABC;
int ledPin=13;

int countSetBits(unsigned int n)
{
    unsigned int c;
    for (c=0;n>0;n=n&(n-1))
        c++;
    return c;
}

void blink(int n)
{
    for (int i = 0; i < n; i++)
    {
        digitalWrite(ledPin,HIGH);
        delay(500);
        digitalWrite(ledPin, LOW);
        delay(500);
    }
}

void setup()
{
    Serial.begin(9600);
    pinMode(ledPin,OUTPUT);
    blink(countSetBits(val));
}

void loop()
{   }

Any help would be appreciated.
EDIT: If I want to take a number from a user and then make the LED blink according to the number of 1's in its binary form, how would I implement that?


texts: Quick start on Arduino for experienced embedded programmer?

texts:
I'd like catch up the Arduino concepts (programming & IDE). There are excellent online tutorials available for Arduino but all of them which I saw are made for those who didn't have embedded/electronics background. Going through them is heavily time consuming as I'm already familiar with the embedded programming other than Arduino or Raspberry Pi.

Does any one know any quick reference materials for Arduino which excludes electronic/embedded basics which is meant for experienced embedded programmer? That could be a big time saver for me.

Thanks in advance!


texts:
Board: "ATtiny25/45/85"

Processor: "ATtiny85"

Clock: "Internal 1 MHz"

Programmer: "Arduino as ISP"

I want to run a servo forwards and backwards on an ATtiny85. The servo library is not compatible with the ATtiny85 so I had to write code from scratch. At this point, the code that makes the servo go forwards (clockwise) is:

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

void loop() {
  digitalWrite(PB1, HIGH);
  delayMicroseconds(1000);
  // 1 millisecond determines the servo going forwards
  digitalWrite(PB1, LOW);
  delay(19);
}

And the code that makes the servo go backwards (anti-clockwise) is simply by changing the amount of microseconds to:

delayMicroseconds(2000);

I want to have the servo motor go forwards one cycle for a few seconds and then go backwards for a few. I want this to keep looping. At this point my code is:

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

void loop() {
  digitalWrite(PB1, HIGH);
  delayMicroseconds(1000);
  digitalWrite(PB1, LOW);
  delay(19);
  digitalWrite(PB1, HIGH);
  delayMicroseconds(2000);
  digitalWrite(PB1, LOW);
  delay(19);
}

This however just makes the servo go back and forward at the same spot forever. I do realise I might need a for loop for this but I am confused as how I will do this.


texts: connect USB keyboard to Arduino using clk and data wires

texts:
Edit:
What I'm looking for is some kind of library which could be used with an arduino to read the HID protocol output from the Data+ and Data- cables of the USB.
==========
If I cut the cable of a usb keyboard, plug in power and ground can I use the clk and data wires to read keystrokes into the Arduino? If so any pointers to libraries and schematics?
Simple I instructions? The "for dummies" version?
EDIT
Following some of the suggestions below I found this:
https://github.com/julianschuler/USBKeyboard
Which looks like what I want to do, basically hook up the lines into the arduinio and read from the keyboard using the HID protocol in this library.
EDIT 2
That doesn't do what I want. Does anyone know how this could be accomplished?


texts: Arduino i2c communication between another arduino and a sensor

texts:
Can the following scenario exist?

Microcontroller 1 sends a code to microcontroller 2 to start reading sensor data. Then Microcontroller 2 reads sensor data from sensor and sends it back to microcontroller 1.

If such a scenario is possible, then how would the pseudo code for microcontroller 2 receive-event be?

Need help with this badly!!


texts: How to listen to multiple server ports with ESP8266?

texts:
I'm using WeMos D1 R2. I'm trying to listen to both ports 1992 and 1993. This is my current code:

    #include

WiFiServer server_1992(1992);
WiFiServer server_1993(1993);

void setup() {
    Serial.begin(9600);
    WiFi.begin("MySSID", "MyPassword");
    while (WiFi.status() != WL_CONNECTED){
        delay(500);
        Serial.print(".");
    }
    Serial.println(" connected");

    server_1992.begin();
    server_1992.setNoDelay(true);
    server_1993.begin();
    server_1993.setNoDelay(true);
}

void check_server(WiFiClient* client, WiFiServer* server, const char* text){
    if (client->connected()) {
        if (client->available()){
            unsigned char c[250];
            client->readBytes(c, 1);
            Serial.print(c[0]);
            Serial.print(" ");
        }
    } else {
        client->stop(); //Adding it here like Juraj said. Not tested.
        *client = server->available();
        if (*client) Serial.print(text);
    }
}

void loop() {
    WiFiClient client_1992, client_1993;
    while (1){
        check_server(&client_1992, &server_1992, "1992 connected \n");
        check_server(&client_1993, &server_1993, "1993 connected \n");
    }
}

The problem is when the client(s) disconnect from the hotspot, my code keeps waiting for data forever without trying to acquire new client (with client = server->available();).

Solution: for now I ask the client "Hey are we still connected?" every few seconds and manually kick the client out if it doesn't reply.
More on this

Sorry if it's wrong to link other question here, I just hope people who have the same problem as mine can find the solution.


texts: Arduino due temperature reading shows random temperatures

texts:
I am using an Arduino Due board to read three temperatures from three separate smt160-30 digital sensors but the program is behaving very randomly. the code I am using is one I got from arduino official site and changed the structure to get three temp readings and display them on a 16x2 lcd. The problem is when I use one sensor the output is reasonable but when I use all three the temperature showing are all off by 4 degrees. also I tried removing the line lcd.print(temperature1, 1) and the output temperatures changed. Is this odd behavior because of SRAM issues ? if so how can I find out about it and fix it ?

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

unsigned long now;
unsigned long lastSample;
unsigned int sampleSize;

unsigned int highCount1;
unsigned int highCount2;
unsigned int highCount3;

unsigned long lastOutput;

float temperature1;
float temperature2;
float temperature3;
float hcf1, hcf2, hcf3;
float ssf;

int sensorPin1 = 23;
int sensorPin2 = 24;
int sensorPin3 = 26;

void setup(){

    pinMode(sensorPin1, INPUT);
    pinMode(sensorPin2, INPUT);
    pinMode(sensorPin3, INPUT);

    digitalWrite(sensorPin1, LOW);
    digitalWrite(sensorPin2, LOW);
    digitalWrite(sensorPin3, LOW);

    lastSample = 0;
    sampleSize = 0;

    highCount1 = 0;
    highCount2 = 0;
    highCount3 = 0;

    temperature1 = 0;
    temperature2 = 0;
    temperature3 = 0;

    lastOutput = 0;

    delay(2000);
    lcd.setCursor(0, 0);

}

void loop() {
    now = micros();
    if (now - lastOutput > 3000000) {
        lcd.clear();

        hcf1 = highCount1;
        hcf2 = highCount2;
        hcf3 = highCount3;

        ssf = sampleSize;

        temperature1 = ((hcf1 / ssf) -0.32)/0.0047;
        temperature2 = ((hcf2 / ssf) -0.32)/0.0047;
        temperature3 = ((hcf3 / ssf) -0.32)/0.0047;

        lastOutput = now;
        sampleSize = 0;

        highCount1 = 0;
        highCount2 = 0;
        highCount3 = 0;

        lcd.print(temperature1, 1);
        lcd.print(" ");

        lcd.print(temperature2, 1);
        lcd.print(" ");

        lcd.print(temperature3, 1);

    }
    if (now - lastSample > 50) {
        sampleSize++;
        highCount1 = highCount1 + digitalRead(sensorPin1);
        highCount2 = highCount2 + digitalRead(sensorPin2);
        highCount3 = highCount3 + digitalRead(sensorPin3);
        lastSample = now;
    } else {
        delayMicroseconds(10);
    }
}

Thank you!


texts: How to control Neopixel LEDs in parallel?

texts:
Imagine a collection of LEDs (Neopixel or otherwise) labeled 2 through 12. There may be more than 11 LEDs, so repeat numberings are allowed. I want a simple way to control them from a single Arduino based on their label. So e.g. I should be able to implement a function whose arguments are a label value and an RGB value, and which turns all LEDs of that label value to the given RGB value. Most importantly, the solution has to be order-independent; that is, I should be able to re-wire the LEDs (or equivalently, scramble around the hex labels) in any manner, and still have everything work without rewriting any code. (For context, my goal is to make a custom Settlers of Catan edition, where the labels on each hex light up when their die value is rolled.)

I know I can't just use Neopixels out of the box, since the addressing depends on the order in which they're wired. So I assume I need to hack together a way for each LED to "know" its label, wire them all in parallel, and then write a custom library to . But I have no idea how to get each LED to know its label without having an entire Arduino for each LED, which would take up way too much space. (I'd like to fit everything in roughly the volume of a typical Catan hex label; think 2-3 quarters stacked together.)

I'm fairly comfortable with Arduinos, but I'm an electronics noob. Is it possible to reprogram the Neopixel controller? Or is there a tiny logic board I can hook up to a Neopixel or dumb LED that would do the job? Anything else I'm missing?


texts: Arduino Gesture Sensor error:No such file or directory

texts:
I cloned https://github.com/sparkfun/APDS-9960_RGB_and_Gesture_Sensor
and copied the libraries into the Arduino libraries folder. I then launched Arduino and selected the example. I opened the file GestureTest and when I started upload I received this error:

GestureTest.ino:49:31: fatal error: SparkFun_APDS9960.h: No such file or directory
compilation terminated.

I checked the SparkFun_APDS9960.h and I found it in the Gesture_Sensor/Libraries/src folder.
Is there a solution to resolve this error?


texts: Pointer to Hardware Differences Documentation For Arduino Boards?

texts:
I hope this question isn't overly broad although it is more of a search for consolidated information.

BACKGROUND:

I am new to the Arduino universe and am drawn in by the open hardware concept. After years of doing electronics projects with PICs, I have tired of iterative hardware prototyping and DIY printed circuit construction for small one-off projects. The lure of buying off-the-shelf hardware and doing minimal wiring on protoboards / shields is a powerful concept that I welcome.

The availability of the hardware from multiple sources (and it seems multiple designers) does present a small problem I have discovered. There appear to be small but important differences between Arduino boards from multiple sources.

As an example, I have found that the hardware PWM isn't always the same from one Arduino Board design to another. I find that the arduino.cc pages (including the Forums) appear to indicate that hardware PWM runs at about 487 Hz. However, my testing shows that on the Arduino 101, two of the four hardware PWM outputs run at 487 Hz while the other two run at 975 Hz. I did not find such details when researching board choices and comparisons. I am assuming that this difference may also exist on other board designs although I have only Uno, 101, and Mega2560 boards to play with at the moment.

A second example is that for at least the Arduino Uno and Arduino 101 board I have, the DC power input jack is 5.5mm/2.1mm, a very common size. However, the Arduino Mega2560 I have (third party) uses a 5.5mm/2.5mm DC input jack -- a standard albeit less common size.

Another difference is the well known differences in (TTL) RS232 port interface chips used. At least these are generally made known and documented so that you can plan in advance for differences that may or may not affect you.

Finally, I have found that on the Arduino 101, plugging in or unplugging (or turning on or off) DC power at the DC input jack (or Vin pin) forces a reboot of the Curie module on the board. I think this is caused by the use of the power management chip and power switching circuitry on the board. The Mega2560 does not show this reboot behavior whenever DC power is changed. (This reboot happens even if the USB source remains connected at all times.)

These sorts of minor differences can affect the choice of board one makes for a given project -- especially, if you develop an application on one board and plan to deploy it on another. (Example: develop on a Mega2560 yet intend on deploying on a Uno later to save cost.)

QUESTIONS:

1) Has anyone come across a Website / page that details many of the minor design differences between Arduino boards?
[Edit] I should have used the word designs rather than boards in this question. I realize each vendor may have tweaks to a board but was more interested in detailed differences in the "official" design. Things like above would be interesting to know -- does the board reboot on application of DC input power? Are all PWMs running at the same default frequency, etc?

2) Are there any Web resources that might at least list other "oddities" with the different board choices? (i.e. PWMs at frequencies other than 487 Hz)?

Any pointers would be much appreciated.


texts:
There's no end to my frustration trying to figure out how the arduino build system works -- despite my best efforts I just can't seem to grok it. Anyhow, I did this:
ALTERNATE_CORE_PATH=/path/to/MightyCore/avr
BOARD_TAG=324
...

make show_boards shows me several boards available, including 324. Yet whenever I try to build my project, I get this error:
avr-g++: error: missing device or architecture after ‘-mmcu=’

Can someone point me in the right direction?
Thanks.


texts: How can I interface, received HC-12 data and transmit the received data using sx-1278 RF-module in arduino-UNO?

texts:
I am currently working on a project, where I need to send data from first unit to the second unit which is a few km apart, so I decided to go with hc-12 RF module as it covers upto 5km. Then the data received in the second unit is again to be transmitted to the last unit which is several km apart from each other, so I decided to go with sx-1278 RF module which can easily transmit data up to 30kms. I am trying to get the received data to print on the serial monitor. So, how do I transmit the received HC-12 data in the second unit using the sx-1278 RF module to the third unit? Is this operation even possible? Are these two boards compatible with each other?
If the answer is yes, please do help me out with the coding part on how to interface these two RF-modules.
Thanks in advance


texts: Serial.read() doesnt work in IF statement

texts:
I am working with an XBee module, so naturally, I started my void loop with AT command testing.

void loop() {
    digitalWrite(Sleep_Rq,LOW);

A +++ with a guard time of 1 sec before and after it, sets xbee module in command mode.

delay(1000);
xbeeSerial.write("+++");              // Enter Command Mode
delay(1000);

This part of the code, puts the serial data into string variable x in the form of a String.

while(xbeeSerial.available()) {
    x = xbeeSerial.readString();
}

Serial.println() is returning OK onto the serial monitor.

Serial.println(x);

But when I compare x with OK nothing happens, 1 doesn't appear on the serial monitor.

if(x=="OK")
  {
   Serial.println(1);
  }
}

I tried swapping "OK" with 4F4B (ascii equivalent of OK), 20299 (decimal value). I also  tried changing datatype of x from String to word and compared x with 0100111101001011.
I also tried changing the IF condition as,

if(Serial.println(x)=="OK")
    {
     Serial.println(1);
    }

and many more techniques with no luck to be found.


texts:
I am trying to transmit serial data from terminal to Arduino and I want to reconfirm that its the same data. But I am not able to get the right answer. I want data to be HEX. I want to check only the third last and last bytes since they will be changing every time.

I tried to write it in 2 different ways but none worked.

First try:

byte thisByte[]={0xAA, 0xBB, 0x06, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03};
void setup()
{
  // start serial port at 9600 bps:
  Serial.begin(9600);
}

void loop()
{
  while (Serial.available())
  {
    delay(250);
    // get the new byte:
    byte thisByte = Serial.read();
    // add it to the inputString:
    //inputString += char(intChar);

    if(thisByte == 0x03 || thisByte == 0x03)
    {
      Serial.print(thisByte, 'Hello');
      //digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(50);             // wait for a second
      Serial.print(thisByte, 'Nothing');
      //digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
    }
    Serial.print(thisByte,HEX);
    Serial.print(" | ");
  }
}

Second try:

const byte message[]={0xAA, 0xBB, 0x06, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03};
boolean found = false;

byte byte1 = 0xAA;
byte byte2 = 0xBB;
byte byte3 = 0x06;
byte byte4 = 0x00;
byte byte5 = 0x00;
byte byte6 = 0x00;
byte byte7 = 0x01;
byte byte8 = 0x01;
byte byte9 = 0x03;
byte byte10 = 0x03;

const byte Hallo;
//void rules();
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  // put your main code here, to run repeatedly:
  //int hexIn = Serial.read();
  //Serial.write(message,2);
  //Serial.write(message,sizeof(message));
  //delay(500000);
  while(Serial.available())
  {
    delay(10);  //small delay to allow input buffer to fill
    byte c = Serial.read();
    byte message = c;

    //Serial.print(c,HEX);
    //Serial.print(" | ");

    //if (c =!byte 0xAA && c =!byte 1 0xAA && c =!byte 0xAA && c =!byte 0xAA && c =!byte 0xAA && c =!byte 0xAA && c =!byte 0xAA && c =!byte 0xAA);

    if (c == message);
    //Serial.print("I received: ");
    Serial.println(c);

    // byte c = Serial.read();  //gets one byte from serial buffer
    // readmessage += c;
  } //makes the string readString
  //Serial.print(messsage);
  //readString=""; //clears variable for new input
}


texts: Intermittent LOW reading from input pin set to INPUT_PULLUP

texts:
i have an output pin connected to a magnetic reed switch. The pin mode is INPUT_PULLUP. When the switch is closed, it connects the pin to GND and drags the pin to a LOW reading. I check the state of the pin in the loop function. Occasionally the pin reads LOW when it shouldn't (the switch is not closed) - e.g. around once per second. What could cause this? The wire from the pin to the switch is about 1m long - could this be long enough to intermittently drag it down to a LOW? Also, it seems to happen much more when the air temperature is hotter.

Circuit summary: Pin (INPUT_PULLUP) -> Magnetic reed switch -> GND


texts:
I have a few useful I2C components, such as a 16-bit port expander (MCP23017), which I'd like to use in various projects.

What do I need to do to make these work with Arduino? Will it work with any Arduino, or do I need a specific board or shield?


texts:
How much time takes to print each sample using Serial.print and analogRead in each iteration?

#include <SoftwareSerial.h>
#define Sensor A0
void setup() {
  Serial.begin(250000);
  pinMode(Sensor,INPUT);
    }
void loop() {
  Serial.println(analogRead(Sensor));// RUN TIME??
}


texts:
I'm using Energia to program TI's CC3200 MCU. Since Energia is based off the Arduino IDE, I'm hoping someone can help me here.

I'm trying to get the CC3200 to act as a Webserver which when successfully starts up serves up a page with two fields for the username and password that the user needs to fill. Now I'm able to see that the two fields are being successfully POST'd (through Serial.write but only when the code to get it into buffer is not present) but I was hoping someone can help me get this content into a character array (called buffer declared before the setup loop begins).

The code in the section //Here is where the POST data is does not seem to be working as I see garbage values in buffer and in the Serial.write. How do I get these POST values into buffer OR even better how do I split the two field values and store them into two separate character arrays?

void loop()
{
  // listen for incoming clients
  WiFiClient client = server.available();

  if (client) {
    //Serial.println("Client connected");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;

    while (client.connected()) {
      while(client.available()) {
        char c = client.read();
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {

            // Here is where the POST data is.
            Serial.println("Post data: ");
            int ctr = 0;
            while(client.available())
            {
            Serial.write(client.read());
            buffer[ctr] = client.read();
            ctr++;
        }
        Serial.println("Buffer: ");
        Serial.write(buffer);
        Serial.println();

        //Serial.println("Sending response");
        // send a standard http response header
        client.println("HTTP/1.0 200 OK");
        client.println("Content-Type: text/html");
        client.println("Connection: keep-alive");
        client.println();

        //form added to send data from browser and view received data in serial monitor
        client.println();
        client.println("<!DOCTYPE html>");
        client.println("");
        client.println("");
        client.println(" <FORM action=\"\" method=\"POST\">");
        client.println("
");
        client.println("    Username:");
        client.println("    <INPUT type=\"text\" name=\"uname\">

");
        client.println("    Password:");
        client.println("    <INPUT type=\"text\" name=\"pwd\">

");
        client.println("    <INPUT type=\"submit\" value=\"Submit\">");
        client.println("
");
        client.println(" </FORM>");
        client.println("");
        client.println("");

        client.println();

        client.stop();
        }
        else if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    //Serial.println("Disconnected");
    Serial.println();
  }
}


texts:
I have an Arduino project that needs to receive data from ThingSpeak. This is the data that I'm supposed to get.

When the data is "true" it must turn the LED on. I tried this code in hope of getting "true".

void loop() {
  Serial.println();
  Serial.println("Receiving Trigger Data...");
  if (client.connect(server, 80)) {
    Serial.println("Connected to server");
    client.println("GET /channels/344468/fields/3/last?key=XXXXXXX HTTP/1.1");
    client.println("Host: api.thingspeak.com");
    client.println("Connection: close");
    client.println();
}
while (client.available()) {
  reply = client.read();
  content.concat(reply);
}
delay(3000);
Serial.println(content);
if(content.indexOf("Content-Length: 4") > 0) {
  digitalWrite(ledPin, HIGH);
}

The Serial Monitor gives this reply. I don't see the word "true" being returned at all and I don't also see the content length. I tried putting delays but still I don't receive the "true" or even just the content length. Please help.


texts: What is the maximum power consumption of the Arduino Nano 3.0?

texts:
What is the maximum power consumption (in mW) of the Arduino Nano 3.0, when it is running in its default state (at 16MHz, no LEDs removed) and powered by an external regulated 5V supply so it bypasses the built in voltage regulator?

This will give us an upper bound on the power consumption of the Arduino Nano that can be used during estimates.


texts: Coding force sensitive resistor to give output based on time used?

texts:
I have a basic set up of having a force sensitive resistor being used to power an LED as can be seen below. I am wondering how I can code it so that the LED is lit after a pressure has been applied to the FSR for a specified amount of time. Leading on from that I would like to use an RBG LED and have it so that after specified intervals on continuous pressure the LED changes colour.
Any advice would be greatly appreciated.

//Constants:
const int ledPin = 3;     //pin 3 has PWM funtion
const int sensorPin = A0; //pin A0 to read analog input

//Variables:
int value; //save analog value

void setup(){

  pinMode(ledPin, OUTPUT);  //Set pin 3 as 'output'
  Serial.begin(9600);       //Begin serial communication

}

void loop(){

  value = analogRead(sensorPin);       //Read and save analog value from potentiometer
  Serial.println(value);               //Print value
  value = map(value, 0, 1023, 0, 255); //Map value 0-1023 to 0-255 (PWM)
  analogWrite(ledPin, value);          //Send PWM value to led
  delay(100);                          //Small delay

}


texts:
I need help. I am making motion detector that calls you when sensor activates
and i have done the code for that, but the thing is i am beginner and i need to make it when it first time boots i send a message with the number that will be called when sensor activates

`

int LED1 = 12;
int GND1 = 13;
int LED2 = 8;
int GND2 = 9;
int pirOutput = 5;
void setup()
{
  Serial.begin(9600);
  pinMode(LED1, OUTPUT);
  pinMode(GND1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(GND2, OUTPUT);
  pinMode(pirOutput, INPUT);

  digitalWrite(pirOutput, LOW);
  digitalWrite(GND1, LOW);
  digitalWrite(GND2, LOW);
  digitalWrite(LED1, LOW);
  digitalWrite(LED2, LOW);
  delay(15000);
  digitalWrite(LED1, HIGH);

}
void loop()
{
  if (digitalRead(pirOutput) == HIGH)
  {
    digitalWrite(LED2, HIGH);
    Serial.println("OK");
    delay(1000);
    Serial.println("ATD+381xxxxxxxx;");
    delay(15000);
    Serial.println("ATH");
    digitalWrite(LED2, LOW);
    delay(1000);
  }
}

that is the code i found and it works fine for me


texts: How to connect a 2 cell LiPo batter to Arduino Motor Shield?

texts: I am trying to connect a 2 cell 7.4 volt LiPo battery into my motor shield. I am a beginner at robotics so I am not sure if I just connect the battery, via a connector of some sort, into the motor shield itself or do I use some 22 AWG wire and connect it via that way. Sorry if that sounds confusing.


texts: Why is I2C OLED failing to initialise when SPI device is added to project (SD.h causing issue)?

texts:
My project uses an RTC, GY-521 MPU-6050 3-Axis Gyro and MakerHawk OLED Display Module. All working fine together to show current date and time as well as displaying Acceleration on 3 Axis.

I now want to log this data but find that the OLED fails to initialise when
SD.h is included.

"SSD1306 allocation failed" you can see this in the code below.

The SD card works fine, but the screen stays frozen. I tried taking out the 'loop forever' and find the clock and Gyro still function OK ( in the serial monitor).

Seems that the change is only affecting the OLED then. Where should I start?

Link to OLED is here https://www.amazon.co.uk/gp/product/B0777HHQDT/ref=ppx_yo_dt_b_asin_title_o09_s00?ie=UTF8&psc=1

The OLED can be configured for both SPI and I2C but I think that involves moving a soldered jumper.

Link to my code is here...

https://drive.google.com/open?id=1ON2Eq3nC6Em6IszqplhA_MmHjQ6PDBdn


texts: I have a simple GET webform that takes in text. Once that text is submitted the URL permanently displays the text as the parameter. This causes echoing issues when I check the input from the web form; the string I am looking for is always found because the URL is never cleared. I cannot use an HTTP redirect and am looking for a way to do this based upon code.


texts: My nodemcu esp8266 is heating a lot and the on board LED of gpio16 is On continuously. What's the Reason of heating?

texts:
How it happened
Recently I was working on a device with Blynk application in which my device will burn crackers using Blynk. I wanted to create a safe environment for burning crackers. There was a dilemma to power Nodemcu with a battery first I used a 38650 lion battery but it didn't provide sufficient power to Nodemcu. Than I connected two 38650 battery in series than it was working fine for half a minute. But later it started became hot but than I removed the power supply immediately and powered it with 3.3v charger than also it was heating and still.
My research
I researched a lot and also changed the S4 didode with IN4007 but it is still heating and malfunctioning. I checked all the parts but they were not shorted. What's the problem with my Nodemcu why is it heating and not working properly.
With regards
Naman


texts:
I simply cannot figure this out, why is this failing after 3 iterations? Other than that, what better way is there to do this? Thanks!

#define rotary_encoder_topic  "/rotary/encoder"
#define remote_button_topic  "/remote/button"
#define remote_2x_toggle_topic  "/remote/2xtoggle"
#define rotary_button_topic  "/rotary/button";
char* devices[] = { "ledrpi", "lamprpi", "mediaroom" };
int currentDevice = 0;

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

void incrementCurrentDevice() {
  currentDevice++;
  if (currentDevice >= sizeof(devices)) {
    currentDevice = 0;
  }
 Serial.println(concatenateChars("Switched device to: ", devices[currentDevice]));
}

char* concatenateChars(const char* one, const char* two) {
  char result[150] = "";
  strcat(result, one);
  strcat(result, two);
  return result;
}

void loop() {
  Serial.println(concatenateChars(devices[currentDevice], remote_2x_toggle_topic));
  incrementCurrentDevice();
  delay(1000);
}