body:
I've recently purchased a no-brand 1€ ATtiny programmer off eBay, and with the ridiculous price obviously came no documentation nor support from the seller.

[![][2]][2]

At first I thought that using it with the Arduino IDE would have been as simple as plugging and programming, but no default lib worked. My hopes definitely crumbled when I realized the device wasn't even being picked up by Debian, showing instead this in the logs:

    kernel.info: [ 2758.501968] usb 6-3: new low-speed USB device number 2 using ohci-pci
    kernel.err: [ 2758.641798] usb 6-3: device descriptor read/64, error -62
    kernel.err: [ 2758.885515] usb 6-3: device descriptor read/64, error -62
    kernel.info: [ 2759.125231] usb 6-3: new low-speed USB device number 3 using ohci-pci
    kernel.err: [ 2759.265065] usb 6-3: device descriptor read/64, error -62
    kernel.err: [ 2759.508779] usb 6-3: device descriptor read/64, error -62
    kernel.info: [ 2759.748500] usb 6-3: new low-speed USB device number 4 using ohci-pci
    kernel.err: [ 2760.156027] usb 6-3: device not accepting address 4, error -62
    kernel.info: [ 2760.291871] usb 6-3: new low-speed USB device number 5 using ohci-pci
    kernel.err: [ 2760.699382] usb 6-3: device not accepting address 5, error -62
    kernel.err: [ 2760.699421] usb usb6-port3: unable to enumerate USB device

and with `lsusb` outputting this:

    Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 002 Device 003: ID 07d1:3c0a WiFi Dongle
    Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 003 Device 002: ID 045e:0745 Mouse/Keyboard BT Dongle
    Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Reading up on the subject seemed to confirm that it was something I shouldn't have bought, and the closest I've got to a better understanding was with this question ([link][1]) which I can't comment.

So building up on the answer there, can anyone please explain a bit more in detail what for and where `micronucleus` would be needed?

Alternatively, is it possible to go with something as easy as installing the drivers and plugging it into the Arduino IDE?

  [1]: https://arduino.stackexchange.com/a/23999/26623 "link"
  [2]: https://i.stack.imgur.com/KWXIw.jpg

title: Cheap ATtiny programmer on Debian

Answers: 3

body:
Micronucleus is a bootloader - in the same way that Optiboot is a bootloader used on the Uno. It provides the USB connection to program the chip.

Without it you can't do anything at all with that, since the USB port just plugs direct into the ATTiny chip. With no software on the chip the USB port doesn't do anything.  It's kind of a catch-22 situation - you need software on the chip in order to put software on the chip.

In essence Micronucleus turns the ATTiny into a kind of Mini Leonardo.

You need to first put Micronucleus on the chip (which you can do with an Arduino as an ICSP programmer) and then once that is installed you should be able to start using that little board with the chip to program it.

Since you're on a decent operating system there's no need for "drivers".

body:
It isn't clear to me what you need to do- both for specific chip and your programming needs.

You can easily program an ATTiny with just an arduino and a breadboard.  A breakout board and a socket are fun, you could also build or buy a permanent shield for this.

With that breakout board (you could just use a breadboard, too) and an Arduino, you can program your ATTiny from the ArduinoIDE or from avrdude (if for example you have just a .hex file from an Instructable.  You will find that the Arduino IDE doesn't support uploading .hex files directly, but since the IDE calls on avrdude for all the actual work- you can invoke avrdude from the command line to upload your .hex file to the chip).

If you mention which ATTiny you need to program, I've missed it.

Overall process is:
From the Arduino IDE, add these core libraries from: Tools/ Boards/ Boards manager

github.com/damellis/attiny
This will get you:

    ATtiny 25 (8 pin)
    ATtiny 45 (8 pin)
    ATtiny 85 (8 pin)
    ATtiny 24 (14 pin)
    ATtiny 44 (14 pin)
    ATtiny 84 (14 pin)

Add:
github.com/MCUdude/MicroCore  (this will need manual install, instructions are provided)

and
sourceforge.net/projects/ard-core13/files/latest/download  (I forget if this can be added from the IDE or needs manual install).

if you need ATtiny13 support.  Each has some advantages the other does not.

You will want to use IDE 1.6.x.

Wire up your breakout board (or breadboard) to your Arduino appropriately for the ATTiny you are using.  For example, according to the wiring diagram here for the ATTiny85:
highlowtech.org/?p=1695

And from there you should be able to program your ATTiny so that it can run independently from your Arduino.

If you need to upload a .hex file to your ATTiny check the examples here:
arduinodiy.wordpress.com/2012/09/11/programming-hex-code-on-an-attiny85-with-the-arduino/

You can do that by using the Arduino as an ISP and then uploading the .hex file to the ATTiny using AVRdude.  You'll have to tweak the avrdude command line params a little specific to your situation.

I've just done programming of ATTiny13 using an Arduino Uno, a breadboard, and 6 jumper wires just fine.  Both uploading sketches I made in the Arduino IDE as well as using compiled .hex files that were part of an Instructables.com project I was building worked fine.

If you need to upload a program to a board and then use that board to mass-produce many identically programmed ATTiny without using an Arduino, adafruit as a solution, as does shop.myavr.com.  I can't justify the expense but they look really neat.  Using the Arduino as ISP for this of course works as well.

htlinux has a shield for Arduino's that is really inexpensive and comes with sockets for many Atmel pinouts:

www.htlinux.com/product/attiny-isp-shield/

I ordered one and it isn't here yet, it took a month to get the shipping notice, but it looks like a convenient all-in-one solution.  It still needs an Arduino to act as programmer.  It would meet your requirement of "removing all wiring" if you are find with a shield.

You could easily build your own shield with a proto board, too.
http://www.instructables.com/id/ATtiny-Programming-Shield-for-Arduino-1/?ALLSTEPS

I hope this helps!  I spent a while figuring out all this stuff, hopefully having many items in one answers helps the next person looking to program ATTiny with Arduino.  I'm working from OS X, it should be even easier from Windows or Linux.

body:
Judging by the picture it's **just a board**.

If it is anything like [this link on eBay](http://www.ebay.com/itm/Development-Programmer-Board-for-ATtiny13A-ATtiny25-ATtiny45-ATtiny85-/400994911916) (the first hit for "attiny programmer board") then this is the description:

> Development board supporting chip:ATtiny13A / ATtiny25 / ATtiny45 / ATtiny85 etc

It *supports* the named chips, it doesn't have them on it.

I presume you are supposed to do a few things with it:

* Purchase an ATtiny85 (or similar) chip
* Install it on the board
* Solder in an ICSP header onto the 8 pins on the right
* Program the Micronucleus bootloader using a suitable other piece of hardware (like a ICSP programmer)
* **Then** use the board as a ATtiny development board.

It's not responding because there is no chip there (unless you can see one on the other side). That's why it's cheap. You are buying a board, not a microcontroller on a board.

This [other link on eBay](http://www.ebay.com/itm/Development-Programmer-Board-Micro-USB-for-ATtiny13A-ATtiny25-ATtiny45-ATtiny85/201536595756) for a slightly different board (for the same price) shows that the other side does not have a processor on it.


body:
I would like to know how i can use my ultrasonic value in an if else statement, so i can use the value that the servo motors stop running and go in another direction when the ultrasonic sensor gets close to an object.

    /*
      Digital pin 2 is connected to a switch
      Digital pin 3 is connected to a switch
      Digital pin 7 is connected to the echo port of the ultrasonic sensor
      Digital pin 8 is connected to the trig port of the ultrasonic sensor
      Digital pin 9 is connected to a servo
      Digital pin 10 is connected to a servo
      Digital pin 13 is connected to a LED

     */

    #include <Servo.h> // include a special file that is needed for servo motors, do this only once

    Servo motor1; // create a servo object for each motor
    Servo motor2;

    int echo = 7; //declare echo from ultrasonic sensor
    unsigned long duration;
    void setup() {
      // initialize the LED pin as an output:
      pinMode(13, OUTPUT);
        // initialize the pushbutton pin as an input:
        pinMode(2, INPUT);
        // switch 2 initialize
        pinMode(3, INPUT);
      // initialize the servo on pin 9
      motor1.attach(9);
      // motor 2 initialize
      motor2.attach(10);
        // initialize serial communication at 9600 bits per second:
        Serial.begin(9600);
        //echo pin of ultrasonic sensor
        pinMode(echo, INPUT);
        //trig pin of ultrasonic sensor
        pinMode(8, OUTPUT);

    }

    void loop() {
          // the trigger pin sends a pulse
           digitalWrite(8, LOW);
           delayMicroseconds(2);
           digitalWrite(8, HIGH);
           delayMicroseconds(10);
           digitalWrite(8, LOW);
           duration=pulseIn(echo, HIGH);
          // the echo pin measures how long it took for that pulse to come back
           Serial.println(duration);
          // delay in between reads for stability
           delay(50);
           duration=pulseIn(echo, HIGH);

      // check if the pushbutton is pressed.
      // if it is, the buttonState is HIGH:
      if(duration <=400) {
        // turn LED on:
        digitalWrite(13, HIGH);
        // turn the motors off for 2 seconds
        motor1.write(90);
        motor2.write(90);
        delay(2000);
        //turn motor 1 on for 2 seconds to make a turn
        motor1.write(180);
        delay(2000);
      } else {
        digitalWrite(13, LOW);
        //motors run when vehicle is not near objects
        motor1.write(0);
        motor2.write(180);
      }
    }

title: How to read Ultrasonic sensor value to use and drive servo motors

Answers: 1

body:
First, I would make sure I have continuous servo motors that can rotate 360 degrees. Your servos will just rotate to the degree you entered if they are not continuous. Additionally, it would be more helpful if you named your pins. For example:

    int echo = 7;
    void setup(){
        pinMode(echo, INPUT);
    }

This will help us read the code better.

I also see that you have "pulseIn" in your if statement. You must save the value to a variable with the data type of unsigned long.

    //before the setup
    unsigned long duration;

    //keep your setup as it is

    void loop(){
       digitalWrite(8, LOW);
       delayMicroseconds(2);
       digitalWrite(8, HIGH);
       delayMicroseconds(10);
       digitalWrite(8, LOW);

       duration=pulseIn(echo, HIGH);

       if(duration<=400){//check for the value
           // turn LED on:
            digitalWrite(13, HIGH);
            // turn the motors off for 2 seconds
            motor1.write(90);
            motor2.write(90);
            delay(2000);
            //turn motor 1 on for 2 seconds to make a turn
            motor1.write(180);
            delay(2000);
       }else{
            digitalWrite(13, LOW);
            //motors run when vehicle is not near objects
             motor1.write(0);
             motor2.write(180);
           }
       }

Overall: check your servos and save the value of pulseIn to a variable. You might also want to convert to centimeters by dividing duration by 58.2.


body:
I'm trying to send some data using nRF24L01+ transceivers, but I need to use 8 byte payloads for reliability. The data I'm sending is much bigger than that, so I need to split it into 8 byte packets and then reassembly on the receiving end. I wrote the following code to test it, but to no success.
<!-- language-all: lang-cpp -->

 #include <SPI.h>
 #include "nRF24L01.h"
 #include "RF24.h"
 #include "printf.h"
 RF24 radio(9,10);
 const byte pipes[][7] = { "master", "slaves" };
 #define PayLoad 8

 void setup() {
   Serial.begin(9600);
   while(!Serial){}
   radio.begin();
   radio.setRetries(15,15);
   radio.setPayloadSize(PayLoad);
   radio.setPALevel(RF24_PA_LOW);
   radio.setDataRate(RF24_1MBPS);
   radio.setCRCLength(RF24_CRC_16);
   delay(100);
   radio.openWritingPipe(pipes[0]);
   radio.openReadingPipe(1,pipes[1]);
   radio.startListening();
   radio.printDetails(); //RF Debug
   delay(1000);
   //sendRF("Payload splitting test. 1234567890");
 }

 void loop() {
   if (radio.available()){
  fromRF();
   }
   if (Serial.available()){
  String dataIn = Serial.readString();
  sendRF(dataIn);
   }
 }

 void fromRF(){
   byte numPkgs;
   radio.read(&numPkgs,1);
   Serial.println(numPkgs);
   char rcvBuffer[numPkgs*PayLoad];
   for (byte pkg=1; pkg<=numPkgs; pkg++){
  char payloadBuff[PayLoad];
  radio.read(&payloadBuff,PayLoad);
  for (int charpos=0; charpos<PayLoad; charpos++){
    rcvBuffer[((pkg-1)*PayLoad)+charpos] = payloadBuff[charpos];
  }
  if (pkg < numPkgs){
    int timeout = 0;
    while(!radio.available() && timeout<100){
   timeout++;
   delay(1);
    }
    if (timeout >= 100){
   Serial.println("Package timed out.");
   return;
    }
  }
   }
   String msgRcvd(rcvBuffer);
   Serial.println(msgRcvd);
 }

 void sendRF(String msg){
   byte msgLen = msg.length();
   Serial.println(msg);
   Serial.println(msgLen);
   char msgBuff[msgLen];
   msg.toCharArray(msgBuff,msgLen);
   radio.stopListening();
   byte numIters = msgLen/PayLoad;
   if (msgLen%PayLoad > 0)
  numIters++;
   radio.write(&numIters, 1);
   Serial.println(numIters);
   char payloadBuff[PayLoad];
   for (byte iter = 1; iter <= numIters; iter++){
  for (byte i=0; i<=PayLoad; i++){
    payloadBuff[i] = (char)0;
  }
  byte initchar = (iter-1)*PayLoad;
  byte lastchar = (iter*PayLoad)-1;
  if (lastchar > msgLen)
    lastchar = msgLen;
  byte counter = 0;
  for (byte nextchar = initchar; nextchar <= lastchar; nextchar++){
    payloadBuff[counter] = msgBuff[nextchar];
    counter++;
  }
  radio.write(&payloadBuff, PayLoad);
  Serial.println(payloadBuff);
  delay(50);
   }
   radio.startListening();
   delay(100);
 }

This code is intended to work for both master and slave, except that writing and reading pipes change places.

My splitting is working fine (as shown by the serial monitor), but it looks like I'm not able to receive it well. Any help would be greatly appreciated!!

EDIT:

I've got it working! (kind of). It still lacks managing lost packages, but it's working quite fine.

 void fromRF(){
   byte numPkgs;
   radio.read(&numPkgs,1);
   //Serial.println(numPkgs);
   String rcvdStr = "";
   for (byte pkg=1; pkg<=numPkgs; pkg++){
  char rcvBuffer[PayLoad+1];
  delay(100);
  radio.read(&rcvBuffer,PayLoad);
  rcvBuffer[PayLoad] = '\0';
  String strBuffer(rcvBuffer);
  rcvdStr += strBuffer;
   }
   Serial.println(rcvdStr);
   //sendRF(rcvdStr);
 }

 void sendRF(String msg){
   byte msgLen = msg.length();
   Serial.println(msg);
   //Serial.println(msgLen);
   char msgBuff[msgLen];
   msg.toCharArray(msgBuff,msgLen);
   radio.stopListening();
   byte numIters = msgLen/PayLoad;
   if (msgLen%PayLoad > 0)
  numIters++;
   radio.write(&numIters, 1);
   Serial.println(numIters);
   char payloadBuff[PayLoad];
   for (byte iter = 1; iter <= numIters; iter++){
  for (byte i=0; i<=PayLoad; i++){
    payloadBuff[i] = (char)0;
  }
  byte initchar = (iter-1)*PayLoad;
  byte lastchar = (iter*PayLoad)-1;
  if (lastchar > msgLen)
    lastchar = msgLen;
  byte counter = 0;
  for (byte nextchar = initchar; nextchar <= lastchar; nextchar++){
    payloadBuff[counter] = msgBuff[nextchar];
    counter++;
  }
  radio.write(&payloadBuff, PayLoad);
  Serial.println(payloadBuff);
  delay(50);
   }
   radio.startListening();
   delay(100);
 }

Gotta give a look at RF24Mesh.

title: RF24 - Split data in payloads at sender and then rebuild on receiving end

Answers: 0


body:
I want to make some precise measurements with Arduino Due. Although I'm using very good external voltage reference (LTC6655) measured data is still jumping around, especially significant when I'm trying to measure low voltages (0.1-0.05V). Can I improve ADC accuracy by changing it's settings?

The default Arduino Due ADC settings are:

    // Initialize Analog Controller
    pmc_enable_periph_clk(ID_ADC);
    adc_init(ADC, SystemCoreClock, ADC_FREQ_MAX, ADC_STARTUP_FAST);
    adc_configure_timing(ADC, 0, ADC_SETTLING_TIME_3, 1);
    adc_configure_trigger(ADC, ADC_TRIG_SW, 0); // Disable hardware trigger.
    adc_disable_interrupt(ADC, 0xFFFFFFFF); // Disable all ADC interrupts.
    adc_disable_all_channel(ADC);

So, with `adc_init` we can configure frequency and startup time. And with `adc_configure_timing` we configure tracking time, settling time and transfer time. But how to select those values? Does increasing of that times improves precision?

Useful links:

[Datasheet][1] - ADC description starts on page 1317.

[Atmel Software Framework][2] - see adc.h and adc.c.

  [1]: http://www.atmel.com/Images/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf
  [2]: http://www.atmel.com/tools/avrsoftwareframework.aspx

title: Advanced ADC setup on Due (SAM3X8E) to increase precision

Answers: 3

body:
Default resolution is 10b because of backward compatibility, so you can start with setting `analogReadResolution(12);` as stated on [Arduino analogReadResolution Refference page][1].

If it's still not enough you can use GAIN setting for used ADC channel. For single ended input GAIN can be set up to 4. But it means you can mesaure voltages up to 1/4 of Uref

  [1]: https://www.arduino.cc/en/Reference/AnalogReadResolution

body:
> measured data is still jumping around

it will always jump around -> that's why adc modules are such a great random number generators (using its lsb). jumping around 8 - 9 lsb isn't that rare. anything beyond that should be investigated.

a few things to watch for:

1. use a good reference;
       2. allow sufficient time;
       3. pay attention to layout;
       4. make sure that the source impedance isn't too great;
       5. put a signal conditioning circuit on the input. a 1k/.1uf filter can do wonders;
       6. pick the right oscillator for the adc module - see some c8051f350 code for example;
       7. write the right code;
       8. oversampling.

body:
Generally speaking the input BandWidth of the analog signal is a major cause of noise in a ADC circuit as well as improper ground and reference generation and layout techniques.  Be very careful that ALL of the analog paths do not have any digital current return paths. Remember that at 12 bit for a 1.25V reference an LSB is ~300uV. I have not ever measured the SNR of the SAM ADC but I doubt that it is the specified ~60db (i.e. 10bit) unless absolute care is taken during the layout/routing.
Recommend:
1) Limit input BW to the correct channel ground. (well below Nyquist BW if possible to avoid alliasing)
2) Oversample if possible.
3) Insure low digital I/O of peripherals during sample period.


body:
I'm making a pretty basic light circuit and I'd like to have it react to applause or laughter, but NOT during regular speech, amplified over speakers.

I'm wondering if anyone has already made a function for this that I could use in this design!

Your help is greatly appreciated! Thanks for being awesome people who help educate, assist, and elevate others in their creative journeys. You're the best!

Ryan

title: Applause reactivity

Answers: 1

body:
Not really an applause detector, but I have written a sound meter
program you could use as a starting point for your own project. It is
available here: [Arduino sound meter][sound-meter]. It works as follows:

- the analog input is read at a constant rate of about 9600 samples per
  second, which is normally fine for telephone quality audio processing
- the DC offset from the microphone is removed
- the readings are squared in order to get the instantaneous sound
  intensity; note that this is not immediately usable, as it fluctuates
  furiously
- this is run through a first order low-pass filter with a time constant
  of 26.6 ms in order to get a usable sound intensity reading
- the readings are decimated to keep only one every 26.6 ms
- they are sent to the PC through the serial port.

The program does not use the `analogRead()` function, because it is
really not suited for this kind of real-time sampling. Instead, it
directly accesses the ADC, it configures it in the so called “free
running mode” and uses the ADC interrupt to retrieve the samples. This
limits the portability of the program, which has been written for an
Arduino Uno.

If you want to make an applause detector form this, I suggest the
following approach:

1. Use the program as is, to record and plot the sound intensity as a
   function of time.
2. Test various types of sounds: applause, laughter, speech, noise...
3. Look carefully at the plots and try to see how the sounds you want to
   detect are different from those you do not want: high peaks? short
   peaks? fast rise times? You will have to make up some criteria to
   tell them apart. This is the most difficult part, as it will require
   some creativity.
4. Write some code to apply your criteria. Keep in mind that your code
   will ultimately have to run in real time, i.e. process one intensity
   sample at a time. It will not have the whole record to start with.
5. Test your code on your computer, on the data previously recorded.
6. Debug, fine-tune... until you are happy with your detection
   algorithm.
7. Modify my sound-meter program: remove the last statement
   (transmitting the data to the host computer) and replace it with your
   detection code.

Good luck!

[sound-meter]: https://gist.github.com/edgar-bonet/e693799f58a545ca89a2


body:
when i use `SoftPWMBegin()` function in setup there is some delay while receiving data over bluetooth. And if i pressed o and 1 fastly (see in below given code), some time it receives data and sometime not receives.
when i not using `SoftPWMBegin()` it receives data fastly . I think `SoftPWMBegin()` function creating some problem.
I want use `SoftPWM.h` library for controlling RGB led brightness. So please give me any solution for that...

    #include <"SoftwareSerial.h">
    #include <"SoftPWM.h">

    SoftwareSerial Genotronex(0, 1);

    int redPin = A5;

    int greenPin = 3;

    int bluePin = A0;

    int BluetoothData;

    void setup()

    {

     Genotronex.begin(57600);

      SoftPWMBegin();

      }

    void loop()
    {

    if (Genotronex.available())

       {

          BluetoothData=Genotronex.read();

       if(BluetoothData=='0')

       {

      SoftPWMSet(redPin, 0);

       }

       else if(BluetoothData=='1')
    {

        SoftPWMSet(redPin, 20);

       }

    }

    }

title: Delay In receiving data when SoftPWMBegin(); is used from SoftPWM.h library

Answers: 2

body:
Maybe you need to change the class that contains the `SoftPWMBegin()` or `Genotronex.read()` methods.
I don't know this library, can you give the link for donwload it and to try it...?

body:
Software PWM is quite complex and uses interrupts to emulate PWM using a timer. SoftwareSerial also uses interrupts. You can't have two things happening at once, so one wilk take precedence over the other. In this case the timer interrupt is taking precedence over the Pin Change interrupt, so the reception is delayed, which breaks SoftwareSerial since it relies on a prompt response to the interrupt to work.

You basically have to avoid the use of both software emulations together. Either switch to using the hardware UART, or hardware PWM or, even better, ditch both and go for 100% hardware driven.


body: I know how to program in C but I'm more productive in python, so, I would like to know if there is a way to run a python code into arduino.

title: Is it possible to run Python embedded in Arduino?

Answers: 1

body:
You can use other kind of board called [MicroPython][1]

  [1]: https://micropython.org

But yes, is possible using some kind of TX-RX Python class...


body:
I have an ESP8266 module connected with my Arduino configured as a server, with both AP and station modes (AT+CWMODE=3) activated, and I want to know if an incoming connection comes from the AP's network or the station's network. This is the package I'm receiving, and it's exactly the same whether it comes from one or another network:

 +IPD,0,437:GET /?uuid=7be547af980d13c5&cmd=10 HTTP/1.1
 Host: 192.168.0.222:51813
 Connection: keep-alive
 Cache-Control: max-age=0
 Accept: */*
 Origin: http://127.0.0.1:8020
 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
 DNT: 1
 Referer: http://127.0.0.1:8020/domo_ctrl/www/index.html
 Accept-Encoding: gzip, deflate, sdch
 Accept-Language: es-419,es;q=0.8,en;q=0.6

At first I thought that it would reject packages addressed towards another IP (AP's IP is different from station's IP), but since this IS the gateway, it receives ALL incoming traffic. Please help!

EDIT:

This is the firmware and other stuff shown by `AT+GMR`:

 AT+GMR

 AT version:1.1.0.0(May 11 2016 18:09:56)
 SDK version:1.5.4(baaeaebb)
 Ai-Thinker Technology Co. Ltd.
 Jun 13 2016 11:29:20
 OK

title: ESP8266 - How to know if incoming connection is from AP or station network?

Answers: 1

body:
I don't think the default AT firmware allows to automatically reject packets because that would probably require a higher degree of control, but looking at the [Expressif documentation about the AT command set][1] I've discovered you can actually retrieve the remote address rather than the local one, just by using the same command you were using but with a different parameter

    AT+CIPDINFO=1

Not sure though this actually might solve your problem.

  [1]: http://espressif.com/sites/default/files/documentation/4a-esp8266_at_instruction_set_en.pdf


body:
When I try to upload a sketch on this brand new Arduino Leonardo, I get this error:

    Arduino: 1.6.11 (Linux), Board: "Arduino Leonardo"

    Sketch uses 4,134 bytes (14%) of program storage space. Maximum is 28,672 bytes.
    Global variables use 148 bytes (5%) of dynamic memory, leaving 2,412 bytes for local variables. Maximum is 2,560 bytes.

    avrdude: Expected signature for ATmega32U4 is 1E 95 87
         Double check chip, or use -F to override this check.
    Wrong microcontroller found.  Did you select the right board from the Tools > Board menu?

The output of "Get board info" is

    BN: Arduino Leonardo
    VID: 2A03
    PID: 0036
    SN: (null)

This is the actual board

[![enter image description here][1]][1]

And if I shine a very bright light on che microcontroller, take out my glasses and look veeeeeeery close at it, I can read MEGA32U4. So I think that this is an actual Arduino Leonardo.

I downloaded arduino.org IDE. After compiling ncurses5 (...) and making it starts, now i get this error

    Arduino: 1.7.10 (Linux), Board: "Arduino Leonardo"

    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /tmp/build6488251228617422525.tmp/sketch_sep16a.cpp -o /tmp/build6488251228617422525.tmp/sketch_sep16a.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/wiring.c -o /tmp/build6488251228617422525.tmp/wiring.c.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/wiring_digital.c -o /tmp/build6488251228617422525.tmp/wiring_digital.c.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/wiring_analog.c -o /tmp/build6488251228617422525.tmp/wiring_analog.c.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/wiring_shift.c -o /tmp/build6488251228617422525.tmp/wiring_shift.c.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/hooks.c -o /tmp/build6488251228617422525.tmp/hooks.c.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/WInterrupts.c -o /tmp/build6488251228617422525.tmp/WInterrupts.c.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-gcc -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/wiring_pulse.c -o /tmp/build6488251228617422525.tmp/wiring_pulse.c.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/HardwareSerial1.cpp -o /tmp/build6488251228617422525.tmp/HardwareSerial1.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/HardwareSerial0.cpp -o /tmp/build6488251228617422525.tmp/HardwareSerial0.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/USBCore.cpp -o /tmp/build6488251228617422525.tmp/USBCore.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/HardwareSerial2.cpp -o /tmp/build6488251228617422525.tmp/HardwareSerial2.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/main.cpp -o /tmp/build6488251228617422525.tmp/main.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/abi.cpp -o /tmp/build6488251228617422525.tmp/abi.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/HardwareSerial.cpp -o /tmp/build6488251228617422525.tmp/HardwareSerial.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/HardwareSerial3.cpp -o /tmp/build6488251228617422525.tmp/HardwareSerial3.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/WString.cpp -o /tmp/build6488251228617422525.tmp/WString.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/Stream.cpp -o /tmp/build6488251228617422525.tmp/Stream.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/Print.cpp -o /tmp/build6488251228617422525.tmp/Print.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/CDC.cpp -o /tmp/build6488251228617422525.tmp/CDC.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/Tone.cpp -o /tmp/build6488251228617422525.tmp/Tone.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/HID.cpp -o /tmp/build6488251228617422525.tmp/HID.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/WMath.cpp -o /tmp/build6488251228617422525.tmp/WMath.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/IPAddress.cpp -o /tmp/build6488251228617422525.tmp/IPAddress.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=107010 -DARDUINO_AVR_LEONARDO -DARDUINO_ARCH_AVR -DUSB_VID=0x2a03 -DUSB_PID=0x8036 -DUSB_MANUFACTURER="Unknown" -DUSB_PRODUCT="Arduino Leonardo" -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino -I/home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/variants/leonardo /home/phas/Downloads/arduino-1.7.10-linux64/hardware/arduino/avr/cores/arduino/new.cpp -o /tmp/build6488251228617422525.tmp/new.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/wiring.c.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/wiring_digital.c.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/wiring_analog.c.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/wiring_shift.c.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/hooks.c.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/WInterrupts.c.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/wiring_pulse.c.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/HardwareSerial1.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/HardwareSerial0.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/USBCore.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/HardwareSerial2.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/main.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/abi.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/HardwareSerial.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/HardwareSerial3.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/WString.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/Stream.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/Print.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/CDC.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/Tone.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/HID.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/WMath.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/IPAddress.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-ar rcs /tmp/build6488251228617422525.tmp/core.a /tmp/build6488251228617422525.tmp/new.cpp.o
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-gcc -w -Os -Wl,--gc-sections -mmcu=atmega32u4 -o /tmp/build6488251228617422525.tmp/sketch_sep16a.cpp.elf /tmp/build6488251228617422525.tmp/sketch_sep16a.cpp.o /tmp/build6488251228617422525.tmp/core.a -L/tmp/build6488251228617422525.tmp -lm
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /tmp/build6488251228617422525.tmp/sketch_sep16a.cpp.elf /tmp/build6488251228617422525.tmp/sketch_sep16a.cpp.eep
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avr-objcopy -O ihex -R .eeprom /tmp/build6488251228617422525.tmp/sketch_sep16a.cpp.elf /tmp/build6488251228617422525.tmp/sketch_sep16a.cpp.hex

    Sketch uses 4,252 bytes (14%) of program storage space. Maximum is 28,672 bytes.
    Global variables use 151 bytes (5%) of dynamic memory, leaving 2,409 bytes for local variables. Maximum is 2,560 bytes.
    Forcing reset using 1200bps open/close on port /dev/ttyACM0
    PORTS {/dev/ttyACM0, /dev/ttyS0, } / {/dev/ttyACM0, /dev/ttyS0, } => {}
    PORTS {/dev/ttyACM0, /dev/ttyS0, } / {/dev/ttyACM0, /dev/ttyS0, } => {}
    Uploading using selected port: /dev/ttyACM0
    /home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/bin/avrdude -C/home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/etc/avrdude.conf -v -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D -Uflash:w:/tmp/build6488251228617422525.tmp/sketch_sep16a.cpp.hex:i

    avrdude: Version 6.0.1, compiled on Jan 15 2015 at 13:12:29
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2009 Joerg Wunsch

             System wide configuration file is "/home/phas/Downloads/arduino-1.7.10-linux64/hardware/tools/avr/etc/avrdude.conf"
             User configuration file is "/home/phas/.avrduderc"
             User configuration file does not exist or is not a regular file, skipping

             Using Port                    : /dev/ttyACM0
             Using Programmer              : avr109
             Overriding Baud Rate          : 57600
             AVR Part                      : ATmega32U4
             Chip Erase delay              : 9000 us
             PAGEL                         : PD7
             BS2                           : PA0
             RESET disposition             : dedicated
             RETRY pulse                   : SCK
             serial program mode           : yes
             parallel program mode         : yes
             Timeout                       : 200
             StabDelay                     : 100
             CmdexeDelay                   : 25
             SyncLoops                     : 32
             ByteDelay                     : 0
             PollIndex                     : 3
             PollValue                     : 0x53
             Memory Detail                 :

                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               eeprom        65    20     4    0 no       1024    4      0  9000  9000 0x00 0x00
               flash         65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00
               lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
               hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
               efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
               lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
               calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
               signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

             Programmer Type : butterfly
             Description     : Atmel AppNote AVR109 Boot Loader

    Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding
    Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

  [1]: https://i.stack.imgur.com/8ouxn.jpg

title: Wrong microcontroller found on Arduino Leonardo

Answers: 1

body: Since no one has elaborated a better answer: if something like this happens, try to install arduino.org IDE on windows, connect the leonardo and flash a firmware. It should then start to work on any OS.


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

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

Thank you

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

Answers: 1

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

No, it is basically a hall-effect sensor that requires power and generates a low effect pulse.

Look for a generator. Something like this; https://netram.co.za/1199-36v-micro-hydro-generator.html

Cheers!


body:
I've been working with the Arduino Due for a project, we have been setting up these Arduinos with an ARM Board that hosts a Linux System with Busybox that connects to the Arduino. Recently I got assigned the job of making it possible for the Arduino Due to be updated with the new code remotely so we don't have to travel to each location every time we need to update anything.

At first it seemed easy, crosscompile bossac for Arduino Due and use it in the ARM Linux Board, needing to open the port at 1200 bauds so the Arduino is available for a new upload.

The problem is, i've tested bossac and it works perfectly on Windows same as the Arduino IDE, it always uploads the sketch without a single problem. On Linux, however it doesn't seem to be working properly, not even the full Arduino IDE in AMD64, we have already tested it in 2 Vbox with Linux and in 2 native Linux installations, testing 32b and 64b, ARM and x86, i've tested everything I've seen on the web: up the permissions, add the user to the dialout group, reset the board manually...

I'm sure i'm missing something stupid but I don't know what and it's driving me crazy because the Arduino IDE is supposed to work properly on Linux. Just in case, these are the steps I've followed:

 - Download the latest version of the Arduino Due, untar it and sudo ./install.sh
 - Add my user to the dialout group, and log out.
 - In the Arduino IDE go to the Board Manager and install the SAM support for Arduino Due
 - Select Arduino Due (programming port) and /dev/ttyACM0
 - Upload any sketch (also tried with example sketches), it compiles but when uploading the next message appears

> SAM-BA operation failed

And if using the verbose output this always happens after the next output,it seems to fail the last write and tries to overwrite it again (this is not the full output, there are writes and reads before this)

    Chip ID      : 285e0a60
    version()=v1.1 Dec 15 2010 19:25:04
    Version      : v1.1 Dec 15 2010 19:25:04
    Address      : 524288
    Pages        : 2048
    Page Size    : 256 bytes
    Total Size   : 512KB
    Planes       : 2
    Lock Regions : 32
    Locked       : readWord(addr=0x400e0a08)=0x1
    readWord(addr=0x400e0c08)=0x1
    writeWord(addr=0x400e0a04,value=0x5a00000a)
    readWord(addr=0x400e0a08)=0x1
    readWord(addr=0x400e0c08)=0x1
    readWord(addr=0x400e0a0c)=0
    readWord(addr=0x400e0a08)=0x1
    readWord(addr=0x400e0c08)=0x1
    writeWord(addr=0x400e0a04,value=0x5a00000a)
    readWord(addr=0x400e0a08)=0x1
    readWord(addr=0x400e0c08)=0x1

Almost every time it crashes it's like that but sometimes it even starts uploading and showing the percentage of upload but again "SAM-BA operation failed" before finishing the upload.

What irks me is that in Windows it works flawlessly so the board is all good and even compiling bossac from the sources produces the same error in Linux, I've also tested an Arduino Duemilanove and it works perfectly on Linux however it uses avr, not bossac. As i've said i've tested it in 4 machines and it's always the same, even in the ARM version.

What is it that I'm missing?

Thanks in advance.

title: Arduino Due works perfectly on Windows but doesn't on Linux (SAM-BA operation failed)

Answers: 0


body:
I have an electromagnet that I wish to use to pull a neodyne magnet closer.

I'm thinking of having the electromagnet sensing when the magnet is close, but when the magnet is running I'm pushing 12 volts through it and I don't want to fry my Arduino. How can I do the wiring to achieve this?

I only have to be able to use the magnet as a sensor while it's turned off.

title: Use an electromagnet for reading induction as well

Answers: 1

body:
You can use a hall sensor from an old computer fan.

If the magnet is not moving you are not going to be able to sense it with the coil of your electromagnet.
You can also decouple de input of your arduino with a cap in series with the coil, but again if the magnet is not fast enough you will have to use a bigger cap.

You can also make a voltage divider between your coil and sense from there. When the 12V are applied just add some code to offset the input signal.


body:
I am using the following simple code to test the interrupt functionality of due:

    void aMillion(){
        for(int i = 0; i < 1000000; i++){
            if(i % 1000 == 0){
                Serial.print("m");
            }
        }
    }

    void setup(){
      Serial.begin(9600);
      pinMode(2, INPUT);
      attachInterrupt(digitalPinToInterrupt(2), aMillion, CHANGE);
    }
    void loop()
    {
    }

obviously what we expect to see is a thousand "m" characters after each interrupt event. On Arduino Mega, this worked fine. But I have tested it on multiple Due boards.

Very odd news is that on the reset event of due, I do get a single "m" character printed.

title: ISR halts in DUE

Answers: 1

body:
An attempt to run long loops in the ISR for the DUE fails. This is the result of some sort of a run time monitoring system. An infinite loop like this one here, or even a loop with a thousand repetitions of a Serial Print will result in an early halt of ISR on the **DUE**.

On the **MEGA** however, This is not the case. ISRs can run much longer. (At least ten minutes as I tried)


body:
I want to check my understanding on how to use `digitalWrite` for `5V` and `Grd` and why this code isn't working.

This is for the [Makeblock sensor][1]

Consider [the image here][2] which says to plugin a wire to 5V, Grd and a signal pin.

My code does the following

    #define h  22
    #define l  24
    #define sig 26

    void setup() {
       Serial.begin(9600);
       pinModde(h, OUTPUT);
       pindMode(l, OUPUT);
       pinMode(sig, OUPUT);

       digitalWrite(h, HIGH);
       digitalWrite(l, LOW);
    }

    void loop() {
       digitalWrite(sig, LOW);
       delayMicroseconds(2);
       digitalWrite(sig, HIGH);
       delayMicroseconds(10);
       digitalWrite(sig, LOW);
       pinMode(sig, INPUT);
       long duration = pulseIn(sig, HIGH, 38000);
       delay(2500);
    }

When I run this code duration is always `0`.  If I unplug` 22` and `24` and use the board's `5V` and `Grd` I get duration is `30001` no matter how far away an object is from the sensor.  Meaning it's not sensing anything, just returning this number.

Full disclosure that I'm using solder-less wires but I don't that would make this much of a difference?

So to summarize: why are 22 and 24 resulting in a 0 readout and not acting as 5V and Grd?  My only thought is maybe too much voltage and a resister is needed?

Secondly: why is the sensor not working even when using 5V and Grd pins?

  [1]: http://learn.makeblock.com/en/me-ultrasonic-sensor/
  [2]: http://learn.makeblock.com/en/wp-content/uploads/2016/01/微信截图_20160129144228.png

title: Problems with Ultrasonic Sensor

Answers: 1

body:
You've set `pinMode(sig,INPUT);` and never changed this back to `OUTPUT` before triggering next measure:

    void loop() {
       pinMode(sig, OUTPUT);    // ensure sig is configured as an output
       digitalWrite(sig, LOW);
       delayMicroseconds(2);
       digitalWrite(sig, HIGH);
       delayMicroseconds(10);
       digitalWrite(sig, LOW);
       pinMode(sig, INPUT);
       long duration = pulseIn(sig, HIGH, 38000);
       delay(2500);
    }

And for example PING))) (which is basically the same module) has power consumption about 30mA-35mA in datasheet. Output pin might be strong enough to power it, but I'd recommend at least GND connect directly to arduino GND. And using transistor for powering it up would be even better


body:
I have a breadboard connected to an Arduino Uno, 220k resistors connected to an led, of course it has a common ground and a pin connected to 5v. All pins are digital.

Now, I want led 1 to turn on for one second, the next led for two seconds and the next for three seconds, but that means, when the second led which has to be on for two seconds then the first led will come back on after one second has past on the second led, the third led would be on for three seconds, so the second led will also be on when two seconds pass and the first would be on when one second passes. So basically, all leds are on for their given duration.

How do I do this? I have been trying to do this since three days. It would be a pleasure if someone helps me out. Thanks.

    int ledPin1= 2;
    int ledPin2 = 4;
    int ledPin3 = 7;

    void setup(){
      pinMode(ledPin1, OUTPUT);
      pinMode(ledPin2, OUTPUT);
      pinMode(ledPin3, OUTPUT);
      }

      void loop(){
      digitalWrite(ledPin1, HIGH);
      delay(500);
      digitalWrite(ledPin1, LOW);
      delay(500);

      digitalWrite(ledPin2, HIGH);
      delay(1000);
      digitalWrite(ledPin2, LOW);
      delay(1000);

      digitalWrite(ledPin3, HIGH);
      delay(1500);
      digitalWrite(ledPin3, LOW);
      delay(1500);
        }

So far this is the code. But it delays the whole program. Need leds on at given times.

title: Making three led's blink at different times in Arduino

Answers: 2

body: Using a 220k Ohm resistor will lead to approximatively 20µA to light the LED. This is not enough to light the LED, you should replace the resitor by one of value 330Ohm (220 to 470 could be OK depending of the LED)

body:
Seems like you want a pattern like this ?

    LED1 : 1 0 1 0 1 0 1 0 1 0 1 0 ... repeat
    LED2 : 1 1 0 0 1 1 0 0 1 1 0 0 ... repeat
    LED3 : 1 1 1 0 0 0 1 1 1 0 0 0 ... repeat

In which case you'll need something like this pseudo code

    // set up the relevant pins as output etc
    ....
    // set up a counter
    counter = 0

    loop
      toggle LED1
      if (counter modulo 2 == 0) then toggle LED2
      if (counter modulo 3 == 0) then toggle LED3

      counter++
      if counter > 11 then counter = 0 // your pattern repeats every 12 seconds

      delay for 1 second

Toggling the LED is just a case of checking if it is high or low and setting it to the opposite value.


body:
This question comes on the heels of [this question][1]

In the last question I learned how to use an initializer list to solve my issue, but working with `ros::Subscriber` is requiring a different solution.

I'm dealing with a callback in this scenario. If I leave the callback as a standalone function then the program runs but I have no access to class members and methods inside the function which defeats the purpose. Here is my standalone callback:

    void setPRYCallback( const std_msgs::Empty& toggle_msg) {}

Once I move this into my class is when I encounter the error.

*steps to implementing into class*

    // add member variable for callback
    protected:
      void setPRYCallback( const std_msgs::Empty& );

    ...

    // ass method
    void ROSController::setPRYCallback( const std_msgs::Empty& toggle_msg) {}

    ...

    // set initializer list
    ROSController::ROSController() : sub("setPRY", &setPRYCallback )

How do I thwart this error while keeping my callback as a class method?

**Program with Standalone Function Callback** *(program runs)*

    #include <ros.h> // https://github.com/ros-drivers/rosserial/blob/jade-devel/rosserial_arduino/src/ros_lib/ros.h
    #include <std_msgs/Empty.h>

    class ROSController {
      protected:
        ros::Subscriber<std_msgs::Empty> sub;
        ros::NodeHandle _nh;
      public:
        void loop();
        ROSController();
    };

    void setPRYCallback( const std_msgs::Empty& toggle_msg) {}

    ROSController::ROSController()  {
      this->_nh.initNode();
      this->_nh.subscribe(sub);
    }

    void ROSController::loop() {
      this->_nh.spinOnce();
      delay(1000);
    }

**Program with Method Callback** *(program fails)*

    #include <ros.h> // https://github.com/ros-drivers/rosserial/blob/jade-devel/rosserial_arduino/src/ros_lib/ros.h
    #include <std_msgs/Empty.h>

    class ROSController {
      protected:
        ros::Subscriber<std_msgs::Empty> sub;
        ros::NodeHandle _nh;
        void setPRYCallback( const std_msgs::Empty& );
      public:
        void loop();
        ROSController();
    };

    void ROSController::setPRYCallback( const std_msgs::Empty& toggle_msg) {}

    ROSController::ROSController() : sub("setPRY", &setPRYCallback )  {
      this->_nh.initNode();
      this->_nh.subscribe(sub);
    }

    void ROSController::loop() {
      this->_nh.spinOnce();
      delay(1000);
    }

  [1]: https://arduino.stackexchange.com/questions/29115/how-can-i-move-these-global-variables-to-be

*arduino mega*

title: ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function

Answers: 2

body:
When you move the setPRUCallback function into your class you change the prototype (well, C++ changes the prototype) from:

    void setPRYCallback( const std_msgs::Empty& toggle_msg) {}

to:

    void setPRYCallback( ROSController *this, const std_msgs::Empty& toggle_msg) {}

That is now not what the callback registering function expects, and so it breaks.

By making the method `static` it removes that `*this` parameter, but also means that the function can only access static data within your class (variables also marked `static`) and there is only one copy of the function (and `static` variables) shared between all instances of the class (maybe not what you want).

body:
If you define instance as a global value, how about to set callback with using lambda expression as variable of constructor.

```cpp
#include <ros.h>
#include <std_msgs/Empty.h>

class ROSController {
  protected:
    ros::Subscriber<std_msgs::Empty> sub;
    ros::NodeHandle nh;
  public:
    ROSController(void (*staticPRYCallback)(const std_msgs::Empty& msg));
    void begin();
    void loop();
    void setPRYCallback( const std_msgs::Empty& );
};

void ROSController::setPRYCallback(const std_msgs::Empty& toggle_msg) {}

ROSController::ROSController(void (*staticPRYCallback)(const std_msgs::Empty& msg))
  : sub("setPRY", staticPRYCallback )  {
}

void ROSController::begin() {
  nh.initNode();
  nh.subscribe(sub);
}

void ROSController::loop() {
  nh.spinOnce();
}

ROSController rosController([](const std_msgs::Empty& msg){
  rosController.setPRYCallback(msg);
});

void setup() {
  rosController.begin();
}

void loop() {
  rosController.loop();
  delay(1000);
}
```

Reference (A post of my blog in Japanese)<br />
https://asukiaaa.blogspot.com/2020/09/define-cpp-callback-for-class-value-with-using-lambda-as-a-variable.html


body: I'm making a water level detector to control my motor which supplies water in water tank and for that I'm going to use ultrasonic sensor to be attached to tank lid. My question is whether the vapor arising from water inside the tank hamper the overall working of ultrasonic sensor and/or it may be damaged permanently. I can cover complete ultrasonic sensor using hot glue stick but cannot cover its diaphragm as it will block sound waves. Please suggest something.

title: Water level Detection using Ultrasonic Sensor and arduino

Answers: 3

body:
A friend of mine worked on a liquid level monitoring project, and after many iterations finally abandoned the kinds of sensors you're talking about. Ultimately he just pointed a cheap USB webcam at the thing and used [OpenCV](http://opencv.org/) and the edge detection algorithm to find the level of the water.  Then it's just a matter of doing some math using the dimensions of the container, to figure out how full it is.

If you are using a clear container and if you have the option of using a Raspberry Pi (or a PC, whatever) that can run OpenCV, you might find that option worth exploring.

body:
Majenko, agreed.
Use some FM antenna cable, if you can find it. Insulate the lower end by dipping in molten heat glue.
Two rods, insulated with heat shrink tubing also works well.
Use LM393 dual comparator as Schmitt trigger and inverter. That will oscillate at  frequency dependant on the water level. Works well, recalibrate or clean the sensor when accuracy suffers due to being too dirty. should not be necessary more than annually.

body:
Sensors exist for exactly your use case. Here is an example;

[Maxbotix MB7589 Ultrasonic Sensor][1]

I have used several of these to measure river levels. they are virtually indestructible and have all the features that you would expect;

 - Temperature compensation
 - Self heating to deal with humidity/condensation
 - serial output
 - 1mm resolution

  [1]: https://maxbotix.com/products/mb7589


body:
So i have taken apart this old remote i found, and removed the IR-LED and replaced it with wires.

I thought that i would just be able to put the wire that used to go to the positive side of the IR-LED, to a pin on my Arduino UNO (and negative to GND), and just use the same IR decoding library to decode the signal, as if it was from an IR sensor.

But as it turns out, i receive undecipherable nonsense (or so it seems), like 5+ different codes from pressing the same button on the remote.

If i connect the 2 pins from the remote to the IR-LED on my breadboard, and an IR receiver to my Arduino i receive the signal you would expect, which in my case is "24137D" in HEX (1 on the remote) every time.

So my question is: Why does this happen and is it even possible to do what i am trying to do. Why? Why not? And if possible how is this done?

Here is the code i am using:

    #include <IRremote.h> //https://github.com/z3t0/Arduino-IRremote

    #define IR_Pin 7

    IRrecv irrecv(IR_Pin);
    decode_results results;

    void setup() {
      Serial.begin(9600);
      pinMode(IR_Pin, INPUT);
      irrecv.enableIRIn();

    }

    void loop() {
        if(irrecv.decode(&results)) {
        Serial.println(results.value, HEX);
        irrecv.resume();
      }

    }

Maybe the answer is obvious and i just don't understand how IR works. If so feel free to link some documentation that can help me.

Thank you.

title: Sending IR via a wire

Answers: 1

body:
Your IR receiver is decoding the high frequency pulsed *On-Off-Keying* waveform for you. The Arduino doesn't do that.

An IR signal consists of high frequency (say 36KHz) on-off light pulsed at a lower (data) frequency (different combinations to make 1 and 0)

[![enter image description here][1]][1]

The receiver you have takes that high frequency signal, amplifies it, filters it, and gives you just the resulting 1 and 0 signals. From that the Arduino can use simple time measurements to work out the code.

Without the filtering that the receiver provides the Arduino will have to do all that work by itself - and while that may be technically possible, it's seldom done. You may be able to find a library that can do it, but it's unlikely.

  [1]: https://i.stack.imgur.com/KmMao.jpg


body:
I would like to know if it is possible to read from and write to the microcontroller's (Arduino Uno's ATmega328P) flash memory using a program or "bootloader" previously stored in the flash memory (or the EEPROM memory) itself.

If it is possible, can it be done using the Arduino IDE?

title: In-application programming for the Arduino Uno

Answers: 0


body:
I have an Arduino connected to a pico motor driver that is supposed to take a number of steps for a specific number of triggers that gets from a source (i.e. waveform generator). I've setup the code so that it would ask the user to input number of steps and number of triggers. For example, if I want the motor to take 10 steps once it got 60 triggers, I should input s10; and t60; separately into Serial Monitor.

In addition, I want to be able to change the number of steps and triggers any time that I want. However the problem is that sometimes Arduino doesn't receive the input string entirely for the first time. Sometimes it works on the second try. Or even not at all. I really appreciate if someone can give a hint on why this is happening.

This is a simple version of the code (without the parts that move the motor):

    #include<String.h>

    long int steps;
    long int num_triggers;
    long int newtrigger;
    long int newstep;
    long int oldtrigger;
    long int oldstep;

    const int main_control = 0;
    int triggers_count;
    bool motor_trigger = true;

    void setup() {

     Serial.begin(19200);
     Serial.println("Please enter chosen number of steps and triggers.");
     Serial.println("Example: \n If you want the pico-motor to take 10 steps per 40 triggers,");
     Serial.println(" write 's10;' and press enter then do the same for 't45;'(Order doesn't matter).");
    }

    void loop() {

      while (num_triggers == 0 || steps == 0) {

        getcommand(&steps, &num_triggers);

      }

      attachInterrupt(main_control, trigger, RISING);  // it starts looking for trigger

      if (motor_trigger == false) {

        getcommand(&steps, &num_triggers);
      }

      else if (motor_trigger == true) {

        motor_trigger = false;
        detachInterrupt(main_control);

        if (triggers_count <= (num_triggers - 1)) {

          getcommand(&steps, &num_triggers);

        }

        else {

          for (int i = 0; i < steps; i++) {

            oldstep = steps;
            oldtrigger = num_triggers;
            getcommand(&steps, &num_triggers);

            if (  num_triggers != oldtrigger || steps != oldstep) {
              break;
            }
          }
        }
      }
    }

    void trigger(void) {

      motor_trigger = true;
      triggers_count++;
    }

    void getcommand (long int *newstep, long int *newtrigger) {

        char   char_input;
        String string_input;
        String output_1;
        String output_2;

      while (Serial.available()) {

        char_input = Serial.read();
          if (char_input == ';'){
        Serial.println("done");

          }
          else{
        string_input += char_input;
        delay(500);
        }
      }

      Serial.println("Getting input...");
      Serial.println(string_input);
      Serial.println("Input printed.");

      int inputlen = string_input.length();
      output_1 = string_input[0];

        for ( int i = 1; i < inputlen; i++ ) {
          output_2 += string_input[i];
        }

          if ( output_2.toInt()<=0 && inputlen>0 ){   // check if there's an error

            Serial.println("Error with input number");
            delay(5000);
            Serial.println("Reading the input string");
            Serial.println(Serial.readString());
            Serial.println("Done reading the input string");
            }

        if (output_1 == "s") {

          *newstep = output_2.toInt();

        }

        else if (output_1 == "t") {

          *newtrigger = output_2.toInt();
        }

      }

title: Serial Communication Not Receiving Entire String

Answers: 1

body:
I can see several issues:

- If the Serial buffer contains more than one command already, you'll read it too. For example serial buffer contains `"s43;t25;"` and  the `input_string` would be something like `"s43t25"`. This is highly to happen if you send those characters in less than 3seconds (as you have `delay(500)` for each appended character). You have to stop reading from buffer if you detect ';'.

- Parsing of commands is also pretty weird. You are blocking for some time, so you can detect 's'/'t' and then use `Serial.parseInt();` with `Serial.setTimeout(1000);` to do similar but much faster get command.

- Variables set inside of ISR (function trigger is called from ISR) must be volatile. Otherwise it might be optimized out or into register by compiler.

Anyway, if you want to read whole commands try the [`serialEvent()` example][1]. Just change checking for `'\n'` to `';'` and then you can parse that command in your way when it's complete.

  [1]: https://www.arduino.cc/en/Tutorial/SerialEvent


body:
I have a breadboard connected to an Arduino Uno, 220k resistors connected to an led, of course it has a common ground and a pin connected to 5v. All pins are digital.

Now, I want led 1 to turn on for one second, the next led for two seconds and the next for three seconds, but that means, when the second led which has to be on for two seconds then the first led will come back on after one second has past on the second led, the third led would be on for three seconds, so the second led will also be on when two seconds pass and the first would be on when one second passes. So basically, all leds are on for their given duration.

How do I do this? I have been trying to do this since three days. It would be a pleasure if someone helps me out. Thanks.

    int ledPin1= 2;
    int ledPin2 = 4;
    int ledPin3 = 7;

    void setup(){
      pinMode(ledPin1, OUTPUT);
      pinMode(ledPin2, OUTPUT);
      pinMode(ledPin3, OUTPUT);
      }

      void loop(){
      digitalWrite(ledPin1, HIGH);
      delay(500);
      digitalWrite(ledPin1, LOW);
      delay(500);

      digitalWrite(ledPin2, HIGH);
      delay(1000);
      digitalWrite(ledPin2, LOW);
      delay(1000);

      digitalWrite(ledPin3, HIGH);
      delay(1500);
      digitalWrite(ledPin3, LOW);
      delay(1500);
        }

So far this is the code. But it delays the whole program. Need leds on at given times.

title: Making three LED's blink at given times

Answers: 3

body:
EDIT: I just love Finit State Machines and templates to do some simple tasks:

    class FSM {
      public:
        using Handler = void(*)(FSM &);

        FSM(Handler hnd) : m_func{hnd} {}

        void check(uint32_t ts = millis()) {
          if (m_next < ts) {
            m_func(*this);
          }
        }

        void delay(uint32_t _delay) {
          m_next += _delay;
        }

        void nextState(uint8_t state) {
          m_state = state;
        }

        uint8_t state() { return m_state; }

      protected:
        Handler   m_func;
        uint8_t  m_state = 0;
        uint32_t  m_next = 0;
    };

    template <uint8_t PIN, uint32_t HIGH_DELAY, uint32_t LOW_DELAY> void pin_fsm(FSM & fsm) {
      switch (fsm.state()) {
        case 0:
          pinMode(PIN, OUTPUT);
          // fall through
        case 1:
          digitalWrite(PIN, HIGH);
          fsm.delay(HIGH_DELAY);
          fsm.nextState(2);
          break;
        case 2:
          digitalWrite(PIN, LOW);
          fsm.delay(LOW_DELAY);
          fsm.nextState(1);
          break;
      }
    }

    FSM fsms[] = {{&pin_fsm<2,500,500>}, {&pin_fsm<4,1000,1000>}, {&pin_fsm<7,1500,1500>}};

    void setup() {

    }

    void loop() {
      auto ts = millis();
      for (FSM& fsm : fsms) fsm.check(ts);
      delay(1);
    }

-----------------

The code should be working, so as mentioned before in that duplicate thread, `220k` is far bigger than it should be. So just use `220R` (`= 220 Ohms`) instead of `220k Ohms` (`= 220000 Ohms`).

And if it's not working even with correct resistor, your LED is connected in reversed direction. Try the builtin LED on pin 13. That one must be working. Anyway you should read something about [LEDs][1].

[![enter image description here][2]][2]

  [1]: http://www.societyofrobots.com/electronics_led_tutorial.shtml
  [2]: https://i.stack.imgur.com/mpTdj.png

body:
How about this? Basically each loop is 1sec, and each LED has it's own counter which increases. If the counter is higher than the LED number/onTime, the LED is off for that loop and the conter reset, otherwise LED is on.

    uint8_t LED[3] = { 2, 4, 7 };
    uint8_t LED_COUNTER[3] = { 0, 0, 0 };

    void setup() {
      for (int i = 0; i < 3; i++) {
        pinMode(LED[i], OUTPUT);
      }
    }

    void loop() {
      for (int i = 0; i < 3; i++) {
        if (LED_COUNT[i] = i) { LED_COUNT[i] = 0; }
        else {
          digitalWrite(LED[i], 1);
          LED_COUNT[i] += 1;
        }
      }
      delay(1000);
    }

body:
You could start by drawing a time graph, like this:

    LED 1   # # # # # # # # # # # # # # # # # #
    LED 2    ##  ##  ##  ##  ##  ##  ##  ##  ##
    LED 3      ###   ###   ###   ###   ###   ###
            <-period 1-><-period 2-><-period 3->

As you see on the graph, the whole sequence repeats itself every
12 seconds. Then, you can just write down all the pin toggles for
12 seconds and let the loop repeat itself:

    void loop() {
        digitalWrite(ledPin1, HIGH);
        digitalWrite(ledPin3, LOW);
        delay(1000);
        digitalWrite(ledPin1, LOW);
        digitalWrite(ledPin2, HIGH);
        delay(1000);
        digitalWrite(ledPin1, HIGH);
        delay(1000);
        digitalWrite(ledPin1, LOW);
        digitalWrite(ledPin2, LOW);
        digitalWrite(ledPin3, HIGH);
        delay(1000);
        digitalWrite(ledPin1, HIGH);
        delay(1000);
        digitalWrite(ledPin1, LOW);
        digitalWrite(ledPin2, HIGH);
        delay(1000);
        digitalWrite(ledPin1, HIGH);
        digitalWrite(ledPin3, LOW);
        delay(1000);
        digitalWrite(ledPin1, LOW);
        digitalWrite(ledPin2, LOW);
        delay(1000);
        digitalWrite(ledPin1, HIGH);
        delay(1000);
        digitalWrite(ledPin1, LOW);
        digitalWrite(ledPin2, HIGH);
        digitalWrite(ledPin3, HIGH);
        delay(1000);
        digitalWrite(ledPin1, HIGH);
        delay(1000);
        digitalWrite(ledPin1, LOW);
        digitalWrite(ledPin2, LOW);
        delay(1000);
    }

This was the simple, albeit tedious solution.

The smart solution is to go through the [Blink Without Delay][] Arduino
tutorial. You will see that, once you start using `millis()` instead of
`delay()` for managing your timings, blinking three LEDs instead of one
is completely trivial.

[Blink Without Delay]: https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay


body:
I'm trying to print some data to and from an **ATtiny85** via serial, using the `SoftwareSerial` library.  So far I've tried these setups with no results:

 - 1/8MHz clock
 - baud rates from *9600* to *57600* (library doesn't seem to support higher rates)
 - printing to a newline or a single one
 - packing up a `char` array just as much as a `String` and then printing it
 - `Tx`ing/`Rx`ing through an Arduino Nano/Uno/Mega or a cheap USB-Serial port

Reading up on the subject seemed to suggest that some values I was passing (such as '1000') might have been erroneously interpreted as EOL characters breaking the code, but attempts with different values (i.e. 845) returned the same failures.

As you might have guessed I'm writing code with the ArduinoIDE, and no errors are returned when compiling and uploading. Many other parts of the project involving serial work just fine, and I can communicate with the ATtiny on pretty much any of the above setups (actually packing up the `String` or `char[]` crash the whole thing).
The 'Ready' at the end of the setup is also printed fine, and the loop runs as long as it won't encounter any of the above issues.

Here's the code:

    int VALUE = 1000;
    int ANOTHER = 12;

    #include <SoftwareSerial.h>
    SoftwareSerial tSerial(3,4);

    void _serialEvent() {
      if (tSerial.available()) {
        char mode = tSerial.read();
        if (mode == '?') {
          tSerial.println("someTextHere 1.23moreText");
          tSerial.print("value:");
          tSerial.print(VALUE);
          tSerial.print(";another:");
          tSerial.println(ANOTHER);
        }
        else if ...
      }
    }

    void setup() {
      tSerial.begin(57600);
      ...
      tSerial.println("Ready");
    }

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

title: ATtiny serial.print() crash with INTs

Answers: 1

body:
It is much better to store string literals in the FLASH only. In Arduino there is `__FlashStringHelper` class and [`F()` macro][1] ensures that correct version of `print` method is used and that the string literal is not copied into the ram before it's printed.

Basically if you don't have enough memory, using lots of string literals results in stack overflows, coruption and/or returning to random adresses and it looks like crashes/resets.

  [1]: http://playground.arduino.cc/Learning/Memory


body:
I am trying to connect a Dagu DG01D motor to my Arduino Uno. First I tried connecting the black wire to `GND` and the red wire to digital pin `7`. My code:

    void setup() {
      pinMode(7, OUTPUT);
      digitalWrite(7, HIGH);
    }

    void loop() {
    }

When I connected the motor, it wouldn't turn, but would rotate a little when turned in one direction. However, when I connected the red wire to `3.3V` or `5V`, the motor turned quickly as expected. **Why didn't writing `HIGH` to pin `7` work?**

I already verified that I can connect and run code on the Arduino by turning on the LED by replacing pin `7` with `13`. I also tried running the same code on a SparkFun RedBoard, with similar results.

title: Motor running slowly when connected to digital pins, but fine with 5V pins

Answers: 1

body:
> No Load Current: 190mA (250mA MAX)

You're not getting that out of a ATmega328P GPIO. Use a driver instead.


body:
I am currently using an Arduino Uno and creating an LCD simulator that works by sending LCD data through the hardware UART (serial interface). This LCD data is very short in length; in this case, it's 2 bytes. The LCD simulator has [already been made](https://github.com/oldmud0/LCDViewer), and it is capable of detecting these LCD packets on the serial port and using them to control the simulated LCD.

However, I don't want to disturb the other traffic passing through the serial port; in this case, it's just text. The problem is that most serial monitors are able to pick up the LCD packets, which aren't supposed to be printed out because they appear as gibberish.

For now, I'm prefixing these short LCD packets with two magic numbers for it to be detectable by the LCD simulator alongside non-LCD traffic, and perhaps removable by a modified serial monitor.

I thought about using ASCII control characters to inform regular terminals that following data must not be printed, but there does not seem to be a specific control character to "hide" text/data; the closest thing there is is the `BS` character. All other control characters seem to give an inconsistent result among terminals - i.e. ESC doesn't actually hide text with the Windows console host, but it does with mintty.

My goal is to not have to integrate my own serial monitor and force others to use it if there is traffic present that can only be read by the LCD simulator. I want to allow others to use their own terminals and serial monitors to exchange textual data with the Arduino while seamlessly having LCD packets being sent invisibly and "under the hood."

Is this possible? Can I mix different types of data across the same serial port? If not, what are my options, or am I essentially forced to "reinvent the wheel" by making my own protocol that can mix the two types of traffic?

title: Sending textual and nontextual data simultaneously across a serial port

Answers: 3

body:
The idea that sundry terminal programs can cleanly deal with binary data intended for your LCD simulator doesn't seem realistic.  Instead, look for a method to suppress the binary data when the Arduino isn't talking to an LCD simulator.

For example, during startup the Arduino could send some fixed text and a number to the host, and if the simulator is running, it would reply to the Arduino with some other fixed text and the 9's complement of the number.  If the Arduino doesn't get such a reply within a couple of seconds, it turns off LCD-simulation data transmission.

body:
I would simply send the data as ASCII, in the form of hex bytes. It wil make your two bytes become four, plus the two "leader" characters to uniquely identify them becomes six. This minor overhead can probably be absorbed.

If you have much more binary (non-ASCII) data, you could look at using a different encoding format such as Base64. This only has a 2 character overhead for every 6 bytes of binary data.

You don't mention what data rate you use, either in baud rate or "packets per second", but if you're reading it on a serial monitor it can't be very much.

body:
If I were to do something like this on Linux, I would probably have the
LCD simulator sit between the Arduino and the serial monitor, like this:

                        +---------------------------------------------------+
                        |                    host computer                  |
    +-------------+     | +-------------------+         +-----------------+ |
    |             |     | |                   |         |                 | |
    | Arduino  UART-----tty  LCD simulator    ptmx----pts  Serial monitor | |
    |             |     | |                   |         |                 | |
    +-------------+     | +-------------------+         +-----------------+ |
                        +---------------------------------------------------+

For this, you have to:

1. open the serial port connected to the Arduino (“tty” on the figure)
2. create a pair of [pseudo-terminals][] (ptmx/pts)
3. open the master side of the pair (ptmx)
4. ask the user to open the slave side (pts) with his serial monitor
5. forward all traffic but the LCD control messages between the Arduino
   and the pseudo-terminal.

I don't know how this works on MacOS, but since the whole
pseudo-terminal concept is a standard Unix feature, I would expect it to
work in a similar way on MacOS and Linux. But then I have no idea how
hard it would be to port this to Windows.

[pseudo-terminals]: https://linux.die.net/man/7/pty


body:
I'm trying to use the serial communication to work between a naked AVR Atmega328p and a computer (OS X and Linux Ubuntu).

I can program the atmega (using a pololu programmer), I make it blink a LED on a breadboard, it works fine.

I am using the Arduino libraries to facilitate the task. And they seem to work fine (using delay, digitalRead, digitalWrite, etc).

I use a USB-to-TTL CH340 chip bought on [internet](https://www.aliexpress.com/item/USB-to-TTL-converter-UART-module-CH340G-CH340-3-3V-5V-switch/32392228218.html?spm=2114.13010608.0.73.h4eui1). The CH340 works fine, it is recognised both on Ubuntu and OS X, and the loopback test works (Put a jumper between the TX and RX line, launch `screen`, type something and it comes back in the terminal), so I assume the CH340 is properly recognise and works.

Then, I plug the CH340 on my board. The 5V on the + column of the breadboard, the GND to the - column. The circuit works, my LED blinks as requested. The loop function looks like this:

    void setup() {
      Serial.begin(9600);
      pinMode(9, OUTPUT);
    }

    void loop() {
      digitalWrite(9, HIGH);   // sets the LED on
      delay(30);                     // waits for a second
      digitalWrite(9, LOW);    // sets the LED off
      delay(70);                     // waits for a second
      Serial.println("loop end");
    }

As you can see, at the send of the loop I send a string on the serial line. Now, I see the blue LED blinking on the USB-to-TTL converter, so it is definitely receiving data. But when I try to connect like so:

    screen /dev/cu.wchusbserialfd110 9600

on OS X, or

    screen /dev/ttyUSB0 9600

on Ubuntu, nothing is displayed. I just get a black terminal.

Is the Arduino Serial works with Atmega328 ? I suppose so, as it is the same microcontroller than on the Arduino. Any idea of what I am doing wrong?

**Update:**

More details to answer Christ Stratton question:

My low fuse is 62: 01100010. So, according to the specifications, the internal clock is used and set at 1MHz.

I programmed the Atmega using my own test bed, a Pololu programmer (as described in the book [Practical AVR Microcontrollers: Games, Gadgets, and Home Automation with the Microcontroller Used in Arduino](https://www.amazon.com/Practical-AVR-Microcontrollers-Automation-Microcontroller/dp/1430244461)) and avrdude (through the use of platformio).
This is the command line used by platformio to flash the ROM:

    /Users/[user]/.platformio/packages/tool-avrdude/avrdude -v -p atmega328p -C /Users/[user]/.platformio/packages/tool-avrdude/avrdude.conf -c avrispv2 -B 10 -e -b 115200 -P "/dev/cu.usbmodem00149121" -U flash:w:.pioenvs/pololu/firmware.hex

According to avrdude documentation, `-B 10` means bitclock is set to 10us (microseconds) so a clock at speed 100Khz.

Now if I set this -B option to 1 (1Mhz), I can't program the Atmega anymore. Avrdude just timeout:

    avrdude stk500v2_ReceiveMessage(): timeout

title: Atmega328p programming with Arduino libraries

Answers: 1

body:
The clock rate of your board must match the clock rate defined in the board file you used to compile your sketch.  If it does not, the baud rate will differ by the same factor.

If the actual baud rate so achieved is a valid one, you can temporarily achieve communication by setting the computer to that baud rate, but all delays and other clock-rate related functions will be off.

You should use or create a board file entry that matches your board, or use a standard clock source / clock divier setting for which there already is an entry.


body:
My personal choice is to purchase from the .cc (or adafruit) for new boards. YMMV.  Craigslist locally of course has generic and .org boards now and then.

If I get a .org board on craigslist, will I need to use their fork of the IDE for the board to be recognized by the IDE?

My feeling is "yes" but I wanted to confirm.

A board there just now is Arduino mega 2560 from the .org.  Would I have to use their flavor of the IDE?

Thank you for your thoughts- photo of the board I am considering is attached.

[![CL mega2560][1]][1]

  [1]: https://i.stack.imgur.com/ZMQEk.jpg

title: Arduino Mega 2560 from .org- which IDE works?

Answers: 1

body:
Arduino.org and arduino.cc have come to a agreement.
As such all incompatibilities that exist (I don't think they exist for this mega board) will be solved with next version of the Arduino IDE as if it is a board of their own.


body:
I have one ESP(1) opening an AP and running a server on it. The other ESP(2) is running a client on it and is connecting to the AP and after that trying to connect to the host server. The connection to the AP does succeed but the connection to the host always fails and I cannot figure out what the problem is here. Testing the server via netcat and packetsender works fine. Connecting to it via telnet fails because the connections gets closed by the "foreign host".

*Server Sketch*

    #include <ESP8266WiFi.h>

    const char* ssid = "artex11";
    const char* pw = "getmenow11";
    WiFiServer server(80);
    WiFiClient client;

    void setup() {
      Serial.begin(115200);
      //setup AP
      WiFi.softAP(ssid, pw);
      Serial.println("AP started at: ");
      Serial.print(WiFi.softAPIP());
      server.begin();
      Serial.println("Server started...");
    }

    void loop() {
      client = server.available();

      if(client){
        Serial.println("Client connected!");
        Serial.print("HasClient: ");
        Serial.println(server.hasClient());
        char message = client.read();
        Serial.printf("Message: %c\n", message);
      }
    }

*Client Sketch*

    #include <ESP8266WiFi.h>

    const char* ssid = "artex11";
    const char* pw = "getmenow11";
    const char* host = "192.168.4.1";
    const int port = 80;

    void setup() {
      Serial.begin(115200);
      WiFi.begin(ssid, pw);
      Serial.println("Connecting to AP");
      while(WiFi.status() != WL_CONNECTED){
        delay(500);
        Serial.print(".");
       }
      Serial.println(" connected");
    }

    void loop() {
      WiFiClient client;
      Serial.println("Connecting to host");
      if(!client.connect(host, port)){
        Serial.println("...connection failed!");
        Serial.println("Retrying in 5 seconds...");
        delay(5000);
        return;
      }
      client.print("A");
      Serial.println("...TCP message fired!");
      delay(2000);
    }

title: WiFiClient.connect() does fail all the time (ESP8266 Core for Arduino)

Answers: 2

body:
If the server has a default IP address of 192.168.0.1 and the client has an IP address of 192.168.4.1 my guess is they won't be able to talk because you are using a 24 bit mask.

The subnet mask defines the number of bits that makes up the subnet, so if you were using the two addresses above and had a mask of 255.255.255.0 or 24 bits then the subnets you were using would be 192.168.0 and 192.168.4.  To cross subnets you need some form of routing process (usually a router, switch that can route, etc).

So you need to either change the mask or, stick both devices on the same subnet.
(Don't rely on defaults, when they change your code breaks)

body:
The problem was this missing piece

`WiFi.mode(WIFI_STA);`

If omitted  it seems the WiFi is starting in Station & AP mode - so I was able to connect to the other AP but not to connect to the host because of reasons.