texts: Home devices control system using gsm and arduino mega2560

texts:
Hi dears I'm trying to do project to control app base gsm control by arduino mega 2560 gsm module SIM900A

To send SMS to open Led than reply SMS to give as the status I mean send SMS then I received SMS from GSM module  by this code same time work but same time not work also same time send SMS1111 received SMS2222 status.
I hope it is clear.

#include <SoftwareSerial.h>
#include <string.h>
#include "SIM900.h"
#include <TinyGPS.h>
#include "sms.h"
SoftwareSerial GSMSerial(12, 13);
byte buffer[128];
int count = 0;
const int Led4 = 43;
const int Led1 = 44;
const int Led2 = 45;
const int Led3 = 50;
void SIM900power()
{
}
void setup() {
    pinMode(Led1, OUTPUT);
  pinMode(Led2, OUTPUT);
  pinMode(Led3, OUTPUT);
  pinMode(Led4, OUTPUT);
  GSMSerial.begin(19200); // the SIM900 baud rate
  Serial.begin(9600); // the Serial port of Arduino baud rate.
  Sim900_Inti();
}
void loop() {
  GSMSerial.listen();
  if (GSMSerial.available()) // If date is comming from from GSM shield)
  {
    while (GSMSerial.available()) // reading data into char array
    {
      buffer[count++] = GSMSerial.read(); // writing data into array
      if (count == 128)break;
    }
    Serial.write(buffer, count); // if no data transmission ends, write         buffer to hardware serial port
Cmd_Read_Act(); //Read the 'COMMAND' sent to SIM900 through SMS
clearBufferArray(); // call clearBufferArray function to clear the storaged data from the array
count = 0; // set counter of while loop to zero
  }
  if (Serial.available()) // if data is available on hardwareserial port ==>     data is comming from PC or notebook
    GSMSerial.println(Serial.read()); // write it to the GPRS shield
}
void clearBufferArray() // function to clear buffer array
{
  delay(1000);
  for (int i = 0; i < count; i++)
  {
    buffer[i] = NULL; // clear all index of array with command NULL
    delay(100);
  }
  for (int n = 0; n < count; n++)
  {
    buffer[n] = NULL; // clear all index of array with command NULL
    delay(100);
  }
  for (int m = 0; m < count; m++)
  {
    buffer[m] = NULL; // clear all index of array with command NULL
    delay(100);
  }
  for (int p = 0; p < count; p++)
  {
    buffer[p] = NULL; // clear all index of array with command NULL
    delay(100);
  }
}
void Sim900_Inti(void)
    {
     GSMSerial.println("AT+CMGF=1"); // Set GSM shield to sms mode
  Serial.println("AT+CMGF=1");
  delay(500);
  GSMSerial.println("AT+CNMI=2,2");
  Serial.println("AT CMGF=1");
  delay(500);
}
void Cmd_Read_Act(void) //Function reads the SMS sent to SIM900 shield.
{
  char buffer_i[128];
  for (int i = 0; i < count; i++)
  {
    buffer_i[i] = char(buffer[i]);
  }
  if (strstr(buffer_i, "1111")) //Comparing password entered with password     stored in program
  {
          digitalWrite(Led1, HIGH);
   SMS_1111();
  }
  char buffer_n[128];
  for (int n = 0; n < count; n++)
  {
    buffer_n[n] = char(buffer[n]);
  }

  if (strstr(buffer_n, "2222")) //Comparing password entered with password     stored in program
  {
          digitalWrite(Led2, HIGH);
   SMS_2222();
  }
      char buffer_m[128];
  for (int m = 0; m < count; m++)
  {
    buffer[m] = char(buffer[m]);
  }
  if (strstr(buffer_m, "3333")) //Comparing password entered with password     stored in program
  {
   digitalWrite(Led3, HIGH);
   SMS_3333();
  }
  char buffer_p[128];
  for (int p = 0; p < count; p++)
  {
    buffer[p] = char(buffer[p]);
  }
  if (strstr(buffer_p, "4444")) //Comparing password entered with password stored in program
      {
    digitalWrite(Led4, HIGH);

   SMS_4444();
  }
}
  void SMS_1111() // complet liter Replay SMS TO Know Led1 Is ON
 {
 }
 void SMS_2222()// complet liter
{
}
void SMS_3333()// complet liter
{
}
void SMS_4444()// complet liter
{
}>


texts: Arduino: load variables with values read from SD card

texts:
I am having a bit of trouble loading values stored on an SD card and assigning them to variables within my program. I can achieve this as one big block of data, but would much prefer them to be saved to variables whilst in a loop or some other process.

My txt file has the following 6 ints & floats values, which are displayed vertically in the file:

2
0.003200
312
1
0.720000
8

Each of these values I want assigned to variables data1,....2,3,4,5,6. Unfortunately, the code I use below will never achieve this, but I am clueless as to any theory to solve this problem. Thanks in advance.

myFile = SD.open("test.txt", FILE_READ);
    if (myFile) {
    while (myFile.available()) {
        data = myFile.read();
    }
myFile.close();
}
else {
    Serial.println("Read Error");
}


texts:
This is my first post here, so apologies in advance if I've done something against any forum guidelines!
I have a project where I am monitoring multiple switch states with an Arduino using multiple MCP23017 ICs. I found a fantastic article by Nick Gammon which pretty much does what I want for the first element of the project at least. There are 2 small errors in his expanderWriteBoth and expanderRead routines - swap "send" for "write", and "receive" for "read" and the code works out of the box.
However - Nick's code will only display which pin has triggered the interrupt when the input pin is grounded. If you remove the ground to return the pin to the previous state, it will not state that this pin has changed state.
Can anybody see why this is the case? I have been through the datasheet for the MCP over and over again with no clues...
Any help appreciated,
Thanks.


texts: How does if(serial) work, a c++ question

texts:
The Arduino documentation says if(Serial) always returns 1, except for the case where Leonardo USB serial connection delays becoming ready.

(Leonardo has two USB IDs, and switches between them for boot loader and Serial USB.  After boot loader finishes and kicks off the program, it takes a while for the USB master (e.g. your PC) to process the disconnect of the boot loader USB device and the connection of the Serial USB device.  Thus the need for a wait.)

Now "Serial" is a static external instantiation of the Serial_ class (defined as extern Serial_ Serial;).

The c++ rules, as I understand them, do not allow a constructor to return a value, nor may the class name (which is also the constructor name) be used as a member (function) name in the class.

"Serial" cannot be defined in class Serial_, or the if(Serial) syntax would have to be if(Serial.Serial).

"Serial" cannot be defined outside the class Serial_, or it will conflict with (i.e. hide) the definition of Serial as an instantiation of Serial_.

So how does the Arduino IDE do it?

All I can think of is that the magic pre-scanner does something...  But what exactly, pray tell?


texts: How can I use a transistor to "press" a button?

texts:
I have a heater remote that I want to press the buttons of with my Arduino. I am powering both the remote and Arduino from an external 5V source so both grounds are connected.

Currently I have tried using an NPN transistor(TIP122) and it does work but is not very reliable. It probably works 80% of the time but isn't good enough for my purpose. Sometimes nothing happens and sometimes the button is pressed twice for no reason.

These are my connections.

I have the emitter connected to ground, collector connected to the button and the base connected to the Arduino with a 1k resistor. Are my connections OK?

I've also tried using a PNP transistor but pulling LOW instead of HIGH and LOW instead of HIGH.

The code is very simple, in the setup I have:

pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
delay(20);
digitalWrite(4, LOW);

Therefore when I restart the Arduino it should press the button, right?

I also have IRLZ44N and IRF540N, would either of these work better?


texts: Can the Sparkfun AVR pocket programmer bootload/program a 3.3 V ATmega328p

texts:
The product in question - https://www.sparkfun.com/products/9825 - operating at 5 V (and can also supply it to the device being programmed).

I need to program the bootloader onto a 3.3 V ATmega328p and don't have any level shifters immediately available. Thus the question. The "Hookup Guide" for the product (https://learn.sparkfun.com/tutorials/pocket-avr-programmer-hookup-guide) seems to suggest that it will work fine as long as the 3.3 V device being programmed isn't powered by the programmer. I wouldn't have thought it's the best idea in the world, but maybe I'm wrong.

So any practical experience?

Are the over voltage tolerances for input lines on Atmel devices good enough to handle the extra voltage?

I guess the output level from the device being programmed would be high enough to be buffered up to 5.0 V?


texts:
can anyone please tell me the whole difference between hardware and software serial for the HC-05.
I read UART,USB cable, serial and I was like really confused
so what is the difference and advantages between both?
thank you...


texts: Which reflectance sensor array for a line following robot?

texts:
I'm working on a line-following robot with my son. We've found a sensor array on Robot Shop that will help us but .. there's two and I'm not sure which will be the best for us.

The difference between them, as described in this PDF is "The QTR-8A uses a voltage divider for each sensor’s output while the QTR-8RC uses an RC circuit."

What I want to do is detect which sensor the followed line is triggering. All I need is a yes/no. But I'm too new to this to decide which of these two sensors would be best for me.


texts:
I have a brand new 8GB micro SD card freshly formatted as FAT in my Yun.

When I run df -h, I don't see the card's capacity included.
When I enter cd /mnt/sda1, it says can't cd to /mnt/sda1.

When I SSH into the Yun with ssh root@arduino.local and run dmesg, I see confirmation that the SD card is recognized:

[   11.510000] sd 0:0:0:0: [sda] 15431680 512-byte logical blocks: (7.90 GB/7.35 GiB)
[   11.510000] sd 0:0:0:0: [sda] Write Protect is off
[   11.510000] sd 0:0:0:0: [sda] Mode Sense: 03 00 00 00
[   11.510000] sd 0:0:0:0: [sda] No Caching mode page present
[   11.510000] sd 0:0:0:0: [sda] Assuming drive cache: write through
[   11.520000] sd 0:0:0:0: [sda] No Caching mode page present
[   11.520000] sd 0:0:0:0: [sda] Assuming drive cache: write through
[   11.530000]  sda: sda1
[   11.530000] sd 0:0:0:0: [sda] No Caching mode page present
[   11.530000] sd 0:0:0:0: [sda] Assuming drive cache: write through
[   11.540000] sd 0:0:0:0: [sda] Attached SCSI removable disk

How can I access my SD card and include it in the Yun's recognized storage space?


texts: Reading/Writing Strings with Bluetooth Windows API

texts:
I am trying to use my HC05 so my Arduino can communicate with my Windows 10 PC. I have a program written using the Window API for Serial Communication but the problem is it looks like the Arduino/HC05 can only send or the API can only read one character at a time. It is the same with Arduino; I send an entire string with the API and the Arduino has to read/parse it character by character. I was wondering if there was a solution to this problem or if I will need to develop some sort of coding protocol (like space to separate messages) to send messages. (The other issue is that it will take an age to send long messages this way.)

Windows File Reading API
https://msdn.microsoft.com/en-us/library/windows/desktop/aa364232(v=vs.85).aspx

Here is the PC side file.

do {
    // check for data on port and display it on screen.
    ReadFile(file, buffer, sizeof(buffer), &read, NULL);
    int i;
    sscanf(buffer, "%d", &i);
    std::cout << i << std::endl;

    if (read) {
        //WriteFile(screen, buffer, read, &written, NULL);

        //When space seen, add the string to data
        if (buffer[0] == ' ') {
            int convertedDatum = std::stoi(datum, &sz);
            if (convertedDatum < 12) {
                //WriteFile(file, "S " , 2, &written, NULL);
                //WriteFile(screen, "S", read, &written, NULL);
            }
            else {
                //WriteFile(file, "G ", 2, &written, NULL);
                //WriteFile(screen, "G", read, &written, NULL);
            }
            data.push_back(convertedDatum);
            datum = "";

Arduino-side test code

void loop() {

while (true) {
    String sendValue = String(100);
    sendValue.toCharArray(buf, sizeof(buf));

    Serial1.write(buf);
    Serial1.write(' ');
    delay(4000);
}

What I am seeing on the console on the PC which is represented by the screen variable when I debug is when I break at the line

std::cout << i << std::endl;

1-Continue-0-Continue-0
or on the console

1
0
0
0
0
0
...

I am pretty sure that I have seen entire strings sent at once with the Android Bluetooth API so I am not sure exactly if the same can be done with Windows or if the Windows VC++ API's are incapable.


texts:
I was wondering if its possible to use an OTG cable as an extention?

The reason for this is, today I build an EDTracker which is a device that translates head movement to the PC. The reason for me doing this is because a normal USB - Micro usb cable is to heavy and eventually outcenters the EDTracker. Which I don't want to glue to my headset.

The EDTracker must communicate with my computer.
I ordered a MICRO USB OTG cable and USB A-A cable.

I hope some one can help me out!


texts:
I have some small functions to format numbers. I move them to a new file and I would like to import it to my proyect.

I can't find how to do it without defining a class (maybe it's the only way). I would like to import like JavaScript, PHP or other languages: just using the import word or something similar.

I know how to import libraries. Example:

#include <OneWire.h>
#include <DallasTemperature.h>


texts: Is it possible to have an Adafruit music maker shield and a sensor connected to the same Arduino?

texts: Are the analog I/O pins on the Arduino still available for sensors when there is an Adafruit Music Maker shield attached to it? I want to play a sound file, but only when a PIR sensor senses motion.


texts:
Does somebody know if the IRremote library is compatible with Moteino boards?

If not, do you know a cheap solution to build a IR-remote controllable via wireless?


texts: String class summation disappears the right operand

texts:
I intend to create a function to jsify sensors' content and save it on a SD-card or send through a http client. Except for the Serial.println's, the function is transcripted below.

String jsonificar(vector<vector<String>> sujeito){
  String json_txt = String(""), chave, valor;
  String chave_str, valor_str;

  json_txt+=String("{");
  for(unsigned int i = 0; i<sujeito.size(); i++){
    if(sujeito[i].size() != 2){
        Serial.println("Cada conteudo deve conter 2 textos!");
    }
    else{
        chave = sujeito[i][0];
        valor = sujeito[i][1];
        Serial.println(chave);
        Serial.println(valor);
        Serial.println(json_txt);
        json_txt += "\\\"";
        Serial.println(json_txt);
        json_txt += chave;
        Serial.println(json_txt);
        json_txt += "\\\"";
        Serial.println(json_txt);
        json_txt += ":";
        Serial.println(json_txt);
        json_txt += "\\\"";
        Serial.println(json_txt);
        json_txt += valor;
        Serial.println(json_txt);
        json_txt += "\\\"";
        Serial.println(json_txt);

        if(i != sujeito.size() - 1){
          json_txt += String(",");
        }
    }
  }

  json_txt+="}";
  Serial.println(json_txt);

  return json_txt;
}

The output on serial follows:

Output:

Chave1
Valor1
{
{\"
{\"Chave1
{\"Chave1\"
{\"Chave1\":
{\"Chave1\":\"
{\"Chave1\":\"Valor1
{\"Chave1\":\"Valor1\"
Chave2
Valor2
{\"Chave1\":\"Valor1\",
{\"Chave1\":\"Valor1\",\"
{\"Chave1\":\"Valor1\",\"    <===
{\"Chave1\":\"Valor1\",\"\"
{\"Chave1\":\"Valor1\",\"\": <===
{\"Chave1\":\"Valor1\",\"\": <===
{\"Chave1\":\"Valor1\",\"\": <===
{\"Chave1\":\"Valor1\",\"\": <===
{\"Chave1\":\"Valor1\",\"\":}

The arrows show the spots where the logs are different from expected: the keys and values provided are "Chave1", "Valor1", "Chave2", "Valor2". So, the key-value should be "Chave2":"Valor2". Would you have a grasp of this behaviour? I look forward for the answer!


texts: Using Johnny-five API with RFID Controller Shield

texts:
Is it possible to use the Adafruit PN532 NFC/RFID Controller Shield with the Johnny Five API? I've searched the depths of google and I'm unable to find anything so far. If it is possible, how can I go about this?

I'm using an Arduino Uno with this.


texts:
I would like to use my Attiny85 as an remote controlled relay switch.
I have already tested the sketch on my Atmega328 and it worked.
Now I wanted to burn the sketch on my Attiny85 using ArduinoISP but I get the following error in the ArduinoIDE:

sketch_dec25a.ino: In function ‘void setup()’:
sketch_dec25a:13: error: ‘class RCSwitch’ has no member named ‘enableReceive’
sketch_dec25a.ino: In function ‘void loop()’:
sketch_dec25a:20: error: ‘class RCSwitch’ has no member named ‘available’
sketch_dec25a:21: error: ‘class RCSwitch’ has no member named ‘getReceivedValue’
sketch_dec25a:22: error: ‘class RCSwitch’ has no member named ‘getReceivedValue’
sketch_dec25a:25: error: ‘class RCSwitch’ has no member named ‘resetAvailable’

That's my code:

#include <SoftwareSerial.h>
#include <RCSwitch.h>

int RELAY_PIN = 2;

RCSwitch mySwitch = RCSwitch();
SoftwareSerial mySerial(1, 3); // RX, TX

void setup()
{
  pinMode(RELAY_PIN, OUTPUT);
  mySwitch.enableReceive(0);  // Receiver on inerrupt 0 => that is pin #2
  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{
  if (mySwitch.available()) {
    Serial.println(mySwitch.getReceivedValue());
    if(mySwitch.getReceivedValue() == 1234567){
      digitalWrite(RELAY_PIN, HIGH);
    }
    mySwitch.resetAvailable();
  }
}

I am using these cores: https://code.google.com/p/arduino-tiny/

I am using the SoftwareSerial just for debugging.
Sorry for my bad english and thanks for your help!


texts: Reading Arduino serial stream in Java using jSerialComm

texts:
I'm having issues reading the actual double values from my Arduino Serial.println() in my Java app. I've tried following usage examples found here but get what I guess is a hex value. The serial monitor within the Arduino program is displaying the correct values.

This is the code: I'm fairly new to this and would appreciate any comments regarding style/problems/inefficiencies within my code!

import com.fazecast.jSerialComm.*;
import java.util.*;
import java.io.*;

public class PortRead {
  public static SerialPort userPort;
  static InputStream in;

  public static void main(String args[]) {
    Scanner input = new Scanner(System.in);
    /*
     This returns an array of commport addresses, not useful for the client
     but useful for iterating through to get an actual list of com parts available
    */
    SerialPort ports[] = SerialPort.getCommPorts();
    int i = 1;
    //User port selection
    System.out.println("COM Ports available on machine");
    for (SerialPort port : ports) {
      //iterator to pass through port array
      System.out.println(i++ + ": " + port.getSystemPortName()); //print windows com ports
    }
    System.out.println("Please select COM PORT: 'COM#'");
    SerialPort userPort = SerialPort.getCommPort(input.nextLine());

    //Initializing port
    userPort.openPort();
    if (userPort.isOpen()) {
    System.out.println("Port initialized!");
    //timeout not needed for event based reading
    //userPort.setComPortTimeouts(SerialPort.TIMEOUT_READ_SEMI_BLOCKING, 100, 0);
    } else {
    System.out.println("Port not available");
    return;
    }

    userPort.addDataListener(new SerialPortDataListener() {
      @Override
      public int getListeningEvents() {
        return SerialPort.LISTENING_EVENT_DATA_AVAILABLE;
      }
      public void serialEvent(SerialPortEvent event) {
        if (event.getEventType() != SerialPort.LISTENING_EVENT_DATA_AVAILABLE)
        return;
        byte[] newData = new byte[userPort.bytesAvailable()];
        int numRead = userPort.readBytes(newData, newData.length);
        System.out.println("Read " + numRead + " bytes.");
      }
    });
  }
}


texts:
I'm working with Arduino and getting some strange errors. qsorting is not sorting correctly.

//using this libraries
#include <ESP8266WiFi.h>
#include <inttypes.h>

//the red struct is

typedef struct {
    int32_t rssi;
    int id;
} red;

//Here is my compare function
int compare (const void * a, const void * b)
{
  yield();
  red *redA = (red *)a;
  red *redB = (red *)b;
  //Serial.printf("redA->rssi: %d, redB->rssi: %d\n",redA->rssi,redB->rssi);
  //Serial.flush();

  return redA->rssi > redB->rssi ? 1 : (redB->rssi < redA->rssi ? -1 : 0);
  //return ( redB->rssi - redA->rssi );
}

void showNetworks(){
  int n = WiFi.scanNetworks(false,false);
  red listOfRedes[n];

  for (int i = 0; i < n; i++) // ...initialize it
  {
    yield();
    listOfRedes[i].rssi = WiFi.RSSI(i);
    listOfRedes[i].id = i;
    Serial.printf("%d: RSSI%d\n", i, listOfRedes[i].rssi);
    Serial.flush();
  }
  Serial.printf("salio\n");
  Serial.flush();
  qsort (listOfRedes, n, sizeof(red), compare);
  Serial.printf("ordeno\n");
  for (int i = 0; i < n; i++) // ...initialize it
  {
    yield();
    Serial.printf("%d: RSSI:%" PRId32 "\n", listOfRedes[i].id, listOfRedes[i].rssi);
  }
}

and this is the output i get

0: RSSI-69
1: RSSI-65
2: RSSI-72
3: RSSI-50
4: RSSI-60
5: RSSI-87
6: RSSI-87
7: RSSI-79
8: RSSI-80
9: RSSI-88
10: RSSI-74
11: RSSI-77
12: RSSI-78
13: RSSI-83
14: RSSI-79
15: RSSI-60
16: RSSI-85
17: RSSI-86
18: RSSI-66
19: RSSI-88
20: RSSI-80
21: RSSI-74
22: RSSI-81
23: RSSI-87
salio
ordeno
4: RSSI:-60
1: RSSI:-65
0: RSSI:-69
3: RSSI:-50
18: RSSI:-66
15: RSSI:-60
2: RSSI:-72
10: RSSI:-74
11: RSSI:-77
21: RSSI:-74
19: RSSI:-88
20: RSSI:-80
22: RSSI:-81
23: RSSI:-87
12: RSSI:-78
5: RSSI:-87
6: RSSI:-87
7: RSSI:-79
8: RSSI:-80
9: RSSI:-88
13: RSSI:-83
14: RSSI:-79
16: RSSI:-85
17: RSSI:-86

As you can see the sorting is not OK and I don't get why.
Thank you in advance and sorry for my poor English.


texts: How can we know the status of the DC Motor whether it is ON or OFF

texts: A DC motor is operated using an L298n driver and Arduino UNO. How can I get to know whether the Motor is ON or OFF? Using a code in Arduino.


texts: Conncet Bluetoth module HC-05 to Arduino Uno Using UART Usb to enter in AT command

texts:
I have connected Arduino Rx(pin 0) to Bluetooth module Rx pin. Tx od Arduino to Tx of Bluetooth . I am able to send command to Bluetooth module using Serial Monitor of Arduino on my PC.

I have uploaded the empty code in Arduino.

I want to know why we connected Tx to Tx and Rx to Rx i.e one to one connection?

If I send command "AT" from my PC using serial Monitor of Arduino , How is it flowing to Bluetooth module.

Why not we connect Rx to Tx pin in AT Mode of Bluetooth module?

Pls explain using diagram.


texts: post data from node mcu to my sql database

texts:
#include <ESP8266WiFi.h>

const char* ssid = "xxxx";
const char* password = "xxxxxxxxxx";

const char* host = "192.168.43.18";
const int ldr = A0;
int val = 0;

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

  Serial.printf("Connecting to %s ", ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println(" connected");
}

void loop()
{
  val = analogRead(ldr);
  WiFiClient client;

  Serial.printf("\n[Connecting to %s ... ", host);
  if (client.connect(host, 80))
  {
    Serial.println("connected]");
    client.println("POST /past.php HTTP/1.1");
    client.println("Host: 192.168.43.10");
    client.print(val);
    Serial.println(val);
    Serial.println("\n[Disconnected]");
  }
  else
  {
    Serial.println("connection failed!]");
    client.stop();
  }
  delay(5000);
}

I have uploaded this code to node mcu but it get's working but the uploaded data in my database is not shown please any one help me out


texts:
I'm wondering if Arduino is able to not just measure sound and work based on hearing a sound that is "loud enough", but if it is able to identify a specific sound (say the first few seconds of a song). Is this possible, and how would one go about doing so?

If identifying the first few seconds of a song isn't really feasible, is it at least possible to do so with a consistent (but particular) pitch (rather than a general loudness threshold)?


texts: Program around this while loop not working as expected

texts:
int i=0;
while(i == 0){
  if(digitalRead(saveSwitch) == HIGH){
    Serial.print("New coordinates saved \n");
    lat1 = gps.location.lat();
    Serial.print("Latitude");
    Serial.println(lat1);

    lng1 = gps.location.lng();
    Serial.print("Longitude");
    Serial.println(lng1);
    i = 1;
  }
}

Why isn't leaving the while loop?


texts: How to effectively modify a library to be able to function with Mozzi Library?

texts: I have sketch that runs almost exactly as I would want it to. Now I am trying to add sound to it using the Mozzi Library instead of just using the tone function. This way I can avoid having to put a memory card slot and a memory card with the Arduino, considering Mozzi produces some good sound. The problem is that Mozzi takes over the timers and a lot of other things. The analogread and the delaymicroseconds have been replaced by Mozzi functions mozzi analog read and mozziMicros etc. I rewrote my sketch adding mozzi relted stuff, but it stops functioning like it should, but it does compile. SO I am assuming I would need to change the Library to replace original functions with mozzi functions like mozzianalogread. On doing this, several errors about arguments and declaration for these functions pop up. Is editing the other library a necessary step? If yes, then what should be things to look out for to prevent such errors.


texts: SIM868 AT+CIPGSMLOC returns latitude and longitude location as 0.000000

texts:
I am unable to get any location data from SIM868 module using the command

AT+CIPGSMLOC=1,1
It returns 0.000000,0.000000,2019/12/23,08:50:39

I have internet enabled using AT+SAPBR=1,1 command.
However I get proper location data when I use the command AT+CLBS=4,1
Havent found any relevant info in the AT command Manual v1.10.

I had AT+CIPGSMLOC=1,1 command working correctly on a sim800L module.


texts: Powering Arduino and LED strips from one adapter

texts:
My project has my Arduino controlling 10 led strips. I'm going with a plan by @gre_gor that is posted here: Setting 10 RGB Strips Independently from Single Arduino
...where each strip is controlled by an STM32 driver.

I'm packing all electronics into a tight space and will need to have the power adapter external with just the cable coming in.

I need power both to the arduino and directly to the stm32's.

Question: can I simply split the 12V power cable to send power to both the led strips and the arduino? Or is there something I should worry about?


texts:
I am working on a dew point sensor, and I am using the Arduino Uno board with the DHT22 sensor. I have it taking a reading once ever 2 seconds and I am using the DHT.h library.
The problem I am having is when I compare the values to our standard here the Humidity reads high and the Temp reads low. Is there anyway to get the values to read closer to what the standard is?


texts: Using Lego temperature sensor with Arduino

texts:
I have Arduino mega and Lego temperature sensor which I would like to connect to the Arduino. I'm trying to use a I2C connection between them, with no luck. I connected the sensor and Arduino referring to the picture below:
I'm using the Wire library for transmitting data. This is my code currently:

#include < Wire.h >
byte ADDRESS=0x98;
byte CONFIG=0x01;
void setup(){
  Serial.begin(9600);
  Wire.begin();
  Wire.beginTransmission(ADDRESS);
  Wire.write(CONFIG);
  Wire.endTransmission();
  delay(100);
}
void loop(){
  Wire.beginTransmission(ADDRESS);
  Wire.write(CONFIG);
 Wire.endTransmission();
  Wire.requestFrom(ADDRESS,2);
  delay(100);
  int avail=Wire.available();
  Serial.println(avail);
  delay(100);
}

I found the config and address values from RobotC drivers for the same sensor. But all I get is zeros. Is there any way i could check for a defect sensor? Is my code correct?


texts:
I'm writing code for a project with Arduino Yun. My project is quite simple: it takes a picture with a webcam and saves it in a PNG or JPEG file format. I've already installed the uvc driver for Arduino Yun and tested it with my webcam and the fswebcam application. The application saved pictures both in PNG and JPEG format successfully, so I went on and installed the C compiler, make and binutils for Arduino Yun and started to write my own application that would do the same thing (just taking a picture and saving it in PNG format). After writing the code to capture the pixels of the image, I decided to write them down in a PNG file format by using the libpng library available for Arduino Yun through luci web control panel. After installing the package, I included the png.h (using #include png.h) in my source code and wrote the code to write those pixels down in a simple PNG file (thanks to this tutorial: http://www.labbookpages.co.uk/software/imgProc/libPNG.html).
What's the problem? It just won't compile! I tried everything and all I got were "undefined reference to 'function name here'" errors. I thought that, maybe, libpng was buggy so I moved to libjpeg. No luck! I get the same errors over and over again. I really don't know what else I can do, I tried everything, it just seems that the Arduino Yun C compiler can't handle "external" libraries. I thank you in advance for any help you'll give me...

Here are the errors I get when I try to compile it using the libjpeg library:

/tmp/ccdzMFgN.o: In function `salvaImmagineJPEG':
    ScattaFoto.c:(.text+0x1d9c): undefined reference to `jpeg_std_error'
    ScattaFoto.c:(.text+0x1da8): undefined reference to `jpeg_std_error'
    ScattaFoto.c:(.text+0x1dc8): undefined reference to `jpeg_CreateCompress'
    ScattaFoto.c:(.text+0x1dd4): undefined reference to `jpeg_CreateCompress'
    ScattaFoto.c:(.text+0x1dec): undefined reference to `jpeg_stdio_dest'
    ScattaFoto.c:(.text+0x1df8): undefined reference to `jpeg_stdio_dest'
    ScattaFoto.c:(.text+0x1e2c): undefined reference to `jpeg_set_defaults'
    ScattaFoto.c:(.text+0x1e38): undefined reference to `jpeg_set_defaults'
    ScattaFoto.c:(.text+0x1e54): undefined reference to `jpeg_set_quality'
    ScattaFoto.c:(.text+0x1e60): undefined reference to `jpeg_set_quality'
    ScattaFoto.c:(.text+0x1e78): undefined reference to `jpeg_start_compress'
    ScattaFoto.c:(.text+0x1e84): undefined reference to `jpeg_start_compress'
    ScattaFoto.c:(.text+0x1ed8): undefined reference to `jpeg_write_scanlines'
    ScattaFoto.c:(.text+0x1ee4): undefined reference to `jpeg_write_scanlines'
    ScattaFoto.c:(.text+0x1f10): undefined reference to `jpeg_finish_compress'
    ScattaFoto.c:(.text+0x1f1c): undefined reference to `jpeg_finish_compress'
    collect2: ld returned 1 exit status


texts: Send data to Programmable Power supply from Arduino by RS232

texts:
I have a programmable power supply, which has serial communication port. If I send a string "VSET1:11.00" then power supply will be set to 11.00V.
But, I need to write a program which will increase the voltage of power supply by 0.10V
For ex from 0V to 11.00V in incrementing steps of 0.10V.
Also, power supply needs a fixed data frame format like Parity bit, Data bits, stop bit.
So, how to create a data frame structure and send from arduino.
Do I need to use Software Serial library?
PS. I'm new to arduino, so may sound foolish.


texts: Sonar and servo stop working when usb cable unplugged

texts:
I am using the following components to build simple motobot:

Arduino Uno
Arduino motor shield,
servo,
sonar HC-SR04,
magician chessis,
DC adapter with 4 AA batteries.

All works fine while USB cable is plugged. As soon as I unplug USB cable servo and sonar stop working, although motors connected to motor shield continue rolling.

From what I read around internet motor shield operates with 7-12V voltage. I need 5V for sonar and servo. So they both are connected to 5V pin on the shield board.

How could I overcome this issue?


texts: Getting some strange data from an MPU-6050

texts:
I'm trying to create an IMU unit using MPU-6050 unit.
I've got 100k data records, and this is the result:

It seems to me that's a kind of offset in gx. Why?

Why I'm getting this kind of drifting in acz?
This is the setup code:
void setup_mpu_6050_registers(){

  //Activate the MPU-6050

  //Start communicating with the MPU-6050
  Wire.beginTransmission(0x68);
  //Send the requested starting register
  Wire.write(0x6B);
  //Set the requested starting register
  Wire.write(0x00);
  //End the transmission
  Wire.endTransmission();

  //Configure the accelerometer (+/-8g)

  //Start communicating with the MPU-6050
  Wire.beginTransmission(0x68);
  //Send the requested starting register
  Wire.write(0x1C);
  //Set the requested starting register
  Wire.write(0x10);
  //End the transmission
  Wire.endTransmission();

  //Configure the gyro (500dps full scale)

  //Start communicating with the MPU-6050
  Wire.beginTransmission(0x68);
  //Send the requested starting register
  Wire.write(0x1B);
  //Set the requested starting register
  Wire.write(0x08);
  //End the transmission
  Wire.endTransmission();

}

And this is the reading code:
void read_mpu_6050_data(){

  //Read the raw gyro and accelerometer data

  //Start communicating with the MPU-6050
  Wire.beginTransmission(0x68);
  //Send the requested starting register
  Wire.write(0x3B);
  //End the transmission
  Wire.endTransmission();
  //Request 14 bytes from the MPU-6050
  Wire.requestFrom(0x68,14);
  //Wait until all the bytes are received
  while(Wire.available() < 14);

  //Following statements left shift 8 bits, then bitwise OR.
  //Turns two 8-bit values into one 16-bit value
  myData.msecs = millis();
  myData.acc_x = Wire.read()<<8|Wire.read();
  myData.acc_y = Wire.read()<<8|Wire.read();
  myData.acc_z = Wire.read()<<8|Wire.read();
  myData.temp = Wire.read()<<8|Wire.read();
  myData.gyro_x = Wire.read()<<8|Wire.read();
  myData.gyro_y = Wire.read()<<8|Wire.read();
  myData.gyro_z = Wire.read()<<8|Wire.read();
}

The structure that stores data is:
struct datastore {
   long msecs;
   int acc_x, acc_y, acc_z;
   int temp;
   int gyro_x, gyro_y, gyro_z;
};

Then I save data in the card:
logFile.write((const uint8_t *)&myData, sizeof(myData));


texts: 5xWS2812B in parallel works fine in ESPHome but not in C code?

texts:
Facing a weird issue, that is probably something pretty simple, but I've went through ESPHome's code on Github and can't figure out.

I've wired up 5 WS2812B controllers on an ESP8266 (Wemos D1 R1), going from D1 to D5, controlling only 7 LEDs each.

I have the following code in ESPHome:

light:
  - platform: fastled_clockless
    chipset: WS2812B
    pin: D1
    num_leds: 7
    rgb_order: GRB
    name: "Heat #1"

  - platform: fastled_clockless
    chipset: WS2812B
    pin: D2
    num_leds: 7
    rgb_order: GRB
    name: "Heat #2"

  - repeat this 5 times, only thing changing is D1 through D5 and the name

In ESPHome, it works fine, I can control all 5 controllers no problem, both with the HTTP server and the Home Assistant API. I had done that in ESPHome to test the hardware build, since I had ESPHome already setup and it was easy.

I want to setup some Arduino code so that I don't need to depend on ESPHome (this will be a standalone project, that broadcasts an AP and has custom logic).

I have the following sample copied from FastLED's multiple controller example:

#include "FastLED.h"

#define NUM_LEDS_PER_STRIP 7
CRGB leds0[NUM_LEDS_PER_STRIP];
CRGB leds1[NUM_LEDS_PER_STRIP];
CRGB leds2[NUM_LEDS_PER_STRIP];
CRGB leds3[NUM_LEDS_PER_STRIP];
CRGB leds4[NUM_LEDS_PER_STRIP];

void setup() {
    FastLED.addLeds<WS2812B, D1, GRB>(leds0, NUM_LEDS_PER_STRIP);
    FastLED.addLeds<WS2812B, D2, GRB>(leds1, NUM_LEDS_PER_STRIP);
    FastLED.addLeds<WS2812B, D3, GRB>(leds2, NUM_LEDS_PER_STRIP);
    FastLED.addLeds<WS2812B, D4, GRB>(leds3, NUM_LEDS_PER_STRIP);
    FastLED.addLeds<WS2812B, D5, GRB>(leds4, NUM_LEDS_PER_STRIP);
}

void loop() {
    for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
        leds0[i] = CRGB::Red;
        leds1[i] = CRGB::Red;
        leds2[i] = CRGB::Red;
        leds3[i] = CRGB::Red;
        leds4[i] = CRGB::Red;
        FastLED.show();
        leds0[i] = CRGB::Black;
        leds1[i] = CRGB::Black;
        leds2[i] = CRGB::Black;
        leds3[i] = CRGB::Black;
        leds4[i] = CRGB::Black;
        delay(100);
    }
}

With this one, I can only control 3 lights: D1, D2 and D5. I've attached a picture of what it looks like. The other 2 just stays white.

https://i.imgur.com/AQ7X0pe.jpg

I'm most likely missing something simple that ESPHome is doing that I am not. It's a long shot, but anyone has a clue?


texts:
I've scored a couple Nanos with FT232RL chips but can't see them on my brand new M1 mini. Can someone point me at how to determine whether v11.1 supports this USB chip?
It appears that the device is being instantiated but the Arduino IDE gets no response to the Get Board Info.
FT232R USB UART:

  Product ID:   0x6001
  Vendor ID:    0x0403  (Future Technology Devices International Limited)
  Version:  6.00
  Serial Number:    AR0JT9YB
  Speed:    Up to 12 Mb/s
  Manufacturer: FTDI
  Location ID:  0x02214000 / 20
  Current Available (mA):   500
  Current Required (mA):    90
  Extra Operating Current (mA): 0

Executing the ioreg mentioned by @st2000 gives;
+-o Root  <class IORegistryEntry, id 0x100000100, retain 31>
  +-o AppleT8103USBXHCI@00000000  <class AppleT8103USBXHCI, id 0x100000291, registered, matched, active, busy 0 (1676 ms), retain 328>
  | +-o Extreme SSD@00200000  <class IOUSBHostDevice, id 0x10000081d, registered, matched, active, busy 0 (219 ms), retain 132>
  +-o AppleT8103USBXHCI@01000000  <class AppleT8103USBXHCI, id 0x100000295, registered, matched, active, busy 0 (4 ms), retain 39>
  +-o AppleT8103USBXHCIFL1100@02000000  <class AppleT8103USBXHCIFL1100, id 0x1000006eb, registered, matched, active, busy 0 (1220 ms), retain 494>
    +-o Keyboard Hub@02100000  <class IOUSBHostDevice, id 0x10000071c, registered, matched, active, busy 0 (164 ms), retain 30>
    | +-o Apple Keyboard@02120000  <class IOUSBHostDevice, id 0x100000805, registered, matched, active, busy 0 (162 ms), retain 32>
    +-o 4-Port USB 2.0 Hub@02200000  <class IOUSBHostDevice, id 0x100000730, registered, matched, active, busy 0 (826 ms), retain 46>
    | +-o 4-Port USB 2.0 Hub@02230000  <class IOUSBHostDevice, id 0x100000785, registered, matched, active, busy 0 (11 ms), retain 42>
    | +-o 4-Port USB 2.0 Hub@02220000  <class IOUSBHostDevice, id 0x100000791, registered, matched, active, busy 0 (16 ms), retain 43>
    | | +-o Backup+ Hub@02223000  <class IOUSBHostDevice, id 0x1000007dc, registered, matched, active, busy 0 (6 ms), retain 41>
    | +-o 4-Port USB 2.0 Hub@02210000  <class IOUSBHostDevice, id 0x10000079d, registered, matched, active, busy 0 (776 ms), retain 43>
    | | +-o FT232R USB UART@02214000  <class IOUSBHostDevice, id 0x100007622, registered, matched, active, busy 0 (75 ms), retain 23>
    | +-o 4-Port USB 2.0 Hub@02240000  <class IOUSBHostDevice, id 0x1000007b6, registered, matched, active, busy 0 (12 ms), retain 42>
    +-o 4-Port USB 3.0 Hub@02600000  <class IOUSBHostDevice, id 0x100000749, registered, matched, active, busy 0 (231 ms), retain 46>
      +-o 4-Port USB 3.0 Hub@02620000  <class IOUSBHostDevice, id 0x10000075e, registered, matched, active, busy 0 (170 ms), retain 43>
      | +-o Backup+ Hub@02623000  <class IOUSBHostDevice, id 0x1000007c3, registered, matched, active, busy 0 (155 ms), retain 41>
      |   +-o Backup+ Hub BK@02623100  <class IOUSBHostDevice, id 0x1000007ee, registered, matched, active, busy 0 (147 ms), retain 131>
      +-o 4-Port USB 3.0 Hub@02640000  <class IOUSBHostDevice, id 0x100000763, registered, matched, active, busy 0 (15 ms), retain 42>
      +-o 4-Port USB 3.0 Hub@02630000  <class IOUSBHostDevice, id 0x100000775, registered, matched, active, busy 0 (15 ms), retain 42>
      +-o 4-Port USB 3.0 Hub@02610000  <class IOUSBHostDevice, id 0x1000007a9, registered, matched, active, busy 0 (16 ms), retain 42>

Which does not appear to contain the device afai can see. Any know if this means a new device for Big Sur is indicated as per Majenko♦ ?


texts: OLED display crashes when connecting USB

texts:
I got an 16x2 OLED Display (DEP 16201-Y , compatible to the HD44780 controller) for my Arduino Uno and I got it to work in 4-bit Mode, but just if the USB isn't connected and it is powered by a 9V power supply.

So my routine is:

Connect USB and power supply
Upload Code
--> Doesn't work
Disconnect USB and power supply
Just connect power supply
--> Works
Connect USB
--> Display crashes

So basically: If the arduino is connected via USB to my PC, with or without an additional power supply, the display won't work properly, it will crash or the Arduino even restarts itself. (some kind of memory error?)

I have no possible explanation for this..

Thanks for your help.

EDIT: I'm running Ubuntu Mate Kernel 4.4.0-43-generic 64bit

If I plug in the cabel without power, display works fine.
If I plug in the cabel with 5V, but the PC is shut down, the display works fine.
For the display to crash, the pc has to be running.

Test code:

#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

void setup()
{
    //lcd.clear();
    lcd.begin(16, 2);
    lcd.clear();
    lcd.setCursor(0,1);
    lcd.print("Hello there");
    delay(1000);
}

void loop()
{
    lcd.setCursor(0,1);
    lcd.print("Hello World");

    lcd.setCursor(0,0);
    lcd.print("ABCDEFGHIJKLM");

    delay(1800);

    lcd.clear();

}


texts: IR module sensor query for Line Follwer Robot

texts: Are the IR sensors used in Line following Robot and Obstacle avoidance Robot with Arduino UNO different ? If yes , where do we buy these parts online ? I used the following sensor in my Line Follower and am not getting result as it’s detecting obstacle instead of black line .


texts: How can I configure Arduino after programming it (for post upload wifi configuration)?

texts:
I would like to make a device that can take a photo, and send it to a website over wifi. I'm using an Arduino Uno, a ArduCam OV2640 module, and ESP8266 Serial WIFI module. Eventually I'd like to take it off the board as a stand alone project for permanent use.

The wifi works fine, but requires a serial communication to configure. I would like to make it so that I can plug the device into a computer (via something like micro usb), change the WIFI settings, and save those settings for future reboots.

If there anyway I can do this with an Arduino interface? If not, what could I use instead?


texts: How do I set a variable so that after a condition is met the loop ignores input?

texts:
I have a analog inputs to my Uno that I am cleaning up and using to keep a digital pin high until the output drops to zero. At this point I want to stop reading that input because it may come back up after being low for a short time.
Is there any way to set a variable that can be triggered by that first zero that prevents the loop from sending the digital pin high from then on?
Like a latch of some sort, or could I use an interrupt somehow?


texts: how to fix USBASP Unknown USB Device (device descriptor request failed) - Win 10?

texts: I just recently purchased Usbasp from Ali Express, when i'm connecting it to the windows 10 desktop in device manager its Unknown USB Device (device descriptor request failed). How to fix this error? Even in Linux its not detecting.


texts: Makeblock Arduino keeps stopping from motor overpower protection

texts: I got a makeblock Arduino. Sometimes when I make it go forward at full speed, all motors stop for 3 seconds and it beeps shortly. I think it is that the motors are a little hard to turn for a moment and it stops to prevent damage to the motors. It is getting very annoying. Is there any way to disable it or make it less sensitive?


texts: bitRead() gives wrong answer Arduino UNO R3

texts:
I am trying to read from a quadrature rotary encoder using an Arduino UNO R3. This is done by connecting the encoder's channel A pin to the Arduino interrupt 0 pin (digital IO pin 2). Inside the interrupt routine I then read the value of channel B (connected to digital IO pin 8) to determine the direction of rotation.

I am able to read the correct value of channel B using the digitalRead() function, but when I use bitRead() it always gives me a 0. As far as I know digital IO pin 8 is mapped to PORTB bit 0, so I am using bitRead(PORTB, 0) to read the bit. I also tried to read all of the other pins, but all of them show 0, except the LED at pin 13, which shows 0s and 1s when it gets toggled (It is also the only pin defined to be an OUTPUT pin, whereas the encoder uses INPUT pins).

Below is my code:

int channelA = 0;
int channelB = 8;
volatile int rotateNumber = 0;
volatile boolean interrupted = false;

void setup() {

    Serial.begin(115200);

    attachInterrupt(channelA, rotate, RISING);
    pinMode(channelB, INPUT);
}

void loop() {
   if(interrupted){
       Serial.println(rotateNumber)
       interrupted = false;
   }
}

void rotate(){
  if(bitRead(PORTB, 0) == 1)
     rotateNumber++;
  else
     rotateNumber--;

  interrupted = true;
}


texts: vrdude stk 500 not responding error inspeed control of dc motor using arduino uno board .how to solve this issue


texts: RGB Led strip pot control burned my arduino?

texts:
I made this exact build on my Arduino, with the following differences:

I'm using Arduino Nano
Transistors I use are 2N2222A
I'm running everything on 12V except Arduino, I use LM317 to feed Arduino 6v

Here's the build:

Here's what happened. First, it started to get strange voltage, arduino would light up even when disconnected from power. After that, Arduino kind of got fried, when I connect it to USB, nothing happens. I can give it 6v to VIN and ground it with the rest, but turning potentiometers only dims the onboard LED of the Arduino and that's it.

Now I'm going to go and pick up a new nano, however, I'd prefer not to fry that one, so figuring out why this one burned would be nice.

PS. The image shows RGB LED instead of RGB LED Strip because 123d doesn't have strip component.


texts: I cannot find the I2C device by scanning

texts:
I've been trying to get a LCD I bought from deal extreme to work for some time with my ATTiny85 chip. It should be capable.
I've tried googling the device but there is no proper documentation, so I figured the best way to get the address is to scan for it. How ever, the code below does not work :( any pointers? Anyone else who has gotten this I2C LCD display to work with Arduino?

As I have no other output then the screen, the thought behind the code is to scan for devices and then when it finds one (the LCD is the only one connected to the bus) should then print the address :)

I only have a serial programmer and attiny85 chips, so I have no way to bring it to a full Arduino UNO or whatever for further debugging.

#include <TinyWireM.h>
#include <LiquidCrystal_I2C.h>

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

void loop()
{
  byte error, address;

  for(address = 1; address < 127; address++ )
  {
    TinyWireM.beginTransmission(address);

    error = TinyWireM.endTransmission();

    if (error == 0) break;

    delay(5000);
  }

  LiquidCrystal_I2C lcd(address, 16, 2);

  lcd.init();
  lcd.backlight();
  lcd.clear();

  lcd.setCursor(0, 0);
  lcd.print("Hello World - " + address);
}

I2C LCD: http://www.dx.com/p/iic-i2c-2-5-blue-screen-lcd-display-module-for-arduino-green-black-266170#.U6f_B_l_vIc


texts: Controlled power-down for automotive application

texts:
I'm working on an automotive project that uses an Arduino Mega 2560.

What I need is a circuit that allows the unit to sense when the external power feed drops (triggering an interrupt?) so that the software can preserve state to the non-volatile memory and then shut down.

I was thinking some sort of capacitor/battery to run it once the eternal feed drops, but the hardware side of things is not my strong skillset - I'm more of a software kinda person.


texts:
I just got my arduino and servo. But my servo may be acting strangely.

Whenever I tell the servo to go somewhere it keeps going to 0 than to that position and stops after 10-15 seconds or more.

This is the code used in this video

#include <Servo.h>

    Servo myservo;

    void setup()
    {
      myservo.attach(11);
      myservo.write(50);
    }

    void loop()
    {
    }

https://www.youtube.com/watch?v=rsikknT7z6g

It is connected like this:

Ground from Arduino to breadboard row 3

Ground from external power supply to breadboard row 3

Ground from SERVO to breadboard row 3

Power supply positive to servo VCC

Servo signal to pin 11


texts: One Arduino collects data, several other Arduinos use the data. What is a simple way to do this?

texts:
I am looking for a way to exchange a few bytes of data from one Arduino to two or more additional Arduinos. It's a one way communication and speed is not a problem. 10Hz is fast enough.

Data Collector Arduino: I have one Arduino with SPI and I2C shields which collects and analyzes data from a CAN-BUS in a motorcycle. The CAN-BUS supplies lots of information but I filter it down to few info like which lights are on, intake temperature, motor RPM, which gear.

Light Control Arduino: This Arduino should know which lights are on. Depending on low beam, high beam, indicators, etc. it will control additional lights which are not part of the original bike.

Motor Control Arduino: This Arduino should know the current RPM, gear, etc. and work with that data.

The question is how do I "transfer" the data from the data collector to the other Arduinos? If it would be a little simpler I would connect some digital pins which the data collector would write and the others would read. But there are not enough pins for my needs and why use 10 pins when maybe 2 are enough.

All the Arduinos use SPI and I2C connected devices so I don't think it's a good idea to use SPI or I2C for communication between the Arduios.

I guess Serial communication would work with 2 Arduinos but not with 3 or even more. Maybe I could use multiplexing or something like that?

Maybe I could let the data collector Arduino write data into some kind of shared memory and the other Arduinos could read it?

What do you suggest? I am sure there are simple solutions out there but I didn't find anything. I don't mind any extra ICs.

Before someone suggest to do all in one Arduino: Maybe it would be possible. But I really like to keep the modules (Arduinos) separate and I want to be able to add others later if I want to. Then I only want to change the software of the collector Arduino and don't touch the others.


texts: How to stop Arduino from reseting after serial connection lost

texts:
If I connect to an Arduino Uno via a serial console to read debugging statements and then disconnect, the Arduino appears to reset. How do I stop this from happening?

I'm trying to program an Arduino to receive a "shutdown" signal from a Raspberry Pi via serial, which will make the Arduino cut the RPi's power. However, this will also cut the serial connection, and if it causes the Arduino to reset, it'll reactivate power.


texts: Need help to set PWM frequency to 25kHz on pin 8 of Arduino Mega to control speed of a 4-wire cpu fan

texts:
This question is not same as the other one and this is more about employing the pwm signal to drive a CPU fan;

I am trying to follow the answer by Edgar Bonet on the question Need help to set PWM frequency to 25kHz and generate the same 25khz on pin 8 of arduino mega which is controlled by TIMER 4 and use this pwm signal to control the speed of a 4-wire cpu fan(with black, yellow, green and blue wires);

Following is my updated code for generating the pwm signal on timer 4

void analogWrite25k(int value)
{
    OCR4C = value;
}

void setup()
{
    TCCR4A = 0;
    TCCR4B = 0;
    TCNT4  = 0;
    TCCR4A = _BV(COM4C1)  // non-inverted PWM on ch. C
          | _BV(WGM41);  // mode 10: phase correct PWM, TOP = ICR4
    TCCR4B = _BV(WGM43)
         | _BV(CS40);   // prescaler = 1
    ICR4   = 320;      // TOP = 320

    // Set the PWM pin as output.
    pinMode( 8, OUTPUT);
}

void loop()
{
    analogWrite25k(10);
    for (;;) ;  // infinite loop
}

I have connected pin 8 on the mega to the pwm input on the fan(blue wire) but I dont see any variation in fan speed and fan seems to run at full speed;

I dont really have any means or tools to verify if its really generating a 25khz pwm signal but fan speed is not changing or if its not generating a 25khz pwm signal because of which there is no change in the speed of fan;

I am stuck at this point and any help on this would he highly appreciated;


texts: I just started using Arduino and so far I've used both delay() and delayMicroseconds(). I was wondering what the difference between these two is, because it seems to me that they're the same.


texts:
I have a program where the Arduino receives hex Strings that represent a RGBW color (similar to css for example). My goal is to create that color by using pwm, so I need to convert that one hex string into four integer values between 0..255 to use for the pwm.
Whats the best/easiest way to do this?

Example:

void incomingMessage(const MyMessage &message) {

    // h = hex value
    // message = e.g. (h) #112233AB
    redval = ?; // h11 => 17
    greenval = ?; // h22 => 34
    blueval = ?; // h33 = 51
    whiteval = ?; //AB = 171

    analogWrite(RED_PIN, redval);
    analogWrite(GREEN_PIN, greenval);
    analogWrite(BLUE_PIN, blueval);
    analogWrite(WHITE_PIN, whiteval);

}


texts: Counting to 1000 In Both cores execution time problem in esp32?

texts:
I am trying to count to 1000 with single core and dual core with esp32 but the output(run time) dose not make sense, the time which takes a single core should be doubled compared to dual core in theory right?
Here is the code
TaskHandle_t Task1;
TaskHandle_t Task2;
SemaphoreHandle_t baton;

int i = 0;
long l;

void setup() {

  Serial.begin(115200);
  pinMode(2, OUTPUT);
  pinMode(4, OUTPUT);

  baton = xSemaphoreCreateMutex();
  l = millis();
  xTaskCreatePinnedToCore(
    Task1code, /* Function to implement the task */
    "Task1", /* Name of the task */
    10000,  /* Stack size in words */
    NULL,  /* Task input parameter */
    1,  /* Priority of the task */
    &Task1,  /* Task handle. */
    0); /* Core where the task should run */

//single core or dual core execution

//  xTaskCreatePinnedToCore(
//    Task2code, /* Function to implement the task */
//    "Task2", /* Name of the task */
//    10000,  /* Stack size in words */
//    NULL,  /* Task input parameter */
//    1,  /* Priority of the task */
//    &Task2,  /* Task handle. */
//    1); /* Core where the task should run */

}
void Task1code( void * parameter) {
  while (true) {
    xSemaphoreTake(baton, portMAX_DELAY);
    xSemaphoreGive(baton);
    delay(1);// I don't understand in here without this command output result is worse
    i++;
    if (i == 1000) {
      l = millis()-1;
      Serial.print("Done ");
      Serial.print(xPortGetCoreID());
      Serial.print(" ");
      Serial.println(l);

    }if(i>1000){
      vTaskDelete(Task1);
    }
  }
}
void Task2code( void * parameter) {
  while (true) {
    xSemaphoreTake(baton, portMAX_DELAY);
    xSemaphoreGive(baton);
    delay(1);// I don't understand in here without this command output result is worse
    i++;
    if (i == 1000) {
      l = millis()-1;
      Serial.print("Done ");
      Serial.print(xPortGetCoreID());
      Serial.print(" ");
      Serial.println(l);
    }if(i>1000){
      vTaskDelete(Task2);
    }
  }
}
void loop() {

}

The output I get for runtime
Single core :- 1033 ms
Dual core :- 701 ms

Without delay(1); command the result is even more obvious
Single core :- 39 ms
Dual core :- 40 ms

How can I make my algorithm show that single core takes twice time as dual core execution time I wan't both cores to work parallel not one after the other.


texts:
so please read this whole thing.

My Project: I am making a bell system that is based on PHP. The bell is connected to the arduino UNO via a relay and the arduino is connected to the computer via a USB cable. The interface with the database is built with PHP and MySql. Then we have the code which checks every minuit if the bell has to be rung and if it does send a numeric value to the arduino. There is also an option for a longer bell if we send a '0' to the arduino.

My Code: So this is the file that checks if bell has to rung and sends value to arduino

<?php
include('database.php');
$usb_comPort = "COM3";
date_default_timezone_set("Asia/Kolkata");
$time = date("H:i");
$time = trim($time);
$sql = "SELECT bell_amount FROM bell_db WHERE DATE_FORMAT(bell_time,'%H:%i') LIKE '$time'";
$result = mysqli_query($conn, $sql);
$numRows = mysqli_num_rows($result);
if ($numRows == 0) {
  echo 'Error: Nothing found!';
} else {
  $row = mysqli_fetch_assoc($result);
  $bellAmount = $row['bell_amount'];
  $runCommand = "ECHO " . $bellAmount . " > $usb_comPort";
  echo $runCommand;
  exec($runCommand);
}
?>
<html>
<meta http-equiv="refresh" content="60">
<body>
</body>
</html>

and this is the arduino's code:

int b = 0;
void setup() {
Serial.begin(9600);
pinMode(10, OUTPUT); //relay
}

 void loop() {
  b = Serial.read();

    b = b - 48;
    if(b == 0){
      digitalWrite(10,HIGH);

      delay(3000);
      digitalWrite(10,LOW);
      }
    else{
    for (int i=0; i < b; i++){
      digitalWrite(10, HIGH);
      delay(200);
      digitalWrite(10, LOW);
      delay(200);
      }

    }

}

The Issue that i am facing: My aim is that the code should run automatically when the computer is turned on. The code works fine but there is random bug. The code is uploaded to the arduino. When the computer is turned on i want that the system should work but when i run the file  (the one that checks if there is a bell to be rung or not ) it processes the code but it is not able to send a value to the com port so the bell does not ring(the serial light on the arduino does not flash). But if i go to the arduino ide and send a value through the serial monitor once then run the php file, it works!

I am running this on a windows 10 computer, i have an arduino UNO and i have tried this with 2 arduino's same result on both.

So anyone know what i can do?


texts: How to turn I2C Sensors on and off with an Arduino Mega 2560?

texts:
I want to turn on and off I2C Sensors with the Arduino Mega 2560.

I use one max. 0.4A NPN Transistor, which controls the Vcc line to the sensor.

When I plug my Arduino into my laptop and the sketch begins working everything is fine. The sensor is turned on and is working.

But when I set the Transistor Base to Low and cut the Vcc the sensor acts weird.
The LED on the sensor breakout board shines very weak. So the sensor/breakout board is getting electricity from somewhere else; probably from the I2C connections.

Same results with this small experiment:

Breakout board directly connected to the Arduino (without Transistor)
Vcc-3.3V pin wire disconnected from the Arduino female pin

How can i properly turn on and off an I2C sensor with an Arduino?

Do I have to use additional transistors for every I2C line? Are better circuit solutions available or maybe a software solution?

How should I design my circuit and my software if I have multiple I2C sensors connected to my Arduino and I want to use them independently from each other?

Used hardware: Arduino Mega, Sensor Breakout Board

Software excerpt for power control:

void setup() {

    pinMode(7, OUTPUT);
    digitalWrite(7, HIGH);

    ...

    delay(10000);
    digitalWrite(7, LOW);

    ...
}


texts:
I am writing a program for esp32 on Arduino IDE. On some point of execution of code for File reading I am facing this exception,
Guru Meditation Error: Core  1 panic'ed (Unhandled debug exception)
Debug exception reason: Stack canary watchpoint triggered (loopTask)

However on reading few forums I found an answer of increasing the depth of the stack for your FreeRTOS task.
My question is there any other way to handle this exception other than increasing stack size and avoid the program from crashing ?


texts: I have IR sensor with current draw 100ma i have to connect 5 of them is i can connect all 5 with arduino directly or i have to use external power suplly for them


texts: What are (or how do I use) the power saving options of the Arduino to extend battery life?

texts:
For solar & battery powered projects, decreasing power consumption is a necessity.

I know a little bit about using a timer and interrupt to put the microcontroller into sleep when it isn't doing anything.

I have also read that you can disable some peripherals to further save power.

Here is a page explaining these: Power Saving Techniques

My question:

What other techniques are there to save power?
Are there any libraries that make using these AVR features easier?


texts:
I have a list of set-ups and I only have 2 rows in the lcd , I'm trying to scroll down for the moment and I'm doing this by changing the row in the setcursor function to either 0 or 1.

However since that I'll be having about 10 set-ups I used an equation that will change the rows to 0 and one for the ones I want to display and a negative number for those that I don't want to appear.
The problem is when setting the cursor's row to -1 or 2, it will ignore the one with row one (which is the 2nd row).

Is there a way that I can overcome this problem ? by setting it to a row that will not appear on my LCD?
I'm using #include <LiquidCrystal.h>
and I already set lcd.begin(16, 2);

int  colom[5] = {
    0-goDown,1-goDown,2-goDown,3-goDown,4-goDown  };
for (int i = 0; i < 4; i++) {
    if (colom[i] > 1) colom[i] = -1;
}

  lcd.setCursor(0, colom[0]);
  lcd.print("choise 1 ");
  lcd.setCursor(0, colom[1]);
  lcd.print("choise 2 ");
  lcd.setCursor(0, colom[2]);
  lcd.print("choise 3 ");
  lcd.setCursor(0, colom[3]);
  lcd.print("choise 4 ");
  lcd.setCursor(0, colom[4]);
  lcd.print("choise 5 ");

So here goDown is 0 so choice 1 and 2 should appear, but I'm only getting choice 1 and in the second row it's changing quickly between 2 and 5, it's not constant.

I thought about doing an if condition for each choice but that will be a lot of code to write and it won't be efficient for my application.


texts:
I currently have limited electronics experience. I am planning to use mains power through relays for climate control, so considering the risk, I would like to check to see if these relays are appropriately connected to receive mains power.

I have two relays. One relay will take 600W (a heater) while the other will have 50W/0.2A (a fan).

The relay module is: https://www.auselectronicsdirect.com.au/assets/files/(ST1080)5V%20Relay%20module.pdf
There seems to be a resistor inbuilt into the casing, and according to the packet (but not the PDF) there is inbuilt Back-EMF protection.

My concern is that it may not be protected against inrush, uses screw terminals, and may not be isolated.

Diagram is:

Any advice will be appreciated. Once again, I will not run mains power through it until I am sure of it being safe.


texts: WebCam Face detection and tracking tutorial with Arduino Uno R3 and OpenCV 3.0 RC1 in Ubuntu 14.04

texts:
I try to make this Arduino Open CV tutorial for webcams. OpenCV 3.0 RC1 is compiled and installed. I also use Code::Blocks 13.12 as IDE. I am a newbie what comes to OpenCV and I do not know too much about Arduino either but here I am learning. Arduino IDE is 1.7.2. The tutorial is made for Windows 7 and software for this OS but I bet it is possible to repeat this in Ubuntu Linux 14.04 also.

So the tutorial is here:

http://duino4projects.com/face-detection-and-tracking-with-arduino-and-opencv/

When I try to compile and run the techbitarFaceDetection.cpp

the Code::Block IDE gives me following error:

  fatal error: Tserial.h: No such file or directory

So please tell me what to do next and how to fix this error.


texts: multiple connection with ISP Pin at Arduino Micro

texts:
Actually I'm not good at English ;-) trying to ask to you. please understand me :)

I needed connect SD card Shield and TFT LCD Screen to Arduino Micro.

successfully finished compile at source code but when i connect MISO together

it doesn't work. only SS pin is connected separate Pin's to Micro

How can i make it work together to Micro..

i've checked each device perfectly work at Micro

Plese Help me!!

Regards and Thanks


texts: Accessing multiplexed I2C and UART pins of STM32F103 in arduino IDE

texts: I want to access both of the multiplexed I2C and UART pins in the same program. I am programming in Arduino IDE.Can anyone please tell me how to access same pins for different functionalities?


texts: Cannot start Arduino IDE after playing with several versions of it

texts:
On my Linux Mint 17 Quiana I have manually downloaded and ran several versions of the arduino IDE (1.05 which is in the repo, 1.6.x for some time, now 1.8.3). Things worked like a charm.

Now I am trying to get the IDE 1.8.5 going, but I cannot get the IDE started. Started means: I download, extract the files to a directory and run the install.sh command such that the desktop icon gets created. This finishe with a success message. Now I am clicking on the desktop icon, but nothing happens.

Need to say that the IDE 1.05 which comes as a package with Qiana works just fine. I have run the install.sh of both to and fro, but only the 1.05 will start properly. I checked on the desktop link, the execution rights, user, group etc. They are all looking fine for 1.8.5 but it wont start.

I tried to start the 1.85 arduino IDE from the command line - hoping to get some clue from error messages:

java -DAPP_DIR=/opt/arduino-1.8.5/ Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel processing.app.Base

--> running this it tells me, that the main class cannot be found.

Any hints where I am going wrong? Are there any config files to be cleared up, paths to be set ...?


texts: Leonardo and micro: high pitch noise when powered from Vin

texts:
I have an issue with several Leonardo and Micro boards.

On all of my boards, there is a sawtooth of about 690mV ptp @ 4kHz on the 5V supply when powered from Vin (external power).
The frequency changes slightly when changing input voltage from 7V to 12V.

C12 is a capacitor on the Leonardo board that is making the acoustic noise, it is "singing" with the frequency of this sawtooth. It follows the voltage regulator NCP1117 for the 5V power supply generation.

According to the schematics of the Leonardo and micro, the voltage regulator used on these boards should be the NCP1117, but on the boards I have, there is no number printed on this component, so I suspect an alternative was used, with these annoying results...

For a project I have for generating audio signals, this noise was unacceptable, so I cut out the regulator and powered everything with an external LM7805. One should not power the module via USB then as long as the external power is connected!!!

Anyone having the same trouble with these boards?
Other solutions?

(The Leonardo is a genuine Arduino board.)


texts: Can't figure out source of interference reading 10k POTs with 74HC4051

texts:
I realize this gets asked a lot, but I feel like I've applied the most common fixes without success. I have 10 10k potentiometers plugged in to an arduino via a custom shield. 2 are wired directly to the MC via A2 and A3. The other 8 are plugged in via a 74HC4051 multiplexer. The 2 plugged in directly work great. The other 8 show a ton of cross talk and don't seem to vary as much as they should. Here is some example output on the arduino serial plotter:

Things I have tried:

I put a delay between the pin selection and the read.
I'm reading twice (with a delay in between) and discarding the first read.

I'd use an MCP2308 if I were doing this again, but in the mean time is there anything else I can try?

Here is my schematic:

Each pot is plugged in to 5V and ground, with the wiper wired directly to the pin, all via jumper cables to the shield. Here's a picture of how this works (apologies for the mess):

The pin blocks have, per row, one pin each feeding in to a multiplexer input, and another attached to the GND and +5V planes on the PCB. These are attached to +5V and GND on the arduino:

Here is my code:

const int selectPins[3] = {8, 12, 13}; // S0, S1, S2
const int zInput = A1; // Connect common (Z) to A1 (analog input)
const int DIMp = A2;
const int bDIMp = A3;
void setup()
{
  Serial.begin(9600); // Initialize the serial port
  // Set up the select pins as outputs:
  for (int i=0; i<3; i++)
  {
    pinMode(selectPins[i], OUTPUT);
    digitalWrite(selectPins[i], HIGH);
  }
  pinMode(zInput, INPUT);
  pinMode(DIMp, INPUT);
  pinMode(bDIMp, INPUT);
}

// The selectMuxPin function sets the S0, S1, and S2 pins
// accordingly, given a pin from 0-7.
void selectAMuxPin(byte pin)
{
  for (int i=0; i<3; i++)
  {
    if (pin & (1<<i))
      digitalWrite(selectPins[i], HIGH);
    else
      digitalWrite(selectPins[i], LOW);
  }
}

void loop()
{
  // Loop through the hard wired dimmers
  Serial.print(String(analogRead(DIMp))+" ");
  Serial.print(String(analogRead(bDIMp))+" ");
  // Loop through all eight pins.
  for (byte pin=0; pin<=7; pin++)
  {
    selectAMuxPin(pin); // Select one at a time
    delayMicroseconds(500); // delay after pin select
    int inputValueb = analogRead(zInput); // read Z
    delayMicroseconds(150); //delay after first read
    inputValueb = analogRead(zInput); // read Z again
    Serial.print(String(inputValueb) + " ");
  }
  Serial.println();
}


texts: How to write a function to return matrix?

texts:
I need a function to return a 2x2 rotation matrix, something like:

float matrix(float phi){
  float R[2][2] = { {cos(phi), -sin(phi)},
                    {sin(phi),  cos(phi)} };
return R;
}

But it doesn't work obviously. What is the best way to write this function?


texts: Arduino Mega 2560 and Android USB OTG serial communication

texts:
currently I am building a little project based on the Arduino Mega 2560.
My goal is to send some data gathered by some sensors to an Android phone.
It has to be as basic as possible.
Buying new hardware is no option.

After some research, I found that it is possible to communicate via USB OTG just with Serial commands.
I downloaded the an app which can do this (Serial Monitor), connected the Arduino via the USB cable to the Android.
Unfortunately, it did not work.

I have an Arduino UNO, too.
Connecting the UNO the same way to the phone works like a charm and does exactly what I want.

I did some more research and found nothing about that.
It seems that everybody is using the Arduino Mega ADK to establish a communication between Arduino and Android.
But I would like to be able to achieve this the same way it works with the UNO.

Can somebody explain me why it does not work?

EDIT
Here is the code I have to test:

Arduino

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

void loop() {
  Serial.println("Test...");
  delay(2000);
}

For Android I use the code from this tutorial.

Any further suggestions?


texts: How can I tell which pins I will have left available by looking at a shield?

texts:
I'm very new to Arduino and came to a point where I'm interested in playing with shields, such as LCDs.

For example, I really like the looks of "LCD 1602 with keypad" module, but it seems to be using a lot of pins.

By looking at a module / shield, how can I tell (or at least estimate) which pins will be used and which ones I will have left if I stack them with my Uno or Mega without printed schematics?


texts: Serial Communication, if statement not working

texts:
#include <SoftwareSerial.h>
SoftwareSerial my (D6,D7); //(Rx,Tx)
String msg;

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

void gas()
{

  Serial.println(msg);
  if (msg == "0")
  {
    Serial.println("Gas Leakage !!");
  }
  if(msg == "1") {
    delay(1);
  }
}

void loop() {

  msg = my.readStringUntil('\n');
  gas();
}

//I am using software serial to exchange data from Arduino UNO to NodeMCU, i am receiving the data correctly but the "if statement condition" is not working with it. how can i make the if statement work?


texts: How do I add Gyroscope, Accelerometer, Euler, and Temperature data to one Arduino board?

texts:
I have to use a BNO055 to get temperature/accelerometer/Euler/Gyroscope data into one Arduino board for a school project. I am very new to coding so I am not familiar with the commands. I have gotten my BNO055 to give me all the data individually but I am having problems getting them all compiled into one code file to upload. I have googled it but I keep getting links to upload them individually. Posted below is my latest attempt.

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>

Adafruit_BNO055 bno = Adafruit_BNO055(55);

void setup(void)
{
  Serial.begin(9600);
  Serial.println("Orientation Sensor Test"); Serial.println("");

  /* Initialise the sensor */
  if (!bno.begin())
  {
    /* There was a problem detecting the BNO055 ... check your connections */
    Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
    while (1);
  }

  delay(1000);

  bno.setExtCrystalUse(true);
}

void loop(void)
{
  /* Get a new sensor event */
  sensors_event_t event;
  bno.getEvent(&event);

  /* Display the current temperature */
  int8_t temp = bno.getTemp();

  Serial.print("Current Temperature: ");
  Serial.print(temp);
  Serial.println(" Celsius");
  Serial.print("");
}

void loop(void)
{
  /* Get a new Sensor event */
  sensors_event_t event;
  bno.getEvent(&event);

  imu::Vector<3> gyroscope = bno.getVector(Adafruit_BNO055::VECTOR_GYROSCOPE);

  /* Display the floating point data */
  Serial.print("X: ");
  Serial.print(gyroscope.x());
  Serial.print(" Y: ");
  Serial.print(gyroscope.y());
  Serial.print(" Z: ");
  Serial.print(gyroscope.z());
  Serial.println("");
  delay(100);
}

void loop(void)
{
  /* Get a new sensor event */
  sensors_event_t event;
  bno.getEvent(&event);

  imu::Vector<3> accelerometer = bno.getVector(Adafruit_BNO055::VECTOR_ACCELEROMETER);

  /* Display the floating point data */
  Serial.print("X: ");
  Serial.print(accelerometer.x());
  Serial.print(" Y: ");
  Serial.print(accelerometer.y());
  Serial.print(" Z: ");
  Serial.print(accelerometer.z());
  Serial.println("");
  delay(100);
}

void loop(void)
{
  /* Get a new sensor event */
  sensors_event_t event;
  bno.getEvent(&event);

  imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER);

  /* Display the floating point data */
  Serial.print("X: ");
  Serial.print(euler.x());
  Serial.print(" Y: ");
  Serial.print(euler.y());
  Serial.print(" Z: ");
  Serial.print(euler.z());
  Serial.println("");
  delay(100);
}


texts: How to network multiple Arduinos so they react to the same signal

texts:
I want to build a project that contains multiple Arduino nano's, each connected to one controlling Raspberry Pi.  I would like to send one signal (a string of characters or numbers) which would be the master state, which the other Arduinos would react to based on their programming.  What is the best way to do this?

Can the Arduino support a protocol for this, or will it need additional hardware?

Max distance: 30 meters


texts: Adafruit Motor Shield steppers not turning

texts:
The Adafruit Motor Shield is connected to 2 steppers which are wired correctly and work when I just use the onestep function. I understand that I cannot drive both at once, so I am using a while loop with two if statements. The Motors were wired:

The left motor was wired:

Green -> m3+
White -> m3-
Red -> m4+
Blue -> m4-

The right motor was wired:

Red -> M2+
Blue -> M2-
Green -> M1+
Black -> M1-

Here is the code:

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_MS_PWMServoDriver.h"

Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_StepperMotor *leftMotor = AFMS.getStepper(200, 2);
Adafruit_StepperMotor *rightMotor = AFMS.getStepper(200, 1);
//79 steps per half inch
//half inch is a coordinate
//declaring global variables for Hypotenuses (cord lengths)
int leftHyp;
int rightHyp;
int prevX = 0;
int prevY = 0;
//space from shaft to shaft is 30"
//calculating function
void CordCalc(int xCord, int yCord)
{
    Serial.begin(9600);
  //cords start at 0,0
    xCord = xCord - prevX;
    yCord = yCord - prevY;
    int xSquared = sq(xCord);
    int ySquared = sq(yCord);
    int addSquares = xSquared + ySquared;
    int leftHyp = sqrt(addSquares);
  //now for the right
    int rightX = 60 - xCord;
    int rightXsq = sq(rightX);
    int rightSquares = rightXsq + ySquared;
    int rightHyp = sqrt(rightSquares);
  //leftMotor->step(leftHyp * 79, FORWARD, MICROSTEP);
  //rightMotor->step(rightHyp * 79, FORWARD, MICROSTEP);
    int lStepsTaken = 0;
    int rStepsTaken = 0;
    leftHyp = leftHyp * 79;
    rightHyp = rightHyp * 79;
    bool stepsComplete = false;

  //This is the section for moving the Motors
    while(stepsComplete == false) {
        if(lStepsTaken <= leftHyp) {
            leftMotor->onestep(FORWARD,DOUBLE);
            lStepsTaken++;
            Serial.print("Left");
        }

        if(rStepsTaken < rightHyp) {
            rightMotor->onestep(FORWARD,DOUBLE);
            rStepsTaken++;
            Serial.print("Right!");
        }

        if(rStepsTaken >= leftHyp && lStepsTaken >= leftHyp) {
            stepsComplete = true;
        }
    }

    int prevY = yCord;
    int prevX = xCord;
    stepsComplete = false;
}

void setup()
{
// direction from project point of view
    int leftLength = 0;
    int rightLength = 0;
    leftMotor->setSpeed(122);
    rightMotor->setSpeed(122);
    Serial.begin(9600);

    CordCalc(15, 15);
}

void loop()
{
}

Loop is empty on purpose because only need to move to coordinates once.


texts: Unable to upload sketch using Platformio (but Arduino IDE works)

texts:
I am using an Arduino Nano (Clone) which I was programming with the Arduino IDE (Version 1.8.5 on Mac OS X 10.10.5).

Using the Arduino IDE I need to re-plug the Nano before uploading, but after doing this everything works as expected and the sketch is being uploaded successfully.

I then tried to use Platformio core (CLI) and get the well-known not in sync error:

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

As said, this error is well-known, esp. in relation to Arduino clones, and reported several times around the Internet with different solutions.

I just wonder how Arduino IDE is able to upload the code successfully, but Platformio is not since both Arduino IDE and Platformio CLI are just calling avrdude to upload the code.

Remark: Uploading the same code to an Arduino Uno works like a charm with both using Arduino IDE and Platformio.

Updates due to further investigation:

I enabled verbose output for both Arduino IDE and Platformio showing the exact avrdude command executed to upload the built hex-file. I adopted the call to avrdude from Arduino IDE with the path of the compiled Platformio code. This works as expected:

avrdude -v -p atmega328p -c arduino -b 57600 -D -P /dev/cu.usbserial-00000000 -U flash:w:.pioenvs/nano/firmware.hex:i

I then had a look at the command used by Platformio which is quite similar but provides an additional -C for a config-file:

avrdude -v -p atmega328p -C /Users/Albert/.platformio/packages/tool-avrdude/avrdude.conf -c arduino -b 57600 -D -P "/dev/cu.usbserial-00000000" -U flash:w:.pioenvs/nano/firmware.hex:i

Unfortunately, I am not able to run this command from the Terminal due to an error:

avrdude: Version 6.0.1, compiled on Dec 16 2013 at 17:26:24
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/Users/Albert/.platformio/packages/tool-avrdude/avrdude.conf"
avrdude: syntax error at /Users/Albert/.platformio/packages/tool-avrdude/avrdude.conf:1080


texts: What configuration settings do I need to change on my computer to use the ethernet shield mounted on my Arduino UNO as I don't want to connect the ethernet shield to the router?


texts: USB Communication between Arduino Nano and UHF Reader module

texts:
I am working on a project that requires a UHF reader development kit that can communicate using either RS232 or by USB.  Via USB and a Serial terminal, I have been able to send commands to the reader as well as analyze its response.

My goal is to send these same commands to the reader, but through an Arduino Nano.  My first instinct was to use the RS232, converting the signal via a MAX232.  However, this is for a school project, and my advisor preferred I try to work with USB.  I am familiar with UART communication, and I've been under the assumption that USB operates using UART.

I had purchased a USB converter that gives me access to the pins, but it had two additional pins than I was not expecting: CTS and DTR.  I attempted to communicate despite these pins (just leaving them open, and connecting Rx, Tx, Vcc and GND as I normally would).  When plugged into the UHF reader, the device did power on (as it draws power from the USB connection), however, it did not receive the output signal from the Arduino Nano.

I know that my baud rate and other settings are correct, because, as I have said, communicating via USB and a Serial terminal gives me no problems.  My initial thought is that I need to properly connect the CTS and DTR pins, but immediately I could not find a good reference on how to do this, and I am not entirely convinced this is the issue.  My other thought was that perhaps I am writing out my HEX values wrong from the Arduino, using a line similar to the following, where "UHF_Reader" is defined by SoftwareSerial:

UHF_Reader.write(0xAA);

However, it appears to me from research that this is indeed the correct way to output HEX values via serial.

My final attempt to resolve this was to connect the micro-USB from the Nano to the USB of the reader, and then use Software Serial in conjunction with the USB converter to analyze the output on a Serial terminal, while powering the Nano via a 5V power supply.  However, since the reader draws power from the USB port, it did not even turn on when I attempted this (I am assuming that the Vcc can only be supplied from the USB end?).  Regardless, this attempt proved useless as well.

If anyone can offer any advice, or point me towards any references for something similar, I would much appreciate it!  I have spent a while on this, and I just can't figure out what the problem is.

For reference, the reader I am using is found here: UHF Reader

And the USB converter I am using is here: USB Converter


texts:
I am getting error with this. It is displaying those segments which are not to be displayed, i.e., 3.141 is dark and other segments are red. And I have checked that the seven segment module I am having is common anode type only.

#include "SevSeg.h"

SevSeg sevseg; //Initiate a seven segment controller object

void setup() {
    byte numDigits = 4;
    byte digitPins[] = {2, 3, 4, 5};
    byte segmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13};
    sevseg.begin(COMMON_ANODE, numDigits, digitPins, segmentPins);
    sevseg.setBrightness(1000);
}

void loop() {
    sevseg.setNumber(3141, 3);
    sevseg.refreshDisplay(); // Must run repeatedly
}


texts: Sketches not uploading to Micro from Ubuntu 14.04

texts:
I recently bought an Arduino Micro to see what all the fuss was about and I figured I'd use it with Ubuntu on an older Dell Latitude. I was able to install all of the files using some tutorials but I have this problem uploading sketches. After plugging in the board, the green top LED is consistently flashing so it seems to be working, but when I try to upload a sketch I get the following error

Connecting to programmer: .avrdude: Send: . [1b]
avrdude: Send: S [53]
avrdude: ser_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding

Any ideas how to fix this? I tried pressing reset during the send as some forums have suggested but it doesnt seem to be working.


texts: Erratic readings on Analogread with low voltages

texts:
I am using Arduino Uno for measuring sensor voltages. I am using multiplexer to switch between different sensors. The readings measured in the range of 800-900 mv are accurate, but at low millivolts (at about 20 mv) they are erratic. I read repeatedly to get average of 20 values. I get values such as 1.3, 1,4, 2,0, 3.8 etc.
Can any one help on why it is happening and how to avoid it.

Additional information: I am using reference voltage of 1.25 volt for better resolution.
I tried having delay between two readings, though there is some improvement, still the problem persists.

I appreciate the help by experts.
Thanks


texts: Only print when the button is pressed and not being pressed anymore

texts:
I have an Arduino and a microswitch that I want to use to know when the switch is initially being pressed (get "OnsetTime" on Serial) and when the switch is not being pressed anymore (get "OffsetTime" on Serial).

Imagine a bird sitting on the switch. I want to get an output "OnsetTime" when the bird first sits on the switch and an output "OffsetTime" when the bird flies away from the switch.

Right now, I have an output that constantly prints out "OnsetTime" when the switch is pressed.
I would appreciate it if anybody can help me figure out how can I implement the below code to get the outputs only when the switch is initially pressed and not being pressed anymore.

void setup() {
  pinMode(7, INPUT);
  Serial.begin(9600);
}

void loop() {
  if (digitalRead(7) == HIGH) {
    Serial.println("OnsetTime");
    }
}
    //Serial.println("GetOffsetTime");


texts: Serialize JSON as response to HTTP request

texts:
I'd like my ESP8266 to provide some JSON endpoints. I want to use ArduinoJson for serialisation. While this works in general if I serialize into a String and return this String afterwards, I was wondering if there is really no way to do this without wasting so much memory. Shouldn't it be possible to do something like this? Any hints?

ESP8266WebServer server;
StaticJsonDocument<768> response;
response["night"] = _playback.isNight();
response["shuffle"] = _playback.isShuffle();
server.send_P(200, "application/json", NULL);
serializeJson(response, server.client());

(this gives the following error:)

no instance of overloaded function "serializeJson" matches the argument list -- argument types are: (ArduinoJson6141_0000010::StaticJsonDocument<768U>, WiFiServer::ClientType)


texts: Including keypad library removes sound from my piezo element

texts:
I am using the keypad library to include keypad and input numbers. when a specific number is entered a sound must be made.
However when I input using the serial monitor , sound is working. But when I include keypad , it only inputs numbers but not sound.
Help please , how can I make both work?
Thanks.

#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[ROWS] = {12, 11, 10, 9}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8,7,6,5}; //connect to the column pinouts

Then I get the input from keypad and store as result

char guess = 'n';
 char keypressed = keypad.getKey();
  if (keypressed != NO_KEY) {
    char guess = keypressed;

in void loop, it get result(key from keypad) and must play it: Tried separate sketch it works. but with keypad only input is , not sound.

Serial.print("You guessed:");
      Serial.println(guess);
      result = checkYourself(guess);
      Serial.println(result);
      playSound(result);

check yourself takes in guess from keypad ,checks then returns as result.
play sound function works when tried in another sketch( sorry not posting too much code its very long)


texts: using UART bridge module to have serial communication through usb port of arduino nano

texts:
This can be a silly question but I'm having a trouble with serial communication between arduino nano with other serial device. Please help me to handle it.

I'm currently doing a RF communication project using arduino nano and radio telemetry which is using serial communication. I tried to use SoftwareSerial but unfortunately, every pin is being used on arduino nano to control other extra devices. So I decided to have serial communication via usb port of arduino nano

Firstly, I directly connected rx and tx wire of RF device with D- and D+ of B type mini USB. but it did not work

Secondly, I tried to connect rx and tx wire with arduino nano via UART to USB bridge, cp2102 module. I soldered a female USB - male mini USB wire for this connection. but It did not work. the wiring that I build seems like the picture below.

Did I miss something? It doesn't work theoretically anyway?
Please help
Thank you in advance


texts: Graphing force sensor data routed through HX711?

texts:
I'm using the code off of the sparkfun website HX711 hookup guide (https://learn.sparkfun.com/tutorials/load-cell-amplifier-hx711-breakout-hookup-guide#arduino-code) to attempt to create a scale.

Currently I have output data of weight in the serial monitor - is there an easy way to then graph this data with regards to time? I've spent an hour fooling around with Processing and googling, but haven't had any luck.

Thanks!


texts:
When compiling a sketch, after linking, the build outputs a kind of forecast on RAM usage, e.g.:

  Minimum Memory Usage: 1456 bytes (71% of a 2048 byte maximum)

Is it possible to somehow get a breakdown or itemization of these 1456 bytes and details on exactly where in my code, or in included libraries, they are used?


texts: Direct port manipulation to write 40 bits

texts:
I have 5 shift register changed in series and want to shift the data quickly. I have learned that the internal shiftOut function is slow and direct port manipulation can speed up the things.

However, I am not sure to write code in the specific way.

The current working code block is:

#define SensDataPin 4
#define SensClockPin 9
#define SensLatchPin 8
updateAllShifters()
{
digitalWrite(SensLatchPin, LOW);
shiftOut(SensDataPin,SensClockPin,LSBFIRST,byte_1);
shiftOut(SensDataPin,SensClockPin,LSBFIRST,byte_2);
shiftOut(SensDataPin,SensClockPin,LSBFIRST,byte_3);
shiftOut(SensDataPin,SensClockPin,LSBFIRST,byte_4);
shiftOut(SensDataPin,SensClockPin,LSBFIRST,byte_5);
digitalWrite(SensLatchPin, HIGH);
}

As the code shows, I have 5 bytes which are written by independent functions and just before the return statement, these functions call "updateAllShifters()" to mark the changes.

I have followed few tutorials over the internet and have re-written the logic like:

#define MSDATAHIGH PORTD |= (1<<PD4)
#define MSDATALOW PORTD &= ~(1<<PD4)
#define MSLATCHHIGH PORTB |= (1<<PB0)
#define MSLATCHLOW PORTB &= ~(1<<PB0)
#define MSCLOCKHIGH PORTB |= (1<<PB1)
#define MSCLOCKLOW PORTB &= ~(1<<PB1)
updateAllShifters()
{
MSLATCHLOW;
for(int i=0;i<40;i++)
{
HOW TO CODE HERE USING THE DEFINED MACROS!
}
MSLATCHHIGH;

Edit: Coding example of this (but want a more optimized way):

#define MSDATAHIGH PORTD |= (1<<PD4)
#define MSDATALOW PORTD &= ~(1<<PD4)
#define MSLATCHHIGH PORTB |= (1<<PB0)
#define MSLATCHLOW PORTB &= ~(1<<PB0)
#define MSCLOCKHIGH PORTB |= (1<<PB1)
#define MSCLOCKLOW PORTB &= ~(1<<PB1)
updateAllShifters()
{
MSLATCHLOW;
for(byte i=0;i<8;i++)
{
 if(!!(byte_1 & (1 << i)));// LSBFIRST
   {
   MSDATAHIGH;
   }else
   {
   MSDATALOW;
   }
}
 MSCLOCKHIGH;
 MSCLOCKLOW;
//DO ABOVE FOR ALL REMAINING 4 BYTES
MSLATCHHIGH;
}


texts:
I am using arduino Uno/Mega.
I am trying to output a range of 0-5v volts using PWM.
Is it possible to do it?
It’s would be nice to see some code or instructions, as far I have seen, they used external Module to get that voltage range, maybe I am wrong or I didn’t understand them well.
Thanks!


texts: Why connect the source pin on a mosfet to the pull down resistor?

texts: I'm trying to power stuff controlled by an arduino, and I'm looking at this tutorial: http://bildr.org/2012/03/rfp30n06le-arduino/ and it almost all makes sense, send a signal to the gate, but it's like a capacitor or something so provide a path for that signal to go to ground when the arduino isn't supplying current, but when it is supplying current then the source and drain are connected so current can flow from some external source through them... but why even connect that part of the circuit back to the board? I'll paste a pic with a question mark on the wire I'm frowning at:


texts: How can I inline parameters during build time from an external file?

texts: I have a small sketch that I'd like to redistribute. It contains a password that I don't want to pass on. Is there a way to have for example an external properties file or an env param that will allow me to push my sketch to version control without containing that password, but so that it is automatically inlined into the code without me having to insert it manually?


texts: Will an Arduino Uno be able to read 3x incremental encoders?

texts: Encoders are quadrature 600ppr encoders with X2 counting. Therefore 1200 counts per revolution for each encoder. Is there an edge rate limit? I currently have one encoder hooked up using code with interrupts.


texts: Can i use a range in a switchcase like in pascal?

texts:
in pascal's case statement i can use this:

Var i : integer;
...
Case i of
 1..5 : DoSomething;
end;

i was wondering if there is a way in can do this with c/c++ in the arduino compiler using:

switch (var) {
   case 1..5:
     // statements
     break;

or is this only possible using if/else?


texts: Returning struct from function generates 'does not name a type' compilation error

texts:
I have a main.ino file that contains
struct EulerAngles {
  double roll, pitch, yaw;
};

void setup() {
  EulerAngles angles;
  angles = anglesCalc();
  Serial.print(angles.yaw);
}

void loop() {
  Serial.println("In loop");
  delay(1000);
}

and an angles.ino file that contains
EulerAngles anglesCalc(){
   EulerAngles a;
   // calculate a
   return a;
}

When I compile the program, I get a compile error in the main.ino file:
   code/so_examples/main.ino:5:1: error: 'EulerAngles' does not name a type
 void setup() {
 ^~~~~~~~~~~
code/so_examples/main.ino: In function 'void setup()':
code/so_examples/main.ino:7:12: error: 'anglesCalc' was not declared in this scope
   angles = anglesCalc();
            ^~~~~~~~~~
code/so_examples/main.ino:7:12: note: suggested alternative: 'angles'
   angles = anglesCalc();
            ^~~~~~~~~~
            angles
[Build] Error occurred.

How do I fix this? Note that struct is declared before all else, so this answer does not seem to apply.  I am using the Stino plugin for Sublime Text as the IDE.


texts: FTDI Cable to bypass USB for Arduino (Blend Micro) Programming

texts:
I bought a Blend Micro (an Arduino Micro with Bluetooth) a few months ago, and after my first experimentation with uploading the Blink sketch something went wrong with the USB connection--it would supply power, but no computer (Windows, OS X or Linux) would show it as a USB device, and Windows would complain that the device was somehow damaged. Anyway, when I plug the board in, it still boots up and runs "Blink" so I'd like to try to still use it.

I have a USB-to-FTDI cable, and it would seem fairly straight-forward to use that, but I'm a little uncertain to the appropriate wiring and whether I would need to tell the Arduino software somehow that I was using FTDI.

I can figure out these connections: (I think)

black to ground
red to 5V (VIN?)
orange to RX
yellow to TX

What about green and brown? Do one of those go to RST (Brown?) and MOSI (Green?)

I figured I would ask before accidentally burning something out.


texts: Arduino Bluetooth data (large data files) transfer efficiency using HC05 module

texts:
Im using an HC-05 Bluetooth module connected to my Arduino MEGA. The Arduino has an SD card with some data files stored (sensor readings). After the sensor readings are done, the Arduino then connects to Android phone via Bluetooth and transfers the file data.
This is working fine. Arduino sends the data to HC-05 over Serial port, which transfers it over the air to my Android phone.

But its kinda slow and I hence had a question.

QUESTION: Does the HC-05 buffer the data coming from the Arduino Serial and then send efficiently filled packets over the air. I would like to make sure that the HC-05 isn't inefficiently sending just a single byte or so per Bluetooth packet.

Thank you.