texts:
I am trying to use Process.h library to run a shell command. Here is my code. I am using Arduino Uno.

#include <Process.h>
#include <Bridge.h>

void setup() {
  // Initialize Bridge
  //Bridge.begin(115200);

  // Initialize Serial
  Serial.begin(115200);

  // Wait until a Serial Monitor is connected.
  while (!Serial);

  // run various example processes
  runPythonFunction();
}

void loop() {
  // Do nothing here.
}

void runPythonFunction() {

  Process p;        // Create a process and call it "p"
  //p.begin("/usr/bin/python /home/kairos/Arduino/codes/sketch_jan26a/tweet.py");
  p.runShellCommandAsynchronously("/usr/bin/python -U /path/to/tweet.py");      // Run the process and wait for its termination
  //p.run();
  // Print command output on the SerialUSB.
  // A process output can be read with the stream methods
  while(p.available() > 0) {
     char c = p.read();
    Serial.print(c);
  }
  // Ensure the last bit of data is sent.
  Serial.flush();
  delay(300000);
}

If I do not comment the Bridge.begin() line, then in monitor display reverse question marks are displayed. And after commenting that, I am getting some garbage on the serial monitor. Also, my python script makes a new file in the same directory, which runs fine if I run it using a terminal. But if I run it using Arduino code, I am not able to see that new file being generated.

Even using p.begin() and p.run()it does not run. Nor using p.runShellCommandAsynchronously().

So how can I run that python script?


texts:
I'm trying to get a sensor to activate if a push button is clicked. And deactivate when a certain condition is met and reactivate when the push button is pressed again.

#include <SPI.h> // Included for SFE_LSM9DS0 library
#include <Wire.h>
#include <SFE_LSM9DS0.h>

#define LSM9DS0_XM  0x1D // Would be 0x1E if SDO_XM is LOW
#define LSM9DS0_G   0x6B // Would be 0x6A if SDO_G is LOW
// Create an instance of the LSM9DS0 library called `dof` the
// parameters for this constructor are:
// [SPI or I2C Mode declaration], [gyro I2C address], [xm I2C address]
LSM9DS0 dof(MODE_I2C, LSM9DS0_G, LSM9DS0_XM);

const byte INT1XM = 4; // INT1XM tells us when accel data is ready
//const byte INT2XM = 8; // INT2XM tells us when mag data is ready
//const byte DRDYG = 7;  // DRDYG tells us when gyro data is ready
const int buttonPin = 15;     // the number of the pushbutton pin

int buttonState = 0;

double X;
double Y;
double Z;

void setup(){

  pinMode(INT1XM, INPUT);
  pinMode(buttonPin, INPUT);

  Serial.begin(9600);
  Serial1.begin(9600); // Start serial at 115200 bps
  // Use the begin() function to initialize the LSM9DS0 library.
  // You can either call it with no parameters (the easy way):

  uint16_t status = dof.begin();
  // Or call it with declarations for sensor scales and data rates:
  //uint16_t status = dof.begin(dof.G_SCALE_2000DPS, dof.A_SCALE_6G, dof.M_SCALE_2GS);

  // begin() returns a 16-bit value which includes both the gyro and
  // accelerometers WHO_AM_I response. You can check this to make sure
  // communication was successful.
  // Serial.println(status, HEX);
  setODR();
}

void loop(){

  buttonState = digitalRead(buttonPin); //Read push button logic.

 // Serial.println(buttonState);

  if (buttonState == 1) {   //if push button is pressed

    printAccel(); //print sensor data

  }

}

void printAccel()
{
  // Only read from the accelerometer if the accel interrupts,
  // which means that new data is ready.
  if (digitalRead(INT1XM))
  {
    // Use the readAccel() function to get new data from the accel.
    // After calling this function, new values will be stored in
    // the ax, ay, and az variables.
    dof.readAccel();

    //Serial.print("A: ");

    // Using the calcAccel helper function, we can get the
    // accelerometer readings in g's.
    X=dof.calcAccel(dof.ax);
    Y=dof.calcAccel(dof.ay);
    Z=dof.calcAccel(dof.az);

    Serial.print(X);
    Serial.print(", ");
    Serial.print(Y);
    Serial.print(", ");
    Serial.println(Z);

    // Serial1.println(Z);

    fall(); //jump to check condition

  }
}

void setODR(){

  dof.setAccelODR(dof.A_ODR_25);
  dof.setAccelScale(dof.A_SCALE_16G);
}

void fall(){

  if(-0.08<X && X<0.08){
    if(-0.08<Y && Y<0.08){
      if(-0.08<Z && Z<0.08){

        Serial1.println("N");
        Serial.println("Fallen!");

        loop(); //if condition is met, jump to loop to wait for push button to be pressed again.

        }
      }
    }
  //else{

    printAccel(); //else continue printing sensor data

  //}
}

However I am having some trouble getting it to work, above is what I have worked out thus far.


texts: Problems when communicating with SD card using ethernet shield

texts:
I am using the "SD read/write" code from the Arduino IDE examples to test an ethernet shield (clone). The problem is that although a file is created no data is stored in it.

When running the serial monitor will only show the first characters of the Serial.print() sentences, e.g when doing Serial.print("Initializing SD card...") the serial monitors displays Ini or In and nothing else.
Also the IDE shows the following error message: (some words in spanish)

Error dentro de Serial.serialEvent()
java.io.IOException: Error de entrada/salida in nativeavailable
at gnu.io.RXTXPort.nativeavailable(Native Method)
at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1598)
at processing.app.Serial.serialEvent(Serial.java:258)
at gnu.io.RXTXPort.sendEvent(RXTXPort.java:774)
at gnu.io.RXTXPort.eventLoop(Native Method)
at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1644)

I have tried with 2 different SD cards, including a brand new one, and 2 different Arduino Uno (a clone and an original one). The OS is Ubuntu 13.10.

My guess is that it has something to do with the myFile.println() sentences, when they are commented the serial monitor works fine.

Any help is much appreciated since I couldn't find the problem anywhere else so far!


texts: Display problems with the 1602A LCD Display while the COM7 shows the results

texts:
I am trying to use an Arduino for a temperature sensor, the sensor will use an if-else command to give the temperature reading. I didn't wrote the whole code but found the code and was making necessary changes to obtain the desired results. I am using the 1602A display with Arduino Mega 2560. I use the following websites to obtain the desired results the inks I have shared below:

https://www.instructables.com/Calibration-of-DS18B20-Sensor-With-Arduino-UNO/

https://gist.github.com/AlexanderSavochkin/6045dad44130bbff80db.

I was able to get the desired results and the sensor is working which is displayed in the Serial Monitor on the Arduino, but I am not able to get a display on my 1602A LCD screen. I have uploaded the code below. Can anyone please provide me with any suggestions?
Thank you.
#include <Wire.h>

#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 7
#define RELAY1  4  // Relay heating
#define RELAY2  6  // Relay cooling

int red = 8; // red LED heating
int blue = 2; // blue LED cooling

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

LiquidCrystal_I2C lcd(0x27, 2, 16); // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
  Serial.begin(9600);// initialize serial monitor at a baud rate of 9600
  sensors.begin(); //Initialize the sensor
  lcd.backlight(); //Turns backlight on

  lcd.begin(0, 0);
  //lcd.clear();// to clear the output
  pinMode(red, OUTPUT);//Setting the pin 8 as an output
  pinMode(blue, OUTPUT);// Setting the pin 2 as an output
  pinMode(RELAY1, OUTPUT);// setting the pin 4 as an output
  pinMode(RELAY2, OUTPUT);// Setting the pin 6 as an output

}

void loop()
{
  sensors.requestTemperatures();

  //Read first sensor
  float temperature = sensors.getTempCByIndex(0);
  Serial.print(" Temperature Control");
  lcd.setCursor(0, 0);
  Serial.println(sensors.getTempCByIndex(0));
  lcd.write(temperature);
  Serial.print(temperature);
  Serial.print((char)10);

  if (temperature < 25)
  {
    digitalWrite(red, HIGH);
    digitalWrite(blue, LOW);
    digitalWrite(RELAY1, 0);
    digitalWrite(RELAY2, 1);
    lcd.setCursor(2, 2);
    Serial.print("Heating is required");
    lcd.print(temperature);
    //Wait 0.1 sec
    delay(1000);

  }

  else if (temperature > 25)
  {
    digitalWrite(RELAY1, 1);
    digitalWrite(RELAY2, 0);
    digitalWrite(red, LOW);
    digitalWrite(blue, HIGH);
    lcd.setCursor(2, 2);
    Serial.print("Cooling is required ");
    lcd.print(temperature);
    delay(1000);
    //Wait 0.1 sec

  }
}


texts: Message Interpreter and Handler - How to store a function name in a struct?

texts:
For a project, I need to store an array of structures in PROGMEM. Array MessageTable[] will be composed of about ten struct InMessage elements. InMessage looks sort of like this:

struct AvcInMessage {
  MessageHandler  msgHandler;
  byte            dataSize;
  byte            data[8];
  char            description[20];
};

MessageHandler is not a data type... yet. I'm not really sure what data type to use. I want to be able to pick a message from the table and then call MessageTable[x].msgHandler() if that makes sense. I'm almost positive that this involves a pointer. Does someone here have an idea about what I'm looking for?


texts: Serial receiver (Arduino Micro ATmega32U4) in bad state

texts:
I have configured two Arduino Micros as a pair of multiplexer/demultiplexers communicating via Tx and Rx.

Everything works great except for one little thing. If I reset the sender (multiplexer) the receiver (demultiplexer) goes into a bad state resulting in random low and high outputs.

Resetting the receiver brings it back to a normal state but I am hoping someone might have a better solution. Using the serial monitor I noticed that during the reset process on the sender there are some seemingly random bits being transmitted toward the end. Not sure if this has anything to do with it.

The code for the sender is:

byte PINBold;
byte PINDold;
byte PINFold;

byte PBmask = B11111110;
byte PDmask = B11010011;
byte PFmask = B11110011;

void setup() {
  Serial1.begin(3704400); // Speed
  DDRB = DDRB & B00000001; // Sets pins to digital input: 11,10,9,8,MI,MO,SCK
  DDRD = DDRD & B00101100; // Sets pins to digital input: 2,3,4,6,12
  DDRF = DDRF & B00001100; // Sets pins to digital input: A0,A1,A2,A3,A4,A5
}

void loop() {
  if (((PINB & PBmask) != PINBold) |((PIND & PDmask) != PINDold) | ((PINF & PFmask) != PINFold)) {
    Serial1.write(PINB);
    Serial1.write(PIND);
    Serial1.write(PINF);

    PINBold = PINB & PBmask;
    PINDold = PIND & PDmask;
    PINFold = PINF & PFmask;
  }
}

The code fore the receiver is:

void setup() {
Serial1.begin(3704400); // Speed
DDRB = DDRB | B11111110; // Sets pins to digital output: 8,9,10,11,MI,MO,SCK
DDRD = DDRD | B11010011; // Sets pins to digital output: 2,3,4,6,12
DDRF = DDRF | B11110011; // Sets pins to digital output: A0,A1,A2,A3,A4,A5

PORTB = PORTB | B11111110;
PORTD = PORTD | B11010011;
PORTF = PORTF | B11110011;
}

void loop() {
if (Serial1.available() > 2) {
PORTB = Serial1.read();
PORTD = Serial1.read();
PORTF = Serial1.read();
}
}


texts: Arduino not writing full NMEA sentence to SD-card file

texts:
I'm currently building a small GPS-box that's supposed to track my location and write the full NMEA sentence to an sd card.
(I want to pars it afterwards at my pc)
I'm using the Arduino Nano and the NEO-6M GPS Module to get the data.

What works: getting the NMEA data from the module, writing to the SD-card.
Outputting the data to the serial output over Serial.write works fine.

Now I have the problem that it looks like the Arduino can't write the data fast enough to the SD-card and desyncs with the GPS module. This occasionally produces things like this: $G3,3,09,32,20,248,*4D

I have some ideas on how to fix this:
1. write the data faster
2. always wait till the data is fully written before acquiring the next fix
3. only write every second GPS fix

I tried to implement these but failed every time (sorry I'm new to this).

Here is my current code:

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

SoftwareSerial GPS_Serial(4, 3); // GPS Module’s TX to D4 & RX to D3
File GPS_File;
int NBR = 1;  //file number

void setup() {
  Serial.begin(9600);
  GPS_Serial.begin(9600);
  SD.begin(5);                  //SD Pin

  //write data to a new file
  bool rn = false;
  while (rn == false) {
    if (SD.exists(String(NBR) + ".txt")) {
      NBR = NBR + 1;
    }
    else {
      GPS_File = SD.open(String(NBR) + ".txt", FILE_WRITE);
      GPS_File.write("START\n");
      GPS_File.close();
      rn = true;
    }
  }
}

int x = 0;
int temp = 0;
char gpsData;
char buff[300];

void loop() {

  //collect data and write to buffer
  while (GPS_Serial.available() > 0) {
    gpsData = GPS_Serial.read();
    x++;
    buff[x] = gpsData;
  }

  temp = x;
  x = 1;

  GPS_File = SD.open(String(NBR) + ".txt", FILE_WRITE);

  //copy from buffer to sd
  while (x <= temp) {
    GPS_File.print(buff[x]);
    x++;
  }

  GPS_File.close();

  x = 0;
  temp = 0;
}


texts:
How does an AVR-based Arduino's CPU performance compare to a vintage PC (Apple II, PC-XT, TRS-80, et.al.)?

How many megaflops of number crunching can one get out of an AVR-based Arduino?


texts: Char buffer for serial input: char str[2] vs char* str = (char*) malloc(2)

texts:
I am using software serials on my Arduino nano to read data from my esp01 in functionality testing for the software serial. I simply make the esp01 to send a string "OK" to an Arduino's software rx serial port (in this case pin 9) , and then the Arduino prints it on the monitor via its hardware serial (USB).
I've found that when I allocate space for the string in Arduino using char str[2], the message seems to be correct. However, with char* str = (char*)malloc(2), there appear to be an unkown character tai
ling the string "OK"
Below is the code I use
#include<SoftwareSerial.h>

SoftwareSerial s(9,10);
void setup() {
  pinMode(2,OUTPUT);
  Serial.begin(9600);
  s.begin(9600);      // link to esp01
}

void loop() {

  if(s.available() > 0){
    char txt[2];
    int indx = 0;

   // read input
    while(s.available() > 0 && indx <=SIZE-1){
        char buff;
        buff=  s.read();
        txt[indx] =  buff;
        Serial.println(indx);
        indx++;

    }
   // bink an LED for debugging
   if((String)txt == "OK"){
    digitalWrite(2,HIGH);
    delay(500);
    digitalWrite(2,LOW);
    delay(500);
   }

   //reset index
   if(indx ==2){

     Serial.println(txt);
     Serial.print("Size of string:");
     Serial.println(sizeof(txt));
    indx = 0;
   }
  } // if(s.available())

}

here is the print-out of the serial monitor

That tailing square is the myster for me.
Any help would be grateful!!
Boris


texts: Record stereo audio from two Bluetooth headsets

texts:
I've been playing with Arduino for a few years, but I'm new to Bluetooth and streaming audio.

I'd like to develop (or assemble or buy) a device for recording stereo audio from a pair of Bluetooth headsets to a lossless file format on a micro SD card. I'm thinking this would be great for recording a podcast on the go with two people.

I'm guessing an ESP32 or similar could relatively easily record mono audio to an SD card.

Questions:

Any recommendations on libraries and/or tutorials that could be used to piece together audio recording from a Bluetooth headset mic to lossless audio file on micro SD card? I'm thinking at least this first step should be relatively straightforward. :)
Any suggestions on how to integrate two stream of mono audio from two Bluetooth headset mics in order to combine to a single stereo audio file (using the streams as left and right channel)? I think this would require two Bluetooth receivers, and streaming the audio from each to a third processor for combining and saving the streams to a single stereo file. But again I'm interested in libraries, frameworks, etc.

Thanks so much!!


texts:
There was a similar thread before but it didn't solve my problem. I had an issue with sending GPS data, which is float, and I couldn't receive the float with the same amount of significant figures as I was sending. I always received a number with 2 digits after a decimal point. So I started debugging and wrote this simple code just to check if floats work as intended:

#include <SoftwareSerial.h>
void setup() {
Serial.begin(9600);
}
void loop() {
float number1;
number1=1.45436;
Serial.print(number1);
delay(200);
}

And the serial monitor showed 1.45 as an output. How can increase the precision of the float I am saving in memory?


texts: Attiny85 not recognized at windows startup

texts:
I'm using an Attiny85 to interact with a computer using an USB connection, and everything works fine except when I restart my computer and the Attiny85 is connected. When Windows end to boot up the Attiny85 isnt't recognized, and on Device Manager it's listed like this:

If I unplug the Attiny85 and then plug it back in, everything works just fine.

Is there any to make it detectable at boot time without having to always unplug/plug it?

EDIT:

More details:

I'm using this board

and libusb-win32 as the USB driver


texts: Arduino Orion Upload - Which Board When Compiling

texts:
I'm trying to compile and upload the example code for the arduino robotics starter kit (https://github.com/Makeblock-official/Makeblock-Library and https://raw.githubusercontent.com/Makeblock-official/Assembly-Instructions/master/Starter_Robot_Kit_IR_Instruction.pdf).

In the IDE to compile the code, you need to select the appropiate 'board' for the sketch, and the Arduino Orion isn't listed.  Should I just compile under the Arduino Uno, which I believe the Orion is based on?


texts: Wireless playstation 2 remote not connecting up to arduino

texts:
I am trying to connect my wireless playstation 2 remote up to my arduino but I am facing one problem. Whenever I restart my program (by clicking the red button) the PS2 remote's dongle blinks at the exact same times as the blink light on the arduino blinks. But as soon as the arduino's light stops blinking, the RX light on the PS2 dongle (which was blinking), stops blinking. I saw a guide out there on potential ways of fixing this and one type of way of fixing it according to the documentation for the PS2 libary (which no longer exists on a website) was by doing some type of pull-up resistor (I am not 100% too sure what this is). I have checked the wiring and its fine. This was the website that I followed that shows the step by step instructions on how to program the controller with the arduino and how to wire it: https://create.arduino.cc/projecthub/electropeak/how-to-interface-ps2-wireless-controller-w-arduino-a0a813. Here is the schematic that I followed for the concept with the pull-up resistor:

I have just tried removing the clock pin from pin 13 (which is already connected up to the clock pin of the PS2 controller).This got rid of the blinking of the dongle blinking directly at the same time as the arduino when restarting the program. The reason why I did this was because it seemed to get rid of the RX blinking issue. Here is a few images that might solve the confusion with the problem.

This is how my dongle is wired up to my arduino :

This is the PS2 dongle. The RX light is what keeps blinking synchronous to the arduino pin 13 light (This is the light that blinks each time you re-compile or restart the program).

This is the LED that I am referring to when I mention the LED on pin 13 of the arduino.
So when pin 13 on the arduino is blinking the RX light on the PS2 dongle is blinking synchronous to it.
The reason that I removed the clock pin from pin 13 on the arduino was because I knew that the pin 13's blinking LED connects up to pin 13 itself (which is wired up to the clock pin on the arduino), this did nothing.
What I am trying to aim to get is that the PS2 dongle

Is for it to be like this and for it to just stay on and NOT blink :
One final thing I forget to mention was that when the LED finished blinking (when restarting). the RX LED on the dongle went off.


texts: nrfl2041, WIFI, bluetooth, xbee, zwave, other wireless communications

texts: Have a project using up to 200 sensors. communication method needs to be wireless. Sensors need to communicate data to the cloud or to a local storage device. Data is transmitted 6 to 24 times per day only. Data size is less than 1KB per sensor in most cases. Transmission distance is less than 150' in most cases. Transmitted data described here is digital, but might be analog if needed. Cost is a big issue. Power consumption is also a big issue but less important than cost. What method would you use nrfl2041, WIFI, bluetooth, xbee, zwave, or other wireless communications method? Love to hear your opinion.


texts:
I have a EL Sequencer and FTDI 5V breakout board.  I have been have been unable to program it.  All my attempts get some variation of "programmer is not responding".

I was using these instructions as a starting place.  I soldered the 6 pinholes as indicated.  I have connected everything.  I am not sure if I should switch the FTDI jumper to 3.3V (it is currently at 5V).  The pin in the EL Sequencer is labelled 5V, but the instructions also say "the EL Sequencer runs an ATmega328p at 8 MHz and 3.3V".  Should I change the jumper to 3.3V?

I have downloaded the latest IDE from here.  But there is no board option for the EL Sequencer.  What board should I select?

Anything else I need to do to program the EL Sequencer?

Thank you,


texts: Error 'exec: "python": executable file not found in $PATH Error compiling for board AI Thinker ESP32-CAM.' in Arduino IDE 1.8.12

texts:
I am trying to upload a sketch to the ESP32-CAM board using Arduino IDE 1.8.12 and I get an error message:

exec: "python": executable file not found in $PATH
Error compiling for board AI Thinker ESP32-CAM.

My OS is Ubuntu 18.04.4.LTS.

When I type python in the console, it does open python:

$ python
Python 2.7.17 (default, Nov  7 2019, 10:07:09)
[GCC 7.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
KeyboardInterrupt
>>>

Also python is in one of the directories referenced by PATH:

$ which python
/usr/bin/python
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

I added an additional URL referring to the ESP32 boards on the Espressif website:

Arduino IDE > File > Preferences > Settings > Additional Boards Manager URLs: > https://dl.espressif.com/dl/package_esp32_index.json

Then I added the libraries for all ESP32 boards:

Arduino IDE > Tools > Board > Boards Manager > esp32 version 1.0.4

(I tried with version 1.0.3 and it didn't change anything...)

I selected my board in the interface:

Arduino IDE > Tools > Board > AI Tinker ESP32-CAM

I granted all permissions to the USB port:

sudo chmod a+rwx /dev/ttyUSB0
ls -la /dev/ttyUSB0
crwxrwxrwx 1 root dialout 188, 0 Mar  4 21:25 /dev/ttyUSB0

My sketch is really simple:

void setup() {
}

void loop() {
}

I get the same error for any example sketch and for any ESP32 board.

Any idea how this could be fixed ?


texts: How to create a log file document which is not editable by a word processor on SD card

texts:
I'm using a Arduino Mega 2560  and SD card shield to make an industrial logging panel. Is there any way to write log data document in a read-only type file like a pdf on SD card so that the contents cannot be edited once created by word processing software? The data has to presented as a document on a windows machine.

Thanks in advance for your time – if I’ve missed out anything, over- or under-emphasized a specific point let me know in the comments.


texts:
I would like to pass a formatted string to a method that accepts a __FlashStringHelper. Here is the method signature:
void myMethod(const __FlashStringHelper *str);

I have been using snprintf to format my string:
char cmd[30];
snprintf(cmd, 30, "There are %d seconds in a minute", 60);
myMethod(F(&cmd[0]));

Clearly the above doesn't work but how can I format a Flash String?
EDIT: I need to include an integer variable in my flash string. In the example above, '60' is a variable.
uint8_t nSeconds = 60;
char cmd[30];
snprintf(cmd, 30, "There are %d seconds in a minute", nSeconds);
myMethod(F(&cmd[0]));


texts: Looking for circuit diagram for evaluation of a pulsed signal

texts:
How can I evaluate a pulsed signal in Arduino? The signal comes from an car alarm system and is called (-) output 200 mA. Arduino and the car have the same GND. Can I attach the output through a resistor to PB0 (D8) or PD5 (D5)?
Alarm system is called Ampire. Probably the same as Viper. I just wanted to read these pulses, but I do not know exactly how I connect this output correctly with Arduino.
This is the description for this Output:

HN1/9 BROWN/WHITE – 200mA (-) Horn honk output: This wire supplies a 200mA (-) output that can be used to honk the vehicle’s horn. It provides a pulsed output when the security system is armed/disarmed and in trigger sequence or in panic mode. In most vehicles with (-) horn circuits this wire can control the vehicle’s horn without adding a relay. If the vehicle has a (+) horn circuit, an optional relay must be used to interface with the vehicle’s horn circuit.


texts:
I have a Arduino UNO with a Ethernet shield which hosts a basic HTML page with a button on it which controls a Relay module.

I'm trying to connect to a computer's power button so I can turn it on remotely.

I have found out that the relay basically does the opposite to the digital pin's output

Normally open Relay
HIGH = Open
LOW = Closed

I connected it through a NOT Gate made using a NPN transistor and it works perfectly how I wanted it.

Now to the question... Is there a way to write the code to make the digital pin = HIGH straight away and fast enough to not allow the relay to close the circuit and accidentally turn the computer on/off when the Arduino restarts, so I don't have to use a NOT Gate.


texts: Using Waveshare Raspberry Pi TFT LCD with Arduino Uno

texts:
I have a 3.5 inch Waveshare Raspberry Pi TFT LCD which uses the XPT2046 Touch Controller. I want to use this LCD screen with my Arduino Uno.

I originally believed something like this was impossible, but then I found out that the XPT2046 Touch Controller is compatible with the Arduino, and a large number of libraries for the same exist. However, I'm not really very sure whether I can use this with my Arduino; the design of the screen I have is slightly different from the ones I've found online, which are supposed to be compatible with an Arduino Uno.

Is it possible for me to use this screen with my Arduino Uno? If so, what would the wiring schematics look like, and would I be able to use libraries like URTouch?


texts: Any way to include the text of a file inside a sketch, to make it shorter and neater?

texts:
I'm wondering if there is any way to include the text of a file into a sketch by using a single placeholder command, similar to the "#Include" command when using Server Side Includes on .shtml files.

I'm sorry if I'm not wording this correctly. It was hard for me to phrase it and also hard for me to search about it, since the nouns seem so generic.

I understand that some parts of code can be separated out into their own functions, and that those functions could be saved in a different .ino file. But I'm wondering about for the cases that can't be separated out into functions (like for declarations at the beginning of a sketch, or an area in loop() that would require too many variables to be passed to the function).

EDIT: I think I should've been more specific:
In one example, I have lots of html code being served from the loop() function. The Arduino webserver is serving a complex page that shows about 100 buttons on the webpage. I would like to separate the page-serving code to a separate .ino file and have it opened as a separate tab in the Arduino IDE. That way it's easy for me to open that tab whenever I want to modify the webpage, but also the code for serving the page won't take up so much space in my main file. The code isn't completely html (it has lots of functions and conditionals), so that's why I can't just save it as an external .html file and have it served from that file.

As another example: At the top of my sketch I have lots of defines for wireless signals that need to be sent. They look like this:

const unsigned long a1o = 4216115, a1c = 4216124, a2o = 4216259, a2c = 4216268, a3o = 4216579, a3c = 4216588, a4o = 4218115, a4c = 4218124, a5o = 4224259, a5c = 4224268; //remote control 1

There are 10 lines of code that look like that, and I never have to modify them because they're all constants. When I'm searching for bugs in my code, I never have to refer to those lines, and they're usually just in my way.


texts:
I am working on a project that needs to drive a relay board. I'm looking at the ETHERNET board with PoE and according to the documentation here (http://arduino.cc/en/Main/ArduinoBoardEthernet) the output of the PoE module is 9V.

Is that the voltage to expect out of the Vin pin?

The Relay board that I want to use (http://numato.com/downloads/dl/file/id/29/product/47/user_manual.pdf) specifies that it wants a 7-12V power supply.

I want to confirm that this is the case so I can use the voltage out of the PoE and I don't need to add a separate DC power supply to this system.


texts: My arduino pro micro started behaving weird. I noticed it had crashed with very simple code on it (basically just two lines of fastled code followed by a delay. Then it didn't appear as a USB device on my macbook anymore. I reset it (pulling the rst pin to gnd) and that then allowed me to upload smaller sketches but not bigger ones. The smaller sketch only works for a short period of time. then the arduino just stalls. (Serial output also stops). Any idea what i can do? Or do i just have to toss the board and get myself a new one?


texts:
I am a beginner in Arduino. Below is my code to propel the fans of my motor. This happens in a clockwise direction but I wish to change the direction of rotation.

How can I modify it?

// Declare the pin for the motor
int motorPin = 9;

void setup() {
  // Define pin #9 as output
  pinMode(motorPin, OUTPUT);
}

void loop() {
  // Turn motor on
  digitalWrite(motorPin, HIGH);
  // Wait 250 ms
  delay(250);
  // Reanimate motor
  digitalWrite(motorPin, HIGH);
  // Wait 250 ms
  delay(250);
  // Turn motor off.
}


texts: Button and switch to turn on and off LED and changing after time

texts:
I have system connected to an Arduino Uno where I want to read whether the switch is open or closed.

Based on if the switch is open/closed, I want an LED light to turn on/off.  When the switch is open, the LED turns on and pushing the button turns it off and stays off for 24 hours then turns back on if the switch is still open and I can again turn off the light with one push of the button.  However, if the switch is closed within the 24 hours, the light doesn't turn on and pushing the button does not do anything.

I don't know how to change the state of the LED back on after the 24 hours.  Should I use a button counter, if statements, or while statements?  I'm really new to coding and took on a large project I'm not sure how to complete. This is obviously a very small portion of the project.  Any help is much appreciated.

This is as far as I've gotten.  When the switch is open the LED turns on, but when I push the button, the light just dims.  I also have to hold the button down to keep the light "off" and it turns right back on when I release the button.

if (digitalRead(switch) == LOW) {
digitalWrite(Light, HIGH );

if (digitalRead(Button) == LOW) {
    digitalWrite(Light, LOW);
}

else if (digitalRead(switch) == HIGH) {
  digitalWrite(Light, LOW );

}
}


texts: Servo motor rotates back to 0 after reaching destination

texts:
I am using a XMG-996R servo motor. It is controlled by and Arduino Uno board. The problem is when I tell it to go to a certain angle, it will rotate to the desired position but then return to 0. The motor keeps rotating back and forth between the destination and 0 degrees. I tried this with different servos and they all do the same.

I am using 3 AA batteries as an external power supply. I have also tried using 4 AA batteries or a 9V battery. The same thing happens no matter the power supply.

My control wire is connected to the Arduino, positive is connected to the external power source. The negative is connected to the ground of the power source and the ground of the Arduino.

This is my code:

include <Servo.h>

Servo servo;

void setup(){
   servo.attach(9);
   servo.write(90);
}

void loop(){

}

I have also tried putting the write() into loop as well as putting servo.write() before servo.attach(). neither of these methods made a difference.

What can I do to make the servo rotate to the given degree and stay at that degree? Thanks.


texts: I want to know how to record and play radio waves?

texts: I want to make a universal remote.I have an ir receiver and transmiter. I.I can use it to control my tv and other equipment.I want to also control my dish network in the US. I checked and think that the dish uses 395mhz but i am not sure.How can i replicate a dish remote radio signal.I know it is radio signal and not ir. What part do I need for the arduino?


texts: How can I get my (Arduino) Pro Micro schematic to allow me to program it through GPIO instead of USB

texts:
I'm trying this project so far I've got the schematic of a Pro Micro, which is powered through GPIO from a Raspberry Pi Zero, and want to remove the micro usb connection and able to flash it using an avr programer and a few pins.

How do I get to Achieve that? also the Pro Micro is getting D+/D- from the the raspberry's D+/D- pads as well. Schematic below for reference.


texts:
I would like to know if the Wire Library is using a Hardware Timer from the Arduino Mega 2560. And If so which Timer it is.
As I am using the Timer 1. After implementing the Wire Library I have some strange things happening that are probably due to the Timer.
Thanks a lot.


texts: ttyACM0 no such file or directory On Ubunutu 14.04

texts:
I have an Arduino Uno which communicated with the computer (Ubunutu 14.04) fine till 6 days ago (I assume some software update is to blame).

Now when trying to upload I get

processing.app.SerialNotFoundException: Serial port '/dev/ttyACM0' not found. Did you select the right one from the Tools > Serial Port menu?   at processing.app.Serial.(Serial.java:191)    at processing.app.Serial.(Serial.java:77)     at processing.app.debug.Uploader.flushSerialBuffer(Uploader.java:77)    at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:175)   at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67)     at processing.app.Sketch.upload(Sketch.java:1671)   at processing.app.Sketch.exportApplet(Sketch.java:1627)     at processing.app.Sketch.exportApplet(Sketch.java:1599)     at processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)     at java.lang.Thread.run(Thread.java:745)

When I sudo ls /dev/ttyA*

I get

ls: cannot access /dev/ttyA*: No such file or directory

So it does not look like a permission issue.

when I lsusb

I get

Bus 001 Device 002: ID 8087:8000 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 003: ID 04f2:b39a Chicony Electronics Co., Ltd
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

So it does not even see the device (which is connected and pulling current).

when I dmesg before and after connecting the Arduino, I don't see anything new.

I tried switching USB cables, and switching USB ports on the machine (both ports work with a mouse), but in vain.

What went wrong and how do I fix it ?

Thanks,
David.


texts: What are the consequences of different clock speeds on different boards?

texts:
I am a programming amateur, arduino noob, trying to decide which board will be better for my project. I need a small board. I am trying to decide between the Teensy 3.2 and the RFduino. I want to have blue-tooth capability for over air routine changes to a WS2812B LED strip, which makes the RFduino attractive because of its integrated BLE4.0 antenna. However, I want to be able to have enough speed for imperceptible LED modulation, which makes the 72MHz speed of the Teensy attractive.

What would be the objective difference between the 16MHz processor on the RFduino versus the 72MHz on the Teensy3.2? Is this something I should be concerned with?


texts: Double Speed Operation for USART on Arduino Mega 2560

texts:
I happened to be looking through the HardwareSerial.cpp file that contains the functions used for Serial communication for Arduino.  While looking through the HardwareSerial::begin(baud, config) function, I noticed that the ucsra register has its U2X0 bit set.  When I looked through the datasheet, it says that the U2X0 bit is set to start Double Speed Operation.  From what I'm reading, this means that the baud rate is doubled.
I've been using this Arduino on this computer for a while now with no complaints for the baud rate being at an incorrect speed. What is Double Speed Operation?  Why does it seem to be set in the code by default? I attached the code and section in the manual below.

void HardwareSerial::begin(unsigned long baud, byte config)
{
  // Try u2x mode first
  uint16_t baud_setting = (F_CPU / 4 / baud - 1) / 2;
  *_ucsra = 1 << U2X0;

  // hardcoded exception for 57600 for compatibility with the bootloader
  // shipped with the Duemilanove and previous boards and the firmware
  // on the 8U2 on the Uno and Mega 2560. Also, The baud_setting cannot
  // be > 4095, so switch back to non-u2x mode if the baud rate is too
  // low.
  if (((F_CPU == 16000000UL) && (baud == 57600)) || (baud_setting >4095))
  {
    *_ucsra = 0;
    baud_setting = (F_CPU / 8 / baud - 1) / 2;
  }

  // assign the baud_setting, a.k.a. ubrr (USART Baud Rate Register)
  *_ubrrh = baud_setting >> 8;
  *_ubrrl = baud_setting;

  _written = false;

  //set the data bits, parity, and stop bits
  #if defined(__AVR_ATmega8__)
    config |= 0x80; // select UCSRC register (shared with UBRRH)
  #endif
  *_ucsrc = config;

  sbi(*_ucsrb, RXEN0);
  sbi(*_ucsrb, TXEN0);
  sbi(*_ucsrb, RXCIE0);
  cbi(*_ucsrb, UDRIE0);
}


texts:
I'm working with MPU-6050 with Arduino Uno.

I copied the code below from Arduino Playground - MPU6050.

Code :

  // MPU-6050 Short Example Sketch
  // By Arduino User JohnChi
  // August 17, 2014
  // Public Domain
  #include<Wire.h>
  const int MPU_addr = 0x68; // I2C address of the MPU-6050
  int16_t AcX, AcY, AcZ, Tmp, GyX, GyY, GyZ;
  void setup() {
    Wire.begin();
    Wire.beginTransmission(MPU_addr);
    Wire.write(0x6B);  // PWR_MGMT_1 register
    Wire.write(0);     // set to zero (wakes up the MPU-6050)
    Wire.endTransmission(true);
    Serial.begin(9600);
  }
  void loop() {
    Wire.beginTransmission(MPU_addr);
    Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
    Wire.endTransmission(false);
    Wire.requestFrom(MPU_addr, 14, true); // request a total of 14 registers
    AcX = Wire.read() << 8 | Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
    AcY = Wire.read() << 8 | Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
    AcZ = Wire.read() << 8 | Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
    Tmp = Wire.read() << 8 | Wire.read(); // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
    GyX = Wire.read() << 8 | Wire.read(); // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
    GyY = Wire.read() << 8 | Wire.read(); // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
    GyZ = Wire.read() << 8 | Wire.read(); // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
    Serial.print("AcX = "); Serial.print(AcX);
    Serial.print(" | AcY = "); Serial.print(AcY);
    Serial.print(" | AcZ = "); Serial.print(AcZ);
    Serial.print(" | Tmp = "); Serial.print(Tmp / 340.00 + 36.53); //equation for temperature in degrees C from datasheet
    Serial.print(" | GyX = "); Serial.print(GyX);
    Serial.print(" | GyY = "); Serial.print(GyY);
    Serial.print(" | GyZ = "); Serial.println(GyZ);
    delay(333);
  }

Firstly, I want to know every details about this code, AcX, AcY, AcZ, GyX, GyY, GyZ what all these mean ?

It will be nice with some visual representation.

Secondly, If I change the delay to 500 from 333, will it cause a problem ?

This type of stupid question because, I can't find any relatable figure with 333 except 1000/3


texts: How does code typed in Arduino IDE runs on a nodemcu?

texts:
I actually have a series of questions regarding Nodemcu and esp8266.

How does code typed in Arduino IDE run on Nodemcu?
What firmware is present on the nodemcu?
How do I upload the above firmware on esp8266-01 module?
I want my esp8266-01 module to work with a Lilypad Arduino. So this is the way I want it to work: Lilypad Ardiuno has acquires some data using a sensor. It wants to post this data to a server on internet. So to do the job it uses a ESP8266-01. Will the configuration work?


texts:
I am new to Arduino. I'm making a line-following bot. I need to power my L293D module. I know that I can supply 9/12V directly with a battery but I am not sure whether I can supply 5V directly from the 5V pin of the Arduino or I have to use something like an IC 7805.

I am confused because I read that the L293D can cause currents up to 600 mA but the max current for an Arduino Uno pin is only 50mA. This question might seem too novice but it would be of great help if someone could explain me about this or the concept in general.

Thanks in advance.


texts: How to blink the LED forever when detect an object is more than 30 cm away using ultrasonic sensor

texts:
I would like to make an alarm system using ultrasonic sensor.

My aim is to blink an LED for ever once ultrasonic sensor detect an object is more than 30 cm away.

But the problem is that my code some time fail to detect object accurate distance and even LED blinks but when ultrasonic sensor off LED becomes off.

I am using timer to on the ultrasonic sensor for 2 minutes (timer code not attached) so within that period if it detect an object is more than 30 cm away it blinks the LED till the power is cut.

int echoPin = 10; // pin 10 for the echo

int trigPin = 9; // pin 9 for trigger
int duration, inches, cm; // Establish variables for duration of the ping, and the distance result
#include <NewPing.h> // Library for improved ultrasonic sensor readings

#include <SoftwareSerial.h>

NewPing sonar(trigPin, echoPin,30); // sets up the sonar function and limits distance to 30 cm

int ledpin=7;
// Variables will change:
int ledState = LOW;             // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;        // will store last time LED was updated

// constants won't change:
const long interval = 250;           // interval at which to blink (milliseconds

void setup() {
    pinMode(ledpin,OUTPUT);
    Serial.begin(9600); //sets up serial monitor
}

void loop() {

    delay(50);

    Serial.print("Ping: ");
    Serial.print(sonar.ping_cm());
    Serial.println("cm");

    //warning
    Serial.println("cm");

    //warning
    if(sonar.ping_cm()>=30)
    {
      unsigned long currentMillis = millis();

      if (currentMillis - previousMillis >= interval) {
        // save the last time you blinked the LED
        previousMillis = currentMillis;

        // if the LED is off turn it on and vice-versa:
        if (ledState == LOW) {
          ledState = HIGH;
        } else {
          ledState = LOW;
        }

        // set the LED with the ledState of the variable:
        digitalWrite(ledpin, ledState);
      }

    }
}


texts: do i need an I/O shield for quadcopter motors

texts: I would like to know if I need an I/O shield for the 4 ESC's on a Quadcopter I am building using Arduino Mega2560.  The current to the ESC's should come from the battery itself and the data from the board so my first thought is that it is not needed however I wanted to be sure.


texts: Why does my LCD screen display white rectangles?

texts: I recently got an Arduino LCD screen. I tried connecting it to the UNO with the 10k potentiometer and all the needed equipment but all I got were white rectangles instead of characters. I have uploaded the hello world code but I saw no changes.


texts: How to read response from server using an Ethernet shield?

texts:
I want to control a relay by reading values from MySQL. I'm using an Arduino and an Ethernet shield. So far, I can get the response from server and get the value. I just need the value 10110110, but I get a response in the serial monitor like this:

HTTP/1.1 200 OK
Date: Sun, 02 Jul 2017 07:53:29 GMT
Server: Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
X-Powered-By: PHP/5.3.1
Content-Length: 13
Content-Type: text/html

<10110110>

How to remove this long response and get the value 10110110?


texts:
For a physical activity monitoring project, I am developing a prototype based on an Arduino Due and several IMUs (BNO055 from Bosch).

I have to collect the data from the sensors simultaneously (3 for the moment). I want to use a Serial connection (Since the Arduino Due has 4 hardware serial ports).

Here comes the first issue : I use the shuttleboard BNO0055, and because of my limited knowledge, I'm not sure I did the right wiring. As I understood in the datasheets, the PS0 pin must be connected to the GND and PS1 to the incoming voltage. The COM0 to the RX of the Arduino and COM1 to TX. I am confused by the documentation, I can't figure out which pin of the shuttleboard are the COM0 and COM1. (I can't post the pictures of my wiring since it's my first post here).
And now there is a second problem: If the wiring is good, how can I communicate with the sensor to get the Euler angles? The BNO055 sensor does the fusion data itself, and gives the quaternions or the Euler angle. Bosch provides a library. I have never used a library, and I don't know the syntax to ask the sensor to give the Euler angles. Can someone give me a code to do this? Or at least explanations on the syntax I should use?


texts: unable to read RS232 output on Arduino mega with MAX232 shield

texts:
I am trying to read data from an RS232 equipped sensor using a serial monitor connected to an Arduino Mega with RS-232 shield but I do not receive any data.

I am unable to detect the exact cause of the problem, as it only occurs when combining sensor and RS232shield/Arduino, while communication works as expected when testing them separately

What works:

Connecting the sensor to a computer with a RS232-USB converter cable.
Passing data from the computer through the USB-RS232 converter cable to RS232 shield and back through Arduino USB output.
Connecting the RS232-pin 2 to port 10 using {SoftwareSerial} library with inverted logic.

What does not work:

Passing data from the sensor to the computer via the MAX232 and Arduino.

The setup:

Arduino Mega 2560
Seeed RS232 shield (MAX232 based)
Sensor with RS232 output (57600 8N1)

I have connected the RS232 output of the sensor to the shield using an M-M gender changer. The shield and Arduino are connected with three wires: GND-GND , 5V-5V, 232_TX-RX1), and the Arduino connects to a Macbook via USB. The serial monitor on the computer is set to 56700 baud.

I use the following sketch to transfer data from the RS232 shield to Serial:

void setup()
{
// Open serial communications at 5700 baud
    Serial.begin(57600);
    Serial1.begin(57600);

// Check whether Serial1 is active
if (Serial1.available())
     while (!Serial1) {
        ;
    }
    Serial.println("Serial 1 is active");
}

void loop()
{
    if (Serial1.available()){
    Serial.write(Serial1.read());
    }

}


texts: Cannot detect Bluetooth device when connected to female receiver with PS4 Joystick

texts:
I am trying to connect the Bluetooth transmitter to a female receiver via an Arduino Uno. The button blinks, but the Bluetooth is not visible in any device.
i want to connect PS4 controller using HC05
I am sharing my code below:
#include<SoftwareSerial.h>

/* Create object named bt of the class SoftwareSerial */
SoftwareSerial bt(2,3); /* (Rx,Tx) */

void setup() {
  bt.begin(9600); /* Define baud rate for software serial communication */
  Serial.begin(9600); /* Define baud rate for serial communication */
}

void loop() {
  if (bt.available()) { /* If data is available on serial port */
    Serial.write(bt.read()); /* Print character received on to the serial monitor */
  }
}

Can anyone help me out with this ?


texts: Arduino web server-how to get values form URL

texts:
I’ve already searched through the internet but cannot find satisfactory answer.
Is there an easy way to get value of variable passed through an URL?
What I mean is I want to start a web server on my Arduino then call the URL like 10.0.0.1/?var1=x&var2=y from my browser and read var1 and var2 to my program.
I could also use JSON format but how to send it to my Arduino and then read it?
I use Arduino Ethernet Shield W5100.
Any ideas?


texts: Is there any way I can turn off the 5V pin?

texts:
I'm trying to find a way I can toggle the 5V pin to turn on/off. I want the voltage to pass to another wire at a certain point. It should be off and then when something happens, the 5V should turn on.

How can I do this?


texts: Why the command noDisplay() clear all LCD screen?

texts:
i want to preserve video information for long time without communicating with arduino on lcd 1602, i'm tryng to use the command of liquidCrystal library noDisplay() but when i use it,this clear all display. On arduino website here is the description of this command "Turns off the LCD display, without losing the text currently shown on it." but i lose all on screen. Thanks for reply

there is my test code

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // Turn off the display:
  lcd.noDisplay();
  delay(500);
  // Turn on the display:
  lcd.display();
  delay(500);
}

with this code display blinking and don't show continuos "hello word".


texts: Using TMRpcm library, the audio does not play

texts:
I'm using the https://github.com/TMRh20/TMRpcm/wiki library to play wav files from an SD card to a speaker I have attached to my Arduino.

I have run separate tests/programs that ensures:

my speaker is connected properly and can play sound
my SD file is connected properly as it can read and files, text files.

However, I'm trying to use the tmrpcm.play("example.wav") command and nothing is happening. I used wav files that for sure works (from a demo I found online) so it's not the wav file problem.

Anyone have any clue on what is going on and how I can fix this?


texts: Please explain the void loop() section of the sketch

texts:
#include <VirtualWire.h>

int PWMB = 5; //Speed control

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

  //receiver setup
  vw_set_rx_pin(2);
  vw_set_ptt_inverted(true);
  vw_setup(2000);
  vw_rx_start();
}

void loop(){
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
  if (vw_get_message(buf, &buflen)) // Non-blocking
  {
    int i;
    int column = 0;
    String message;
    int commands[30];

    for (i = 0; i < buflen; i++)
    {
      //DEBUG:
      Serial.print(char(buf[i]));

      if(char(buf[i]) == '|'){
        commands[column] = message.toInt();
        message = "";
        column++;
      } else {
        message += char(buf[i]);
      }
    }

  commands[column] = message.toInt();
  }
}

This topic is the receiver side of my last topic: please explain the sketch attached
that one sending date and this is a receiver.

questions:

The transmitter transfer date array of [60] like: 523 | 487, here int commands[30]; just 30, is it OK?
if(char(buf[i]) == '|') / commands[column] = message.toInt();, seems just convert the date before '|'?
What is the result of message += char(buf[i]);?

Thanks


texts: problem with communication between Linux and microcontroller

texts:
Hello Arduino community,

I am new to the Arduino community and would like to ask for help (I work on a Arduino TIAN). Indeed, since 2 3 weeks I try through simple programs to understand the operation of Arduino programming (I am a student).
I am currently in the planning phase and I am in charge of debugging a number of issues (to make the old alumni programs of other promotions work for the continuity of the project). Unfortunately, it's been a while since I have a problem: my program works well but after 2 3 hours of operation it stops working and I do not receive the data. So I think the problem comes from the communication between Linux and microcontroller (with something like an overflow?). So I put here the 2 parts of my program intended precisely for this communication.
In the hope of having an answer in help.
Thanks.

Part 1 (main): void loop() {
CiaoData data = Ciao.read("restserver");
if(!data.isEmpty()){
    String id = data.get(0);
    String sender = data.get(1);
    String message = data.get(2);
    message.toUpperCase();
    execute(message,id);
}
yield(); } void execute(String cmd, String id) {
lvd.setup(cmd);
Ciao.writeResponse("restserver",id, td.toString());

}

Part 2 :

void CiaoRead() {
CiaoData data = Ciao.read("restserver");
if(!data.isEmpty())
{
    String id = data.get(0);
    String sender = data.get(1);
    String message = data.get(2);
    //message.toUpperCase();

    splitString(message,"=",LtT,62);

    beep         =LtT[0].toInt(); LtT[0]="";
    gen          =LtT[18].toInt(); LtT[18]="";
  } } void CiaoReadWrite() {
CiaoData data = Ciao.read("restserver");
if(!data.isEmpty())
{
    String id = data.get(0);
    String sender = data.get(1);
    String message = data.get(2);
    //message.toUpperCase();

//I have added the line  « Ciao.writeResponse("restserver",id,... » but I dont put it here because it to long and the problem come not from here I think.


texts: How to program a BSFrance LoRA32u4 from Arduine IDE 8.5?

texts:
I've bought a BSFrance LoRA32u4 from DIYmall on eBay UK.

https://bsfrance.fr/lora-long-range/1311-BSFrance-LoRa32u4-1KM-Long-Range-Board-Based-Atmega32u4-433MHz-LoRA-RA02-Module.html

I've copied the "bsfrance" directory (from the ZIP) into Arduino/hardware (on 64-bit Ubuntu 16.04).

Staring the Arduino IDE, I've selected the correct board (Tools>>Board>>BSFrance>>LoRA32u4).

I've selected the correct port Tools>>Port>>/dev/ttyACM1 (LoRA32u4).

Verifying a trivial sketch looks fine:

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

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

Result:

Sketch uses 4104 bytes (14%) of program storage space. Maximum is 28672 bytes.
Global variables use 149 bytes of dynamic memory.

The USB device appears in lsusb as: Bus 002 Device 077: ID 239a:800c.

Clicking install causes a white LED to flicker for around ten seconds, but results in:

avrdude: error: buffered memory access not supported. Maybe it isn't
a butterfly/AVR109 but a AVR910 device?
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

or:

Couldn't find a Board on the selected port. Check that you have the
correct port selected.  If it is correct, try pressing the board's reset
button after initiating the upload.

or:

Found programmer: Id = "CATERIN"; type =

or:

Device code: 0x0d

or:

.   Software Version = 1.0; Hardware Version =

or:

An error occurred while uploading the sketch

How do I transfer code onto this board?

(I am new to Arduino, so I may be missing something obvious.  I do have lots of experience programming vanilla ATMEGAs in C without the Arduino IDE.)

--

I have an AVRISP mkII - would burning a new boot-loader help, or just wreck the USB-serial on the device?


texts: How should you predict the battery size required for a project?

texts:
I am using an Arduino nano along with an ESP8266.  The nano is connected to an OLED display and a keypad. The ESP8266 uploads the data entered from the keypad onto a server. I wish to make the device portable; i.e. add a battery to it so that it can last for at least 8 hours.

How can I calculate the rating for the LiPo battery to use? I understand that it is very important to know the current rating of the devices in use.

How can I make an approximate guess?


texts: How can I send data to many IC's without using tons of shift registers?

texts:
I'm building an audio circuit that will play VGM files (Video Game Music).

I have it working with two different "vintage" IC's such as the SN76489 and the AY-3-8912.

Currently, my design is using an Arduino Micro and two shift registers for the data buses and direct pins for the control pins on the audio IC's.

On average, an audio IC has 8 pins for the data bus and 4 pins for the control or address bus.  This varies per IC.  Some might be 3, some 4, some 6, etc.

Bottom line, even with the 20 IO pins on the Arduino, I will quickly run out of pins.  I thought about serializing many shift registers and basically pass 64 or 128 bit numbers to spread out to the multiple IC's but this sounds ugly.

I'd like to be able to support maybe 6 IC's which could be 60-80 pins.

I also have an Arduino DUE which has many more IO pins.  But then I have to deal with the 3.3v limit and I only have 4 level shifters (16 pins).

Any suggestions on how to handle this?

Thanks.


texts:
I am interested in calculating the amp/hour output of a solar panel using an Arduino. I am confident I can get the voltage (with a voltage divider) & the amperage (with an ACS712). My question is about the math of calculating Amp*hour.

Here is my plan:

My plan is to pull the voltage and amperage every second.
I would then add this amp*second value to a variable. I would also increment another variable for each second.
I would then be able to get an average or total of Ampseconds from these 2 variables. I could also divide the ampsecond by 3600 if I wanted Amp*Hour.

Is it too much a stretch to poll the amperage every second and call it amp/second? How can I make this more accurate?


texts: Does not name a type error when using makeTime

texts:
I am getting a "does not name a type" error when trying to use makeTime() from the Time.h library, code snippet as follows:

#include<Time.h>

tmElements_t tmet;
tmet.Year = 2013-1970;
tmet.Month = 8;
tmet.Day = 28;
tmet.Hour = 18;
tmet.Minute = 30;
tmet.Second = 0;

time_t dateMet = makeTime(tmet);

Alternatively I've also tried time_t dateMet = maketime(&tmet); with the same result. I am no expert so go easy on me but am I missing something small here?

Thanks


texts:
I'm going to use this for Arduino Pro Mini (5v version) to communicate with ESP32 via UART so I need level shifting. I found this circuit which uses NPN transistor and I'm also going to use it. This is the circuit I'm going to use...

simulate this circuit – Schematic created using CircuitLab

Are the resistors' value appropriate or do I have to change the collector resistor?


texts: Multiplication operator with or without braces

texts:
I have written a simple calculator program for an LCD keypad shield. It works fine except for the multiplication case. It gives me zero. However, I have noticed that when I enclose the expression num1 * num2 in parenthesis it does work. Why is that so?

#include <LiquidCrystal.h>

LiquidCrystal lcd (8, 9, 4, 5, 6, 7);

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

void loop() {

  float ans = 0;

  lcd.print("Starting Calc");
  delay(500);

  lcd.clear();
  lcd.print("Enter 1st Num");
  while (Serial.available() == 0) {}
  float num1 = Serial.parseFloat();

  lcd.clear();
  lcd.print("Enter 2nd Num");
  while (Serial.available () == 0) {}
  float num2 = Serial.parseFloat();

  lcd.clear();
  lcd.print("Enter Operator");
  lcd.setCursor(0, 1);
  lcd.print(" R+, U*, D/, L- ");
  int val = analogRead(A0);

  while (val > 1000) {
    val = analogRead(A0);
  }

  if (val == 0) { // addition
    ans = num1 + num2;
  }

  if (val >= 97 && val <= 98) { // multiplication
    ans = num1 * num2;
  }

  if (val >= 253 && val <= 254) { // division
    ans = num1 / num2;
  }

  if (val >= 407 && val <= 408) { // subtraction
    ans = num1 - num2;
  }

    lcd.clear();
    lcd.print("Answer is = ");
    lcd.print(ans);
    delay(2000);
}

Modified Code

#include <LiquidCrystal.h>

LiquidCrystal lcd (8, 9, 4, 5, 6, 7);

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

void loop() {

  float ans = 0.0;

  lcd.print("Starting Calc");
  delay(500);

  lcd.clear();
  lcd.print("Enter 1st Num");
  while (Serial.available() == 0) {}
  float num1 = Serial.parseFloat();

  lcd.clear();
  lcd.print("Enter 2nd Num");
  while (Serial.available () == 0) {}
  float num2 = Serial.parseFloat();

  lcd.clear();
  lcd.print("Enter Operator");
  lcd.setCursor(0, 1);
  lcd.print(" R+, U*, D/, L- ");

  // here we split our logic.. first repeatedly read input value until valid operator read
  // secondly we perform the arithmetic operation accordingly

  char input = ' '; // space = no operator read so far
  int val;

  do {
    val = analogRead(A0);
    // see how if statements are written concisely for readability
    // if only one statement after condition you can skip curly brackets
    if (val == 0) input = '+';
    if (val >= 97 && val <= 98) input = '*';
    if (val >= 253 && val <= 254) input = '/';
    if (val >= 407 && val <= 408) input = '-';
  } while (input == ' ');

  Serial.println(input);
  Serial.println(num1);
  Serial.println(num2);
  delay(1000);

  // perform arithmetic operation
    switch (val) { // not written in a standard way but very readable
      case '+': ans = num1 + num2; break;
      case '-': ans = num1 - num2; break;
      case '*': ans = num1 * num2; break;
      case '/': ans = num1 / num2; break;
    }

  lcd.clear();
  lcd.print("Answer = ");
  lcd.print(ans);
  delay(2000);
}


texts: What is the best serial protocol for bidirectional communication with NodeMCU?

texts:
Except hardware UART. Main requirements are reliability and simplicity of use. Speed isn't as important.

Details:

I have an Arduino Pro Mini (ATmega328P 5V) controlled via UART.
I wish to connect an ESP8266 with stripped-down NodeMCU to offer a web interface for the same functionalities, sending <=122 character strings to Arduino and possibly getting a short response.
I do not want to use Arduino for processing the interface (too little memory) or use the ESP only (need a stable clock and multiple analog inputs).

My research shows that:

ESP8266 has obvious timing issues, having been designed for a different purpose.
Controlling the ESP8266 from Arduino via hardware serial works fine, but I need it the other way around, too. Also, NodeMCU is rather chatty and I don't know how to suppress it, and I'd rather keep the hardware serial ports for programming.
The same via SoftwareSerial is unreliable
Personal experience shows OneWire works poorly on ESP8266 (though it may have been fixed)

I have no experience with I2C and SPI beyond polling a slave, and don't know about reliability on ESP8266.
The Arduino already works as an I2C master.
I'm assuming I2C is the way to go, but wanted to ask for opinions first.

[EDIT]
Seems I have once again neglected to set up the proper context. The reason I'm asking is that ESP8266 can't do very precise timing, leading to communication problems. Hardware UART to hardware UART is shown to be reliable. For most other protocols, at least one side does bit-banging. I have not done or found extensive reliability tests for those options, and hope instead that the community can offer some insights. Can you?


texts: Accessing configuration registers of OV7670 cam on i2c

texts:
I am a new user of Aurdino and want to interface OV7670 camera with aurdino uno which uses i2c mode of communication.I want to check the configuration of the device control registers and set them as per requirement. In this case, OV7670 is my slave device.
     How can I access a particular register inside the slave device?(The parameters for commands like wire.begin() etc., include slave address but not the address of the registers inside a slave device.)


texts: Running a HC-SR501 PIR Sensor constantly using battery

texts:
I am not sure if this is the correct forum since I tend to use the ESP8266 standalone and not together with the arduino nano.
However, here is what I am planning.

I have a HC-SR501 PIR sensor, which I want to use to constantly track movements of animals outdoor. I dont want to go into further details, but 10 impulses per minute are expected (max. is 30/min) except for the night maybe.
I am planning to count the impulses for one hour, than send the sum to a webserver using wifi and reset the counter.
For powering I want a battery/akku solution (non-negotiable). Since the input of the PIR sensor is 4.8-20V I will directly connect it to the battery (provided the Voltage is high enough like with a 9V battery) and the ESP8266, which is used as WIFI station will be connected via an AMS1117 generating 3.3V.

WIFI Router which is connected to the internet is available and several sensor systems will be used to check several areas. Basic knowledge of using AT cmds or programming with Arduino IDE is given.

Questions:

Can the ESP8266 module count impulses during one of the sleep modes?
Do you have a less current consumpting module in mind allowing wifi transmittance? (LoRa or the NRF Module are not an option atm, since the router has to be used)
What kind of battery/akku would you suggest? Having sufficient voltage and capacity (mAh) and still being easy to handle?

Optimum lifetime for the beginning would be 1 month for the first prototype. Afterwards a SolarModule + Akku solution will be implemented, but the first prototype has to be finished simple and fast yet satisfying :)

kind regards


texts: Comparing a text string to text output (DHT22)

texts:
Lately I've received a DHT22 sensor. I've started to create a small temperature and humidity monitor station. One of the things I noticed was if you pulled out the sensor while in use, it displayed "nan". What I wanted to do was if the variable "temp" (for the temperature) equaled "nan", my LCD would display a message. But I keep getting a scope, conversion, and declaring errors. I've tried every variable and a lot of online forums, documentations, and the official Arduino reference site. My code looks like this:

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

const int rs = 53, en = 51, d4 = 49, d5 = 52, d6 = 48, d7 = 47;

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

#define DHTPIN 27
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

int chk;
float hum;
float temp;

byte bigdot[8] = {
  B00000,
  B00000,
  B00000,
  B01110,
  B01110,
  B01110,
  B00000,
  B00000
};

byte circle[8] = {
  B00110,
  B01001,
  B01001,
  B00110,
  B00000,
  B00000,
  B00000,
  B00000
};

void setup() {
  lcd.createChar(0, bigdot);
  lcd.createChar(1, circle);
  lcd.begin(16, 2);
  dht.begin();
  do {
  lcd.setCursor(5,1);
  lcd.write(byte(2));
  lcd.setCursor(4,0);
  lcd.print("Loading");
  delay(500);
  lcd.clear();
  lcd.setCursor(7,1);
  lcd.write(byte(2));
  lcd.setCursor(4,0);
  lcd.print("Loading");
  delay(500);
  lcd.clear();
  lcd.setCursor(9,1);
  lcd.write(byte(2));
  lcd.setCursor(4,0);
  lcd.print("Loading");
  delay(500);
  lcd.clear();
  dht.readHumidity();
  dht.readTemperature();
  } while (hum > 90 || temp > 50.00);
  Serial.begin(9600);

}

void loop() {
    hum = dht.readHumidity();
    temp = dht.readTemperature();
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Temp: ");
    lcd.print(temp);
    lcd.write(byte(1));
    lcd.print("C");

    lcd.setCursor(0,1);
    lcd.print("RH:   ");
    lcd.print(hum);
    lcd.print("%");

    if (temp == a) {
      lcd.clear();
      lcd.home();
      lcd.print("Whoops! An");
      lcd.setCursor(0,1);
      lcd.print("error occured!");
    };
    Serial.print("Humidity: ");
    Serial.print(hum);
    Serial.print(" %, Temp: ");
    Serial.print(temp);
    Serial.println(" Celsius");
    delay(2000); //Delay 2 sec.
 }

Thanks in advance!


texts:
I have a 20KG Load cell with an HX711 and I am looking to trigger servo movement if the load cell detects a predetermined weight reading.
Is anyone able to please help with the coding for this or point me in the direction of some handy resources, as coding isn't my strongest point?
The way the logic should work is:
**- Servo starts at 0 degrees

If the reading is equal to 3.4 - turn the servo to 180 degrees
If the reading over 3.4 - servo remains at 0 degrees
In the reading is less than 3.4 - servo remains at 0 degrees**

Someone in another forum also did mention it may be worth looking into ranges and hysteresis, but I'm honestly not sure how I would go about implementing those.
I've been able to, however, 'jerry-rig' the following code together
#include "HX711.h"
#include <Servo.h> // Include the Servo library

#define calibration_factor -7050.0 //This value is obtained using the SparkFun_HX711_Calibration sketch

#define LOADCELL_DOUT_PIN  3
#define LOADCELL_SCK_PIN  2
int servoPin = 5; // Declare the Servo pin

HX711 scale;

Servo Servo1; // Create a servo object
float units;

void setup() {
  Serial.begin(9600);
  Serial.println("HX711 scale demo");

  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
  scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
  scale.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0

  Serial.println("Readings:");

  Servo1.attach(servoPin);  // We need to attach the servo to the used pin number
}

void loop() {
  Serial.print("Reading: ");
  Serial.print(scale.get_units(), 1); //scale.get_units() returns a float
  Serial.print(" lbs"); //You can change this to kg but you'll need to refactor the calibration_factor
  Serial.println();

 Serial.print("Reading: ");

 units = scale.get_units(), 10;
     if (units > 3.4)
     {
       Servo1.write(180);
     }
     else
     {
       Servo1.write(0);
       delay(1000);
     }
}

However, I've run into the following 'kinks' with this:

When it hits the target weight (which in this example is 3.4) the
servo keeps moving between 0 and 180 and doesn't hold the 180
positions as intended.

It also still does this when it exceeds the target weight. However,
It is supposed to reset the servo to position 0 in this case.


texts: Debug-logging without using Serial.print and without WiFi

texts: In order to transmit text from the Arduino board to the HC-05 Bluetooth module, I have use Serial.print. However, I don't see a way to debug the code without using Serial.print to test the other features of the software. Is there another way to transmit text from the Arduino to the computer, and from the Arduino to the HC-05, simultaneously (and without WiFi)?


texts: How do I connect a temperature and heartbeat sensor to an Arduino Uno?

texts:
I have been using a temperature sensor and heartbeat sensor separately and I am trying to code for temperature and heartbeat sensors. How do I get its output on the Arduino IDE's Serial Plotter?

Code of temperature sensor:

int val;
int tempPin = 1;

void setup()
{
  Serial.begin(9600);
}
void loop()
{
  val = analogRead(tempPin);
  float mv = ( val / 1024.0) * 5000;
  float cel = mv / 10;
  float farh = (cel * 9) / 5 + 32;

  Serial.print("TEMPRATURE = ");
  Serial.print(cel);
  Serial.print("*C");
  Serial.println();
  delay(1000);

  /* uncomment this to get temperature in farenhite
    Serial.print("TEMPRATURE = ");
    Serial.print(farh);
    Serial.print("*F");
    Serial.println();
  */
}


texts: Why do only specific arduinos support the keyboard and mouse libraries?

texts:
The Arduino website suggests that only three boards are supported for the Mouse and Keyboard library page:

Leonardo
Micro
Due

What is special about those boards, that the other boards in the Arduino family don't have? I thought they might have the same proceesing chip on them but only two of them do. The CPUs are correspondingly:

ATmega32u4
ATmega32u4
Atmel SAM3X8E ARM Cortex-M3

I have Nanos, Unos and Duemilanoves. I am out of luck aren't I?

So my question is: what do those three boards have that lets them support those libraries?


texts: How to achieve active 4G LTE communication?

texts:
I'm not sure if this is correct place to post this, if not PLEASE redirect me to the proper page, as this matter is quite pressing to me.

My entire day was spent researching different methods of inter-Arduino communication, and for my project, using 4G/LTE/LTE-M is clearly the route I need to take. However, I cannot find an answer to my problem:

I see a lot of information about how to continuously upload information to a IoT service/provider, or to a dashboard website. That's great. Problem is, I need an Arduino with a LTE shield to talk to another Arduino with a LTE shield. Suddenly the internet shuts down and I can find next to nothing about communicating between two Arduino's using LTE shields, much less keeping that connection active.

Of course this could be accomplished by uploading data to a IoT site via Arduino A, and retrieving stored information via Arduino B, but I'm afraid that will induce too much latency into my system. I need this to be as FAST as possible.

The module I have my eye set on currently is this one: https://www.cooking-hacks.com/documentation/tutorials/4g-gps-lte-wcdma-hspa-3g-gprs-shield-arduino-raspberry-pi-waspmote-tutorial/#step10

Is there a way to connect directly to another LTE device? How to I keep that connection always active? I know this question is a little broad, but I don't even know where to look! Internet connectivity is not my strong suit. From what I've gathered, I need to set up one Arduino as a server and the other as client. UDP may be the option I'm looking for, but I'm not totally sure. Every single tutorial/explanation I've seen is connecting directly to a webpage or other online service and NOT another LTE device.

Any help or direction is greatly appreciated, thank you!


texts: Can't get constant reading with load cells

texts:
I'm really a newcomer to arduino and I'm trying to build a scale with four SEN-10245 load cells and a HX711. My issue is that I can't get constant readings in the serial monitor and I'm not sure if my coding is right or if I did the right setup.
I made the following setup, based on some examples I found online:

The code I'm using is as follows:

    #include <hx711.h>
    Hx711 scale(A1, A0);
    void setup() {
    Serial.begin(9600);
    }
     void loop() {
     Serial.println(scale.averageValue());
     delay(200);
    }

link for the library github: https://github.com/aguegu/ardulibs/tree/master/hx711

Please help me, i'm a total beginner.


texts: Arduino controlling a heavy solenoid water valve

texts:
So after burning up a couple Arduinos, I'm running out of ideas...

I am trying to power both a Solenoid valve and the Arduino(nano) with the same 12V-2amp power supply. I've tried it with both a relay breakout board, and via transistor switching, and both are giving me sporadic behavior for the Solenoid.

Early failures came from realizing that the solenoid water value was actually a coil (duh), and thus needed some kind of diode placed over its connections, so I'm assuming the back voltage spike is what fried the first two boards.

At first I added a small diode that helped but wasn't enough, so I beefed it up to a 3 amp "rectifier diode" 200PIV, which stopped the board frying.

Here is a link to the solenoid water valve. Not much to go on I'm afraid. 12V 0.02-0.8Mpa.

The behavior that I'm seeing now, is that the solenoid will engage, but it won't disengage.

Do I need to add a Capacitor for the solenoid?  If so, any recommendations on sizing?

int relayPin = 2;

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

void loop()
{
  Serial.println("starting");
  digitalWrite(relayPin, HIGH);
  delay(2000);
  digitalWrite(relayPin, LOW);
  delay(2000);
}


texts: Reading data from airspeed v3 eagle tree

texts:
I am trying to get values from this sensor Airspeed v3 from eagle tree but it seems my I2C is not working properly.

I bought a module in third party mode and followed these instructions from the manufacturer website.

I went to rcgroups forum and discovered the right values for the bits mentioned in the documentation about WRITE and READ.

I started the development of a code but I cannot get the values from the sensor. It is supposed to send me a 2 byte-formatted value indicating the airspeed measured. But surprisingly when I call this method Wire.requestFrom(AIRSPEED_ADDRESS, 2) it returns 0, so someway the communication is not working. I have used I2C before for ADXL345 sensor and it works perfectly.

The results from these lines

Serial.println(data[0]);
Serial.println(data[1]);

are just -1 indicating that no data is available to display.

Does anybody know how to get this working? Am I missing something?

This is my code right now.

#include <Wire.h>

#define AIRSPEED_ADDRESS  0xEA
#define WRITE_BIT         0x00
#define READ_BIT          0x01

void setup() {
  // join I2C bus (I2Cdev library doesn't do this automatically)
  Wire.begin();
  Serial.begin(9600);
  Serial.println("Program started");
}

void loop() {
  byte data[2] = {0};
  int i = 0;
  int16_t velocidade = 0;

  Wire.beginTransmission(AIRSPEED_ADDRESS);
  if (!Wire.write(WRITE_BIT)) {
    Serial.println("error sending write_bit");
  }
  Wire.endTransmission();

  Wire.beginTransmission(AIRSPEED_ADDRESS);
  if (!Wire.write(0x07)) {
    Serial.println("error sending 0x07");
  }
  Wire.endTransmission(false);

  Wire.beginTransmission(AIRSPEED_ADDRESS);
  if (!Wire.write(READ_BIT)) {
    Serial.println("error sending read_bit");
  }
  else {
    //Serial.println("ok sending read_bit");
  }
  Wire.endTransmission();

  Wire.beginTransmission(AIRSPEED_ADDRESS);
  Serial.print("bytes read from slave: ");
  Serial.println(  Wire.requestFrom(AIRSPEED_ADDRESS, 2) );
  data[0] = Wire.read();
  data[1] = Wire.read();
  Wire.endTransmission();

  velocidade = data[1] | (data[0] << 8);
  Serial.println(data[0]);
  Serial.println(data[1]);
  Serial.println(" ");

}


texts: Controlling an LED using a transistor (TL188)

texts:
I wanted to control an LED using a transistor (my first attempt at using a transistor). I connected a transistor (TL188) to pin 13 of an Arduino Uno accidentally and noticed something.

(The resistor I used was 150 ohms, and I forgot to change the resistor value in the diagram.)

The program on the Arduino Uno was the basic Blink sketch. As per the program, the LED on the Arduino Uno was supposed to turn on for 1000 ms and turn off for 1000 ms. But when I connected the LED like the diagram below

For the first 1000 ms delay:

LED on pin 13 stayed on
LED connected using the transistor stayed off

For the next 1000 ms delay:

LED on pin 13 stayed partially on (it was dim)
LED with the transistor was on

I know that the connection that I made is completely wrong. Can someone explain me how and also why the LED on the Arduino Uno was dim?


texts: Can you use a RF remote with nRF24L01 and Arduino?

texts:
I recently bought a 10 pack of RF transceivers (nRF24L01). I wanted to know if its possible to pair one with an RC drone controller. I can't seem to find any ways to do this through google.

If this helps:

My drone and its controller is called "Sky Viper v2400" and a link to where you buy it is: https://www.amazon.com/Sky-Viper-01601-Streaming-Video/dp/B01D1HRXSK.

Thanks


texts: sim808 init error when trying to use DFRobot to get gps

texts:
I'm using "mega 2650 pro" Arduino with SIM808 BK-808 V-3.1 and I connect the vcc for the sim808 to 5volt pin in the arduino, and the arduino connected with laptop usb. and I add a sim to the sim808 module.
I upload the following code:
#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>

#define PIN_TX 14
#define PIN_RX 15
SoftwareSerial mySerial(PIN_TX,PIN_RX);
DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,

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

//******** Initialize sim808 module *************
while(!sim808.init()) {
delay(1000);
Serial.print("Sim808 init error\r\n");
}

//************* Turn on the GPS power************
if( sim808.attachGPS())
Serial.println("Open the GPS power success");
else
Serial.println("Open the GPS power failure");

}

void loop() {
//************** Send the coordinates(latitude&lonitude)in the Serial Monitor *******************
if (sim808.getGPS()) {

Serial.print("latitude :");
Serial.println(sim808.GPSdata.lat);
Serial.print("longitude :");
Serial.println(sim808.GPSdata.lon);

}

}

but the output is
Sim808 init error
and I tried several codes to test AT commands, nothing work!
so what is the problem?


texts: digitalPin giving lower voltage than Vcc

texts:
I am using an ATTINY88 for a project that requires to turn on an LED. Right now I am using pin PA1(ADC7/PCINT25). I noted, however, that when the pin is ON, I get about half the voltage that is connected to Vcc. I checked the voltage in other pins and they are close to Vcc. Will anyone know, what could be the reason for this?

I figure this pin has an internal resistor enable, but I am not certain.


texts: Arduino with 12 bit DAC (MCP4725) Not Working

texts:
I have an Arduino Mega AT2560 and need to have real DAC. I purchased the Sparkfun 12 bit DAC, however I don't think it is working properly.

I am using the Arduino wire library to communicate with the DAC. When I write 0, I am expecting to see 0v from the DAC's OUT pin. However, I see some seemingly random constant voltage. In reverse, when I write 4095 to the DAC I see the same voltage as when I write 0. I expected to see 5v.

Can someone verify that I hooked it up correctly?
Can someone verify the code I am using?

#include <stdint.h>
#include <stdio.h>
#include <Wire.h>

#define MCP4725_ADDR 0x60 // [0000 0110]
/*
* 12 Bit DAC MCP4725 gives a range of 4096 possible values.
*
*/
void setup() {
  Wire.begin();
  Serial.begin(9600);
}

void loop() {
  Wire.beginTransmission(MCP4725_ADDR);
  Wire.write(64);            // cmd to update the DAC [0100 0000]
  Wire.write(4095 >> 4);        // the 8 most significant bits...
  Wire.write((4095 & 15) << 4); // the 4 least significant bits...
  Wire.endTransmission();
}


texts: Can an a Arduino make music or speech without a speaker?

texts:
I have an Arduino Leonardo that can turn a relay off and on and the click is audible on the relay -this is simply done by making one of the control wires HIGH in the program code to turn the relay on and make the same control wire LOW to turn the relay off. In this way it can turn a set of relays on and off. By varying the patterns of on and off timings to the relay it make distinct sounds-it reminded me of a piezoelectric speaker for some of the programmed values. At fast on or off puling this 6V relay makes a buzzing noise. I was wondering if the sound emitted from the relay could be used as a crude speaker- I'm not talking about a quality speaker- just good enough to recognise a melody or speech. So my question
I was thinking the problem maybe be simplified if a set of relays is used buzzing at a certain frequency-corresponding to tones heard in the human voice to make it sound like speech. Im no expert in acoustics.

My questions are

1) is  it theoretically possible to use the clicking noise from a set of relays only to act as a a crude speaker (so hear a crude known melody or a crude speech)?

2) Is there such a circuit (if so what is it exactly and the theory of how it works) that can be built with an arduino?-so it only used the noise from a relay to act as a crude speaker.

I personally think it possible it would be an interesting circuit to build as I have not seen a relay used like this before. I just think it sounds interesting that music or speech can possible be made by a circuit without using a speaker type component. Maybe there's another non-speaker component (i.e. a component that was not originally designed to make a sound) that can be used instead of a relay.

I'd love to know the answers.

Update
I started on this. And the relays do make different tones-thats as far as I got.
So music seems to be possible; something like a famous melody of a song. I havent got any ideas yet for a another component instead of a relay.


texts: i can't work toggle for my small project

texts:
i build my small project from a few component as this photo
after finish code and project . i work run for Proteus and then the project not run perfectly because my code need toggle for data entered . i cant work toggle for data .i want help .please

this my code arduino

#define CLK 10
#define CLKI 9
#define LD 8
#define SO 11
#define SER 12

byte ledstates;
byte copy=0;
int rec=0;
unsigned long bt_leds_timestamp=0;
byte bt_leds_activated=0;

void setup(){
Serial.begin(9600);
pinMode(CLK,OUTPUT);
pinMode(CLKI,OUTPUT);
pinMode(LD,OUTPUT);
pinMode(SO,INPUT);
pinMode(SER,OUTPUT);
}

void loop(){
if (Serial.available()>0){
message();
}
if(bt_leds_activated && millis()-bt_leds_timestamp > 2000){
ledstates &= ~bt_leds_activated;
shift_out(ledstates);
bt_leds_activated = 0;
}
shift_In();
shift_out(ledstates);
}

void message(){
if(Serial.available()){      // Send data only when you receive data:
char data = Serial.read();        //Read   the incoming data & store into data
Serial.print(data);          //Print Value inside data in Serial monitor

switch (data){
  case 'A' :
    bt_leds_activated |= 1;
    break;
  case 'B' :
    bt_leds_activated |= 2;
    break;
  case 'C' :
    bt_leds_activated |= 4;
    break;
  case 'D' :
    bt_leds_activated |= 8;
    break;
  case 'E' :
    bt_leds_activated |= 16;
    break;
  case 'F' :
    bt_leds_activated |= 32 ;
    break;
  case 'G' :
    bt_leds_activated |= 64;
    break;
  case 'H' :
    bt_leds_activated |= 128;
    break;
  default   : return; }
  }
  ledstates |= bt_leds_activated;
  shift_out(ledstates);
  bt_leds_timestamp = millis();

  }

  void shift_out (byte copy){
  digitalWrite(LD, LOW);
  shiftOut(SER,CLK,MSBFIRST,copy);
  digitalWrite(LD, HIGH);
  delay(100);
  }

  void shift_In(){
  digitalWrite(CLKI,HIGH);
  digitalWrite(LD,HIGH);
  digitalWrite(LD,LOW);
  digitalWrite(LD,HIGH);
  digitalWrite(CLK,HIGH);
  digitalWrite(CLKI,LOW);
  byte buttonstates = shiftIn(SO,CLK,MSBFIRST); //read button states in a local variable
  digitalWrite(CLKI,HIGH);
  for(int i=0;i<8;i++){ // loop through all 8 bits of the buttonstates
    if(!(copy & (1<<i)) && (buttonstates & (1<<i))){ // check if old button state (in copy) is zero and new buttonstate is 1 (for the currently check bit)
        ledstates ^= 1<<i; // toggle the corresponding bit in the ledstates variable (will be shifted out later in the loop() function)
    }
  }
  copy = buttonstates;
  delay(10); // delay for debouncing
   }


texts: Code for determining beats per min when timing a wooden clock

texts: I'm new to Arduino and coding but I build wooden clocks.  The biggest problem is timing the clock to the correct beats per min when adjusting pendulum length.  I'm thinking Arduino and an IR sensor?? to detect when the pendulum breaks the beam, then displaying the beats per min real time would be possible.  If not real time then just beats in a variable time period, ie 1 min or 2 or 5 or 10 min.  I've looked for this type of code and circuit but haven't been able to find one.  Any help would sincerely be appreciated.


texts: Can we use analog input pins as a parameter of analogWrite() for PWM?

texts:
int led = A1;

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

void loop() {
  analogWrite(led, 188.7);
  delay(100);
  analogWrite(led ,0);
  delay(100);
}

Like this and it works! I mean I am getting the exact voltage as calculated while mapping 5V between 0-255


texts: How can I pass multiple variables to a function?

texts:
Using the FastLED library, I want to light up multiple lights at once.

Currently I am passing in just one light to the function.

spell( int LEDNumber )
{
  FastLED.clear();
  leds[LEDNumber] = CRGB (255,255,255); //white
  FastLED.show();
  time = 500;
  delay(t);
}

I would like to pass in more than just 1 light at a time.


texts:
I'm trying to send a string from an ESP32 to an Arduino. I'm using a level shifter, where the Uno is now the Mega (since I couldn't get the Uno to work).

RX0 is now RX1, connected to UART2 of ESP32.
// Master sender ESP32

#include <HardwareSerial.h>

void setup() {
  // Serial.begin(115200);
  Serial2.begin(9600, SERIAL_8N1, 16, 17);
  delay(100);
}

void loop() {
  String shape = "1,2,3";
  Serial2.println(shape);
  delay(500);
}

//Receiver Mega

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  Serial1.begin(9600);
  Serial.begin(19200);
  delay(100);
}

void loop() {
  if (Serial1.available()) {
    String received = "";
    received = Serial1.readString();
    Serial.println(received);
  }
}

Is there something in either sketch that should be changed?


texts: I want 2 output pins to working alternately

texts: I have given pwm output on pin(9) and I Want pin(10) to be high when pin(9) is low and pin(10) to be low when pin(9) is high.  So what should i add to my code?


texts: Where can I get a high-quality ADC (audio digitizer) for Arduino?

texts:
Is there a high-quality (32 bit/96,000 kbps) digitizer for Arduino?

Does anybody know where I can find the best options for this?


texts: Arduino Nano uploading gives error: avrdude: stk500_recv(): programmer is not responding

texts:
I have a Arduino Nano (Sainsmart) that I'm trying to upload a sketch to. Under the Arduino IDE, the device selected was Arduino Nano w/ ATmega328.

However uploading the sketch gives me the error

avrdude: stk500_recv(): programmer is not responding

I tried both USB ports (/dev/tty.usbserial & /dev/cu.usbserial) but the same error persist. The Arduino is connected to a Macbook Air via the USB cable, and the PWR LED indicator light on the Arduino is turned on and the L indicator LED blinks. There was no problem uploading to a Arduino Uno.

Retried after installing the latest FTDI drivers (MAC OSX, x64, v2.2.18, FTDIUSBSerialDriver_10_4_10_5_10_6_10_7.mpkg) from http://www.ftdichip.com/Drivers/VCP.htm. However that did not help.

What could have gone wrong?


texts: Can I hook up an Analog multiplexer to Arduino Nano?

texts:
I want to increase the analogue inputs for the Nano. So is it possible to hook up a CD74HC4067 analog multiplexer to it?

Thanks.


texts: I have three load cells can I sum all the three into Arduino to be one output? If yes how?

texts: I am doing stand thrust and I have three load cells to measure the force. I would like to know if I can sum them to gather into the Arduino or I should use a junction box.


texts: Using a Micro SD card for data logging, bad idea? Reliable?

texts:
I'm planning a project that will read data from an I/O board.
The micro SD card would hold data for input bit identity, labeling ?, then logging after events end.

Nothing would be written to or read from the micro sd, unless an event takes place, usually 2-10 events/hour. System will run 24/7 for years, hopefully.
Is a micro sd card the best way?  Is it reliable enough?


texts: Can't connect to internet with Proteus Arduino project

texts:
Can any one help me with making a connection to the Internet or localhost using any way to make that possible without any physical components (just virtually by simulator)?
I've tried many ways such using:

ESP8266 library
NodeMCU
Ethernet, using webserver or backsoon examples

All what I need is to make a connection virtually to the Internet or localhost to send data from my Proteus project to my asp.net application.
Best regards,


texts:
Good evening :)

I am fairily new to coding the fabulous Arduino UNO. My project right now are consisting of reading Temperature from a DHT22 (AM2302) and writing to a 4-digit 7-segment display. I have got the display to work, but the system does not update the temperature at all. Just the first reading are displayed

#include <DHT.h>
  #include <TimerOne.h>
  #include <SevenSeg.h>

  #define DHTPIN 4    //Defines the temp-pin

  /* DHT22- Pin1 (left) - 5V/3.3V
  Pin2- DATA
    Connect a 10K res from pin1 to pin2
  Pin3 - NC
  Pin4 - GND
  */

  //#define DHTTYPE DHT11   // DHT 11
  #define DHTTYPE DHT22   // DHT 22  (AM2302)
  //#define DHTTYPE DHT21   // DHT 21 (AM2301)

  DHT dht(DHTPIN, DHTTYPE);

  SevenSeg disp (13 ,2 ,3 ,8 ,5 ,6 ,7);
  //            (11, 7, 4, 2, 1, 10, 5)
  const int numOfDigits =4;
  int digitPins [ numOfDigits ]={9,10,11,12};  // uten transistorer
  //                            (12,9,8,6) Alle med 220 Ohm seriemotstand
  //int digitPins [ numOfDigits ]={12,11,10,9};  // med transistorer

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

    disp . setCommonCathode();  // uten transistorer
    //disp . setActivePinState(HIGH,HIGH);  // med transistoere
    disp . setDigitPins ( numOfDigits , digitPins );

    Timer1.initialize(15);   // 0.015 sek
    Timer1.attachInterrupt(loop);
  }

  void loop() {

    dht.begin();

    delay(300);
    float t = dht.readTemperature();

    disp.writeFloat(t);
    Serial.println(t);

  }

How do I get the Sensor to update regularly?


texts: Global variable won't update inside void loop arduino

texts:
I need to update my global variable once I get a 'overdtrue' response and light up my LED but only my LED is lighting up but my global variable is not updated.

Here is my code

int x = 0;

void loop() {
if (content.indexOf("ovrdtrue") > 0)
 {
  x++;
  digitalWrite(ledPin, HIGH);

 }
fsrReading = analogRead(fsrAnalogPin);
Serial.print("Analog reading = ");
Serial.println(fsrReading);
Serial.print("X: ");
Serial.println(x);
}

The x value should be 1 but only the LED has light up. Please help.


texts:
I've written a program for Arduino UNO and 3 LED lights. The program is supposed to turn an inputted number into binary and then display it on the LEDs, on being 1 and off being 0 I have looked it over quite a few times and don't understand why it is not working as it should. I'm a beginner at working with Arduino so I probably just need a more experienced eye to show me where I have messed up. I have a link to a picture of the Arduino setup below. Thanks!
https://drive.google.com/file/d/0B8k_WNZ3eFOkZHkwNUllTEp4WGM/view?usp=sharing

//setting up lights
const int lightOne = 13;
const int lightTwo = 12;
const int lightThree = 11;

//array of the lights for when printing the binary
int lights[] = {lightOne, lightTwo, lightThree};

void setup() {
  //setting pin modes and starting up the serial monitor
  pinMode(lightOne, OUTPUT);
  pinMode(lightTwo, OUTPUT);
  pinMode(lightThree, OUTPUT);
  Serial.begin(9600);
}

//converts a given number into binary
String binary(int number) {
  String r;
  while(number!=0) {
    r = (number % 2 == 0 ? "0" : "1")+r;
    number /= 2;
  }
  return r;
}

//outputs the binary string to the lights (not expecting numbers larger than     9)
void printBinary(String binaryNumber) {
  for (int i = 0; i < sizeof(binaryNumber); i++) {
    digitalWrite(lights[i+11], (binaryNumber[i] == '0' ? LOW : HIGH));
    delay(2000);
  }
}

void loop() {
  int input = Serial.read();                //get the number
  String binaryNumber = binary(input);      //convert number to binary
  Serial.println(binaryNumber);             //print binary to serial monitor
  printBinary(binaryNumber);                //display number in binary on     LEDs

}


texts: I can't get code transferred to my Arduino Mini Pro

texts:
About 3 years ago Sparkfun had a sale on Arduino Minis, so I bought 6 of them (3 x 3.3 V @ 16 MHz and 3 x 5 V @16 MHz). I used two of them for separate projects (everything worked flawlessly) then stored the rest. Then last night I grabbed one of the 5 V and 3.3 V Minis and tried to upload the Blinking LED program to them. But I kept getting this error:

avrdude: stk500_recv(): programmer is not responding

I'm getting similar results on all of these computers: Mac OS X 10.10, Mac OS X 10.7, and Windows 7. I tested with default drivers and I tried installing fresh drivers based on the HardwareID's of the devices. I used both the newest version of Arduino IDE and a few older versions.

I've tried two different USB devices: Sparkfun Basic FTDI and a Generic USB to Serial PL2303 similar to this one. They both produce the same error, however the FTDI seems to be somewhat able to communicate since the RX & TX lights are flashing as well as the Arduino LED. With PL2303, the LED is lit constantly.

While searching last night, I found a few forums where people suggested things like hitting the reset button and selecting different Arduino boards in the IDE.


texts: Send information (such as a string) over digital pins

texts:
I wan't to send information from my arduino digital pins to another arduino's digital pins like a string, or a char. Can I do this without something like Software Serial?

The reason I am asking is because I am wanting to send information from several serial devices to my raspberry pi from an arduino. Thing is, that Raspberry pi only has one set of UART pins, so I was thinking because I have extra arduino uno's, why not send then information to the arduino and have it write the received information to the raspberry pi's digital pins..

Now that I am writing this, I think I will connect the 2 arduinos via a serial connection, and use software serial to write out to the raspberry pi, in three different stages, to get the information to the pi.

The reason I am using the PI is I want to display this information on a large screen with many different options, in short the GPU capabilities are what I am using the PI for, that and Processing.

Question still stands though, can you send information over digital pins?