texts: Is I2C a good option for transmitting data over 200 meters by cable?

texts:
Is I2C a good option for such application or are there other protocols? I know that modules like these exists to extend I2C range, and I'm planning to use this one (P82B96).

I'd like to use a frequency of 100kHz for I2C and use DMX cables of 20m connected in series.

So, is there any alternative that is more adapted for Arduino to Arduino data transmission over a cable?

EDIT : The solution here is CAN because it allows to have multiple devices on the bus. But if it is a simple communication between two arduinos, then go for the RS-232.
Solution mentionned by @Dmitry Grigoryev and @Joe S

Thanks in advance.


texts: Controlling Arduino through Internet and Bluetooth

texts: I have an Arduino sketch that controls an LED through the Internet, and another through Bluetooth. The thing is I want to combine both sketches so that I can control my Arduino LED by Bluetooth as well as through the Internet. Is it possible to do that?


texts: What kind of antenna should i use for my esp8266 module?

texts: I have an esp8266 module and i want to increase its range by adding an antenna to it. What kind of antena should i use. Can i use an antenna from a RC car remote?


texts:
Here's a simple sketch. I have an array data and a variable idx.
I'm assigning a value to each of the array element, and then sending them to my serial monitor.

volatile uint16_t data[5];
volatile uint16_t idx = 5;

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

  while (!Serial) { }
  Serial.println("\nHello!");

  data[0] = 1010;
  data[1] = 1011;
  data[2] = 1012;
  data[3] = 1013;
  data[4] = 1014;

  for(int i = 0; i< idx; ++i)
  {
    Serial.print(data[idx]);
    Serial.write(",");
  }

  while(1){  }
}

void loop() {}

When I look into my serial monitor, I get this:

Hello!
0,0,0,0,0,

Why is this happening? Did I overlook something fundamental? I'd appreciate if you could offer your thoughts on this.

I'm testing this code on Arduino Mega2560.


texts: Can I measure multiple photoresistors from one pin?

texts:
I would like to make a laser sensor to detect light coming from a 650nm diode. My current idea would be to use CdS photoresistors/LDRs. I want to measure a few (4-8?) at once, where light falling onto any one of them generates a signal - I don't care from which sensor it actually came. However, I would like to put as many sensors on as few pins as possible.

I've already somewhat figured out that putting LDRs in parallel isn't ideal, because any changes in voltage will become smaller the more I use. Instead, it would seem like a better idea to build some kind of 'switch' by putting each LDR together with a fixed resistor and a transistor. How exactly would a circuit for this look like, or are there better ways to do it?


texts: Arduino Nano use SPI pins as I/O pins? and still be able to do ISP?

texts:
I wonder if can use the Arduino Nano SPI-pins(MOSI,MISO & SCK) as I/O pins in a sketch? and still be able to program over ISP?

Of course I will physical disconnect the Arduino from any other hardware before programming.


texts: I used to work with PIC micro-controller so i know what it needs to work from operating circuit to crystal oscillators needed and other components to power it up , my question here where can i find the operating circuit for ATmega32p-pu and other AVR models . or all i need to do is to give it +5v and gnd and it will work ?


texts: Is my code triggering the N-Channel MOSFET as I have intended to

texts:
I have a certain bit of code that I believe after 10 seconds will send a high signal to the second digital pin for 50 seconds. After it will not do anything.

For some reason the nichrome wire is not heating up. I realize there could be a problem with my circuit but just want to make sure for the final time it is not an issue with my code. Thanks.

int nichromePin = 2;

unsigned long burnTime = 10000;
unsigned long dt = 50000;
unsigned long time;

void setup()
{
  pinMode(nichromePin, OUTPUT);
  Serial.begin(9600);
  Serial.println("Balloon Countdown...");
  Serial.print("When Will It Burn: ");
  Serial.println(burnTime);

}

void loop()
{
  time = millis();

  if (time > burnTime && time < burnTime+dt)
  {
  digitalWrite(nichromePin, HIGH);
  Serial.print("Time: ");
  Serial.println(time);
  }
}


texts: Arduino board not recognized by Linux (dmesg, lsusb, etc.)

texts:
I just received my first Arduino board which is essentially a Leonardo (ATmega32U4) customized to include a NFC reader (PN532).

When I plug it in, the PWR LED comes on steady, the D13 LED flashes a few times, and then the STA LED blinks once and only the PWR LED is left on. I can upload a basic sketch to the correct Serial Port, but the Serial Monitor is always empty.

I have noticed that, when uploading the sketch, the RX/TX LEDs stay off (which I thought was a sign of uploading/downloading data). I figured this was the root of my issue so I tried to look into it further. Running lsusb does not find the device and dmesg does not show any information when (un)plugging the device.

I also tried on a Windows install, but couldn't install the Leonardo drivers since Device Manager wouldn't register any unknown USB/Arduino devices.

Do you think my board is dead on arrival or am I doing something wrong?

Update:

I just uploaded the Blink tutorial sketch and it uploaded "successfully" but I noticed no differences. Please note that I don't have an external LED attached, but am looking at the board's LED on pin 13. This pin already flashes a few times (as mentioned above) on a reset, so I modified the delay times and still noticed no change.

I am uploading using board Leonardo, as recommended for my hardware, and the serial port /dev/ttyS0. I thought this was the right port because I remember not seeing it at first, but on second thought I had a permission issue at first (which is now resolved) causing me to not see the port.

So it looks like my board is not detected by my computer and I'm successfully uploading sketches to a meaningless port. Any troubleshooting options for me? I've tried different USB ports and am, as of recently, plugging my board into external power (9V). The only thing I can think of that on my end is that I'm using a Y-cable for my USB connection (I have a normal Mini-USB coming tomorrow via Amazon) since it is all I had. I can also confirm that this USB connection does power the board when plugged in.


texts: Comunication between Android and Arduino

texts:
I am trying send data from an Arduino to an android device with bluetooth.
I want to send a date y and when it arrives, turn on a led, but when I send the data nothing happened.
This is my code for Arduino (I use the bluetooth module hc-05)

char entrada;
void setup()
{
pinMode(8,OUTPUT);
Serial.begin(9600);
digitalWrite(8,LOW);
}
void loop()
{
   if(Serial.available()>0)
{
 entrada=Serial.read();
 if(entrada=='1')
 {
    digitalWrite(8,LOW);
    Serial.println("1");
  }
 }

And in the side of android i have this codec with my handler and thread for inputstream and outputstream

public void run()
    {
        byte[] espera=new byte [256];
        int esperaalmacen;
        while (true) {
            try {
                esperaalmacen=entradadatos.read(espera);
                mhandler.obtainMessage(MENSAJELEYENDO,esperaalmacen,-1,espera).sendToTarget();
            }catch (IOException e){}
        }

And in my activity main I have:

       @Override
    public void handleMessage(Message msg)
    {
        super.handleMessage(msg);
        switch (msg.what)
        {
            case CONECTADO:
                //ManejarDatos msjre = new ManejarDatos((BluetoothSocket)msg.obj);
                msjre = new ManejarDatos((BluetoothSocket)msg.obj);
                break;
            case MENSAJELEYENDO:
                byte[] readBuf = (byte[])msg.obj;
                String string = new String(readBuf);
                Toast.makeText(getApplicationContext(), string, Toast.LENGTH_LONG).show();
        }
    }

My modulo I have configured as slave.


texts: How does use an arduino like a A/D converter for convert 3 analogue signal from 3 poteciometer to a raspberry?

texts:
I am developing a control system in my raspberry, but i have the problem that it doesn't have any analogue port, so if i use an arduino to convert de signal from analogue to digital and after send this signal into a I/o digital port from anduino to raspberry, thas is posible?

my plan was receive the analog signal in arduino and transforms here in a digital signal and after send it by Digital port to rasberry


texts:
I'm trying to control my ~230 V fan from the Arduino.

Can anyone say the best possible ways to design a fan regulator that can be controlled by the Arduino using a low cost design.


texts: Reading values from SQL Arduino ethernet

texts:
I'm about to do this project where I will make some lights flash up depending on some values that are in an SQL database on a server. I have already bought my Arduino and waiting for it to arrive. But I've been stuck at how to read the SQL data from the Arduino, connected to ethernet only.

Is there a library where I can select from the database directly or do I have to make a web service, in which I can make a http request to when needed?

If it's a web service, can I be directed to some examples of this being used with Arduino? I've been looking around the past few days but haven't been able to find a decent example.

Best regards and thanks a lot in advance for your time! :-)


texts: Can we connect 4 4-digit 7 segment LED Displays to a single Arduino board?

texts: Can we connect 4 4-digit 7 segment LED Displays to a single Arduino board ? Is it possible without another component in between ?


texts: How to make a servo sweep from 0 to 180 on press of a button on PS2 controller? (without delay)

texts:
I am working on a project that requires the servo to make a complete sweep once on pressing a button say r2 on the pS2 controller. I am using the Arduino Mega 2560,a PS2 controller clone, Bill porter's Ps2x library.

I have figured out a way to do so by adding a delay to the code but when the delay is used I can't use other parts of my project. What should I do?

int pos = 0;    // variable to store the servo position
int button = 2;  // The button will be on Pin 7
void setup()
{
myservo.attach(9);  // attaches the servo on pin 9 to the servo object
pinMode(pos, OUTPUT);
pinMode(button, INPUT);
digitalWrite (button, LOW);
}

void loop()
{
if(ps2x.ButtonPressed(PSB_RED))

for(pos = 0; pos < 90; pos += 90)  // goes from 0 degrees to 90 degrees
{                                  // in steps of  degree
 myservo.write(pos);

}
  if(ps2x.ButtonReleased(PSB_RED))

 for(pos = 90; pos>=90; pos-=90)
 {
myservo.write(pos);
delay(50);                             // waits 50ms for the servo to reach the position


texts: How many total digital pin outs does the Arduino Yun have

texts: I have read the details on the products page for Arduino Yun but I have also read, on a Arduino forum, that there are only 18 digital pins because of Tx, and Rx. Is this true? I am not worried about the PWM, or analog capabilities of the pins, just purely digital.


texts: ESP8266 ASCII to HEX convertion and checking

texts:
I am trying to convert ASCII to hex and check if the hex is equal to that hex that I want.

For example:

1B 42 05 it means B in ASCII, I need to check if that hex is equal to 1B 42 05.

Here I need to send converted hex code from ASCII code by using SoftwareSerial.

Example:

02 20 2D 33 30 32 35 30 20 6B 67 0D 0A 03

I have to convert to

-30250 kg


texts: Connect two UNO WIFI REV2 to communicate with one another through WIFI

texts: I have two UNO WIFI REV2. I want the first Arduino to send a message to the other to print "hello, world" on the LCD screen of the second Arduino. Is this possible without WiFi modules? If so, does anyone have a code for this. I think it requires some kind of server and client code.


texts: Servo.attach method causing strange issue

texts:
I am using the L298N motor driver for a robotics project to control 4 motors. 2 motors in each input and output terminal. I have this connected to an Arduino Uno which is powered by about 7-8v from NiMH batteries. This battery source also powers a servo with a 470uF capacitor and the L298N board.

I have a strange problem when I use the servo attach method for my servo, only outputs 1 and 2 on the L298N start working meaning the wheels on the left of the robot start moving only. When I have the servo connected and imported the library but don't use the attach method, the L298N outputs to all DC motors meaning it works. Even when I use the servo attach method on a pin where nothing is connected to it, the motors on out 4 and 3 on the L298N don't move. For some reason this attach method is causing issues. Can anyone explain why?

Note:  I applied a larger power supply, from my 7V to about 12V but the problem still persists. I don't think power is the issue since the problem even happens when the attach method is called on a pin that has no servo connected to it.


texts: Market Research - 4G Capable Arduino Module

texts:
Not sure if this belongs here, if there's a dedicated place I'll happily move this thread over there.
Like many people I have had issues with the 3G board from Adafruit ( https://www.adafruit.com/product/2691) especially in make HTTP GET Requests. I recently made a post on the Adafruit forums https://forums.adafruit.com/viewtopic.php?f=54&t=175691 that has working code to make HTTP GET Requests.
While that is fine for the minute, 3G is being depreciated so ideally everyone should be moving to 4G for thier projects. In my Reaserch for 3G code, I found some 4G chips that can be used as nearly drop in replacements for Adafruit's 3G modules.
The main question is how much would you be willing to pay for such a 4G module and what features would you want from such a module.
I'm not making any promises that I can bring such a module to market, and if it gets on the market it will be next year at the earliest.
Any input is appreciated,
Edward


texts: A few questions on the first steps with an ESP32/ESP8266 NodeMCU

texts:
I would like to know what are the first steps, as a good practice, when receiving a new ESP based NodeMCU. For example:

Checking if everything works fine
After you connect to the relevant COM port, using either putty, Arduino IDE or any other method, what are some basic commands to check the version and the status of hardware in general?

Reassuring a restore point
Is there a way to keep the initial/factory firmware in some kind of image? Or is the basic firmware stored in some kind of ROM that can't be changed by a user no matter what? In other words, is it possible to "brick" a NodeMCU in case something goes wrong, and how to prevent that?

Restore from backup
What is the proper reverse process to restore a NodeMCU to a previous state?

C / microPython
I have seen some projects using microPython instead of C, what is the standard way for start using a NodeMCU with microPython?

LUA (LUA shell)
What exactly is the role of LUA in a NodeMCU? Is it just the interface a user has available after the COM connection?


texts: Can I use a camera sensor from a not functioning smartphone in Arduino or Raspberry pi?

texts:
I want to use the OmniVision_OV16860 camera sensor from a not functioning Moto G4 plus phone to capture pictures using Arduino or Raspberry Pi.

Is it possible to do that? If yes, explain the whole process.


texts: I'm about to buy two ESP8266 modules. I want them to use as an auto deauth device. The first module will monitor my WiFi router's packet transmission. If a certain device receive loads of packets from my router (which hogs my network) the second module will deauth that device or flood "forged" packets. There will be a threshold so a simple web browsing will not trigger the deauth process from the second module. Btw. My router doesn't support traffic shaping & QoS. Only a different kind of QoS (DHCP & IPP/TOS) which is useless because my ISP doesn't support it.


texts: Send custom 802.11 data frame with ESP8266

texts:
I would like to send raw 802.11 data frames in order to transmit pictures with the ESP8266.
I have the Espressif SDK 1.3 and so far I have tried to construct a packet and send it with wifi_send_pkt_freedom, but it didn't work. I cannot pick it up with wireshark or airodump-ng on Kali.

here is the code:

wifi_set_channel(5);

uint8_t packetH[36]={
0x80, 0x00, //Frame Control
0x00, 0x00, //Duration
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, //Receiver Address= Destination Address
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, //Transmitter Address= Source Address
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, //BSSID
0x00, 0x00,                         //Sequence control
0x01, 0x02, 0x02, 0x03,0x03,0x03,0x04,0x04, //Body
0x05, 0x03, 0x02, 0x01 //FCS
};

wifi_send_pkt_freedom(packetH,sizeof(packetH),0);

For testing I just wanted to send some numbers in the Frame body, but later it should send pictures. The goal is to receive unidirectional video transmittion. One ESP8266 should send and the other one should receive. Both have their wireless card in monitor mode.

My guess is that the packet construction is complete wrong. Can someone help me understand how to "build" a proper packet?


texts:
I connected a HC-SR04 Ultrasonic Sensor to Arduino Uno and built the circuit as shown in the link below. I also used the code below the link. Together, this code and the circuit detect any motion that occurs in front of the ultrasonic sensor. When the sensor detects motion, the console in the Arduino IDE prints that it detects motion and how far away the moving object is. Otherwise, nothing is printed.

I created an app using MIT App Inventor. Every time the Arduino detects motion, I want a sound to be played on the phone of the person with the app. In order to do this, I plan on using a HC-05 Bluetooth Module.

Does anyone have any suggestions for how I should build the circuit and what code I should use?

arduinobasics.blogspot.de/2012/11/arduinobasics-hc-sr04-ultrasonic-sensor.html

#define echoPin 7 // Echo Pin
#define trigPin 8 // Trigger Pin
#define LEDPin 13 // Onboard LED

int maximumRange = 200; // Maximum range needed
int minimumRange = 0; // Minimum range needed
long duration, distance; // Duration used to calculate distance

void setup() {
 Serial.begin (9600);
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);
 pinMode(LEDPin, OUTPUT); // Use LED indicator (if required)
}

int prevdist = 0;

void loop() {
/* The following trigPin/echoPin cycle is used to determine the
 distance of the nearest object by bouncing soundwaves off of it. */
 digitalWrite(trigPin, LOW);
 delayMicroseconds(2);

 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10);

 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);

 //Calculate the distance (in cm) based on the speed of sound.
 distance = duration/58.2;

 if (distance >= maximumRange || distance <= minimumRange){
 //Print "Out of range when there is no object within the range of the ultrasonic sensor.
 Serial.println("Out of range.");
 digitalWrite(LEDPin, HIGH);

 }
 else {

 /* Send the distance to the computer using Serial protocol, and
 turn LED OFF to indicate successful reading. */

   if((prevdist - distance) > 10 || (prevdist - distance) < -10)
   {
     prevdist = distance;
     Serial.println("[OBJECT MOVED]");
     Serial.print("Detecting object ");
     Serial.print(distance);
     Serial.println(" cm away");
     Serial.println();
     digitalWrite(LEDPin, LOW);
   }
 }

 //Delay 1 millisecond before next reading.
 delay(1);
}


texts: Powering Arduino and transistors with one power supply > 12V

texts: So say you want to use transistors with your Arduino Nano to power components, which require greater than 12V. If your power supply is more than 12V, is there a way to safely use the same power supply to power the Arduino?


texts: What should I use Arduino-Mega or Rasbeery pi?

texts: I am doing a project on Vehicle tracking and security. In my project Micro controller will sense input from sensors and at the same time it has to sense signal from user for tracking purpose and continuously checking the speed limit and boundary. so, there will be 3-4 tasks that would be executing parallel. Can anyone suggest which one is perfect for this kind of project... Arduino-Mega or Rasberry Pi?


texts: Correct solution for "multiple definition of" compile error

texts:
I'm in the process of trying to take this demo sketch and extract the necessary bits into a modular library that can be included in other sketches.

Here's where I'm at so far.

Here's the test sketch that I'm including it in.

However, when I try to compile it right now, I'm getting...

libraries/Adafruit_CC3000_Dynamodb/sha256.cpp.o: In function `Sha256Class::init()':
/home/me/sketchbook/libraries/Adafruit_CC3000_Dynamodb/sha256.cpp:33: multiple definition of `Sha256Class::init()'
sketch/sha256.cpp.o:sketch/sha256.cpp:33: first defined here

I've been programming for years in other languages, but I'm not all that experienced in C. I'm sure I'm doing something completely stupid, but I can't figure out what it is.

I'm also aware that this code still needs a lot of cleanup work in general. Right now I'm just trying to work toward a basic MVP that works so that I start gradually cleaning things up and making it more OOP one step at a time.


texts: Differing behaviour from Arduino Nano when plugged into laptop vs power source

texts:
Well here's a weird one. I'm monitoring a mic on an analog pin of an Arduino Nano and using the variation in voltage to control and LED.

When plugged in to my Laptop (USB 3, 500ma available, the nano only pulls 90) the detection is flawless. When plugged into an external power source, I get no variation at all or a random, non-responsive pattern of variation. Could be I'm getting voltage values that are out of range, but of course I can't monitor them on the serial port when I'm not plugged into the laptop.

I've got a potentiometer on the circuit to increase or decrease sensitivity by changing the trigger value. I can play poke-and-try at changing the trigger values to higher and lower ranges to try and find the sweet spot, but does anybody have an explanation of why I'd see a difference in the first place? I've tried a variety of external supplies, 500ma 1a, 2a - but if it's only pulling 90 (as reported by my Macbook System Report) this shouldn't matter, right? What else could account for differing behaviour?

Here's the code:

    void loop()
{
   unsigned long startMillis= millis();  // Start of sample window
   unsigned int peakToPeak = 0;   // peak-to-peak level

   unsigned int signalMax = 0;
   unsigned int signalMin = 1024;

   // collect data for 50 mS
   while (millis() - startMillis < sampleWindow)
   {
      sample = analogRead(0);
      if (sample < 1024)  // toss out spurious readings
      {
         if (sample > signalMax)
         {
            signalMax = sample;  // save just the max levels
         }
         else if (sample < signalMin)
         {
            signalMin = sample;  // save just the min levels
         }
      }
   }
   peakToPeak = signalMax - signalMin;  // max - min = peak-peak amplitude
   double volts = (peakToPeak * 5.0) / 10;  // convert to volts
   val = analogRead(potPin);
   if (val > 0) triggervoltage = 10;
   if (val > 500) triggervoltage = 11;
   if (val > 800) triggervoltage = 12;
   if (val > 1000) triggervoltage = 15;

   Serial.println(val);
   Serial.println(triggervoltage);
   Serial.println(volts);
//triggervoltage =
//Serial.println(volts);
//Serial.println(val);
//THIS IS the trigger mechanism for the effect. Vary the volts value to adjust sensitivity.

   if (volts > triggervoltage) [LED RESPONSE HERE]


texts: Arduino and reading from multiple USB connections

texts:
I'm sending up a high-altitude balloon with an onboard Mighty Ohm Geiger Counter and some other sensors, all of which will be managed by an R Pi B+. I'll collect and store the data with the R Pi; all of that's fine.

In order to track and recover it, I'm using the HABDuino shield on an Arduino. It uses the APRS system and sends back short messages, giving the altitude, internal temp, my callsign, and coordinates. I'd like to add the Geiger counter's data to that, but I'll need to get it from the R Pi.

Currently, I'm using an FTDI Friend to connect the Gieger counter to the R Pi, and getting the data from the serial port. I see here that I can connect the Arduino and Pi vai USB, but... since there's already a USB connection to the Gieger counter, will there be a conflict? Is that something that I can work around?

Thanks for the help!


texts: Reading and processing a PWM on AtTiny45

texts:
I have this question and I can't find answers!

I wanted to use an AtTiny45V (due to low voltage requirements, it will run at 1.8 volts) to read a PWM from an Arduino, and then process this information.

Explained better:

let's say, I hook up one pin of the AtTiny to an Arduino pin (named connection), and in the IDE I write:

AnalogWrite(connection,X)

I want the AtTiny to write high on a port based on the X value.

Example:

X = 20 writes high on AtTiny PB5

X = 25 writes high on AtTiny PB5 and PB3

etc...

So, basically I want to read the duty cycle from the Arduino PWM and let the AtTiny do something based on duty cycle value.

Is this possible?

Thanks


texts: ERROR: Timed out waiting for Arduino 101 - anything I can do?

texts:
I just received an Arduino 101 so I did the following in a wave of excitement...

Connected the USB cable between it and my Macbook Pro
Started the Arduino IDE version 1.6.7
Wrote a little bit of code
Selected Tools | Boards | Boards Manager... and installed the Intel Curie Boards as per Getting Started
Selected Tools | Board: "Arduino 101"
Selected Tools | port: "/dev/cu.usbmodemFA141 (Arduino 101)"
Selected Sketch | Upload

I was expecting something amazing, but I got the error:

Starting upload script
Payload: /var/folders/jr/5rmqcrqj58103d4p1f6_3sjr0000gn/T/build7c6ce067b9e8a57f9917c651ec494989.tmp/orientation.ino.bin
Waiting for device...
ERROR: Timed out waiting for Arduino 101.

Is there anything I can do to debug this or did I miss a step perhaps?

(I tried the good ol' turn it off and on again, including shutting the IDE down).


texts:
I am experimenting with CIRC-03 but the DC motor won't start spinning with motorAcceleration(); unless I give it a push. Also, it makes a little noise when it stands still.  It does spin, however, with one of the first two functions (motorOnThenOff(); motorOnThenOffWithSpeed()). I've tried adding the 220 µF capacitor but that doesn't change a thing.

Could someone offer me a solution to this problem?


texts: How can I receive signal from remote control using tcrt5000 sensor module

texts: how can I use tcrt5000 sensor module instead of TSOP31238 (TSOP1738) IR receiver to get signal from remote control? I want to create remote control for my PC to navigate through my slide shows. Thanks in advance.


texts: Collecting data from a timer interrupt and storing it into an array

texts:
My question is: how can I use an ISR and store the data I get from my analog inputs into an array for easier data analysis.
More specifically, I want to collect my data using an ISR function (internal timer interrupt), then store the collected data into an array. This way I can analyze the data more easily.
I have posted the code below. I have posted code showing how I implemented my ISR without storing the data into an array. I was wondering I anyone could help me out with this (how to store that data into an array). Thank you.
const int A0_pin = PC0;
const int A1_pin = PC1;

const uint16_t t1_load = 0;
const uint16_t t1_comp = 3173;

float count = 0;
float num = 0;

void setup() {

  //Set A0 and A1 pins as inputs
  DDRC &= ~(1 << A0_pin);
  DDRC &= ~(1 << A1_pin);

  //Reset Timer1 Control Reg A
  TCCR1A = 0;

  //Set CTC mode
  TCCR1B &= ~(1 << WGM13);
  TCCR1B |= (1 << WGM12);

  //Set to prescaler of 256
  TCCR1B |= (1 << CS12);
  TCCR1B &= ~(1 << CS11);
  TCCR1B &= ~(1 << CS10);

  //Reset Timer1 and set compare value
  TCNT1 = t1_load;
  OCR1A = t1_comp;

  //Enable Timer1 compare interrupt
  TIMSK1 = (1 << OCIE1A);

  //Enable global interrupt
  sei();

  Serial.begin(9600);
  Serial.println("CLEARDATA"); //clears up any data left from previous projects
  Serial.println("LABEL,TIME,TIMER,AVG,GAUGE0, GUAGE1"); //always write LABEL, so excel knows the next things will be the names of the columns
  Serial.println("RESETTIMER"); //resets timer to 0
}

void loop() {
}

ISR(TIMER1_COMPA_vect) {
  TCNT1 = t1_load;
  float Gauge0 = analogRead(A0_pin);
  float Gauge1 = analogRead(A1_pin); //44

  //conversion of read data, to voltage range (0-100 percentVolts)
  float gauge0 = Gauge0 * (100.0 / 1023.0);
  float gauge1 = Gauge1 * (100.0 / 1023.0);
  float add = gauge0 + gauge1;
  float AVG = ((gauge0 + gauge1) / 2);

  Serial.print("DATA,TIME,TIMER,");
  Serial.print(add);
  Serial.print(",");
  Serial.print(gauge0);
  Serial.print(",");
  Serial.println(gauge1);
}

In the code, I want to store the gauge1 and the gauge0 values into an array essentially.


texts: List of Arduino board preprocessor #defines

texts:
When one selects a board within Arduino IDE, a preprocessor definition is added to one of the behind-the-scenes files.

After a lot of hunting and some good fortune I found that the format of this definition is:

#define ARDUINO_<PROCESSOR-DESCRIPTOR>_<BOARDNAME>

Some are easy to guess (ARDUINO_AVR_UNO, for example), but others are less so. The Pro Micro has '16' or '8' appended to the definition depending on the speed. I do not know if the definition is different for 5V or 3.3V. I haven't managed to guess the definition for the Mega2560, but it isn't anything obvious.

Question 1: Is there a list in existence of the possible definitions?

Question 2: Is there any distinction, as far as compilation and preprocessor involvement is concerned, between BoardX-5V and BoardX-3.3V, and how is this distinction defined?


texts: Passing serial data to Processing using something other than ln to trigger Processing

texts:
I have a Uno program and I can transfer data to Processing using println. In Processing bufferUntil('\n') interprets the ln  as \n, stops buffering, and reads the string until the next '\n'. I would like to use something other than ln to trigger Processing. That way I can use Serial Monitor in the Uno to see serial data when Processing is not running at the same time.

I have searched the net but have not found the technique to use something other than ln. Thanks.


texts:
I am receiving bytes, converting them into hex and now I need to convert the hex to ASCII. Can it be done on an Arduino? Or do I need something else?
I am new to programming with Arduino.


texts:
I'm wanting to make a keypad for my gragedoor. I found one like this but i don't think it is very waterproof.

Now i'm wondering if someone of you know a good keypad that can be used outdoors and can be connected to a arduino (preferably arduino nano).

Hope you can help.

Edit if found this keypad will i be able to program this one with a arduino?
link


texts: is it possible to program an arduino with usb/ttl adapter

texts: i want to upload sketch into arduino uno using usb/ttl adapter.i tried searching for it, but found about programming arduino using another. can anyone help me.


texts: How to add the -F switch for avrdude in Arduino IDE

texts:
So, before starting to learn with something else, I'll give it one last try. The avrdude is complaining that the device signature doesn't match. Whatever, I don't care. To me, what's written on it is what counts.

So I'd like to force it to upload the program. It promises to ignore the problem if -F is specified.

Where are settings for avrdude parameters, like other IDEs have settings for their compilers?


texts:
I've been struggling with some code that was failing to "begin()" any devices on my i2c bus. I've uploaded a scanner program from arduino playground which lists the addresses of any i2c modules found.  With a single sensor connected the whole arduino freezes but when I unplug the wires from the a4 and a5 pins it continues. Plug them back on and it locks. I've tried with the SDA / SCL wires reversed as I've seen mention of things being backward.

Anyone know what I'm missing?


texts: So I'm trying to work on a project and need to include bluetooth. The latest problem I have is I'm using a Lilypad Arduino and need to keep the project in the same round area. I was looking at this: https://www.sparkfun.com/products/12580 however I'm not sure how I would make it smaller? Does it have to clip on or can I simply solder it in a way that it's resting directly above/below the Lilypad?


texts: Will the 3.3V regulator on an Arduino Leonardo work when powered from USB?

texts: Will the 3.3V regulator produce 3.3v when the Arduino is powered from the USB port?


texts:
Please help me! Once I click the upload button.
I get the following error:

  'serialWrite' was not declared in this scope

Here is my code:

int buttonPin
void setup ()
{
beginSerial(9600);
pinMode (buttonPin, INPUT);
}
void loop ()
{
if (digitalRead(buttonPin) == HIGH)
serialWrite('H');
else
serialwrite('L');
delay(1000);
}


texts: Generate a ramp input with an Arduino Uno

texts:
Is there anyway to generate a ramp input from an Arduino Uno? A visual depiction of the pulse I am looking for is as follows:

With other microcontrollers, I was able to use their in-built DACs, however I am aware that the Arduino UNO doesn't have any? Is there a way using PWM or analogWrite to output these type of pulses? I'm new to Arduino programming, so I'm a bit unsure. However my next guess would be to use an R-2R ladder to output this type of pulse?


texts: How many sensors can an ARDUINO UNO support?

texts: I'm doing a project that requires me to use 4 different sensors, namely a load sensor, RFID tag sensor, 2 IR sensors and a Hall effect sensor on one Arduino Uno board, along with a L293D motor expansion shield. Is this possible? or will there be some issue with doing this?


texts:
I have an HC-05 Bluetooth module attached to an Arduino Mega; the module is paired with a Raspberry Pi and fed data via a python program; there's roughly one send and one receive per second of about 35 bytes.

When I first power up the Arduino / HC-05, it flashes quickly, and then after pairing, it flashes twice every second indicating a successful pair & communication. All is good; data is flowing. Periodically (5 minutes? 3 hrs?) & unpredictably, the communication ends; I'm still trying to troubleshoot this; the python code on the RPi reports a not-helpful OSError: [Errno 5] Input/output error on the available() method of the pySerialTransfer library; though I welcome thoughts on that, I realize that question isn't for this forum.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/.local/lib/python3.7/site-packages/pySerialTransfer/pySerialTransfer.py", line 416, in available
    if self.connection.in_waiting:
  File "/home/pi/.local/lib/python3.7/site-packages/serial/serialposix.py", line 467, in in_waiting
    s = fcntl.ioctl(self.fd, TIOCINQ, TIOCM_zero_str)
OSError: [Errno 5] Input/output error

The HC-05 module continues to flash as if it's connected, even though it is not, and even if I restart the python program, I'm unable to repair with the HC-05.  The only way I can figure out to reconnect to the HC-05 is to power the Arduino / HC-05; then I can reconnect.

So here is the question: is there to reset the HC-05 from within the Arduino sketch? I realize I could attach the VCC to a digital pin to do a full power cycle on the HC-05, but I believe the HC-05 draws on the outer limit of safe current for an Arduino (40ma); I could go thru a relay to do the disconnect, but I wonder if there's a cleaner way with fewer moving parts, or if that is indeed the best way?

Thanks for any guidance!


texts:
I have did something stupid.. I connected 10K Ohm potentiometer at its maximum value PARALLEL with a LED. The positive long leg of the led to arduino 5v and the negative leg to the GND.
After giving arduino 5v from USB Mobile Charger ( Output: 5V , 1A ) I smelt a burn and quickly removed the charger from the outlet.
I waited a few hours and connected the arduino ( without any components ) to the charger again. and the arduino worked. I then connected it to the PC and uploaded the blink sketch of the on-board led and it worked !
Then I uploaded a sktech for blinking led on other pins and it worked also !

My question is:
1) What is damaged on the board ?
The smell is near the regulator but I'm not sure if it's from the regulator itself or just a component near it.

2) Can it be safe to still using the arduino board on USB Power or Battery Power without any problems ?


texts: Can I Interrupt on any keypress on this keypad?

texts:
I'm learning how to write code interrupt code. I just experimented with my first toy example that I got from here:

const byte ledPin = 13;
const byte interruptPin = 2;
volatile byte state = LOW;

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), blink, CHANGE);
}

void loop() {
  digitalWrite(ledPin, state);
}

void blink() {
  state = !state;
}

Now I'm trying to incorporate interrupts into my own project. I have a circuit that looks like this using an Arduino Uno Wifi Rev2, Membrane 3x4 Matrix Keypad, a buzzer, some resistors and an RGB LED:

Can I write code such that it interrupts any time any of the keys is pressed (and I can still tell which key is pressed)? How would I do that?


texts:
I have a QMC5883L magnetometer, and a pretty basic sketch which just prints the values from X, Y and Z axis to the serial monitor.

I want to use it in an application to detect changes in the magnetic field, and the sensor will be in a fixed position. However, it seems that when I start the Arduino, the values from the sensor are all over the place (looking at it in the serial plotter all 3 axis are going from 1 extreme to the other and back). If I move the sensor around a bit, the values calm down and become more steady, and usable to detect metal objects approaching the sensor.

Since the sensor will be installed in a fixed position, I can't move it around to calibrate it every time the Arduino restarts. Can I calibrate it programatically somehow? Note that I don't really need to know which way it is oriented, I simply want to detect when the magnetic field changes (i.e. when a metal object approaches/leaves the sensor).


texts:
I'm a member of a Formula SAE team and we use the Performance Electronics ECU which uses the CAN protocol with a speed of 250 kbit/s and works fine with our 2D Recording Systems Data logger, but we're trying to build a telemetry system which gathers the same data from the CAN bus using an Arduino Uno and CAN shield provided by SparkFun Electronics.

However the CAN shield we're trying to use has failed to initialise the communication with the bus. Kindly help me out on what can be done or are there any alternatives of communicating using CAN with Arduino?

P.S. The link for the CAN shield: CAN-Bus Shield Hookup Guide


texts: Terminal read-only serial monitor without blocking serial port for sketch upload

texts:
I would like to have all serial output from Arduino (nano) dumped to the terminal in Linux, without blocking the serial port for uploading new sketch version (for quick debugging loop), when using Arduino-Makefile:

[Errno 16] could not open port /dev/ttyUSB0: [Errno 16] Device or resource busy: '/dev/ttyUSB0'

Is there something made for that already? I did read about 10 related questions here and elsewhere (using screen, socat and others) but none of them deals with the question how to not block the port.

I might eventually code something in Python, which will disconnect when  signalled and reconnect again after a few seconds (I use custom Makefile for the upload) and I imagine Arduino's IDE serial monitor does something similar.

Other pointers on how to solve the issue are appreciated!


texts:
How can I convert a float value into a String object without implementing any library?

I'd like to avoid using char array.


texts: error: 'CLASS' does not name a type only when creating object inside another object

texts:
I'm trying to use Adafruit's LED Backpack library within a custom class. When I use the Adafruit library directly within a sketch, it compiles fine. When I use an example sketch provided with the library, it compiles fine. However when I create an instance of my custom class with the Adafruit object within it, I get the following error:

  In file included from sketch_feb18a.ino:6:
  /Users/lawnmowerlatte/Documents/Arduino/libraries/Bargraph/bargraph.h:18: error: 'Adafruit_24bargraph' does not name a type

All the reasons I've seen for this error stem from the library being missing or otherwise incorrectly installed. However, since I can use it directly, I think something else must be wrong.

Working

#include <Adafruit_LEDBackpack.h>
#include <Adafruit_GFX.h>
Adafruit_24bargraph bar = Adafruit_24bargraph();

void setup() { }
void loop() { }

Not Working

#include <bargraph.h>
Bargraph bargraph = Bargraph("Test", "api", 0);

void setup() { }
void loop() { }

bargraph.h

#ifndef Bargraph_h
#define Bargraph_h

#include <Adafruit_GFX.h>
#include <Adafruit_LEDBackpack.h>

#if (ARDUINO >= 100)
#include <Arduino.h>
#else
#include <WProgram.h>
#endif

class Bargraph {
  public :
    String name;
    String api;
    Adafruit_24bargraph bar;

    Bargraph(String _name, String _api, int _device,
        String _type="Default");

    void set(String _value);
    void setMax(String _max);
    void update();
    void print();

  private :
    int display[24];

    long max;
    long value;
    int device;
    int size;
    String type;

    void format();
    void write();
};

#endif

bargraph.cpp

#define OFF 0
#define RED 1
#define YELLOW 2
#define GREEN 3

#include <bargraph.h>

#if (ARDUINO >= 100)
#include <Arduino.h>
#else
#include <WProgram.h>
#endif

Bargraph::Bargraph(String _name, String _api, int _device, String _type) : bar() {
    name        = _name;
    api         = _api;
    max         = _max.toLong();
    device      = _device;
    type        = _type;
    value       = 0;

    for (int i=0; i<24; i++) {
        display[i] = OFF;
    }

    bar.begin(0x70+device);
}

**Methods Omitted for Brevity**

Can anyone explain what's going on here? I'm pretty certain my class syntax is correct as I have other object-in-object relationships working. I can post code to GitHub if anyone would like to see more context.


texts:
I am working on a project (the scenario is depicted in the attachment) involving Bluetooth Low Energy (BLE). As a master (central device) I am using the Adafruit nRF52 feather board (https://learn.adafruit.com/bluefruit-nrf52-feather-learning-guide/introduction) and as slaves (peripheral devices) a pair of Adafruit nRF8001 modules (https://learn.adafruit.com/getting-started-with-the-nrf8001-bluefruit-le-breakout/pinouts?view=all#introduction). Moreover, I have to wire the nRF52 up with an Arduino Uno rev3.

I am trying to set up the very initial communication between central and peripheral devices, but if I even try to upload the blinky sketch into the nRF52 board the compiling phase returns to me the following error:

  exec: "nrfutil": executable file not found in $PATH

Does anyone have an idea what it means? I googled a lot but I am not able to figure it out on this problem.

Thanks in advance to anyone would be able to help me!

Filippo

[EDIT] Solved: just need to install the nfrutil first, as written in https://learn.adafruit.com/bluefruit-nrf52-feather-learning-guide/arduino-bsp-setup#nrfutil-os-x-and-linux-only


texts: Send RF 433MHz data to Domoticz RfxCom with protocol X10 from Arduino Nano

texts:
I have installed Domoticz on Raspberry Pi and bought an RfxCom 433MHz emitter/receiver.
It works well for example with Chacon DiO 54781 door sensor.
I want to create my own sensor with Arduino that would be recognized by Domoticz as a native RF 433MHz device.
In first place, I want to make a flooding sensor, I also need an On/Off information.
I would like to implement X10 protocol because it seems to be the simplest one.


texts: How to connect a Pressure Sensor-MPX10DP to an Arduino?

texts:
I'm very new to Arduino, I'm trying to connect an air pressure Sensor without success.

I followed this tutorial:

Arduino Air Pressure Measurement

The values I'm getting are very weird and the variations when I blow in the sensor are not more than about +/- 0.2.

So, the tutorial does use the same model, is that why? I need something else?

Any help will be very appreciated.


texts: Arduino two sketch add to single sketch based on timers

texts:
How to add two sketch in single sketch and run same time because one sketch timer1 used and another sketch used timer0 and timer2
both sketch have setup()and loop () so how to add please help us with example


texts: ESP8266 in AP Mode -determining if a station is connected

texts:
I have an ESP8266 running in AP mode using softAP and i want to conserve battery life.
I am wanting to turn on wifi and advertise SSID for 20 seconds. If no station connects to the ssid within the 20 seconds, I want to go to sleep for 1 minute, otherwise I do not sleep.

My problem is that I cannot get "WiFi.softAPgetStationNum()" working. when I build i get a message that this is not part of ESP8266WiFi class. I have attached simplified code.

Can someone help me to achieve this please?

#include <ESP8266WiFi.h>

//WIFI Access point setup
const char* Ssid = "SSID";
const char* Password = "Password";
IPAddress ip(10,0,0,10);
IPAddress gateway(10,0,0,1);
IPAddress subnet(255,255,255,0);
WiFiServer server(80);                    // Set web server port number to
80

// GPIO pins
const int output_set = 5;
int delay_loop=0;

void setup()
{
  // Data Direction
  pinMode(output_set, OUTPUT);

  // Output initial Values
  digitalWrite(output_set, LOW);

  WiFi.softAPConfig(ip,gateway,subnet);
  WiFi.softAP(Ssid,Password);
  server.begin();

// check to see if a station is connected to this AP. If no station
connected within 20 sec timeframe, go to sleep.

while (WiFi.softAPgetStationNum()==0)              //loop here while no AP is connected to this station
{
    delay(1);
    delay_loop++;
    if (delay_loop>=20000)
    {

        ESP.deepSleep(60e6);                          //go to sleep for 60 sec -wake pin externally connected to reset pin
    }
}
}

void loop()
{
   digitalWrite(output_set, HIGH);      //Flash led once station is connected
   delay(200);
   digitalWrite(output_set, LOW);
   delay(400);
}


texts: Does anyone have a data sheet for MC16-0072

texts: I can't seem to relibly find data sheets for MCM electronics parts.. Searched for hours.. Any help?


texts:
Im having a little problem with my code. here i called a function to make a test, if it passed it goes back and continue if it doesn't it goes to main loop.

void loop()
{

    if (call == 1)
    {
        funca();
    }
    print("waiting..");
}
 void funca()
    {
        gsmtest();
        print("calling..")
    }
 void gsmtest()
    {
        if (test==1)
             {
            print("test ok");
             }
        else
              {
                print("error");
                loop();
              }
    }

here is a simple example, if u press call, the code goes to funca which make a call to gsmtest. if test goes ok it print "calling.." if not it print "error" and goes back to loop. for some reasons here if test failed, it print error and than goes to loop after that it print "calling.." (continuing funca which i want to abort it if test goes wrong) .


texts:
With WebSocket various messages arrive.
Task:

Find message "setBrightness: 15"
Extract the value "15" from the message (the value can be any)
Convert this value to uint8_t

My code:
#include <string.h>

String payload_str = "setBrightness: 15"; // WebSocket message
const char* payload = payload_str.c_str(); // Convert string to char

const char* value; // Message value
uint8_t brightness;

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

  if(strncmp(payload, "setBri", 6) == 0) { // Search message
   value = strtok(payload, " ");
   value = strtok(NULL," "); // Get value (15)
   brightness = (uint8_t)atoi(value); // Convert to uint8_t
  }
}

void loop() {}

Compilling error:

error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
error:   initializing argument 1 of 'char* strtok(char*, const char*)' [-fpermissive]

Maybe I'm doing it completely wrong and not safe. How can this be fixed?


texts:
I'm still struggling with the Servotimer2 library

I have an Arduino uno board with a servo motor with the servotimer2 library because I'm using a music shield beside the servomotor and the music shield library and the servo.h wasn't compatible.
But finally I make the two of them working together with the servotimer2.h but now I want my servo to rotate 90 or 180 and then "stop" for a minute and come back again, rotate, stop, rotate,stop, rotate, stop... short of thing so I read this what is commonly done to stop a servo after reaching desired point and now I know that servo can't stop, but they can detach
so I tried making something like this

#include <ServoTimer2.h>  // the servo library
#define rollPin  9

ServoTimer2 servoRoll;

void setup() {
  servoRoll.attach(rollPin);

}

// this function just increments a value until it reaches a maximum
int incPulse(int val, int inc){
   if( val + inc  > 2000 )
      return 1000 ;
   else
       return val + inc;

}

void loop()
{
   mover();
   parar();

}

void mover() {
 int val;

   servoRoll.attach(rollPin);
   val = incPulse( servoRoll.read(), 2);
   servoRoll.write(val);
   delay(10);

}
void parar() {

  servoRoll.detach();
     delay(100);
}

but the servo is only moving very slow and I think is not detaching in any moment. I'm quite lost, I'm very noobie and in the post(what is commonly done to stop a servo after reaching desired point) they said things like making while(true){} loop in the setup? or use millis() and other things that I don't understand quite well
But someone tried to do something like control the time the servo is stopping with the delay, so I tried something like this

#include <ServoTimer2.h>  // the servo library

// define the pins for the servos
#define rollPin  9

int pos = 0;

ServoTimer2 servoRoll;    // declare variables for up to eight servos

void setup() {
  servoRoll.attach(rollPin);     // attach a pin to the servos and they will start pulsing

}

//from https://learn.adafruit.com/multi-tasking-the-arduino-part-1/a-clean-sweep

void loop()
{
 for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees
  {                                  // in steps of 1 degree
    servoRoll.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees
  {
    servoRoll.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }

}

but with this code, my servo is only moving once, and then stops and don't move again

and I think that my servo with the servotimer2 library is only moving with this

   int incPulse(int val, int inc){
   if( val + inc  > 2000 )
      return 1000 ;
   else
       return val + inc;
}

void loop()
{
 int val;

   val = incPulse( servoRoll.read(), 1);
   servoRoll.write(val);
  delay(10);
}

so, any ideas of what I'm doing wrong?


texts: Changing preferences.txt to 4-space tabs, how to AutoFormat existing code?

texts:
Title says it all really, but to elaborate, in my preferences.txt file, I've changed the editor.tabs.size variable to 4, which works wonderfully, and now produces 4-space tabs as do my other IDEs for all the languages I write in.

However, I was told that using the Tools->AutoFormat feature would update all lines in my previously-written sketches that had the standard 2-space tabs with the new 4-space tab layout.

This isn't so. Whether I CTRL-a to select all and run the Auto Format function, or whether I leave everything de-selected, nothing happens.

Should auto-format "fix" the 'incorrect' indenting to the new style? If so, what am I missing?

I'm currently on Arduino IDE 1.8.5 on Linux Mint, if that makes a difference.


texts: Wirelessly communicate between two Arduinos without router

texts:
I want to "connect" two Arduinos, without using wires. The range is ~0.2 miles (300 meters). Using Google, I saw too many options.

The idea is to build something like a beacon, so the bandwidth can be small. I want to send 32 or 64 bits/second of data (32 bits for the application + 32 bits for checksum if the module does not guarantee consistency of data).
The communication between Arduinos is bi-directional, and I'm looking for something cheaper than 50 US dollars per module.

Can I use a serial WiFi module for this, without using a router? Do you recommend a 2.4GHz module? Or a RF module?


texts: Storing byte array from serial and converting to a floating point number

texts:
I have tried getting my Arduino to communicate with another device, to no avail. The command A, when sent via serial to the device, triggers it to respond with 8 binary bytes with the first 4 representing a floating point number, and the final 4 representing a floating point number. The command only has to be sent once a second, and the aim is to store the 8 incoming bytes in an array, and convert them into their respective floats.

unsigned long previousMillis = 0;
const long interval = 1000;
char incomingByteA[8];

void setup() {
  Serial.begin(9600);
  while(!Serial);
  Serial1.begin(9600);
  while(!Serial1);
}

void loop() {
  unsigned long currentMillis = millis();
  if(currentMillis - previousMillis >= interval){
    //1 second timer
    previousMillis = currentMillis;
    Serial1.write('O');
    //Send command 'A' to device *noting Serial1 not Serial
    for(int n = 0; Serial1.available() < 8; n++) {
    incomingByteA[n] = Serial1.read();
    //Add each consecutive byte to an array until all 8 bytes have been added
  }
  float x;
  float y;
  ((byte*)&x)[3] = incomingByteA[0];
  //Convert first four bytes into a float
  ((byte*)&x)[2] = incomingByteA[1];
  ((byte*)&x)[1] = incomingByteA[2];
  ((byte*)&x)[0] = incomingByteA[3];
  ((byte*)&y)[3] = incomingByteA[4];
  //Convert final four bytes into a float
  ((byte*)&y)[2] = incomingByteA[5];
  ((byte*)&y)[1] = incomingByteA[6];
  ((byte*)&y)[0] = incomingByteA[7];
  Serial.println(x, 4);
}
}

However, when I do Serial.println(x);, it returns "nan". And if I try to do Serial.println(incomingByteA[2]);, it returns "?".

The following is the floating point format as per the device protocol:

31: sign of mantissa, 1=negative.
30-23: exponent, biased by 128.
22-0: mantissa, 24 bits, MSB hidden and always=1.

The mantissa is normalized, 24 bits with the MSB hidden. The MSB is always
assumed to be 1, therefore only 23 bits are needed to store the mantissa. The exponent is biased by 128; i.e. a 128 value represents an exponent of zero. A 129 value is an exponent of 1. Example: if the exponent has a 131 value (+3), the number is 2^3 * (mantissa). The mantissa is always less than one, and greater than or equal to 1/2. The number zero is stored as four zero bytes.

I am confident that it is not a fault with the hardware and for what it's worth, I am using a Leonardo. I would like to get the code down pat before I stress about hardware issues. What is this code not doing properly, if at all?

Thanks in advance.


texts: How to interpret accelerometer data to get decimals from -255 to 255

texts:
I'm using gy-521 module and I'm wondering how can i get useful readings from it so that i could work with the data that I'm receiving.

I want for AcX and AcY variable values to be from -255 to 255.
How to make this work.

sample data that I'm getting right now

X = 16380 Y = -64
X = 8116 Y = 3520
X = 12564 Y = 8728
X = -12652 Y = 1296
X = -17732 Y = -2420
X = -14576 Y = -2264

;

#include<Wire.h>
const int MPU_addr=0x68;
int16_t AcX,AcY;
void setup(){
  Wire.begin();
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x6B);
  Wire.write(0);
  Wire.endTransmission(true);
  Serial.begin(9600);
}

void loop(){
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
  Wire.endTransmission(false);
  Wire.requestFrom(MPU_addr,14,true);
  AcX=Wire.read()<<8|Wire.read();
  AcY=Wire.read()<<8|Wire.read();

  Serial.print("X = "); Serial.print(AcX);
  Serial.print(" Y = "); Serial.println(AcY);

  delay(333);
}


texts: Connecting GSM Dongle to Intel Galileo-Gen 2

texts:
I have tried to connect a GSM dongle to a Intel Galileo Gen2 board and test the functionality of sending and receiving SMS through it.I know that it is easier to use a GSM shield to do above, but I'm currently doing a project in the way i mentioned above.Basically in Linux, we should know the serial port(like ttyACM0 in /dev directory) correspond to the device to communicate with it(Using AT commands).

but when i tried it in Galileo board it doesn't show such a serial port.but it detect device because lsusb command shows the device.

does anyone can help me to solve this matter?


texts: How to program Esp8266 remotly via wifi?

texts:
I hope it's not a sci-fi for arduino. But I saw that dual system with two MCU can program each other via radio connection. It has been done in experimental space cube projects.
It is theoretically possible? I'm thinking about two arduino MCU first of them will be main MCU and second will be like programming device via serial link.I want to program mcu via wifi without cable connection. Somehow send hex file via wifi to eeprom and upload to second device flash memory.
How do you see this issue? Is that a big nonsense?


texts: Decoupling cap for self-powered LED matrix and LED strip

texts:
Should I add a decoupling capacitor to my RGB 16x32 LED matrix powered directly via the 5V pin?

When I display a spectrogram, the current load is fluctuating quickly in the 100-250 mA range (on average, the full range is 50-300 mA).

If yes, which capacitor should I pick for this purpose?

I have 0.01 μF, 0.1 μF ceramic and 1 μF, 2.2 μF, 4.7 μF, 10 μF, 100 μF electrolytic caps.

EDIT: I'm also interested to know about this WS2812B LED strip i've connected to the 5 V pin to another Arduino.

After reducing the brightness it has similar current consumption and fluctuation of the LED matrix.

In this tutorial they suggest to add a 1000 μF cap, but in my case the currents are much smaller.


texts: Compile-time 'Undefined reference' error for functions defined in a .cpp source file that are called in my main project file

texts:
I'm currently working with the NodeMCU ESP12E and MPU6050 IMU using the Arduino IDE and wanted to create a project that has a .h file that declares the variables and functions. In the .cpp file, I have various function definitions. The main.ino file just calls some of these functions. Please find some excerpts of code from each file and the errors I encountered. The errors say the three functions called in the .ino file are undefined even though they are defined in the .cpp file

Algo.h file:

extern int activity_state; // activity_state=1 for RUN and activity_state=0 for WALK
extern float * speedarray; // Dynamic array for storing speed
extern int speedindex;
extern float * timearray; // Dynamic array for storing time
extern int timeindex;

extern unsigned int localPort;

Algo.cpp:

static void pedometerInit() // Initialising all pedometer algorithm variables
{
      int i = 0;
  //pedometerAlgo varibles
  pedi_window_high = 2000;
  pedi_window_low = 200;

  pedi_sampling_counter = 0;
  pedi_refresh_frequency = 50;
  validZone = 1;
  jatin_index_1 = 0;
  jatin_mag = 0;
  pedi_max = 0;
.
.

All the functions work on the variables declared in the header file.

Ped_algo.ino:

void setup() {

  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(STASSID, STAPSK); // Setting up WiFi station
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print('.');
    delay(500);
  }

  Udp.begin(localPort); // Setting up UDP connection

  MPU6050_Init(); // Initial configuration of the MPU6050
  pedometerInit();
}

void loop() {

  pedometerAlgo();
}

Error messages:

Ped_Algo.ino.cpp.o:(.text.loop+0x0): undefined reference to pedometerAlgo()'
in functionloop':
 undefined reference to pedometerInit()'
 undefined reference toMPU6050_Init()'
 undefined reference to `pedometerInit()'

Error compiling for board NodeMCU 1.0 (ESP-12E Module).


texts: How Arduino UNO differentiate between program/flash and serial terminal data

texts:
I am excited to know how Arduino UNO or nano differentiate between program data that is to be burned into its flash when we press Upload Sketch and serial terminal data when we press Send? Is there any special sequence to identify those? How it will be identified by Bootloader?
And I have this understanding can anyone correct if I am wrong or anything you want to add will be helpful:

When we press Upload Sketch then a RST signal is sent.
ATmega controller when it receives RST signal jumps to Bootloader section of flash and waits for a perticular sequence from UART
If it receives then starts to write the data buffered from UART to flash. This process is handled by Bootloader.
If it doesn't receive the sequence waits till timeout and then jumps to flash section and starts to execute from 0x0000


texts: Distance Sensor. Calculating running median and Average

texts:
I'm trying to smooth out values for my IR distance sensor through running median filtering and a running average. I've tried to do the averaging, but my values don't seem correct and I am confused about how I would do the median filtering. I am also using timer interrupts and I don't want to use libraries when calculating the average and median. I've attached the code where I attempted to calculate the average.

int analogpin=5;
int sum=0;
int index=0;
int averead=0;
const int numreadings=9;
int i;
int timer1_counter;
int adc_val;
int int_flag;
int int_array[9];
float V;

void setup() {

int_flag=0;

Serial.begin(9600);
pinMode(analogpin,OUTPUT);
for(i=0; i<=8; i++){
  int_array[i]=0;
}

noInterrupts();           //

  TCCR1A = 0;
  TCCR1B = 0;

timer1_counter = 59286;

  TCNT1 = timer1_counter;
  TCCR1B |= (1 << CS12);
  TIMSK1 |= (1 << TOIE1);
  interrupts();
}

ISR(TIMER1_OVF_vect)
{
  TCNT1 = timer1_counter;
  int_flag=1;
    }

void loop() {

  if (int_flag==1){
    adc_val=analogRead(A2);
    V=5.0*adc_val/1023.0;
    analogWrite(analogpin,adc_val/4);
    }
    sum=sum-int_array[i];
    int_array[i]=analogRead(A2);
    sum=sum+int_array[i];
    index=index++;
    if(i==9){
      i=0;
    }
    averead=sum/numreadings;
    Serial.print("\n"); Serial.print("Average Filter Reading: ");
Serial.println(averead);
    delay(1);
    }


texts: Confusion on array definition at Arduino website

texts:
See the below explanation about Arrays from Arduino's official site:

  Creating (Declaring) an Array

  All of the methods below are valid ways to create (declare) an array.

  int myInts[6];
  int myPins[] = {2, 4, 8, 3, 6};
  int mySensVals[6] = {2, 4, -8, 3, 2};
  char message[6] = "hello";

  You can declare an array without initializing it as in myInts.

  In myPins we declare an array without explicitly choosing a size. The
  compiler counts the elements and creates an array of the appropriate
  size.

  Finally you can both initialize and size your array, as in mySensVals.
  Note that when declaring an array of type char, one more element than
  your initialization is required, to hold the required null character.

I have the following problems to understand:

Isn't int mySensVals[6] = {2, 4, -8, 3, 2}; wrong? I count 5 elements.
Isn't char message[6] = "hello"; is wrong as well? I count 5 elements.


texts:
Is it possible to reset an Arduino (i.e., to reboot it) from code (i.e from the sketch itself)? I know that is possible with a special circuit but is there a chance to make it just with code?

Below is my code and the comment //reset is where I want to force a reset.

#include <TrueRandom.h>

int i;
int randSeed;
long randNumber;

void setup(){
  Serial.begin(9600);
  Serial.println("20 pseudo Zufallszahlen:");
  for (i=1;i<=20;i++) Serial.print(random(10));
  Serial.println();
  Serial.println();
  //randomSeed(TrueRandom.random());
  randSeed = analogRead (A0);
  randomSeed(randSeed);
  Serial.print("Der 'seed' Wert: ");
  Serial.println(randSeed);
  Serial.println();
  Serial.println("20 Zufallszahlen mit analogem 'seed' Wert:");
  for (i=1;i<=20;i++) Serial.print(random(10));
  Serial.println();
  Serial.println("---------------------------");
  Serial.println();
  delay(500);
  //reset
}

void loop() {
}

I want to reset the micro-controller at the end of the setup function to show the effect of random numbers with and without a seed.


texts: NodeMCU 1.0 - Exception 9 `Fatal exception 9(LoadStoreAlignmentCause):`

texts:
I am getting this error in my code.
Fatal exception 9(LoadStoreAlignmentCause):

Using core version 2.4.2

Stack trace

Decoding stack results
0x40213e9c: dns_gethostbyname at core/dns.c line 1472
0x40204c21: ESP8266WiFiGenericClass::hostByName(char const*, IPAddress&, unsigned int) at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp line 468
0x40205038: WiFiClient::connect(char const*, unsigned short) at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/libraries/ESP8266WiFi/src/WiFiClient.cpp line 98
0x4020306b: setPostString(int, int, Array8Int, char*) at /home/tony/Arduino/sketches/tempo1_vs11e_Master_NodeMCU_Rain_Wind/tempo1_vs11e_Master_NodeMCU_Rain_Wind.ino line 516
0x40203f8a: uploadAgrigis(char const*) at /home/tony/Arduino/sketches/tempo1_vs11e_Master_NodeMCU_Rain_Wind/tempo1_vs11e_Master_NodeMCU_Rain_Wind.ino line 335
0x40209080: Print::println() at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.2/cores/esp8266/Print.cpp line 178
0x402048e0: loop() at /home/tony/Arduino/sketches/tempo1_vs11e_Master_NodeMCU_Rain_Wind/tempo1_vs11e_Master_NodeMCU_Rain_Wind.ino line 243

struct declaration

struct Array8Int {
    int array[8];
};

loop

char post[300] = "";
int pulseChange05m = rainCheck(slaveData);
int now10 = floor(unixtimeServer/10)*10;
Array8Int slaveData = slaveCheck(now()); // update slaveData array
setPostString(now10, pulseChange05m, slaveData, post);

functions

void setPostString(int unixtimeEvent, int pulseChange, Array8Int postData, char* postStr) {
  bool flag = true;
  float rainHour = pulseChange*0.25;
  if (hour() == 10) { // 7 AM palmital
    rainCount = 0;
    rainCount05m = 0;
  }
  rainCountHour = rainCount;
  int humidityBme280HourAvg = 0;
  int pressureBme280HourAvg = 0;
  int temperatureBme280HourAvg = 0;
  int lightSensorHourAvg = 0;
  int pressureBme280HourMin = 100000;
  int temperatureBme280HourMin = 1000;
  int temperatureBme280HourMax = -1000;
  int counterLoop = counterHour;
  for(int i=0;i<counterLoop;i++) {
    lightSensorHourAvg += lightSensorHour[i];
    pressureBme280HourAvg += pressureBme280Hour[i];
    temperatureBme280HourAvg += temperatureBme280Hour[i];
    temperatureBme280HourMax= max(temperatureBme280HourMax,temperatureBme280Hour[i]);
    pressureBme280HourMin = min(pressureBme280HourMin,pressureBme280Hour[i]);
    temperatureBme280HourMin = min(temperatureBme280HourMin,temperatureBme280Hour[i]);
    humidityBme280HourAvg += humidityBme280Hour[i];
  }
  pressureBme280HourAvg = pressureBme280HourAvg/counterLoop;
  temperatureBme280HourAvg = temperatureBme280HourAvg/counterLoop;
  lightSensorHourAvg = (int)lightSensorHourAvg/counterLoop;

  strcat(postStr, stationId);
  strcat(postStr,"&3="); // chuva hora
  strcat(postStr, dtostrf(rainHour,6,2,charDummy));
  strcat(postStr,"&8=");
  strcat(postStr, dtostrf(temperatureBme280HourAvg,6,2,charDummy));
  strcat(postStr,"&9="); //temperature avg
  strcat(postStr, dtostrf(temperatureBme280HourAvg,6,2,charDummy));
  strcat(postStr,"&10="); //temperature avg
  strcat(postStr, dtostrf(temperatureBme280HourMax,6,2,charDummy));
  strcat(postStr,"&11="); //temperature avg
  strcat(postStr, dtostrf(temperatureBme280HourMin,6,2,charDummy));
  strcat(postStr,"&20=");
  strcat(postStr, dtostrf(pressureBme280HourAvg,10,0,charDummy));
  strcat(postStr,"&22=");
  strcat(postStr, dtostrf(pressureBme280HourMin,10,0,charDummy));
  strcat(postStr,"&101=");
  strcat(postStr, dtostrf(lightSensorHourAvg,6,0,charDummy));
  strcat(postStr,"&time=");
  strcat(postStr, dtostrf(unixtimeEvent,16,0,charDummy));
  strcat(postStr,"&endline=1");
  strcat(postStr, "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n");
}
int rainCheck(Array8Int slaveData) {
  int pulseChange = slaveData.array[0];
  return pulseChange;
}


texts:
Update:

Below I implemented how I understood your suggestions. And it still does only turn in one direction (forward). Curiously if I entered M_DEST in the stepperOneForward() function it turned forward very long but smooth. The code below made it rotate as usual very jittery. Is this the acceleration part and if so how can I change that ? Ideally I would be able to tell the stepper go to position X and return to start and that in constant speed.

 #include <AccelStepper.h>

const int stepPin = 5;
const int dirPin = 4;
const int enPin = 12;

unsigned int DEST = 800;
unsigned int M_DEST = -800;
unsigned int SPD = 1600;
unsigned int ACCEL = 800;

AccelStepper stepper1(1,stepPin,dirPin);

void setup() {

  pinMode(stepPin,OUTPUT);
  pinMode(dirPin,OUTPUT);
  pinMode(enPin,OUTPUT);

  stepper1.setEnablePin(enPin);
  stepper1.setPinsInverted(false, false, true);
  Serial.begin(9600);  // Start Serial
}

void loop() {

stepperOneForward();
Serial.println("Stepper1 turned forward.");
delay(1000);
stepperOneBackward();
Serial.println("Stepper1 turned backward.");
}

void stepperOneForward() {

  stepper1.enableOutputs();
  stepper1.setMaxSpeed(SPD);
  stepper1.setAcceleration(ACCEL);
  stepper1.move(DEST);
  if (DEST > 0) {
    while ( stepper1.distanceToGo() > 0) {
      stepper1.run();
      }
  //stepper1.disableOutputs();
  }
 }

 void stepperOneBackward() {

  stepper1.enableOutputs();
  stepper1.setMaxSpeed(SPD);
  stepper1.setAcceleration(ACCEL);
  stepper1.move(M_DEST);
  if (M_DEST < 0) {
    while ( stepper1.distanceToGo() > 0) {
      stepper1.run();
      }
  //stepper1.disableOutputs();
  }
 }

I have multiple steppers that I would like to run forward until they hit a microswitch and backwards to the initial position. But to simplify things I would like to control one stepper going forward and then backward. The code below always just turns clockwise.

I tried to set the dirPin to low, which did not work.
I tried to reverse the setMaxSpeed (by putting a minus in front of it).
I found the "enum AccelStepper::Direction" class in Accelstepper that did not explain how to to set DIRECTION_CCW or DIRECTION_CW.

What I would like to achieve is control these steppers so they move smoothly forward, wait and then backwards. This should be very easy, but has frustrated me now for too long. I would use any library at this point that can do this and control more than 1 stepper.

The SPD and ACCEL values are so high because I use microstepping (6400 is a full cycle).

#include <AccelStepper.h>

const int stepPin = 5;
const int dirPin = 4;
const int enPin = 12;

unsigned int DEST = 6400;
unsigned int SPD = 1600;
unsigned int ACCEL = 800;

void setup() {

  pinMode(stepPin,OUTPUT);
  pinMode(dirPin,OUTPUT);
  pinMode(enPin,OUTPUT);
  Serial.begin(9600);  // Start Serial
}

void loop() {

stepperOneForward();
Serial.println("Stepper1 turned forward.");
stepperOneBackward();
Serial.println("Stepper1 turned backward.");
}

void stepperOneForward() {

  AccelStepper stepper1(1,stepPin,dirPin);
  digitalWrite(enPin,LOW);
  stepper1.setMaxSpeed(SPD);
  stepper1.setAcceleration(ACCEL);
  stepper1.move(DEST);
  if (DEST > 0) {
    while ( stepper1.distanceToGo() > 0) {
      stepper1.run();
      }
  digitalWrite(enPin,HIGH);
  }
 }

 void stepperOneBackward() {

  AccelStepper stepper1(1,stepPin,dirPin);
  digitalWrite(enPin,LOW);
  stepper1.setMaxSpeed(-SPD);
  stepper1.setAcceleration(ACCEL);
  stepper1.move(DEST);
  if (DEST < 0) {
    while ( stepper1.distanceToGo() > 0) {
      stepper1.run();
      }
  digitalWrite(enPin,HIGH);
  }
 }


texts: On UNO, when serial.print to UART pin 11, nothing comes out of pin 11

texts:
The problem: Message prints only to the Arduino IDE's Tools > Serial Monitor, not coming out of TX pin 11.
Question, please how to get Arduino Uno or Mega to send data out of pin 11?

#include <SoftwareSerial.h>
SoftwareSerial mySerial(12, 13); // RX, TX pins on Arduino
void setup() {
  Serial.begin(9600);
}
void loop() {
  Serial.print("This is a test\n\n");
  delay(1000);
}


texts:
Background: I change the job and in the new company you need to pay pizza for the whole team if you forget to lock your screen :-)

I want it to be automated: I walk away and the screen should lock. No additional action should be required. Keyboard shortcuts, special mouse movements or unplugging devices from USB are not valid solutions.

How could this be solved (with or without arduino)?

Please write slowly, I never worked with sensors or arduino before :-)

I need this for Mac and Ubuntu.


texts: Does a graphical driver chip exist for this project?

texts:
I need some expert advice. I'm using an Arduino Leonardo, which I have got working with a Nokia 3310 monochrome screen. I wrote some code to draw any graphics to the screen.

What I want to know is, can I buy a chip from somewhere that will offload most of the CPU usage (for graphics from the Leonardo) that draws numbers and letters to the screen and basic graphics (different types of polygons and lines)? So I'm looking for a chip designed to do the graphical work and a data sheet reference for the chip.


texts:
I am trying to filter ultrasonic readings using averaging technique. I've also used millis() to measure time from start so that I can calculate readings up to 1 second and average them. I've re-initialized the elapsedTime variable each time to zero in the loop but again when the program execution hits this code the time starts from the time it was before. Is there any way to solve this problem?

This is the code:

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.

int dist, ctr, filteredDist;
long rawValue = 0;
unsigned long StartTime = millis();

void setup() {
  Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
}
//********************************************************************************************************************
void loop() {
  delay(500);
  unsigned long elapsedTime = StartTime;

  while (elapsedTime < 1000) {
    ctr++;
    dist = sonar.ping_cm();
    rawValue += dist;
    elapsedTime = millis();
  }
  filteredDist = rawValue / ctr;
  Serial.println(filteredDist);
}


texts: send values from arduino uno to wemos d1 r1

texts:
I have a weather project in which I have to measure the temperature and humidity ( dht22 sensor ), the pressure and other things and then show them in a local web page ( usings wemos d1 r1 ) in either my phone or pc ( I have both Arduino uno and Wemos d1 r1 for this project )
I wanted to use only wemos d1 r1 since it works the same as arduino uno except it has an esp8266 Wi-Fi built-in while arduino uno doesn't have ,but as you may know it only has 1 analog pin while I need at least 3 or 4 analog pin so in my case i should connect the sensors with the arduino uno and measure the temperature, humidity etc .. and then send those values to the wemos d1 r1 which will show the results itself in a web page as I said eariler
It seems that there is a way to do that using I2C connection but I have read many articles talking about connecting arduino to another arduino using I2C connection but I don't know how to do that in my case ( Arduino uno and Wemos d1 r1 ) and if there is another way to send values please tell me


texts:
My project is having Arduino with my WiFi shield connect to Twitter and look for any messages that other users have tweeted at me that contain a certain color, (I.E. @myTwitterHandle I want red) and then changes an RGB LED to become that color.

I have been searching online for different methods, and found a few different solutions which I could use as a starting point. However, these apparently call to an old Twitter API that is not supported anymore (support stopped mid 2013).

One solution I came across was to use node-red as well as MQTT.  I am not too familiar with these programs.

Does anyone know how to have Arduino parse a twitter account for mentions containing certain strings and have it print to LED? Any help with be appreciated


texts: Unsure if my NEMA 14 stepper motor wiring is correct

texts:
So I'm pretty brand new to Arduino's in general so I do apologize if its a simple mistake. But basically I'm trying to use the <Stepper.h> library to control my NEMA 14 motor on an arduino with a CNC shield and a A4988 driver. Specifically at this moment I am testing out this code:
/*
 Stepper Motor Control - one step at a time

 This program drives a unipolar or bipolar stepper motor.
 The motor is attached to digital pins 8 - 11 of the Arduino.

 The motor will step one step at a time, very slowly.  You can use this to
 test that you've got the four wires of your stepper wired to the correct
 pins. If wired correctly, all steps should be in the same direction.

 Use this also to count the number of steps per revolution of your motor,
 if you don't know it.  Then plug that number into the oneRevolution
 example to see if you got it right.

 Created 30 Nov. 2009
 by Tom Igoe

 */

#include <Stepper.h>

const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

int stepCount = 0;         // number of steps the motor has taken

void setup() {
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
  // step one step:
  myStepper.step(1);
  Serial.print("steps:");
  Serial.println(stepCount);
  stepCount++;
  delay(500);
}

Now unfortunately when I run this code I can hear the motor whirring, but it doesn't revolve. I'm guessing that either I wired the motor incorrectly, or because I'm using a CNC shield the pins in the code should be different. Also, I've checked the voltage going into the driver in accordance with this website. I've also attached pictures below of my setup to just to make everything clear:

Picture of CNC shield atop Arduino board with wires connected as follows:

Picture of Stepper motor I'm using:

Specifications of the NEMA 14 motor I'm using:
Can be seen here

I'm sorry for the convoluted post but I am kind've stuck so any help would be greatly appreciated and if there's any more info needed to help clarify my problem I will update the post or reply to your comments. Thanks!


texts: ESP8266-12 is showing garbage when RST is given

texts:
I use ESP8266-12 with an Arduino Uno as a USB-serial adapter.

When I upload any sketch to the ESP8266 it works fine until I reset the ESP8266.

uint32_t realSize = ESP.getFlashChipRealSize();
uint32_t ideSize = ESP.getFlashChipSize();
FlashMode_t ideMode = ESP.getFlashChipMode();

Serial.printf("Flash real id:   %08X\n", ESP.getFlashChipId());
Serial.printf("Flash real size: %u\n\n", realSize);

Serial.printf("Flash ide  size: %u\n", ideSize);
Serial.printf("Flash ide speed: %u\n", ESP.getFlashChipSpeed());
Serial.printf("Flash ide mode:  %s\n", (ideMode == FM_QIO ? "QIO" : ideMode == FM_QOUT ? "QOUT" : ideMode == FM_DIO ? "DIO" : ideMode == FM_DOUT ? "DOUT" : "UNKNOWN"));

if(ideSize != realSize) {
    Serial.println("Flash Chip configuration wrong!\n");
} else {
    Serial.println("Flash Chip configuration ok.\n");
}

delay(5000);

If I ground reset button, garbage values are being shown.

Connections details:

EN  - 3.3V of Uno
VCC - 3.3V of Uno
RST - GND Of Uno(If needed)
TX - TX of Uno
RX - RX of Uno
GPO15 - GND of Uno
GPO01 - GND of Uno
GND - GND of Uno


texts: Arduino ADK, other board, shield or what?

texts:
Sorry for bothering.
I have a problem with my project and I can't fine someone who can help me yet.

I need the next configuration:
PC --------------USB cable-----------------MegaA---------------USB cable----------------MegaB

I need serial communication with USB cable in both boards.

I have now solved the ( PC --------USB cable------MegaA) part.

And the other part, I have done PC------------------USB cable------------------MegaB

But I need do that like the first schematic.
I don't have access to the MegaB because this is inside a machine, I can't access to its pines, I need connect to it by USB Cable.
Is possible do that with ARDUINO MEGA ADK in the MEGA A position? or I need other kind of board or add one shield (like USB host)?
I need send one thing from the pc to MegaA and Mega A send the same thing to MegaB.
Is it possible? because I can't find some way to specify that I need recieve the information from one serial port, and send it to another different serial port.
I need help, is very important.
Excuse my english
Thanks


texts: Arduino IDE: How to get PROGMEM const length?

texts:
I have defined a byte array as a constant in the Atmel's flash memory:

const uint8_t eye [] PROGMEM = {
  0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
  0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
};

How can I (repeatedly) read the length of this constant in the program? All the available functions in avr/pgmspace.h do not deliver the proper length, no matter how I use them. I tried strlen(eye), strlen_P(eye), strLen_PF(eye) and also sizeof(eye). I'm new to C, so I'm not sure about the whole pointer stuff.


texts: How to pass rx/tx led outputs to a shield

texts:
I have an Arduino Uno. I am building a custom shield and was wondering how I would connect two of the LEDs on the shield to the TX / RX LEDs on the Uno. Digital pins 0 and 1 seem obvious, but after further research, it appears that they are not for this.

In better terms, I want two LEDs on my shield that replicate the TX / Rx LEDs on the Arduino Uno.

How would I do this?


texts: How do i efficiently write this code for PS2 controller to USB convertion sketch for Arduino Pro Micro?

texts:
I am really new to coding and building stuff, so forgive me if it is anything offensive.i have been trying to convert my PS2 dualshock controller to USB using arduino. there is a library called ps2x that i can use to read the data and Joystick.h library to send it over USB-HID.
i just want to know if this is efficient code, if not how can i improve it.
This is the loop:

 ps2x.read_gamepad(); //This needs to be called at least once a second
                        // to get data from the controller.

  Joystick.setXAxis(ANALOGSTATE1); //Joystick.setButton(-127 to 127); 0 is center
  Joystick.setYAxis(ANALOGSTATE2);
  Joystick.setZAxis(ANALOGSTATE3);
  Joystick.setThrottle(ANALOGSTATE4); //This one is different, (0 to 255) 127 is center

  Joystick.setButton(0, DIGITALSTATE1); //Joystick.setButton(0-31, 0-1);
                                        //Joystick.setButton(Select Button to Use, Specify ON/OFF of Button);
  Joystick.setButton(1, DIGITALSTATE2);
  Joystick.setButton(2, DIGITALSTATE3);
  Joystick.setButton(3, DIGITALSTATE4);
  Joystick.setButton(4, DIGITALSTATE5);
  Joystick.setButton(5, DIGITALSTATE6);
  Joystick.setButton(6, DIGITALSTATE7);
  Joystick.setButton(7, DIGITALSTATE8);
  Joystick.setButton(8, DIGITALSTATE9);
  Joystick.setButton(9, DIGITALSTATE10);
  Joystick.setButton(10, DIGITALSTATE11);
  Joystick.setButton(11, DIGITALSTATE12);
  Joystick.setButton(12, DIGITALSTATE13);
  Joystick.setButton(13, DIGITALSTATE14);
  Joystick.setButton(14, DIGITALSTATE15);
  Joystick.setButton(15, DIGITALSTATE16);

if(ps2x.ButtonPressed(PSB_TRIANGLE)) {
  DIGITALSTATE1 = 1;
}
  else if (ps2x.ButtonReleased(PSB_TRIANGLE)){
  DIGITALSTATE1 = 0;
}
if(ps2x.ButtonPressed(PSB_CIRCLE))
  {
    DIGITALSTATE2 = 1;
   }
  else if (ps2x.ButtonReleased(PSB_CIRCLE)){
    DIGITALSTATE2 = 0;
  }
if(ps2x.ButtonPressed(PSB_CROSS))
  {
    DIGITALSTATE3 = 1;
   }
  else if (ps2x.ButtonReleased(PSB_CROSS)){
    DIGITALSTATE3 = 0;
  }
if(ps2x.ButtonPressed(PSB_SQUARE))
  {
    DIGITALSTATE4 = 1;
   }
  else if (ps2x.ButtonReleased(PSB_SQUARE)){
    DIGITALSTATE4 = 0;
  }
if(ps2x.ButtonPressed(PSB_PAD_RIGHT))
  {
    DIGITALSTATE5 = 1;
   }
  else if (ps2x.ButtonReleased(PSB_PAD_RIGHT)){
    DIGITALSTATE5 = 0;
  }
if(ps2x.ButtonPressed(PSB_PAD_UP))
  {
    DIGITALSTATE6 = 1;
   }
  else if (ps2x.ButtonReleased(PSB_PAD_UP)){
    DIGITALSTATE6 = 0;
  }
if(ps2x.ButtonPressed(PSB_PAD_LEFT))
  {
    DIGITALSTATE7 = 1;
   }
  else if (ps2x.ButtonReleased(PSB_PAD_LEFT)){
    DIGITALSTATE7 = 0;,
  }
if(ps2x.ButtonPressed(PSB_PAD_DOWN))
  {
    DIGITALSTATE8 = 1;
   }
  else if (ps2x.ButtonReleased(PSB_PAD_DOWN)){
    DIGITALSTATE8 = 0;
  }
if(ps2x.ButtonPressed(PSB_L1))
  {
    DIGITALSTATE9 = 1;
   }
  else if (ps2x.ButtonReleased(PSB_L1)){
    DIGITALSTATE9 = 0;
  }
if(ps2x.ButtonPressed(PSB_L2))
  {
    DIGITALSTATE10 = 1;
   }
  else if (ps2x.ButtonReleased(PSB_L2)){
    DIGITALSTATE10 = 0;
  }
if(ps2x.ButtonPressed(PSB_R1))
  {
    DIGITALSTATE11 = 1;
   }
  else if (ps2x.ButtonReleased(PSB_R1)){
    DIGITALSTATE11 = 0;
  }
if(ps2x.ButtonPressed(PSB_R2))
  {
    DIGITALSTATE12 = 1;
   }
  else if (ps2x.ButtonReleased(PSB_R2)){
    DIGITALSTATE12 = 0;
  }
if(ps2x.ButtonPressed(PSB_L3))
  {
    DIGITALSTATE13 = 1;
   }
  else if (ps2x.ButtonReleased(PSB_L3)){
    DIGITALSTATE13 = 0;
  }
if(ps2x.ButtonPressed(PSB_R3))
  {
    DIGITALSTATE14 = 1;
   }
  else if (ps2x.ButtonReleased(PSB_R3)){
    DIGITALSTATE14 = 0;
  }
if(ps2x.ButtonPressed(PSB_START))
  {
    DIGITALSTATE15 = 1;
   }
  else if (ps2x.ButtonReleased(PSB_START)){
    DIGITALSTATE15 = 0;
  }
if(ps2x.ButtonPressed(PSB_SELECT))
  {
    DIGITALSTATE16 = 1;
   }
  else if (ps2x.ButtonReleased(PSB_SELECT)){
    DIGITALSTATE16 = 0;
  }

  ANALOGSTATE1 = map(ps2x.Analog(PSS_LX), 0, 255, -127, 127);
  ANALOGSTATE2 = map(ps2x.Analog(PSS_LY), 0, 255, -127, 127);
  ANALOGSTATE3 = map(ps2x.Analog(PSS_RX), 0, 255, -127, 127);
  ANALOGSTATE4 = (ps2x.Analog(PSS_RY));

}```


texts:
I have a string that looks like this "10.00,20.00,-50.00," in which these are angle values and they have 2 decimals and can be negative. I want to separate them into 3 separate floats. Here is my current code in which I use sscanf. All I get is 0.00 and have no idea why. Any help is truly appreciated.
String recvString = "10.00,20.00,-50.00,";
float r,p,y;

void setup() {
  Serial.begin(9600);
  Serial.println(r);
  int result = sscanf(recvString.c_str(), "%f,%f,%f,", &r, &p ,&y);
  Serial.println(r);
}

void loop() {}


texts: Simulation of IoT based systems in Software

texts:
Thank you for reading this.

Generally there are libraries for GSM and Ultrasound sensors for the software called Proteus and you can simulate them along with you MCU and the interfacing peripherals and simulate .

I have big problem at my hand , I want to simulate ESP8266 or any other relevant wifi module with my Arduino (Simulation Libraries for Arduino are available ) and get the data from sensor , all in software . Then , I want the wifi device (in software ) to show an ip address , so that I can log the data to an online cloud .

The software and module does not have to be specific , I want to know , If there are any professional software that let you simulate IoT based systems.

I'am new to IoT designing and I'am always comfortable with simulating everything.

If you have any other similar guide on how to design and simulate IoT systems , Let me know .

Have a great day


texts: What happens if I draw too much current from ATMEGA IO pin?

texts:
I revisited an older device that I made and discovered, that I had an 8 Ohm speaker connected directly to ground and an IO pin of an Atmega328P. According to my calculation that means that the pin would have to source 625 mA, which is way above the 40 mA that any single port should be able to source and even above the 200 mA that the Vcc and GND support. Yet it somehow worked and the chip seems to be working just fine. The application uses a duty cycle of 50%, so in the best case it would use maybe 312.5 mA, which is a little better but still way above the ratings.

So my question is, what happens if the output pin is asked to source more than it's rating?

I've seen chips that just release their magic smoke while others just can't keep up with supplying that kind of voltage, so only the voltage drops without any other problems. How does the Atmega328P handle this?

The Atmega clearly didn't burn through, but what other kind of damage should I expect?


texts: 16x2 lcd lighting up blue but not showing any text

texts:
i should probably start off by saying i am really new to this stuff and have barely any idea what i'm doing. i am triyng to use a DHT22 and a 16x2 LCD to show the temperature and humidity. here is the code i'm using:

#include <DHT.h>
#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

//Constants
#define DHTPIN 7     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino

//Variables
int chk;
float hum;  //Stores humidity value
float temp; //Stores temperature value

void setup()
{
  Serial.begin(9600);
  dht.begin();
  lcd.begin(16,2);
}

void loop()
{

  delay(2000);
  //Read data and store it to variables hum and temp
  hum = dht.readHumidity();
  temp = dht.readTemperature();
  //Print temp and humidity values to serial monitor
  Serial.print("Humidity: ");
  Serial.print(hum);
  Serial.print(" %, Temp: ");
  Serial.print(temp);
  Serial.println(" Celsius");

  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Temp: ");
  lcd.print(temp);
  lcd.print(" ");
  lcd.print((char)223);
  lcd.print("C");
  lcd.setCursor(0,1);
  lcd.print("Hum:  ");
  lcd.print(hum);
  lcd.print(" %");

  delay(2000); //Delay 2 sec.

}`

is it an issue with my code or my hardware? thanks


texts: How can I receive several inputs from wifi and save them?

texts:
I'm trying to send and receive some data from one Arduino to another Arduino. I'm using an Arduino Uno and FS1000A / XY-MK-5V 433Mhz TX/RX Modules. For transmitting I use the Radiohead library.

I want to send two strings and save them as different strings. My receiver code is:

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

RH_ASK driver;

void setup() {
  Serial.begin(9600); // Debugging only
  if (!driver.init())
    Serial.println("init failed");
}

void loop() {
  uint8_t buf[200];
  memset(buf, '\0', 200);
  uint8_t buflen = sizeof(buf);
  if (driver.recv(buf, &buflen)) {
    // Non-blocking
    Serial.print("Message: ");
    Serial.println((char*)buf);
  }
}

First of all, why do I have to use #include <SPI.h>? To receive I use:

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

This code saves the output as one output! How can I specify which input is the first one and which is the second one?


texts:
I have a pro micro and I'm running the IDE on linux.
The IDE easily recognises that my board is on /dev/ttyACM0 so i can flash programs on to it.
I am testing the following code

void setup()
{
  Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps
}

void loop()
{
  Serial.print("Hello universe ");
}

After I upload the code if I try to bring up the serial monitor I get this error message

  Error opening serial port '/dev/ttyACM0'. (Port busy)

tried resetting the pro micro, rebooting the computer, tried the code

  sudo usermod -a -G dialout yourUserName as suggested here

But the problem still didn't solve. Any idea what went wrong.

Edit1:

I noticed that when the arduino is in the bootloader mode (i.e when I press reset) lsusb shows

  Bus 004 Device 055: ID 2341:0037 Arduino SA

however, when it starts to execute the program from its memory, lsusb doesn't show that entry. but instead, shows

  Bus 004 Device 054: ID 1b4f:9206


texts: Arduino-Bluetooth HC-05 Android app blueterm connection for chatting

texts:
I want to communicate between an arduino and an Android phone that has an Android app blue term. I connected HC-05 with Arduino using software serial and I connected the hc05 as a device with the android app. I am able to send data ( data as in message) from Android to Arduino but I am unable to send message from arduino to Android though I have given .write() command to Bluetooth connected.

Is it such that the Android app does not show the received message? Or there is some master-slave configuration issue? Do I need to configure HC-05 in master mode? It was configured in slave mode by default when I had connected it to Android app.


texts: PT100 and MAX31865 readings showing wrong

texts:
I am using PT100 (3 Wire) to measure the temperature with Arduino Uno and MAX31865.
I have connected everything perfectly.
Configuration in the code i am using is :

max1.begin(MAX31865_3WIRE);

And the output is:

output

RTD value: 0
Ratio = 0.00000000
Resistance = 0.00000000
Temperature = -242.02

I am testing it in a room temperature.

My question is , is there any settings or calibration that i need to do, or any other way to test the PT100 sensor, because the temperature is showing correct readings ?


texts:
I have an Atmega 328 chip and want to load the Arduino boot loader to the chip. I have planned to use a SPI protocol to do this, but I have read other posts saying that they have done similar using an UART with using an FTDI chip. I have planned to use the FTDI to support USB.

I did rad some information that said that loading the boot loader through UART is very slow.

Which is best? I would like to save space, if I do not need a SPI header then I would like to remove this. Is what I have read correct?

Thanks


texts: I have resorted to creating bitmaps for each number and a few letters for a 128x64 Oled module. This was to save memory and get around limitations of libraries such as the u8glib. If I had linux I could use the tools they provided to fix some of these but that's out of the question for now. I wanted to know if there's a simple way of mapping each character to it's bitmap so a function similar to XXX.print(); be used, in order to parse the characters and display the corresponding bitmaps automatically. That would make my life so much easier! thanks!


texts: Triggering a soft reset (Arduino Leonardo)

texts:
I want to trigger a soft reset on my Arduino Leonardo, and after some searching settled on using the watchdog timer, as it seemed to be the easiest and cleanest way to do it.

However, I don't think it works as it should. It seems to work fine on the following example:

#include <avr/wdt.h>

int outputPin = LED_BUILTIN;

void setup() {
  MCUSR = 0;
  wdt_disable();
  pinMode(outputPin, OUTPUT);
  digitalWrite(outputPin, HIGH);
  delay(500);
  digitalWrite(outputPin, LOW);
  delay(500);
  digitalWrite(outputPin, HIGH);
  delay(500);
  digitalWrite(outputPin, LOW);
  delay(1000);
}

void loop() {
  wdt_enable(WDTO_15MS);
  while (true) {}
}

The LED blinks continuously,.

But for the following example:

#include <avr/wdt.h>

void setup() {
  MCUSR = 0;
  wdt_disable();
  Serial.begin(9600);
  while (!Serial);
  Serial.println("Hello");
}

void loop() {
  wdt_enable(WDTO_15MS);
  while (true) {}
}

"Hello" only gets printed once (where I would expect it to arrive continuously).

I tried increasing the watchdog timeout to 2 seconds, but that didn't solve the issue.


texts: How to write to the second line of a display?

texts:
I got this 4 line display from Mouser: https://www.gravitech.us/20chbllcd.html, and I get it to work fine for lines 1 and 3 (as line 3 is just the 21st character of line 1). But I am struggling to get lines 2 and 4 working. If I understand correctly, these are "line 2" for the HD44780 controller, and I should set the DDRAM address to 0x40 before I write there.

But, when I try that, nothing happens.

I tried writing 0x04 to the DDRAM address counter, and I can see the cursor jumping there, but when I write to that address, no text shows up. If I omit the command, text pops up correctly.

Also, when changing the contrast of the display (using the potentiometer on the Vdd and Vo pins), only lines 1 and 3 change contrast.

My code:

This method I use for convenience:

void set(int _rs, int _rw, int _d7, int _d6, int _d5, int _d4, int _d3, int _d2, int _d1, int _d0) { ... }

To set the DDRAM address to 0x40:

set(0,0,1,1,0,0,0,0,0,0);

The general timing and control is correct, as I can get text on the display, and also a function like "shift" works fine.