texts: Figuring out IR sensor PWM frequency with Arduino

texts:
I'm trying to verify the pulse width of an IR receiver I "borrowed" from one of those cheap RGB controllers (like thisone) with an arduino nano. But the data I'm getting right now is about 3.4KHz and not the 38KHz I expected.

I'm trying to measure it by connecting the data pin of the IR on INT0 and listening for any change, if the pin goes low I start a measurement, if it goes high I stop the measurement and read out the value.

I'm using Timer1 and no prescaling

My code is as followes

#include <util/delay.h>

#define inpin 1 << PIND2
#define timeron 1 << CS10 //timer no prescale

bool wasTiming = false;
short i = 0;

volatile short timings[20];
volatile bool print = false;

volatile short seconds = 0;

int main()
{
    USART.begin();

    _delay_ms(500);
    USART.writeln("Arduino online");

    DDRD = 0;

    TCCR1A = 0; //no compares, normal counter mode
    TCCR1B = 0; //clock off

    EICRA = 1 << ISC00; // Any change INT0 (PD2)
    EIMSK = 1 << INT0; // INT0 interrupt enable

    sei();

    char buff[20];
    for (;;)
    {
        if (print)
        {
            print = false;

            for (short j = 0; j < 20; j++)
            {
                sprintf(buff, "% 6d ticks", timings[j]);
                USART.writeln(buff);
            }
        }
    }
    USART.end();

    return 0;
}

ISR(INT0_vect)
{
    if (PIND & inpin) //pin high
    {
        if (wasTiming)//
        {
            TCCR1B = 0; //timer clock off
            timings[i] = TCNT1;
            TCNT1 = 0; //empty timer register
            wasTiming = false;

            i++;
            if (i == 20)
            {
                print = true;
                i = 0;
            }
        }
    }
    else // pin low
    {
        if (!wasTiming)
        {
            TCCR1B = timeron; //timer clock on
            wasTiming = true;
        }
    }
}

and the output data is

 13902 ticks
  8865 ticks
  9961 ticks
  8877 ticks
  9968 ticks
  9842 ticks
  8506 ticks
  9896 ticks
  9585 ticks
  9865 ticks
  9541 ticks
  8853 ticks
  9545 ticks
  8888 ticks
  9885 ticks
  9954 ticks
  8515 ticks
  9885 ticks
  8909 ticks
  9874 ticks

on average that looks like about 9500 ticks, which leads me to the following calculation: (16,000,000 / 9,500) * 2 = 3,368.4Hz

Am I doing something wrong here? Or is the data that I'm getting correct, in which case, how would I go about turning that into 1's and 0's?

I'm not really looking for off-the-shelf solutions, half the fun of doing this is figuring it out myself. Eventually I'm gonna build my own RGB controller with this to replace that cheapo thing I already have (it has a few flaws I would like to correct).


texts: How to calculate the needed voltage and current to supply for Arduino

texts:
I have Arduino MEGA and I'm connecting to it 5 servomotors.

{ 3 TowerPro M995
Basic Information

Modulation:  Digital
Torque:  4.8V: 130.5 oz-in (9.40 kg-cm)
6.0V: 152.8 oz-in (11.00 kg-cm)

Speed:  4.8V: 0.20 sec/60°
6.0V: 0.16 sec/60°

Weight:  1.94 oz (55.0 g)
Dimensions:
Length:
1.60 in (40.7 mm)

Width:
0.78 in (19.7 mm)

Height:
1.69 in (42.9 mm)
Motor Type:  3-pole
Gear Type:  Metal

2 Towerpro M996R

Basic Information

Modulation:  Digital
Torque:  4.8V: 130.5 oz-in (9.40 kg-cm)
6.0V: 152.8 oz-in (11.00 kg-cm)

Speed:  4.8V: 0.19 sec/60°
6.0V: 0.15 sec/60°

Weight:  1.94 oz (55.0 g)
Dimensions:
Length:
1.60 in (40.7 mm)

Width:
0.78 in (19.7 mm)

Height:
1.69 in (42.9 mm)
Motor Type:  3-pole

}

So how can I calculate the voltage and current needed to supply this Arduino?


texts: Common Wire sizes for connecting peripherals to arduino

texts: Please don't judge me for asking this question i have never touch arduino before but We plan to use it in our thesis we are doing a budget plan and it must include wires. can anyone tell me the common wire sizes used? This is to estimate the prices.


texts: Can I know a code for simple IR receiver. I using external trasmitter, and when the receiver (on arduino board) get the input (detect signal from transmitter), LED will be HIGH.


texts:
for the purpose of learning, I'm trying to have a kind of digital/binary input where I'm using 3 buttons but only 2 input pins.

I thought of

01 = Button 1
10 = Button 2
11 = Button 3

My first attempt was like this:

I left the resistors out right now. The problem here is of course, that it doesn't matter what button I press, both LEDs are lighting up.

I used 2 Diodes in my second attempt:

This time, S1 and S2 work as expected, but S3 brings only one LED up.

Now I was wondering how I can wire things up correctly, using as little components as possible and having in mind, that I'm going to use an Arduino instead of the LEDs.

Thank you for any help!


texts:
So, I found an interesting article the other day, and I'm trying to build a project that could benefit from a battery-backed memory (no wear limits, but keeps data over power cycling). The article lists how an extremely small current from an LED (acting as a photocell in the lit room) accidentally powered the AVR during a RAM-endurance test.

But, what if this is done on purpose with a battery?

(Article here: https://wp.josh.com/2014/03/03/the-mystery-of-the-zombie-ram/)

The problem with this idea (since the RAM can already be backed up, as shown in the article, though the author does not seem to have considered this) is that I need a way to keep an array of memory ignored by the C initializer. It would be the height of hilarity to have the memory survive the power-off event only to be nuked by the chip's powerup reset code. The listed example at that article would work, for the first requirement, but would break almost anything else I might try to do (since it overrides the entire initializer). (Comment on the reset issue: https://wp.josh.com/2014/03/03/the-mystery-of-the-zombie-ram/#comment-598)

Also, assuming I tried this, would I simply damage the pin rather than provide power? I plan to use a pin continually set to input attached to the positive side of a lithium coin cell, with a common ground. In theory, powering the AVR (and I think at any voltage) through the VCC pin would cause the chip's diodes to disconnect the battery, but if it's unplugged, the core would receive enough power to keep the RAM alive.

Of course, my question is whether it would instead stupidly try to keep the core running when power is disconnected (in the original article, the nanowatts from the LED couldn't do that, so it's forced to shut down, but I don't know if this is solely due to power limits or if it would shut down the main systems if there's no connection over VCC). In this case, it might try to draw more than the 1mA rating over that parasitic supply, and try to power the entire chip when I don't want it to (thus frying the clamping diode or something equally bad).

I wonder if it would be possible simply to put a large resistor (10K? 1M?) in series with the battery in this case? That would automatically limit the supply to less than 1mA.


texts: Arduino UNO R3 as flight control plus brushless motor driver

texts:
I am trying to build an RC plane using an arduino UNO as the flight control board.

I found a code on the arduino forum for driving a 3 phase AC motor with an arduino.
http://forum.arduino.cc/index.php?topic=8642.0

I believe it will also work for brushless motors commonly used in RC airplanes.This will eliminate the need for an ESC (Electronic Speed Controller) which are pretty expensive.

Now I plan to use a single arduino board to communicate with the nrf2l01 rf receiver , control the servos as well as drive the brushless motor(mentioned above).

In each cycle of the code the arduino will be fetching data from the receiver,sending a pwm signal to the servos and setting which two phases of the brushless motor will be high and which one will be low.
Since so many things are being done in each cycle the phase change of the brushless motor might not be fast enough and this might hamper the motor speed? Or is the arduino  fast enough to handle all this and it won't affect the speed noticeably.


texts:
I am fairly new to working with sensors and Arduino. I am working on a project using Max MPS to control the volume of three audio files. There will be three framed photos, each having its own IR sensor and audio file. So when someone gets closer to the sensor, the volume of the corresponding file gets louder. Is this doable? The samples I have seen with the board I have and an IR sensor only use one. I'm assuming I'll be able to use the breadboard I have to add more sensors like I've done in the past with photocell sensors but I have yet to test it since it's in the mail. Just hoping to get ahead of any issues I may face and see if I should order any other equipment.
I ordered 3 of these IR sensors and this is the Arduino kit I am working with.
Sorry if I may not be describing it in enough detail, but thanks in advance!


texts: ESP8266 not running when connected to 3V3

texts:
I have a simple code that uses a tactile button and ESP8266.  I have one wire going from GND to one leg and one wire going from D3 to the other leg.  Works perfectly.  When I start it up, I have write statements in setup() which show that it is starting up and working.
I wanted to switch to a Touch Sensor.  I added a wire from one of the 3V3 to the VCC of the sensor.  If I do this while the program is running it seems to work... (it recognizes when I touch the sensor).  However, if I reset the ESP, then it no longer runs.  I see nothing in the serial window.
I tried to narrow the problem down and here's where I'm at...

The ESP is connected via USB to the computer so I can look at the console window to track how it's running.
I have a wire connected to D3 and GND (but the ends aren't connected to anything).  I reset the ESP and I see in the console window that it is printing out the expected print statements in setup().
I add a wire to 3V3 (it is not connected to anything).  I reset the ESP and now no print statements are in the console window - so I believe it is not running.

Why?  I thought 3V3 was to connect to sensors to power them.  Not input to the ESP.  So what am I missing?
RESOLVED:  I randomly picked the wrong GPIO to use... I switched to D1 and it now works ok.


texts: Ultrasonic sensor returns random values on external power supply

texts:
my Problem is, that I get random values from my ultra sonic sensor if my arduino is connected to any external power supply (vin port 30) on my arduino nano.

If I power up from the laptop usb port, I get consistent values.

I have tested 3 different power supplies between 7-17V and up to 2000mA.
I have tested this on 2 different nano boards.
Also tested with an extra 2000uF capacitor between vin and gnd

pls help if you got an idea :)


texts: What's the difference between pow and sqrt in this code?

texts:
I'm not the best at Arduino so I'm sorry for my "noobiness".

I'm extending some code that I found online to work on the gyroscope that I'm building.

I'm wondering what the difference is between pow and sqrt in this code.

I'm also wondering what the 180/pi is used for. I haven't gotten my mind around this part yet.

arx = (180/3.141592) * atan(ax / pow((ay, 2) + pow(az, 2));

What's the difference here?

ary = (180/3.141592) * atan(ay / sqrt(square(ax, 2) + square(az, 2)));


texts: Understanding writing to input pins and pull up resistors

texts:
I am new to Arduino, and am trying to understand the following code.  The question is: Is my understanding correct, or if not, what is happening here?

I have to reverse engineer an existing undocumented project, based on Marlin firmware for 3D Printers.  The relevant lines from the source are:

#define DIO87_PIN               PINE2
#define DIO87_RPORT             PINE
#define DIO87_WPORT             PORTE
#define DIO87_DDR               DDRE
#define DIO87_PWM               NULL

#define MASK(PIN)  (1 << PIN)
#define _TOGGLE(IO)  do {DIO ##  IO ## _RPORT = MASK(DIO ## IO ## _PIN); } while (0)
#define TOGGLE(IO)  _TOGGLE(IO)

TOGGLE(87);

1) Reducing this code gives me:
DI087_RPORT = 1 << DI087_PIN

2) Which reduces further to:
PINE = 1 << PINE2
3) Which reduces further to:
PINE = 00000100

4) I understand this to mean that we are setting Pin 2 of the Inputs Register (of Port E) to "High". (and are setting the other 7 pins to low)

5) I understand this to mean, as we are writing to an "Input", that we are enabling the internal pull-up resistor on Port E Pin 2.
(EDIT: I have made a mistake here in point 5: to enable a pull-up resister, you write to a pins OUTPUT register, not it's INPUT register. (but you must write to it's output register when it is in "input mode")

Questions:

Is my understanding and work-through above correct?
If yes, does this also mean that we are also disabling the pull-up resistors to the other 7 Input Pins at the same time?

I am confused by the "TOGGLE" code given above - it seems that it is "destructive" in the sense that by "toggling" the input resistor on one pin, you also disable the resistors on all other pins?  Would it not make more sense to just toggle the one pin with a bitwise or.
e.g:
PINE = PINE | 1 << PINE2


texts:
I'm trying to use a template function, but I get an error
home/guy/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: sketch/emptyCode.ino.cpp.o: in function `startIOTservices()':
/home/guy/Documents/git/Arduino/HomePi/emptyCode/emptyCode.ino:37: undefined reference to `void myTest::funcOne<bool>(bool)'
/home/guy/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: sketch/emptyCode.ino.cpp.o: in function `setup':
/home/guy/Documents/git/Arduino/HomePi/emptyCode/emptyCode.ino:70: undefined reference to `void myTest::funcOne<bool>(bool)'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

inside .cpp file:
myTest::myTest()
{
        Serial.println("start");
}

template <class T1>
void myTest::funcOne(T1 arg)
{
        Serial.println(arg);
}

inside .h file:
class myTest
{
public:
    myTest();
    template <class T1>
    void funcOne(T1 arg);
};

and calling it from .ino file:
testA.funcOne(true);
What am I doing wrong ?
EDIT 1:
complete .h .cpp files - which originaly belongs to myJSON library which are deleted in this snip
#ifndef myJSON_h
#define myJSON_h

#include "Arduino.h"
#include <ArduinoJson.h>
#include "FS.h"

#define DOC_SIZE 1000

class myJSON
{
};

class myTest
{
public:
    myTest();
    template <class T1>
    void funcOne(T1 arg);
};

#endif

.cpp file
#include "Arduino.h"
#include "myJSON.h"
#include "FS.h"
#include <ArduinoJson.h>

#define LOG_LENGTH 4

myJSON::myJSON(char *filename, bool useserial)
{
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

myTest::myTest()
{
        Serial.println("start");
}

// template <typename T1>
void myTest::funcOne(T1 arg)
{
        Serial.println(arg);
}


texts: analogRead() doesn't read more than 500Hz

texts:
I connected a wave generator to the analog pins to read the frequencies of the waves generated. I used different frequencies of sine waves with a minimum of 0V and maximum of 5V.
Whenever the voltage is greater than 2.5V, I made one of the digital pins HIGH, and LOW when less than 2.5V. Now by measuring the square wave from the digital pin, it always has the same frequency as the sine waves until 500Hz.
After 500Hz, the square wave's frequency doesn't agree with the sine wave, which made me think that the problem is in the analogRead(). Is there a way to have higher frequency?
Code:
const int sensorPin1 = A0;
const int sensorPin2 = A1;
const float maximumPower = 2.5;
int calibration = 1;

void setup() {
  Serial.begin(57600);
  pinMode(6, OUTPUT);
  digitalWrite(6, LOW);
}

void loop() {
  int voltage2 = 3;
  int voltage1 = 3;
  int sensorVal = abs(analogRead(sensorPin1) - analogRead(sensorPin2));
  float ratio = abs(analogRead(sensorPin2) / analogRead(sensorPin1));
  float voltageDifference = (sensorVal / 1024.0) * 5.0;
  float power = calibration * voltageDifference;
  if (power >= maximumPower || voltage1 <= 1 || voltage2 <= 1) {
    digitalWrite(6, LOW);
  }
  else {
    digitalWrite(6, HIGH);
  }
}


texts: Use timer0 without affecting millis() and micros()

texts:
I'm writing a library which needs an ISR to turn off an LED some time after it was turned on. Since it's all about turning an LED on and off it doesn't need to be very precise. On the other hand I would like to use this library in a program where timer1 and timer2 are given out to other (more important) tasks, and I also need the millis() and micros() functions. Last, I'm using an ATmega328P microcontroller, which only has 3 timers (and I can't easily replace it with another one).

So I was wondering if I could attach an ISR to timer0 without affecting the above Arduino functions, and – if that can be done – what would be the restrictions of such an ISR (e.g. I suppose I could not use all the timer/interrupt modes...) and the disadvantages or side effects in using this timer in a non-Arduino library and the Arduino millis() and micros() functions.

Thanks in advance for any answer!


texts:
I had a very common question. Why a additional MEGA used in most of the Arduino Boards. Arduino board Mega2560 also have a MEGA16U2 controller on board which i think is used for programming via USB. Is there any other specific usage of atmega16 on arduino board.

Thanks


texts: Problem in RS485 Communication between Arduino and PC

texts:
I'm trying to sending and receiving data via RS485 communication. Interfacing Arduino and PC(laptop)
using SN75176 RS485. I wrote a program to send a string "Hello" from arduino via Tx pin. My intention is to receive
the "Hello" string in my PC's hyperterminal. After uploading the program im receiving junk data. The baud rate i've mentioned in
my program and i gave in hyperterminal are same. I've checked the wire connection, it is ok. Then, what is the problem?

Code:

#include <SoftwareSerial.h>
int Txpin = 1;
int ditpin = 5;  //for 1st rs485
int ditpin1 = 2; //for 2nd rs485
void setup()
  {
          // put your setup code here, to run once:
    Serial.begin(9600);
    pinMode(Txpin,OUTPUT);
    digitalWrite(ditpin, HIGH); //For transmit data from arduino
    digitalWrite(ditpin1, LOW); //For receive data to hyperterminal
  }

void loop()
  {
    Serial.println("Hello\r\n");
    delay(1000);
  }

Wire connection:


texts: `servo.attach()` paralyzing (one) motor on L298N

texts:
I have 2 DC motors (well, 4; but each pair is controlled by the same "signals") connected via a L298N, which is connected to the Arduino. In addition, I have a servo motor connected to the Arduino.

When I run the following program (in reality, it's a bigger program; however, I've managed to chiseled it down to the following):

#include <Servo.h>

const int servoPin = 3;
Servo servo;

const int LMotorsSpeedPin = 5;
const int RMotorsSpeedPin = 10;
const int LMotorDirectionBit1Pin = 7;
const int LMotorDirectionBit2Pin = 6;
const int RMotorDirectionBit1Pin = 8;
const int RMotorDirectionBit2Pin = 9;
const int MotorSpeed = 150;

void setup()
{
  // 1
  pinMode(servoPin, OUTPUT);
  servo.attach(servoPin);

  // 2
  pinMode(LMotorsSpeedPin, OUTPUT);
  pinMode(RMotorsSpeedPin, OUTPUT);
  pinMode(LMotorDirectionBit1Pin, OUTPUT);
  pinMode(LMotorDirectionBit2Pin, OUTPUT);
  pinMode(RMotorDirectionBit1Pin, OUTPUT);
  pinMode(RMotorDirectionBit2Pin, OUTPUT);

  // 3
  digitalWrite(LMotorDirectionBit1Pin, LOW);
  digitalWrite(LMotorDirectionBit1Pin, HIGH);
  analogWrite(LMotorsSpeedPin, MotorSpeed);

  // 4
  digitalWrite(RMotorDirectionBit1Pin, LOW);
  digitalWrite(RMotorDirectionBit1Pin, HIGH);
  analogWrite(RMotorsSpeedPin, MotorSpeed);

  // 5
  delay(10000);
}

void loop() {}

1 Sets up servo.
2 Sets up L298N pins.
3 Sets up left motor data.
4 Sets up right motor data.
5 Tests the code above for 10 [s].

I assume that you'll need some experience with the L298N; however, here's the gist.

*MotorsSpeedPin sends each motor what speed (MotorSpeed 0-255) they must go (via PWM).
Data into a pair of *MotorDirectionBit*Pin tell each motor what direction to go (i.e. back 01, stop 00 11, right 10).

When I run the program above, only the left motor runs. However, if I comment out 1 (which essentially renders the servo useless), both left and right motors start to work.

I find this problem quite odd. What does the servo code have to do with the motor code (and only one at that!)?


texts: iterate through 8 thermocouple sensors (MAX31856)

texts:
I have 8xMAX31856 and I am trying to use the Adafruit library. Instead of writing all 8 thermocouple channels each time in code (and wasting memory), I want to store the objects in an array and loop through them periodically.
Here is my code:
Adafruit_MAX31856 TCouple1 = Adafruit_MAX31856(2,11,12,13);
Adafruit_MAX31856 TCouple2 = Adafruit_MAX31856(3,11,12,13);
Adafruit_MAX31856 TCouple3 = Adafruit_MAX31856(4,11,12,13);
Adafruit_MAX31856 TCouple4 = Adafruit_MAX31856(5,11,12,13);
Adafruit_MAX31856 TCouple5 = Adafruit_MAX31856(6,11,12,13);
Adafruit_MAX31856 TCouple6 = Adafruit_MAX31856(7,11,12,13);
Adafruit_MAX31856 TCouple7 = Adafruit_MAX31856(8,11,12,13);
Adafruit_MAX31856 TCouple8 = Adafruit_MAX31856(9,11,12,13);

char* thermocouples[] = {TCouple1, TCouple2, TCouple3, TCouple4, TCouple5, TCouple6, TCouple7, TCouple8};

however, I am met with this error on compile:
cannot convert 'Adafruit_MAX31856' to 'char*' in initialization

Why can I not store these variables in an array and call on them later? Is there another way to do this? They work on SPI logic...


texts:
I made this simple code but I'm getting the following error

exit status 1
'RGB' does not name a type

typedef struct
RGB
{
        double r;
        double g;
        double b;
};

RGB led;

RGB func(){
  RGB temp;
  return RGB;
}

I am not getting the error on "RGB led" but just on the function.
Does anyone know a solution for this? Thanks!


texts:
I have a simple HTML file that I have uploaded as sketch data using the ESP8266 sketch data upload tool in arduino IDE. The file is 7k in size.

In the set up, I refer to the following function to read the file:

String readTemplatefile(){
  String retval ="";
  File fr = SPIFFS.open("/templatecfg.htm", "r");

  if(!SPIFFS.exists("/templatecfg.htm")){

    Serial.println("Template file not available ");
    }
    while (fr.available()){
        retval += char(fr.read());
      }

fr.close();
Serial.println("Template file = ");
Serial.println(retval);
return retval;
}

I always get 'Template file not found'. I have

SPIFFS.begin();

at the beginning of the setup function

My board is an ESP8266EX. I have wondered if it the flash size settings in the IDE that could cause this not to be found. Can anyone offer any advice on this issue. I have tried lots of different combinations of Flash size and SPIFF sizes without any luck.

Thanks in advance to any help.


texts: I am trying to communicate between Arduino and raspberry pi over SPI. I am using spidev in python and sending data to Arduino using xfer2. But I do not have an idea of how to receive bytes from Arduino. Can anyone have any idea?


texts: How much current can arduino ground absorb?

texts:
I am currently working on an LED 4x4 cube, so here is my pre planned circuit diagram.
https://easyeda.com/editor-mobile/#id=ffca9f3303f242a185b950b0bee4fa29|

I am to connect 220ohm to each positive terminals.(16)

I am to use 4 transistors(2n2222) for 4 negative layers of which, collector terminal will be connected to the negative terminal layers , base will be connected to 4 analog pins through 1k ohm, and emitter to be connected to the GND pin of arduino. Using transistor as a switch.

Can my studio ground get damaged if connected directly without a resistor.
If no?
Is there any way to make it?
Explanation with circuit diagram will highly be preferred...
Thanks for your precious time...


texts: How to run background music while the code for a game is executed

texts:
I have some background music. If I put it at the top of the void loop(), it'll first play the music and then execute the game code afterwards.

How do I have the code run while the background music is playing?


texts:
I´m completely new to the arduino and not used to work with it. Due to an project I need to know the best way to transfer Data to my Arduino Mega. The transferred file will be an sliced 3D object. Is it possible to use the built in USB port to read from a stick? Or do I have to use a PC to transfer my data?
Please help me to answer this question since I have no clue how to manage to get the sliced file to my Arduino.


texts: I want to ask a question. I am using my project xbee pro s2c to get data from arduino(temp,pressure etc.) and i am sending data another xbee module and read these data from serial port. Question is that i want to use esp8266 instead of xbee. is it possible ? can i communicate 2 esp module like xbee ?


texts: hello,i have an problem with my arduino with an lcd

texts:
i've totally done everything i could,but when i run my arduino uno with my 16*2 lcd (with i2c) . it has a higher brightness on the top and a lower one in the bottom. ive even tried putting example codes but my arduino totally freaks out, starting to change it's backlight . i cant even use lcd.print . i had tried just to adjust my lcd with a ldr , this is the code:

    // Include Wire Library for I2C
#include <Wire.h>
// Include NewLiquidCrystal Library for I2C
#include <LiquidCrystal_I2C.h>
int ldr;
int sensor=0;
int lcdb=5;

// Define LCD pinout
const int  en = 2, rw = 1, rs = 0, d4 = 4, d5 = 5, d6 = 6, d7 = 7, bl = 3;

// Define I2C Address - change if reqiuired
const int i2c_addr = 0x3F;

LiquidCrystal_I2C lcd(i2c_addr, en, rw, rs, d4, d5, d6, d7, bl, POSITIVE);

void setup()
{

  // Set display type as 16 char, 2 rows
  lcd.begin(16,2);
  Serial.begin(9600);
  lcd.setCursor(0,1);
  lcd.print("hello world");
  lcd.setCursor(0,0);
  delay(1000);
  lcd.print("hello world");

}
void loop()
{
  int ldr=analogRead(sensor);
  ldr=map(ldr, 0, 1023, 0,255);
  delay(1000);
  analogWrite(lcdb,ldr);

}


texts:
In your code https://gist.github.com/edgar-bonet/0b03735d70366bc05fc6 for homodyne detection, is there a way to make the frequency detected a range of frequencies? For example detecting between 3kHz and 4kHz?
Thanks in advance!


texts: Serial.write(buf, len) error. How to remove an error and pass an array of bytes?

texts:
int angleServo1,angleServo2 = 0;
const int axisX=A0; // ось Х подключена к A0
const int axisY=A1; // ось Y подключена к A1
int valX, valY = 0; // переменные для хранения значений осей
int datos[3];
#include <SPI.h>

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

void loop()
 {
      valX = analogRead(axisX); // значение оси Х
      valY = analogRead(axisY); // значение оси Y
      // масштабируем значение к интервалу 0-180
      angleServo1=map(valX,0,800,100,-100);
      angleServo2=map(valY,0,810,100,-100);

       datos[0] = angleServo1;
       datos[1] = angleServo2;
       Serial.write(datos, sizeof(datos));
       delay(100);
}

error: no matching function for call to 'HardwareSerial::write(int [3], unsigned int)'

how to remove an error and pass an array of bytes?


texts: Altering code to run a timer while checking for a data input

texts:
I am rather new to the Arduino world and am looking for a way to create my own tipping rain gauge with only one Arduino(micro).

I have had some help from a friend to get a loop that checks for when a switch is closed, which signals that the bucket has tipped and thus "x units" of rain have fallen. The code I have for sensing this is:

void loop()
{
  /*
    digitalWrite(4, HIGH);
    delay(500);
    digitalWrite(4, LOW);
    delay(6500);
  */
  int analogValue = digitalRead(8);

  if (analogValue==HIGH)
  {
    Serial.println(count);
    count++;
    delay(250);
  }
}

Then I developed a code to count up in 0.5 second intervals so that I could essentially time stamp when the switch from the first loop was closed/activated. The code for the timer is as follows:

void loop()
{
  while (ssec < 10)
  {
    Serial.print(hour);
    Serial.print(":");
    Serial.print(minute);
    Serial.print(":");
    Serial.print(sec);
    Serial.print(".");
    Serial.print(ssec);
    //Serial.print(" s");
    //Serial.println();
    ssec += 5;
    delay(500);
    Serial.println();
  }
  if (ssec == 10);
  {
    sec++;
    ssec = 0;
    //Serial.print(sec);
    //Serial.print(".");
    //Serial.print(ssec);
  }
  if (sec == 60)
  {
    minute++;
    sec = 0;
  }
  if (minute == 60)
  {
    hour++;
    minute = 0;
  }
  if (hour == 24)
  {
    Serial.println();
    Serial.print("DAY ");
    Serial.print(day);
    Serial.print(" COMPLETED!");
    Serial.print("Data Points: ");
    //Serial.print(count);
    Serial.println();
    Serial.println();
    hour = 0;
    day++;
  }
}

I understand that it is very hard to run these together at the same time due to the fact that I am using a delay function to run the timer.

Are there any ways to essentially run these side by side? Or a library I can use that will run the timer while i have the arduino looking for the switch to close, and I can simply call the timer when I need it?

Thank you for any and all help! :)


texts: Cannot POST to server. HTTP code -1. NodeMCU

texts:
I am trying to make a POST request with NodeMCU, but I get a HTTP status code -1.

Code:

#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>

#ifndef STASSID
#define STASSID "Wifi"
#define STAPSK  "123"
#endif

const char* ssid = STASSID;
const char* password = STAPSK;
const char* host = "https://laimonasjanutenas.000webhostapp.com/wifidata.php";

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

  HTTPClient http;

  http.begin(host);
  http.addHeader("Content-Type", "application/x-www-form-urlencoded");

  int httpCode = http.POST("temp=1337");
  Serial.println(httpCode);
  http.end();
}

Serial monitor outputs this:

connecting to Wifi
........
WiFi connected
trying to post
-1

I can confirm that I can actually make a POST to the server. I tested in Postman using this:

https://laimonasjanutenas.000webhostapp.com/wifidata.php?temp=159

I have no clue what I am doing wrong. Feel free to make POST requests to the this server if needed. Thank you.


texts:
I have my arduino connected to my PC and another serial device.
This serial device sends a 3 line piece of info on bootup then if I trip a zone it will send information regarding the radio transmission.

When I first power up the device I see the information from the device in the serial monitor (SELFTEST-PASS) however that is the last information I receive from it until I powercycle the device.

I have connected it directly to my PC comport and verified information is being sent via Serial however the arduino seems to quit after the first bit of info... any idea where to proceed from here?
PS I have tried both SoftwareSerial and NewSoftSerial
Here is an example of the data sent from the serial device as viewed by hyperterminal:

<1234 #3F->0000 1234->FFFF D_ALARM>
<FFFF #3F->1234 FFFF->1234 P_ACK>
<1234 #40->0000 1234->FFFF D_ZREST>

Code that is currently not working:

 #include <AltSoftSerial.h>
 AltSoftSerial portOne;

void setup() {

                Serial.begin(4800);
                while (!Serial) {; // wait for serial port to connect. Needed for native USB port only
                }
                // Start each software serial port
                portOne.begin(4800);

              }

// the loop function runs over and over again forever
void loop()
{
  if (portOne.available())
  {
    Serial.write(portOne.read());
  }

  if (Serial.available())
  {
    portOne.write(Serial.read());
  }
}


texts:
I have the Arduino Uno and I'm working on a project to build a controller with different inputs and some outputs for readouts. In classic style, I got the Arduino Uno before realising that I might not have enough I/O points to connect everything I want.

I believe there is a way to expand my Uno by using an I/O Expander? Has anyone done something similar? The controller will be for a specific game called Kerbal Space Station. There are quite a few articles helping with the build but not specific to what I am looking at.

Components I'll be using:

INPUTS:

2x 3 Axis Joysticks
11x Microswitches
6x Toggle switches
1x Analogue slider
1x 10 point rotary switch

OUTPUTS:

4x 12 pin LED Bargraphs
1x Serial LCD module display


texts:
I've an array of type uint8_t* const with 6 items, defined like this

uint8_t* const neighbourSet[] = {PEER1, PEER2, PEER3, PEER4, PEER5, PEER6};

Whereas each element in this array is static uint8_t defined like this

static uint8_t PEER1[] {0x86, 0xF3, 0xEB, 0x7A, 0xE8, 0x3B};
static uint8_t PEER2[] {0x86, 0xF3, 0xEB, 0x7A, 0xA1, 0x09};
static uint8_t PEER3[] {0x84, 0x0D, 0x8E, 0x03, 0x95, 0xED};
static uint8_t PEER4[] {0x84, 0x0D, 0x8E, 0x03, 0x99, 0xD5};
static uint8_t PEER5[] {0x80, 0x7D, 0x3A, 0xC5, 0x2B, 0x79};
static uint8_t PEER6[] {0x84, 0x0D, 0x8E, 0x03, 0x95, 0x1D};

When I do

  Serial.print("size:");
  Serial.println(sizeof(neighbourSet));

I get size:24. I am expecting the size to be 6. could someone explain ?
I don't want to hardcode the total number of PEER in a separate integer variable. I want my for loop to run through each element till the total size of array.

    for (int i = 0; i < sizeof(neighbourSet); i++) {
         //do something for each PEER.
         delay(50);
    }


texts: Noise in Analog Read Serial from an instrumentation amplifier(ina122p)

texts:
I am trying to read the values from a simple EMG circuit (with an INA122P) using the analogRead() and plotting in the plotter using an Arduino nano v3. I am powering the ina1222p from the 5v pin of the Arduino. But no matter what I do, the signal comes out very noisy most of the time(i can rarely make out the EMG). The bandpass filter is also not really helping. I am using regular solid core wire and alligator clips to connect to the electrodes.
Can someone please tell me what I am doing wrong? or tell me how to make a simple EMG circuit that uses the Arduino's analogRead().
I am also getting ac sine waves when my laptop is plugged to power, so I tried removing the power. The distinguishable sine wave wasn't really showing up, but it was still just as noisy...
I am a beginner to both Arduinos and designing Analog circuits.

I found this design from here: https://greenhecktech.wordpress.com/2016/09/19/improving-the-emg-amplifier/


texts: Purpose of USB (FTDI) and ICSP connectors

texts:
As an Arduino newbie I am a little bit confused about possible ways of programming and communicating with this device. I have done some research and it seems that:

ICSP is used for programming with a bootloader in MCU.

The USB (FTDI) port is used (mostly) for sending text messages to the PC and programming without a bootloader.

Am I right? How can I detect whether I have a bootloader installed (Uno R3 clone)? Thank you very much!


texts: How can I loop for a set amount of time when a condition is met?

texts:
I'm trying to create an Arduino project with a light sensor and a buzzer. The idea is that when the sensor detects that the lights have gone off, the buzzer will sound for 5 seconds. At some point, the lights will come back on, but when they go back off, I need the buzzer to sound again.

At the moment the buzzer does sound the first time the lights are turned off but after the lights have come back on and then off again, it won't sound and I can't figure out why.

int lightSensor = 2;
int buzzer = 3;
long startTime,stopTime;
long myDesiredTime = 5000;

void setup()
{
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(lightSensor, INPUT);
  pinMode(buzzer, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  int sensorState = digitalRead(lightSensor);

  switch(sensorState)
  {
  case 1:
    while (sensorState == 1)
    {
      if(stopTime-startTime<=myDesiredTime && sensorState == 1)
      {
        runBuzzer();
        stopTime=millis();
      }
    }
  }
}

void runBuzzer()
{
  tone(buzzer, 1000); // Send 1KHz sound signal...
  delay(1000);        // ...for 1 sec
  noTone(buzzer);     // Stop sound...
  delay(1000);
}


texts: troubleshooting - Turn on a single led in a ws2811 ledstrip with an arduino Uno with FastLed

texts:
I want to to turn on a single led in a ledstrip running on ws2811 with an Arduino Uno.

The problem is that when I try to turn just one of them on, they all three light up. The strip is a 3-wire strip, with GND, 12V and DIN. I am just running an example from the Arduino library FastLed

My code can be seen below

// Use if you want to force the software SPI subsystem to be used for some     reason (generally, you don't)
// #define FASTLED_FORCE_SOFTWARE_SPI
// Use if you want to force non-accelerated pin access (hint: you really don't, it breaks lots of things)
// #define FASTLED_FORCE_SOFTWARE_SPI
// #define FASTLED_FORCE_SOFTWARE_PINS
#include "FastLED.h"

///////////////////////////////////////////////////////////////////////////////////////////
//
// Move a white dot along the strip of leds.  This program simply shows how to configure the leds,
// and then how to turn a single pixel white and then off, moving down the line of pixels.
//

// How many leds are in the strip?
#define NUM_LEDS 3

// Data pin that led data will be written out over
#define DATA_PIN 6

// Clock pin only needed for SPI based chipsets when not using hardware SPI
//#define CLOCK_PIN 8

// This is an array of leds.  One item for each led in your strip.
CRGB leds[NUM_LEDS];

void setup() {
    // sanity check delay - allows reprogramming if accidently blowing power w/leds
delay(2000);
FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);

}

// your leds.
void loop() {
  leds[0] = CRGB::Red;
  leds[1] = CRGB::Black;
  leds[2] = CRGB::Black;
  FastLED.show();

}


texts: Can a timer be used in both CTC and (fast) PWM mode simultaneously?

texts:
I would like to generate a sequence of pulses of varying lengths in the range of 0-100us, so that from the start of one pulse to the start of the next there is a delay of 100us. I have set up timer0 in CTC mode to trigger an interrupt every 100us.

In this interrupt, I would like to turn the appropriate pin high, read the length of the current pulse from an array, and then configure the timer in such a away that it turns the pin off as soon as the pulse length has elapsed (I am hoping that this is possible without using an interrupt for turning off the pin). It seems that the PWM functionality can do what I want, if I use the second output compare register.

In any case this seems possible using a secondary timer in PWM mode, but I'd like to know whether the same is possible using only a single timer. From what I've seen in the datasheets the answer seems no, but perhaps I am missing something.

Can a timer be used in both CTC (with output compare register A) and PWM modes (with output compare register B)?


texts: Frequency of Retrieving Data from Website

texts:
I have wrote a code that communicate with my website to retrieve data to power on or off a 5V relay. I'm running the code every second to make sure it is real time. Is there more efficient way to tell Arduino to get the data whenever it is changed rather than continuous GET request.
// Send HTTP GET request
  int httpResponseCode = http.GET();

  if (httpResponseCode>0) {
    Serial.print("HTTP Response code: ");        Serial.println(httpResponseCode);        String payload = http.getString();
        StaticJsonDocument<2000> doc;             DeserializationError error = deserializeJson(doc, payload);
        if (error) {              Serial.print(F("deserializeJson() failed: "));              Serial.println(error.c_str());              return;            }

        String status = doc["status"];
        Serial.println(status);
         if ( status == "ON" ) {
           digitalWrite(ledPin, LOW);
         } else {
           digitalWrite(ledPin, HIGH);
         }
  }


texts:
I have a bunch of different dev boards for different projects. What I have been getting very confused about is what board needs what programmer from the Tools > Programmer menu.

I wish the selection had the option to be partially automated for the board selection. But it's evidently not. Part of my problem is that if you choose the wrong programmer, some boards seem to work. Others read but won't write, or will write to some spaces, but not others. Or, you might get other cryptic errors that sound a lot like failed hardware. Have a look at this message for an example:

OK, so let's say I have some random dev board. How can I know what programmer I should use? Assume the manufacturer's documentation mentions nothing about it...


texts: Can I Control My Android Game with Arduino Gamepad

texts: I have a project that I need to make a game(guitar hero like rhythm game) on unity for android and develop a custom controller for it that works on mobile game. I decide to use Arduino and hc05 module for communication via bluetooth. But every tutorial that I watched on internet that phone used as a controller, I want to make it reverse. I want to use Arduino as a gamepad on Adnroid. Is that possible?


texts: How can I learn to use Generic ESP8266 boards Libraries in Arduino?

texts:
I am new to ESP8266. I am using the Arduino IDE to program the ESP8266-01 module. How can learn to make my own codes for ESP using Arduino?

I am going through the example programs and learning which part of the code does what. But, is there a better way to understand the syntax of those libraries.

Thanks!!


texts: Problem Uploading to the Arduino Nano board

texts:
]2I am using an Arduino Nano board. It has an ATmega 328P processor. For running the codes I use Arduino 1.8.6 Software. The issue is that when I am uploading my sketch to the board it shows me the following errors:

 Using Port                    : COM7
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: stk500_recv(): programmer is not responding

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

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

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

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

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

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

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

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

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

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

avrdude done.  Thank you.

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

I have turned on the show verbose output option turned on.

Also, sometimes the following errors pop up:

collect2.exe: error: ld returned 255 exit status

Using library SoftwareSerial at version 1.0 in folder: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.14.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SoftwareSerial
exit status 1
Error compiling for board Arduino Nano.

I have referred the following links to solve my issue:

collect2.exe: error: ld returned 5 exit status
Why I can't upload my programs to the Arduino board?

I am making an application wherein I have to control two DC motors via Bluetooth module HC-05

In one of the troubleshooting questions, the solutions contained the possibility of the bootloader not being installed where the problem can be verified by pressing the reset button and checking the bootloader LED to blink. Can someone help me with this?

Also, there are two processors shown for ATmega328P:

The ATmega328P
The ATmega328P (old bootloader)

I tried using then both options for uploading the sketch but still, the errors pop up.

I have also downloaded and installed the latest FTDI drivers from their site.


texts: Fail uploading any sketch to ATtiny85 USB

texts:
I have a Digistump's ATtiny85 (probably a clone ), which fails uploading any sketch, saying: Warning: device with unknown new version of Micronucleus detected. This tool doesn't know how to upload to this new device. Updates may be available. I'm using Ubuntu 20.04 and Arduino IDE 1.8.13.
I used these guides:

Digistump's troubleshooting for linux

Kovo's blog

After using these guides, finally I stop getting this error, but when trying to upload the firmware ( last line at Kovo's ), I get this error:
`guy@desktop:~/tmp/micronucleus/upgrade$ ~/.arduino15/packages/digistump/tools/micronucleus/2.0a4/launcher -cdigispark  --timeout 60 -Uflash:w:~/tmp/micronucleus/upgrade/t85_default.hex:i
Running Digispark Uploader...
Plug in device now... (will timeout in 60 seconds)
> Please plug in the device (will time out in 60 seconds) ...
> Device is found!
connecting: 16% complete
connecting: 22% complete
connecting: 28% complete
connecting: 33% complete
> Device has firmware version 2.4
> Device signature: 0x1e930b
> Available space for user applications: 6522 bytes
> Suggested sleep time between sending pages: 7ms
> Whole page count: 102  page size: 64
> Erase function sleep duration: 714ms
parsing: 50% complete
> Program file is 1594 bytes too big for the bootloader!

Did someone encounter this ?


texts:
Okay, I'm using u8g2 library for my OLED display. After calling SD.begin(4) function, I cannot display anything on my OLED.

I'm using U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); constructor from u8g2 library since I'm using I²C for the display and SPI for microSD reader. I removed the CS Pin 4 from SD.begin() and I can now display something on the OLED.

How did supplying CS Pin parameter to SD.begin() function affected the I²C OLED display?


texts: How does the PID controller actually work?

texts:
Preferably PID functions on an Arduino uno or any other examples. I have been researching but many of the the websites really do not explain it.

P.S is there an algorithm for a PID? Thanks


texts:
I try to built a snake robot. I used servo motors mg996r. Its Operating voltage is 4.8 V to 7.2 V
and running current is 500 mA – 900mA. I used 4 servo motor. So I need a power supply that is 4*(900mA)=3600 mA. Regular batteries will not operate it and I do not have a power supply device. Lipo batteries are good but there is 3.7 V and 7.4 V models. Is 3.7 V lipo batteries can supply the power servos need or 7.4V lipo batteries because it is exceed the operating voltage. Also you can comment any other alternatives.


texts: Translating WS2812-LED-Strip-IDs when cutting up a strip to multiple parallel ones

texts:
Lets say i have 1 meter of WS2812 Strip at 60 LEDs per meter. Now i cut the strip up in to 6 single strips but keep the wiring the same and lay them out in parallel. So it would look something like this

1   |  11  |  21 ...

2   |  12  |  22 ...

3   |  13  |  23 ...

...

10   | 20   | 30 ...

Is there any library that would allow me to easily translate this? If i for example want to work with rows, turn a certain row in a certain color, treat certain sub-strips as if they were an individual one, etc etc...
I'm sure i can't be the first one who had this problem?


texts:
I am using an Arduino Uno to create a kinetic sculpture with magnets and electromagnets (EMs). I have a setup with two externally debounced buttons using resistors,capacitor and CMOS 4584 hex inverter. All non-used inputs of the 4584 are grounded. These buttons deliver a clean signal to the board and trigger the two interrupts which set flags to turn LEDs on or off and trigger one or both optoisolators (OIs).
These connect to another board with a separate 12V supply. One of the OIs turns a BUZ71 power mosfet on and the other triggers a relay which can reverse the polarity of the power to a small 30 ohm EM coil. This can make the magnet suspended above like a pendulum fly away from the coil...

This works perfectly well with the buttons,  the LEDs and the two inputs to the OIs  But when I connect the relay/mosfet board  to the output of the OIs it stops working properly. button 2 turns off button 1  as well as itself. Button one always turns off and on cleanly But button two triggers ISR2 about 10 times and ISR1 a couple of times, leaving both off. If I disconnect the EM coil the buttons work properly. It seems that switching the polarity is somehow interfering with the Uno maybe due to a fairly hefty inductive spike generated by switching the relay. I have tried using shielded coax to the coil. I have 47000 uF caps on both boards. I tried a crude faraday cage around the relay board - no luck. Could the spike be coming through the household power supply somehow even though the Uno board and the relay board have different power supplies and are fully seperated by the OIs?
Here is the sketch I am using:

    //  Coding by Jeremy 070520
//  development for ricochet module

const int coilButton = 2;
const int directionButton = 3;
const int coilPin = 8; //coil driver
const int directionPin = 9; //direction driver
volatile bool coilFlag;
volatile bool directionFlag;
int coilLedState = LOW;
int directionLedState = LOW;

void setup()
{
  pinMode(coilButton,INPUT);
  pinMode(directionButton, INPUT);
  pinMode(coilPin, OUTPUT);
  pinMode(directionPin, OUTPUT);
  digitalWrite(coilPin,LOW);
  digitalWrite(directionPin, LOW);
  attachInterrupt(digitalPinToInterrupt(coilButton), ISR1, FALLING);
  attachInterrupt(digitalPinToInterrupt(directionButton), ISR2, FALLING);
  Serial.begin(9600);
  }

void loop(){
  if(coilFlag)
  {
    coilFlag = false;
    coilLedState = !coilLedState;
    digitalWrite(coilPin, coilLedState);
  }
 if(directionFlag)
  {
    directionFlag = false;
    directionLedState = !directionLedState;
    digitalWrite(directionPin, directionLedState);
  }
delay(1);   //I'm desperate I will try anything ....
} //end loop

void ISR1()
{
  Serial.println("ISR1");
  coilFlag = true;
  }

void ISR2()
{
  Serial.println("ISR2");
  directionFlag = true;
  }


texts: avrdude: stk500v2_ReceiveMessage(): timeout with ADDAC VCC

texts:
I am getting the above error message uploading the ADDAC VCC, and the only thing that's changed I think is the patch is bigger.

Is there a fix for this or will I have to send it back? Hope my formatting is OK

Binary sketch size: 12,330 bytes (of a 258,048 byte maximum)
/usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega2560 -cwiring -P/dev/ttyUSB0 -b115200 -D -Uflash:w:/tmp/build953252908946386724.tmp/comps.cpp.hex:i
avrdude: ser_recv(): programmer is not responding
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]

avrdude: Version 6.0.1, compiled on Oct 21 2013 at 17:07:18
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/usr/share/arduino/hardware/tools/avrdude.conf"
         User configuration file is "/home/luke/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyUSB0
         Using Programmer              : wiring
         Overriding Baud Rate          : 115200
avrdude: wiring_open(): releasing DTR/RTS
avrdude: wiring_open(): asserting DTR/RTS
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

avrdude done.  Thank you.

avrdude: ser_recv(): programmer is not responding
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]


texts: SD.begin() causes SD card to pull 20mA in idle mode. Seem high?

texts:
I'm working on a project that uses an Atmega328p as the primary controller. I am using the Arduino libraries for programming.

I currently have an SD card in the project. I've done quite a bit of studying on current consumption of SD card and it turns out they're quite power hungry during read/write operations. However, when an SD card is not being interacted with, I believe it should go into an idle mode in which the power consumption is much less.

Now I've noticed that when I start using the Arduino SD library, specifically SD.begin(), the current consumed is approximately 20mA. This is a continuous 20mA without any read/write operations being used. Simply selecting SD.begin().

So I've got a few questions:
- Does this seem high for an SD card that is essentially doing nothing?
- What exactly does SD.begin do? I assume it configures some pins but does it do anything else? If it's just set up, shouldn't it 'set up' and be done? Why the continuous high current?


texts: Mac OSX Yosemite no serial ports showing for Uno R3

texts:
I have a MacBook Pro running OS X Yosemite (10.10.3). I connected my Arduino UNO R3 to my computer for the first time after the Yosemite upgrade - it worked fine before this!

When I opened the Arduino IDE I selected Tools > Board > "Arduino UNO", but when I try to choose a Serial Port the only options are:

/dev/tty.Bluetooth-Incoming-Port
/dev/cu.Bluetooth-Incoming-Port
/dev/tty.Bluetooth-Modem
/dev/cu.Bluetooth-Modem

I have followed several tutorials and threads on how to 'fix' this issue, all to no avail:

I've installed the latest version of the FTDI drivers (even though, from what I recall the UNO doesn't even need them): FTDIUSBSerialDriver_v2_3.dmg

Downgraded to a prev. version of the FTDI driver hoping that would clear it up: /Volumes/FTDIUSBSerialDriver_v2_2_18

I followed a tutorial of how to remove the existing Apple drivers and removed the kext files, etc...

Tried connecting arduino to both USB ports.

Tried various cables, including the one that a I used before the Yosemite upgrade.

Tried installing updated Silabs drivers:
Arduino compatible's serial port not showing Mac OSX

Walked through the entire Arduino Mac OSX guide:
http://www.arduino.cc/en/guide/macOSX

After looking into the system info of my Macbook Pro, I can see the USB Controller is Broadcom based, in case that helps. I searched for Broadcom USB drivers but got hits for Silabs one instead.

Under my Tools > Port menu.. I can see these options:

clicking the Serial Ports option doesn't do anything.

Running ls -1 /dev/tty.* or ls -l /dev/tty.usb* from terminal gives me:

/dev/tty.Bluetooth-Incoming-Port
/dev/tty.Bluetooth-Modem

The Board does NOT show up under system networking (as it has for others), so it's not recognized as an incorrect device.

I'm at a complete loss. The board powers up... but I cannot connect to it.

SIDE NOTE: This is a legit Uno R3, not a clone.


texts: many mac keyboards have a power button. Is there a way to mimic this power button shortcut from an arduino?


texts: Sparkfun CCS811 Air Quality Sensor is just not workin

texts:
i have an Arduino uno board and a sparkfun ccs811 sensor. I tried to reproduce the howto from the sparkfun homepage (https://learn.sparkfun.com/tutorials/ccs811-air-quality-breakout-hookup-guide?_ga=2.45231532.967238096.1560976781-258902726.1560976781), including the error states part.

I uploaded one picture of the wiring (updated). I also tried to use an alternative hardware connection with SDA to A4 and SCL to A5 as it is mentionned in the code comments (see homepage).

However, it is just not working and i always get this error code in the serial monitor beginCore exited with: I2C_ERROR

Here is my code (without the top comment block):

#include <Wire.h>

#include "SparkFunCCS811.h" //Click here to get the library: http://librarymanager/All#SparkFun_CCS811

#define CCS811_ADDR 0x5B //Default I2C Address
//#define CCS811_ADDR 0x5A //Alternate I2C Address

CCS811 mySensor(CCS811_ADDR);

void setup()
{
Serial.begin(9600);
Serial.println("CCS811 Basic Example");

Wire.begin(); //Inialize I2C Harware

//It is recommended to check return status on .begin(), but it is not
//required.
CCS811Core::status returnCode = mySensor.begin();
Serial.print("beginCore exited with: ");
switch ( returnCode )
{
case CCS811Core::SENSOR_SUCCESS:
 Serial.println("SUCCESS");
 break;
case CCS811Core::SENSOR_ID_ERROR:
 Serial.println("ID_ERROR");
 break;
case CCS811Core::SENSOR_I2C_ERROR:
 Serial.println("I2C_ERROR");
 break;
case CCS811Core::SENSOR_INTERNAL_ERROR:
 Serial.println("INTERNAL_ERROR");
 break;
case CCS811Core::SENSOR_GENERIC_ERROR:
 Serial.println("GENERIC_ERROR");
 break;
default:[enter image description here][2]
 Serial.println("Unspecified error.");
}

if (returnCode != CCS811Core::SENSOR_SUCCESS)
{
Serial.println(".begin() returned with an error.");
while (1); //Hang if there was a problem.
}
}

void loop()
{
//Check to see if data is ready with .dataAvailable()
if (mySensor.dataAvailable())
{
//If so, have the sensor read and calculate the results.
//Get them later
mySensor.readAlgorithmResults();

Serial.print("CO2[");
//Returns calculated CO2 reading
Serial.print(mySensor.getCO2());
Serial.print("] tVOC[");
//Returns calculated TVOC reading
Serial.print(mySensor.getTVOC());
Serial.print("] millis[");
//Simply the time since program start
Serial.print(millis());
Serial.print("]");
Serial.println();
}

delay(10); //Don't spam the I2C bus
}


texts: Regarding using I2C with Arduino for Silicon Micro-structure 5852 D 1.5 psi

texts:
I am trying to get output from a sensor (micro-structure 5852D), but I only get two outputs: 11 and 255 for even applying pressure.

The following is my code, please show me how to over come this problem.

#include "Wire.h"
#define addrs 0x5F // I2C bus address

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

void loop()
{

   byte lobyte;
   byte hibyte;
   int Press;

   Wire.beginTransmission(addrs);
   Wire.write(1);
   int x = Wire.endTransmission();

   Serial.print("endTransmission: ");
   Serial.println(x, DEC);

   Wire.requestFrom(addrs, 2); // contents of your first two registers
   while(Wire.available() < 2 );          // Check for data from slave
   {
      delay(1000);
      lobyte = Wire.read();       // Read press high byte
      Serial.println(lobyte, DEC);
      hibyte = Wire.read();      // Read press low byte
      Serial.println(hibyte, DEC);

      Press = toPressure(hibyte, lobyte);
      Serial.print("Pressure: ");
      Serial.println(Press);

      delay(1000);
   }

}

float toPressure(byte hi, byte lo)
{
  int a = (hi * 256 + lo) & 0x3FFF;  // see pdf, mask 14 bit

  float rv = (a - 116)* 0.8606; // faster //(t - 1638.0) / 30.84 + 600.0
  return rv;

}


texts: Unstable system when controlling power to serial peripheral devices and sleeping

texts:
In the process of trying to make a small system that will last a while on 4 AA batteries, I've reduced my Arduino project to a barebones system that when asleep draws a tiny amount of current from the batteries.

However, to achieve this, I found it would be necessary to cut power to the two attached peripheral devices (connected to an ATMega328P-PU). One of them is an I2C device, and the other is a serial device, and both are attached to the hardware serial/I2C pins as appropriate.

In terms of powering the peripherals, the bases of two transistors are connected to two of the digital pins, and power to them is controlled from code via these transistors. Both devices are 5V, and when the system is running the total current draw is around 200mA.

Basically this setup works, however I'm getting "random" system hanging and essentially an unreliable project. Sometimes when I power it up it will work as normal, but then hang and not sleep. Other times, it will sleep, but then freeze after waking or just get stuck during waking (which I can tell because the serial device powers up first and does nothing, but the I2C device remains off).

My best guess is the root of the cause is either something to do with the serial communication being interrupted by sleeping the MPU (I'm using the maximum power saving sleep, which is woken by an external interrupt on pin 2), or possibly some sort of power problem (sudden current draw from battery?) that occurs when the peripherals are powered on in code (though I don't know how I should test this).

So far, I've tried calling Serial.end() before sleeping the MPU, and Serial.being(9600) on waking, and have scattered delay(1000)s throughout to ensure everything has enough time to get running, but the problem still remains.

Does anyone have any pointers on things I could change/test, or an alternative approach I could take to make the same power savings?

EDIT: Some more details

The transitors used are TIP 120's. The connections are essentially an exact copy of the image here: https://ctheds.files.wordpress.com/2007/10/tip120.jpg, except the resistors used are 560 Ohms (just what I had to hand, no other reason, didn't think it would change anything).

The I2C peripheral is a 20x4 LCD (which I believe is HD44780 compliant). The serial device is an GT511C3 fingerprint sensor. I don't believe either of them have any automatic power saving features, though I haven't looked for such things in the documentation explicitly.

The exact code I use to call sleep is

set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
sleep_mode();

which I'm lead to believe is the lowest power mode, and aside from this problem works well for my system.


texts:
I was trying to switch to Atmel Studio for programming my Due project since it became more and more complex.
I managed to use the Arduino Importer Wizard to load a blink.ino file and included all the requested libraries more or less my hand that were marked as missing during compiling.
Now the compiling kind of works, but I still get this error:

Error       (inkerScript): No such file or directory    ECU arm-none-eabi-g++.exe   0

The (inkerScript): part is no typo. It is really like this in the console.
Taking a look in the Toolchain Options I have these settings (which I am not able to edit):

Going into the Miscellaneous Part of the Options I can edit these fields:

By editing the Linker Flags field, I can change the error message from (inkerScript): No such file or directory to e.g. HelloWorld: No such file or directory.

Is there anything wrong with my options? What is the correct setting for "Linker Flags" and what are they doing?

Unfortunately I am not a pro with C++ Compiling / Linker Errors / Settings.

Thanks.


texts: How to load program into Arduino pro mini using FTDI cable?

texts: Do we need a ftdi basic board to connect a ftdi 232R USB - TTL serial level converter cable via a 6 pin 0.1" male header into an Arduino pro mini/ nano 328 to upload the sketch?


texts: How to use components that don't have a shield?

texts:
I recently started messing around with an Arduino and I have made a few "gadgets" using shields. I then wondered how I would go about using things I can't find shields for.

One specific thing I want to do is to be able to use the larger e-paper displays from Pervasive Displays (7'' and 10'') but a brief consultation with Google found no Arduino kits or shields. I then looked through the documentation of the timing controller for the 7'' display and found the information required to be able to use it (initiation, sending data to be drawn, opcodes, etc.). I then decided to check the Github repo for the examples for the 2'' displays and they seem to just do what the documentation says to do.

Is my observation naive here? Is it really as straightforward as following the documentation? No magic sauce?

Note: I don't have a clue how complex using the 7'' display actually is, I just used it as an example because I had just looked it up...


texts: Initial setup print getting cut off from printing

texts:
I am writing a program in Python (using PySerial) that needs to read data from the Arduino quickly. For this reason I have set the serial timeout to 0.01 seconds. (Baud rate is 115k) If I don't set the timeout this low I run into issues with there being a noticeable delay between sending a command and receiving a reply. As long as I have the timeout set low enough then its all fine, but the downside is that I have a message print out when I first connect to the Arduino to confirm that it has indeed connected. (Message reads "Connected" once the serial connection has been established in void setup)
Okay, the problem: If I don't have the timeout set to 0.9 seconds or higher, the initial 'connected' message gets cut off. Of course if I have it set that high I get the issues I first described.
I'm looking for a way to keep the timeout very low but also get this first connected message when the void setup runs. Is there a way to have my cake and eat it too?
I did try starting with the timeout set to 1 second and once the connected message prints out change it to 0.01 seconds, but it just kept giving me an error.
Any help would be appreciated.


texts:
I have small problem in setting device ID for Mosbus slave arduino. Here is simple example

In Modus library; device ID being configure hardcode while program. This code works for Me.

Modbus slave(1,0,0);

Now I wanted to recognise 0-255 device ID , I am using 8:1 digital Multiplexer & DIP switch to select the port. I am reading status of digital pin & depend on status of 8 DIP pin i come to know whats device ID. Below function return device ID. I have checked Serial it returns value properly. If i assign the value to Device ID it wont work . Please let me know how can i solve this.

unsigned int ID_Check() {
      unsigned   int ID_value;
      for(int row=0;row<8;row++)
      {
        digitalWrite(SO_enable,array[row][0]);
        digitalWrite(S1_enable,array[row][1]);
        digitalWrite(S2_enable,array[row][2]);
        Status_Out[row]=digitalRead(Output_Read);

      }

  ID_value = 1 * Status_Out[0] + 2 * Status_Out[1] + 4 * Status_Out[2] + 8 * Status_Out[3] + 16 * Status_Out[4] + 32 * Status_Out[5] + 64 * Status_Out[6] + 128 * Status_Out[7];
  return(ID_value);
}

Below is complete code.I tried to call function loop But it wont work

#include <ModbusRtu.h>
int SO_enable=5;
int S1_enable=4;
int S2_enable=3;
int Status_Out[8];
int Output_Read=2;
Modbus slave(ID_Check(),0,0); // this is slave @1 and RS-232 or USB-FTDI
int array[8][3]={
  {
    0,0,0    }
  ,
  {
    0,0,1    }
  ,
  {
    0,1,0    }
  ,
  {
    0,1,1    }
  ,
  {
    1,0,0    }
  ,
  {
    1,0,1    }
  ,
  {
    1,1,0    }
  ,
  {
    1,1,1    }

};

unsigned int ID_Check() {
  unsigned   int ID_value;
  for(int row=0;row<8;row++)
  {
    digitalWrite(SO_enable,array[row][0]);
    digitalWrite(S1_enable,array[row][1]);
    digitalWrite(S2_enable,array[row][2]);
    Status_Out[row]=digitalRead(Output_Read);

  }

  ID_value = 1 * Status_Out[0] + 2 * Status_Out[1] + 4 * Status_Out[2] + 8 * Status_Out[3] + 16 * Status_Out[4] + 32 * Status_Out[5] + 64 * Status_Out[6] + 128 * Status_Out[7];
  return(ID_value);
}

uint16_t au16data[16] =
{
  3, 1415, 9265, 4, 2, 7182, 28182, 8, 0, 0, 0, 0, 0, 0, 1, -1
};

void setup() {
  slave.begin( 9600 ); // baud-rate at 19200
  pinMode(SO_enable, OUTPUT) ;// pin can enable/disable using digital IO 7 of arduino
  pinMode(S1_enable, OUTPUT) ;// pin can enable/disable using digital IO 6 of arduino
  pinMode(S2_enable, OUTPUT) ;// pin can enable/disable using digital IO 5 of arduino
  pinMode(Output_Read,INPUT);
}

void loop() {
  slave.poll( au16data, 16 );
}

The other way i tried

void Modbus_Setup()
{
  Device_ID=ID_Check();
     delay(100);
    Modbus slave(Device_ID, 0, 0);
     slave.begin(9600);
  //slave.setID(Device_ID);

}


texts:
Is there a chip that is just a parallel in / serial out shift register but with integrated internal pullups?

I could use a full-blown I/O expander but I really just need more momentary button inputs. I don't need outputs and I would rather not bother adding resistors or with writing commands to initialize the chip.


texts: How to create an array from serial.read?

texts:
I'm working on a audio-reactive lightinstallation with 16 LED lights.
In Max MSP I analyse my audio and split the frequencies in 16 'parts'.
I store these parts in a message of 16 ints, either 1 or 0 (on of off).
Every time a new frequency is detected the message updates and puts out a new int from 16 numbers (for exampe 1000100100110101).

I receive this number in my serial monitor of my Arduino Uno.
I want to put this 'incomingValues' in an array so I can check if a number/frequency is 0 or 1. When it's 1 I can turn on my relay/ light.
The 'incomingValues' is changing quite quickly but that shouldn't be a problem right?

I tried multiple things to create an array and update this every time a new serial message is coming in but I'm not used to work with Arduino so I could need some help.

Thanks! :)

Here is my code:

int counter;
int incomingValues = 0;
int lights[16];

void setup() {
  Serial.begin(9600);
  counter = 0;
  pinMode(13, OUTPUT);
}

void loop() {

  boolean newValue = false;

  while (Serial.available() > 0) {

    incomingValues = Serial.read();
    Serial.print(incomingValues);
    counter = counter + 1;

    newValue = true;
  }

  if (newValue) {
//    delay(50);
//    lights[counter] = incomingValues;
//
//
//    Serial.print(lights[0]);
//
//    for (int i = 0 ; i < 16 ; i ++) {
//      Serial.print(lights[i]);
//    }
//    Serial.println("");
//    newValue = false;
  }

  if (counter > 15) {
    counter = 0;
    Serial.print("\n");
  }

  if (incomingValues == 1) {
    digitalWrite(13, HIGH);
  } else if (incomingValues == 0) {
    digitalWrite(13, LOW);
  }
}


texts: ArrayList implementation fails for string object

texts:
I'm using a customised C++ implementation of ArrayList based on the method found in Processing. The original code is by Obed Isai Rios, but I've added a version to Github with more explicit file structure.  The arraylist is appended to by the add_string_item method, which works ok in the format arraylist->add_string_item("text string") but fails when the same input is a String variable.  The following script illustrates:

#include "ArrayList.h"
void setup(){
  ArrayList *list = new ArrayList("text1");
  list->add_string_item("text2");
  String str = "text3";
  list->add_string_item(str);
}
void loop(){}

This fails on the last line with error message:

no matching function for call to 'ArrayList::add_string_item(String&)'

sketch_aug24b.ino: In function 'void setup()':
sketch_aug24b:7: error: no matching function for call to 'ArrayList::add_string_item(String&)'
/Users/robinedwards/Documents/Arduino/libraries/ArrayList/ArrayList.h:17: note: candidates are: void ArrayList::add_string_item(char*)

I'm not familiar with C++ so can't figure out why this method accepts a string but not when assigned to a String object str.  I'm pretty sure it's because I need to coerce to char* but not sure how to do this.  I've tried toCharArray without success, although this seems the right direction.  Very grateful for any assistance.

ArrayList.cpp code:

#include "Arduino.h"
#include "ArrayList.h"

ArrayList::ArrayList(char* init){
  stringlist = (char**)malloc(10*sizeof(char*));
  stringlist[0] = init;
  this->size = 1;
}

ArrayList::~ArrayList(void)
{
}

void ArrayList::add_string_item(char* item){
  char **neulist = (char**)malloc((size+1)*sizeof(char*));
  for(int i=0; i<size; i++){
    neulist[i] = stringlist[i];
   }
   //
   neulist[size] = item;
   stringlist = neulist;
   size = size + 1;
}

void ArrayList::set_string_item(char* item, int index){
  stringlist[index] = item;
}

void ArrayList::remove_selected_item(int index){
  char **neulist = (char**)malloc((size-1)*sizeof(char*));
  //From Begining
  for(int i=0; i<index; i++){
    neulist[i] = stringlist[i];
  }
  //From next Index
  for(int i=index; i<=size-1; i++){
    neulist[i] = stringlist[i+1];
  }
  //free(matrix);
  stringlist = neulist;
  size = size - 1;
}

void ArrayList::empty_list(){
   size = 1;
   char **neulist = (char**)malloc((size)*sizeof(char*));
   stringlist = neulist;
   stringlist[0] = "EMPTY";
}

void ArrayList::display_string_list(){
   Serial.begin(9600);
  for(int i=0; i<size; i++){
    Serial.println(stringlist[i]);
   }
}

char** ArrayList::get_stringlist(){
  return this->stringlist;
}

char* ArrayList::get_item(int index){
  return this->stringlist[index];
}

void ArrayList::set_stringlist(char** stringlist){
  this->stringlist = stringlist;
}

int ArrayList::get_size(){
  return this->size;
}


texts: LED not blinking when using a transistor

texts:
I want to control an led using a transistor. The led gets it‘s power from an external 5v dc power supply.

For the transistor I use an 1kΩ base resistor. The transistor is a BC547C (npn). The datashet is available here.
The led is red (3mm), draws 20mA of current and needs 2V.

I‘ve got a very simple Arduino sketch and wiring setup:

Code:

#define ledPin 6

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

void loop() {
  digitalWrite(ledPin, HIGH);
  delay(1000);
  digitalWrite(ledPin, LOW);
  delay(1000);
}

Wiring diagram:

Problem:

The led is not blinking but shining at full power constantly.
Disconnecting ledPin 6 from the Arduino (to mimic digitalWrite(ledPin, LOW)) still lets the led shine, just not as bright. The LED should be off in that case, not just dimmed to 50% brightness.

What I tried so far:

I tried using different base resistors. I tried 2kΩ, 3kΩ, 2.5kΩ, 470Ω, 1.5kΩ. The behavior did not change.
I tried using different leds. Same behavior. LEDs are shining constantly, not blinking, and are dimmed when disconnecting pin 6.
I used another BC547C to see if the first one was broken. It wasn’t. I still got the same behavior.
Connecting the led directly to the Arduino without the transistor and external power supply let’s the led blink exactly how it was defined in code.

Any ideas?
I several-times-checked the wiring in my setup. It should not be the problem.


texts: Measure Natural Gas Pressure with arduino?

texts:
I am looking to measure Gas pressure in order to turn off Gas Heater when there is low gas. As in Pakistan alot of deaths occur when flame turns off because of low pressure of gas and then gas comes back. People suffocate into CO2. So to measure that gas what kind of sensor should i use with arduino?
Thanks


texts: There is a chip on Arduino UNO board which I can not find anything about. It is labeled RSR 09TI. It is placed near other power related components (see the image), but what is its purpose on the board?


texts: MySQL Connector/Arduino insert data from row into an array

texts:
I'm new here.
These days I have been working with the MySQL Connector/ Arduino library. So, my problem is how can i retrieve a rows data so as to enable an output. I have written some code, which was going pretty good, but here is where my problem is introduced:

void query_analysis_states () {
  row_values *row = NULL;
  column_names *columns = NULL;
  SQL_SETUP.cmd_query(QUERY_STATE_SQL);
  columns = SQL_SETUP.get_columns();
  do {
    row = SQL_SETUP.get_next_row();
    if (row != NULL) {
      for (int f = 0; f < columns->num_fields; f++) {
        state_Array[f] = atoi(row->values[f]);
      }
    }
  } while (row != NULL);
}

So the problem is that if I put a serial.print inside the for loop, I get the correct states which I have requested. If, I put it outside, I get them all wrong, like they are gone missing, for example I get states 1, 0, 1 and then 0, 0, 0 or something else. That means that the array also which plays the role of capturing the data from the row doesn't work when I call the method. Can anyone please help me? If you want me to post the rest of the code, please tell me. Thank you in advance.


texts:
I'd like the double number 200.00 shown as 200.00 on my LCD screen.

For instance, when I pass just a number (int) like 40 to the LCD, it uses it as an ASCII code to show a character on the display.

Now I want to send a double to it and it should be displayed as a double.

#include <Wire.h>

void setup() {
   Wire.begin(0x63);
}

double f;
void loop() {

  f = 200.00;

  Wire.beginTransmission(0x63);
  Wire.write(byte(0x00));
  Wire.write(4); //HIDE CURSOR
  Wire.write(12); //CLEAR SCREEN
  Wire.write(13); //CURSOR 2nd LINE
  Wire.write("Frequenz: ");
  Wire.write(f); //<- How to do this?
  Wire.write("Hz");
  Wire.endTransmission();
}


texts: TCP or HTTP connection between web server and arduino

texts:
If arduino works as a client and tries to connect to web server (the server is mine), should I connect to it via TCP or HTTP connection? Data will be simple strings (20 chars at max) so TCP connection should probably be enough?

The connection has to work in both ways - web server sending data to arduino and arduino sending data back to server.


texts: Arduino connection with the server failed

texts:
I am trying to connect arduino uno and ethernet shield and try to send some data to an asp.net web api application. When i upload the sketch, i get in the serial monitor connection failed.
I don't understand what's going wrong ?
Below is the code i am using

#include "cactus_io_DHT22.h"
#include <SPI.h>
#include <Ethernet.h>
#include <Client.h>

#define DHT22_PIN 2

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xDD };

IPAddress ip(192,168,0,177);
IPAddress server(192,168,0,11);
EthernetClient client;

DHT22 dht(DHT22_PIN);
float heatindex1 =0.00;
float heatindex2 = 0.00;

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

    Serial.println("connecting...");
    if (client.connect(server, 80)) {
      Serial.println("connected :D ");
    }
  Serial.print("Arduino server IP address: ");
  Serial.println(Ethernet.localIP());
  Serial.println("DHT22 Humidity - Temperature Sensor");
  Serial.println("RH\t\tTemp (C)\tTemp (F)\tHeat Index (C)\t Heat Index
 (F)\t Max(C)\t\t Min(C)");

  dht.begin();
  dht.readHumidity();
  dht.readTemperature();

}

float max1=dht.temperature_C;
 float min1=100;

void loop() {
  dht.readHumidity();
  dht.readTemperature();
  heatindex1=dht.computeHeatIndex_C();
  heatindex2=dht.computeHeatIndex_F();

  if(dht.temperature_C>max1)
  {max1=dht.temperature_C;}
  if(dht.temperature_C<min1)
  {min1=dht.temperature_C;}

  // Check if any reads failed and exit early (to try again).
  if (isnan(dht.humidity) || isnan(dht.temperature_C)) {
    Serial.println("DHT sensor read failure!");
    return;
  }
  if (client) {

   // When a client sends a request to a webserver, that request ends with a blank line
    boolean currentLineIsBlank = true;

    Serial.println("OK"); }

  if (client.connect(server, 80)) {
    client.print("GET /api/todo?humidity=");
    client.print(dht.humidity);
    client.print("&temperature1=");
    client.print(dht.temperature_C);
    client.print("&temperature2=");
    client.print(dht.temperature_F);
    client.print("&heatindex1=");
    client.print(heatindex1);
    client.print("&heatindex2=");
    client.print(heatindex2);
    client.print("&max1=");
    client.print(max1);
    client.print("&min1=");
    client.print(min1);// And this is what we did in the testing section above. We are making a GET request just like we would from our browser but now with live data from the sensor
    client.println(" HTTP/1.1"); // Part of the GET request
    client.println("Host: 192.168.0.11"); // IMPORTANT: If you are using XAMPP you will have to find out the IP address of your computer and put it here (it is explained in previous article). If you have a web page, enter its address (ie.Host: "www.yourwebpage.com")
    client.println("Connection: close"); // Part of the GET request telling the server that we are over transmitting the message
    client.println(); // Empty line
    client.println(); // Empty line
    client.stop();    // Closing connection to server

  }

  else {
    //If Arduino can't connect to the server (your computer or web page)
    Serial.println("--> connection failed\n");
  }

   Serial.print(dht.humidity); Serial.print(" %\t\t");
  Serial.print(dht.temperature_C); Serial.print(" *C\t");
  Serial.print(dht.temperature_F); Serial.print(" *F\t");
  Serial.print(dht.computeHeatIndex_C()); Serial.print(" *C\t ");
  Serial.print(dht.computeHeatIndex_F()); Serial.print(" *F\t ");
  Serial.print(max1); Serial.print(" *C\t ");
  Serial.print(min1); Serial.println(" *C\t");

  delay(5000);
}


texts: How to differentiate between 2 Micros on Linux

texts:
I have 2 Arduino Micro based devices that I want to use on my Ubuntu Linux machine.  I need them to have unique serial ports.  Unfortunately, both have the same serial number which makes identification through udev rules difficult (if not impossible).

This is the serial number that I get for both:

$ udevadm info -a -p  $(udevadm info -q path -n /dev/ttyACM0) | grep -i serial
  ATTRS{serial}=="0000:00:14.0"

Is there any way to manually set the serial number on an Arduino Micro?  Or is there any other unique identifying properties I can use for udev rules?

Typically, I do something like this in my /etc/udev/rules.d/99-usb-serial.rules file:

SUBSYSTEM=="tty", ATTRS{product}=="Arduino Uno", ATTRS{serial}=="64936333936351911191", SYMLINK+="MyDevice"

Side note: I also have a Due, that has the same serial number as the Micros, but since ATTRS{product} is different, I can differentiate it.


texts: How do I create a constant loop with an event that only occurs once?

texts:
I am currently working in void loop() and have setup a distance meter that constantly checks the distance.

Once the distance threshold is met, a function is called. Now I only need this function to be called ONCE. But because the distance meter is constantly scanning (which I need), the function is also being repeatedly called. I tried making some sort of timer but I can't figure it out. Can someone please have a look at this?

if (distance <= 150){
    personPresent();
    }

  if(distance > 150){
    personAbsent();
      }

I need certain events within the if statement to occur only once. E.g., I want to register when there is a personPresent and have that event not fire repeatedly.

In this case, personPresent() is attached to a GPIO pin which triggers a buzzer sound. As it is now, the buzzer keeps on ringing as long as distance is less then 150. I need the buzzer to make a sound only ONCE and then not buzz for at least 5 minutes.


texts: How many connections can Arduino I2C method create?

texts:
I was just learning about I2C between 2 Arduinos, one as sender and another as a receiver
So I have got curiosity to know how many Arduinos can be connected to I2C connection in serial?
I mean,
Arduino1 --> Arduino2
Then can I connect Arduino3 to
Arduino 2 then again Arduino 4 to Arduino 3? Till how many Arduinos can I continue this connection?


texts: How to access native USB port of Arduino Due on Synology NAS?

texts:
I would like to flash my Arduino Due from my Synology DS218+ NAS which runs on an Intel 64bit Linux-derivate platform. Previously, I was able to flash a Mega 2560 from this NAS via avrdude and currently, I am able to flash an Arduino Due via bossac through the Due's programming port. The port is registered as /dev/ttyACM0 (as was the Mega 2560) after I installed the necessary usbserial kernel module.
However, the native port is not detected likewise, or rather it is deregistered immediately:

[8336388.471865] usb 1-2: new high-speed USB device number 27 using xhci_hcd
[8336388.613119] Got empty serial number. Generate serial number from product.
[8336388.685041] cdc_acm 1-2:1.0: ttyACM0: USB ACM device
[8336389.331596] usbcore: deregistering interface driver cdc_acm

The programming port shows up like this:

[8338189.956730] usb 1-2: new full-speed USB device number 29 using xhci_hcd
[8338190.100022] usb 1-2: ep 0x82 - rounding interval to 1024 microframes, ep desc says 2040 microframes
[8338190.615513] cdc_acm 1-2:1.0: ttyACM0: USB ACM device
[8338190.621705] usbcore: registered new interface driver cdc_acm
[8338190.628534] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

Is there anything I need to install in addition to the usbserial kernel modules to get the native port working?

P.S.: I know that the programming port is more stable, but it is also rather slow with its 115200 bps. Uploading a sketch that just takes up 50% of the Due's flash memory takes almost a minute, and if you want to see the effects of code changes, this is quite time consuming.


texts: Watchdog timer stuck in restart loop? (green led flashing)

texts:
I am trying to set up a way to reboot arduino on command. The code below should do that but it seems like my arduino just get's stuck in some sort of a loop where I cant upload or get any serial output. The green led (pin 13) flashes very fast. The only way to stop this is to cut power to the device, even reset button does not work. This happens only when "R" is received via serial or if wdt_reset() function is commented out.

#include <avr/io.h>
#include <avr/wdt.h>

int ledPin = 3;

void setup()
{
  MCUSR=0;
  wdt_disable();
  Serial.begin(57600);
  Serial.println("BOOT!");
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);
  delay(500);
}

void loop(){
  if (Serial.available() > 0){
    char cmd = Serial.read();
    if (cmd == 'R'){
      Serial.println("R received!");
      wdt_enable(WDTO_1S);
      delay(2000);
      Serial.println("1 SEC.");
    }
  }
  wdt_reset();
  digitalWrite(ledPin, HIGH);
}

What am I doing wrong?


texts:
I have a functionality on my mega 2560 to connect with other devices. Sometimes, devices can't answer. I don't want to wait for a longwhile. So, how can I interrupt the chunk of program after the specific amount of time?

My code for receiving messages is:

while (!(UCSR1A & (1<<RXC1)));

so, millis can't solve my problem because I haven't ability to check for conditional loops like that

if(currentMillis - previousMillis > interval) {


texts: Serial Getting Garbage Data with real data

texts:
I have made an app in VS2015 C#.Net which sends data to Serial port. The data i am sending is:

stat>temp:39,38,;load:17,4,42,;fans>50,50,;

Where as I am receiving:

ððððstat>temp:39,38,;load:17,4,42,;fans>50,50,;

What I have tried:

Set SerialPort Encoding to ASCII in C#
Set SerialPort Encoding to UTF8 in C#
Set SerialPort Encoding to Default in C#

All have no effect.

Some observations:

When I send the data via Serial Monitor of Arduino there is no garbage data.
When I send data via a USB to TTL converter via my App, no garbage. (This part confuses me more)

BAUD RATE IS: 115200.

This is the only thing I have not changed yet and I dont want to change this as the string length will increase over time. this is 43 bytes of data. It can grow to up-to around 64 or 100 bytes and that would take longer to send and even longer to read adding delays in functions that are already working before the serial interrupt.

Regards


texts:
I am designing a new soldering station which will use a 24 V ac soldering iron.

I started to make some research and I designed a few steps of the soldering station. I will use a 24Vac/100VA toroidal transformer. I will use a 24V/50W soldering iron with K type thermocouple. For the thermocouple I will use a LM358 amplifier. Please have a look at the attached schematic and code. The code is not ready yet and I need some help in making the connection between the PID library and output in the code.
The voltage on the soldering iron looks like: https://ibb.co/CMF1gQ0
If I rotate the pot, nothing happens on the screen of the scope.

https://ibb.co/vdDRmnJ

I wrote a few lines of code but I don't know how to make the connection between the PID library functions and the interruption function and the other variables in my code.

Please have a look at the code and at the schematic and tell me what you think...
I am waiting for your help.

#include <PID_v1.h>

int AC_LOAD = 1;    // Output to Opto Triac pin
double set_value = 0;
double input = 0;
double output = 0;

PID aaa_PID(&input, &output, &set_value, 1, 0.05, 0.25, DIRECT);

void setup()
{
  aaa_PID.SetOutputLimits(0, 128);
  aaa_PID.SetMode(AUTOMATIC);
  pinMode(AC_LOAD, OUTPUT);// Set AC Load pin as output
  attachInterrupt(0, zero_crosss_int, RISING);  // Choose the zero cross interrupt # from the table above
}

//the interrupt function must take no parameters and return nothing
void zero_crosss_int()  //function to be fired at the zero crossing to dim the light
{
  // Firing angle calculation : 1 full 50Hz wave =1/50=20ms
  // Every zerocrossing thus: (50Hz)-> 10ms (1/2 Cycle)
  // For 60Hz => 8.33ms (10.000/120)
  // 10ms=10000us
  // (10000us - 10us) / 128 = 75 (Approx) For 60Hz =>65
  int dimtime = (75*output);    // For 60Hz =>65
  delayMicroseconds(dimtime);    // Wait till firing the TRIAC
  digitalWrite(AC_LOAD, HIGH);   // Fire the TRIAC
  delayMicroseconds(10);         // triac On propogation delay (for 60Hz use 8.33)
  digitalWrite(AC_LOAD, LOW);    // No longer trigger the TRIAC (the next zero crossing will swith it off) TRIAC
}

void loop()  {
  int set_point = analogRead(A1);
  set_point = map(set_point, 0, 1023, 150, 400);
  int in = analogRead(A0);
  input = map(in, 0, 550, 25, 400);
  set_value = set_point;
  aaa_PID.Compute();

}


texts: Why does the reading on the ESP32 read max, when the reading on UNO read accurately?

texts:
I have a 'Capacitive Soil Moisture Sensor' hooked up to my Uno.
Very simple code. AnalogRead(MoistureSensorPin);
This will return a differing value that I can work with.

When applying the same code to an ESP32 with a similar set-up. It always returns '4095' which I understand is the maximum value an analog input can return. But I cannot understand why it does this.

Any help will be much appreciated.


texts:
Looking at my Arduino Uno board, it appears the digital PWM pins are #11, #10, #9, #6, #5 and #3.

When playing around with the Theremin, it seems that the Tone() message works on all pins regardless of whether they are marked PWM or not?

Can anyone explain what is happening or how this is possible?


texts: Wroom 32 can't be recognized by Arduino 1.8.9 on a ubuntu 19.04 computer

texts: I started by plugging my Wroom 32 into my Kubuntu desktop. I checked my /dev before and after, and found no changes. After opening Arduino IDE, I only found my other Arduino, the Arduino Due, in the port list. I already installed the ESP 32 board. What's wrong?


texts: Arduino Mega not recognized by device manager

texts:
My lab partner and I are working on a project for school and we are using an Arduino Mega 2560 for prototyping. The board was working just fine until, out of nowhere, the board was not being recognized at all. I tried reinstalling the IDE but still it does not work. I checked to see if the Arduino driver was installed, but the board does not show up in the device manager. Also, the L LED on the board does not light up at all. Attached are photos to help understand the problem.

If someone could help, it would be much appreciated. Thanks.


texts: Firmata: strings sent from the computer become damaged after Arduino

texts:
I have a Python program that acts as a Firmata client. This program connects to the Arduino at a user-specified COM-port (with Firmata onboard, the sketch can be seen below), sends the user-requested string message to the Arduino, and awaits Arduino's reply. If the reply is present, the program prints it out as a list of ASCII symbol codes.
I expect the program and the sketch to work this way (block scheme is below), but the strings coming from the Arduino are damaged. They don't contain all symbols which were sent, but they contain only the first symbols in some random order, with a \0 symbol present after each character in the string. For example,

String sent to the Arduino
Received as ASCII symbol codes
Received as a string

A
(65, 0)
A\0

AB
(65, 0) where is the B?
A\0

ABC
(65, 0, 67, 0) the B lacks presence
A\0C\0

ABCD
(65, 0, 67, 0) the received data length remains the same, but B and D aren't present
A\0C\0

ABCD(10)
(65, 0, 67, 0, 40, 1, 48, 1) WHAT IS THIS?
A\0C\0(\10\1

DHTt(4)
(68, 0, 84, 0, 40, 0, 41, 1)
D\0T\0(\0)\1

Program's screenshot:

Awaited work algorithm block scheme:

Python program code:
import pyfirmata, time

class CustomArduino(pyfirmata.Arduino):
    def __init__(self, port: str):
        pyfirmata.Arduino.__init__(self, port)
        self.iterator = pyfirmata.util.Iterator(self)
        self.iterator.start()

        self.add_cmd_handler(0x71, self.receiveString)

    def receiveString(self, *args, **kwargs):
        print(f'Received: {args}')

    def sendString(self, data):
        self.send_sysex(0x71, bytearray(data, 'utf-8'))

    def send_sysex(self, sysex_cmd, data=[]):
        """
        Sends a SysEx msg.
        :arg sysex_cmd: A sysex command byte
        : arg data: a bytearray of 7-bit bytes of arbitrary data
        """
        msg = bytearray([pyfirmata.pyfirmata.START_SYSEX, sysex_cmd])
        msg.extend(data)
        msg.append(pyfirmata.pyfirmata.END_SYSEX)
        self.sp.write(msg)

print('STRING TESTER\nPlease input your COM port: ', end = '')
myCom = str(input())
device = CustomArduino(myCom)

while True:
    device.sendString(input('Send: '))
    time.sleep(1)

Arduino sketch:
#include <Firmata.h>

void stringCallback(char *myString)
{
  //The function accepts one charset.
  Firmata.sendString(myString); //send the *same* charset  back
}

void sysexCallback(byte command, byte argc, byte *argv)
{
  Firmata.sendSysex(command, argc, argv);
}

void setup()
{
  Firmata.setFirmwareVersion(FIRMATA_FIRMWARE_MAJOR_VERSION, FIRMATA_FIRMWARE_MINOR_VERSION);
  Firmata.attach(STRING_DATA, stringCallback); //when there is a STRING incoming to the Arduino, call 'stringCallback'
  Firmata.attach(START_SYSEX, sysexCallback);
  Firmata.begin(57600);
  pinMode(13, OUTPUT);
}

void loop()
{
  while (Firmata.available()) {
    Firmata.processInput();
  }
}

How I can deal with this?


texts:
I am making an LED controller that reads instructions from a text file on my computer. I need to get the arduino to read this text file line by line and put each line into the appropriate variables. I'm using a sparkfun pro micro which is a knock off arduino pro micro. The pro micro is connected via USB

I've seen people use the SD library, but I don't know if this will work for my situation because I am reading directly from the computer and not an SD card. Is this the correct approach, or is there an additional/alternate library that I need to use?


texts: Unable to read data more than once via Modbus RTU

texts:
I'm a newbie to this forum so kindly excuse me for any errors.

I'm using an Arduino Uno and Max485 (RS-485 to TTL) to communicate with a Power meter, but I'm able to receive the data from the Power Meter only once and then it prints "Error" continuously. I need to reopen the Serial Monitor to get the new reading but again the issue persists thereafter. Reading parameter is voltage.

I am using ModbusMaster library. Please refer to the code below.

#include <ModbusMaster.h>

uint16_t vl1, v11;
uint8_t result1;
float v1;

ModbusMaster  node;
#define MAX485_DE      2
#define MAX485_RE_NEG  3

void preTransmission()
{
  digitalWrite(MAX485_RE_NEG, 1);
  digitalWrite(MAX485_DE, 1);
}

void postTransmission()
{
  digitalWrite(MAX485_RE_NEG, 0);
  digitalWrite(MAX485_DE, 0);
}

void setup()
{
  // Open serial communications and wait for port to open:

  pinMode(MAX485_RE_NEG, OUTPUT);
  pinMode(MAX485_DE, OUTPUT);

  digitalWrite(MAX485_RE_NEG, 0);
  digitalWrite(MAX485_DE, 0);

  Serial.begin(9600);

  node.begin(1, Serial);

  node.preTransmission(preTransmission);
  node.postTransmission(postTransmission);

}

void loop()
{
  result1 = node.readInputRegisters(0x0001, 5);

  delay(1000);

  if (result1 == node.ku8MBSuccess)
  {
    //Retrieiving data from energy meter via modbus

    vl1 = node.getResponseBuffer(0x01);
    v11 = node.getResponseBuffer(0x00);
    uint16_t data[2] = {va11, val1};
    memcpy(&v1, data, 4);
    Serial.println("Voltage:);
    Serial.print(v1);
  }

  else
  {
    Serial.println("Error");
  }
}

This is the output I get from the Serial Monitor

Voltage:221.21
Error
Error
Error

FYI, Meter communication details as follows:

  Baud Rate: 9600, Parity: None, Stop bits: 1, Slave ID: 1

I'm unable to figure out the issue therefore I'm looking forward in seeking your assistance. Thank you!


texts:
I would like to set up an esp8266, connected arduino as a webserver, specifically, one that has its own IP, and is stand alone, not connected to other networks, and offers its sensor info as the contents of its internal webpage. what is this called?

I see numerous examples for connecting the esp8266 to another network, but that is not what I want to do. I want the esp8266 to read its sensors, and write a webpage, but have other devices connect to it.