texts: What kind of a sim card is required for sim800 module? I know it must be activated and must be valid. But about 2g, 3g or LTE...What kind of a sim card in overall should I use with this module?


texts: Connecting multiple MAX30100/30102 via I2C

texts:
I want to connect multiple (up to 4) MAX30100 or MAX30102 oximeter sensors to an Arduino via I2c. But I could not find a solution to change/assign the I2C address.

implementing-pulse-oximeter-using-max30100

datasheet MAX30100


texts:
I am using an arduino mega clone called the Funduino.
I am developing a python based, tkinter application that will receive the serial data that arduino sends.
However, i am witnessing some behavior that i cannot explain and i am trying to debug. I won't say anything more, because this is an arduino forum, not a python forum.
But, in the arduino, there are some leds. One of them is power, which is constantly ON, when the arduino is powered.
There is another led that is named 'L'. When i open a serial connection this is lighted up and it stays ON.
However sometimes, when i send a string to the arduino, in order to trigger some data exchange, this button is switched off.
So what does this 'L' led is, and what it means when it is turned off?


texts: Homebrew Arduino using ATMEGA328P, ISP or ICSP?

texts:
I plan on creating a homebrew Arduino breakout board using the ATMEGA328P smd version. I'm geeting confused by the wealth of information out there as to whether I should be using ICSP or ISP to program it. It is a blank chip, aka no Arduino bootloader on it yet. I'd rather not have to buy a specialized programmer to burn the bootloader, I do have another Arduino I could use to burn the bootloader and upload sketches to it with.

So the question is; Do I use ISP or ICSP, or both?


texts:
I am new to arduino coding.
I am reading data from serial port and storing it in char array.
I want to send that data to the local server but it is not getting converted to string

Code :

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
ESP8266WebServer server;
char* ssid = "Office RTPL";
char* password = "********";
char data[64];
char data1[64];
String str;
void setup()

{
  // put your setup code here, to run once:
  WiFi.begin(ssid,password);
  Serial.begin(115200);
  while(WiFi.status()!= WL_CONNECTED)
  {
    Serial.print(".");
    delay(500);
  }
  Serial.println("");
  Serial.print("IP Address: ");
  Serial.print(WiFi.localIP());
  server.on("/",[](){server.send(200,"text/plain","Data Test");});
  server.on("/toggle",serialData);
  server.begin();
}
void loop()
{
  // put your main code here, to run repeatedly:
  server.handleClient();
 ;
}
void serialData()
{
  if(Serial.available() > 0)
      {

        server.send(200,"text/plain","Data");
         for(int n=0; n<64; n++)
         {
           data[n] = (Serial.read());

         }
         String str (data);
         server.send(200,"text/plain",str);

  else
        {
        String no_data = "No Serial Data";
        server.send(200,"text/plain",no_data);
        delay(5000);
        }

}

Please help


texts: I am trying to get both a SPI LED matrix display and an NRF24L01 to both work on the same Arduino Pro Micro. I know they both want to use the clock pin but how do I get them to share? Can I use the CS pin to turn off one device while trying to use the other? The display does can be set only when something needs to change so it's not always running.


texts: Arduino MKR 1010 WiFi as BLE central/client

texts:
I'm trying to use my new Arduino MKR 1010 WiFi as a Bluetooth Low Energy central/client, however I could only find information on how to use it as a peripheral/server (for example with the ArduinoBLE library, which only supports peripheral mode).

Is this possible? Maybe with a different library or firmware for the integrated NINA-W102 chip?


texts: XBEE coordinator WITH or WITHOUT Arduino?

texts:
I am building a wireless system that has got an Arduino with a XBEE as the 'end user' and I need to acquire data/control that Arduino from a PC graphical interface.
As far as I'm aware there are two options to obtain the communication:

I could use another Arduino with XBEE (coordinator) that is connected to my PC (serial) to control the 'end user'. The code is stored in this Arduino which works as a bypass between PC and XBEE.
I could simply use a XBEE without Arduino (coordinator) connected to my PC to control the 'end user'. The code should be stored within the PC or the XBEE to establish communication and control data transmission to different end users (???)

As I am new to the Arduino world, would you please direct me to the best/easiest solution to obtain such thing?


texts:
I am trying to do a self-balancing bot as a school project, but I got stuck with the MPU6050.

I tried using the code by Jeff Rowberg (MPU_6050_raw) but it's reading only zeros.

I tried the MPU_6050_DMP and got stuck at "initializing DMP..." and no reading is shown.

I tried other code, but same thing happens, either reading zeros or getting stuck at "initializing DMP..".

And how can I make sure that the chip isn't broken?


texts: Atmega328 and ADXL335 - is the right choice for vibration analysis?

texts:
I'm planning to use the ATMEGA328 and the ADXL335 accelerometer to monitor the bearing and gears vibration of a industrial extractor that works at maximum speed of 3000rpm at 380VAC - 50Hz .
The main scope of this monitoring is to get continuously the vibration readings and apply the FFT transform in order to identify if there is something that is not running well.
My primary concerns are regarding the sampling speed of the ATMEGA328P: i've tried to identify the needed sampling speed but i'm a little bit confused about the relation of motor/gear speed and the ADC sampling speed of the ATMEGA...also, the ADXL is the right choice?


texts: How to connect arduino mega 2650 and motor driver shield with seperate powers source?

texts: I am building a robot that runs only when a matching rfid tag is identified..for that i need motor driver shield for running the motors and rfid module. The problem is if i attach the motor driver shield directly to arduino (MEGA) there won't be any 3.3v left which is necessary to power rfid so what i am thinking is connecting all the pins of arduino and shield seperately using jumper wires and leaving the 6 power sockets unconnected. If i connect 9v battery to arduino mega to power the rfid and micro-controller itself, what battery should be connected to the shield? Is it necessary to connect the GND of arduino awa shield even if power sources are seperate? Is it necessary to attach 2 switches for each source?


texts: How to make an RC mixer with the arduino

texts:
I want to make a RC mixer mixing two channels of a receiver.

What I have: a delta model plane, two servos, a receiver and a Arduino Nano.

So I'd like to mix the aileron (two channels) with the elevator(one channel).

EDIT: What I've done: I read the input of the receiver and wrote it to the servos. The problem: The servo stutters and the arduino displays false inputs.

int pin = A0;
int pin1 = A1;
unsigned long duration;
unsigned long dur;

unsigned long duration2;
unsigned long dur2;

#include <Servo.h>

Servo myservo;
Servo myservo2;

void setup()
{
  Serial.begin(9600);
  myservo.attach(9);
}

void loop()
{
  duration = pulseIn(pin, HIGH);
  dur = duration;
  Serial.println(dur);
  myservo.writeMicroseconds(dur);
  delay(50);
//  duration2 = pulseIn(pin1, HIGH);
//  dur2 = duration2-980/4-200;
//  Serial.println(dur2);
//  myservo2.write(dur2);
}


texts: Reading values from TTP229 capacitive touch sensor on arduino

texts:
I would like to be able to read the raw capacitive sensor values from a TTP229 chip through i2c in Arduino. I have one of these breakout boards to play with :

My goal is to get values similar to those of the MPR121 or the Capacitive Sensor Arduino library where the reading changes depending on proximity and how hard you touch the pads. I have tested the following code but I'm only able to detect an on / off reading.

#include <Wire.h>
#define ttp229 ( 0xAF>>1 )

uint16_t data_out = 0;
uint16_t data1, data2;
int count = 0;
boolean count2 = false;
int button[16];
int oldata[16];

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

void loop()
{
    Wire.requestFrom( ttp229, 2, true );
    //delay(1);
    while( Wire.available() )
    {
        data1 = Wire.read();
        data2 = Wire.read();
        data_out = (data1<<8)|data2;

        for(int i=1;i<17;i++)
        {
            uint16_t contrast = 0x8000;
            if(data_out & contrast)
            {
                //Serial.println(i);
                button[count]=i;
                count++;
            }
            data_out<<=1;
        }
        if(count2)
        {
            switch(count)
            {
                case 1:
                if( oldata[0] == button[0] )
                {
                    Serial.println( button[0] );
                    delay( 20 );
                }
                break;
                case 2:
                if(oldata[0]==button[0]&&oldata[1]==button[1])
                {
                    for(int i = 0; i < 2; i++)
                    {
                        Serial.print( button[i] );
                        Serial.print("  ");
                    }
                }
                break;
            }
        }
        for( int i = 0; i < 16; i++ )
        {
            oldata[i] = button[i];
        }
        count = 0;
        count2 =! count2;
    }
}

Even if i just print out data1 and data2 from the example it doesn't seem to produce readings that change with the capacitance. I originally thought this was a hardware limitation but then I came across this TTP229 product that has a linear touch sensor built into it.

Does anyone have any experience with this sensor and how I can access the raw readings?


texts:
This bug/stupidity-of-myself/problem is killing me:
I'm have created an RGB strip controller that cycles through the additive-rgb-color spectrum while turning a potentiometer.

I have a pot hooked up to my Arduino Nano v3 (from AZ-Delivery, not official Arduino). Then I have an RGB amplifier hooked up to the Arduino with each phase (R, G, B, V+) and to an external power supply (12V by 2A max).

I shortened my program and removed all the value-to-colour-conversion because that has nothing to do with the problem:

void loop() {
    ColorVal = analogRead(pinPot); //read value of color poti
    ColorByte = map(ColorVal, 0, 1023, 0, 255); //Scales 0-1023 to 0-255

    // potvalue to color conversion
    // ...

    // write via PWM to LED
    analogWrite(pinR, R);
    analogWrite(pinG, G);
    analogWrite(pinB, B);
}

My problem: Theoretically you would expect the system to show white when all variables (R, G and B) are set to 255. However, it behaves the other way around. When all values are set to 255 it's off and vice versa. Another example: When R = 255 and G = 0 and B = 0 Green and Blue are lighting and Red is off.

I thought this has to do with polarity or something but I cannot seem to find it out.


texts:
Class myIOT2 contains a function that need to be called from class IPmonitoring:
bool myIOT2::checkInternet(char *externalSite, byte pings)
{
    return Ping.ping(externalSite, pings);
}

This function is needed as a pinger in IPmonitor:
void IPmonitoring::start(cb_func ping)
{

        _ping_cb = ping;
}

and this cb_func is defined by (inside IPmonitor.h):
typedef bool (*cb_func)(char *externalSite, byte pings);
cb_func _ping_cb;

inside my sketch (relevant parts only) I fail when iot.checkInternet is passed, while using a function test that calls iot.checkInternet succeeds:
myIOT2 iot;
IPmonitoring WiFi_service(ROUTER_IP, "Router");

bool test(char *a, byte b)
{
        bool x = iot.checkInternet(ROUTER_IP);
        return x;
}

void setup()
{
WiFi_service.start(iot.checkInternet); // <---- Trial a)fails
WiFi_service.start(test);              // <-----Trail b)succeeds
}

error is :
home/guy/Documents/git/Arduino/IPmonitor/IPmonitor.ino: In function 'void setup()':
IPmonitor:436:45: error: no matching function for call to 'IPmonitoring::start(<unresolved overloaded function type>)'
         WiFi_service.start(iot.checkInternet);//
                                             ^
/home/guy/Documents/git/Arduino/IPmonitor/IPmonitor.ino:436:45: note: candidate is:
In file included from /home/guy/Documents/git/Arduino/IPmonitor/IPmonitor.ino:2:0:
/home/guy/Documents/git/Arduino/libraries/myIPmonitor/myIPmonitor.h:42:10: note: void IPmonitoring::start(IPmonitoring::cb_func)
     void start(cb_func ping);
          ^
/home/guy/Documents/git/Arduino/libraries/myIPmonitor/myIPmonitor.h:42:10: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'IPmonitoring::cb_func {aka bool (*)(char*, unsigned char)}'
Multiple libraries were found

What is done wrong ? and why test succeeds ?


texts: Adafruit Trinket 3v with LED matrix backpack producing error

texts:
I have been wanting to create a Arduino watch. I built the circuit with an Adafruit Trinket 3v and an Adafruit LED matrix backpack (8*8). When I try to upload this example code:

/***************************************************
  This is a library for our I2C LED Backpacks

  Designed specifically to work with the Adafruit LED Matrix backpacks
  ----> http://www.adafruit.com/products/872
  ----> http://www.adafruit.com/products/871
  ----> http://www.adafruit.com/products/870

  These displays use I2C to communicate, 2 pins are required to
  interface. There are multiple selectable I2C addresses. For backpacks
  with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
  with 3 Address Select pins: 0x70 thru 0x77

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
 ****************************************************/

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

Adafruit_8x8matrix matrix = Adafruit_8x8matrix();

void setup() {
  // Serial.begin(9600);
  // Serial.println("8x8 LED Matrix Test");

  matrix.begin(0x70);  // pass in the address
}

static const uint8_t PROGMEM
  smile_bmp[] =
  { B00111100,
    B01000010,
    B10100101,
    B10000001,
    B10100101,
    B10011001,
    B01000010,
    B00111100 },
  neutral_bmp[] =
  { B00111100,
    B01000010,
    B10100101,
    B10000001,
    B10111101,
    B10000001,
    B01000010,
    B00111100 },
  frown_bmp[] =
  { B00111100,
    B01000010,
    B10100101,
    B10000001,
    B10011001,
    B10100101,
    B01000010,
    B00111100 };

void loop() {
  matrix.clear();
  matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_ON);
  matrix.writeDisplay();
  delay(500);

  matrix.clear();
  matrix.drawBitmap(0, 0, neutral_bmp, 8, 8, LED_ON);
  matrix.writeDisplay();
  delay(500);

  matrix.clear();
  matrix.drawBitmap(0, 0, frown_bmp, 8, 8, LED_ON);
  matrix.writeDisplay();
  delay(500);

  matrix.clear();      // clear display
  matrix.drawPixel(0, 0, LED_ON);
  matrix.writeDisplay();  // write the changes we just made to the display
  delay(500);

  matrix.clear();
  matrix.drawLine(0,0, 7,7, LED_ON);
  matrix.writeDisplay();  // write the changes we just made to the display
  delay(500);

  matrix.clear();
  matrix.drawRect(0,0, 8,8, LED_ON);
  matrix.fillRect(2,2, 4,4, LED_ON);
  matrix.writeDisplay();  // write the changes we just made to the display
  delay(500);

  matrix.clear();
  matrix.drawCircle(3,3, 3, LED_ON);
  matrix.writeDisplay();  // write the changes we just made to the display
  delay(500);

  matrix.setTextSize(1);
  matrix.setTextWrap(false);  // we dont want text to wrap so it scrolls nicely
  matrix.setTextColor(LED_ON);
  for (int8_t x=0; x>=-36; x--) {
    matrix.clear();
    matrix.setCursor(x,0);
    matrix.print("Hello");
    matrix.writeDisplay();
    delay(100);
  }
  matrix.setRotation(3);
  for (int8_t x=7; x>=-36; x--) {
    matrix.clear();
    matrix.setCursor(x,0);
    matrix.print("World");
    matrix.writeDisplay();
    delay(100);
  }
  matrix.setRotation(0);
}

I get this error:

Build options changed, rebuilding all
In file included from matrix8x8.ino:23:0:
C:\Users\My_Username\Documents\Arduino\libraries\Adafruit_LEDBackpack/Adafruit_LEDBackpack.h:30:24: fatal error: TinyWireM.h: No such file or directory
  #include <TinyWireM.h>
                        ^
compilation terminated.
Error compiling.

I have installed TinyWireM, Adafruit_GFX, and Adafruit_LEDBackpack. Why would I get this error?


texts: ADS1262 and 2.2 SPI TFT (Two SPI Slave) with Arduino

texts:
I am interfacing two SPI slave module i.e. ADS1262 and 2.2 SPI TFT with the Arduino Ethernet board.

When I test each device on its own it works. Initially, I interfaced the TFT to the Arduino and it is working fine. Likewise, the example code of ADS1262 is working fine when I am running it alone.

So after successfully running the TFT alone, I then wire-up the ADS1262, add the corresponding code, however the ADS1262 doesn't seem to respond.

I think the issue may be related to the ADS1262_CS or ADS1262_START or ADS1262_DRDY pin sequence to access the ADS1262.

I have used the ProtoCentral_ads1262 library from GitHub and have used the example code.

From Comments:
We have already reserved D10 for Ethernet Controller and D4 for SD Chip select. The issue is, how to communicate both of them, one by one. I can access one of them only when code is prepare for both devices.

// Portion of the code is given here

// https://github.com/adafruit/Adafruit_ILI9341 library used for TFT

// Code start from here

for(j=initvalue;j<=finalvalue;j+=x)
{

      dacvalue=((j*5)/65535);

      writeValue(j);

      tft.fillRect(30,150,70,28,ILI9341_BLACK);

      tft.setCursor(30,150);

      tft.println(dacvalue,3); // dac value is showing on TFT

      Serial.println(dacvalue,3);

// ADS1262 is need to communicate here as per https://github.com/Protocentral/ProtoCentral_ads1262 library

// Which pins are need to control here to communicate with ADS1262???

      volatile int p,data;

      if((digitalRead(ADS1262_DRDY_PIN)) == LOW)               // monitor Data ready(DRDY pin)
     {
       SPI_RX_Buff_Ptr = PC_ADS1262.ads1262_Read_Data();      // read 6 bytes conversion register
       Responsebyte = true ;
     }

      if(Responsebyte == true)
      {
       for(p = 0; p <5; p++)
      {
        SPI_RX_Buff[SPI_RX_Buff_Count++] = *(SPI_RX_Buff_Ptr + p);
      }
      Responsebyte = false;
      }

       if(SPI_RX_Buff_Count >= 5)
      {
        ads1262_rx_Data[0]= (unsigned char)SPI_RX_Buff[1];  // read 4 bytes adc count
        ads1262_rx_Data[1]= (unsigned char)SPI_RX_Buff[2];
        ads1262_rx_Data[2]= (unsigned char)SPI_RX_Buff[3];
        ads1262_rx_Data[3]= (unsigned char)SPI_RX_Buff[4];

        uads1262Count = (signed long) (((unsigned long)ads1262_rx_Data[0]<<24)|((unsigned long)ads1262_rx_Data[1]<<16)|(ads1262_rx_Data[2]<<8)|ads1262_rx_Data[3]);//get the raw 32-bit adc count out by shifting
        sads1262Count = (signed long) (uads1262Count);      // get signed value
        Serial.println("sads1262Count:");
        Serial.println(sads1262Count);
        resolution = (double)((double)VREF/pow(2,31));       //resolution= Vref/(2^n-1) , Vref=2.5, n=no of bits
        Serial.println(resolution,15);
        volt_V      = (resolution)*(float)sads1262Count;     // voltage = resolution * adc count
        volt_mV   =   volt_V*1000;                           // voltage in mV
     tft.setCursor(166,150);
     tft.println(volt_mV,3); } //not printed on TFT

In above code, ADS1262 is not activated so not giving value on serial window or TFT.

How to activate the ADS1262 module.


texts: how to use Nano instead of Uno3 to operate DC motors

texts:
OK I have the Logitech G29 Wheel and Pedal setup that I use for my Racing Sim. On YouTube there is a gentleman (amstudio) who has used motors on the Gas and Brake pedals to give some realism to the Sim. To achieve this he used a Uno 3 and a motor shield. The motors used are those that you'd find in the XBox/PS4 controllers. It's my understanding that the Uno 3, Nano and Micro are the same in its basic form, meaning that the sketch he uses can be used on all 3. If this is true then I want to use the smallest footprint to achieve the Rumble effect.
Question is how do I wire up the Nano to do this and with the motors as small as they are is it really necessary to have a motor shield or H bridges?
I have taken a picture of his Uno setup.  My aim here is to make it the smallest as it can be and still do the function of this mod' as this will be its only function. Any ideas on how best to go about this, The XBox Controller is rated at 5v @ 450mA. have included a picture showing his setup.thanks in advance


texts: Waking Arduino from sleep by holding button for more than 3 seconds

texts:
I am working on a battery powered Arduino project, where I need to put a standalone Arduino in sleep mode (to save some battery).

My aim is to put Arduino in sleep mode by holding a button for 3 seconds or more on pin 2 (hardware interrupt) and wake it up by holding the same button by 3 seconds or more.

I can put the Arduino to sleep by holding button more than 3 seconds, but I can't wake it from it by holding the button for 3 seconds.

Below is my code:

#include <avr/sleep.h>
const int led1 = 44;
const int led2 = 45;
const int led3 = 46;
const int usbState = 12;
float pressLength = 0;
const int button = 2;
int optionOne = 100;
int optionTwo = 3000;

void setup() {
  pinMode(button, INPUT);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(usbState, INPUT);
  Serial.begin(9600);
}

void loop() {
  while (digitalRead(button) == LOW) {
    delay(100);
    pressLength = pressLength + 100;
    Serial.print("ms-");
    Serial.println(pressLength);
  }
  if (pressLength >= optionTwo) {
    digitalWrite(led1, LOW);
    digitalWrite(led2, LOW);
    digitalWrite(led3, LOW);
    sleepNow();     // sleep function called here
  } else if (pressLength >= optionOne) {
    digitalWrite(led1, HIGH);
    digitalWrite(led2, HIGH);
    digitalWrite(led3, HIGH);
    while (1) {} //Keeps LEDS HIGH
  }
}

void sleepNow() {
  set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here
  sleep_enable(); // enables the sleep bit in the mcucr register
  attachInterrupt(0, wakeUpNow, LOW); // use interrupt 0 (pin 2) and run function
  sleep_mode(); // here the device is actually put to sleep!!
  // THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP
  while (digitalRead(button) == LOW) {
    delay(100);
    pressLength = pressLength + 100;
    Serial.print("ms-");
    Serial.println(pressLength);
  }
  if (pressLength >= optionTwo) {
    SleepNow(); //Back to sleep fucntion
  } else if (pressLength >= optionOne) {
    sleep_disable();
    // first thing after waking from sleep: disable sleep...
    resetFunc();//Resetting
  }
}

void wakeUpNow() {
  // execute code here after wake-up before returning to the loop() function
  // timers and code using timers (serial.print and more...) will not work here.
  // we don't really need to execute any special functions here, since we
  // just want the thing to wake up
}
void(* resetFunc)(void) = 0;

Please help. Thanks.


texts:
I am new to low level programming.I am trying to send binary data to the http server.At the moment i just fill up the byte array with numbers and send them to the server(eventually i want to send image file). I can see the request in the server log as
2016-05-18T23:30:26.688040+00:00 heroku[router]: at=info method=POST path="/api/users" host=myapp.herokuapp.com request_id=ed2b7852-7021-4642-a663-f9709e1aea70 fwd="99.89.114.63" dyno=web.1 connect=0ms service=2ms status=404 bytes=221

Questions

1.My question is as you can see in the log, what is bytes=221 i thought if i sent byte array of length 32 i should see 32 bytes(or around 40s).And i made the buffer of length 1024 byte array, still in the server log is bytes=221.Are my bytes are even being sent?

2.How would i handle the bytes received on the server side just to be sure client.write actually succeeded?(Just in high level...doesn't matter you can guide me in any language,Java,ruby,C,NodeJS)

Here is my code.Thank you in advance.

#include <ESP8266WiFi.h>
#define SSID "ssid"
#define PASS_SSID "password"
#define HOST "myapp.herokuapp.com"
WiFiClient client;

byte buffer[32];
int bufOffset = 0;
byte startByte = 0;
byte nextByte = 0;

void setup() {
    Serial.begin(115200);
    checkConnection();
}

void loop() {

  if (client.connect(HOST,80)) {
           Serial.begin(115200);
           Serial.println("conected to the server");
           String start_request = "";
           String end_request = "";
           start_request = start_request  + "--AaB03x" + "\n"
                                   + "Content-Disposition: form-data; name=\"picture\"; filename=\"cam.jpg\"" + "\n"
                                   + "Content-Type: image/jpeg" + "\n" + "Content-Transfer-Encoding: binary";
          end_request = end_request + "\n" + "--AaB03x--" + "\n";
          client.println("POST /api/users HTTP/1.1");
          client.println("Accept: */*");
          client.print("Content-Type: multipart/form-data; boundary=AaB03x");
          client.println(start_request);

         //Fill the buffer with values
            nextByte = startByte++;
            for(int ii = 0; ii < sizeof(buffer); ii++) {
            buffer[ii] = nextByte++;
        }

          //write it to the server
        int count = client.write(&buffer[bufOffset], sizeof(buffer));

       //end the request
       client.println(end_request);
        client.stop();
       }
      }


texts:
Is this timer set correctly for Arduino Mega? It should count exactly one second. And why when I print in serial monitor (seconds_passed++) is it incremented by 2 not by 1?

Full code on Pastebin: LINK

noInterrupts();
//set and initialize the TIMER1

TCCR1A = 0; // set entire TCCR1A register to 0
TCCR1B = 0; // set entire TCCR1B register to 0
TCCR1B |= (1 << CS12);
TIMSK1 |= (1 << TOIE1);
TCNT1 = 3036;

attachInterrupt(digitalPinToInterrupt(ignition_pin), ignitionSignal, CHANGE);
interrupts();

ISR(TIMER1_OVF_vect) {
  //TIMER1 overflow interrupt -- occurs every 1sec --
  instantSpeed();
  LPG_Consumption();
  LPG_injector_open_duration = 0;
  unleadedConsumption();
  unleadinj_Open_Duration = 0;
  seconds_passed++;
  vss_pulses = 0;
  TCNT1 = 3036;
}


texts: need to get values from a function with structure pointer argument and print on serial terminal

texts:
I am developing a code in which I need to print value of structure pointer on serial terminal.
Below is my code snippet:

typedef struct
{
  uint8_t AB;     ///< Address byte (Start byte)
  uint8_t CB;     ///< Command (index) "ASCII-byte"
  uint8_t SI;     ///< Action (sub index) "ASCII-byte"
  uint8_t PH_1;    ///< Payload "ASCII-byte" of the high nibble of the high byte of the raw payload
  uint8_t PH_2;    ///< Payload "ASCII-byte" of the low nibble of the high byte of the raw payload
  uint8_t PL_1;    ///< Payload "ASCII-byte" of the high nibble of the low byte of the raw payload
  uint8_t PL_2;    ///< Payload "ASCII-byte" of the low nibble of the low byte of the raw payload
  uint8_t CS1;    ///< Checksum "ASCII-byte" of the high nibble of the raw checksum
  uint8_t CS0;    ///< Checksum "ASCII-byte" of the low nibble of the raw checksum
} rs485_message_t;

int proto485ComposeMsg(rs485_message_t* msg, uint8_t address, uint8_t command, uint8_t action, uint16_t value){
  msg->AB = address;
  msg->CB = command;
  msg->SI = action;
  msg->PH_1 = (int)((value & 0xF000) >> 12) ;
  msg->PH_2 = (int)((value & 0x0F00) >> 8);
  msg->PL_1 = (int)((value & 0x00F0) >> 4) ;
  msg->PL_2 = (int)(value & 0x000F);
  int checksumRaw = (msg->CB) + (msg->SI) + (msg->PH_1) + (msg->PH_2) + (msg->PL_1) + (msg->PL_2);
  setCheckSum(msg);
}

uint8_t proto485Write(uint8_t address, uint8_t command, uint8_t action, uint16_t value)
{
  int i = 0;
  int stringOne[9] = {int(0x00), int(0x00), int(0x00), int(0x00), int(0x00), int(0x00), int(0x00), int(0x00), int(0x00)}; ;
  rs485_message_t rs485Msg;
  proto485ComposeMsg(&rs485Msg, address, command, action, value); // value is passed in "raw" format
  Serial.write(rs485Msg);       // getting error on this line
}

Please help... Thank you


texts: How do I even out Infared distance sensor readings?

texts: I am using a standard infared distance sensor on a small robot and i am trying to even out the readings on it so it is more accurate. The readings are very sporadic and often take huge jumps in the distance. Is there a method of programming or circuit design that might make this easier to use? I'm trying to keep my robot from running into things.


texts: Arduino compiler uploading last saved version of sketch, not current

texts:
Is this an issue or a defined behavior? I am using Arduino IDE 1.6.6

Sometimes I made changes in code, and immediately upload them to the Arduino board. And many times issues already fixed are persisting, leaving me that feeling of "the uploaded code has not the changes I have just made". Then I save my sketch, compile and upload again and the issue vanishes. As long as the issue get someway fixed, I tend to forgot about it.

As software engineer, most of the times I assume the code I am compiling and uploading / publishing to any platform is always the latest, not the latest saved. I believe this is not the behavior of the Arduino IDE. It uploads the last saved version of code, not the last modified.

In summary: I believe the Arduino IDE uploads to the board the last saved version of the sketch, not the current one being modified. Can anyone confirm this?

Thanks in advance.


texts: Arduino WiFi shield working intermittently, "WiFi Shield not present"

texts: I am trying to use the official arduino wifi shield, It works occasionally, but most of the time (when running the WiFi web server example code, or my derivitave program, it outputs WiFi shield not present on the terminal. I have tried updating the firmware several times, but it has not fixed the problem. Is the wifi shield always this unreliable? What can I do to fix it?


texts: Why does my dc motor immediately spin when connected to a 9v battery?

texts:
I've set up a DC motor connected to my Arduino Uno with the following layout. I'm using a 1.5V - 3V DC motor that was purchased from RadioShack.

Here is my code:

int controlPin = 9;

void setup(){
  pinMode(controlPin, OUTPUT);
  Serial.begin(9600);
  while(!Serial);
  Serial.println("Ready");
}

void loop(){
  if(Serial.available()){
    int s = Serial.parseInt();
    if(s >= 0 && s <= 255){
      Serial.println(s);
      analogWrite(controlPin, s);
    }
  }
}

If I connect the motor through the Arduino 5V pin it only hums until I set the speed s to 200 or greater. This seems odd because I'm supplying 5V.

As a next step I decided to try a 9V battery (I don't really care if I fry the motor, I just wanted to experiment). Of course this is over the recommended voltage, but I assumed if I sent a low enough signal (s) through pin 9 it might not destroy the motor. However, to my surprise, when I connected the 9V battery (as illustrated below) the motor immediately starts spinning. I measured the current and it seems to be ~150mA when connected to the 9V battery. It seems like the circuit is connected even though I'm not sending any signal from pin 9 to the transistor. If I removed any of the wires connected to ground, the motor, obviously, stops spinning. My expectation, which is apparently wrong, was that the motor wouldn't spin until I sent a signal from pin 9 to the transistor. What am I not grasping here?

Here's a picture as my diagram may be wrong based on comments below. This shows the diode reversed as suggested by Chris.

I also moved the jumper going from pin 9 to the breadboard out of the Vcc column and directly into the row with the resistor. I'm not sure if that resolves the short mentioned in comments.


texts: ESP32 with Lolin 2.4 inch TFT Shield Power control

texts:
I am running out of intelligence trying to control a Lolin 2.4 Inch TFT shield.
I connected the shield via the official TFT connector to a Lolin D32 Pro. I am using the ILI9341 libary from Adafruit. With the libary it is no porblem controlling the display.
Unfortunately, as soon as I put the esp32 into Deep Sleep, the display goes white but the background illumination stays on.
Does someone know, how I can trun off the background illumination?
As far as I understood, the background light is not controlled via the ILI9341. Instead I tried putting the GPIO32 on Low, since accoring to the schema of the Lolin TFT cable it is responsible for the TFT_Led
Unfortunately that does not work either


texts: Emulate non-standard keyboard from Arduino

texts:
I want to emulate keyboard presses in an old C64 microcomputer using an Arduino.

The keyboard connection is a non-standard 20-pin port (i.e. the Arduino keyboard libraries won't be useful) which, as I understand, works as a simple matrix of switches.

Since my Arduino Mega has more than 20 general purpose I/O ports, I understand I can approach the problem by simply mapping these 20 keyboard pins to individual "digital" Arduino ports, and then programming around it, right?

Or is this too naive and I'm missing something here?

I'm new to Arduino, so any comments highly appreciated. Thank you!


texts: How to find the index of the maximum value in an array?

texts:
Say we have an array named myMeasurements

int myMeasurements[9]={3,4,8,12,7,2,1,67,8};

How can I find the index of the maximum element of this array?

For example the MATLAB code would be:

myMeasurements = [3,4,8,12,7,2,1,67,8];
[maxValue,Index] = max(myMeasurements);

where maxValue is returned as 67 whereas the Index is returned as 8.

For the record, I am using Teensy 3.2 and I program it with the Arduino IDE using the Teensyduino add-on.


texts:
I have an ESP32 and want to connect it to the WLAN at my office. Based on my current knowledge of the Arduino, we use the WiFiClass to connect to a WLAN and then use a WiFiClient to use the WiFi for data transfer.

In order to connect to the WLAN at my office, a certificate is needed. I have asked the network guys to issue a x.509 certificate and plan to use the WiFiSecureClient class.

The problem is that my WiFi.begin(ssid) method never leaves the following while loop:

Wifi.begin(ssid); // my office needs a certificate to connect to the wifi at the first place
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}

Note that to connect to my office network, no password is needed. The x.509 certificate is enough for the connection to establish.

Only after a WiFi connection is established, I can set the WiFiSecureClient parameters of the CA. But to connect to the WiFi, I need the certificate.

This is very confusing. Could someone please clarify a way our for me in this situation.


texts: Problem programming Mini Pro via Arduino as ISP

texts:
I just picked up a pair of Arduino Mini Pro 5v clone boards (Inland, sold at Microcenter, currently $4 USD) and I wanted to use my Uno as an ISP like I've done with ATmega328 and ATtiny85 chips before.  I've programmed the Uno with the instructions at the ArduinoISP tutorial page and I've connected up the Uno to the Mini Pro using the instructions at this page.  I cannot get the Arduino IDE or avrdude from the command line to successfully program these boards no matter what I try.  Except that I can use the Arduino IDE to burn a new bootloader to the Mini Pro.

I've connected up the status LEDs as well (pins 7, 8 and 9), and I can see that the programmer has an error condition (pin 8) when I attempt to program anything besides the bootloader.

Here is my avrdude command line where I tried to set the fuses on the Mini Pro:

avrdude -P /dev/tty.usbmodema0121 -b 57600 -c avrisp -p atmega328p -U lfuse:w:0xff:m -U hfuse:w:0xdb:m -U efuse:w:0xfd:m

I get the following back from avrdude:

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

avrdude done.  Thank you.

I've not had any problems with using pretty much this exact same setup, but with a ATmega328 or ATtiny85 chip on a breadboard with avrdude in the past, so I'm at a loss as to what is happening here.

I've also taken a look at the ArduinoISP code, and I'm not really sure what the resp=0x1c is.  I don't see a 0x1c value defined in the STK Definitions section of the code, so I'm not sure what might be causing this.

Any pointers here would be appreciated. And yes, I do know that I can use the Uno board with the ATmega328 chip pulled to use as a programmer as well.  But I want to be able to overwrite the bootloader area with my own code like I can with a regular ATmega328 chip.

Thanks!


texts: LED strip with 12v power connected to ESP32

texts:
I'm looking at controlling a ws2811 strip and I have seen mention that you should share the same ground between the strip and the controller, which does make sense.
I do not currently have a proper power supply that will supply the full range of 12,5 and 3 volts but what I do have is one of these breadboard power supplies:

https://tinkersphere.com/906-thickbox_default/breadboard-power-supply-module-33v-5v-arduino-raspberry-pi-compatible.jpg

If using a correctly rated 12v power supply into this am I able to take a feed from the 12v line and hook the strip up to that and still have the rest function correctly?

Thanks!


texts:
I am trying to control a 5V pump with arduino and ultrasonic sensor however i can't make it work with the pump connected to a pin.

I saw on the forum that you need transistor or relay but i don't understand why ?

Thanks !


texts: How to create large progmem arrays and not annoy the linker

texts:
I have a rather complex project (PlatformIO, but I've also had this happen in the vanilla IDE) with several nested includes.
Let's say that there are three files and a main sketch.
The main sketch includes #2 and #3.
File #3 includes file #1 and file #2.

If file #2 is a .h file containing something like a font, of the format:

const char foo[] PROGMEM = {0xDE,0xAD,0xBE,0xEF};

Then I get linker errors of multiple definitions of 'foo' in both #3 and main.

Weirdly, the default fonts included in my OLED library are placed in a header file, EXACTLY like how I did it, and yet multiple files including that library (or files that themselves included it) do not cause this issue with the library's header file.

Yes, I do have a working include guard. For some reason it doesn't ever seem to help.

I have been using extern to solve this issue, but it's annoying and I'm not sure that it's proper behavior, either...

Could it have something to do with #include <font.h> vs #include "font.h"? What is the difference? My reference said they mean the same thing, but now I'm not so sure.


texts: Can AccelStepper accelerate non-linearly?

texts:
I am running a Nema 23 motor with an Arduino Uno and a microstepper driver. I am making a torsional vibration demo, which uses a series of springs connected to the motor driveshaft to spin gears. These gears, as changes in shaft speed occur, should begin to weave in- and out-of-phase with one another. In my particular case, I am using three potentiometers, which read 0-1023, to read speed, amplitude, and frequency.
The changes in motor speed are where I run into my issues. I need the speed of the stepper to be a sinusoidal function - of the form "Speed - Amplitude x sin(frequency x time)".
Below is some rudimentary code I put together with the AccelStepper library, which does not work:
#include <AccelStepper.h>

/* Using a stepper motor,
  rotate a vibrational model using gears interconnected by springs
  in such a way as to induce torsional vibration, which should be visible by comparing
  movement of juxtaposed rotating gears with markers painted on. */

AccelStepper stepper(AccelStepper::DRIVER);
void setEnablePin(int enablePin = 8);

int Microstepping = 8; /* Microstepping factor, as set on the ST-M5045 control board.
                          Multiplies the number of steps per revolution on the stepper motor.
                          Reference controller manual for adjustments to this number. */
int Steps = 200; /* Number of steps on your stepper motor.*/
int SPS;
int Amp;
int Freq;
// int SC;
int n = 2;
int i;
int totalSteps = Microstepping * Steps;
int currentPosition();

/* It should be noted that the Microstepping and Steps factors are not necessary, and adjusting the microstepping factor
    on the fly will not break the code. However, be aware that changing the microstepping factor by more than one interval
    at a time can cause the motor to not keep up with the sudden changes, i.e. losing torque or vibrating/stuttering. */

void setup() {               // THIS RUNS ONCE //

  Serial.begin(9600);

  // read potentiometers; raw inputs from 0 to 1023 //
  SPS = analogRead(0) * 0.5; // MAX steps per second should be <1000. Speeds above 1000 unreliable, according to AccelStepper docs.//
  Amp = analogRead(1) / 20;   // MAX AMP ~51//
  Freq = analogRead(2) / 170; // MAX FREQ ~12 Hz//

  stepper.setMaxSpeed(1000);
  stepper.setAcceleration(SPS / 1.5);

  int nextStop = totalSteps / Freq;

  stepper.moveTo(nextStop);
  stepper.run();
  Serial.println("INITIALIZED");
}

void loop() {
  SPS = analogRead(0) * 0.95;
  Amp = analogRead(1) / 20;
  Freq = analogRead(2) / 170;

  float spd = SPS + (Amp*sin(Freq*millis()));
  stepper.setSpeed(spd);
  stepper.run();
  Serial.print("speed:  ");
  Serial.println(spd);
}

The issue I am having with the above code is that it enters the loop but does not vary the speed, despite the serial output showing me a speed which oscillates about the desired value several times a second.
And now, folks, what you've all been waiting for: The Point.
Does AccelStepper actually support non-linear accelerations not as the result of an error? I cite the following excerpt from the AccelStepper documentation,
 /// Sets the maximum permitted speed. The run() function will accelerate
 /// up to the speed set by this function.
 /// Caution: the maximum speed achievable depends on your processor and clock speed.
 /// The default maxSpeed is 1.0 steps per second.
 /// \param[in] speed The desired maximum speed in steps per second. Must
 /// be > 0. Caution: Speeds that exceed the maximum speed supported by the processor may
 /// Result in non-linear accelerations and decelerations.
 void    setMaxSpeed(float speed);

which makes the only mention of non-linear acceleration in all of the documentation - in the context of an overflow error.
I've thought of possibly using a modified version of the easydriver example program from reply #3 to this post if AccelStepper isn't capable of doing what I need it to do. Included is also an image of the system (minus the arduino and controller).
Thanks for your help in advance


texts: Including libraries from header files sometimes doesn't work

texts:
I, once again have difficulties including libraries from code files other than my .ino file.

I have several .cpp and .h files in my project to keep it sorted and clean.
However one of my header files starting like this:

#ifndef DPLANDEF
#define DPLANDEF
#include <Arduino.h>
#include <EEPROM.h>
#include "syssettings.h"

yields the following errors:

  In file included from
  /var/folders/jl/nv1qvh6n569cxq9xxfd6dx980000gn/T/build4605486877500371361.tmp/dplan.cpp:2:0:
  /var/folders/jl/nv1qvh6n569cxq9xxfd6dx980000gn/T/build4605486877500371361.tmp/dplan.h:5:20:
  fatal error: EEPROM.h: No such file or directory  #include
                      ^ compilation terminated. Fehler beim Kompilieren.

EEPROM.h should be known to the IDE, because I can find it in the libraries menu, too. If it was a custom library, I might have botched something during installation, but this is a standard library. It should work out of the box. What's the problem here?


texts: What sensor would detect the black stripe on an analog electricity meter?

texts:
I have an analog electricity meter (AEM) and I would like to track my usage of electricity.
I've attempted to use the EE-SY310 photo sensor, but that's not sensitive enough it seems. I suspect the black stripe on the dial is too thin to be picked up. The other concern on using any photo sensor is its dependance on light (obviously) hence no reading would be picked up during the night.

Other: I've also found that AEMs work by using magnetic fields to move the dial. The magnetic field detector I used did not show much fluctuation when turning appliances on/off. The dial was pegged at the max. Therefore, I'm not so confident that a sensor to measure magnetic fields would work here, but I'm open to suggestions.

So, would anyone know what sensor would be good to detect the black stripe on AEMs?
Preferably to also work without light.

I know there are off-the-shelve products that do this already, but where's the fun in that?


texts: Why is one LED more luminous (brighter) than the other?

texts:
Given that there is a circuit with two pins (12 and 10) from an Uno providing power to LEDs on two separate branches, why is the yellow LED dimmer than the green LED? (Please see below image.) To my understanding, the branches attach to GND in parallel, so the LEDs should be equally bright.

If it helps, the two branches are programmed so one LED is off when the other is on and vice versa, with a 1s interval between changing pin state. This isn't a PWM thing as using pin 8 instead of 10 makes no difference.


texts:
I am trying to upload this simple sketch into my arduino with a shield I made. It takes forever (note I have the right COM port on)

  int sensorValue = 0;

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

  void loop(){
     sensorValue = analogRead(A4);
     delay(10000000);
     Serial.println(sensorValue);
     delay(10000000);
  }


texts: Is it possible to use a USB camera with Arduino?

texts:
It is necessary to recognize the motion and record video live.

Update
Save enough on your memory card.

PS
Maybe I'll repeat the question, but I am not guided in English.
Sorry for my English.


texts: Is it wise to use analog input pins to read digital buttons?

texts:
I am thinking about building a circuit that is literally going to take 11 of the 14 digital pins of an UNO to communicate with an SD card and an external EEPROM chip (EEPROM programmer).

Using 4 shift registers and the SD card, I will have 1 digital pin left.  Well, I'm also reserving pins 0/1 for serial communication.

Anyway, I need to read some external buttons and I have the 6 analog pins that I haven't touched.

I will only need about 4-5 push buttons in my design so they should fit nicely on A0+.

So, my question is, will I run into any issues doing this?  Or, are the analog inputs better left for true analog reading?

Thanks.


texts:
I'm trying to connect an Arduino Micro to MPU-9150 using the  MPU6050_DMP6 example.
It runs for couple of seconds then the board Hangs, I sometimes see the "FIFO overflow" message.
The same code runs well when i connect the MPU-9150 to Arduino UNO and Arduino Duemilanove.
I tried to lower the serial baud rate but no success with that. I even tried connecting an external 12V to the Micro but it's the same.

should I lower the i2c clock (not sure how to do it)?

another interesting thing i have noticed is that with the Duemilanove i can use a longer line for the i2c (5m of cat5e), with the Uno it only works with less then 2m cables, can anyone tell why?


texts: Arduino Yun's sample "Bridge" code not working

texts:
I'm new to the Arduino world (or the electronics world for that matter).

I have the Arduino Yun and the WifiStatus code works fine (so does the HttpClient).
But every time I try to run the bridge sample code, all I see is the pin 13 led light up, and the browser commands don't work.

PS: I have updated the open-wrt to ver. 1.3.

Any thoughts on why this would be happening?

Edit 1:

I have tried to reboot arduino using the hardware switches as well as from the web console. The blink sketch works fine, so does the WifiStatus code and the HttpClient code.

The other problem I face after every few uploads is that the IDE is stuck at "Uploading...". I have tried to give it more time (even an hour). But then I had to unplug it from the Mac and restarted. Then it worked but only for a few times.

But this problem is not specific to the Bridge code. The uploading issue has occurred with other sample code as well. But at least the code worked.

Edit 2:

This is the result from the command ls /dev/tty.*

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


texts: DHT11 sensor works on Arduino Uno, not on LoLin NodeMcu

texts:
When run this code on an Arduino Uno (clone), everything works.
When I run it on my LoLin NodeMcu, I get the following verbose upload output:

esptool v0.4.9 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
    setting board to nodemcu
    setting baudrate from 115200 to 115200
    setting port from COM1 to COM4
    setting address from 0x00000000 to 0x00000000
    espcomm_upload_file
    espcomm_upload_mem
    setting serial port timeouts to 1000 ms
opening bootloader
resetting board
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
resetting board
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
resetting board
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

The only difference I really see is that on the Arduino Uno, the voltage pin is connected to 5V, while on the LoLin, it's connected to one of the 3V pins. Does the DHT11 require 5V?

Edit

So I stumbled upon this list of port mappings. When I change my pin number to 5 (meaning D1), it actually works. Kinda. The numbers outputted are strange. Even when I put the board outside, in about -6 Celcius, it still displays

Temp 247.208 °C
RH 216.208 %

Well, I guess this oddity should be posted as another question. I'll answer my own question here with reference to the weird pin-to-number mapping on the LoLin board.


texts: Connecting HC-06 to Arduino, this happens

texts: Been trying to figure out why my HC-06 Bluetooth module doesn't work with Arduino UNO.1st I tried the method where I didn't use resistors. The HC's light starts blinking for few seconds and then the light dissapears. Also used 1K and 2K resistors, same thing. Haven't uploaded any codes. HC's pins are connected to 5V, GND, TX(1) and RX(0). Powering Arduino via USB cable. Maybe the 5V damaged my module? I was dumb and removed the plastic thing around the module when I did get it, maybe module got damaged by that aswell. Followed this video youtube.com/watch?v=F6E5mP70jaw&t=1s. Doubt there are any errors in wiring. Do I need to upload some sort of code or do something in serial monitor to get this module to work?


texts:
i have a problem with my code, i basically move a motor with the help of 3 relays, when a sensor does not detect the presence of an object part of a call, everything works perfectly, if it was after having called the function CHIAMATA() the arduino loop() stop unexplains, i certainly made a mistake, but i do not understand which.

thanks for your help
this is the code....

#include <swRTC.h>
#include <SoftwareSerial.h>
#include <String.h>

swRTC rtc; //create a new istance of the lib
SoftwareSerial mySerial(3, 2);

const int buttonPin = 19;
const int sensorPin = 9;
const int allarmPin =  13;

int buttonState = 0;
int sensorState = 0;
int relay1 = 8;
int relay2 = 7;
int relay3 = 6;
int var = 0;

// initialize the stepper library on pins 8 through 11:

void setup() {
    rtc.stopRTC(); //stop the RTC
    rtc.setTime(12,0,0); //set the time here
    rtc.setDate(4,6,2012); //set the date here
    rtc.startRTC(); //start the RTC
  Serial.begin(19200); //choose the serial speed here
  mySerial.begin(19200);
  pinMode(allarmPin, OUTPUT);
}

void loop() {

while(mySerial.available()!=0);{}delay(10);

    Serial.print(rtc.getHours(), DEC);
    Serial.print(":");
    Serial.print(rtc.getMinutes(), DEC);
    Serial.print(":");
   Serial.print(rtc.getSeconds(), DEC);
    Serial.println(" ");

//stato riserva croccantini
sensorState = digitalRead(sensorPin);

if (sensorState == HIGH) {
    // turn LED on:
    digitalWrite(allarmPin, HIGH);
    Serial.println("Croccantini esauriti");
    Serial.println("Spia allarme ACCESA");
    Serial.println("Tramoggia DISABILITATA");
    Serial.println("Imposto la chiamata");
    while(sensorState == HIGH) {CHIAMATA(); break;}
  } else {
    // turn LED off:
    digitalWrite(allarmPin, LOW);
    Serial.println("Croccantini OK");
  }
if (sensorState == LOW && rtc.getHours()== 12 && rtc.getMinutes()== 00 && rtc.getSeconds()== 5) {startmotor();}
  //start manuale carico/scarico
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);
  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
    if (buttonState == 1) {
      Serial.print("Pulsante alimentazione manuale ATTIVO");
    // turn on:
  // singlestartmotor();
  }

      }

void startmotor(){
//numero di cicli di carico da eseguire (5)
 while(var < 5){
 pinMode(relay1, OUTPUT);
  pinMode(relay2, OUTPUT);
    pinMode(relay3, OUTPUT);

 digitalWrite(relay3, LOW); //ABILITA TUTTO
 //AVANTI
 digitalWrite(relay1, LOW);
 digitalWrite(relay2, LOW);
 Serial.print("AVANTI");
 delay(1000); // wait 2 seconds

 digitalWrite(relay3, HIGH);//STOP TUTTO
 digitalWrite(relay1, HIGH);
 digitalWrite(relay2, HIGH);
 delay(1000); //ATTESA PER INVERSIONE MARCIA

 //INDIETRO
 digitalWrite(relay3, LOW);//ABILITA TUTTO
 digitalWrite(relay1, HIGH);
 digitalWrite(relay2, HIGH);
 Serial.print("INDIETRO");
 delay(1000); // wait 2 seconds

  digitalWrite(relay3, HIGH);//STOP TUTTO
  delay(5000); // wait 2 seconds

  var++;
}}

void CHIAMATA() {
 mySerial.println("ATD329xxxxx135;");//dial the number, xxxx ix the phone number.
 delay(100);
 Serial.print("Chiamata in corso..."); return loop();}


texts: Waking Raspberry Pi on time schedule using Sleepy Pi

texts:
I'm have a Sleepy Pi and am having extreme difficulties trying to program a wake/sleep cycle. Sleepy Pi is an Arduino board with a RTC. My ultimate goal is for a time-lapse project.

I have the Raspberry Pi programmed and operational to take a picture on boot, my trouble is coming from trying to program the Arduino board to actually do it's job.

I would like the Sleepy Pi to wake at 8am, 9am, 10am, ..., 3pm, 4pm, and 5pm, each for 5 minutes, then go back to sleep. I've been working with the SleepyPi, Time, TimeAlarms, LowPower, and DS1374RTC libraries in the Arduino IDE. However, I cannot find any examples on how to put everything to sleep until a specific time comes around. Also, in several of my tests, it seems that the clock actually stops when the Sleepy Pi is asleep!

Here is what I've been working with (and this is non-working). It's probably completely wrong.

#include "SleepyPi.h"
#include <Time.h>
#include <TimeAlarms.h>
#include <LowPower.h>
#include <DS1374RTC.h>
#include <Wire.h>

// Set the status LED pin constant
const int LED_PIN = 13;

void setup()
{
  // Configure "Standard" LED pin
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN,LOW); // Switch off LED

  // Start with the Pi off
  SleepyPi.enablePiPower(false);

  // Set our communication rate
  Serial.begin(9600);

  // Set up our boot times
  Alarm.alarmRepeat(8,0,0, startPiUp);
  Alarm.alarmRepeat(9,0,0, startPiUp);
  Alarm.alarmRepeat(10,0,0, startPiUp);
  Alarm.alarmRepeat(11,0,0, startPiUp);
  Alarm.alarmRepeat(12,0,0, startPiUp);
  Alarm.alarmRepeat(13,0,0, startPiUp);
  Alarm.alarmRepeat(14,0,0, startPiUp);
  Alarm.alarmRepeat(15,0,0, startPiUp);
  Alarm.alarmRepeat(16,0,0, startPiUp);
  Alarm.alarmRepeat(17,0,0, startPiUp);
}

void loop()
{
  // Tick the alarm clock every second
  SleepyPi.enableWakeupAlarm();
  Alarm.delay(1000);

  // Cut Power if we detect Pi not running
  bool pi_running;
  pi_running = SleepyPi.checkPiStatus(true);
  if(pi_running == false){
    SleepyPi.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
  }

  // Flash the LED
  digitalWrite(LED_PIN,HIGH);
  delay(1000);
  digitalWrite(LED_PIN,LOW);
}

// Function to tell the Pi to boot up
void startPiUp()
{
  // Turn the Pi on
  SleepyPi.enablePiPower(true);

  // Turn on the LED to signal we're here
  digitalWrite(LED_PIN,HIGH);

  // Keep the Pi on for 5 minutes
  delay(300000);

  // Start a shutdown
  digitalWrite(LED_PIN,LOW);
  SleepyPi.piShutdown(true);
}

I also cannot find a good way to "debug" things. I've been trying to use the LED flashes as a "I'm here" echo, but have been unsuccessful with this as well.

NOTE: I do not have enough reputation on this site yet to create new tags. Someone with over 150, please tag this with raspberry-pi and sleepy-pi. Thank you.


texts: Using PWM pins on the UNO to generate Stereo Sound

texts:
I am trying to generate stereo sound using an Arduino UNO. Instead of using a separate DAC chip (as shown here), can I use the PWM pins on the UNO along with a low-pass filter?
Also, would I need any additional circuitry if I go this path?


texts: 28 BYJ stepper motor runs faster using delay() and little slower using millis(), why?

texts:
I'm working to develop a code for the stepper motor to use it in a project. And since using delay() isn't as efficient as millis(). So I first developed the code that use delay with 1ms delay between the steps which is the fastest I could do with this stepper motor.

Then I developed similar code using millis() with same 1ms delay but it didn't feel as smooth/fast as the one with delay() function.

So what's the reason for that?

These are the code:

With delay():

    void clockwise(void){
        digitalWrite(in4, HIGH);
        digitalWrite(in3, LOW);
        digitalWrite(in2, LOW);
        digitalWrite(in1, LOW);
    delay(1);
        digitalWrite(in4, HIGH);
        digitalWrite(in3, HIGH);
        digitalWrite(in2, LOW);
        digitalWrite(in1, LOW);
    delay(1);
        digitalWrite(in4, LOW);
        digitalWrite(in3, HIGH);
        digitalWrite(in2, LOW);
        digitalWrite(in1, LOW);
    delay(1);
        digitalWrite(in4, LOW);
        digitalWrite(in3, HIGH);
        digitalWrite(in2, HIGH);
        digitalWrite(in1, LOW);
    delay(1);
        digitalWrite(in4, LOW);
        digitalWrite(in3, LOW);
        digitalWrite(in2, HIGH);
        digitalWrite(in1, LOW);
    delay(1);
        digitalWrite(in4, LOW);
        digitalWrite(in3, LOW);
        digitalWrite(in2, HIGH);
        digitalWrite(in1, HIGH);
    delay(1);
        digitalWrite(in4, LOW);
        digitalWrite(in3, LOW);
        digitalWrite(in2, LOW);
        digitalWrite(in1, HIGH);
    delay(1);
        digitalWrite(in4, HIGH);
        digitalWrite(in3, LOW);
        digitalWrite(in2, LOW);
        digitalWrite(in1, HIGH);
    delay(1);
}

With millis():

  void stepper_run_cw(void){
  stepper_step_cw(1,0,0,0,1);
  stepper_step_cw(1,1,0,0,1);
  stepper_step_cw(0,1,0,0,1);
  stepper_step_cw(0,1,1,0,1);
  stepper_step_cw(0,0,1,0,1);
  stepper_step_cw(0,0,1,1,1);
  stepper_step_cw(0,0,0,1,1);
  stepper_step_cw(1,0,0,1,1);
}

void stepper_step_cw(uint8_t m_in1, uint8_t m_in2, uint8_t m_in3, uint8_t m_in4, uint8_t delay_time){
  if (!stepper_run){
    digitalWrite(in1, m_in1);
    digitalWrite(in2, m_in2);
    digitalWrite(in3, m_in3);
    digitalWrite(in4, m_in4);
    stepper_start = millis();
    stepper_run = 1;
  }

  if(stepper_run){
    stepper_current = millis();
    if(stepper_current - stepper_start >= delay_time){
      stepper_run = 0;
    }
  }
}


texts: SSD1306 allocation failed when adding a constant

texts:
I am trying to get this code working:

#include <Button.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <RTClib.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
RTC_DS1307 RTC;

// when I remove this part it works...
int mode = 1;
const String periodicSystem[60] = {
    "H", "He", "Li", "Be", "B", "C", "N", "O",
    "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S",
    "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr",
    "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge",
    "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb",
    "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn",
    "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd"
};
/////////////////////////////////////////////////////////////////////

Button button1(7);

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

  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }

  RTC.begin();
  if (! RTC.isrunning()) {
    Serial.println("RTC is NOT running!");
    // This will reflect the time that your sketch was compiled
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }

  display.display();
}

void loop() {
  DateTime now = RTC.now();
  if(button1.pressed()) {
      display.clearDisplay();
      display.setTextSize(1); // Draw 2X-scale text
      display.setTextColor(WHITE);
      display.setCursor(10, 0);
      display.print(now.second());
      display.display();
  }
}

Whenever I try to add the constant periodicSystem, I get the error SSD1306 allocation failed over Serial. The error also goes away when I remove the part with button1.pressed(). Basically I am not able to add the constant periodicSystem and read out a digital pin at the same time. To me it seems to be some sort of memory issue (I am only adding the constant, I am not doing anything else with it), but my IDE tells me I am only using 52% of the available storage. What am I doing wrong?

Here is my wiring (in reality I am using a 128x32 display, I didn't have the correct part for Fritzing; my display is labeled SDA, SCK, VCC, GND instead of SDA, SCK, VDD, GND; the RTC Module I am using is a DS1307 AT24C32 RTC Module):


texts:
I am trying to create a clock on an LCD when I upload the code below, all it displays is a very rapidly flashing 0:00 PM. Please help. This is my first time using Millis.

#include <LiquidCrystal.h>   //includes LCD display library in sketch
LiquidCrystal lcd(27,26,25,24,23,22);   //determines pins of the LCD display
int seconds = 0;    //generates integer storing seconds
int minutes = 0;    //generates integer storing and showing minutes
int hours = 12;      //generates integer storing hours in 24 hour mode
int displayHours;      //generates integer displaying hours in 12 hour mode
unsigned long previousMillis = 0;   //creates a variable to store the amount of milliseconds since last update
const long interval = 1000;    //generates integer to find 1 second interval

void setup()
{
  lcd.begin(16,2);  //determines size of the LCD display
}

void loop()   //runs code repeatedly
{
  updateSeconds();   //runs the updateSeconds function
  clockShown();   //runs the clockShown function
  clockConversion();    //runs the clockConversion function
}

void updateSeconds()   //check to see if it's time to update the seconds integer
{
  unsigned long currentMillis = millis();  //generates the number of milliseconds program has been running
  if (currentMillis - previousMillis >= interval)
    {
      previousMillis = currentMillis; //updates the last time seconds was updated
      seconds = seconds ++;   //adds a second to the counter
   }
}

void clockShown()   //displays the time on an LCD display
{
  lcd.clear();   //resets screen on LCD
  lcd.setCursor(0,0);    //sets the place to start writing at the top left corner of the LCD
  lcd.print(displayHours);  //displays hours
  lcd.print(":");   //displays colon
  if(minutes <= 9)  //if the minute is 1 digit
  {
    lcd.print("0"); //displays 0
  }
  lcd.print(minutes);  //displays minutes
  if(hours < 12)lcd.print(" AM");  //displays AM in the morning
  if(hours >= 12)lcd.print(" PM");   //displays PM at night
}

void clockConversion()  //runs math to convert seconds minutes and hours
{
  if(seconds == 60) //when seconds is 60
  {
    seconds = 0;  //set seconds back to 0
    minutes = minutes ++;  //and add a minute
  }
  if(minutes == 60) //when minutes is 60
  {
    minutes = 0; //set minutes back to 0
    displayHours = displayHours ++; //and add an hour
    hours = hours ++; //and keep track of AM PM
  }
  if(displayHours == 13)  //if the hour being displayed is 13
  {
    displayHours = 1; //make it 1 instead
  }
}


texts: Which sensors to choose to detect movement direction

texts:
So I'm planning to build a sort of light switch for my Philips Hue bulbs with an Arduino. This project will be mounted on a shelf next to my door to the room, parallel to the walking direction. In order to detect the movement direction to either turn on or off the lights when a person is entering or leaving the room, I need one or two sensors. I've tried HC sr04 before but got inaccurate results which resulted in random changes of the lightstate.

So what sensors will be best for my application? I was thinking about the Sharp IR sensors (i.e. Sharp GP2Y0A60SZLF) but I'm not sure about any possible interference that comes with it when I mount to of these right next to each other. Any ideas?

Thanks in advance!


texts: Arduino Leonardo Pro Mini will not begin sketch when connected to BIOS not an OS

texts:
I have an Arduino Leonardo that I am using to emulate a Keyboard using the keyboard.press function with the Keyboard.h libraries. I have gotten the Keyboard.press function to work on my windows and mac- the keystroke I used was CTRL N to test- this worked well. So my ultimate goal was to emulate a keystroke ,F1, on a PC that is not running an OS- meaning I want the sketch to run in BIOS. for context, This keystroke (F1) tells the computer to use the a bootable USB to run a certain MathWorks OS.
The problem, when it is plugged in the Arduino shows that power is receieved by lighting the POWER LED but it does not begin the sketch. The RED LED that usually flashes ( TX or RX im not sure) when it is running a sketch is not happening (not illuminating).
How can I troubleshoot this and what could be happening? I have read that maybe too much serial info is going to the board so it confuses the board and does not begin the sketch.

I appreciate all the following help!!


texts:
I wrote a simple code to count the number of pulses when the motor runs.
The code just counts the number of interrupts from the encoder, but the output is very weird.
Even when the motor is not running it outputs huge numbers of the range of 10000s as the number of pulses.
Same case with the other motor.
Is something wrong with the encoders or am i missing something?


texts: How to pass 2 parameters with RCSwitch library?

texts:
I'm learning Arduino's world, but knowing very little about C and C++.

I'm trying to achieve a little RF transmitter which should send the temperature and  humidity from a DHT-11 sensor to a Raspberry Pi.

I'm using the RCSwitch library to send information with the Arduino, and the 433Utils library to receive it on the RPI.

Using those 2 libraries demos, I was able to send an integer, holding temperature or humidity information (mySwitch.send("00001010");), and read it on the RPI.

But how can I send both informations so that the RPI will know which one is the temperature and the humidity ?

I know I could just send both and assume the lowest is the temperature, but this would be very messy and not very rewarding.

EDIT :

Following Edgar's answer in https://arduino.stackexchange.com/a/52992/11604, I know write:

void send_string(const char *str){
    int i = 0;
    for (char *p = str; *p; p++ ) {
        mySwitch.send((i<<8) + *p, 16);
        i++;
    }
}

void loop() {
    delay(1000);
    h=40.650;
    t=32.0078;
    hic=33.586;
    String x = "$H" + String(h) + "T" + String(t) + "HI" + String(hic);
    send_string(x.c_str());
}

Works perfectly ! (see his complete answer for the RPI-side code)


texts: Limitations of connecting to many Arduinos via Ethernet?

texts:
I'm planning a project where I need to control a lot of Arduino Unos from a single PC. I'll need to send commands to the Arduinos and receive responses, as well as have the ability to update each Arduino from the PC, preferably without Arduino IDE at some point. Connecting via USB is out of the question, as I have already tried this and got miserable results, in part because of the number of Arduinos I need to control. So now I'm considering connecting the PC to an ethernet switch and then from there connect each Arduino with an ethernet shield.

Which brings me to my questions. Are there any limitations I should be aware of, if I want to pursue this setup? Will controllings tens, or even a hundred, Arduinos at the same time be a problem? How about stuff like updating a specific Arduino on the network?

My current working prototype uses a Windows PC that connects to one of multiple Raspberry Pis, which then in turn communicates with a number of Arduinos via I2C, and updates them via USB. But if I'm able to do all this directly from the main PC to the Arduinos via Ethernet, that would be fantastic.

Thanks for reading, looking forward to any answers.


texts: How do you call a class method with named parameters?

texts:
I have a C++ class constructor like:

Motors(int p1=0, int p2=0);

However, when I attempt to instantiate it with named parameters like:

Motors motors(p1=123, p2=456);

the Arduino C/C++ compiler gives me the errors:

src/motors.ino:3: error: ‘p1’ was not declared in this scope
src/motors.ino:3: error: ‘p2’ was not declared in this scope

The compiler doesn't seem to support named parameters and thinks I'm referring to variables. I thought named parameters was a pretty widely supported feature, even in C++. What am I doing wrong?


texts:
I want to read the data from an IMU (MPU9250) periodically. To do that I use a ticker as shown in the following code:
#include <Ticker.h>
#include "MPU9250.h"

constexpr int SERIAL_BAUDRATE = 115200;
constexpr float SAMPLING_FREQUENCY = 1.0;

Ticker TimerIMU;
MPU9250 IMU(Wire, 0x68);

void readIMU()
{
    // read the sensor
  IMU.readSensor();
  // display the data
  Serial.print(IMU.getAccelX_mss(),6);
  Serial.print("\t");
  Serial.print(IMU.getAccelY_mss(),6);
  Serial.print("\t");
  Serial.print(IMU.getAccelZ_mss(),6);
  Serial.print("\t");
  Serial.print(IMU.getGyroX_rads(),6);
  Serial.print("\t");
  Serial.print(IMU.getGyroY_rads(),6);
  Serial.print("\t");
  Serial.println(IMU.getGyroZ_rads(),6);
}

void setup()
{
  // serial to display data
  Serial.begin(115200);
  while(!Serial) {}
  // start communication with IMU
  int retVal = IMU.begin();
  if(retVal < 0)
    Serial.println("IMU initialization unsuccessful: check your wiring or try resetting power to the sensor.");
   // start ticker
  TimerIMU.attach(1.0 / SAMPLING_FREQUENCY, readIMU);
}

void loop()
{
}

This approach does not produce the expected results: the IMU returns always the same values. Putting the readIMU function in the main loop and commenting the Ticker works well. I use an ESP32-WROVER.
Where is my error? Any suggestion would be appreciated.


texts:
I want to send sms to a number if and only if that number is in the radius of the arduino with GSM module.

I already have GPS into it.

Should i integrate a ultrasonic sensor to get the distance and then send the message??? let me know if there is anyother option.

Thank you in advance.


texts: Problem with using SD and Adafruit_SSD1306 libraries at the same time

texts:
I am searched over the internet and found out a few similar questions, but non of them were helpfull, so I decided to open a new quetion.
I tried both SD and Adafruit_SSD1306 libraries and they both worked fine when they were separated - in different codes. The error came when I used them in one code.
In my programme I try to init SD card, write to it and then init dispaly (everything works fine). After that I do another write cycle into the SD, but I get an error in opening a file:
error opening test.txt

In other words I cant write anything into the SD card after oled display is initialized (display works then without any problems).
Here is my code:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

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

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32

TwoWire Wire1(PB9, PB8);// Use STM32 I2C2
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire1, -1);

const int chipSelect = PA15;

void setup() {

    Serial1.begin(9600);
   if (!SD.begin(chipSelect)) {
    Serial1.println("Card failed, or not present");
    // don't do anything more:
    while (1);
  }
  Serial1.println("card initialized.");

 for (int i = 0; i < 10; i++)
  {
  File dataFile = SD.open("test.txt", FILE_WRITE);

  if (dataFile) {
    dataFile.println("Test");
    dataFile.close();

    Serial1.println("Test");
  }
  else {
    Serial1.println("error opening test.txt");
  }
delay(30);
  }

  delay(2000);

 // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
 if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
    Serial1.println(F("SSD1306 allocation failed"));
  }

  delay(500);

  for (int i = 0; i < 10; i++)
  {
  File dataFile = SD.open("dat_test.txt", FILE_WRITE);

  if (dataFile) {
    dataFile.println("Test");
    dataFile.close();

    Serial1.println("Test");
  }
  else {
    Serial1.println("error opening test.txt");  //here is the error I get
  }
delay(30);
  }
}

void loop() {
}

Here is the output:
card initialized.
Test
Test
Test
Test
Test
Test
Test
Test
Test
Test
error opening test.txt
error opening test.txt
error opening test.txt
error opening test.txt
error opening test.txt
error opening test.txt
error opening test.txt
error opening test.txt
error opening test.txt
error opening test.txt

I am using STM32F103CB.


texts: How to take a CHAR change it into a int increment and then back to a Char for a clock display

texts:
So I'm using the NTP on the arduino.
I'm going to only ping the NTP once a day to truth up the clock. however the rest of the time I want just to use incrementing the minute and hour via ints.
I'm using a TFT display..so here is my issue.
The getLocaltime of the NTP seems to return a struct of characters. Which I'm able to push out to the screen every miniute. What I'd like to do is be able to get the NTP once a day and then just use the ESP32 clock to increment the minutes every 60000ms and then the hour when the min goes from 59 to 00....
I'm new to C and am not sure how to take the char to int and then increment it and then back to char to send to the display.
any help appreciated.
I think I determined an answer which seems to beworking OK. timeHour and timeMin are set from the NTP library in a previous Setup area.
if (currentMillis - timeMillisincrement > 60000){
timeMillisincrement = currentMillis;
int hh,mm;
sscanf(timeHour, "%02d", &hh);
sscanf(timeMin, "%02d", &mm);

if(mm == 59){
  mm = 0;
  if(hh == 23){
    hh = 0;
  }else{
    hh = hh + 1;
  }
}else{
  mm = mm + 1;
}

sprintf(timeHour,"%02d",hh);
sprintf(timeMin,"%02d",mm);

gslc_ElemSetTxtStr(&m_gui, m_pElemOutTxt1_3, timeHour);
gslc_ElemSetTxtStr(&m_gui, m_pElemOutTxt5, timeMin);


texts: How do I use a i2c port expander to read buttons with pull ups and inverting the resulting uint16_t?

texts:
I am using a mcp23017 to read button presses for my joystick project and am using the internal pullup to minimize complications. Is there a way to invert all the bits in the uint16_t so i can send the values as normally off?

I'm using this Adafruit library.

And the reading code: uint16_t buttons = mcp.readGPIOAB();


texts: Simplified timezone shapefile suitable for Arduino?

texts: Is there a library or shape file available that allows an Arduino to approximate a timezone based on a latitude/longitude coordinate? There is a timezone shape file available, but it's too detailed and too large. I am hoping someone knows of a simplified version small enough for an Arduino and/or a library that's able to handle this task.


texts: How can I declare global array with its length stored in EEPROM?

texts:
I am working with Arduino UNO connected with BV4612 display.
I am working on a simple code that controls several water pumps. Each pump has several modes it can run in. I store these modes in an array.
The number of water pumps may vary, and I'd like to store that value in EEPROM (either arduino's or display's).

When the pump count is fixed, I use fixed value, defined by macro:

#define     PUMP_COUNT      18      //How many pumps we have

uint8_t pumpModes[PUMP_COUNT];

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

I'd like to get rid of fixed defined value of PUMP_COUNT, and rather load it from EEPROM, or save the new pump count into the EEPROM if needed.
However, I can't declare an array if I can't read from EEPROM before setup() function like this (from address 32 for example):

uint8_t pumpModes[EEread(32)];

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

Is there a solution to get the value from EEPROM so I can declare global array's length with it?

Thanks.


texts: Trouble using proximity sensor as input and LED output

texts:
I was wondering if anyone had any pointers or advice to make this project work. Essentially I would like to have the LED fade (meaning like fade on and off at a calm rate) at one rate when there is nothing close to the proximity sensor, and then to speed up the fade amount when there is something close to the sensor.

#include <NewPing.h>   //include the library

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

int triggerPin = 12;   //pin conneccted to the Trig pin on the sensor
int echoPin = 11;       //pin connected to the Echo pin on the sensor
int maxDistance = 200;  //set the max distance for the sensor to read (helps with errors)
int distanceVal;        //variable to hold the distance val

int sampleRate = 200;   //how fast to sample the value
long lastReading;       //used for the timer

NewPing proximity1(triggerPin, echoPin, maxDistance);   //sets up the sensor object

void setup()
{
  Serial.begin(9600);  //start the serial port
  pinMode(led, OUTPUT);
}

void loop() {

    if(millis()-lastReading>=sampleRate) //this very simple statement is the timer,
  {
  distanceVal = proximity1.ping_cm();  //get the distance value in centimeters

  lastReading = millis();

  Serial.print("Distance Reading CM : ");  //print the value to the Serial monitor
  Serial.println(distanceVal);

if(distanceVal<20){

fadeAmount = 5;
}
else{
  fadeAmount = 2;
}

  // 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;
  }
  // wait for 30 milliseconds to see the dimming effect
  delay(30);
  }
}

https://github.com/sanaalla/Fade-LED-with-Proximity-sensor

Above is my code, which is not working. I am fairly new to Arduino and so would greatly appreciate some more seasoned wisdom!


texts: Arduino Uno Constantly Resets with WiFi and 4 Relay Module

texts:
I am using an Arduino Uno with a 4 relay module (found here: http://www.amazon.com/JBtek-Channel-Module-Arduino-Raspberry/dp/B00KTEN3TM?ie=UTF8&psc=1&redirect=true&ref_=oh_aui_detailpage_o04_s00) and an Adafruit CC3000 WiFi breakout board.  However, once I connect the power source, the board just constantly cycles on and off, e.g. about 1 second per cycle.  Could this have to do with too much current being drawn? Or that the current output of the digital pins isn't enough for all of the relay inputs? I'm new with this, but I am sure all of the pins are appropriately connected.

EDIT: If I use the USB connector (5V 1A) instead of the external power supply, I can connect 1 or 2 of the relays without problem, but must do so AFTER the wifi has already connected to the network, otherwise the wifi chip will never connect.  Also, if I toggle the relays a few times, the wifi becomes unresponsive.  I suspect a current issue maybe?. Any ideas? Thanks!


texts: Writing a new function: configMotor(speed, direction)

texts:
How can I create a function that can control a DC motor's speed and direction?

configMotor(int speed, direction){
   pwmVal = speed;

   //need help with code for picking direction
}

//move FORWARD
void moveForward(){
  analogWrite(pwn, pwmVal);
  delay(sDelay);
  digitalWrite(ina, HIGH);
  digitalWrite(inb, LOW);
}

//move BACKWARD
void moveBackward(){
  analogWrite(pwn, pwmVal);
  delay(sDelay);
  digitalWrite(ina, LOW);
  digitalWrite(inb, HIGH);
}

I don't know what to write in the code for configMotor function so that it can choose going forward or backward.


texts:
I'm controlling a Hitech HS-625MG servo from a 10k slider via a Nano. For a while the motion tracks the slider position even when moved quickly.

Then, for no reason I can find, it will stop following smoothly & only move in jittery steps & then move as expected again!

The code is cut & paste from the pot-servo example..

#include <Servo.h>

Servo myservo_1;  // create servo object to control a servo

int potpin_1 = A0;  // analog pin used to connect the potentiometer

int val_1;    // variable to read the value from the analog pin

void setup() {
  myservo_1.attach(7);  // attaches the servo on pin 9 to the servo object
}

void loop() {
  val_1 = analogRead(potpin_1);             // reads the value of the potentiometer (value between 0 and 1023)

  val_1 = map(val_1, 0, 1023, 0, 180);      // scale it to use it with the servo (value between 0 and 180)

  myservo_1.write(val_1);                   // sets the servo position according to the scaled value

  delay(15);                                // waits for the servo to get there
                                            // have tried values ranging from 5 to 25 same behaviour
}

YouTube vid of the behaviour

Anyone seen this kinda thing before?

EDIT: That is the full code listing & here's the circuit diagram, the same as the knob example frome the Servo examples page except the servo is not being powered by the Nano but is sharing the same power supply. (sorry not next to it at the moment)


texts: How to convert a delimited string of hex numbers to an int array

texts:
I am sending a string to the Arduino via serial, I made the program that sends the data, so I can change it to anything, but for now it sends a string of hex numbers delimited by ':', so for example 00:AA:FF and I need to get that into an int array onto the Arduino, the main problem is I don't always know how big the array will be, sometimes just 2 indexes, other times 16 indexes.

As I said, I made the program sending the data so I can make the data anything, I just need to get an int array to the Arduino and get it back as an int array via serial


texts: Find RSSI of Mobile Device Without Connecting

texts:
I have a device in which a user connects their mobile device to an arduino uno via a HM-10 bluetooth transponder.  I want to be able to calculate the approximate distance between the user and the transponder by hopefully using the RSSI methodology:

 d = 10 ^ ((TxPower - RSSI) / 20)

My goal is for the user to send a connection request to the HM-10, the uno to then calculate the distance, and if greater than x meters away, reject the request.  I realize RSSI based distance is an estimate at best but that is fine for my purposes.

With that in mind, I have two questions:

1.) Is an HM-10 able to capture the RSSI strength of a mobile device to
    calculate distance?
2.) Can it do so WITHOUT connecting first based on the
    initial request of the mobile device?


texts: Send commands from cPanel website to client ESP8266

texts:
I have a project where I want to remotely turn on and off a relay using an Arduino,(ESP8266) over the internet.

I have a remote web server that hosts my existing hobby website, cPanel hosted by GoDaddy Sites.
An Arduino (ESP8266) connects to this website listening for relay on/off commands.
Open a browser and load the webpage dashboard to sent commands to Arduino.

Yes I could have the Arduino poll the website ever so often to check for a value changed in a database, but I don't want to do that, Just seems unethical to me.
I was looking at WebSockets and thought that might be what I'm looking for but I know too little about it or there's not enough relevant documentation online about it to use it in this type of project.
I am looking forward to your comments and answers, but please do not tell me to host the site on the Arduino, and also using an app or other service is not going to work either, We are working with my own webpage and thats it no thirdparty apps, Thanks.


texts: How to you initialize a reset on a sht30 digital thermometer?

texts:
I have a sht30 that will output correct temperature readings for about 5 min and then will drift off.
So I'm trying to hit the reset every few seconds to keep the readings accurate.
I am on a nano connecting d4 to the sht30 reset pin, but I don't appear to be resetting. My temp still drifts.
How do you correctly hit the reset on a sht30?
code:
#include <Wire.h>

// SHT31 I2C address is 0x44(68)
#define Addr 0x45

int reset_pin = 3; // reset pin is set to d4 on board.
int counter = 0; //reset counter

void setup()
{
  // Initialise I2C communication as MASTER
  Wire.begin();
  // Initialise serial communication, set baud rate = 9600
  Serial.begin(115200);
  delay(300);
}

void loop()
{
  unsigned int data[6];

  // Start I2C Transmission
  Wire.beginTransmission(Addr);
  // Send 16-bit command byte
  Wire.write(0x2C);
  Wire.write(0x06);
  // Stop I2C transmission
  Wire.endTransmission();
  delay(300);

  // Start I2C Transmission
  Wire.beginTransmission(Addr);
  // Stop I2C Transmission
  Wire.endTransmission();

  // Request 6 bytes of data
  Wire.requestFrom(Addr, 6);

  // Read 6 bytes of data
  // temp msb, temp lsb, temp crc, hum msb, hum lsb, hum crc
  if (Wire.available() == 6)
  {
    data[0] = Wire.read();
    data[1] = Wire.read();
    data[2] = Wire.read();
    data[3] = Wire.read();
    data[4] = Wire.read();
    data[5] = Wire.read();
  }
  // Convert the data
  int temp = (data[0] * 256) + data[1];
  float cTemp = -45.0 + (175.0 * temp / 65535.0);
  float fTemp = (cTemp * 1.8) + 32.0;
  float humidity = (100.0 * ((data[3] * 256.0) + data[4])) / 65535.0;

  // Output data to serial monitor
  Serial.print("Temperature in Celsius :");
  Serial.print(cTemp);
  Serial.println(" C");
  Serial.print("Temperature in Fahrenheit :");
  Serial.print(fTemp);
  Serial.println(" F");
  Serial.print("Relative Humidity :");
  Serial.print(humidity);
  Serial.println(" %RH");
  delay(500);
  if(counter == 25){
    digitalWrite(reset_pin, HIGH); // sets the digital pin 13 on
    delay(1000);            // waits for a second
    digitalWrite(reset_pin, LOW);  // sets the digital pin 13 off
    delay(1000);
    counter  = 0;

  }
  counter++;
  Serial.println(counter);
}


texts: I set a project-goal for me: to make a very small compiler in Attiny.This compiler should read the code from user and translate it into code;then save it in some portion of the flash and jump there. I know this sounds impossible on Attiny85 but I want test self-programming. I read from various websites that the '85 does not have a "bootloader protection" like Atmga or Uno does. If it's true what are the functions used to write to the flash? (The only function I can thing of that access the flash is pgm_read_byte() but that is only for read).


texts:
I want to read a 4-20 mA analog signal from a 24V flowmeter. I've read the simplest way is to convert it into 1-5V signal using a 250 ohm resistor. The thing is I want my reading to be precise so my question is; is there any resolution loss when converting it to 1-5V?

I've also looked up on current to voltage converting boards similar to this one: https://www.sparkfun.com/products/14544

but I don't think they can detect 4mA signal.

I am a beginner in this so need some guidance here.


texts: Troubleshooting Program using sensors and actuators

texts:
I am doing a project on waste management. I have to separate waste majorly as metal, plastic and other materials. For that using Arduino Mega 2560. I have connected Inductive proximity sensor @ A0 (Anolog pin 1 of Arduino) & Capacitive proximity Sensor @ A1(analog pin 2 of Arduino). The two 5V DC motor which are to be used as actuators when the sensors sense the object.
I have given 12 V to the 2 sensors and I have directly connected the sensor's output pin with arduino.

If the Inductive sensor senses any metal object in the conveyor, the dc motor which is a actuator here has to rotate forward, wait sometime and to rotate reverse and stay until the next sense started.
The same for capacitive sensor.

But the problem was there is even though the sensor is not sensing the motor is running. The motor keeps on running forward, delayed and reverse. Please help me out for this, I don't know where I have done the mistake.

The program I have tried is here:

#define motorpin1 4 \\dc motor's pin 1
#define motorpin2 5 \\dc motor's pin 2
#define motorpin3 6 \\dc motor's pin 3
#define motorpin4 7 \\dc motor's pin 4

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(A0,INPUT);
  pinMode(A1,INPUT);
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  pinMode(8,OUTPUT);
  pinMode(9,OUTPUT);

}

void loop() {
  // put your main code here, to run repeatedly:
if((analogRead(A0)<400) && (analogRead(A0)>100)
{
  digitalWrite(motorpin1,HIGH);
  digitalWrite(motorpin2,LOW);
  delay(5000);
  digitalWrite(motorpin1,LOW);
  digitalWrite(motorpin2,HIGH);
  delay(5000);
  digitalWrite(motorpin1,LOW);
  digitalWrite(motorpin1,LOW);

}
if((analogRead(A1)<400) && (analogRead(A1)>100)
{
  digitalWrite(motorpin3,HIGH);
  digitalWrite(motorpin4,LOW);
  delay(5000);
  digitalWrite(motorpin3,LOW);
  digitalWrite(motorpin4,HIGH);
  delay(5000);
  digitalWrite(motorpin3,LOW);
  digitalWrite(motorpin4,LOW);

}


texts: how to break out servo.write(angle) after it reach the angle?

texts:
I used a servo as a grabber so I don't know the angle I need specifically.I need it to break the serve.write(angle) when the grabber holds something.
I used a simple code

#include <Servo.h>
Servo myservo;
void setup() {
  myservo.attach(9);
}
void loop() {
  myservo.write(100);
  delay(500);
  myservo.write(50);
  delay(500);
}

when it holds anything it deos not return to the small angle until I remove the obstacle from its way.


texts: How can i stop DC motor when button on remote is released?

texts: I am trying to control a motor using a remote with Arduino Mega. The motor turns on when I press the button on the remote but when I release the button, it continues to move. Does anyone know how to stop the motor spinning when I release the button on the remote?


texts: Resistance in Switch (negative vs positive logic)

texts: I tried in my Arduino the negative logic to get a digital input from a switch (with 10 KΩ resistance). If I want to use the positive logic what kind of resitance I have to use? For me seems that 10KOhm it to big and probably a smaller resistor should be used. How do we compute the value of the resistor? The schemes of Negative and Positive Logic from Valvano's notes/ebook - University of Texas gives 10 kΩ in both cases. Is it correct?


texts:
I'm planning on making my own Bluetooth mechanical keyboard using the Adafruit Feather 32u4 Bluetooth LE. Something that I haven't really figured out is the programming side of things. I was wondering if there is an easy to use library for this.

I know of the KeyPad library but I'm not sure how to handle modifier keys like Shift and CTRL with it. Any idea can help!

Edit: Like said before the project I'm working on is a Bluetooth mechanical keyboard. So this means there will be 85 (at least for my design) switches in a matrix.

In an ideal world the library I'm looking for can do the following: I specify the keys and their position in a matrix and what the modifier keys are. It can generate the appropriate ASCII character when the matching key(s) are pressed and return it or something, so that I can send it over Bluetooth in another piece of code.

In a less ideal world I use the KeyPad library but I don't really know how to take care of modifier keys like shift when doing that.

Have a nice day!


texts:
I have this simple push button schematic:

The idea is that the LED is on as long as the button stays pushed, with the switch closed.
The code is below:
int ledPin=10;
int switchPin=5;

void setup()

{
  Serial.begin(9600);
  pinMode(switchPin, INPUT);
  pinMode(ledPin,OUTPUT);

}
void loop()

{
  digitalWrite(ledPin,LOW);//DBG
  if (digitalRead(switchPin)==HIGH)
{
 digitalWrite(ledPin,HIGH);//DBG
 delay(500);
}
 if (digitalRead(switchPin)==LOW);
{
digitalWrite(ledPin,LOW);//DBG
delay(200);
}
}

As I keep the button pressed, the LED blinks regularly, instead of staying on. Why?
I have tried using a capacitor between the switch and switchPin, with no change.


texts: I am building a robotic arm using 8 servo motors. I am wondering about what voltage my external power will need to be to control all of them at 6v. I am wanting to use a rechargeable battery.


texts:
i wan’t to know if is possible to use  this raw e-ink display  with arduino. if it’s possible to directly connect cables from this ribbon cable to arduino without any driver pcb and control it with 3 or 4 wire SPI.
the pinout of the display is on the 6th page


texts: Calculating fluid volume using arduino sensors

texts:
I would like to measure liquid sealant volume inside bike tires, using sensor located between rim beads.
I guess it would by possible, by using ToF sensor, that would measure distance between rim and fluid surface.

Yellow - fluid itself
Than I would like to calculate fluid volume by using a formula for torus ?cap?

In another words: drained fluid would look like this cut section (not to scale):

Is there any mathematical formula to calculate volume of such "cap", based on its height and two torus radiuses? I only found formula for "ball cap" volume...

Or maybe there is better approach to measure volume, and I am doing it wrong?