texts: Sending accelerometer data using BLE to a Cordova phone app

texts:
I'm working on a simple project, that involves an Arduino sending accelerometer data to a Cordova-based phone app using BLE.

I've got my Arduino wired up correctly, I think - I can see the data in the serial monitor.

However, when I send the data with BLE - each axis value has it's own characteristic - it looks like the phone app is only receiving a notification for the first axis.

Here's my .ino:

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

#define BLE_REQ     10
#define BLE_RDY     2
#define BLE_RST     9

float
    x1 = 0,
    y1 = 0,
    z1 = 0;

Adafruit_BNO055 bno = Adafruit_BNO055(55);

// create peripheral instance
BLEPeripheral ble = BLEPeripheral(BLE_REQ, BLE_RDY, BLE_RST);

// create service
BLEService srv = BLEService("FF10");

BLEFloatCharacteristic charX = BLEFloatCharacteristic("FF11", BLENotify);
BLEFloatCharacteristic charY = BLEFloatCharacteristic("FF12", BLENotify);
BLEFloatCharacteristic charZ = BLEFloatCharacteristic("FF13", BLENotify);

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

  ble.setLocalName("TestApp");  // Advertised in scan data as part of GAP
  ble.setDeviceName("TestApp"); // Advertised in generic access as part of GATT
  ble.setAdvertisedServiceUuid(srv.uuid());

  ble.addAttribute(srv);
  ble.addAttribute(charX);
  ble.addAttribute(charY);
  ble.addAttribute(charZ);

  ble.begin();

  /* Initialise the sensor */
  if (!bno.begin())
  {
    Serial.print("Could not initialize the BNO055");
    while (1);
  }

  delay(1000);

  bno.setExtCrystalUse(true);

}

void loop(void)
{

  imu::Vector<3> v;
  float x, y, z;

  v = bno.getVector(Adafruit_BNO055::VECTOR_LINEARACCEL);

  x = v.x();
  y = v.y();
  z = v.z();

  Serial.print("-20.0,"); //set lower scale
  Serial.print(x);  // x acceleration
  Serial.print(",");
  Serial.print(y);  // y acceleration
  Serial.print(",");
  Serial.print(z);  // z acceleration
  Serial.println(",20.0"); //set upper scale

  ble.poll();

  // only notify if the acceleration value is > 0.20

  if (abs(x1 - x) > 0.20)
  {
    x1 = x;
    charX.setValue(x);
  }
  if (abs(y1 - y) > 0.20)
  {
    y1 = y;
    charY.setValue(y);
  }
  if (abs(z1 - z) > 0.20)
  {
    z1 = z;
    charZ.setValue(z);
  }

}

As I mentioned - the data looks OK in the serial monitor. And my Cordova app is connecting to the Arduino peripheral, and receiving notifications.

But, only for the first axis.

If I comment out this line:

// charX.setValue(x);

... then the Cordova app only receives notifications for the second axis.

Likewise, if I comment out both of these lines:

// charX.setValue(x);
// charY.setValue(y);

... then the Cordova app only receives notifications for the third axis.

In other words - it's as if the Cordova app can only receive one notification at a time.

Since I need the app to receive data for all three axis' - how can I fix this?

[UPDATE]

In the current design - the Arduino app is updating all three characteristics on every loop. Since the Cordova phone app only seems to notice one - I wondered if maybe it's only able to process one notification per "cycle". So, I changed my Arduino app to this:

(Assumes I have a global int variable called i that's initialized to 0:

  if (i == 0) {
    charX.setValue(x);
  } else if (i == 1) {
    charY.setValue(y);
  } else if (i == 2) {
    charZ.setValue(z);
  }

  i++;
  if (i == 3) {
    i = 0;
  }

With this change - the Cordova app registers every notification, so it's "working". However, this approach is less than ideal, because there's a delay with each notification, since it's only updating one dimension every loop cycle.

So, I'm wondering if there's a better way to do this.

Thanks in advance.


texts:
Sorry if this is a dumb question, I'm new to Arduinos. I'm planning to use a MOVI voice shield with SparkFun's RedBoard Turbo (3.3v). The RedBoard Turbo requires a power supply under 6VDC, but the MOVI website recommends a power supply of 9VDC to the Arduino, because the MOVI can't have its own power supply. Will this destroy my RedBoard? Or is this safe and just something you have to do when using shields? Thank you.

The product website says: "A 7V to 16V 500mA external power supply that powers MOVI™ through the Arduino board. The power consumption of both boards is just above what the USB port can provide. If you don't have already one, this 9V adapter from Adafruit will work perfectly."


texts: I am new to arduino please help me in understanding this code

texts:
while (client.connected()) {
  if (client.available()) {
    char c = client.read();
    Serial.write(c);

Why we require char c and what is the use of using this command Serial.write(c)


texts: Arduino remote-controlled car stops after a few seconds

texts:
I am making a remotely controlled car for a project at Uni. The car is made from an Arduino Uno, a 2 motor driver and a Bluetooth transceiver. I have written some code for it, but it randomly stops after 2 or 3 loops.

Here is my code:

#include "SoftwareSerial.h"

typedef unsigned char u8;

typedef struct {
  u8 right;
  u8 left;
} speed;

SoftwareSerial bluetooth(4, 2);

const u8 RIGHT_MOTOR_PIN1 = 3;
const u8 RIGHT_MOTOR_PIN2 = 5;
const u8 LEFT_MOTOR_PIN1 = 6;
const u8 LEFT_MOTOR_PIN2 = 9;

const u8 MAX_SPEED = 0xFFU;
const u8 HALF_SPEED = MAX_SPEED / 2;
const u8 NO_SPEED = 0x0U;

static u8 command = 0U;
static speed potentialSpeed;
static speed actualSpeed;

void setup() {
  bluetooth.begin(115200);
  while (0U != bluetooth.available()) bluetooth.read();
  potentialSpeed.right = MAX_SPEED;
  potentialSpeed.left = MAX_SPEED;
  actualSpeed.right = NO_SPEED;
  actualSpeed.left = NO_SPEED;
}

void loop() {
  readCommand();
  {
    if (clockwise(command)) {
      if (0U == (command & 0xFEU)) {
        actualSpeed.right = - MAX_SPEED;
        actualSpeed.left = + MAX_SPEED;
      }
    } else if (counterclockwise(command)) {
      if (0U == (command & 0xFDU)) {
        actualSpeed.right = + MAX_SPEED;
        actualSpeed.left = - MAX_SPEED;
      }
    } else {
      if (right(command)) {
        potentialSpeed.right = HALF_SPEED;
      }
      if (left(command)) {
        potentialSpeed.left = HALF_SPEED;
      }
      if (forward(command)) {
        if (!backward(command)) {
          actualSpeed.right = + potentialSpeed.right;
          actualSpeed.left = + potentialSpeed.left;
        }
      } else if (backward(command)) {
        actualSpeed.right = - potentialSpeed.right;
        actualSpeed.left = - potentialSpeed.left;
      }
    }
    if (0U == command) {
      potentialSpeed.right = MAX_SPEED;
      potentialSpeed.left = MAX_SPEED;
      actualSpeed.right = NO_SPEED;
      actualSpeed.left = NO_SPEED;
    }
  }
  runAt(actualSpeed);
  delay(95);
}

void readCommand(void) {
  command = 0U;
  if (1U == bluetooth.available())
    command = bluetooth.read();
}

inline boolean clockwise(u8 command) {
  return (boolean)((command >> 0U) & 1U);
}
inline boolean counterclockwise(u8 command) {
  return (boolean)((command >> 1U) & 1U);
}
inline boolean right(u8 command) {
  return (boolean)((command >> 2U) & 1U);
}
inline boolean left(u8 command) {
  return (boolean)((command >> 3U) & 1U);
}
inline boolean forward(u8 command) {
  return (boolean)((command >> 4U) & 1U);
}
inline boolean backward(u8 command) {
  return (boolean)((command >> 5U) & 1U);
}

void runAt(speed Speed) {
  if (Speed.right > 0U) {
    analogWrite(RIGHT_MOTOR_PIN1, 0U);
    analogWrite(RIGHT_MOTOR_PIN2, Speed.right);
  } else {
    analogWrite(RIGHT_MOTOR_PIN1, (-(Speed.right)));
    analogWrite(RIGHT_MOTOR_PIN2, 0U);
  }
  if (Speed.left > 0U) {
    analogWrite(LEFT_MOTOR_PIN1, 0U);
    analogWrite(LEFT_MOTOR_PIN2, Speed.left);
  }
  else {
    analogWrite(LEFT_MOTOR_PIN1, (-(Speed.left)));
    analogWrite(LEFT_MOTOR_PIN2, 0U);
  }
}

Could you please help me find the cause?
Also, I am unable to make it go backwards. Can that be related?


texts: Arduino Due 16U2 Programming Port Documentation

texts:
Are there any documentation or whatsoever on what the 16U2 does when trying to program the Sam3X in Arduino Due?

I reallynwant to know what's wrong with my made up board but can't get pass the No Device Found problem.

Been searching it but I can't find any. I can't understand the hex file burned on the MCU.


texts: DS18B20 Temperature Sensor return as float function returning null 50% of the time

texts:
I just got an DS18B20 Temperature sensor and am trying to modify the example code to use a function instead. Below is my getTemp function. It's working but returning results with a 0 value part of the time for example:

  Temperature = 72.39
  Temperature = 0.00

If I add Serial.print(fahrenheit); within the function I am always provided with the correct temperature. I though this may have to do with needing a delay but adding delay(5000); in my loop didn't help.

I'm assuming it's something simple I'm not understanding about how floats return.

#include <OneWire.h>

// OneWire DS18S20, DS18B20, DS1822 Temperature Example
//
// http://www.pjrc.com/teensy/td_libs_OneWire.html
//
// The DallasTemperature library can do all this work for you!
// http://milesburton.com/Dallas_Temperature_Control_Library

OneWire  ds(2);  // on pin 10 (a 4.7K resistor is necessary)

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

float getTemp(char tScale) {
  byte i;
  byte present = 0;
  byte type_s = 0;
  byte data[12];
  byte addr[8];
  float celsius, fahrenheit;

  if ( !ds.search(addr)) {
    ds.reset_search();
    delay(250);
    return false;
  }

  ds.reset();
  ds.select(addr);
  ds.write(0x44, 1);        // start conversion, with parasite power on at the end

  delay(1000);     // maybe 750ms is enough, maybe not
  // we might do a ds.depower() here, but the reset will take care of it.

  present = ds.reset();
  ds.select(addr);
  ds.write(0xBE);         // Read Scratchpad

  for ( i = 0; i < 9; i++) {           // we need 9 bytes
    data[i] = ds.read();

  }

  // Convert the data to actual temperature
  // because the result is a 16 bit signed integer, it should
  // be stored to an "int16_t" type, which is always 16 bits
  // even when compiled on a 32 bit processor.
  int16_t raw = (data[1] << 8) | data[0];
  if (type_s) {
    raw = raw << 3; // 9 bit resolution default
    if (data[7] == 0x10) {
      // "count remain" gives full 12 bit resolution
      raw = (raw & 0xFFF0) + 12 - data[6];
    }
  } else {
    byte cfg = (data[4] & 0x60);
    // at lower res, the low bits are undefined, so let's zero them
    if (cfg == 0x00) raw = raw & ~7;  // 9 bit resolution, 93.75 ms
    else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
    else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
    //// default is 12 bit resolution, 750 ms conversion time
  }
  celsius = (float)raw / 16.0;
  fahrenheit = celsius * 1.8 + 32.0;
  if (tScale == 'C') {
    return celsius;
  }
  else if (tScale == 'F') {
    return fahrenheit;
  }

}
void loop(void) {
    Serial.print("Temperature = ");
    Serial.println( getTemp( 'F' ) );

}

Edit:
Interesting enough, adding an if statement to the loop fixes this, however. I'd still like to understand what is going on:

void loop(void) {
  if ( getTemp( 'F' ) == 0 ){
    Serial.print( "Temperature = " );
    Serial.println( getTemp( 'F' ) );
  }
}


texts: I am working on a project which requires countdown from 30sec to 0sec. I can't use delay() function because I am taking input from keyboard during countdown. millis() function wont help because my board will be active for more than 50 days. I require something like counter which I can reset after or before completion of 30sec.


texts:
I'd like to deploy my project so I'm looking for a way to power the nodemcu.
I'd like to know if there's a way to power it with a 9V battery without any other external circuit.

Until now I've found information for the nodemcu 1.0 and it supports up to 20V on the VIN port. Here's the article I read:
http://henrysbench.capnfatz.com/henrys-bench/arduino-projects-tips-and-more/powering-the-esp-12e-nodemcu-development-board/

I'd like to use the two port: 5V and GND but I'm not sure, here there is no VIN port and I'd prefer to not burn my board.
Are there any better way to power my project?


texts:
I recreated this project from Fritzing in my circuits.io project then on the arduino itself, it all works fine just how I wanted it.

The concept behind it is:

You plug it in and the time is set to 00:00
You can adjust the time to the time now let's say 22:46
You can put in an alarm to wake up let's say an hour later at 23:46
The piezo beeps in stops, so not continious.

So now my question is, how can I add a led that flickers on the same rhythm as the piezo (when the alarm goes off)? Can someone help me in my circuits.io project?

An update/edit would be great! I'm relatively new to all of this.

Thanks a lot!


texts: HM-10 send and receive data and checking received value

texts:
I am wondering what is wrong with my code below. I have 2 issues.

The first issue, I am checking if c equals "hi" and if it does then display said hi. I currently see the output of c when it hits Serial.println(c); but never see the said hi even though Serial.println(c); does say "said hi".

The second issue is that when I start up the Arduino I am sending the AT command using bluetooth.println("AT");, but all it seems to do is display AT on the phone instead of OK as it should.

#include <SoftwareSerial.h>

SoftwareSerial bluetooth(8,9); // RX, TX

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  Serial.println("PC Side Connected");
  bluetooth.begin(9600);
  while (!bluetooth) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  bluetooth.println("Bluetooth Side Connected");
  bluetooth.println("AT"); // just a check
}

void loop() { // run over and over
  String c;
  if (bluetooth.available()) {
    //What is sent back from the BT module
    c = bluetooth.readStringUntil('\n');
    delay(10);
    Serial.println(c);
    if (c.equals('hi')) {
      Serial.println("said hi");
    }
  }
  if (Serial.available()) {
    //Send back data to Bluetooth module
    bluetooth.write(Serial.read());
  }
}


texts:
I am building a quadrocopter with an Arduino Uno as control unit. I know I can supply 5 volts to the 5V pin, but my ESCs produce 5.5 volts, which I measured with my multimeter. Will this voltage drop to 5 volts when I connect the Arduino and if not are 5.5 volts to the 5V pin a problem?

Edit:

My Arduino was running well for a couple of days on this setup with 5.5 volts to the 5V pin but died yesterday. By dying I mean the ATmega doesn't execute any code anymore, the L LED doesn't blink, and even a loopback test fails, which is a sign of a defective USB connector. But I am faced with the same challenge. Should I run my Arduino on 14.4 Volts from my 3S LIPO to Vin or supply 5.5 volts to the Vin pin?

Actually I just realised when I measure the voltage from the ESCs they deliver 9 point something volts for half a second when connecting the multimeter, I guess this voltage spike killed the Arduino.


texts: Can I program for Arduino without having a real board?

texts: I would like to start the development of some basic Arduino projects but I don't own an Arduino board yet. Is there a way I can write my code and emulate/test it using a desktop computer so after my board arrives I just have to upload and run my project on it?


texts: ACS712 to build doorbell sensor - Arduino Hangs up

texts:
I have a ACS712 module that I am connecting to my Arduino Uno to read the current spike when my door bells rings (and then trigger some events in my "sketch").

In my country doorbells use the ~115 VAC at ~60Hz. So, I just opened the doorbell and connected the ACS712 module in series.

I do not know how much amperage my doorbell draws, but it is hardly the 30A supposedly supported by the module.

At this point I am not connecting the OUT pin to the Arduino, only VCC and GND to the +5V and GND of the Arduino Uno. (I am also tried connecting the OUT pin to A2 in the Arduino).

What happens is that as soon as I ring the doorbell the Arduino hangs up. Sometimes I even have to physically unplug the Arduino to get it back to life.

It doesn't necessarily happens in the first bell, but it does not survive 3 rings in a row.

The ACS712 chip is supposed to provide 2.1 kVRMS of isolation... it doesn't seem likely that the "kickback" from the bell would be 2100 VAC... so I cannot imagine how/why my Arduino is hanging up, when it is supposed to be completely isolated from the AC (that's the whole point of the Hall Effect current sensor).

I added some capacitors to the VCC/GND pins with no luck.

So... any ideas on 1) how to protect the Arduino from hanging up?, 2) what is making the Arduino hang up?.


texts:
So I have been working trying to measure the velocity of a string attaches using Rfduino microcontroller.
I have downloaded all the library(based on https://www.youtube.com/watch?v=K0JiPQnrkHQ) and check the PCB all the connection via multimeter ( i have made the PCB, and assemble via Chineses manufacture). and connect PCB to my laptop via FTDI board as this;

When I compile the code it. It's compiled nicely. But when I try to download the code it says

RFduino device required for RFduino hex file

Does anyone had any experience with this sort of error message?
(this is my first question in this forum. I don't no this belong to hardware or software side)

EDIT:
I'm trying to program RFD22302 micro using RFD22121 USB shield and USB MicroB Plug Breakout board.

RFD22302

USB Development Kit-RFD22121

USB MicroB Plug Breakout

any help would be appreciated!
Thanks, Heaps!


texts: I'm using servo motor in my Arduino based project, I've tried to provide servo with external power supply, So I've used 9v battery with IC7805 to step down to 5v,  but the motor is not working, so what should I do? FYI: I used the same battery with IC7805 to power IR proximity sensor which works fine.


texts:
I'm having some issues dealing with strings in a small Arduino app.
I wonder why this code works:

mqtt.setServer("192.168.1.42", port);

and this code doesn't:

IPAddress ip = MDNS.queryHost(...);
mqtt.setServer(ip.toString().c_str(), port);

Even when strcmp returns 0 when I compare both:

strcmp(ip.toString().c_str(), "192.168.1.42"); // output = 0 => equality

I've also tried other alternatives, such as creating a char array, with no luck:

String ipstr = ip.toString();
char ipchar[ipstr.length() + 1];
ipstr.toCharArray(ipchar, ipstr.length() + 1);

mqtt.setServer(ipchar, port);

All alternatives compile, but the mqtt connection is never established later on. I must be missing something obvious because it works when I hardcode the "192.168.1.42" string.


texts: How do I specify a working directory when saving to SD card?

texts:
I'm trying to datalog to a EyeFi SD card by writing to a file with a jpg extension. Here's that portion of my code so far:

// see if the directory exists, create it if not.
if( !SD.exists("/DCIM/100NIKON") )
{
  if( SD.mkdir("/DCIM/100NIKON") )
  {
    Serial.print("File directory created: ");
  }
  else {
    error("File directory not created");
  }
}
else
{
  Serial.print("File directory exists: ");
}

// Test file
char filename[] = "DSCN0000.JPG";

if (! SD.exists(filename))
{
  logfile = SD.open(filename, FILE_WRITE); // only open a new file if it doesn't exist
}

if (! logfile)
{
  error("Couldnt create file");
}

The Arduino creates the directory, but the file is still saved to the root.  I would love some help or tips on this.


texts: LEDs on TX/RX lines interfering with the programmig of the device

texts: I have recently designed a shield to my Arduino Duemilanove, which has 8 LEDs, on the digital GPIO, from 0 to 7, but it won't program with the shield on because the voltage drop is too much on the RX and TX lines. My question is: can I have a LED on the TX/RX line with a minimum resistor value that allows me to program the Arduino?


texts: Use LED on pin 13 again after using the SD library

texts:
The question in short:
On an Arduino UNO or Nano using the SD library, is it somehow possible to use the LED on pin 13 (or any other pin that is used by the library) again after finishing all SD operations?

Detailed explanation:
In my sketch, during setup() I need to read some data from a file on the SD card, which is being closed again before leaving setup().

Now, I wanted to use the LED on pin 13 during loop() as a status indicator for the user, but it seems that after SD.begin(), pin 13 (and its LED) cannot be used as an OUTPUT anymore.

Here is a minimum sketch to show the behavior. It doesn't matter if I try to turn on the LED right after the call to SD.begin() in setup() or in loop():

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

#define SD_CS  4
#define LED    13

void setup() {
  pinMode(LED, OUTPUT);

  // This still works:
  digitalWrite(LED, HIGH);
  delay(1000);
  digitalWrite(LED, LOW);

  SD.begin(SD_CS);

  // This does not work anymore:
  digitalWrite(LED, HIGH);
  delay(1000);
  digitalWrite(LED, LOW);
}

void loop() {}


texts: Power Arduino Over 9V automatically after being disconnected from USB 5V

texts: Am wondering if there is some way the Arduino can automatically power itself using through the 9v port in case the USB is disconnected, and afterwards if the USB is connected again it stop feeding from the 9v Input.


texts: Wanted to control 2 servos with serial read

texts:
I want to use 2nd servo only when 1st is in up state by asking user whether he wants to fire or not.(code in bold is not working )

#include <Servo.h>

    Servo myservo;
    Servo trigervo;
    int pos = 0;
    int u = 0, p = 0, t = 0;
    int incomingByte = 0; // for incoming serial data

    void setup() {
      Serial.begin(9600);
      myservo.attach(9);
      trigervo.attach(10);
      pinMode(13, OUTPUT);
      myservo.write(0);
    }

    void loop() {
      if (Serial.available() > 0) {
        // read the incoming byte:
        incomingByte = Serial.read();
        Serial.print("I received: ");
        if (incomingByte == 111 && u == 0) {
          for (pos = 0; pos <= 80; pos += 1) {
            myservo.write(pos);
            delay(5); //
            digitalWrite(13, HIGH);
          }
          u = 1;
          p = 0;
          Serial.println(incomingByte, DEC);
          Serial.print("Want to Shoot? \n");
          Serial.print("1\n");
          ***t = Serial.read(); // from here
          if (t == 107) {
            Serial.print("2\n");
            trigervo.write(60);
            trigervo.write(0);
          } // to here, it is not working***
        } else if (incomingByte == 102 && p == 0) {

          for (pos = 100; pos >= 0; pos -= 1) {
            myservo.write(pos);
            delay(7);
            digitalWrite(13, HIGH);
          }
          u = 0;
          p = 1;
          Serial.println(incomingByte, DEC);
        }
        Serial.println(incomingByte, DEC);

      }
    }


texts: How do I set up an Arduino to be a wireless HID?

texts:
The question below describes how to set up an Arduino as an HID (Human Input Device -- like a keyboard, mouse, etc.).  How can I set up an Arduino as a wireless HID?
I'm flexible as to the wireless format.  Bluetooth, USB receiver, or any other format is acceptable.
Arduino as USB HID


texts: Why won't my iMac recognize my Mega32u4 Arduino Pro Micro board (I've tried several cables)?

texts:
I bought this Pro Micro on eBay a while back, and I never really got around to using it. But now that I do my iMac won't recognize the board. I plug it into my iMac and open Arduino and go to the board tab, and it doesn't even have a Pro Micro choice, so I just choose Micro.

In ports it isn't showing up like my other boards do. Is it my computer, because my Chinese clone Uno and Mega weren't being recognized a while ago? I downloaded the CH340 chip driver for them because they used the CH340 chip and now they are recognized and work perfectly!

The thing is the Pro Micro does not use that chip so is there something else I have to do like another driver to download? It is not the cable because I have tried 5 cables and some had the symbol with the circle triangle and square connected on them, which is the usb serial symbol I think, so they aren't just power cables. If anyone knows what the problem is, that would be awesome! Here is the error it gives me when I try to upload it.

 Arduino: 1.6.9 (Mac OS X), Board: "Arduino/Genuino Micro"

failed MSpanList_Insert 0x31dea0 0x29ab70fa1fa 0x0
fatal error: MSpanList_Insert

runtime stack:
runtime.MSpanList_Insert(0x2c70d0, 0x31dea0)
/usr/local/go/src/runtime/mheap.c:692 +0x8f
runtime.MHeap_Alloc(0x2c6d20, 0x6, 0x10000000034, 0xf989)
runtime.MCentral_CacheSpan(0x2d10d8, 0x30c270)
/usr/local/go/src/runtime/mcentral.c:85 +0x167
runtime.MCache_Refill(0x308000, 0xc200000034, 0x30c270)
/usr/local/go/src/runtime/mcache.c:90 +0xa0

 goroutine 1 [running]:
 runtime.switchtoM()
/usr/local/go/src/runtime/asm_amd64.s:198 fp=0xc2082b7468          sp=0xc2082b7460
 runtime.mallocgc(0x2200, 0x19ff80, 0x0, 0xc2080d68e9)
/usr/local/go/src/runtime/malloc.go:178 +0x849 fp=0xc2082b7518     sp=0xc2082b7468
 runtime.newarray(0x19ff80, 0x20, 0xa5ca)
/usr/local/go/src/runtime/malloc.go:365 +0xc1 fp=0xc2082b7550    sp=0xc2082b7518
 runtime.hashGrow(0x1b4300, 0xc2080dc150)
/usr/local/go/src/runtime/hashmap.go:744 +0x86 fp=0xc2082b7580    sp=0xc2082b7550
 runtime.mapassign1(0x1b4300, 0xc2080dc150, 0xc2082b7698, 0xc2082b7688)
/usr/local/go/src/runtime/hashmap.go:456 +0x568 fp=0xc2082b7620  sp=0xc2082b7580
  arduino.cc/builder/props.PropertiesMap.Merge(0xc2080dc150,      0xc2082b7748, 0x1, 0x1, 0x3)
/Users/jenkins/jenkins/workspace/arduino-builder-     macosx/src/arduino.cc/builder/props/properties.go:162 +0x153     fp=0xc2082b7718 sp=0xc2082b7620
 arduino.cc/builder/props.PropertiesMap.Clone(0xc20803ce40, 0xb2f5f)
/Users/jenkins/jenkins/workspace/arduino-builder-    macosx/src/arduino.cc/builder/props/properties.go:170 +0xad fp=0xc2082b7770     sp=0xc2082b7718
 arduino.cc/builder.(*RecipeByPrefixSuffixRunner).Run(0xc20801e300,     0xc208068000, 0x0, 0x0)
/Users/jenkins/jenkins/workspace/arduino-builder-    macosx/src/arduino.cc/builder/recipe_runner.go:53 +0x2c4 fp=0xc2082b78e8    sp=0xc2082b7770
arduino.cc/builder.runCommands(0xc208068000, 0xc2082b7af8, 0x1c, 0x1c,     0xc208038001, 0x0, 0x0)
/Users/jenkins/jenkins/workspace/arduino-builder-   macosx/src/arduino.cc/builder/builder.go:181 +0x139 fp=0xc2082b7978    sp=0xc2082b78e8
 arduino.cc/builder.(*Builder).Run(0xc2082b7ce0, 0xc208068000, 0x0,   0x0)
/Users/jenkins/jenkins/workspace/arduino-builder-  macosx/src/arduino.cc/builder/builder.go:116 +0xe8e fp=0xc2082b7cc0   sp=0xc2082b7978
 arduino.cc/builder.RunBuilder(0xc208068000, 0x0, 0x0)
/Users/jenkins/jenkins/workspace/arduino-builder- macosx/src/arduino.cc/builder/builder.go:212 +0x49 fp=0xc2082b7ce8  sp=0xc2082b7cc0
 main.main()
/Users/jenkins/jenkins/workspace/arduino-builder-   macosx/src/arduino.cc/arduino-builder/main.go:316 +0x171b fp=0xc2082b7f98    sp=0xc2082b7ce8
 runtime.main()
/usr/local/go/src/runtime/proc.go:63 +0xf3 fp=0xc2082b7fe0   sp=0xc2082b7f98
 runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:2232 +0x1 fp=0xc2082b7fe8    sp=0xc2082b7fe0
arduino-builder returned 2
Error compiling for board Arduino/Genuino Micro.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


texts: Communication over I2C protocol with more than one A/D device

texts: According to datasheet of MCP3021 A/D converter (Microchip, page 16) the MCP3021 can be accessed by proper address bits in control byte. In case of MCP3021 5AT the address is 101, in case of MCP3021 4AT the address is 100. Does than mean that to interface two MCP3021 diveces in one circuit one have to purchase two devices with different serial number, e.g. MCP3021 5AT and 4AT?


texts:
How to clear the serial buffer of arduino uno?
This is my code to on and off the LED using sms from mobile using gsm module

#include <SoftwareSerial.h>
int Led=7;

SoftwareSerial mySerial(9, 10);

void setup()
{
  pinMode(Led,OUTPUT);
  mySerial.begin(9600);   // Setting the baud rate of GSM Module
  Serial.begin(9600);    // Setting the baud rate of Serial Monitor (Arduino)
  delay(100);
}

void loop()
{
  if (mySerial.available()>0)
  {

  }
   switch(mySerial.read())
  {
    case 'a':
           digitalWrite(Led,HIGH);
           delay(10000);
           digitalWrite(Led,LOW);
           delay(100);
           break;

    case 'b' :
           digitalWrite(Led,LOW);
           break;

  }}

problem is whenever i on the module or the connection is restablished it automatically gets even without an sms.I need it to be fully in my control so i need to clear the serial buffer.


texts: Are there any good and maintained libraries for using DS2482 I2C to 1-Wire bridge?

texts:
The DS2482-100 and DS2482-800 are I2C to 1-Wire bridges which are useful for driving complex 1-Wire networks.

These are natively supported by a number of packages in Linux so you can interface easily with them on a Raspberry Pi.

I was surprised to find there is not an obvious library for accessing them on an Arduino however.

I have found the following:

An Arduino library - has some quirks and not-maintained.
Part of AVR-Liberty - less quirks, not sure if maintained, not "Arduino" as
such, more AVR.

It is helpful to be able to rely on maintained libraries to deal with any changes to the Arduino environment.

Arduino libraries are often easier to use than ones designed for AVR in general, which means more people are able to use the software.

Is there a better library available?


texts: Fail to upload sketch when Arduino Nano is connected to breakout board

texts:
When I upload a sketch from Arduino IDE to my Arduino Nano (not yet connected to breakout board) via USB, it works. I can then plug the Nano back to the breakout board and let it do its thing.
However, if the same Nano is already connected to the breakout board (which is in turn connected to some other things), and I try to upload a sketch via USB, it does not work.
The error message is:
Arduino: 1.8.13 (Windows 7), Board: "Arduino Nano, ATmega328P (Old Bootloader)"

Sketch uses 3844 bytes (12%) of program storage space. Maximum is 30720 bytes.

Global variables use 204 bytes (9%) of dynamic memory, leaving 1844 bytes for local variables. Maximum is 2048 bytes.

avrdude: stk500_recv(): programmer is not responding

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

avrdude: stk500_recv(): programmer is not responding

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

avrdude: stk500_recv(): programmer is not responding

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

avrdude: stk500_recv(): programmer is not responding

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

avrdude: stk500_recv(): programmer is not responding

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

avrdude: stk500_recv(): programmer is not responding

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

avrdude: stk500_recv(): programmer is not responding

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

avrdude: stk500_recv(): programmer is not responding

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

avrdude: stk500_recv(): programmer is not responding

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

avrdude: stk500_recv(): programmer is not responding

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

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

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

What's wrong? How do I solve it?


texts: How to store values from a sensor inside an empty array?

texts:
I need to store the value of the distance in the dist array, then calculate the maximun value and print the index associated with this value:

The problem is when starting the nested for inside another for, the servomotor stops working

// Includes the Servo library
#include <Servo.h>

// Array y valores para funcion valor maximo

int max=0;

int angle=0;

int distance=0;

// Defines Tirg and Echo pins of the Ultrasonic Sensor

const int trigPin = 10;

const int echoPin = 11;

// Variables for the duration and the distance

long duration;

//int distance[180];

Servo myServo1; // Creates a servo object for controlling the servo motor

void setup() {

  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output

  pinMode(echoPin, INPUT); // Sets the echoPin as an Input

  Serial.begin(9600);

  myServo1.attach(12); // Defines on which pin is the servo motor attached
  }

void loop() {

distance = calculateDistance();
  if (distance <= 15 && distance >=2)
  {

  // rotates the servo motor from 1 to 179 degrees and calculate the distance at each angle

  for(int j=90;j>=0;j--){

  myServo1.write(j);

  delay(30);}

  for(int j=0;j<=180;j++){

  myServo1.write(j);

  int i=0;

  int  dist [i] = {calculateDistance()};

      for (i=0;i=180;i++){           <--------------------------------------

       if (dist[i]>max){
      max=dist[i];
      angle=i;
      Serial.print(angle);
      delay(30);}

  }
      }

  // Repeats the previous lines from 179 to 90 degrees

for(int j=180;j>90;j--){

  myServo1.write(j);

  delay(30);

  }
}
}

// Function for calculating the distance measured by the Ultrasonic sensor
int calculateDistance(){

  digitalWrite(trigPin, LOW);

  delayMicroseconds(2);

  // Sets the trigPin on HIGH state for 10 micro seconds

  digitalWrite(trigPin, HIGH);

  delayMicroseconds(10);

  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH); // Reads the echoPin, returns the sound wave travel time in microseconds

  distance= duration*0.034/2;

  return distance;

}


texts:
I am trying to make a simple breathing led circuit in which the intensity of the led varies between 0 and 255. I followed the Fade tutorial on the Arduino site, which gives me what I want, but I notice that the change in brightness is much more noticeable when the intensity is at 0.

In other words, the brightness seems to be bouncing back from 0, rather than slowly gliding back up.

I tried mapping the value of the delay to brightness: del = map(brightness, 0, 255, 10, 1); but that did not do the job.

The mapping seems to work better when I use 30 instead of 10 as longest delay time:  del = map(brightness, 0, 255, 30, 1); but I think what I really need is to implement some sort of sinusoidal function to make transitions smoother, but I am really struggling with the math... Any suggestions?

Here is the code:

int led = 9;           // the PWM pin the LED is attached to
int brightness = 0;    // how bright the LED is
int fadeAmount = 1;    // how many points to fade the LED by
int del;

// the setup routine runs once when you press reset:
void setup() {
  // declare pin 9 to be an output:
  pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  // set the brightness of pin 9:
  analogWrite(led, brightness);

  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightness <= 0 || brightness >= 255) {
    fadeAmount = -fadeAmount;
  }

  // here I map the delay to brightness
  del = map(brightness, 0, 255, 10, 1);

  delay(del);
}


texts:
I am learning brain wave programming from Tinkernut tutorial.

#include <IRremote.h>
#include <IRremoteInt.h>
#include <Brain.h>
IRsend irsend;
Brain brain(Serial);
const int ledPin = 3;
long interval = 500;
long previousMillis = 0;
int ledState = LOW;
int medValue;

void setup() {
  // Set up the LED pin.
  pinMode(ledPin, OUTPUT);
  // Start the hardware serial.
  Serial.begin(9600);
}

void loop() {
  // Expect packets about once per second.
  if (brain.update()) {
    Serial.println(brain.readCSV());
    // Attention runs from 0 to 100.
    medValue = brain.readMeditation();
  }

  // Make sure we have a signal.
  if(brain.readSignalQuality() == 0) {
    // Send a signal to the LED.
    if (medValue < 50) {
    irsend.sendNEC(0x10EFA05F, 32);
    delay(40);
    }
  }
}

The above code by tinkernut controls a single button of a tv remote only if the meditation value drops below 50.

My question is,

How to program arduino to control all the buttons of a tv remote ?


texts: How to connect Arduino to headphone jack?

texts:
I would like to connect a headphone jack to my Arduino and make it as an output. I mean I would simply send some simple beeps.

I know that there is a breadboard friendly headphone jack, but I don't know how to wire it. I really don't know if I can simply connect the Arduino to the headphone jack, or I will need some resistors, etc. Will I need some voltage measurements?

Also, can I do this simply by connecting the parts of the jack ( right, left, GND) to the Arduino?

So could you please help me with this?


texts:
I am trying to create a code that has at least 6 servos attached and two buttons for a two player game. I want to be able to roll a random number and have it hold that value then when it is that players turn. The program should also take that previous number and add it to the next. It would eventually be adding up all the values of the rolls. This is what I have so far. Any advice would be helpful. Thanks!

#include <Servo.h>

Servo myservo;

int pos = 0;    // variable to store the servo position
int x;
int button = 8;
int BUTTON;
int randomNumber;
int xPrevious;

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

void loop() {
  for (x = 2; x <= 7; x += 1) {
    myservo.attach(x);

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

      BUTTON = digitalRead(button);
      if(BUTTON == LOW){
        randomNumber = random(1,7);
        delay(350);
        Serial.println(randomNumber);
      }
    }
    randomNumber += xPrevious;
  }
}


texts:
I watched this video and used his transmitter code and receiver code. However, it's not working. There's no response from the receiver.

The transmitter stuck at the loop:

if (!radio.write( &data, sizeof(unsigned char) )) {
Serial.println("No acknowledgement of transmission - receiving radio device connected?");
}

and the receiver never received anything and only printed:

  Serial.println("THIS IS THE RECEIVER CODE - YOU NEED THE OTHER ARDUINO TO TRANSMIT");

I've been stuck here for hours. I checked the hardware, there's no issue there. I also tried to adjust the code couple of times, and it looked decent but not helping. Could you help me to check what went wrong with the code please?


texts: I change ESP8266 baudrate and now it doesn't work

texts:
I was trying some AT commands using the monitor of the Arduino Web Editor with an Arduino Uno and a ESP8266 module. It was working at 115200 bauds but then I changed it with AT+CIOBAUD=19200 and now it can't communicate.

How can I change the baudrate to 115200?

Now I see this:


texts: I want to connect my Arduino to my tv screen while playing a playstation/XBox game. When a certain screen comes up (like say when you die the same screen pops up) then I want Arduino to catch that and then trigger another device on and off. How might I be able to trigger something by having arduino read the screen then trigger something on and off?


texts: split reading sensors values from stream after it via xbee

texts:
I'm trying to make project to monitor my home. I am using some gas sensors and temperature and humidity sensors. I want to do this wirelessly and I think the
best thing to do that is XBee.

I use this code for the transmitter Arduino:

char dataPacket[64];

int gx = 1;
int gy = 321;
int gz = 456;
int ax = 654;
int ay = 789;
int az = 987;
int mx = 147;
int my = 258;
int mz = 369;

void setup(){

 Serial.begin(9600);

}

void loop(){

   sprintf(dataPacket, "X%d" ,gx);
    //  sprintf(dataPacket, "A%dB%dC%dD%dE%dF%dG%dH%dI%d", gx, gy, gz, ax, ay, az, mx,     my, mz);
Serial.println(dataPacket);

    }

gx gy gz .... these are the sensor reading variables

and in the receiving Arduino I use this code

void setup(){
    // Start up our serial port, we configured our XBEE devices for 9600 bps.
    Serial.begin(9600);
}

void loop()
{

    if(Serial.available() > 0)
{
     while(Serial.available() > 0)
 {
        char dataPacket[64];

for (int i = 0; i < 64; i++)
{
  dataPacket[i] = Serial.read();
 Serial.print(dataPacket[0]);

}

String show = Serial.readStringUntil('C') ;
delay(500);

}
}
}

but i can't split the values from the stream and put them into their variables (gx gy ...)

Does anyone have idea how to split it?


texts: Cannot program two arduinos at the same time because they both use the same COM port

texts:
I am not able to program my second arduino because they both use the same com port. In other words this picture says it all:

In order to upload my sketch I have to disconnect one arduino. How can I tell windows to use a different COM port?
It will be nice if I do not have to disconnect one arduino evey time I want to upload a sketch. I already restarted my computer and I get the same problem.


texts: How to wait Arduino ready with ANY method?

texts:
Recently I knew, that Arduino restarts any time somebody accesses it's serial port. I was trying to use this feature so that for each request Arduino restarts and give answer on request. Unfortunately, I found this is impossible with shell script, because shell script can't keep port open all time I send requests and wait responses: Arduino restarts on each port touch.

So, I wrote simple C++ program:

#include <iostream>
#include <fstream>

using namespace std;

void help() {
    cout << "bmp180dims usage:" << endl <<
            "bmp180dims port command" << endl;
}

int main(int argc, char* argv[]) {

    if( argc != 3 ) {
        help();
        return 0;
    }

    fstream port;
    string answer;

    port.open(argv[1], std::fstream::in | std::fstream::out);

    port << argv[2] << endl;

    port >> answer;

    cout << answer << endl;

    port.close();

    return 0;

}

Since this program has explicit open and close statements, I was thinking, this program will wait for Arduino answer, because of stream reading functions. But I failed again: this program returns nothing as if it is not waiting.

Why?

Apparently, the only way to communicate with Arduino, is to have daemon program, which always listen it's port. Is this really so?

Arduino-side code is here: How can program/arduino restarted by IDE?


texts: Hacking old car dvd monitors with arduino

texts:
I got this old junk LCD from my car. The DVD function stopped and the LCD holder on the top of the car broke, so I took it.

Is there any documentation or advice I could use to get this working with an Arduino mega or clone of similar power? I couldn't find anything after looking through Google.

I.e. I'm looking for a way to get a pinout or idea of what those wires on the jack are so that I might be able to get text and/or basic graphics on the screen. Maybe to make an Arduino PC or something idk.

Any advice on either figuring out the connections by hand and how to get a simple connection to the Arduino to get bsic stuff working or a place I can find pinout and such or where someone else has done something similar would be helpful.

Update 2
A quick Google search reveals that it's made by sharp I believe. I'm looking into it.

Update
Here's is the back. It's got quite a few numbers on it. Maybe one of those can help?

Top Numbers:
D 09399847
LQ070T5CRQ2 46009355

And the one on the bottom:
K4013TP


texts: 2.4Mhz clock for 3-wire SPI using Arduino Mega 2560

texts:
I am trying to develop an Arduino sketch for ADS8320 ADC IC, which is 3-wire SPI. I need a 2.4MHz serial clock for the SPI interface. I tried the code below, but I don't know how to generate clock pulses at 2.4MHz clock speed.

#define CLK 22
#define DBIT 24 // so
#define CS 26

#include <SoftwareSerial.h>

int v = 0;
float Ctemp, Ftemp;

void setup()   {
  Serial.begin(9600);
  pinMode(CLK, OUTPUT);
  pinMode(DBIT, INPUT);
  pinMode(CS, OUTPUT);
  digitalWrite(CS, HIGH);
  digitalWrite(CLK, LOW);
}

void loop()   {
  v = spiRead();
  if (v == -1)   {
    Serial.print("No sensor \n");
  } else   {
    Serial.println(Ftemp);
  }
  delay(100);
}

int spiRead() {
  int value = 0;
  digitalWrite(CS, LOW);
  delay(2);
  digitalWrite(CS, HIGH);
  delay(220);
  /* Bring CS pin low to allow us to read the data from
    the conversion process */
  digitalWrite(CS, LOW);
  /* 1st 5 clock cycles  */
  digitalWrite(CLK, HIGH);
  delay(1);
  digitalWrite(CLK, LOW);
  digitalWrite(CLK, HIGH);
  delay(1);
  digitalWrite(CLK, LOW);
  digitalWrite(CLK, HIGH);
  delay(1);
  digitalWrite(CLK, LOW);
  digitalWrite(CLK, HIGH);
  delay(1);
  digitalWrite(CLK, LOW);
  digitalWrite(CLK, HIGH);
  delay(1);
  /*
    Read bits 16-0 from ads8320 for the adc. Loop for each bit reading
    the value and storing the final value in 'adc'
  */
  for (int i = 16; i >= 0; i--) {
    digitalWrite(CLK, HIGH);
    value += digitalRead(DBIT) << i;
    digitalWrite(CLK, LOW);
  }
  // check bit D2 if HIGH no sensor
  if ((value & 0x04) == 0x04) return -1;
  // shift right three places
  return value >> 3;
}

'
i have added the code i tried with arduino spi library still i don't get any result

 // inslude the SPI library:
 #include <SPI.h>

 // set pin 10 as the slave select for the digital pot:
 const int slaveSelectPin = 10;

 void setup() {
 // set the slaveSelectPin as an output:
 pinMode(slaveSelectPin, OUTPUT);
 // initialize SPI:
 SPI.beginTransaction(SPISettings(2400000, MSBFIRST, SPI_MODE0))

 void loop() {
 while(1){
 spiread(slaveSelectPin);
 }
 }

 void spiread(int slaveSelectPin) {
 // take the SS pin low to select the chip:
 digitalWrite(slaveSelectPin, LOW);

 receivedVal = SPI.transfer(val);
// take the SS pin high to de-select the chip:
digitalWrite(slaveSelectPin, HIGH);
}


texts: I am using the Adafruit Motor Shield v2.3 for Arduino Uno. I am using the analogWrite() command to power my DC motor and have set the speed to 255. Is there any way to speed up the Arduino motor even further? Thanks!


texts: Hooking up LCD screens reclaimed from old camcorders to Arduino

texts:
Has anyone had any luck using LCD screens reclaimed from old electronics with Arduino, such as camcorders etc?

My 8 yr old has an old sony handycam (dcr-trv103) in bits and now wants to use the LCD screen with the arduino. I'm not even sure how I would go about this. Any tips? How do I figure out 'what does what' in terms of the inputs? How would I drive this thing / what do I need to do to send visual images to it via an Arduino?

Here's the front and back panels of the LCD screen, and their hookups.

The Screen

Screen hookup

I'm assuming this is the backlight

backlight hookup

Note: someone identified this as a duplicate of another question about reusing a cellphone LCD screen. This question is specifically about reusing an older camcorder LCD screen. Also that other question has very little answers. I found the answers below useful and educational. Thanks all.


texts:
I want to get the image from the fingerprint module (https://makeradvisor.com/tools/fingerprint-sensor-module/) as a result of scanning. It is enough to have a single frame image. it would be good if the computer can get image the output image from the serial port (as in linescan camera example: https://www.youtube.com/watch?v=welv4w8B88g   https://www.tindie.com/products/ap_tech/tsl1401cl-linescan-camera/)

I am open to your suggestions if it can be done in another module.


texts:
I have a few questions related to GPRS/GSM SIM900 Shield not working with Arduino.

To keep it short I have a list of concrete questions:

Is the Arduino GSM library compatible with the Geeetech GPRS/GSM SIM900 Shield?
On the board the green LED blinks every 3 seconds which I have read
means that it is connected. However, when I try to use any of the
GSM examples, in regard to internet, I either get error messages or
simply no progress in the program. For instance, in the testGPRS
sketch it sits stuck at the port where it says "Connecting GSM
network...". And in the bandManagement example sketch it can't find
the current band,as well as the modem not responding, well basically nothing works, except that the
shield itself indicates it is connected to a network.

The SIM card I'm using is data exclusively and can't be used for voice calls or SMS. It has no pin code and works as my secondary SIM card (it shares the same subscription as my primary card).

Edit:
I have now tested the SMS capabillities of the board with another simcard, that works with no problems, seems only the internet won't work.


texts:
I'm hoping that someone will be able to help me. I'm looking to produce a power interrupt for testing. I'm looking to have 28V DC input flowing to an output which I can hook up to a load and then switch on and off using an Arduino. I'm thinking of using an NPN high current transistor, I have built the box and code which runs fine. The issue I am having is the pin output on pin 13 doesn't have enough current to switch the transistor, can anyone recommend a transistor that would be able to take the high current and be switched by the Arduino? If you would like a schematic to help you understand it I can provide one!

Thanks for reading,
Lewis


texts:
I am trying to do this tutorial http://www.instructables.com/id/Chappie-Self-Balancing-Robot/  on building a self-balancing robot with uno. However, I bothered by the Bluetooth wiring. I've done Arduino projects with Bluetooth before and all the Hc-05 wirings I've seen have it connected to the Tx and Rx pins.Currently, I have my Bluetooth module wiring like this :   with http://cdn.instructables.com/FSK/AI30/HMMFE6UO/FSKAI30HMMFE6UO.MEDIUM.jpg.
Will the different wiring need a different implementation, the code I see on the chappie instructable link does not have any pin mentions but I'm not sure. Is the chappie wiring fine? should I change my wiring? should I change my code?
I'm confused.


texts: MQTT connection not being recognised in void loop()

texts:
I am trying to publish MPU 9250 readings in the Adafruit IO sending the data from ESP32. The WiFi connection is being established, but the code is not going inside the if(mqtt.connected()) inside the void loop() whereas it's going inside the same command inside the void setup().
I am sure there are no connection issues because once I change if(mqtt.connected()) to while(mqtt.connected()) inside setup(), code is going inside the while loop continuously.
Why is the code not going inside the if command and how can this be solved?
#include <WiFi.h >
#include <Adafruit_MQTT_Client.h>
#include <MPU9250.h>

#define wifi "********"
#define password "********"
#define server "io.adafruit.com"
#define port 1883
#define username "*******"
#define key "********"

WiFiClient esp;
MPU9250 IMU(Wire,0x68);
Adafruit_MQTT_Client mqtt(&esp, server, port, username, key);
Adafruit_MQTT_Publish feed = Adafruit_MQTT_Publish(&mqtt, username"feeds/accelerodata");

void setup() {
  Serial.begin(115200);
  delay(10);
  Serial.println("Adafruit MQTT Demo");
  Serial.println("Connecting to");
  Serial.println(wifi);
  WiFi.begin(wifi,password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.println("Connecting...");
  }
  Serial.println("Connected");
  Serial.println("IP Address: ");
  Serial.println(WiFi.localIP());
  Serial.println("Connecting to MQTT");

  if (mqtt.connect()) {
    Serial.println("MQTT Connected");
  }
}

void loop () {
  Serial.println("Test line to check if code reaches inside loop");
  delay(1000);

  if (mqtt.connected()) {
    int data=IMU.getAccelX_mss();
    Serial.println("\nSending accelero data");
    Serial.println(data);
    Serial.println("....");
    if (feed.publish(data)) {
      Serial.println("Success");
    } else {
      Serial.println("Fail");
    }
    delay(800);
  }
}


texts: Record Ping time using ultrasonic sensors and calculate speed

texts:
I'm trying to find the speed of remote control toy car passing by two ultrasonic sensors. I need help on my code and suggestion on max speed car should go to record time. Opposite direction not accounted for and ideally the car would pass by both sensors without stopping. I know laser reading is better for this simulation but I need it for a presentation in two weeks.

Here are the steps I was recommended to use:

Get the duration of pulse for sensor 1 and convert to distance
if the distance the object is within the desired threshold (you detected something)
2a. record the system time at which object was detected
2b. start a loop to for sensor 2
Within the sensor 2 loop keep getting the duration/distance until an object is detected or too much time has passed
If an object is detected record the system time
Subtract the two system times (from sensor 1 and 2) and use that to determine object speed

#define sensor_distance .111 //distance between two sensors in meters
const int trigPin1 = 3;
const int echoPin1 = 4;
const int trigPin2 = 5;
const int echoPin2 = 6;

double first_time = 0;
double second_time = 0;
double final_time = 0;

double vehicle_speed = 0;

void setup() {

  pinMode(trigPin1, OUTPUT);
  pinMode(echoPin1, INPUT);
  pinMode(trigPin2, OUTPUT);
  pinMode(echoPin2, INPUT);

  Serial.begin(9600);
}

void loop() {

double ping_time(int trig1, int echo1, double first_time);
double ping_time(int trig2, int echo2, double second_time);

final_time = second_time - first_time;
vehicle_speed = sensor_distance/final_time;
}

double ping_time(int trig, int echo, double record_time) //function used to record time.
{
  long duration, distance;

   digitalWrite(trig, LOW);
  delayMicroseconds(2);
  digitalWrite(trig, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig, LOW);

  duration = pulseIn(echo, HIGH);
  distance = duration * 0.034 / 2;

  if (distance < 35) {
    Serial.print(distance);
    Serial.println("  cm");
    record_time = millis();
    record_time = record_time/100; //Divided by 100 to get time in seconds

    return record_time;

  }
  if (distance > 35) {
    Serial.println("OUT OF RANGE");
  }
  delay(20);
}


texts:
I am probing the SPI Clock pin 13 with my analog discovery 2. Nothing else is connected. The clock signal is there but it rises over time. (see picture) Here is my code:
#include <SPI.h>
void setup() {
  // put your setup code here, to run once:
  SPI.begin();
  SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE0));
  pinMode(8, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(8,LOW);
  SPI.transfer(0xF7);
  SPI.transfer(0xFF);
  digitalWrite(8,HIGH);
  delay(500);

}

What do you think is causing this? Thanks


texts: Greyed out port for Raspberry pico in Arduino IDE - Ubuntu 20.04

texts:
I'm trying to figure out how to program my new Raspberry Pico with Arduino, but don't see a port to select so I can't upload the blink sketch.
Here's what I've done:

The Pico is working, I can program it with micro Python.
Just in case, I brought the Pico back to factory settings with the nuke file.
Installed support for the Pico in Arduino IDE. Version 2.1.0 of Arduino MBed RP2040 is installed.
While keeping BOOTSEL pressed, I plug in the Pico to my laptop (Ubuntu 20.04)
The board selected is "Raspberry Pi Pico"
But the option to select a port is greyed out :-(

It seems that I am omitting some step during the installation, but can't figure out what it is.
Any ideas?
Thanks!


texts:
Folks,
There is a document named "Complete Guide for RF 433MHz Transmitter.pdf" available in the GitHub.
There is a a connection diagram showing the Data pin of the Transmitter connected to the pin 12 of the Arduino Uno.
The Transmitter sketch given in it is as follows:
#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile

RH_ASK driver;

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

void loop()
{
 const char *msg = "Hello World!";
 driver.send((uint8_t *)msg, strlen(msg));
 driver.waitPacketSent();
 delay(1000);
}

There is no mention of Pin 12 as part of the sketch. I am not sure how the Arduino knows the Transmitter Data input is connected to the Pin 12? Can someone please help?
Ranjith


texts: Why are my sensors not working (the reaction time is so slow)?

texts:
//testing the light sensor;
int sensor=A0; // setting as input is by default;
int sensorval;
int pin=13;

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

void loop() {
  // put your main code here, to run repeatedly:
  sensorval=analogRead(sensor);
  Serial.println(sensorval);
  if(sensorval>900)
    digitalWrite(pin,HIGH);
  else  digitalWrite(pin,LOW);
    delay(1000);
}

I am using a photocell, a temperature sensor and a potentiometer with an Arduino Uno and it always gives me 1023 0 1023 0 1023 0 1023 ....... All my wires are connected properly and I tried all this stuff online and they are working correctly.


texts:
im using arduino uno r3, motor drive shield tle94112el, geared motors, ir remote and hall sensors. i wanna rotate the motor 120 degrees by pressing a button on the remote, and when one of the tree magnets is close to the hall sensor, i want the motor to stop. the code i attached here works but just for one movement cose the magnet is still close to the sensor whe i press that button again and doesnt let it move. i tried using delay bet this delay was aplied betwenn the moment i pressed the button an the moment of the activation of sensor, as i wanted, but was also aplied between the moment when sensor detected the magnet and the moment when the motor stopped and introduced a semnificative error. please, any ideas how can i fix this?
#include <TLE94112.h>
#include <Tle94112Motor.h>
#include <IRremote.h>

#define sound 0x55
int RECV_PIN = 2;
int hallSensorPin = 3;
int state ;

Tle94112 controller = Tle94112();
Tle94112Motor motor1(controller);

IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
    pinMode(hallSensorPin, INPUT);
   irrecv.enableIRIn();
   controller.begin();

  motor1.connect(motor1.HIGHSIDE, controller.TLE_HB1);
  motor1.connect(motor1.LOWSIDE, controller.TLE_HB2);
  motor1.setPwm(motor1.HIGHSIDE, controller.TLE_PWM1);
  motor1.setPwmFreq(motor1.HIGHSIDE, controller.TLE_FREQ200HZ);
  motor1.begin();
}
void loop()
{

  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
    if(results.value==sound||results.value==0x55||results.value==0x2103||results.value==0x837||results.value==0x37){

  motor1.start(-63);
}
 }
  state = digitalRead(hallSensorPin);
 if (state == LOW){
  motor1.coast();
  }
  }


texts: Is there any way to group variables like group.variable as you can in Java/Delphi

texts:
I'm writing a sketch which does some calculations on measured variables, and it's based on a similar program written in Java like
c = A.Ux + B.Uz;
Where A&B have various parameters Ux,Uy,Uz etc
In Delphi this notation can be used either for parameters of classes or variables in a group. Looks like there's something similar in Java. It's a tidy way to organise and manipulate variables when there are lots of them and move them between methods without having huge numbers of arguments.

Is there any way to do this in the Arduino Wiring language? I don't seem to find anything online, but I'm probably phrasing the question wrong.
Thanks in advance, Brian


texts: Adding a common activation pin to a group of buttons

texts:
I'm working on an Uno, which has only two interrupt capable pins, but i need at least three buttons to wake it up from its power saving mode.
Is there a way to wire buttons such that, in addition to their individual pin, they will also activate a common pin (in this case, the interrupt one)?


texts: Adafruit Trinket & Ultimate GPS & Google Earth Realtime

texts:
I'm using a 5v Pro Trinket that has an Adafruit Ultimate GPS connected and is connected over serial to my laptop. I am not using any fancy parsing code, I'm just letting the GPS spit out the raw data. When I connect to it over the Arduino Serial Monitor, I get all the GPS info and it's highly accurate. I have also tried the Mini GPS v1.4 program and that seems to work really well too.

However, for some reason when I try to get a live feed in Google Earth (and I also have the check box that allows Google Earth to automatically follow the path), it doesn't actually do anything. After starting the feed over serial, I get this message for four seconds: "Reading COM3" and then for a split second I get: "Reading COMPOSITEBUS#MS_IMPLAT_MP#{B17FDEA3-E8A2-45B0-8CAC-85938CA04809}#{ad498944-76f-11d..." The string goes for several more numbers and such (I'm not sure if that's important, I will post the whole string if needed).

Does anyone know what's going on here? Have I missed a step to make the raw data more compatible?

Thanks in advance!
-M2com


texts:
Does anyone know what the I/O line voltage level is on the Tinyduino?

Tinyduino

I want to run a MAX7219 LED array with it, like this one:

LED Array


texts: Do I need the Motor Shield to drive servo motors?

texts:
I was perusing Arduino's list of official shields and noticed the Motor Shield that can be used to drive up to 2 servo motors.

Being brand new to Arduino/robotics, I am wondering: do I really need this shield to drive a set of servos?

What does this shield really offer in the way of driving motors?
What is lost by not using this shield?
What if I my project has more than 2 motors?!?


texts: Can I have help interperting this code? char variable somehow storing big numbers

texts:
I have this GSM module I got for my arduino project and I am trying to access the call feature, but the function makes no sense.

  boolean Adafruit_FONA::callPhone(char *number) {
  char sendbuff[35] = "ATD";
  strncpy(sendbuff+3, number, min(30, strlen(number)));
  uint8_t x = strlen(sendbuff);
  sendbuff[x] = ';';
  sendbuff[x+1] = 0;
  //Serial.println(sendbuff);

  return sendCheckReply(sendbuff, "OK");
  }

This is the function however how is char being used to display a phone number in the parameter?


texts: Arduino MKR GSM 1400 project - Establish call - Wait and hang call

texts:
I am implementing a GSM project using the Arduino MKR 1400 GSM board and I would like to achieve the following:
Establish a call to a specific number, wait for a certain amount of seconds and then hag the call. I have written the following test code in order to see how to manage it.
#include <MKRGSM.h>

// PIN Number
#define PINNUMBER ""

GSM gsmAccess;
GSMVoiceCall vcs;

void setup()
{

  Serial.begin(9600);

  boolean notConnected = true;

  // Start GSM shield
  // If your SIM has PIN, pass it as a parameter of begin() in quotes
  while(notConnected)
  {
    if(gsmAccess.begin(PINNUMBER)==GSM_READY)
      notConnected = false;
    else
    {
      Serial.println("Not connected");
      delay(1000);
    }
  }

  Serial.println("GSM initialized.");

  if (vcs.voiceCall(char_array_number)) {
    Serial.println("Call established");
    delay(10000);
  } else {
    Serial.println("Something is going wrong");
  }

}

void loop()
{

}

Well, the call is established, the phone rings but the instructions inside the if statement won't get execute. Instead I get the following Serial Monitor output.

I don't really understand why that happens because since the call is stablished the first if statement would be executed. I would really appreciate any help, since this is like the final step of my project and been struggling for some time.


texts:
Can someone help me? I'm using a sim7000e from Waveshare. One week ago it was working normally, but now it doesn't work at all; it even can't read the RX-TX communication.
#include <SoftwareSerial.h> //koneksi ke modem

#define TINY_GSM_MODEM_SIM7000
#define TINY_GSM_DEBUG SerialMon
#define BAUD 9600
#define SerialMon Serial

const byte rxpin = 2;
const byte txpin = 3;

SoftwareSerial SerialAT(rxpin, txpin); // RX, TX

That's  my code for connecting to the Arduino. I believe it from my Arduino, but I don't know if something wrong from Arduino.
My 5V (sim7000E) to 5V (arduino mega2560), GND to GND.
Because I'm using Putty on USB for reading my AT-cmd it doesn't and has some trouble.


texts: Is a variable declaration inside a loop static declaration or dynamic?

texts:
while(condition){
    Object object = new Object();
}

So my question is, will each iteration would create a different object in different memory location or it will overwrite the once created object every iteration.


texts: nRF24L01 6TXA_1RXA network + 6TXB_1RXB network with arduino

texts:
How to build nRF24L01 network shown above with arduino ?
SPI pins are shared between RXA,RXB and separate pins for both CE, CSN, IRQ.

Which nRF24L01 library supports my requirements ?


texts: Arduino weather station BMP280 and BM1750

texts:
im experiencing troubles with combining a arduino sketch with BMP280 and BM1750. At this moment i have 2 sketches which need to be combined.

#include Wire.h>
#include BH1750.h>

// ADDR line LOW/open:  I2C address 0x23 (0x46 including R/W bit) [default]
// ADDR line HIGH:      I2C address 0x5C (0xB8 including R/W bit)
BH1750 sensor(LOW);

void setup()
{
  Serial.begin(115200);
  Serial.println(F("BH1750 continues measurement basic example"));

  // Initialize I2C bus
  Wire.begin();

  // Initialize sensor in continues mode, medium 1 lx resolution
  sensor.begin(ModeContinuous, ResolutionMid);

  // Start conversion
  sensor.startConversion();
}

void loop()
{
  uint16_t lux;

  // Wait for completion (blocking busy-wait delay)
  if (sensor.isConversionCompleted()) {
    // Read light
    lux = sensor.read();

    // Print light
    Serial.print(F("Light: "));
    Serial.print(lux);
    Serial.println(F(" LUX"));
  }
}

and the BMP280

#include  Wire.h>
#include SPI.h>
#include Adafruit_Sensor.h>
#include Adafruit_BMP280.h>
#include ESP8266WiFi.h>
#include BH1750.h>

#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 11
#define BMP_CS 10

Adafruit_BMP280 bme; // I2C
BH1750 lightMeter;

/**************************
 *   S E T U P
 **************************/
void setup() {
  Serial.begin(9600);
  // Initialize the I2C bus (BH1750 library doesn't do this automatically)
  Wire.begin(D2,D1);
  // On esp8266 you can select SCL and SDA pins using Wire.begin(D4, D3);

  lightMeter.begin();
  Serial.println(F("BMP280 test"));
  if (!bme.begin()) {
    Serial.println("Could not find a valid BMP280 sensor, check wiring!");
  }

}

  /**************************
 *  L O O P
 **************************/
void loop() {

  uint16_t lux;

  // Wait for completion (blocking busy-wait delay)
  if (sensor.isConversionCompleted()) {
    // Read light
    lux = sensor.read();

    // Print light
    Serial.print(F("Light: "));
    Serial.print(lux);
    Serial.println(F(" LUX"));
  }
    Serial.print("T=");
    Serial.print(bme.readTemperature());
    Serial.print(" *C");

    Serial.print(" P=");
    Serial.print(bme.readPressure()/100);
    Serial.print(" hPa");

    Serial.print(" A= ");
    Serial.print(bme.readAltitude(1013.25)); // this should be adjusted to your local forcase
    Serial.println(" m");
    //every 20 sec
    delay(2000);
}

The BMP part is working fine.


texts: Looking for information and/or how to connect the RF433Mhz module (WL101-341/WL102-341)

texts:
I'm trying to find information about this 433MHz RF module: QIACHIP

Apparently it can be connected to an Arduino with the RadioHead library, but I don't have diagrams of how to connect them togheter in order to send/recieve data, becasue the module have 4 pins (Vcc, Gnd, Dat and En). I guess Dat pin should be connected to any Arduino pin, but as I only have one module I dont wanna risk it. I have no previous experience with RF modules :-(
I have found some Youtbe video, but the language of the video is in russian, and I don't know that langauge (I even ask the owner of the chanel for subtitles).
Please, if anyone have worker whit this module before, share:

How to connect the module with an arduino?
A simple example of how to send a simple word (let's say: "Hello") from the transmitter to the reciever


texts: Compare barcode scanner string with existed string

texts:
I have a project which is reading barcode scanner result then compare with an existed string. I have used the library USB host shield in order to read data from barcode scanner then I would like to compare the code from barcode with an existed code which I will define in an array. My approach is store the arrives data into buffer then compare the buffer but I have failed for several trials.
Here is my code:

#include <hidboot.h>
#include <usbhub.h>

// Satisfy IDE, which only needs to see the include statment in the ino.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#endif
#include <SPI.h>

USB Usb;
USBHub Hub1(&Usb);
USBHub Hub2(&Usb);
HIDBoot<USB_HID_PROTOCOL_KEYBOARD> HidKeyboard(&Usb);

  uint8_t i;
  class KbdRptParser : public KeyboardReportParser
{

protected:
    void OnKeyDown  (uint8_t mod, uint8_t key);
    void OnKeyPressed(uint8_t key);
};

void KbdRptParser::OnKeyDown(uint8_t mod, uint8_t key)
{
    uint8_t c = OemToAscii(mod, key);
    if (c)
        OnKeyPressed(c);
}

/* what to do when symbol arrives */

 void KbdRptParser::OnKeyPressed(uint8_t key)
{
  const char* new_line = "\n";
  uint8_t rcode;
  uint8_t keylcl;
  char buffer [12];
    keylcl = key;
    int a = (int) char (keylcl);
    a = a - 48;

    buffer[i] = a;
    i++;
    Result = char(a);
    Serial.print(Result);
};
KbdRptParser Prs;

void setup()
{
  Serial.begin(115200);
#if !defined(__MIPSEL__)
  while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
  Serial.println("\r\nADK demo start");

  if (Usb.Init() == -1) {
    Serial.println("OSCOKIRQ failed to assert");
    while(1); //halt
  }//if (Usb.Init() == -1...

  HidKeyboard.SetReportParser(0, &Prs);

  delay( 200 );
}

void loop()
{
  Usb.Task();
}


texts: Control DC Motor with Arduino Uno WiFi Rev2 Html Slider Code

texts:
I would like to control my dc motor using the Arduino Uno WiFi Rev2 using an html range slider. Now I can control the motors speed and direction using push buttons just fine. My code is posted below of what I've done so far.

client.println("");
client.println("<input type=\"range\" class=\"class-name\" orient=\"vertical\" id=\"range\" min=\"0\" max=\"255\" step=\"0\" onchange=\"motor1(this.value)\" value=\"0\">");

This code below is the current button code. I need the below code to be used by the slider code above:

if (currentLine.endsWith("GET /MONFWD")) {
digitalWrite(MOTOR_A_ONE, HIGH);  // Establishes forward direction of Channel A
digitalWrite(MOTOR_A_TWO, HIGH);  // ENGAGE BRAKE
delay(1000);                      // DELAY BEFORE RELEASING BRAKE
digitalWrite(MOTOR_A_TWO, LOW);   // Disengage the Brake for Channel A
analogWrite(MOTOR_A_ENGAGE, 255); // Spins the motor forward on Channel A at full speed


texts:
Novice mode, please.

I programmed my ATTiny84 using Arduino Ethernet (Arduino IDE 1.6.7) using https://github.com/damellis/attiny branch - 1 MHz internal oscillator mode. I uploaded ISP sketch to Arduino with all cables disconnected (first I did it with all of them connected but Arduino didn't seem to mind), connected the whole setup using 10 uF capacitor and the sketch got sent into ATTiny84 without problems.

Blink sketch is using atttiny84's digital pin 7 (that is physical leg No. 6) set to 1 s blink rate.

But, when I connect an yellow LED, it won't blink. I'm not yet good enough with my oscilloscope (don't know how to hook it up) but my multimeter is showing something weird - voltage is slowly rising on DP7 (I measured against ground) - over approx. 5-6 seconds to 400 mV, then immediately jumps to 1V (not sure about this, could be measurement bug) and then right to 0V.

Blink sketch:

int led = 7;

// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

I'm clueless. Please confer.
Thank you.

Images of my setup:


texts: Is SPI a good way to connect two rfid modules on separate arduino boards?

texts:
RFID access control

I have two separate rfid projects on separate arduino, the first project requires 2 minutes of contact between the tag and the reader after which it turns the LED on. the second project is a simple rfid access control, but on this access can only be granted if the conditions on the first tag were met. I am trying to use SPI for this but do not know if it would work, any suggestions on any other way of communication between two arduino boards?


texts: How to interpret accelerometer output data?

texts:
I'm running my accelerometer through my Arduino mini and outputting my values using the following values

 // print the sensor values:
  Serial.print(analogRead(xpin));
  // print a tab between values:
  Serial.print("\t");
  Serial.print(analogRead(ypin));
  // print a tab between values:
  Serial.print("\t");
  Serial.print(analogRead(zpin));
  Serial.println();
  // delay before next reading:
  delay(100);

Here's an example.

The x,y,z values that are outputted are quite high even the arduino is not moving. I'm new to Arduino programming and would love some understanding on how to convert these x,y,z to an Acceleration value ie. Is the arduino moving or not?


texts: How to close humidity sensor at specific humidity

texts:
I am using dht humidity and temperature sensor on arduino and i would like to add relay and buzzer on the system. What I would like to do is to close it via buzzer and on 65% humidity run buzzer. The code i use is:
/* DHT-22 sensor with 12c 16x2 LCD with Arduino uno
   Temperature and humidity sensor displayed in LCD
   based on: http://www.ardumotive.com/how-to-use-dht-22-sensor-en.html and
   https://www.ardumotive.com/i2clcden.html for the i2c LCD library by Michalis Vasilakis
   Recompile by adhitadhitadhit
   Notes: use LCD i2c Library from link above, i'm not sure why but new Liquidcristal library from Francisco Malpartida  isn't working for me
   other thing, check your */

//Libraries
#include <dht.h> // sensor library using lib from https://www.ardumotive.com/how-to-use-dht-22-sensor-en.html
#include <LiquidCrystal_I2C.h> // LCD library using from  https://www.ardumotive.com/i2clcden.html for the i2c LCD library
#include <Wire.h>
dht DHT;

//Constants
#define DHT22_PIN 2     // DHT 22  (AM2302) - pin used for DHT22
LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 after finding it from serial monitor (see comment above) for a 16 chars and 2 line display

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

void setup()
{
    Serial.begin(9600);
    lcd.init();                      // initialize the lcd
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setBacklight(HIGH);
}

void loop()
{
    int chk = DHT.read22(DHT22_PIN);
    //Read data and store it to variables hum and temp
    hum = DHT.humidity;
    temp= DHT.temperature;
    //Print temp and humidity values to LCD
    lcd.setCursor(0,0);
    lcd.print("Humidity: ");
    lcd.print(hum);
    lcd.print("%");
    if (humidity <= 50)
{
   digitalWrite(ledPin, HIGH);
   digitalWrite(buzzer, HIGH);

 }

 else

 {

 digitalWrite(ledPin, LOW); digitalWrite(buzzer, LOW);

    lcd.setCursor(0,1);
    lcd.print("Temp: ");
    lcd.print(temp);
    lcd.println("Celcius");
    delay(2000); //Delay 2 sec between temperature/humidity check.
}

How to add relay and buzzer to close it with buzzer run on 65% humidity value?


texts: Printing bitmap image from thermal printer using Serial input

texts:
I want to print Bitmap image from thermal printer, but image data is from Serial Input. But I am not getting valid print. What wrong i am doing ?

Here is code i wrote

#include "Adafruit_Thermal.h"
#include "SoftwareSerial.h"
// PIN 6 -> Yellow
// PIN 5 -> Green
// GND -> Black

#define TX_PIN 6
#define RX_PIN 5

SoftwareSerial mySerial(RX_PIN, TX_PIN);
Adafruit_Thermal printer(&mySerial);

int count =0;
void setup() {
  pinMode(7, OUTPUT);
  digitalWrite(7, LOW);
  mySerial.begin(9600);  // Initialize SoftwareSerial
  printer.begin();        // Init printer (same regardless of serial type)

  Serial.begin(9600);
  Serial.print("1");

  //printer.printBitmap(384, 5, image);

  //printer.feed(2);

  printer.sleep();      // Tell printer to sleep

  delay(3000L);         // Sleep for 3 seconds
  printer.wake();       // MUST wake() before printing again, even if reset
  printer.setDefault(); // Restore printer to defaults
}

void loop() {
    if(Serial.available()>48){
      uint8_t image[50];
      Serial.readBytes(image,48);
      printer.printBitmap(384, 1, image);
    }

}


texts:
I accidentally short-circuited my Arduino mega(ended up connecting the 5V and ground pins). Physically from observation nothing seems to be burnt on the board but I am not able to upload new codes to it again. I am quite sure that the last code I uploaded still run on it because when I plug it in all seems to be normal.
I tried to upload codes to it with the CP2012 programmer I use for my pro mini and that doesn't help either.
Is there any way I can manage to upload codes to the board again or it is dead?


texts: Arduino Ethernet Shield Response Process, Time, and Synchronization

texts:
I have a ethenet shield. I want to update my server page. Server page have to show current time. The code is given in this link. Code works but there is two problem

1- When i press the stop button in the browser, Arduino stops. After this i press refresh button and there is no response.

2- How can i synchronize the arduino time. From where? without setup another server. Is there any time stamp server that compatible with arduino?


texts: Sending sensor readings from Arduino to Raspberry Pi over 433 MHz

texts:
I'm building a garden monitor, so I got myself an Arduino Nano, a soil humidity sensor, an air humidity and temperature sensor as well as a luminosity sensor. Since I had not one but two Raspberry Pis laying around I thought I'll handle the receiving end with one of them. I also got a 433 MHz RF kit.

The trail of the information will look like this: Sensor(s) -> Arduino -> 433 MHz Transmitter - - - 433 MHz - - - 433 MHz Receiver -> Raspberry Pi

Now my question is, what libraries should I use? I checked rc-switch (it has libs for both Arduino as well as RPi) and managed to send some codes but it seems that I'll need to write my own protocol to use this to transmit even simple data as it wasn't developed for sending data, rather simple switch on / switch off signals to simulate remotes.

VirtualWire would seem as the ideal candidate but the problem is it doesn't have an RPi equivalent.

Any suggestions?


texts: How to light up RGB Leds at the exact same time?

texts:
I have 2 sets of RGB Leds, each set is driven by 3 OUTPUT analog pins of the arduino, as illustrated below:

The code is supposed to put on HIGH the 6 analog pins at the same time so that the Leds light up all at the same time, but when I run it, there's a latency between the 2 groups of Leds.
Here's the code:
const int r[2] = {3, 9};
const int g[2] = {5, 10};
const int b[2] = {6, 11};

const int red[3] = {255, 0, 0};
const int green[3] = {0, 255, 0};
const int blue[3] = {0, 0, 255};

int* colors[3] = {red, blue, green};

void setup() {
    for(int i=0;  i<2; i++){
        pinMode(r[i], OUTPUT);
        pinMode(g[i], OUTPUT);
        pinMode(b[i], OUTPUT);
  }
}

void setColor(int r, int g, int b, int color[]){
    int R = 255 - color[0];
    int G = 255 - color[1];
    int B = 255 - color[2];
    analogWrite(r, R);
    analogWrite(g, G);
    analogWrite(b, B);
}

void loop() {
    for(int c=0; c<3; c++){
      setColor(r[0], g[0], b[0], colors[c]);
      setColor(r[1], g[1], b[1], colors[3-c-1]);
      delay(1000);
    }
}

I should point out that the values of the resistors are in my circuit are different than in the diagram.
Is there something wrong in the wiring or in the code that prevents the Leds from wiring all at the same time?
EDIT: I tried the code one more time on the arduino and all Leds lit up at the same time. That happened in the past, but sometimes there's just a latency that I can neither explain nor fix...


texts: Why digital pin not reading ON from push button switches connected to 5V and pull-down 10K resistor?

texts:
Here's my circuit:

And the code:

//pins
const int control1 = 2;
const int control2 = 3;
const int enable = 9;
const int pinDirection = 4;
const int pinOnOff = 5;
const int pot = A0;
//states
int stateOnOff = 0;
int stateOnOffPrev = 0;
int stateDirection = 0;
int stateDirectionPrev = 0;

int motorEnabled = 0;
int motorSpeed = 0;
int motorDirection = 1;

void setup(){
  pinMode(pinDirection, INPUT);
  pinMode(pinOnOff, INPUT);
  pinMode(control1, OUTPUT);
  pinMode(control2, OUTPUT);
  pinMode(enable, OUTPUT);

  digitalWrite(enable, LOW);
  Serial.begin(9600);
}

void loop(){
  stateOnOff = digitalRead(pinOnOff);
  delay(10);
  stateDirection = digitalRead(pinDirection);
  motorSpeed = analogRead(pot)/4;

  if(stateOnOff != stateOnOffPrev){
    if(stateOnOff == HIGH){
      motorEnabled = !motorEnabled;
    }
  }

  if(stateDirection != stateDirectionPrev){
    if(stateDirection == HIGH){
      motorDirection = !motorDirection;
    }
  }
Serial.println(stateDirection);
  if(motorDirection == 1){
    digitalWrite(control1, HIGH);
    digitalWrite(control2, LOW);
  }else{
    digitalWrite(control1, LOW);
    digitalWrite(control2, HIGH);
  }

  if(motorEnabled == 1){
    analogWrite(enable, motorSpeed);
  }else{
    analogWrite(enable, 0);
  }

  stateDirectionPrev = stateDirection;
  stateOnOffPrev = stateOnOff;

}

As you can see, the switch on pin 5 controls whether the motor is on and the potentiometer controls motor speed. Both work.

However, when the switch on pin 4 is closed the stateDirection variable still reads 0, or open circuit. It should when pressed change the direction of the motor via the H-bridge. I've tried everything I could, new switches, higher resistance. The only time it read HIGH is when I literally plugged switch out to GND.

Serial shows stateDirection as an unending chain of zeroes.

And finally the schematics from the original project.

Thank you.

**PS: Forgive for lack of comments! But I think a good Arduino programmer should not need comments. **


texts: USB control panel with endless turn knobs

texts:
I understand that some arduinos are capable of presenting themselves as a USB HID device to a PC.

I would like to use one to build a custom input controller that lets me read maybe 8 or so turn knobs that can infinitely turn left and right.

I am new to Arduino, but have cross-compiled avr binaries before.

Which arduino would be a good choice for this? And any additional parts that would help?

The end product would look like a MIDI mix panel, but it shouldn’t talk MIDI, just USB HID (to a linux PC.)

Note: there is an expensive, and out of stock, device that is similar to what I have in mind called MIDI Fighter Twister, pictured below, to get an idea.


texts: RobotDyn's UNO+WiFi R3 ATmega328P+ESP8266, 32Mb flash, USB-TTL CH340G, Micro-USB

texts:
I'm trying to use this board ([as shown on manufacturer's site][1]

I managed connecting each one and uploading a minimal sketch.
I conducted a test ( using appropriate sketch on each one and a wire between corresponding GPIOs) - that setting HIGH and LOW on ESP to light BUILTIN_LED on ATMega, when working in "Independent Mode".

So Both baords work work OK with and without each other. BUT:

When uploading a generic Wifi sketch to ESP - it boots OK, seeking for Wifi, but does not connect.

I'll appreciate help/ exaplnation on ESP8266+Uno mode, that they interact with each other. What does it mean (witch pins interact ) and how can Wifi can be shared.

Guy
[1]: https://robotdyn.com/uno-wifi-r3-atmega328p-esp8266-32mb-flash-usb-ttl-ch340g-micro-usb.html


texts: SMlib State Machine Library not working as expected

texts:
I have the following setup and sketch.

The problem is that when I click the button it works sometimes, but other times it executes On Off straight after On as if it's executing twice.

This is after pressing the button only 7 times:

Off
On
Off
On
Off
On
Off
On
Off

I thought that was the whole point of a state machine? That it continues to execute the next state (not multiple times at random).

Very very confused with this one.

//http://www.arduino.cc/playground/uploads/Code/FSM.zip
#include <FiniteStateMachine.h>
//http://www.arduino.cc/playground/uploads/Code/Button.zip
#include <Button.h>
//http://www.arduino.cc/playground/uploads/Code/LED.zip
#include <LED.h>

const byte NUMBER_OF_STATES = 2; //how many states are we cycling through?

//initialize states
State On = State(ledOn);
State Off = State(ledOff);

FSM ledStateMachine = FSM(On);     //initialize state machine, start in state: On

Button button = Button(2, INPUT_PULLUP); //initialize the button (wire between pin 12 and ground)
LED led = LED(13);                 //initialize the LED
byte buttonPresses = 0;            //counter variable, hols number of button presses

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

//poor example, but then again; it's just an example
void loop(){
  if (button.uniquePress()){
    //increment buttonPresses and constrain it to [ 0, 1 ]
    buttonPresses = ++buttonPresses % NUMBER_OF_STATES;
    switch (buttonPresses){
      case 0: ledStateMachine.transitionTo(On); Serial.println("On"); break;
      case 1: ledStateMachine.transitionTo(Off); Serial.println("Off"); break;
    }
  }
  ledStateMachine.update();
}

//utility functions
void ledOn(){ led.on(); }
void ledOff(){ led.off(); }
//end utility functions


texts:
I'm writing some code for Arduino and I'm not sure if I'm checking the value of this character variable correctly. Can you please tell me if this is correct:

const char* front = "front";
const char* back = "back";

eyeballs(front);
eyeballs(back);

void eyeballs(const char* frontOrBack){

if (frontOrBack == "front") {
    digitalWrite(frontEyes, LOW);}//end if
  else if (frontOrBack == "back") {
    digitalWrite(backEyes, LOW);}//end else*/
}


texts: How to embed a 5V-range Arduino-based controller in a 12V-range DC circuit?

texts:
We have an installation that provides:

a common line (C), which divides into two wires;
an input line (I), which carries the signal from a button (between I and C there's normally 0V, and 12V when the button is pressed);
an output line (O), which carries a signal to a bell (between O and C there's always 12V).

simulate this circuit – Schematic created using CircuitLab

A controller is to close the OC circuit every time a given temporal pattern shows in I (say, a concrete Morse-like -short/long- sequence of pulses), so the bell will ring if the concrete word is recognized at the input. Such a controller has been implemented in C++ and uploaded to an Arduino Nano, and it works fine on a protoboard, with a button as input and led as output, all in the same electrical range.

Since both the IC and the OC are 12V circuits, and the controller is in the 5V range, what is the minimal circuit to embed the controller between the IC and the OC circuits?


texts: How to use a grove speaker without using delayMicroseconds?

texts:
is there another way to replace delayMicroseconds(BassTab[note_index]) as I cannot have delays in my loop due to the need of having multi-tasking in my sketch.

Grove speaker: http://www.seeedstudio.com/depot/Grove-Speaker-p-1445.html

/*macro definition of Speaker pin*/
#define SPEAKER 8

int BassTab[]={1911,1702,1516,1431,1275,1136,1012};//bass 1~7

void setup()
{
  pinMode(SPEAKER,OUTPUT);
  digitalWrite(SPEAKER,LOW);
}
void loop()
{
    sound(5);
    delay(5000); //Wait 5second and play the sound again
}

void sound(uint8_t note_index)
{
  for(int i=0;i<100;i++)
  {
    digitalWrite(SPEAKER,HIGH);
    delayMicroseconds(BassTab[note_index]);
    digitalWrite(SPEAKER,LOW);
    delayMicroseconds(BassTab[note_index]);
  }
}


texts: I am doing a wireless rover using arduino mega 2560 that can be controlled by a smartphone and a PC. Which bluetooth module would fit me? Again I want to control it both by my Laptop(Built-in Bluetooth) and my smartphone. Thanks in advance.


texts: When connecting, client.connect() returns 0

texts:
I'm using an arduino UNO with ethernet shield. When following a few guides online for a school project I came across this issue. First code sample:

    #include <SPI.h>
    #include <Ethernet.h>

    EthernetClient client;

    byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
    IPAddress ip(192, 168, 1, 25);
    byte server[] = { 64, 233, 187, 99 }; // Google

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

    void loop() {
      if (client.connect(server, 80)) {
        Serial.println("connected");
        client.println("GET /search?q=arduino HTTP/1.0");
        client.println();
      } else {
        Serial.println("connection failed");
        Serial.println(client.connect(server, 80));
      }
    }

This doesn't work unfortunately. We successfully connect to our network, but client.connect() doesn't work and returns 0. Expected result:

SUCCESS: 1
TIMED_OUT: -1
INVALID_SERVER: -2
TRUNCATED: -3
INVALID_RESPONSE: -4

According to the documentation it shouldn't be able to return this. Why wouldn't this work? Thanks in advance.


texts: Connecting STM32F103C through USB as well as external power supply

texts: What will happen if I connect a STM32F103C board to a USB as well as an external power supply? Will it work? Does the STM32 decide which power source to consider?


texts: No programmers available for this board - Programming ESP32 Cam with Ardunio IDE

texts:
This is my first time working with ESP32 Cam boards.
I have followed the instructions as given in this site https://technoreview85.com/how-to-program-esp-32-cam-using-arduino-uno-board/
However my IDE doesn't display any programmers for this board.

Couldn't find any details about this in google. I just want to know how I could fix this problem(i.e. get the programmers listed).
Thanks in advance.


texts: Arduino Mega 2560 Only Powers on with USB

texts: I have an Arduino Mega 2560 board running a ramps 1.4 shield for a 3D printer.  For some reason, I can only power the Mega with USB.  It does not get power from the ramps shield and it also will not power on when plugged in to a 12v wall adapter.  I know all power sources are working because I have a second Mega that works fine on all.  What could I check on the Mega board to help figure this out.  Other than being powered only by USB, everything else works as expected with no problems.


texts: Electret microphone board strange offset using Arduino

texts:
I'm experimenting with an electret microphone, specifically this one.  I put it on my scope and I see what I expect - a really small voltage, typically under 20mV, that varies appropriately with sound.

However, when I put it into my Arduino (connecting signal pin to A0, V to 5V, and G to GND) and read it using analogRead on the appropriate pin, I end up getting a strange offset.  The analog read should read 0 more or less constantly, due to the low voltage coming out of the board.  However, I get an offset of around 425 counts on the ADC, implying that the voltage is somewhere around 2.5V.

What's going on?  Why would the arduino be reading a voltage when there isn't any?


texts: Internal volts in arduino for percent battery

texts:
I'm working on a small project that is creating me a headache. I know arduimo (ATmega 328P .... etc. ..) has an internal voltage source code millivolts, but I would like to know how the full source code become percentage where 3 volts = 0%  and 4.2 volts = % 100% ??? . I appreciate the help because in codes is not my forte. I leave the code so Help me complete. Thank you.

long readVcc() {
  long result;
  // Read 1.1V reference against AVcc
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
  delay(2); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Convert
  while (bit_is_set(ADCSRA,ADSC));
  result = ADCL;
  result |= ADCH<<8;
  result = 1126400L / result; // Back-calculate AVcc in mV
  return result;
}

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

void loop() {
  Serial.println( readVcc(), DEC );
  delay(1000);
}


texts: nRF24L01+ packet loss caused by Arduino reading and communicating with sensors

texts:
I have 2 Arduinos communicating with each other. My problem is that one sends packets every 1.5-2 seconds but the other Arduino does sensor reading and data uploading with a Wifi module, which may take up to 5 seconds until the next time the nRF24L01+ is available to receive data.

This results in about 4 packet losses and if I am lucky sometimes 2. Is there any way that when the nRF24L01+ sends data, the other Arduino stops everything to get the data? Like a communication between these two Arduinos that will be open 24/7, so that the other Arduino can multitask (reading sensors and upload the data through wifi).

I am using the code from this tutorial. Here is a my problem in an image (I hope this helps you understand it). Thanks in advance.


texts: Reading contents of ESP8266 Flash from inside sketch

texts:
I am aware that there is a way to create a dump of the flash via esptool, but is there a way to read the contents of the sketch (just the sketch, not the full flash or SPIFFS) memory via the sketch itself? As in, have a program on the ESP8266 able to read its own machine code from the flash to do something with? I do not need write access, just read access.

I would like to be able to create a backup of the current sketch in SPIFFS so that it is possible to revert a bad sketch so long as the reversion trigger isn't broken. (For example, if a later part of the boot process is messed up, or if a function acts slightly wrong, a button could be held, and it would restore from the saved image. The restore process is something that I've figured out from my previous question, but I would like a way to write the sketch to SPIFFS that does not require a separate manual upload or a wrapper around the OTA process.)

[edit:]
Thank you for the comments.

I have created this code that SHOULD have copied the sketch to SPIFFS. However, it does not seem to have done so properly (since the result does not have the same checksums as the original file, and attempts to write it yield a nonfunctional device). Can I have someone look over it and see if they can figure out why?

unsigned long addr = 0;
unsigned long rem = ESP.getSketchSize();
uint32_t *data = new uint32_t[SPI_FLASH_SEC_SIZE];
File f = SPIFFS.open("/fw.bin", "w");
while (rem > 0) {
  ESP.flashRead(addr, data, SPI_FLASH_SEC_SIZE);
  int sz = SPI_FLASH_SEC_SIZE * sizeof(uint32_t);
  if (rem < sz)
    sz = rem;
  f.write(reinterpret_cast<uint8_t *>(&data[addr]), sz);
  addr += SPI_FLASH_SEC_SIZE;
  rem -= sz;
  yield();
  Serial.println(rem);
}
f.flush();
f.close();


texts: ESP32-CAM brownout detected on broad board power supply but not when using UART USB bridge

texts:
I have connected an ESP8266 and ESP32-CAM to a breadboard power supply. The ESP8266 works perfectly as long as the ESP32-CAM is not connected. When I connect the ESP32-CAM to the supply I get brownout on the ESP32-CAM and it starts to behave erratic (stream freezes, board crashes) and it also crashes the ESP8266 randomly.
Everything works fine when I remove the ESP32-CAM and connect it separately to my PC using a USB UART chip.
One thing I suspect is maybe my power connection to the ESP32-CAM is wrong, I am connecting the 5V output from my breadboard power supply to the 5V pin of the ESP32-CAM and using the negative or ground of the power supply to the GND pin directly beside the 5V pin.
Note that the 8266 and 32-CAM only share the power out pins from the breadboard power supply and no other connections between them exist. Makes me think maybe something wrong is with the power supply?


texts: Best way to assign value to lot of variables

texts:
I'm building web based remote control system for esp8266. In arduino IDE, using the ESP libraries. To, send data to the server, I'm using http post.
For some settings, I need to transfer 30 or so, different values over a single post request.  And assign it to different type of variables.

so, from this:
192.168.1.101/testpost?lenght=10&1=100&2=true&3=1800&4=125

i need this:

uint8_t brightness = 100;
bool randomOrder = true;
uint16_t Delay = 1800;
uint8_t Position = 125;

This is the relevant code. Basically, my idea is, to send the lenght of the array (will be different each time.) in the first argument.
Than create a for loop that put every value in a array into variable pointers. But, since lots of different type variables going on, i'm not sure how to do that.

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

//values i need to set in a single post.
uint8_t settings0;
bool brightness;
uint16_t randomOrder;
uint8_t Delay;

void setup {
//relevant code that handels post request.
server.on("/testpost", HTTP_POST, []() {

String ZeroValue = server.arg("lenght");

int lenght = ZeroValue.toInt();

//this doesnt really work, but its a starting idea.
int* SettingsArray[4] = {&settings0, &brightness, &randomOrder, &Delay};

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

     String PresetSettings = server.arg(i);
     SettingsArray[i] = PresetSettings.toInt();
    }
});
}

Ultimately, I can just do that, but I'm wondering if there is a more elegant solution.

brightness = SettingsArray[1];
randomOrder = SettingsArray[2];
Delay = SettingsArray[3];
Position = SettingsArray[4];