texts: serial communication dead slow after a while

texts:
I'm workin on a node for blender to control an arduino. I notice it goes really slow after a while so I isolated the problem.
It is good in maintaining 60 frames a second, then after around 40 seconds (pretty exact), it drops to a pretty exact 1 fps for some reason.

What could be going on?

import serial
import time

ser = serial.Serial('COM3', 115200)

c = 0

while True:
    c+=1
    print("ok ", c)
    numIn = "100n"
    ser.write(numIn.encode('ascii'))
    time.sleep(1./60)

arduino code:

// special thx to  Nick Gammon

const unsigned int MAX_INPUT = 50;

unsigned long delay_time = 300;
unsigned long last_toggle_time = 0;
int current_state = LOW;

void setup () {
  Serial.begin (115200);
  pinMode(12, OUTPUT);

}

void process_data (const char * data) {
  Serial.println (data);
  delay_time = atoi(data);
}

void processIncomingByte (const byte inByte) {
  static char input_line [MAX_INPUT];
  static unsigned int input_pos = 0;

  switch (inByte) {

    case 'n':   // end of text
      input_line [input_pos] = 0;  // terminating null byte
      process_data (input_line);
      input_pos = 0;
      break;

    case 'r':
      break;

    default:
      if (input_pos < (MAX_INPUT - 1))
        input_line [input_pos++] = inByte;
      break;

  }
}

void loop() {

  while (Serial.available () > 0) {
    processIncomingByte (Serial.read ());
  }

  unsigned long m  = millis();

  if (m > last_toggle_time + delay_time) {
      current_state = current_state == HIGH ? LOW : HIGH;
      digitalWrite(12, current_state);
      last_toggle_time = m;
  }

}


texts: Running script file/programe on Intel Galileo gen2

texts:
How do I run a script file/programs like C / python / shell script in an Arduino IDE like how We use System();

Commands like grep, cut, cat works fine but running System("python file.py"); doesn't.

Board: Intel Galileo Gen 2
OS: Linux devkit image
IDE: Arduino IDE


texts: Arduino Fio: Battery/Solar Powered Weather Station

texts:
I am trying to make a Solar Powered Weather Station. I'm using the Arduino Fio, with a BMP180 and a DHT22 as the sensors. There are sleep modes activated with the Fio and the Xbee. It seems like the battery capacity requirements, after measuring, around about 664 mAh per day.

The Fio has a built in LiPo charger (MCP73831/2). Is this 3.7V 2000mAh battery safe to plug into the Fio as its battery source? Here is the datasheet from the link just provided. I'm not an engineer and I want to make sure that this is a safe device.

Once determining the correct battery, I will like to pair it with a solar panel.

Thanks for the help


texts: Arduino Uno 3.3V pin to GND short how to fix

texts: Hi I am new to the Arduino world. I was playing around with my Arduino UNO making LEDs go on and off in a sequence. Then I connected a motor to the N.0 pins but found it doesn't work so I plugged it doesn't work so I plugged it in 3.3V pin and it worked. I tried to reverse the connections but the one cable slipped and it connected to the metal shielding of the motor now it is not working when plugging it in USB it. Power LED just flashes red and turns off emediatly. Reset button doesn't seem to do annything. Is there a possible fix for this.


texts: Sampling stereo audio at greater than 40 Hertz using arduino

texts:
I am working on a project to make a speaker with reactive lighting. I need to be able to sample stereo audio at a decent rate for songs. The audioRead () function can do about 8 kHz and I have heard you can push it up till 35 kHz but than you can only use it for mono and you cannot use the arduino for anything else.

Someone recommended that I use an ADC. What can it do for me?
Is the arduino's operating speed a limitation?
If not the arduino which other micro-controller is suitable for this purpose.


texts: Powering arduino uno from Car's reverse light?

texts: I am making a reverse sensing alarm system. I am using a HC-SR04, arduino UNo and a piezo buzzer. The programming was a success however i will like this circuit to be powered when the reverse gear is shifted into place. So I am thinking to power the V in of the UNO with the 10V from the  reverse bulb socket receives. However I think the amperage sent to this bulb is too much for my UNO. What should I do ? and Does anyone have any other recommendations to power the UNO in such a scenario?


texts:
I am trying to find a "vanilla" way of writing several arrays into one. I spent a lot of time searching for how to do this but everything that comes up is either a tutorial that doesn't cover concatenation or someones question that ended up being an unrelated syntax problem.

I put several strands of WS2812B LEDs wired in series so the Arduino sees them as one continuous strand. I have been able to run some very cool patterns as one strand using the Pololu library but I would like to program the strands separately. The number of lights I have is very resource intensive and I like to keep things simple so I'm looking for advice on the best way to go about combining arrays without importing more libraries.

Because the patterns I have used so far write to an array and the output is an array, my first thought was that I could write one pattern to an array made up of sections 1, 4, and 5, and another pattern that would be mapped to sections 2, 3, and 6 and then concatenate it all together in order. However, adding arrays seems to be somewhat complicated without worrying about this or that persons favorite library or looping through one value at a time and I am trying to work on my C skills. Is there a simple way to concatenate arrays or a better way for me to think about this? Any best practice or organizational advice is welcome. I want to write clean code.

Bonus Round: I use several different languages at work and I cant figure out why I have it in my head that this would work...

array1 = [a, b, c]
array2 = [x, y]
array3 = array1 + array2

// array3 = [a, b, c, x, y]

Any idea if that is possible or what language I am thinking of?


texts: For Arduino Uno it is possible to use the digital pins with PWM to read analog data, is this also possible with the Wemos D1 Mini?

texts: I want to read out data from a load cell, for this I seem to need 2 analog input pins, the Wemos doesn't have this. In the Arduino I was also able to use the digital pint with PWM, there are also Wemos pins who have that. Is it possible to use them to read the data from the load cell?


texts: Why is delay(1000) breaking my serial communication?

texts:
I have the following sketch...

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
}

void loop() {
  if(Serial.available() > 0){
    Serial.println("Hello world from Ardunio!");
  }
}

This works great with my client code...

import SerialPort from 'serialport';
const port = new SerialPort('/dev/ttyACM0', {
  baudRate: 115200,
  autoOpen: false
})

port.open(function (err) {
  if (err) {
    return console.log('Error opening port: ', err.message)
  }

  // Because there's no callback to write, write errors will be emitted on the port:
  console.log("port opened");
  port.on('readable', function () {
    console.log('Data:', port.read())
  })
})

Now I want to slow it down so I change the sketch to...

void loop() {
  if(Serial.available() > 0){
    Serial.println("Hello world from Ardunio!");
  }
  delay(10000);
}

I would expect this to delay each message by 10 seconds, however, it seems to never rerun so I do not get any messages. What am I missing? Why would delay break the loop?


texts: Using TFT with hardware SPI and speaker with tone()

texts: I want to make a device with a TFT screen and a speaker that uses the builtin tone() function. However, according to the documentation, using tone() interferes with PWM on pins 3 and 11. On the Arduino Uno, the MOSI pin is default on pin 11, and it seems like defining another pin for MOSI disables hardware SPI, which, according to the module page, slows down the device. As well, the examples are written for hardware SPI and the SD card is only available with hardware SPI. What should I do here? Is there a way to redefine the default MOSI pin without disabling hardware SPI?


texts:
So I purchased a 4 channel Relay which handles AC250V 10A ; DC30V 10A.
But am I able to connect this to replace a light switch so I can automate it?  My bedroom runs on 15 amps.

http://amazon.com/gp/product/B00VHVIBAM?psc=1&redirect=true&ref_=oh_aui_detailpage_o00_s00


texts:
I am trying to program an ESP8266-01 WiFi module using an Arduino Uno as a USB to TTL programmer.
I have removed the ATmega and grounded the RESET pin (quite useless without the uC though).
Then, using esptool.py I tried to upload a Bare minimum sketch with the Arduino IDE and later using the following:

python esptool.py -b 57600 -p /dev/cu.usbport write_flash 0x000000 "nodemcu.bin"

However, both ways give me the same output:

A fatal error occurred: Failed to connect to ESP8266: Invalid head of packet ('\x08')

I have tried sending AT commands to the ESP01 like "AT" or "AT+GMR" and everything works fine, but I cannot upload any sketch because of that error.

I also followed esp8266 official forum advice to edit the Python script according to the following, but without success.

Line 43 ESP RAM BLOCK = 0x1800 //change this to 180
Line 44 ESP RAM BLOCK = 0x400 //change this to 40

The level conversion from 5v TTL to 3.3v is done through simple resistor node (2k and 1k), while RST is kept at Vcc through 10k pull-up resistor and a push button to ground it.


texts: Arduino connected keypad printing wrong numbers

texts:
Going crazy here trying to connect a keypad to my Arduino. I followed this article KeypadTutorial, but my guess is something is wrong/different because my keypad only has 9 pins and the far left (pin 1) and far right (pin 9) pins have no traces back to the keypad. I bought it years ago and just got around to finding a use for it. It looks just like this one Arduino Keypad but different with white keys with black font.

The issue is the wrong key shows up (i.e. press 0 and get 9). I used a multi-meter to test for continuity between pins when pressing each key and got results that are kind of stumping me. I would think there would be some kind of pattern (like the first pin would always be a 1, 2, or a 3), but obviously not (or I just have a bad keypad).

KEY(pin1, pin2)
1(2,3)
2(1,2)
3(2,5)
4(3,7)
5(1,7)
6(5,7)
8(1,6)
9(5,6)
0(1,4)
#(4,5)
*(3,4)


texts:
I wrote a generic avr program wrapper which already use the watchdog timer to restart - and after the watchdog reset - recover the the bad situation.

After this recover process i have to restart the avr. Everything i've found in topic "software reset arduino" is about to set the shortest watchdog (15ms) timeout, then spins the CPU (for(;;);) until it cause watchdog reset.

But this results to enter the recovery process which is already done in this point.

It is any elegant way to achieve this?

Some non or less elegant way:

I can bind a digital pin to the reset and pull up with a resistor.
I can write to a fixed address in the flash or eeprom (but this maybe happens frequently) before soft restart, to prevent entering to recovery mode.

Is there any register that "survives" soft resets?

Edit:

I add mock example code to hint what i trying to do.

In the actual code, in the recovering the microcontroller connect to the serial bus, waits for commands then resets itselft in oder to return to application mode.

/*************************** Application wrapper ******************************/

//define call_application and call_recover as weak empty functions
//so they can be rewritten.

bool isWatchdogReset()
{
    return MCUSR == 8;
}

void softwareReset()
{
    //  wdt_enable(WDTO_15MS);for(;;);// (this way enters recovery mode)
    //or
    //  asm ("jmp 0x0");// (this way function registers not being resetted)
}

bool isSoftwareReset()
{
    //???
}

int main()
{
    bool needRecover = isWatchdogReset() && !isSoftwareReset();
    MCUSR = 0;
    init_board();
    wdt_enable(WDTO_1S);
    while(1)
    {
        if(!needRecover)
        {
            call_application();
        }
        else
        {
            call_recover();
        }
        wdt_reset();
    }
}

/********************************* Application ********************************/

void call_application()
{
    if(randomTrue())
    {
        //stuck more that 1 secounds, that results WDT reset
    }
    else
    {
        //proper operation
    }
}

/********************************** Recover ***********************************/

void call_recover()
{
    //initialize UART, attach interrupts, Write flash and EEPROM, modify
    //function registers.

    //recovering completed, returning to the original application as like
    //nothing's happened.
    softwareReset();
}

Edit:
I try explain short to spot the point:

1) I already use the watchdog timer to detect when the application code is flawed.

2) soft reset is an inproper solution, because it doesn't reset the registers. So onyl the program will be resetted, the state of the microcontroller doesn't.

3) To commit a proper reset, the solution is to timeout the watchdog timer. But see point 1), it is already used, so how can you make the difference of a requested reset and a flawed code recovery reset?


texts: (Neopixels) How to keep the pixels of the same colour despite increasing brightness?

texts:
I've been doing a fade function for the NeoPixels. However, the moment I have maximum brightness for the pixels, I noticed there 2 colours even though in my function I have only specified one colour.

Some strips are one colour and the others are another colour. I
specified the colour to be blue for the strips however many strips are blue and the strips nearer the end are green (but closer to a blue-green colour).

Is there any way to keep the colour even when the brightness changes? I've read somewhere online a different colour is seen with different brightness levels i.e. setPixelColor(brightness, r,g,b).

I've also tried FastLED library and followed documentation. However, the lights are not doing what it has said in the codes, I've tried leds[i].fadeLightBy(200) and it has given me no result.

My code for the fade function (edited from http://moving-rainbow.readthedocs.io/en/latest/guide/fade-in-and-out/):

void fade(uint32_t color) {
  for (int i = 0; i < 255; i++) {
    for (int q = 0; q < strip.numPixels(); q++) {
      strip.setPixelColor(q, Wheel((color) & 255));
    }
    strip.setBrightness(i);
    strip.show();
  }

  //decreasing brightness
  for (int l = 255; l > 255; l--) {
    for (int p = 0; p < strip.numPixels(); p++) {
      strip.setPixelColor(p, Wheel((color) & 255));
    }
    strip.setBrightness(l);
    strip.show();
  }
}

The method "Wheel" is from the Arduino Neopixel strandtest example.

uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if (WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if (WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

Any advice on how I should go about doing it?


texts: Arduino Uno unable to detect usb port on Mac OS Sierra 10.12.5

texts:
Few weeks ago my Arduino Uno (IDE version 1.8.2) detected the USB port and I was able to do some small IOT projects. I updated my OS to Sierra 10.12.5 and now suddenly the usb serial option has disappeared.

I followed this link : https://learn.sparkfun.com/tutorials/how-to-install-ftdi-drivers/mac  where it tells us to download and install the FTDI drivers separately. I tried that but it did not help.

Then I came across this post: https://forum.arduino.cc/index.php?topic=427825.0 where the user is having this same problem with MacOS Sierra. He suggested we remove the FTDI drivers and rely on Apple's drivers. So I removed the FTDI drivers from my Mac so it will use Apple's drivers.

Now even after doing all this when I connect my Arduino Uno to my Mac via the USB it does not get detected.

I removed the kext and pkg files for the FTDI drivers and deleted them completely, still when I open the System Report I still see the FTDI USB Serial Driver entry.

When I go to System Report > Hardware > USB I see this:

What is happening? Did the FTDI drivers got removed? If they did then why wont the serial usb port get detected on Arduino? If they are not removed completely then what did I miss?


texts:
I'm reading a RFID Card from RC522 and send the data to my computer. My problem is the conversion of byte[] to String or std::string.

#define SIZE_BUFFER     18
#define MAX_SIZE_BLOCK  16

byte buffer[SIZE_BUFFER] = {0};
byte tam = SIZE_BUFFER;

// get data
status = mfrc522.MIFARE_Read(bloco, buffer, &tam);

  Serial.print(F("\nDados bloco ["));
  Serial.print(F("]: "));

// printing...
 for (uint8_t i = 0; i < MAX_SIZE_BLOCK; i++)
  {
      Serial.write(buffer[i]);
      str += String(buffer[i]);
  }

OUTPUT:

Dados bloco []: asdas

So, it's ok! But if I try make a string:

  String str = "";

  for (uint8_t i = 0; i < MAX_SIZE_BLOCK; i++)
  {
      str += String(buffer[i]);
  }
  Serial.println(" ");
  Serial.println(str);

The output is:

97115100971153232323232323232323232

What is the correct way to create a String from byte[]?


texts: Common/standard library and/or protocol for Arduino to be I2C slave for driving NeoPixel

texts:
I would like to control a string of WS2812/NeoPixels from a SBC like a BeagleBone or C.H.I.P. I realize someone has gone through the trouble to come up with a way to drive the WS2812 string from a BeagleBone directly with the PMU, but I would like to have an Arduino like a Pro Mini do the signal generation, while the SBC would direct the Arduino what to display.

I found the node-pixel setup with I2C backpack on the arduino, but it requires on the SBC side NodeJS, Johnny-Five and other libraries that I would have no other use for. It seems overkill.

Is there some commonly used protocol over I2C for controlling NeoPixels (with the arduino being the I2C slave), or will I be better off developing my own simple protocol?

On the SBC side, I would likely be coding either in C/C++ or Python.


texts: Combining code for two sensors in one programming

texts:
We need to read two readings of Humidity and Temperature from 2 different locations. We can run each of them separately but we don't know how we can make them work simultaneously in one program. We are using a TH02 sensor that we connect to I2C and DHT11 that is connected to one of the Analog port.

We are connecting them to Grove base shield V2, which is on top of Arduino uno wifi.

TH02 Code:

 void setup()
{
Serial.begin(9600);        // start serial for output

Serial.println("****TH02_dev demo by seeed studio****\n");
/* Power up,delay 150ms,until voltage is stable */
delay(150);
/* Reset HP20x_dev */
TH02.begin();
delay(100);

/* Determine TH02_dev is available or not */
Serial.println("TH02_dev is available.\n");
}

void loop()
{
float temper = TH02.ReadTemperature();
Serial.println("Temperature: ");
Serial.print(temper);
Serial.println("C\r\n");

float humidity = TH02.ReadHumidity();
Serial.println("Humidity: ");
Serial.print(humidity);
Serial.println("%\r\n");
delay(1000);
}

DHT11 Code:

byte read_dht11_dat()
{
byte i = 0;
byte result=0;
for(i=0; i< 8; i++){

    while(!(PINC & _BV(DHT11_PIN)));  // wait for 50us
    delayMicroseconds(30);

    if(PINC & _BV(DHT11_PIN))
    result |=(1<<(7-i));
    while((PINC & _BV(DHT11_PIN)));  // wait '1' finish
}
return result;
}

void setup()
{
DDRC |= _BV(DHT11_PIN);
PORTC |= _BV(DHT11_PIN);

Serial.begin(9600);
Serial.println("Ready");
}

void loop()
{
byte dht11_dat[5];
byte dht11_in;
byte i;
// start condition
// 1. pull-down i/o pin from 18ms
PORTC &= ~_BV(DHT11_PIN);
delay(18);
PORTC |= _BV(DHT11_PIN);
delayMicroseconds(40);

DDRC &= ~_BV(DHT11_PIN);
delayMicroseconds(40);

dht11_in = PINC & _BV(DHT11_PIN);

if(dht11_in){
    Serial.println("dht11 start condition 1 not met");
    return;
}
delayMicroseconds(80);

dht11_in = PINC & _BV(DHT11_PIN);

if(!dht11_in){
    Serial.println("dht11 start condition 2 not met");
    return;
}
delayMicroseconds(80);
// now ready for data reception
for (i=0; i<5; i++)
dht11_dat[i] = read_dht11_dat();

DDRC |= _BV(DHT11_PIN);
PORTC |= _BV(DHT11_PIN);

byte dht11_check_sum = dht11_dat[0]+dht11_dat[1]+dht11_dat[2]+dht11_dat[3];
// check check_sum
if(dht11_dat[4]!= dht11_check_sum)
{
    Serial.println("DHT11 checksum error");
}

Serial.print("Current humdity = ");
Serial.print(dht11_dat[0], DEC);
Serial.print(".");
Serial.print(dht11_dat[1], DEC);
Serial.print("%  ");
Serial.print("temperature = ");
Serial.print(dht11_dat[2], DEC);
Serial.print(".");
Serial.print(dht11_dat[3], DEC);
Serial.println("C  ");

delay(2000);
}


texts:
I have this schematic for a DC motor in my arduino, now I want to add 9v battery.

But I've seen that people use TIP120 transistor, I have BC548B,
can I just put the 9v with that transistor?


texts: How to choose alternate I2C pins on ESP32?

texts:
I'm a begginer with Arduino and this may be a basic question but I'm facing an issue.

I'm using a HTU21D sensor with an ESP32. This sensor use I2C communication. Inside the Arduino library, there is this function to start to collect data:

//Start I2C communication
void HTU21D::begin(TwoWire &wirePort)
{
  _i2cPort = &wirePort; //Grab which port the user wants us to use

  _i2cPort->begin();
}

As you can see, we can set in this function which port we want to use. Perfect. But my probleme is that I don't know how to use the type TwoWire. I checked some documentation but I was still unable to find a solution. I want to use GPIO_16 as SDA and GPIO_17 as SCL.
So I tried something like that without result: htu21d.begin(Wire(16, 17));

How to set SDA and SCL pin in TwoWire type ? (in my case GPIO_16 and GPIO_17)


texts: Sending AT commands to Reyax RYLR890 LoRa modules via additional serial port not working

texts:
I am setting up a LoRa module (transmitter) with nodemcu (ESP8266). The module (Reyax RYLR896) accepts AT commands over serial interface. I created an additional serial port using pins D7 and D8 on the nodemcu using SoftwareSerial.h in Arduino IDE to try and set up the transmitter following this example.
I coded up the sketch below to read an AT command from native serial interface, pass it on to the LoRa module via the additional serial port, read the response and print it in serial monitor. The LoRa module should respond with "+OK" to an AT command like "AT" or with data for a command like "AT+ADDRESS". However, I get no response. So far, I have tried:

Experimenting with different baud rates (9600 and 115200)
Hard-coding AT command(s)
Using read/write and readString/print.

The string sent via serial monitor is read correctly but the second if block is never entered.
#include <SoftwareSerial.h>

#define Rx D7
#define Tx D8

SoftwareSerial LoRaSerial(Rx, Tx);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  while (!Serial) {
    ; // Wait until native serial interface is ready.
  }
  Serial.println("Native serial interface ready!");

  LoRaSerial.begin(9600); // Also tried 115200
  LoRaSerial.println("LoRa serial interface ready!");
}

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial.available()) {
    String serial_command = Serial.readString();
    Serial.print(serial_command);
    LoRaSerial.print("AT\r\n"); // hard-coded to test
  }
  delay(200);
  if (LoRaSerial.available()) {
    String LoRa_response = LoRaSerial.readString();
    Serial.print("Done!");
    Serial.print(LoRa_response);
  }
}

The module is brand new and I have tried with two different ones. Any help is appreciated!
Connections are as follows:
Node
mcu <> RYLR896

GND <> GND
D7 (Rx) <> TX
D8 (Tx) <> RX
3V3 <> VDD

The RST on RYLR896 is not wired.


texts: Arduino Mega + ESP8266 - Post Data to website issue

texts:
I'm trying to post data to my SQL database and it seems that I'm not sending the data correctly. My PHP file is working since I have tried it and it writes to the database.

I am getting an esp.find("SEND OK") but I must be sending it wrong or something.

Here is the code:
DT 0050 - GLASSES - from sun to sound - chk oil filter malibu old or new?

void loop() {
    // call sensors.requestTemperatures() to issue a global temperature
    // request to all devices on the bus
    Serial.print(" Requesting temperatures...");
    sensors.requestTemperatures();  // Send the command to get temperatures
    char tempC = sensors.getTempCByIndex(0);
    char buffer[10];
    Serial.println("DONE");
    Serial.print("Temperature for Device 1 is: ");
    // You can have more than one IC on the same bus.
    // 0 refers to the first IC on the wire
    Serial.print(sensors.getTempCByIndex(0));   // "byIndex"
    delay(5000);
    data = "temperature=" + tempC;  // d
    httppost();
    delay(1000);
}

void httppost() {
    esp.println("AT+CIPSTART=\"TCP\",\"" + server + "\",80");   //start a TCP connection.
    if (esp.find("OK")) {
       Serial.println("\r\nTCP connection ready");
    }
    delay(1000);
    String postRequest =
        "POST /http://manilla.technoaid.net/esp8266.php HTTP/1.1\r\n"
        "Host: 66.96.134.25\r\n" "User-Agent: Arduino/1.0\r\n"
        "Connection: close\r\n"
        "Content-Type: application/x-www-form-urlencoded\r\n"
        "Content-Length: \r\n" "data";
    **String sendCmd = "AT+CIPSEND=";
    esp.print(sendCmd);
    esp.println(postRequest.length());
    delay(1000);
    if (esp.find(">")) {
        Serial.println("Sending..");
        esp.print(postRequest);
        if (esp.find("SEND OK")) {
            Serial.println("Packet sent");
            while (esp.available()) {
                String tmpResp = esp.readString();
                Serial.println(tmpResp);
            }
            // close the connection
            esp.println("AT+CIPCLOSE");
        }
    }
}


texts: Arduino board as USB/serial for a Nano with broken USB

texts:
I broke the USB connector on an Arduino Nano and I am trying to use my Uno board as a USB/serial adapter to be able to upload sketches. The broken Nano came with a customized bootloader (avrdude -c arduino compatible), which I do not have a copy of. The content in the HEX files I have is encrypted, it has to go through the bootloader for the plain code to be flashed. This rules out ISP.

I came up with this:

Please note that the ATMega on the Uno board is removed. As I am proxying the Nano through the Uno board, I am wiring RX to RX and TX to TX.

The problem I face is that it seems the Nano board is not receiving data from the PC. Everything else works:

pressing the reset button on either board resets the Nano
TX from the Nano goes back to the PC (the current sketch on the Nano prints some stuff on boot), TX leds blink accordingly on Nano and Uno boards
RX led on the Uno board blinks when PC sends something, but RX led on the Nano board does not blink in that case
connecting the RX/TX Nano pins to a USB/serial cable lets me send and receive data to/from the sketch

I tried with another, non-broken, Nano (standard bootloader) and I have the same issue, so I think the broken Nano is fine. If I upload a sketch that continuously writes to the serial port, the PC receives it. If I upload an "echo" sketch, I do not get anything back (the "echo" works well over direct USB connection).

I am a software guy, my apologies if I am doing something obviously wrong. I read several pages on the topic, I couldn't spot a fix. The boards are not official Arduino products, but I am not sure this is relevant. I wonder if part of the answer is related to the fact that the USB/serial conversion is handled by a Mega16U2 chip rather than something like a CH340, now useless on the broken Nano.

Some links that I checked:

Arduino UNO as USB to serial TTL converter
Arduino Uno as an FTDI RS232 to Serial Adapter
Using an Arduino or Seeeduino for its FTDI chip
Use an Arduino UNO as a USB-to-Serial converter


texts: Controlling voltage and current from chip?

texts:
I'm well aware that this question perfectly showcases my spectacular ignorance, but oh well. It's a simple enough question, so here we go.
I have a 595 chip (SN74HC595) wired up to an Arduino, fed by the 5V output. After switching all the outputs on, I measured an output pin at 5.04V and 74mA.
I want to use the chip's outputs to switch transistors (P2N2222A) which will have 60 mA through them (switching common cathode RGB LEDs), so I believe I need to drop it down to around .6 to 1.2V at .6mA, right (I'm not at all sure I'm reading the datasheet right)?
So how exactly do I do that? It seems like I need to put a resistor in between the pin and the base, but don't I need to know the TOTAL resistance of the circuit? Or can I just calculate from the pin itself (I believe that would need 7K)?
Thanks in advance for your help, and please feel free to OVER-explain if you're so inclined.
EDIT:
EDIT 2: Resistor values are listed wrong. R1=200, R2 & R3 = 100.


texts:
I have a Pro Micro board and I try to make it list my files as in the example of the Arduino IDE.
The pins I use are the following:

board    micro sd module
   D4  ---> CS
   D15 ---> SCK
   D14 ---> MISO
   D16 ---> MOSI
   GND ---> GND
   VCC ---> VCC

On the serial monitor I get "initiallization failed".

What is wrong with my setup?

This is the code running:

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

File root;

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

  Serial.print("Initializing SD card...");

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    while (1);
  }
  Serial.println("initialization done.");

  root = SD.open("/");

  printDirectory(root, 0);

  Serial.println("done!");
}

void loop() {
  // nothing happens after setup finishes.
}

void printDirectory(File dir, int numTabs) {
  while (true) {

    File entry =  dir.openNextFile();
    if (! entry) {
      // no more files
      break;
    }
    for (uint8_t i = 0; i < numTabs; i++) {
      Serial.print('\t');
    }
    Serial.print(entry.name());
    if (entry.isDirectory()) {
      Serial.println("/");
      printDirectory(entry, numTabs + 1);
    } else {
      // files have sizes, directories do not
      Serial.print("\t\t");
      Serial.println(entry.size(), DEC);
    }
    entry.close();
  }
}

And this is my wiring:


texts: Does the tone() generates unwanted signal?

texts:
I was trying to use the tone function for another project but I found that it also generates an undesired frequency (not the harmonics above of square wave it generates) but a lower frq square wave. Is this normal or somethings wrong with my implementation?
the code is pretty simple:

void setup()
{
    pinMode(7,OUTPUT); //set the pin as output
    tone(7,10000); //start a 10KHz tone
    while(true); //stay here
}

void loop()
{ }

hardware was an Uno also tried different pins above but same results. first I tried a 470R and an 8R speaker. then guess maybe the inductance, or something else causing it so I used a piezo buzzer as seen below:

Pin(x)--->10KR--->piezo--->GND

however it was the same. I measured the lower frequency as 19.55Hz for a tone(10000) and 39.05Hz for tone(40000); both are pretty annoying.
what causes this and whats the workaround?


texts: Function of rxAlign parameter in the PCD_ReadRegister function in MFRC522 Library

texts:
I'm trying to port the MFRC522 Arduino library (from GitHub) to the ARM MCUs.
My problem is with the PCD_ReadRegister function:

/**
 * Reads a number of bytes from the specified register in the MFRC522 chip.
 * The interface is described in the datasheet section 8.1.2.
 */
void MFRC522::PCD_ReadRegister( byte reg,       ///< The register to read from. One of the PCD_Register enums.
                                byte count,     ///< The number of bytes to read
                                byte *values,   ///< Byte array to store the values in.
                                byte rxAlign    ///< Only bit positions rxAlign..7 in values[0] are updated.
                                ) {

    if (count == 0) {
        return;
    }
    //Serial.print(F("Reading "));  Serial.print(count); Serial.println(F(" bytes from register."));
    byte address = 0x80 | (reg & 0x7E);     // MSB == 1 is for reading. LSB is not used in address. Datasheet section 8.1.2.3.
    byte index = 0;                         // Index in values array.
    SPI.beginTransaction(SPISettings(SPI_CLOCK_DIV4, MSBFIRST, SPI_MODE0)); // Set the settings to work with SPI bus
    digitalWrite(_chipSelectPin, LOW);      // Select slave
    count--;                                // One read is performed outside of the loop
    SPI.transfer(address);                  // Tell MFRC522 which address we want to read
    while (index < count) {
        if (index == 0 && rxAlign) {        // Only update bit positions rxAlign..7 in values[0]
            // Create bit mask for bit positions rxAlign..7
            byte mask = 0;
            for (byte i = rxAlign; i <= 7; i++) {
                mask |= (1 << i);
            }
            // Read value and tell that we want to read the same address again.
            byte value = SPI.transfer(address);
            // Apply mask to both current value of values[0] and the new data in value.
            values[0] = (values[index] & ~mask) | (value & mask);
        }
        else { // Normal case
            values[index] = SPI.transfer(address);  // Read value and tell that we want to read the same address again.
        }
        index++;
    }
    values[index] = SPI.transfer(0);            // Read the final byte. Send 0 to stop reading.
    digitalWrite(_chipSelectPin, HIGH);         // Release slave again
    SPI.endTransaction(); // Stop using the SPI bus

} // End PCD_ReadRegister()

I read the datasheet several times & can't understand what's the function of this parameter!
Based on datasheet for reading a register from rc522:


texts: I recently thought of using an Arduino to measure voltage and I stumbled across the problem that what is the max voltage I can measure??? It is an Arduino Uno and I am thinking that I would also display the voltage measured on a 16 * 2 LCD screen.My guess is max of 5 volts but if this is correct how can I increase its range?


texts: Are there any online data analysis websites for arduino IoT projects?

texts: I am planning on making a system where multiple arduinos monitor the conditions of certain type of plant. (Each arduino monitors its own plant, but the plants are of the same species). Each plant would have a different placement in the yard(varies the light). The plants are watered as normal, without an exact amount of water. The arduinos would measure light, temperature, and soil water content. Each would send it to the cloud. My question is: Is their a cloud service that can analyze and "find" the best conditions(amount of water,light,temperature,etc) for type a plant, based on how healthy the plants are?(The health of the plants would be entered in manually by the person using the system). (Sorry if my question doesn't make sense, please ask me any questions you have ,Thanks.)


texts: Data packet format when USB initialized as COM port

texts:
Does anyone know how the data in data packet looks like when the USB is initialized as COM port?

I have a Arduino Mega 2560. I have initialized COM port with a baud rate of 9600. I know that there are four types of USB packets as

Token Packet (Commonly used for device identification and transaction initiation.)
Data Packet (Contains the data that needs to be transferred from host to client or vice-versa.)
Acknowledgement Packet (Acknowledgement for error-free data reception.)
Special Packets (Hub to hub communication and speed differential.)

The payload in data packet is formatted as

DATA1 >> PAYLOAD >> CRC16 ; DATA2 >> >> PAYLOAD >> CRC16 ; etc.

Till this point I am clear about whats happening.

Now all I want to know is

How the data is structured in the PAYLOAD section, when USB is initialized as COM port?
How the baud rate comes into picture i.e how a particular baudrate is achieved in this type of communication?
How is communication in terms of packet sequence? Does the sequence of packets change? (Like token>>data>>ack>>data>>ack>>...)

I really need to know this urgently as I am working on program that has to connect with 3 MEga2560 boards through a USB hub. I want to fix my design constraints depending on what is the maximum baud rate that I can achieve for all boards.


texts: Do I need 3 voltage dividers to control ESP8266

texts:
I am buying an ESP8266 and the plan is to control it serially from an Arduino. I am going to use a voltage divider(Using a voltage divider is temporary and I know the cons of using voltage dividers).

I calculated out the values of the voltage divider and I am going to use 220 ohm and 440 ohm value resistors to get 3.3 volts and 250 ma from the Arduino 5v pin so I can power vcc and ch_pd on the ESP8266.

The question is do I need to use a separate voltage divider to connect Arduino TX to ESP8266 RX and Arduino RX to ESP8266 TX. Or will it be safe to connect RX and TX directly to Arduino RX and TX.

Honestly I am extremely new to this and I don't even know if I am going at this right. If I am tell me.


texts: Trying to move servo motor via 3 buttons

texts:
I am having some difficulties in trying to make my servo motor move to a specific angle based on the button pressed.

For example, having the motor start at 0 degrees and then having it move to 180 when the 3rd button is pressed, have it return to 0 degrees when the first button is pressed, and have it go to 90 degrees when the second button is pressed, etc, etc.

I can't tell if I am going about this all wrong or not with my code, so if anyone could provide some assistance with this it would be a great help

EDIT: Added the wiring as a just in case

#include <Servo.h>

Servo myservo;
int angle = 0;
int anglestep = 10;

#define FIRST 2 // pin 2 is connected to 1st floor button
#define SECOND 3 // pin 3 is connected to 2nd floor button
#define THIRD 4 // pin 4 is connected to 3rd floor button
#define SIGNAL 10

void setup()
{
Serial.begin(9600);
myservo.attach(10);
myservo.write(angle);
pinMode(2,INPUT_PULLUP);
pinMode(3,INPUT_PULLUP);
pinMode(4,INPUT_PULLUP);
Serial.println("Lift/Descend");
}

void loop()
{
while (digitalRead(FIRST) == LOW)
    {
    if (angle > 0 && angle <= 90) //2to1
        {
        angle = angle - anglestep;
            if (angle < 0)
            {
            angle = 0;
            }
            else
            {
            myservo.write(angle);
            Serial.print("Moved to: ");
            Serial.print(angle);
            Serial.println(" degree");
            }
        }
    else if (angle > 90 && angle <= 180) //3to1
    {
        angle = angle - anglestep;
            if (angle < 0)
            {
            angle = 0;
            }
            else
            {
            myservo.write(angle);
            Serial.print("Moved to: ");
            Serial.print(angle);
            Serial.println(" degree");
            }
    }
    else //1on1
    {
        angle = 0;
    }

}
while (digitalRead(SECOND) == LOW)
    {
    if (angle > 90 && angle <= 180) //3to2
        {
        angle = angle - anglestep;
        if (angle > 90)
            {
            angle = 90;
            }
        else
        {
        myservo.write(angle);
        Serial.print("Moved to: ");
        Serial.print(angle);
        Serial.println(" degree");
        }
    }
    else if (angle > 0 && angle < 90) //1to2
        {
        angle = angle + anglestep;
        if (angle < 90)
            {
            angle = 90;
            }
        else
        {
        myservo.write(angle);
        Serial.print("Moved to: ");
        Serial.print(angle);
        Serial.println(" degree");
        }
    }
    else
    {//2on2//
    angle = 90;
    }
}

while (digitalRead(THIRD) == LOW)
{
    if (angle > 0 && angle <= 90) //1to3
    {
        angle = angle + anglestep;
        if (angle > 180)
            {
            angle = 180;
            }
        else
        {
        myservo.write(angle);
        Serial.print("Moved to: ");
        Serial.print(angle);
        Serial.println(" degree");
        }
    }
    else if (angle > 90 && angle < 180)
    {//2to3
        angle = angle + anglestep;
        if (angle > 180)
            {
            angle = 180;
            }
        else
        {
        myservo.write(angle);
        Serial.print("Moved to: ");
        Serial.print(angle);
        Serial.println(" degree");
        }
    }
    else
        {
        angle = 180;
        }
    }
}


texts: Choosing between ESP32 and Arduino Pro Mini

texts:
This is probably a fundamental question but I am hoping to get some pointers on how to chose between Arduino Pro Mini and ESP 32.

I am hoping to make a wrist based wearable like fitbit. Three primary needs are

Accelerometer or MPU module is important to collect movement data.
Wi-fi is not important because I think bluetooth would be enough to sync the data to a cell phone.
Battery management is of course more critical as I want it to last longer.
Smaller the dimensions, better for design and aesthetics.

My first choice was using Arduino  pro mini because it is smaller and less  power consuming.  However, we do need to manually connect BLE module like HC-05 to it. Now I think ESP32 could also be a good option because it has both wifi and bluetooth although I do not care about wifi.

Now I found these useful comparisons on web

Arduino and NodeMcu (ESP8266) like this
Between ESP32 vs ESP8266 like this
Between Nano or pro mini like this

However, none of them help me directly in my case. I understand ESP32 and ProMini are meant for different things and hence should not be compared for a single project. May be I am missing something more fundamental. Any guidelines in this would really help.


texts: How to implement Arduino NANO as a RS-232 to USB adapter (Or do I need a Arduino Mega?) For 3D printer comms

texts:
I have a PC upstairs running my 3D printing slicer program (Simplify 3D). In the basement, I have several USB-enable 3D printers. My PC upstairs has a USB-to-RS-232 serial adapter. The serial side of that USB-to-Serial adapter connects to the Serial port of a Moxa Nport 6150 RS232-to-Ethernet protocol adapter. I get those Moxa devices for free when they break at work and then fix them for a couple of dollars.
The other side of the Moxa connects to my home computer network router. In the basement I can plug another Moxa into an ethernet cable on my home network and the serial RS232 output I need to connect to the Micro-USB jack of the 3D printer. How can I use an Arduino Nano (or Uno or Mega if required) to convert the RS232 data to the USB input of my 3D printer?
So I have PC->(RS-232)->[MOXA(RS-232)->Moxa(Ethernet)]->Router->[Moxa(Ethernet)->Moxa(RS-232)]->[Arduino(RS-232)->Arduino(USB)]->3D Printer(USB)... How can I get the Arduino to do that function? Items within [ and ] brackets are single devices performing a protocol conversion.
I know people use Raspberry Pi's and a program called OctoPrint to remotely control their 3D printers but I get the Moxas for free and Uno's or Nanos are dirt cheap. RPi's are more expensive and for several 3D printers it can start adding up. Any ideas?


texts:
I would like to install speaker-dependent voice recognition in a robot equipped with Arduino Uno compatible boards.
Specifically, I want to record the robot's name beforehand and have it respond when I call the robot's name.
Although it is not an Arduino, there is a person who has developed a function that I would like to realize with the M5StickV.
This person used isolated_word.py, a library published by Sipeed, as a reference.
【K210】マイク搭載版M5StickV,Sipeed Maixシリーズで音声認識をする
After some research, I found Maix_Speech_Recognition in the library of Maixduino, which can use Arduino IDE.
Apparently, it uses Mel-frequency cepstrum coefficients analysis of speech input, and then uses dynamic time stretching to find the similarity.
The MFCC uses the K210 FFT on the Maixduino.
Arduino Uno does not have an FFT accelerator, but it can do FFT.
Therefore, I thought it would be possible to use Maix_Speech_Recognition for specific speaker speech recognition on ArduinoUno compatible devices.
Question

Is it possible to use Maix_Speech_Recognition for speaker-dependent voice recognition on Arduino Uno compatible boards?
What part of Maix_Speech_Recognition should I modify to make it work on Arduino Uno compatible boards?


texts:
I am trying to interface TGS 2600 gas sensor to Arduino, particularly to detect methane gas.
Can anyone tell me the conversion equation between Rs/Ro and ppm, so that I can get ppm values from the Rs/Ro ratio. I am looking to detect between 1-10ppm.


texts: How to Read ADC value without Common GND ? (Possible or not !)

texts:
I want to Read external signal with the microcontroller.

But the problem is that ADC does not work because the signal GND and the microcontroller are not Common,

My question is, have you encountered such a problem? Is there a way to do it?


texts: Most power efficient way to constantly save 2 kilobytes of data per second

texts:
I would like to constantly save data coming from sensors (for an activity tracker) while consuming as less battery as possible (I'd like to have a 4/5 days autonomy on a 3000 mAh battery) but I can't find the best way to save about 2 kBytes/s on a memory large enough to contain several days of data.

Sensors would be read at a rate of 20 times per second and produce about 100 bytes each time.

What options do I have in order to:

store such an amount of data (hardware)?
ensure the system can work properly with required autonomy?


texts: How to initialize digital output pin as low

texts:
I need to define a pin as output for relay module but when i do it in setup section, relay is activated (low - 0) automatically then i deactivated immediately with coding digitalWrite(pin, 1) but this issue results the relay is activated then deactivated within miliseconds. But I want to know that is it possible to define a pin as output but low in default.

void setup(){
  pinMode(pin,OUTPUT);
  digitalWrite(pin,1);
}

void loop(){
  if(start_relay){
    digitalWrite(pin, 0);
  }
}


texts: Not able to add JSON data to Arduino data

texts:
In my recent project, I'm working with Arduino with JSON.

I made software on JSON. Now, I want to send data from this software to my Arduino. Serial communication is done between Arduino and JSON. But somehow, I can't able to get proper data from JSON to my Arduino. So, I google out and find library named ArduinoJson. And here, I found out example code. So, I tried out that code and modified based on my requirement.

Here, below is my code.

Now, Software sends me value. And I split it out into three variable MAP_Json, TPS_Json, and LOAD_Json.
In Arduino side, I have already the value of MAP, TPS, and LOAD.

So, now my main intention is to compare MAP_Json with MAP & TPS_Json with TPS. If they are matched then LOAD_Json is added to LOAD. But, when I try it out, then LOAD_Json not added to LOAD. I don't understand why this happened?

 #include <ArduinoJson.h>

//----------------------------For MAP calculation----------------------------//
float MAP_MIN = 0.85;
float MAP_MAX = 1.90;

int LOAD_MIN_MAP[] = {1, 2};
int LOAD_MAX_MAP[] = {3, 4};

float mMAP[2] = {};
float yMAP[2] = {};

int i, j, a;
float MAP, mFinalMAP, yFinalMAP;

//----------------------------For TPS calculation----------------------------//
float TPS_MIN = 0.00;
float TPS_MAX = 5.00;

int LOAD_MIN_TPS[] = {1, 3};
int LOAD_MAX_TPS[] = {2, 4};

float mTPS[2] = {};
float yTPS[2] = {};

int k, l, b;
float TPS, mFinalTPS, yFinalTPS;

//----------------------------For LOAD calculation---------------------------//
int LOAD_MIN = 2;
int LOAD_MAX = 100;

float injTime_MIN_LOAD[] = {8.00, 9.06};
float injTime_MAX_LOAD[] = {10.60, 11.86};

float mLOAD[2] = {};
float yLOAD[2] = {};

int m, n, c;
float LOAD, mFinalLOAD, yFinalLOAD;

//------------------------------ Variable ---------------------------------//

float load;

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

void loop()
{
  //----------------------ARDUINO DATA-------------------------//

  //----------------------------MAP----------------------------//

  MAP = analogRead(A0) * (5.0 / 1023.0);

  for(a = 0; a < 2; a++)
  {
    mMAP[i] = (LOAD_MIN_MAP[a] - LOAD_MIN_MAP[a]) / (MAP_MAX - MAP_MIN);
    yMAP[j] = mMAP[i] * (MAP - MAP_MIN) + LOAD_MIN_MAP[a];
  }

  //----------------------------TPS----------------------------//

  TPS = analogRead(A1) * (5.0 / 1023.0);

  for(b = 0; b < 2; b++)
  {
    mTPS[k] = (LOAD_MAX_TPS[b] - LOAD_MIN_TPS[b]) / (TPS_MAX - TPS_MIN);
    yTPS[l] = mTPS[k] * (TPS - TPS_MIN) + LOAD_MIN_TPS[b];
  }

  //----------------TPS/MAP CALLIBRATION / LOAD----------------//

  mFinalTPS = (yMAP[1] - yMAP[0]) / (TPS_MAX - TPS_MIN);
  yFinalTPS = mFinalTPS * (TPS - TPS_MIN) + yMAP[0];

  mFinalMAP = (yTPS[1] - yTPS[0]) / (MAP_MAX - MAP_MIN);
  yFinalMAP = mFinalMAP * (MAP - MAP_MIN) + yTPS[0];

  LOAD = (yFinalTPS + yFinalMAP) / 2;

  Serial.print("T : ");
  Serial.print(TPS);
  Serial.print("\t");
  Serial.print("M : ");
  Serial.print(MAP);
  Serial.print("\t");
  Serial.print("L : ");
  Serial.print(LOAD);
  Serial.print("\t");

  while(!Serial)
  {
    // wait serial port initialization
  }

  StaticJsonBuffer<200> jsonBuffer;

  char json[] = "{\"TPS\":1.67, \"MAP\":1.83,\"LOAD\":30}"; // JSON DATA

  JsonObject& root = jsonBuffer.parseObject(json);

  // Test if parsing succeeds.
  if(!root.success())
  {
    Serial.println("parseObject() failed");
    return;
  }

  // Splitted JSON DATA

  float TPS_Json = root["TPS"];
  float MAP_Json = root["MAP"];
  float LOAD_Json = root["LOAD"];

  Serial.print("T_J : ");
  Serial.print(TPS_Json);
  Serial.print("\t");
  Serial.print("M_J : ");
  Serial.print(MAP_Json);
  Serial.print("\t");
  Serial.print("L_J : ");
  Serial.print(LOAD_Json);
  Serial.print("\t");

  //Compare JSON DATA and ARDUINO DATA

  if(TPS_Json == TPS && MAP_Json == MAP) //If matched
  {
    load = LOAD_Json + LOAD;            // Add LOAD_Json and LOAD
  }

  Serial.print("Final Load :");
  Serial.print(load);
  Serial.print("\n");
}

EDIT 1: Improve question formatting

EDIT 2: Upload Complete code


texts: Do I need to worry about voltage, coming from ground, and effecting an analog input?

texts: I am building a project that includes an analog Input and several digital Inputs and Outputs.  All of them connect to ground in some way.  Do I need to worry about voltage, coming from the digital outputs, going to ground, and effecting readings on the analog input?  If so, how do I deal with this?


texts:
I have a 200mw laser module that came with a 3v 1A power supply. I want to control it from a digital pin on an arduino uno.
Can I use a simple voltage divider like this or is there some consideration to current I'd need to take into account? The laser module was quite expensive so I'm hesitant to try it out.

simulate this circuit – Schematic created using CircuitLab


texts: How to drive a stepper motor, by having it go even steps forward and odd steps back?

texts:
I have a question about driving a stepper motor back and forward. Basically I want it to do a total of 24 steps (12 forward and 12 back) but I don't want to repeat the same steps when coming back.

So 2, 4, 6, 8, 10, 12 (step numbers) forward and 11, 9, 7, 5, 3, 1 (step numbers) backwards.

Here is the code I have at the moment and I just cannot get the motor to drive properly.

EDIT: It goes 6 times 2 steps forward, then 5 times backwards and after that it starts to just jerk around. What I want it to do is to go 6 times 2 steps forward (so step 2, step 4, step 6, step 8, step 10, 12) and then come back but fill in the odd steps (step 11, step 9, step 7, step 5, step 3, step 1 and step 0). The idea is that then it doesn't just overlap when going forwards and backwards.

#include <Stepper.h>
#include <TimerOne.h>

const int stepsPerRevolution = 200;

Stepper myStepper(stepsPerRevolution, 2, 3, 4, 5);
int backwardsCount = 0;
int stepCount = 0;

void setup() {
  Serial.begin(9600);
  Timer1.initialize(2000);
  Timer1.attachInterrupt(callback);
}

void callback(){
  if(stepCount < 12) {
    myStepper.step(2);
    stepCount += 2;
  } else if(stepCount == 12) {
    myStepper.step(-1);
    backwardsCount = 11;
    stepCount += 1;
  }
  if(backwardsCount > 1) {
    myStepper.step(-2);
    backwardsCount -= 2;
  } else if(backwardsCount == 1) {
    myStepper.step(-1);
    stepCount = 0;
    backwardsCount = 0;
  }
}

void loop() {
}


texts:
I'd always thought Arduino was a microcontroller platform but the actual microcontroller is an AVR chip made by Atmel, or something like that made by someone else, based on a RISC ISA, and Arduino is usually used to refer to the whole circuit board powered by this AVR chip. Is my understanding correct?

What's the difference/relationship between Arduino and AVR?


texts:
I'm unable to access the first led in my strip with this code:

void loop()
{
  leds[0] = CRGB::White; FastLED.show(); delay(100);
  leds[0] = CRGB::Black; FastLED.show(); delay(100);
}

Instead, it blinks 3 leds, though I expect it to blink only the first one.

Here's how my setup code looks like:

#define DATA_PIN    1
#define CLK_PIN   5
#define LED_TYPE    WS2812B
#define COLOR_ORDER RGB
#define NUM_LEDS    60
CRGB leds[NUM_LEDS];

#define BRIGHTNESS          10

void setup() {
  delay(1000); // Power-up delay

  // tell FastLED about the LED strip configuration
  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);

  // set master brightness control
  FastLED.setBrightness(BRIGHTNESS);
}

The led was bought from here: https://www.aliexpress.com/item/0-5-5M-30-60-LEDs-M-2811-Pixels-Programmable-Individual-Addressable-LED-Strip-light-WS2811/32849630888.html?spm=a2g0s.9042311.0.0.8e664c4dU4dru2


texts:
This bot is supposed to begin moving forward when the button is pressed, and stop after counting 3 lines of tape on the ground. Currently it is set up to scan the color of the floor at the beginning and count any major differences as a line of tape. Unfortunately I can't test its tape-sensing capabilities due to not being able to get it to actually start. It will only move if I hold the button down continuously, and stops as soon as I release it. Here is the code and images (It uses the Arduino Pro Mini 3.3v):

#include <SFE_ISL29125.h>
SFE_ISL29125 RGB;
unsigned int master2;
unsigned int detect2;
boolean isOn = false;
unsigned int accumulator = 0;

void setup() {
  RGB.init();
  pinMode(7, INPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  master2 = RGB.readGreen();
}

void loop() {
  if(isOn) {
    if(accumulator < 3) {
      detect2 = RGB.readGreen();
      digitalWrite(8, HIGH);
      digitalWrite(9, LOW);
      if(detect2 <= (master2 - 10) || detect2 >= (master2 + 10)) {
        accumulator++;
      }
    } else {
      accumulator = 0;
      isOn = false;
      digitalWrite(8, LOW);
      digitalWrite(9, LOW);
    }
  } else if(digitalRead(7) == HIGH) {
    isOn = true;
  } else {
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
  }
}


texts:
I’m trying to build a custom baby monitor for my wife who is deaf. It needs to detect loud noises and listen for a specific series of tones from a feeding pump our daughter uses.  It will then send a radio signal to the other room to trigger a bed shaker.

I do have a loop which samples the MAX4466 microphone and uses a “peakToPeak” calculation to determine volume, which I can use to trigger for loud noises (pasted below).  However, I cannot figure out how to determine the frequency of a noise sample.  I’ve tried searching for other sketches and tutorials that would work, but haven’t found anything.  The feeding pump, when it has an error puts out a series of tones which alternates between 4.1 kHz and 2.1 kHz.   What I wanted to do is see if the first tone is sounding, and then if the second tone shows up within a couple seconds afterwards, then it would trigger sending the signal to the other device.

I’ve tried for two days now to find a way to determine the frequency, but haven’t figured it out.  Any help would be greatly appreciated.  The closest I was able to get was this: Instructables - Arduino Frequency Detection, but when I use this script, the Arduino can no longer do analogRead() to get the status of various setting knobs and such I have on the device.

The script I use to get the sound level / loudness is:

  #define micPin 0                      // Microphone
  const int sampleWindow = 96;          // Sample window width in mS (50 mS = 20Hz)
  unsigned int sample;
    while (millis() - startMillis < sampleWindow) {
      sample = analogRead(micPin);
      // Check peakToPeak mins and maxs
        if (sample < 1024) {
          // toss out spurious readings
           if (sample > signalMax) { signalMax = sample; }          // save just the max levels
           else if (sample < signalMin) { signalMin = sample; }     // save just the min levels
        }
    }
    peakToPeak = signalMax - signalMin;  // max - min = peak-peak amplitude


texts: How many Amps can a Nano Arduino hold for LED project

texts:
I'm really new at this, and here is my doubt. What if I need to light 120x WS2812B (5v)LEDs (link: LEDs) using an Arduino Nano? if it takes 60 mAh each pixel, the total amount needed should be around 7,200 mA.

Could I use the same 5V/ 8A power supply (PowerSupply) for the Nano board and lights? Is that possible?

Thanks in advance, and sorry my ignorance on this area.


texts: Arduino not starting after 1.8.10 update

texts:
First off sorry if this is the wrong place.
Yesterday I updated the Arduino IDE to 1.8.10 and I was able to program a couple of hours.
Powering up my laptop today though the IDE is active, I can't switch to it and it shows a white screen if I hover over it in the taskbar below.
When I run the arduino_debug it literally says no error whatsoever it just loads the configuration and start the IDE (5 lines)

Already tried uninstalling and using another version of the IDE


texts: Serial string readout analyzed and logged onto an SD card

texts:
I have a sensor that gives me this string, serially read @9600:

@T;+019.8;H;043.6;51

This burst arrives automatically about every second. It means:

"@" start of the string
"T;" means the Temperature is coming now, after that ";".
"+019.8" the Temp value (fixed number of digits, with a leading +/- sign.
";" separator.
"H;" means the Humidity value is coming now after the ";".
"043.6" the Humidity value (fixed number of digits: so 000.0 to 100.0).
";" separator.
"51" is a 2 digit checksum.

Then a pause of about 1 second >> next string with new values.
I want to Serial.print them separately, and put then into a log file on the SD card of the Arduino Ethernet Shield.

On a next step I will show these values on a local display and a webpage, and add (resettable) alarm settings with individual hysteresis settings...

Any advice to solve this string-breakup and SD card logging?


texts:
I am working on HTTP GET Request. I have created ESP wifi as web server. It creates a access point with IP address : 192.168.4.1
When my android app is connected to web server, it sends values every 50ms on 192.168.4.1/R"VALUE". Value is integer type (0~1023). Example :- 192.168.4.1/R546

However, it is working fine when I send values every 1s, but esp crashes, when IP is hit every 5ms second. I have captured the crash detail on serial monitor. Attaching the file and code as well. Kindly help.

#include <ESP8266WiFi.h>
#include <EEPROM.h>
#include <ESP8266WebServer.h>

#define RED_LED     12

WiFiServer server(80); //Initialize the server on Port 80

char myTestUrl[100];

void setup()
{

  EEPROM.begin(512);
  Serial.begin(9600); //Start communication between the ESP8266-12E and the monitor window

  WiFi.mode(WIFI_AP); //Our ESP8266-12E is an AccessPoint
  WiFi.softAP("LED_Downlight1", "12345678"); // Provide the (SSID, password); .
  server.begin(); // Start the HTTP Server

  IPAddress HTTPS_ServerIP = WiFi.softAPIP(); // Obtain the IP of the Server
  Serial.print("Server IP is: "); // Print the IP to the monitor window
  Serial.println(HTTPS_ServerIP);
}

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

  String request = client.readStringUntil('\r');
  //Serial.print(request);

  request.toCharArray(myTestUrl, 100);

  char *Red = strstr(myTestUrl, "/R");
  if (Red)
  {
    int RedValue  = atoi(Red + 2);
    analogWrite(RED_LED, RedValue);
    Serial.print("Red: ");
    Serial.print(" ");
    Serial.print(RedValue);
    Serial.print("\n");

    int SetRedValue = (RedValue / 4);
    EEPROM.write(0, SetRedValue);

    EEPROM.commit();

    Serial.print("Red Memory Write :");
    Serial.print(" ");
    Serial.print(SetRedValue);
    Serial.print("\n \n");

  }
}


texts:
I am starting an intresting DIY project of baby swing. My son is 3 month old and we have swing made with ropes in our house where he sleeps. I am looking for any electronic component controlled with arduino to swing it in controlled manner. I thought of servo motor but not sure how will it work. Any suggestions please ?
swing is similer to below


texts: Write your own program to control Arduino Uno

texts:
Is it possible to write a program to control the Arduino Uno, without using
the Arduino IDE?


texts: Pushing sketches to pro mini with Uno 101

texts:
So I just bought a Pro Mini the other day, however, I didn't get an FTDI cable or a USB/Serial converter board.
From what I understand from this article I can use my Arduino Uno 101 to push sketches onto the Pro Mini.
The wires are all hooked up (grounded reset on the Uno) and I have uploaded the sketch to disable the serial communication port on the Uno, however, when I try to push a sketch to the Mini it errors out with the following message
Arduino: 1.8.3 (Windows Store 1.8.6.0) (Windows 10), Board: "Arduino Pro or Pro Mini,
ATmega328 (5V, 16 MHz)"

Sketch uses 928 bytes (3%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for
local variables. Maximum is 2048 bytes.
avrdude: ser_open(): can't open device "\\.\COM3": The system cannot find the
file specified.

Problem uploading to board.
See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

The only part of the suggested troubleshooting guide that maybe applicable is the drivers section.

Drivers
The Arduino Uno and Mega 2560 use standard drivers (USB CDC) provided by the operating system to communicate with the ATmega8U2 on the board. Other Arduino boards use FTDI drivers to communicate with the FTDI chip on the board (or in the USB-serial convertor).

I could be wrong but to me it doesn't seem like the second sentence applies to this situation since the the Uno sits between the pc and the mini. However, when I check the windows device manager I can see that the Uno is connected on a COM port, but nothing about the Mini. Though I am not sure that it should show up.
I am using the IDE(1.8.3) to program and "Arduino Pro or Pro Mini" as the board. Though Tools>Port is greyed out when I have this board selected.


texts: Control of 3 LEDs over Bluetooth using MIT App Inventor

texts:
As per title, I have 3 LEDs connected to an Uno. Also connected is an HC-05.

edit: forgot to add a question, my bad.  Is there any glaring major issues in this code that I've overlooked?  Not looking for anyone to write my code for me, just want to understand what I messed up and an idea of how to fix.

const int RED=2;
const int BLUE=4;
const int GREEN=6;

String inputString;
String buttonId;

char junk;

void setup() {
  Serial.begin(9600);
  pinMode(RED, OUTPUT);
  pinMode(BLUE, OUTPUT);
  pinMode(GREEN, OUTPUT);
  digitalWrite(RED,LOW);
  digitalWrite(BLUE,LOW);
  digitalWrite(GREEN,LOW);
}

void loop()
{
  if(Serial.available()){
  while(Serial.available())
    {
      char inChar = (char)Serial.read(); //read the input
      inputString += inChar;        //make a string of the characters coming on serial
    }
    Serial.println(inputString);
    while (Serial.available() > 0)
    { junk = Serial.read() ; }
    if(inputString == "r_on"){      // control red led
      digitalWrite(RED, HIGH);
    }else if(inputString == "r_off"){
      digitalWrite(RED, LOW);
    }
    inputString = "";
    if(inputString == "b_on"){      // control blue led
      digitalWrite(BLUE, HIGH);
    }else if(inputString == "b_off"){
      digitalWrite(BLUE, LOW);
    }
    inputString = "";
    if(inputString == "g_on"){      // control green led
      digitalWrite(GREEN, HIGH);
    }else if(inputString == "g_off"){
      digitalWrite(GREEN, LOW);
    }
    inputString = "";
  }
}

Picture of my App inventor block program in imgur link below

https://imgur.com/DlIdpTH


texts: Where do class files go in Sloeber Eclipse project?

texts:
I'm attempting to create a new Arduino project using Sloeber (Eclipse). Assume it's a newly-created project whose main entry file is ".\ArduinoMainClass.ino"

Now... assume I want to create a half dozen new classes:

ExecutionState-- a C++ class that's intended to be functionally equivalent to a Java Interface. If you're wondering, I'm attempting to implement the 'State' pattern.
GoodState, BadState, UglyState, WeirdState-- C++ classes that all extend ExecutionState. If they were Java, they'd technically be implementing an interface... but since this is C++ and I'm still taking baby steps, for now ExecutionState is just a class with one method that does nothing, and all of THESE classes override it to do the actual work.
StateContainer-- a C++ class whose only purpose in life is to hold single instances of GoodState, BadState, UglyState, and WeirdState. If this were Java, they'd be Singletons... GoodState (and the others) would have something like:

    private static ExecutionState instance = new GoodState();
    // ...
    public static ExecutionState getInstance() { return instance; }

... but it's obviously not Java,  and I'm nowhere close to knowing enough about C++ to properly implement static singletons yet, so for now, I'm just going to create an instance of StateContainer to create and hold those single instances.

So... I now have Sloeber/Eclipse loaded, and I've created my project. If this were Java, I'd create a subdirectory like .\src\java\com\packagename\executionstate and stick the .cpp and .hpp files for ExecutionState, GoodState, BadState, UglyState, WeirdState, and StateContainer in it, and add "include com.packagename.executionstate.*" to it.

I know C++ namespaces have no direct connection to directory names
I've gotten the impression that "Arduino"-ish C++ auto-generates the #include files for things it regards as libraries. I have a hunch that I probably want to put all of the classes I mentioned above in a directory somewhere and present them to the IDE as an Arduino "library" so they'll all get implicitly included in one go within the .ino file.
I'm completely confused about what I need to #include in the classes I mentioned above so they can mutually find each other... and whether those #includes rightfully belong in the .hpp or .cpp files.

So... getting back to the big picture. If my project is in c:\users\moi\Documents\Slober-workspace\FirstSloeberArduinoApp...

Where do the .cpp and .hpp files for ExecutionState, GoodState, BadState, UglyState, WeirdState, and StateContainer go? (Assume I'd be inclined to put them all in a directory named "executionstates" somewhere in the project's directory hierarchy, but I'm not sure where that exact directory should go).
What #includes do I need to put in ExecutionState, Good/Bad/Ugly/WeirdState, and StateContainer... and do they go in the .hpp file, or the .cpp file for their respective class?
What do I have to do so the .ino file can find StateContainer?

In case you're totally confused at this point, my actual .ino file will look something like this:

void setup() {
    // executionStates is a global variable declared higher up
    executionStates = new StateContainer();
    executionState = executionStates.getGoodState();
    // StateContainer's constructor itself creates instances of the various subclasses of ExecutionState,
   // and passes references to itself to their constructors so they can
   // get the references to the others states as they need to return them.
}

void loop() {
    executionState = executionState->doSomething();
    /* executionState holds a pointer to an instance of an ExecutionState subclass.
       Each time doSomething() executes, it returns a pointer to its new state
     */
}

... and in reality, there will be dozens of subclasses of ExecutionState, each representing a unique execution state.


texts:
So I am new to Arduino and new to electronics in general. I've looked up a few tutorials and they all have a simple early tutorial that turns on a DC motor and turns it off again. Something like this:

The transistor I am using is a 2N2222 and the motor is a little 3V DC toy motor.

The problem is that the when I use this circuit, the motor barely turns (I need to give it a little help to get it it moving). I know my code is right (motor is on for 5 seconds, off for 1). i can tell this is working but clearly something is not right.

I am powering the Arduino off the USB port.

As a test, I swapped out the 2.2K Ohm resistor for a 560 Ohm resistor and the motor seems to run fine. However, it creeps during the "off" time (the motor is not under any load). Also, the transistor gets very hot after about a minute of running this loop.

So my questions are:

1) Why does the motor not work when I use the 2.2K Ohm resistor when I see that 2.2K Ohm resistor in different circuit diagrams that demonstrate this type of circuit?

2) Why does changing to the 560 Ohm have the effect that it does

3) Why does the motor creep during the off cycle when using the 560 Ohm?

4) Why does the transistor get so hot using the 560 Ohm resistor?

5) Finally, sometimes as a test, to simple try to turn turn the motor on, I will just reroute to pin 9 wire directly to the Arduino 5V on my breadboard (bypassing Arduino control altogether). Is there any reason this is a bad idea?

I am anticipating questions about current draw but my multimeter maxes out at 200mA; I am getting a new one that goes to 10A and will help me see how much I am drawing.

Thanks in advance of any help. I have tried to be clear and concise so hopefully this does not elicit any snark. If there are any resources to point me to, I would be happy to hear them.

Thank you!

Jim


texts: How to get response of issued AT command for ES266 on Arduino programatically?

texts:
I'm successfully running AT commands via the Serial Monitor. But now I'm issuing AT commands via Arduino code and facing problems getting the correct response.

Goal: After issuing AT commands programatically, knowing whether these run successfully or not.

Microcontroller: Arduino Uno

#include<string.h>
#include<SoftwareSerial.h>

#define OK "OK"
#define SERVER_PORT 1234
#define RX_PIN 2
#define TX_PIN 3

SoftwareSerial ESP(RX_PIN, TX_PIN);

void setup() {
  Serial.begin(115200);
  Serial.println("First serial");
  while(!Serial);
  ESP.begin(115200);
  Serial.println("Second serial");
  while(!ESP);
  //Enabling multiple connections
  ESP.println("AT+CIPMUX=1\r\n");
  while (!ESP.available());
  String muxResponse = ESP.readString();
  Serial.print("muxR:");
  Serial.println(muxResponse);
}

void loop() {
  if (ESP.available()) {
    String val = ESP.readString();
    Serial.println(val);
  }
}

After running the above code I get the response in the Serial Monitor like:

muxR:AT+CIPMUX=1

busy p../

OK

I'm getting special characters too.


texts:
I'm trying to connect Maltab and Arduino by this code:

arduino=serial('COM7','BaudRate',9600);
fopen(arduino);

But I get this message:

  Open failed: Port: COM7 is not available. No ports are available. Use
  INSTRFIND to determine if other instrument objects are connected to
  the requested device.

What might be a proper reason?

I have another question which is; How can I save a text file (.txt) from Matlab to Arduino SD card .. ? Wether opening a .txt file in arduino or saving it from Matlab directly to Arduino SD card.


texts: Looks like a smartwatch but only has a gps tracker and password

texts: I was wondering if anyone had any suggestions about my idea. I want to crate something like a smartwatch but all I need it to have is a Gps and aa password. I want to be able to track it with a smart phone. Finger print would be awesome too


texts: Why does servo library conflict with irremote?

texts:
I am building an Arduino Mega robot. I am planning to use IRremote.h library for it. I am using multiple libraries in my code and I do not know which timers are taken. I always get errors when compiling because I am using the wrong timer. Here are the libraries I am using:

#include <LiquidCrystal.h>
#include <Wire.h>
#include <RTClib.h>
#include <Servo.h>
#include <IRremote.h>

I get this error message when compiling:

libraries\IRremote\IRremote.cpp.o: In function `__vector_42':

C:\Users\Lyuba\Desktop\Nick\Arduino\libraries\IRremote/IRremote.cpp:339: multiple definition of `__vector_42'

libraries\Servo\avr\Servo.cpp.o:C:\Users\Lyuba\Desktop\Nick\Arduino\libraries\Servo\src\avr/Servo.cpp:95: first defined here

c:/users/lyuba/desktop/nick/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.8.1/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

Here is the code in the library where I can change the timers:

// Arduino Mega
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  //#define IR_USE_TIMER1   // tx = pin 11
  //#define IR_USE_TIMER2     // tx = pin 9
 // #define IR_USE_TIMER3   // tx = pin 5
  #define IR_USE_TIMER4   // tx = pin 6
  //#define IR_USE_TIMER5   // tx = pin 46

What can I do to use irremote library? Looking at the error message, the servo library conflicts with irremote. How can I fix this?


texts: Graphical programing language for Arduino

texts:
I am looking for a graphical programming language for a project of mine, where I am using an Arduino.

It HAS to meet the following conditions:

It supports uploaing sketches to ATmega328 (Arduino Uno/Nano)
New functions can be defined inside the programming enviroment (I am trying to use a motor connected to an H-bridge with a single command block)
The program can run on Windows 7
Libraries can be used inside the code
C++ can also be used to write the code inside the same program
Sketches can be uploaded via Bluetooth 4.0

It would be nice if it met the following condition:

The programming enviroment is easy to use
The graphical programming language is somewhat similar to Scratch
The program can be understood by 10-14 year olds with no programming experience


texts:
I am a beginner who would like to buy an Arduino Yún (58 dollars).

It is retired so will I have any problem?

Else I can buy an Arduino Uno and an Arduino Yún Shield. But in this case I don't understand the difference between an Arduino Uno + Arduino Yún Shield and an Arduino Uno + ESP8266 serial WIFI wireless module.

Arduino Yún Shield: I can't find the price. I only found an Iduino.

ESP8266 serial WIFI wireless module: 7 dollars.


texts:
I keep getting this error message:

"'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?"

... when I have already included Keyboard.h.

#include <Keyboard.h>

void setup() {
  pinMode(3,INPUT_PULLUP);
  pinMode(4,INPUT_PULLUP);

 Serial.begin(9600);    //begin seral comms for debugging
}

void loop() {
  Keyboard.begin();
  if (digitalRead(3) == 0) //if button 3 is pushed
   {
Keyboard.write('z');
delay(200);
}
   else if (digitalRead(4) == 0) //if button 3 is pushed
{
  Keyboard.write('x');
  delay(200);
}
  Keyboard.end();
}

Keyboard.h is already included as a default library in Arduino so I'm not sure what's wrong


texts: How to send int[][] as a byte array through Serial

texts: I have int arr[50][2]; and I need to send it through Serial. But I don't know how to do it. is it possible?


texts: How can i provide enough power on an UNO to use the HC-12 wireless module?

texts:
Scenario:  The Uno is being powered by USB for programming, and the HC-12 wireless communications module is wired correctly.  But it will not work.

In reading through the web literature, it is mentioned that to use the HC-12 in the high-power (100 mW) mode requires a power supply in excess of what the laptop's USB port will provide.

I am finding nothing on Stackexchange that addresses this issue.

So the question is, how do I get the power to run the Uno with the HC-12?  I need to be able to periodically update the programming and test it while that auxiliary power is applied, and need to know it is safe to do so.


texts:
I am designing a peristaltic pump and need some advice for parts. I am using an Arduino Leonardo and also have an UNO and am planning on adding a temperature and pH sensor as well. I have two questions:

1) I am planning to use a Stepper Motor but am unsure if I should use the NEMA 17 or 23 or some other motor. I need a relatively "high" amount of torque maybe around 1 to 3 N-m.

2) Should I go with a Motor Shield or Motor Driver. I am currently looking at the Big Easy Driver or A4988 Bipolar Driver or the simple Arduino Motor Shield.

Does anyone know which of these would be best or have any suggestions? Thank you very much!


texts: stk500 getsync() attempt 10 of 10 atmega328pu

texts:
I've been getting this very common error on my atmega328pu circuit.

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x83

Some things iv'e tried are:

Restarting my comp
Reuploading the bootloader
Redownloading old version of arduino IDE
Using an FTDI chip and placing the chip inside an Uno

After I bootloaded the chip I was able to upload a blink sketch. Then the next time I tried I got this error. Anyone know what could be up? This is driving me crazy!


texts:
I've connected an LCD display to an Arduino Uno following the instructions from the Adafruit LCD lesson.

I've used the code sample described in the Adafruit lesson.

What happens after I connect the Uno to the USB cable is that the LCD lights up, but no text is displayed.

I've checked all connections and they look good. I am not 100%sure I have connected the potentiometer correctly, as this is the symptom I usually found online.

Could this also be a bad solder job? It's my first attempt and I guess it did not go that great.

Here are some more images, maybe someone with more experience can spot the error.

Update: here's what the board looks like once connected

and after removing the ethernet shield I get some weird flashes from time to time, only when I switch the potentiometer to maximum on one side, see video at https://i.imgur.com/ZclD2xz.mp4 .

Update 2: I realised that this is a 20-pin LCD screen and re-reading the datasheet and some online tutorials I switched digital wire connections to pins to the LCD 7-10 (DB0-DB3) - same result and then 11-14 (DB4-DB7) - garbled output, shown below. Still no idea what is wrong.


texts: What am I missing? ST7735 TFT white screen

texts: I followed this guy's guide with regards to wiring, etc., and all I seem to be getting is a white screen, as shown in these pictures. Is there an issue with the guy's guide, I'm missing or there is an issue with my wiring (pictures also included in above link) Any help would be appreciated.


texts: How do I connect two slaves of same type in I2C?

texts:
I am not experienced about I2C communications, but I do happen to have two HMC5883L magnetometer modules that I wish to connect to a single arduino. It uses I2C protocol, and hence the slave device will have a fixed address. Now Can I change the address of one of my sensors so that the Arduino can differentiate between the two? (I seem to find no way out by reading the datasheet)
Thanks in Advance
Siddharth Jha

P.S. Can an MPU 6050 module be used to find angle of rotation in X-Y plane (Parallel to the ground)?


texts: Data not uploading on Thingspeak server using ESP8266-01 Wifi -shield

texts:
Here's the problem.
My sketch has NO errors in it. I can see the output in the Serial monitor but
the data is not being uploaded in ThingSpeak server. I've tried changing the API KEYs but it a'int working. Please help me finding my error. Any answer will be appreciated. The code is given below.

#include <SoftwareSerial.h> //Software Serial library
SoftwareSerial espSerial(2, 3);//Pin 2 and 3 act as RX and TX.
#define DEBUG true
String mySSID = "xxxx";       // WiFi SSID
String myPWD = "yyyyyy"; // WiFi Password
String myAPI = "xyxyxyyxxyyxxxyy";   // API Key
String myHOST = "api.thingspeak.com";
String myPORT = "80";
String myFIELD = "field1";
int sendVal;

void setup()
{
  Serial.begin(9600);
  espSerial.begin(115200);
  espData("AT+RST", 1000, DEBUG);        //Reset the ESP8266 module
  espData("AT+CWMODE=1", 1000, DEBUG);  //Set the ESP mode as station mode
  espData("AT+CWJAP=\""+ mySSID +"\",\""+ myPWD +"\"", 1000, DEBUG);

  delay(1000);

}
void loop(){
sendVal = random(1000); // Send a random number between 1 and 1000
String sendData = "GET /update?api_key="+ myAPI +"&"+myFIELD+"="+String(sendVal);
    espData("AT+CIPMUX=1", 1000, DEBUG);       //Allow multiple connections
    espData("AT+CIPSTART=0,\"TCP\",\""+ myHOST +"\","+ myPORT, 1000, DEBUG);
    espData("AT+CIPSEND=0," +String(sendData.length()+4),1000,DEBUG);
    espSerial.find(">");
    espSerial.println(sendData);
    Serial.print("Value to be sent: ");
    Serial.println(sendVal);

    espData("AT+CIPCLOSE=0",1000,DEBUG);
    delay(10000);
  }

  String espData(String command, const int timeout, boolean debug)
{
  Serial.print("AT Command ==> ");
  Serial.print(command);
  Serial.println("     ");

  String response = "";
  espSerial.println(command);
  long int time = millis();
  while ( (time + timeout) > millis())
  {
    while (espSerial.available())
    {
      char c = espSerial.read();
      response += c;
    }
  }
  if (debug)
  {
    //Serial.print(response);
  }
  return response;
}


texts: I am planing on making Arduino from scratch. I found many examples on internet, but they all need another Arduino for programming. How can I make Arduino with USB interface for programming and serial data transfer? Would I need something called FTDI? Basically I want same Arduino you can buy, just build it from separate parts.


texts: Saving library example sketch getting error "you cannot save a sketch into a folder inside itself.."

texts:
I'm writing a library, and that library .cpp/.h code is in devel/arduino/libraries/LightBrightLib/.  I have test code that calls that library, and an example program using the library.  Right now they're in /devel/arduino/lightbright/LightBrightMain/ and /devel/arduino/lightbright/LightBrightLibTest/.

I see most libraries have an examples directory inside the library, so I tried moving mine to /devel/arduino/libraries/LightBrightLib/examples/LightBrightMain/ and /devel/arduino/libraries/LightBrightLib/examples/LightBrightLibTest/

When I do that, and try to save my LightBrightMain.ino file into /devel/arduino/libraries/LightBrightLib/examples/LightBrightMain/, it says "You cannot save a sketch into a folder inside itself. This would go on forever.".  And of course it won't let me select the examples directory or any other directory above it.

How do other library makers do this?  Maybe they don't use the IDE, or they copy it in outside the IDE, or use symlinks?
What does the IDE think it's doing and why is it fighting putting the file where it already is?

NOTE: This is not a file permission problem as I own all files


texts: Please help me read this Schematic Diagram

texts:
So, i'm trying to build an Obstacle Avoiding Robot by refering this site "Robot Obstacle Avoiding Car
On the website they have provided with very poor Circuit Diagram.
Please help me read the positions of capacitors.
I have completed connection of all other components.

Help would be appreciated


texts: RTClib now() within while loop does not update

texts:
I ran into this while trying to make a battery monitor and wondered where I went wrong. Using RTClib available in the Arduino IDE or from adafruit github, I ran into problems when trying to call now within a while loop inside of loop.  Here is a simple example:
#include "RTClib.h"

#define ledPIN 13

RTC_PCF8523 rtc;

void setup() {
  // put your setup code here, to run once:
  pinMode(ledPIN, OUTPUT);
  digitalWrite(ledPIN, LOW);
  Serial.begin(9600);
  while(!Serial) {/* wait for Serial */}
  rtc.begin();
  rtc.start();
  digitalWrite(ledPIN, HIGH);
 }

void loop() {
  // put your main code here, to run repeatedly:
  char fmt[] = "YYYY/MM/DD-hh:mm:ss\n";
  while (millis() < 60000){
    Serial.println((rtc.now()).toString(fmt));
    delay(5000);
  }
  Serial.println("Finished");
  digitalWrite(ledPIN, LOW);
  while(1) { /* do nothing forever */ }
}

The output of this little test will be the same time repeated every 5ish seconds.  If it matters I am using a Feather M0 with the FeatherLogger that has an RTC on it.  Changing this loop function to this:
void loop() {
  // put your main code here, to run repeatedly:
  char fmt[] = "YYYY/MM/DD-hh:mm:ss\n";
  if (millis() < 60000){
    Serial.println((rtc.now()).toString(fmt));
    delay(5000);
  } else {
    Serial.println("Finished");
    digitalWrite(ledPIN, LOW);
    while(1) { /* do nothing forever */ }
  }
}

shows that now does in fact update the time every 5ish seconds.  I looked at the code for now and it appears to do very basic i2c commands to get the time and report it back.  The only thing I can think of is that the compiler created a (not so) temporary DateTime object for me within the while loop and the RTC library does not provide a convenient constructor or operator to overwrite the existing object.
I tested my theory with this
void loop() {
  // put your main code here, to run repeatedly:
  char fmt[] = "YYYY/MM/DD-hh:mm:ss\n";
  while (millis() < 60000){
    DateTime t1 = rtc.now();
    Serial.println(t1.toString(fmt));
    delay(5000);
  }
  Serial.println("Finished");
  digitalWrite(ledPIN, LOW);
  while(1) { /* do nothing forever */ }
}

But again, the time did not change so clearly I don't understand what's happening here.  Why doesn't the rtc now function work as intended within a while loop inside the loop function?


texts: Control external device using Java Web Servlet -> Pi -> Arduino -> Device

texts:
I'm new to the world of Arduino & PI, so far it's been a fantastic experience but I'm now looking to build something a bit more practical.

My plan is for the PI to host a JSP Servlet website.  I'd like to go to a certain page of this site: 'powerCycleDevice' for example where it would pass a parameter in '?=on' or something similar.  This would then be picked up by the Arduino which in turn would then power said device.

It's also be nice to just use it as a monitoring station.  If I have several Arduinos hooked up (and I plan to - think Wallace & Gromit :)) then it'd be nice to view the statistics of each of the sensors.

My problem is not knowing if a: it's possible (I'm certain it is) and b: where to start.

If anyone can lend any advice, hints or tips on where to get started it would be fantastic.  A noob guide or tutorial would be great as I'd then use the info and expand upon it.

Thanks in advance.


texts: NodeMCU V3 + SD Card with Arduino IDE Not working

texts:
I am trying to connect CATALEX MicroSD Card adaptor to new NodeMCU V3 and PIN configuration are as below,

NodeMCU  ---------> SD Card
GPIO13 (D7) ------> MOSI
GPIO12 (D6) ------> MISO
GPIO14 (D5) ------> SCK
GPIO15 (D8) ------> CS
VCC (3.3V) -------> VCC
GND --------------> GND

Tested above setup with QuickStart program from SdFat library in Arduino IDE. But it gives error output as below,

SPI pins:
MISO: 12
MOSI: 13
SCK:  14
SS:   15

SD chip select is the key hardware option.
Common values are:
Arduino Ethernet shield, pin 4
Sparkfun SD shield, pin 8
Adafruit SD shields and modules, pin 10

Enter the chip select pin number: 15

Disabling SPI device on pin 10
Can't access SD card. Do not reformat.
No card, wrong chip select pin, or SPI problem?
SD errorCode: 0X20,0XFF

SD initialization failed.
Do not reformat the card!
Is the card correctly inserted?
Is chipSelect set to the correct value?
Does another SPI device need to be disabled?
Is there a wiring/soldering problem?

errorCode: 0x20, errorData: 0xff

  chipSelect is 15.

Also, I am using SanDisk 16GB Micro SDHC class 4 Memory Card.

I have tried googling with the error but did not find solution. Please help me.


texts:
I'd like to run an application on my system after pushing a button on an Arduino shield. I've read that I need to use the runShellCommand() function, which can be accessed from a Process header. However when I add the #include <Process.h> line to my program I'm getting this error:

.build/uno/src/sketch.cpp:2:21: fatal error: Process.h: No such file or directory
 #include <Process.h>

I'm using Ubuntu 14.04 and I've installed Arduino software from repositories.


texts:
I'm looking to put together a simple mains frequency monitor based on the Arduino platform. The mains here are 250 V @ 50 Hz, but obviously these fluctuate slightly, which is the whole point of the exercise. (I am not interested in capturing voltage fluctuations, only frequency fluctuations).

I have never used any Arduino products before, but I am familiar with PIC-based MCUs. I understand Arduino should be somewhat simpler. Also, I am not an electronics engineer.

Presumably, the Arduino will sample the mains frequency for a second or two, and then report the result somehow. I guess the easiest way is for a computer connected to the Arduino by USB to receive the result and act accordingly. Otherwise, other options include adding an Ethernet module to the Arduino and having it HTTP POST the result to a web server.

(I assume doing this naive method is preferable to recording a time series and then performing a Fourier transform?)

Size isn't a huge concern, but a compact device is preferable over a larger one as I'll be 3D-printing a custom enclosure for it. Therefore I would like to use the Arduino Nano if it's suitable.

Here is what I have so far:

The 250V mains will be half-rectified with an IN4004 (?) transistor (together with a 1K resistor and 0.22 uF cap), and that will go into a 4N35 optocoupler.
A digital (?) GPIO pin from the Arduino goes into the base of the 4N35 and emitter goes to GND.
The Arduino samples for a short time the number of pulses on that pin, does a simple calculation, and reports the result.

Here are my uncertainties so far:

Based on my research, I believe the Arduino can reliably be powered by USB. If this is correct, this would be ideal as it would avoid me having to build a low voltage DC power supply for it.
How stable is the clock on the Arduino? How many decimal places on the frequency can I realistically achieve?
I presume I'll need to debounce the result from the optocoupler? Will there be some noise as the transistor transitions between states? Are there built-in debouncing functions or will I need to write my own? How is this likely to affect available clock cycles and therefore the accuracy of the measurement?
I've seen PIC projects where it interacts with the computer by emulating a keyboard. While simple, this wouldn't be ideal as the computer it's connected to must also remain usable. The software processing the result should run in the background while a user can continue using the computer. How simple is it to write some software (in C#) that will recognise the Arduino connected via USB, and communicate with that device in particular?

I also welcome any other comments and suggestions. Thank you.

Edit: Following these helpful comments and suggestions, I've made some revisions and asked a follow-up question.


texts:
i´m trying to build a little monitor of an ESP8266 and an OLED display that displayes the Status of a Robotarm.

The robotarm is controled by a RAMPSboard that has a webserver, so i can check the status from a browser.
For that i´m trying to use the BasicHttpClient Sketch from Arduino to read the status and progress.

The problem is i.... don´t know how?
I guess i know where the data is in my HTML document, but i dont know how to call it via GET request.

With the modified BasicHttpClient Sketch i can read the whole html site and print it out on serial, but after weeks of reading and watching tutorials i´m still stucked.

Long story short.

i want to read "just" the status and progress off of that webserver, with a GET request

this is the part of HTML code where my data is...i guess:
here are 3 different times of the informations i´d like to "extract" and displayed on my little ESP8266 monitor

Idle
Working
Done

0% Complete
   //äusseresHTML

1% Complete

22% Complete

and i just need to change that part of the sketch as it now prints out everything of the page:

void loop() {...

     ... Serial.print("[HTTP] GET...\n");
      // start connection and send HTTP header
      int httpCode = http.GET();

      // httpCode will be negative on error
      if (httpCode > 0) {
        // HTTP header has been send and Server response header has been handled
        Serial.printf("[HTTP] GET... code: %d\n", httpCode);

        // file found at server
        if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
----->          String payload = http.getString();   <---as i understand here i ask for everything
          Serial.println(payload);
        }
      } else {
        Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
      }

      http.end();
    } else {
      Serial.printf("[HTTP} Unable to connect\n");
    }
  }

Hopefully someone has the time to take a look at that and point me to String i need to call.

BTW, i think the main problem why i couldn´t find the answer myself is my english isnt that professional for that kind of stuff, so im doin hard to understand similar tutorials


texts:
I recently format my  Windows 8 and installed Windows 8.1 . In Windows 8, I was using Arduino IDE and there was no error in compiling.But then I installed Windows 8.1 and re-installed Arduino IDE.I tried various codes for motor drivers and everything but they didn't compile.So, I tried to compile blink LED example first and even it didn't compile.It shows the following error on UPLOADING BLINK LED Example-

Arduino: 1.8.2 (Windows 8.1), Board: "Arduino/Genuino Uno"

C:\Program Files\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files\Arduino\hardware -tools C:\Program Files\Arduino\tools-builder -tools C:\Program Files\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files\Arduino\libraries -libraries C:\Users\Admin\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=0X2341_0X0043 -ide-version=10802 -build-path C:\Users\Admin\AppData\Local\Temp\arduino_build_754363 -warnings=none -build-cache C:\Users\Admin\AppData\Local\Temp\arduino_cache_657645 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files\Arduino\hardware\tools\avr -verbose C:\Program Files\Arduino\examples\01.Basics\Blink\Blink.ino
C:\Program Files\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files\Arduino\hardware -tools C:\Program Files\Arduino\tools-builder -tools C:\Program Files\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files\Arduino\libraries -libraries C:\Users\Admin\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=0X2341_0X0043 -ide-version=10802 -build-path C:\Users\Admin\AppData\Local\Temp\arduino_build_754363 -warnings=none -build-cache C:\Users\Admin\AppData\Local\Temp\arduino_cache_657645 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files\Arduino\hardware\tools\avr -verbose C:\Program Files\Arduino\examples\01.Basics\Blink\Blink.ino
Using board 'uno' from platform in folder: C:\Program Files\Arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Program Files\Arduino\hardware\arduino\avr
Detecting libraries used...
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\Admin\AppData\Local\Temp\arduino_build_754363\sketch\Blink.ino.cpp" -o "nul"
Generating function prototypes...
"C:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10802 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\Admin\AppData\Local\Temp\arduino_build_754363\sketch\Blink.ino.cpp" -o "C:\Users\Admin\AppData\Local\Temp\arduino_build_754363\preproc\ctags_target_for_gcc_minus_e.cpp"
"C:\Program Files\Arduino\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\Admin\AppData\Local\Temp\arduino_build_754363\preproc\ctags_target_for_gcc_minus_e.cpp"
exit status 1
Error compiling for board Arduino/Genuino Uno.

I tried RE-installing the software and drivers.It didn't work

Why is this happening?What is the Solution?