texts: Arduino Force sensitive Resistor with an lcd

texts:
So we were asked to do something with a force sensitive resistor so naturally i thought of a project which takes the name of the main component which is force and applies it ,mine works by as  you apply more and more pressure to the sensor it takes this value and displays it on an lcd but the display should be a bar graph which increases as the pressure increases. the problem is i dont really know how to do a bar graph on a 16x2 lcd. Please help. (my lcd has an I2c)

here is my code for the pressure sensor so far

int fsrAnalogPin = 0; // FSR is connected to analog 0
int fsrReading;      // the analog reading from the FSR resistor divider

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

void loop(void) {
  fsrReading = analogRead(fsrAnalogPin);
  Serial.print("Analog reading = ");
  Serial.println(fsrReading);
  delay(100);
}

ok so i improved my code and i finally got it this code displays the force detected by the fsr into a bar graph

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LcdBarGraphX.h>
#include<LcdBarGraph.h>

byte lcdNumCols = 20; // -- number of columns in the LCD

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);   // -- creating LCD instance

int fsrAnalogPin = 0; // FSR is connected to A0

// -- creating a 4 chars wide bars
LcdBarGraphX lbg0(&lcd, 16, 0, 0); // -- First line at column 0 and row 0 with 16 columns

void setup(void) {
  Serial.begin(9600);   // We'll send debugging information via the Serial monitor
  lcd.begin(4, lcdNumCols); // start lcd with 2 rows and 16 columns
  lcd.clear();
  delay(100);
}

void loop(void) {
  lbg0.drawValue( analogRead(fsrAnalogPin), 9); // the 9  is the maximum range you want for pressure
  Serial.print("Analog reading = ");
  Serial.println(fsrReading);
  delay(100);
}


texts:
So I am trying to test what will eventually be a Arduino controlling 3 110V motors that are currently controlled by an analog pot. But more on that later.

I am trying to test out using a digital pot (never have before) and am running into some issues with tutorials I have found online. For now, I want to control a LED with the digital pot (Spec Sheet) so that the LED fades in and fades out in a continuos loop.

Here is the tutorial I followed. It uses a different chip model but it seems from the pot I am using that the pins are the same. (I could be wrong?)

I double and triple checked the wiring and it matches below.

Here is the code I am running (slightly modified from the tutorial, also tried the tutorial code)

#include <SPI.h>
byte address = 0x11;
int CS= 10;
int i=0;

void setup()
{
  pinMode (CS, OUTPUT);
  SPI.begin();
}

void loop()
{
    for (i = 0; i <= 128; i++)
    {
      digitalPotWrite(i);
      delay(10);
    }
    delay(500);
    for (i = 128; i >= 0; i--)
    {
      digitalPotWrite(i);
      delay(10);
    }
}

int digitalPotWrite(int value)
{
  digitalWrite(CS, LOW);
  SPI.transfer(address);
  SPI.transfer(value);
  digitalWrite(CS, HIGH);
}

As a result of the two above, I have an LED that stays lit (at about 50% it seems) and does not fade in/out at all.

Being relatively new to wiring and EE in general, is there a better way to replicate an analog pot without using a digital pot? Can I just use PWM to control it? Why would the LED be just staying lit?

Thanks!


texts: Not getting any output from ECG sensor AD8232

texts:
I am trying for the beginning to run a simple Arduino code in order to test the functionality of the ECG sensor. What I am getting on the output are some random values around 600 or around 200.
I connected everything the same as in any tutorial about AD8232:
GND -> GND, 3.3V -> 3.3V, L0+ -> digital pin 10, L0- -> digital pin 11, output -> analog pin A0.
I placed the sensor pads on my body like in pictures (forming a triangle), but regardless of putting the electrodes or not, I always get the same floating signal.
Here is Arduino code:

int ecg;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(10,INPUT);
  pinMode(11,INPUT);

}

void loop() {
  if((digitalRead(10) == 1)||(digitalRead(11) == 1)){
    Serial.println('!');
  }
    else{
    // send the value of analog input 0:
    Serial.println(analogRead(A0));
    }
    //Wait for a bit to keep serial data from saturating
    delay(1);
}

When I run this code I get only "!" on the output, no matter where I put the electrodes on my body. When I comment "if" and "else" parts of the code and print directly only reading from the pin A0, I get those random floating values, like on the image.

I also tried another custom built ECG sensor, but the results are the same. I haven't found the solution anywhere. It is not about the noise, because when I touch the metal box of my PC, I only reduce the values but there is still nothing on the output.


texts: Is it possible to change and save I2C address programatically?

texts:
I want to drive 3 i2c devices on a single i2c line. Is it possible to achieve this without using A0,A1,A2 pins?
I thought the address of i2c devices should be programmatically changeable.
2 mcp23017 and si5351 chips I use.


texts:
I'm working on a project with SDcard, and I would like to write int and long in a file.

If I try to write 0x1954 I had 0x5419 on my file with file.write() so I did a circular shifting like:

  data=(data<<8)|(data >> (16-8)); //circular shift
  file.write((char*)&data,sizeof(data));

But with a long, I have 0x54195521 on my file instead of 0x19542155.
So I don't know how to fix this. If you have any idea, I would like to read it ! (Or another way to do it)

Thanks !


texts: Difference between Ciao REST server and Ciao REST connector and when to use each or the other

texts:
I'm reading the Ciao library and can't make out the difference between Ciao REST server and Ciao REST connector.

When is the connector suitable and at what point do I need the server?

This is a graphic of what im thinking to do:


texts:
I've got an application that requires moving to specific points on a file on an SD card, reading, modifying and then writing an update.  The file is fixed size.  The code has no problems moving to the specific offsets required and then reading in blocks of data.

However, when the code does a seek() to the next desired location, then a write() and a flush(), the data is not written.  If my code seeks back to the start of the block just written and reads it back, it does not contain the new data.

The file is definitely open for writing, and the write operation indicates it wrote all the bytes.  No calls are indicating any error.

Since reads and seeks are working I'm assuming this is not a problem with wiring of the device to the Arduino Mega.  The files range from around 100K to almost 2M each, and the code needs to access the entire content of the file, but almost never sequentially.  Writes are almost always non-sequential as well.

Is it necessary to do a close after each write instead of the flush?

Does anyone have any suggestions of things I should be investigating?

Bob


texts: Using ESP8266 Adapter with Temperature/Humidity Sensor

texts:
Good Day. I am currently following a project where I can send data to my firebase database using an ESP8266-ESP01 wifi module and DHT11 temp/hum sensor.
I am using this adapter to enter the boot mode already with a program. Everything seems fine.

When I need to upload a program I am just tweaking the adapter using jumper cables to put the GPIO0 to GND and It works fine. My problem now is I have to use the DHT11 Sensor which is supposed to be connected to GPIO2. I tried to go to bootmode so  I connected DHT11(data) directly to the ESP8266(GPIO2) leaving the slot in the adapter empty in which I cant enter the boot mode for some reason.

But when I plug ESP8266(GPIO2) to the adapter slot, I can enter bootmode. Currently confused on how to tweak the adapter to be able to use the GPI02 to the DHT11. Any tips would really help. thanks!


texts:
I'm working to program DT-06 wireless wifi module.

And right now when i'm trying to program i get the following error message :
espcomm_send_command: can't receive slip payload data

Module RX - Arduino RX

TX - TX

VCC - 5v

GND - GND

Right now i can upload black program to arduino and send serial AT commands to my module and alson getting response.

How can i program ?

Thx

Appendix:

Module:  https://www.banggood.com/Geekcreit-DT-06-Wireless-WiFi-Serial-Port-Transparent-Transmission-Module-TTL-To-WiFi-p-1141047.html


texts:
I've reviewed the documentation

I'm still a little lost when it comes to applying the functions. Each of the redundancy check methods take in an unsigned char and return an unsigned char.

Shouldn't there be some sort of boolean return somewhere confirming that the data is accurate?

I've been trying to debug unsigned char* tempData = "snap" to the terminal, writing it directly to the register, according to the doc it should return h17:

  UDR0 = crc8(tempData,sizeof(tempData));

The terminal outputs '?' - as if it cannot be read.


texts: Arduino motor shield will only work in one direction

texts:
I have this Arduino motor shield which is hooked up with two DC motors. The board is the same as this one from Sparkfun.

A PWM output controls the speed of the motor, and a digital out controls the direction. The problem is that it only works in one direction, namely if the direction pin is high.

With the direction pin HIGH and 255 is written to the PWM pin, Vout on the terminals is similar to Vin. If I reverse the direction by setting the direction pin LOW I would expect Vout to be -Vin, ie. the polarity reversed. But not so. I get a little more than zero volt across the terminals.

It's the same for both channels.

Edit: The setup is powered from a 9V power adaptor through the barrel jack on Arduino.

Is the board defective, or am I misunderstanding something?

SOLUTION: Thanks to the edited post (especially #3) in the accepted answer, I not only looked at the schematic (again), I actually understood it. I had already noticed the jumper called V-LOGIC which on the picture from Sparkfun was set to 5V where it on my shield was not set. I really didn't know what it was used for, but I set it to 5V so it was the same. But by looking at the schematic and the inverters, I realized that the inverter was fed from V-LOGIC which was connected to 5V. And bingo: I had not connected the 5V pin on the shield, only vIN which I assumed would be sufficient. The thing is, I am awaiting a set of stackable headers instead of the ones supplied, so I only connected the minimum numbers of pins because I will need to desolder them when I get the new headers.


texts: Changing the mode when pressing/holding down a buttton

texts:
And first of all sorry for my bad English.

I am trying to write code that allows the user to change between continuous or manual mode, but I am having some issues getting it to work. The goal is to be able to switch from manual SOS (user pressing the button to SOS) and automatic SOS (the led automatically blinking SOS morse).

Currently, when I press down the button it loops once the automatic SOS and returns back to its normal state with LED on.

How would I make it, for an example switch the mode to manual when holding down button and giving user some sort of indication when changing the mode (etc blinking the led for X amount of time?)

What I am looking to achieve is:

Turn LEDS on when pressing the button.
Start looping automatic SOS signal
Press or hold down the button to change mode.

Blink LEDS to indicate the mode change.

Switch to manual SOS signal (user pressing the button to signal)
Press or hold down the button to change mode.

Blink LEDS to indicate the mode change.

Switch back to an automatic loop.

The code so far:

// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin =  13; // the number of the LED pin
int mode;

// variables will change:
int buttonState = 0; // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
}

void loop() {
  // read the state of the pushbutton value:
  mode = digitalRead(buttonPin);

  // Manual SOS mode.
  buttonState = mode;

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == LOW) {
    digitalWrite(ledPin, HIGH); // turn LED on:
  } else {
    digitalWrite(ledPin, LOW); // turn LED off:
  }

  // Automatic SOS mode.
  if (mode == HIGH) {
    // check if the pushbutton is pressed.
    // if it is, starts looping automatic SOS.
    int i = 0;
    for (i=0; i<3; i++) {
      digitalWrite(ledPin, HIGH);   // turn the LED on
      delay(300); // wait for a second
      digitalWrite(ledPin, LOW); // turn the LED
      delay(300); // wait for a second
    }

    for (i=0; i<3; i++){
      digitalWrite(ledPin, HIGH); // turn the LED on
      delay(1200); // wait for a second
      digitalWrite(ledPin, LOW); // turn the LED
      delay(1200); // wait for a second
    }

    for (i=0; i<3; i++){
      digitalWrite(ledPin, HIGH); // turn the LED on
      delay(300); // wait for a second
      digitalWrite(ledPin, LOW); // turn the LED
      delay(300); // wait for a second
    }
    digitalWrite(ledPin, LOW);
    // waits 3 seconds before starting the loop again
    delay(3000);
  }
}


texts: How to control a DC Motor with Hall Encoder using Arduino and Motor Driver?

texts:
I'm using a DC motor with Hall Encoder. I bought it from DX.

I have made all the connections to motor driver and arduino and I suppose all are correct. I've connected m1 and m2 pins of motor to that of motor driver, encoder A phase and B phase to arduino pins 3 and 11, and GND of motor to GND of Arduino and 3.3V pin of motor to 3.3V pin of Arduino. Also motor driver is also connected to arduino.

The problem is that I'm unable to run the motor but I can count the rotations made by the motor. Please help me with the working code. Thanks.


texts: How can I connect a Fona to an Adafruit feather?

texts:
I have this adafruit-feather-huzzah-esp8266:
https://learn.adafruit.com/adafruit-feather-huzzah-esp8266/pinouts

and I want to connect a Fona board. But I am not certain which pins have the aforementioned software serial pins
necessary to make the required connections.
https://www.arduino.cc/en/Reference/SoftwareSerial

from the Fona tutorial:
https://learn.adafruit.com/adafruit-fona-3g-cellular-gps-breakout/arduino-wiring

which pins on the adafruit-feather-huzzah-esp8266 should I use for pin:
"TX connects to digital 3 (9 on Leo/Micro, 10 on Mega) "

where the feather doesn't have this a pin3.
similarly, which pins correspond to RST and RX?


texts:
Have an upcoming project where user input will be based on spinning a large cog and I have several UNOs available

Since rotary encoders need two pins, only a Mega would be able to handle the 7-8 encoders needed. Unless theres a better method of reading them?

Is it worth using an ATTiny85 per encoder and passing all this data to a mega via 1 pin each? This way, I could extend the project beyond 7-8 later?

Or is this idea out the window, because there's a much simpler way?


texts:
Two goals:

Make an LED turn on when a person touches two conductive pads (e.g. two square of aluminum foil)
Make the RGB LED change color depending on how hard the pads are squeezed. I will figure out the color algorithm later. For now I just need to be able to sense variable conductivity/capacitance/current (one of those?).

I have an Arduino LilyPad. I know this can be done because I've seen it before (just don't remember the code or circuit). Example image:

I know the human body is conductive, so I'm not quite sure why the LED won't go on when I contact the conductive pads. My only hypothesis is that the resistance is too high, but that must mean some current is going through, no?

Thanks.


texts: How to connect naked camera from mobile phone to Arduino Uno

texts: Okay, guys. I have this 3 cameras(middle from the iPhone 6s, 2 at the side I found, and I think there are from modern phone). I need some information how to connect Arduino Uno to them. I know c/c++, assembler, but noob in microcontrollers, if this knowledge can come useful.


texts: Unstable reading from pushbutton on digital pin

texts:
I use the Pin 7 to get the status of a push button. I put 10Kohm R on the - .

The status is unstable because arduino says thet I push it but it is not true...

int button = 7;
...
// var for reading pushbutton value
int buttonState = 0;
...
buttonState = digitalRead(button);
  if(buttonState == HIGH)
  {
    myFunction();
  }

EDIT :

ARDUINO PIN 7 <---> R 10Kohm <--> [switch] <---> VCC


texts:
While developing a lot of projects (In Arduino IDE) for ESP32 one common issue I am facing is termination of program execution on unhandled exceptions. There are various exception I get.  For example: stack canary watchpoint triggered (looptask), invoke_abort, etc. I have no idea how to handle them, hence I prefer to restart the ESP manually.
Is there any way where I can restart the ESP32 automatically on all unhandled or unfortunate exceptions other than handling the exceptions ?


texts: analogRead Function AC Voltage Reading Capabilities

texts: Usually when you sense AC voltage, you get a sinusoidal waveform. However, for AC voltage sources, Arduino analogRead ( ) only presents positive voltage values. So what's basically happening? Is it skipping half the cycle where the voltage is negative. If so, how can I account for that when I try to use the voltage values to calculate for total electrical energy generated by the source (piezoelectric film) and avg. power?


texts: Can I use a spare Darlington Pair on my ULN2003A to drive a DC motor?

texts:
I'm successfully running a stepper from my Arduino via a ULN2003A and a secondary power supply. It uses the first four of the seven Darlington Pairs on the chip, leaving three spare.

A) Is there any reason I wouldn't be able to use one of the remaining pairs to drive a standard DC hobby motor? (For the sake of helping future visitors .. what about running three motors off the remaining three pairs?)

B) Do I need anything other than to connect the motor to the chip? (The chip's board has LEDs and resistors on each of pins 1 - 4, but I don't believe they're in series and thus my guess is they can be left off.)

C) The DC motor is on a PWM Pin. Is that the correct way to control its speed?

The image attached shows the setup in case I haven't been clear.

(I could probably just build it and see, but I'm new to Arduino and still scared of the blue smoke if I get something wrong!)


texts: Arduino Uno with Kubuntu 16.04: Unable to enumerate device

texts:
I try to connect my arduino uno R1 in order to program the atmega8u2 but I am not able to do so. When I run sudo dfu-programmer atmega8u2 erase I get the following results:

dfu-programmer: no device present.

So in order to diagnose it i run dmeesg with the following results:

 [ 1395.921051] usb 2-3: new full-speed USB device number 30 using
 xhci_hcd [ 1396.041175] usb 2-3: device descriptor read/64, error -71
 [ 1396.269135] usb 2-3: device descriptor read/64, error -71 [
 1396.497109] usb 2-3: new full-speed USB device number 31 using xhci_hcd [ 1396.617169] usb 2-3: device descriptor read/64, error -71
 [ 1396.845177] usb 2-3: device descriptor read/64, error -71 [
 1397.073163] usb 2-3: new full-speed USB device number 32 using xhci_hcd [ 1397.073371] usb 2-3: Device not responding to setup
 address. [ 1397.281311] usb 2-3: Device not responding to setup
 address. [ 1397.489086] usb 2-3: device not accepting address 32,
 error -71 [ 1397.609173] usb 2-3: new full-speed USB device number 33
 using xhci_hcd [ 1397.609382] usb 2-3: Device not responding to setup
 address. [ 1397.817200] usb 2-3: Device not responding to setup
 address. [ 1398.025176] usb 2-3: device not accepting address 33,
 error -71 [ 1398.025235] usb usb2-port3: unable to enumerate USB
 device

Do you know fellows how to make my arduino connect back into my computer?

Furthermore II forgot to mention my user is in dialout group as groups gnu/linux command mentions:

pcmagas adm dialout cdrom sudo dip plugdev lpadmin sambashare libvirtd docker wireshark

PS: That thing happened after soldering the resistor into the board so it is a new problem.


texts: "stray '/302' in program error" when compiling

texts:
For some weird reason, the following code doesn't compile. I get a "stray '\302' in program" error around volatile unsigned int encoderPos = 0;, and I have no idea what the issue is. I've been trying to figure this out for over 40min, and nothing works. It doesn't make any sense

#include <U8g2lib.h>
#include <SPI.h>

//Pin definitions:

const int control_PWM = A3; //PWM output for the delay

const int btn_1 = 1; //Button for mode 1
const int btn_2 = 4; //Button for mode 2
const int btn_3 = 5; //Button for mode 3

const int r_A = 2; //Rotary encoder A's data
const int r_B = 3; //Rotary encoder A's data
const int r_SW = 0; //Rotary encoder's button data

const int oled_CLK = 9; //SPI cloack
const int oled_MOSI = 8; //MOSI pin
const int oled_CS = 7; //Chip Select pin
const int oled_DC = 6; //OLED's D/C pin
U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);

int mode = 1; //1: RGB, 2: HSL, 3: Distance control
int value_selection = 1; //Actual value selectrion
int value1 = 0; //red in mode 1; tint in mode 2
int value2 = 0; ////green in mode 1; saturation in mode 2
int value3 = 0; //blue in mode 1; luminosity in mode 2

volatile unsigned int encoderPos = 0;  // rotary encoder's current position
unsigned int lastReportedPos = 1;   // rotary encoder's previous position
static boolean rotating=false;      // is the encoder activity status

// interrupter variables
boolean A_set = false;
boolean B_set = false;
boolean A_change = false;
boolean B_change= false;
void setup() {

}

void loop() {
}


texts:
I am in a First Year Design class, and we are supposed to be making an autonomous robot. After hooking up some wind speed and temperature sensors to calibrate, I plugged in to my laptop (we have 2 arduino nanos) and ran a temperature code. I got the reading, but smelled something burning. Nothing was smoking, but I've found that when I plug my arduinos into my laptop, the light and the code indicate that they are not connected. This is odd because when I plug in the batteries, they show that the proper voltage is coming through, but they will still not connect to the laptop. Is it a problem with the micro-usb port?

I've included the code I'm using just in case that is cause for suspicion. It is notable that our instructors have written an API that allows us to code in Java for the arduinos.

public static void main (String[] args)
{
    robot = new ArduinoNano();
    robot2 = new ArduinoNano();
    robot.setPort("COM5");
    robot2.setPort("COM6");
    robot.connect();

    int reading = getThermistorReading();

    System.out.println("The probe read the value " + reading);
    System.out.println("In volts: " + (reading * (5.0/1023.0)));
    System.out.println();

    double temperature = (reading - 855.02) / -7.563;

    System.out.println("Temperature: " + temperature);

}

public static int getThermistorReading()
{
    int sum = 0;
    int readingCount = 10;

    for (int i = 0; i < readingCount; i++)
    {
        robot.refreshAnalogPins();
        int reading = robot.getAnalogPin(3).getValue();
        sum += reading;
    }

    return sum / readingCount;
}

}


texts: can ModbusRtu.h library send data from slave to master using modbus(RS485) module?

texts:
i am using ModbusRtu.h library for modbus protocol. it works for sending data from master to  slave but it can not send data from slave to master.

master code:

#include <ModbusRtu.h>
  #define SERIAL_BUFFER_SIZE 64
// data array for modbus network sharing
uint16_t au16data[26];
uint8_t u8state;

/**
 *  Modbus object declaration
 *  u8id : node id = 0 for master, = 1..247 for slave
 *  port : serial port
 *  u8txenpin : 0 for RS-232 and USB-FTDI
 *               or any pin number > 1 for RS-485
 */
Modbus master(0,Serial1,8); // this is master and RS-232 or USB-FTDI

/**
 * This is an structe which contains a query to an slave device
 */
modbus_t telegram;

unsigned long u32wait;

void setup() {
  Serial1.begin( 19200 ); // baud-rate at 19200
  Serial.begin( 19200 ); // baud-rate at 19200
//  master.start();
 master.begin();
  master.setTimeOut( 2000 ); // if there is no answer in 2000 ms, roll over
  u32wait = millis() + 1000;
  u8state = 0;
}

void loop() {

    telegram.u8id = 2; // slave address
    telegram.u8fct = 3 ; // function code (this one is registers read)3
    telegram.u16RegAdd = 0; // start address in slave 1     slave array index 0 dhora
    telegram.u16CoilsNo = 2; // number of elements (coils or registers) to read 4  //master array er koyta(not start from 0) value show korba
    telegram.au16reg = au16data; // pointer to a memory array in the Arduino
    int x = master.poll(); // check incoming messages
    Serial.print("x: ");
    Serial.println(x);
                if (master.getState() == COM_IDLE)
                {
                   master.query( telegram ); // send query (only once)

                }
Serial.print("Recieve: ");
      for (int i = 0; i < 5; i += 1)
      {
        Serial.print(au16data[i]);
        Serial.print(",");
      }
      Serial.println("");
}

slave code:

#include <ModbusRtu.h>
#define SERIAL_BUFFER_SIZE 64
// data array for modbus network sharing
//uint16_t au16data[26] = {
//  3, 1415, 9265, 4, 2, 7182, 28182, 8, 0, 0, 0, 0, 0, 0, 1, -1 };
uint16_t au16data[26] = {4,17,89};
int led = 13;
/**
 *  Modbus object declaration
 *  u8id : node id = 0 for master, = 1..247 for slave
 *  port : serial port
 *  u8txenpin : 0 for RS-232 and USB-FTDI
 *               or any pin number > 1 for RS-485
 */
Modbus slave(2,Serial1,8); // this is slave @1 and RS-232 or USB-FTDI

void setup() {
  Serial1.begin( 19200 ); // baud-rate at 19200
  Serial.begin( 19200 ); // baud-rate at 19200
  pinMode(led, OUTPUT);
  slave.begin();
  //slave.start();
}

void loop() {

  slave.poll( au16data, 26 );

   Serial.print("Recieve: ");
      for (int i = 0; i < 5; i += 1)
      {
        Serial.print(au16data[i]);
        Serial.print(",");
        if(au16data[3] == 1)
        {
          digitalWrite(led, HIGH);
         // Serial.println("in");
        }
         if(au16data[3] == 2)
        {
           digitalWrite(led, LOW);
           //Serial.println("else");
        }
      }
         Serial.println("");

       memset(au16data, 0, 26 * sizeof(uint16_t)); // recieveLargeArray = {}
}


texts:
Is arduino code Consume More power other than "Avr Studio" Code?

Please tell some key points for power saving.
Processor on $ off Methodology.


texts:
I´m using Spark Fun Micro Pro board 5V: https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/hardware-overview-pro-micro

and to that i´ve hooked a true color OLED from digole: http://www.digole.com/index.php?productID=859

I manage to get my VAL from my potentiometer on screen. But when I exceeds val "10", and then go back to lets say "9", the zero from "10" is still there. It looks like:  "90" instead of "9". The problem is of course that the second (and third) number don't go away.. Im sure there is a simple way of doing this but I can't get my head around it..
I´ve tried using clearScreen but that function makes the OLED blink in a unpleasant way every time it clears... Hope you get my question, english isn't my native language, as u maybe can tell =)
Thanks

void loop()
{
  val = analogRead(potpin);        // reads the value of the     potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 0, 179);  // scale it to use it with the servo (value between 0 and 180)
  myservo.write(val)  sets the servo position according to the scaled     value
  mydisp.clearScreen();
  mydisp.setPrintPos(9, 6);
  mydisp.print(val);

  delay(200);  // waits for the servo to get there
 // mydisp.clearScreen();

}


texts: How to send characters to Arduino serial using Linux command line without tail -f?

texts:
I want to send characters to Arduino serial port which makes the Arduino turn on/off an LED. Here is the code:

int led_main=8;

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

    Serial.begin(9600);
}

void loop()
{
    char chr;

    if (Serial.available())
    {
        chr = Serial.read();

        if (chr == '0')
        {
            digitalWrite(led_main, LOW);
        }
        else if (chr == '1')
        {
            digitalWrite(led_main, HIGH);
        }
    }
}

The Arduino is recognized as either /dev/ttyACM0 or /dev/ttyACM1 in my system. When I run the command echo "1" > /dev/ttyACM0, it doesn't work. But, when I open a second terminal, run tail -f /dev/ttyACM0, and then in the first terminal, run echo "1" > /dev/ttyACM0, it turns on the LED as expected. So why do I have to open a second terminal and keep monitoring the output with tail -f in order for this to work? Is there a way to do this with a single command?


texts: What's the benefits between different interrupts on Arduino

texts:
On an Arduino you can have several different interrupt types, two of them being RISING and FALLING. Looking past that RISING is from LOW to HIGH, and FALLING is the opposite, what are the benefits of using one or the other?

To clarify; why would you use a RISING interrupt or a FALLING interrupt?


texts:
Are there Arduino UNO R3s which use a crystal instead of a ceramic resonator?

(Frankly, I don't understand this cheapness: if you really want to save on component cost you can run both AVRs on the same crystal. The 16U2 always has a crystal.)


texts: Are hardware interrupts used while controlling an LCD screen using the LiquidCrystal library?

texts:
I'm working on a tone generator project that uses Mozzi to make sound (sine waves mainly). As I understand, Mozzi can glitch if used along with hardware interrupts.

The plan is to use the classic 2x16 LCD screen, but I don't know the guts of the library or interface. Are hardware interrupts used while interfacing with an LCD screen, or by the LiquidCrystal library?


texts: Mapping values from analog input giving unexpected values?

texts:
Mega 2560

I am reading in values from 3 pots then mapping them to values between 0 - 255

#define REDPIN   7
#define GREENPIN 8
#define BLUEPIN  9

int red_pot   = A0;  // analog pin used to connect the potentiometer
int green_pot = A1;
int blue_pot  = A3;

void setup() {

  pinMode(REDPIN,   OUTPUT);
  pinMode(GREENPIN, OUTPUT);
  pinMode(BLUEPIN,  OUTPUT);

  Serial.begin(38400); //Debug port
  Serial.setTimeout(50);
}

void loop() {

  int red, green, blue;

  red   = analogRead(red_pot);
  green = analogRead(green_pot);
  blue  = analogRead(blue_pot);

  Serial.print(" r = ");
  Serial.print(red);

  Serial.print(" b = ");
  Serial.print(blue);

  Serial.print(" g = ");
  Serial.print(green);
  Serial.print("\n\n\n");

  // map values
  red   = map(red,   20, 650, 0, 255);
  green = map(green, 20, 570, 0, 255);
  blue  = map(blue,  20, 570, 0, 255);

  Serial.print("red map : ");
  Serial.print(red);

  Serial.print(" green map : ");
  Serial.print(green);

  Serial.print(" blue map : ");
  Serial.print(blue);
  Serial.print('\n\n\n');

  analogWrite(REDPIN,   red);
  analogWrite(GREENPIN, green);
  analogWrite(BLUEPIN,  blue);
}

red & green behave as expected but blue is not, from the serial monitor...

When blue is at its lowest value,

When blue is at its highest value,

I have changed blue's analog pin assignment but the same issue.

Any clues what's happening?

EDIT #1

I thought it might be some int sign error so I changed the map operation to,

blue  = map(abs(blue), 20, 670, 0, 255);

It made no difference.


texts: Is there any easy way to change Arduino Wifi shield to ESP8266?

texts:
As the title says, is there any easy way to replace WiFi shield with ESP8266, with as little as possible modification to code?

Here is my ESP:


texts: Nesting loops - if statement in a while loop

texts:
I have been trying many variations of code like this, cannot seem to get this to work with how I logically would think it would work.  Am I missing something with syntax or breaking some rules?  Everything works independently but not jointly.

int switchS = 0;
int var = 1;

void setup() {
    pinMode(1,INPUT);
    pinMode(7,OUTPUT);
    digitalWrite(7,LOW);
}

void loop() {
    switchS = digitalRead(1);
    while(var == 1)
    {
        digitalWrite(7,HIGH);
        delay(100);
        digitalWrite(7,LOW);
        delay(100);
        if(switchS == HIGH)
        {
            var = 0;
        }
    }
    delay(5000);
    var = 1;
}


texts: Data transmission rate of accelerometer mpu6050 to arduino uno vs Sampling rate of mpu6050

texts:
mpu6050 has sampling frequency of 1kHz (mentioned in datasheet). But when i interface it with arduino uno via I2C communication (400Khz bus speed), i only get 50 raw data (each of x,y,z). There is no delay in the program. why is this happening. Why am I not getting 1000 or at least 800 samples. What is the concept I am missing here. Please explain in detail. I have also attached the code and output for 1 second.

#include "I2Cdev.h"
#include "MPU6050.h"
#include "Wire.h"
//#include <SoftwareSerial.h>
//SoftwareSerial BTserial(10,11);
MPU6050 accelgyro;
char ch;
int incomingbyte = 0;
int16_t ax, ay, az;
int16_t gx, gy, gz;

void setup() {

  Wire.begin();
  Serial.begin(115200);

  accelgyro.initialize();
  accelgyro.setXAccelOffset(542);
  accelgyro.setYAccelOffset(-835);
  accelgyro.setZAccelOffset(1651);
  accelgyro.setXGyroOffset(6);
  accelgyro.setYGyroOffset(-18);
  accelgyro.setZGyroOffset(23);
}
void loop()
{
  accelgyro.getAcceleration(&ax, &ay, &az);
  accelgyro.getRotation(&gx, &gy, &gz);

  Serial.print(ax); Serial.print("\t");
  Serial.print(ay); Serial.print("\t");
  Serial.println(az);
}


texts: I am using Linux Fedora 20. In order to compile C programs for the Arduino, as described in the book "C Programming with Arduino" by Warwick A Smith, pub by Elektor, I have downloaded and untarred/unzipped "avr8-gnu-toolchain-3.5.1.1671-linux.any.x86.tar.gz". That's as far as I can get. Please how do I proceed from this point? Is there anything else I need or should have done?


texts: millis and micros always returns 0 (or other constant)

texts:
On an Arduino Uno, I have a sketch akin to this:

void setup()
{
    // Generate some PWM signal on Pin 5, using Timer 0.
    pinMode(5, OUTPUT);
    TCCR0A = 0b00110011;
    TCCR0B = 0b00001000;
    OCR0A = 0x80;
    OCR0B = 0x20;
    TIMSK0 = 0b00000100;

    Serial.begin(115200);
}
void loop()
{
    // Just write the result of millis to the terminal.
    unsigned long ms = millis();
    char s[100];
    sprintf(s, "%lu\r\n", ms);
    Serial.print(s);
}

Setup timer 0 to generate a PWM signal, setup the serial port, constantly print the result of millis() to the terminal.

The numbers printed to the console do not increase as expected, but stay "0".
Similarly, if I use micros, "4" is printed constantly.

How's that?


texts: After putting Arduino Uno into DFU mode, it is no longer recognised by PC

texts:
My Arduino just stopped working after putting it into DFU mode.
I did not flash any firmware.
Could it be stuck in DFU mode?
I have a UNO r3.


texts:
Having most of my experience on ATmega chips, and just starting up with Arduino (to reduce hardware development time) I'm happy to see that the usual registers such as TIMSK0, PCICR, TCNT1H and others can be used from the Arduino IDE just as they appear in the Atmel datasheet.

Migrating to the Arduino Due, however, came with a shock: the registers specified in the datasheet of the Cortex-M3 are not recognized by the Arduino IDE (although I downloaded the extension necessary for being able to select the Due). I wanted to do something very simple, like configuring a timer. I found TC_CMR0 in the datasheet, but the Arduino IDE doesn't recognize it. I found an example using the Arduino Due with timers in an obscure forum, and they used REG_PWM_CMR0. I tried it in the Arduino IDE, and it was accepted by the compiler.

I searched the Arduino and other forums, and couldn't find any hint whatsoever about the naming of the registers. Why are the names of the registers different? And can I find a conclusive documentation about the register names, or am I doomed to research each and every one of the hundreds of registers individually?


texts:
I've been trying, just out of curiosity, to write my own function that generates a PWM signal, just like analogWrite(), and to make it light up an LED. Here's my attempt so far:

const int pin = 3;
int cycle = 2; // analogWrite() outputs a 498 Hz signal, so each cycle has approximately 2ms

int duty = 0.5; // for a 50% duty cycle

void setup() {
  Serial.begin(9600);
  pinMode(pin,OUTPUT);
}

void loop() {
  digitalWrite(pin,HIGH);
  delay(cycle*duty);
  digitalWrite(pin,LOW);
  delay(cycle*(1-duty));
}

The LED does light up, but very dimly, as shown below:

However, when using analogWrite() with a 50% duty cycle to achieve the same result, the LED shines much brighter:

Is there something wrong with my code, or is there a special reason why more power is dissipated with analogWrite()?


texts:
I want to control Lego Technic Servo Motor 88004.

The way it works is - Lego has a 4 cable connector. Two of them supply power (+9V & GND) and the other are optionally +9V and they are called C1 and C2.

Servo turns right or left max 90 deg when you supply PWM to either C1 ("left") or C2 ("right"). (or the other way round, but it doesn't really matter)

That basically means that what I need is a 9V PWM and be able to supply it to either C1 or C2. What is more the frequency has to be 1150 Hz.

Now the question is how do I achieve this goal?

I'm already using the L298N motor controller and happen to have one engine slot free.

1) If I can supply PWM from Arduino to "LNA" input in L298N - will it also cause the output to be PWM?
Because L298N has a transistor I have a feeling that the output is also going to be PWM unless there's something else there i.e. capacitor

Even if it's not does that matter at all - meaning is it going to still work?

2) How do I produce PWM with 1150 Hz from Arduino? My Arduino is 16MHz so I suppose that it should be possible to switch output with order of magnitude smaller frequency.

If what I'm trying to do makes no sense please try to point me to the right direction.


texts: Instance does not name a type, in function void loop (8x8 matrix)

texts:
Hey guys I'm doing a beginners project 8x8 matrix and I have some errors when compiling

The Errors are;

MyBlink:0: error: 'Instance' does not name a type
MyBlink.cpp: In function 'void loop()':

-MyBlink:40: error: 'row1' was not declared in this scope

 Instance code:
//the pin to control ROW
const int row1 = 2; // the number of the row pin 9
const int row2 = 3; // the number of the row pin 14
const int row3 = 4; // the number of the row pin 8
const int row4 = 5; // the number of the row pin 12
const int row5 = 17; // the number of the row pin 1
const int row6 = 16; // the number of the row pin 7
const int row7 = 15; // the number of the row pin 2
const int row8 = 14; // the number of the row pin 5
//the pin to control COl
const int col1 = 6; // the number of the col pin 13
const int col2 = 7; // the number of the col pin 3
const int col3 = 8; // the number of the col pin 4
const int col4 = 9; // the number of the col pin 10
const int col5 = 10; // the number of the col pin 6
const int col6 = 11; // the number of the col pin 11
const int col7 = 12; // the number of the col pin 15
const int col8 = 13; // the number of the col pin 16
void setup(){
int i = 0 ;
for(i=2;i<18;i++)
{
pinMode(i, OUTPUT);
}
pinMode(row5, OUTPUT);
pinMode(row6, OUTPUT);
pinMode(row7, OUTPUT);
pinMode(row8, OUTPUT);
for(i=2;i<18;i++) {
digitalWrite(i, LOW);
}
digitalWrite(row5, LOW);
digitalWrite(row6, LOW);
digitalWrite(row7, LOW);
digitalWrite(row8, LOW);
}
void loop(){
int i;
//the row # 1 and col # 1 of the LEDs turn on
digitalWrite(row1, HIGH);
digitalWrite(row2, LOW);
digitalWrite(row3, LOW);
digitalWrite(row4, LOW);
digitalWrite(row5, LOW);
digitalWrite(row6, LOW);
digitalWrite(row7, LOW);
digitalWrite(row8, LOW);
digitalWrite(col1, LOW);
digitalWrite(col2, HIGH);
digitalWrite(col3, HIGH);
digitalWrite(col4, HIGH);
digitalWrite(col5, HIGH);
digitalWrite(col6, HIGH);
digitalWrite(col7, HIGH);
digitalWrite(col8, HIGH);
delay(1000);
//turn off all
for(i=2;i<18;i++) {
digitalWrite(i, LOW);
}
delay(1000);
}


texts: In-application programming for the Arduino Uno

texts:
I would like to know if it is possible to read from and write to the microcontroller's (Arduino Uno's ATmega328P) flash memory using a program or "bootloader" previously stored in the flash memory (or the EEPROM memory) itself.

If it is possible, can it be done using the Arduino IDE?


texts: How can i tell the power status of a GSM900

texts:
What I am after is a reliable way of telling whether the GSM900 shield is powered up or not.  "Obviously" the shield power is the constant green light.  But i'm talking about the red light on the other side (next to the flashing green light).

I know i can PowerUp/Down by using the code

digitalWrite(9, HIGH);
Serial.println("write 9 high");
delay(1000);
digitalWrite(9, LOW);
Serial.println("write 9 low");
delay(5000);

And from the AT command manual, I can Power it down by using the command...

AT+CPOWD=1

So it seems that the only way I can ensure that the board is On, is to power it down and then toggle the power.  Surely there's a better way than that?

Another idea is to issue a simple "AT" command, and if I get back "OK" then its on, and if I dont get anything back (timeout of maybe 2 seconds), then its off - thoughts?


texts: How often can I ping an HC-SR04 ultrasonic sensor?

texts:
In my current project, I want the sensor to be continuously scanning for a value of less than 30cm. I was wondering how long of a delay I need (if any) between each call of the ping function. It currently works at 150ms between each ping call with no problem. The less the delay, the better for my project. This is the ping function:

void ping() {
  digitalWrite(trig, LOW);
  delayMicroseconds(2);
  digitalWrite(trig, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig, LOW);
  duration = pulseIn(echo, HIGH);
}

For example, would having a delay of only 5ms be sufficient?


texts:
I am just starting out with an Arduino Diecimila and am playing around with LEDs, and am confused by why some circuits result in an LED not lighting up.

Successful Scenarios:

Yellow LED from pin13 to 16B on the breadboard, Green LED from 16A to GND. This works both LEDS light up.
Yellow LED from pin13 to 16A on the breadboard. Wire from 16E to 14E. Green LED from 14A to GND. This works and both LEDs light up.

Failed Scenarios:

Yellow LED from pin13 to 16A. Green LED from 16E to 14E. Yellow LED from 14A to GND. No LEDs light up. I would assume that all the LEDS are in series, and all 3 should light up, I assumed this would be exactly the same as my second successful scenario where the LED is acting the same as the wire.
Yellow LED from pin13 to 16A. Wire from 16E to 14E. Yellow LED from 15A to GND. Green LED from 16B to 14B. Here I have both Yellow LEDS lit, but the Green LED is not lit. I was expecting that the Green LED would have been in parallel and should have lit up.

In both failed scenarios I have swapped around the LEDs and proved that all the LEDs function.

There must be some basic concept that I am not understanding with the circuits, any ideas?


texts: How to know if a tof VL53L0x sensor is dead or not

texts:
I bought a bunch of VL530X time-of-flight sensors on Aliexpress. They seemed to work fine. Then I connected two of them on the same Arduino Uno board to test with the Adafruit example "dual". During rewiring I may have used the 5v power pin of the Arduino instead of the 3.3v (I can't remember).
Now the sensors won't boot. They fail during setup with error -6 which is documented as "RANGE ERROR".
Yet, scanning for either of them does find a sensor at the default address 0x29.
How can one know if they're dead or if they can somehow be revived?
The Uno works fine with any other VL53L0x, just not those two. I could certainly just trash the ones that won't boot but I would be interested in a procedure to know for sure; it would be very useful when going into production.
The last answer on this thread an ST forum points to the I2C bus, but I don't understand what is being recommended.


texts: Trying to send serial data to computer over network from Arduino Yún

texts:
Using Console.write() to send data to my computer over network, which works when I use the serial monitor. However, I'm using PLX-DAQ to receive Serial communication and input it into an Excel document. The problem with that is that PLX-DAQ only has the option to listen over physical ports.

Is there a workaround to this?

If it helps, the computer is a Windows machine.


texts: I've been playing with the HC-06 BT module lately, but now I want to do more with it and I'm not sure how to. I was wondering if it's possible to get signal strength from the module, or would I have to purchase another HC-0# module to do so? Also the HC-05, can initiate connection if I'm understanding documentation right, and return available devices in the area?


texts: motor driver shield covering ports for ultrasonic sensor

texts: im new to arduino and am making an arduino car. the motor driver shield covers the ports (am connecting an ultrasonic sensor) and i know that we can connect it to the 'holes' on the motor driver shield (l293d) but i do not have a solder or header pins. there's a lockdown and i cannot get any of those. can i make a makeshift arrangement? (refer img): it is a little loose, is there any fix using jumper wires or any other arrangement? please let me know!


texts: Can't identify + or - in the 5v USB wall adapter, does it matter?

texts: I want to power the UNO with the USB power adapter (the charger of a phone), the adapter delivers 5.0 volts and comes from the wall (in the photo a regulator is added). However, the legs of the USB adapter look the same, can I plug it to the wall indistinctly like I do when I charge the phone, or do I need to know which leg is + and which one is - ? (I don't have measurement equipment).


texts:
I know that Arduino uno and Elegoo uno use chips from the same manufacturarers, but still I was wondering if there's any difference between them in terms of software or similar. In school a professor wants to start making projects with Arduinos and Raspberry pis and etc. So one project we saw online online requires an Arduino uno (the most basic one), but we saw that an Elegoo uno is way cheaper, so we were wondering if the same code could work on both.
Sorry if it's a dumb question, we're basicly newbies.


texts: Why does the arduino respond so slow to serial input

texts:
I have this really simple sketch where I blink a led light.
If I send another value threw the serial monitor then first there is always a brief second where the light doesn't blink anymore. Why is that, and how can I get rid of that?

int the_delay = 300;

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

void loop() {
  digitalWrite(12, HIGH);
  delay(the_delay);
  digitalWrite(12, LOW);
  delay(the_delay);
}

void serialEvent() {

  if (Serial.available()) {
    the_delay = Serial.parseInt();
    Serial.println(the_delay);
  }
}

In case it helps, eventually I would like to send values with 60fps.


texts: Can I change this code to use a potentiometer instead of a push button

texts:
The following code is for a pyrograph power supply that uses an ATtiny85. I want to change it, so instead of a push button I have a potentiometer being the control of the temperature. Can anyone guide me on how to accomplish this with this code?

//Written by Tyler Gerritsen
//2017-10-21
//Pyrography Pen Power Supply Controller
//Written for ATTiny85 w/ Internal 1MHZ Clock

const byte btn = 2;
const byte led = 1;
const byte pwr = 0;
byte rate = 0;
unsigned long nextChange = 0;
boolean onOff = false;
unsigned long blinkyCount = 2000000000;
unsigned long nextBlink = 0;
unsigned long debounceTimer = 2000000000;
const unsigned int debounceDelay = 400;
const unsigned int onDelay[5] = {6800, 6300, 5800, 6300, 4800};
const unsigned int offDelay = 5000;

void setup() {
  pinMode(btn, INPUT_PULLUP);
  digitalWrite(btn, HIGH);
  pinMode(led, OUTPUT);
  pinMode(pwr, OUTPUT);
  digitalWrite(pwr, LOW);
  debounceTimer = 60000000;
  while (digitalRead(btn)) {
    checkButton();
  }
  analogWrite(led, 0);
  nextChange = micros();
  debounceTimer = millis() + debounceDelay;
  blinkyCount = 1;

}

void loop() {
  runBurner();
  checkButton();
}

void runBurner() {
  if (micros() > nextChange) {
    if (onOff) {
      digitalWrite(pwr, LOW);
      onOff = false;
      nextChange += onDelay[rate];
    } else {
      digitalWrite(pwr, HIGH);
      onOff = true;
      nextChange += offDelay;
    }
  }
}

void checkButton() {
  if (!digitalRead(btn) && millis() > debounceTimer) {
    debounceTimer = millis() + debounceDelay;
    rate++;
    rate %= 5;
    blinkyCount = (rate) * 2 + 5;
    nextBlink = millis();
  }
  if (blinkyCount > 1 && millis() > nextBlink) {
    if (blinkyCount % 2) {
      digitalWrite(led, LOW);
      blinkyCount--;
      nextBlink += 150;
    } else {
      analogWrite(led, 10);
      nextBlink += 150;
      blinkyCount--;
    }
  } else if (blinkyCount == 1) {
    analogWrite(led, 10);
    blinkyCount = 0;
  }
}


texts: Using SoftwareSerial for the serial monitor

texts:
Most programs follow this route: They have a Serial.begin() for the serial connection between PC and Arduino (the serial monitor) and they use SoftwareSerial for a device.

Can you go the other way around? Can you use SoftwareSerial for the communication between PC and Arduino, and Serial for a device?


texts: Connecting multiple load cells to the same microcontroller

texts:
This is my first post and I am a little bit confused about one thing.
I would need to do the following project:
have about 5-6 load cells to be connected to a microcontroller.
I am not sure if there is a way to connect multiple load cells to the same arduino.
I would need each load cell to act individually, so I would need an individual result from all each load cell.

I believe I would need to connect 1 load cell to 1 load cell amp and then connect the load cell amp to the Arduino and repeat this process 5-6 times (for each load cell that I need)

I'm not sure if this is possible using one Arduino or I would need 1 Arduino for each individual load cell.

The main idea of the project is to have a load cell to be placed under different kitchen supplies (1 load cell to continuously check the weight of Flower, another one to check for bread, another to check for paprika, and so on)

After this is read from the sensors, I need to write the weight of each item in a table / DB every 30 minutes.

Also, if this can be done with another board, like a microcontroller (Raspberry Pi) I'm open to that.


texts: Arduino Nano Stops Working after Soldering

texts:
I recently got given a few CH340G Arduino Nano's and I tested them by uploading the blink sketch and they worked fine. However, I have soldered the provided header pins to two of them now and they will no longer upload the Blink sample sketch, although they still power up and are recognised in my USB port.

If anyone has any solutions or suggestions that would be appreciated :)

Thanks, Kian


texts: Communication between two ESP8266 modules using Arduino IDE

texts:
Firstly, I'll just give you a brief introduction about our project... It's a "Speech-controlled Home-Automation System" where we are controlling the home appliances by voice or speech commands.

We're successfully done with the voice recognition module. But our problem is with achieving the communication between the transmitter, where the user gives the voice command, and the receiver, where the home appliances are present, through WiFi. i.e. we have 2 ESP8266 12E modules interfaced with Arduino both at the transmitter and receiver side, and these two WiFi modules need to communicate (to interchange some data sent by Arduinos).

So please let us know what Arduino code needs to be used on the transmitter's side wifi module and on the receiver's side wifi module. and also about the header files or additional software (if any) to be used.


texts:
I'm a beginner in creating my own libraries so the following might contain some stupid stuff.

Anyways, I'm using NRF24L01+ modules for wireless communication and I've been utilizing the magnificent RF24 library (https://github.com/TMRh20/RF24) to operate these modules using Arduino. I wanted to clean up my code and decided to write my own library that uses the R24 library. My own library would contain all the subroutines that handle TX and RX functions.

Problem is that the RF24 library is initialized using e.g.

/* Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 & 8 */
RF24 radio(7,8);

To begin using the NRF24L01+ one would the use the RF24 library like for example:

byte addresses[][6] = {"1Node","2Node"}; // Radio pipe addresses for the 2 nodes to communicate.
Serial.begin(57600);
printf_begin();
radio.begin();

radio.setPALevel(RF24_PA_HIGH);
radio.setCRCLength(RF24_CRC_16);

radio.setRetries(2,15);
radio.setChannel(RFChannel);
if(radioNumber){
radio.openWritingPipe(addresses[1]); // Both radios listen on the same pipes by default, but opposite addresses
radio.openReadingPipe(1,addresses[0]); // Open a reading pipe on address 0, pipe 1
}else{
radio.openWritingPipe(addresses[0]);
radio.openReadingPipe(1,addresses[1]);
}

if(radioNumber == 1){
radio.startListening(); // Start listening
}
radio.printDetails();

Well, now I would like to make a library that would allow me just to call setup to handle all of the above. My library would be called RadioComm so I would call in my main code:

RadioComm rComm();

setup() {
rComm.setup();
}

The problem is that how do I use the RF24 library and all its functions in my library? To initialize the RF24 library in my own library I would have to call somehow this

RF24 radio(7,8);

and use all the radio. commands. How do I tell my own library that everything starting with "radio." is related to RF24 library because right now I'm getting this:

RadioComm.cpp: In member function 'void RadioComm::setup()':
RadioComm.cpp:20:18: error: 'radio' was not declared in this scope
radio(pin1,pin2); // Set up nRF24L01 radio on SPI bus plus pins 9 & 10

Below are my .h .cpp and .ino files

Lib_test.ino

#include <RadioComm.h>
#include <RF24.h>
#include <SPI.h>

RadioComm rComm;

void setup() {

rComm.setup();

}

void loop() {

}

RadioComm.h

#ifndef RadioComm_h
#define RadioComm_h

#include "Arduino.h"
#include <RF24.h>

struct dataStruct{
unsigned long id;
float value1;
float value2;
float value3;
float value4;
};

class RadioComm
{

public:

RadioComm();
void setup(void);

private:
int pin1;
int pin2;

};

#endif

RadioComm.cpp

#include "Arduino.h"
#include "RadioComm.h"
#include <RF24.h>
#include "printf.h"

RadioComm::RadioComm(void)
{}

void RadioComm::setup()
{
byte addresses[][6] = {"1Node","2Node"}; // Radio pipe addresses for the 2 nodes to communicate.
radio(pin1,pin2); // Set up nRF24L01 radio on SPI bus plus pins 9 & 10
Serial.begin(57600);
printf_begin();
radio.begin();
radio.setPALevel(RF24_PA_HIGH);
radio.setCRCLength(RF24_CRC_16);

radio.setRetries(2,15);
radio.setChannel(RFChannel);
if(radioNumber){
radio.openWritingPipe(addresses[1]); // Both radios listen on the same pipes by default, but opposite addresses
radio.openReadingPipe(1,addresses[0]); // Open a reading pipe on address 0, pipe 1
}else{
radio.openWritingPipe(addresses[0]);
radio.openReadingPipe(1,addresses[1]);
}

if(radioNumber == 1){
radio.startListening(); // Start listening
}
radio.printDetails();
}

Any help is appreciated.

Thanks.


texts: How to prevent inclusion of unnecessary libraries?

texts:
How do you save space by preventing the inclusion of unnecessary binaries?

When I compiled the ROS Blink example, I received the warning:

Global variables use 1,951 bytes (76%) of dynamic memory,
leaving 609 bytes for local variables. Maxiumum is 2,560 bytes.
Low memory available, stability problems may occur.

Considering the example uses almost no libraries, I was surprised by this, but sure enough, the compiler pulls in a ton of libraries that are never used:

Scanning dependencies of src
Scanning dependencies of arduino
Scanning dependencies of ros_lib
src/main.cpp
arduino/wiring.c
arduino/wiring_shift.c
arduino/wiring_digital.c
arduino/wiring_pulse.c
arduino/WInterrupts.c
arduino/hooks.c
arduino/wiring_analog.c
arduino/USBCore.cpp
arduino/new.cpp
arduino/Tone.cpp
arduino/WString.cpp
arduino/HardwareSerial1.cpp
arduino/Stream.cpp
arduino/HardwareSerial3.cpp
arduino/HardwareSerial0.cpp
arduino/CDC.cpp
arduino/HardwareSerial2.cpp
arduino/main.cpp
arduino/HID.cpp
arduino/HardwareSerial.cpp
arduino/IPAddress.cpp
arduino/Print.cpp
arduino/WMath.cpp
arduino/abi.cpp
Linking libarduino.a
ros_lib/duration.cpp
ros_lib/time.cpp
Linking libros_lib.a
Linking firmware.elf
Converting to firmware.hex

Why are so many files being included in the compilation, and how do I filter them out?


texts: Issues while making ESP8266 as web server

texts:
I have programmed ESP8266 with below program. I used USB to TTL convert to program ESP8266. This is how I wired my circuit:

USB TTL---------------- ESP8266 ESP-01

GND-----------------------GND

TX---------------------------RX

RX---------------------------TX

3.3V-----------------------VCC & CH_PD

GND------------GPIO0

#include <ESP8266WiFi.h>

const char* ssid = "shiv";//type your ssid
const char* password = "manmohan@12345";//type your password

WiFiServer server(80);

void setup() {
  Serial.begin(115200);
  delay(10);

  // Connect to WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");

  // Start the server
  server.begin();
  Serial.println("Server started");

  // Print the IP address
  Serial.print("Use this URL to connect: ");
  Serial.print("http://");
  Serial.print(WiFi.localIP());
  Serial.println("/");

}

void loop() {
  // Check if a client has connected
  WiFiClient client = server.available();
  if (!client) {
    return;
  }

  // Wait until the client sends some data
  Serial.println("new client");
  while(!client.available()){
    delay(1);
  }

  // Read the first line of the request
  String request = client.readStringUntil('\r');
  Serial.println(request);
  client.flush();

  // Match the request

  int value = LOW;
  if (request.indexOf("/LED=ON") != -1) {
    value = HIGH;
  }
  if (request.indexOf("/LED=OFF") != -1){
    value = LOW;
  }

  // Return the response
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println(""); //  do not forget this one
  client.println("<!DOCTYPE HTML>");
  client.println("");

  client.print("Led pin is now: ");

  if(value == HIGH) {
    client.print("On");
  } else {
    client.print("Off");
  }
  client.println("

");
  client.println("Click here turn the LED on pin 2 ON
");
  client.println("Click here turn the LED on pin 2 OFF
");
  client.println("");

  delay(1);
  Serial.println("Client disonnected");
  Serial.println("");

}

It was successful, here are the logs:

Archiving built core (caching) in: C:\Users\williams~1\AppData\Local\Temp\arduino_cache_375631\core\core_esp8266_esp8266_generic_CpuFrequency_80,FlashFreq_40,FlashMode_dio,UploadSpeed_115200,FlashSize_512K64,ResetMethod_ck,Debug_Disabled,DebugLevel_None_____feb0d75f3cf4e05271af4f91549cd009.a
Sketch uses 230073 bytes (52%) of program storage space. Maximum is 434160 bytes.
Global variables use 32376 bytes (39%) of dynamic memory, leaving 49544 bytes for local variables. Maximum is 81920 bytes.
Uploading 234224 bytes from C:\Users\williams~1\AppData\Local\Temp\arduino_build_189179/sketch_may14d.ino.bin to flash at 0x00000000
................................................................................ [ 34% ]
................................................................................ [ 69% ]
.....................................................................            [ 100% ]

Once this was completed, I opened serial monitor and it was empty there, baud rate was 115200. It is weird, Isn't ?

I followed this tutorial https://create.arduino.cc/projecthub/ROBINTHOMAS/esp8266-esp-01-webserver-7248ca and on serial monitor it should be like below snapshot. What wrong I am doing ? Can anyone help me.


texts:
I noticed there are cheap SD modules and complete SD shields.
I assume the last are used for a 'final' product and not for bread-boarding (?)

However, I was wondering, is there also a difference in functionality or more important, support for e.g. the sd library (thus having file I/O in addition  to SPI interface)?

E.g. can I use the file I/O and the SD library with the This SD module?


texts:
I have an Adafruit 2.8" cap touch display, which has an interrupt pin (IRQ). I tried to use this with my Arduino Nano, but encountered a problem:

When trying to get the touched point from the display during a display triggered interrupt, it would not work because the touch screen is connected via I2C and according to this post, it is not possible to call I2C functions inside an ISR on an Arduino. Therefore the IRQ pin does not make much sense to me, as I would have to poll if the screen is touched inside the main loop.

My question now is: is this a problem specific for the AtMega 328p? I am thinking about getting an ESP32 based board. Would it be possible to get the I2C data inside an ISR on this chip? Or is it just not possible at all?


texts: Module and library for self healing large sensor network

texts:
I have to build a wireless sensor network with arduinos on my project. It does not need to be a mesh network, but it needs to have self healing capabilities.

I would like to use something cheaper than XBees. I tried the NRF24L01 with maniacbug's, TMRh20's and MySensors' libraries. However they aren't solving the problem and I'm wasting a ton of time trying to figure out how to make them work.

Another thing, I need a lot of repeater nodes between the base and the sensors because the office is 2 km far from the monitoring area and some of these libraries have a limitation of 5 level deep network, so I'd have max 4 repeaters between the base and sensor, which is bad.

And the last, my project is going to be fine with 15 sensors for now, but it'll have 500-1000 nodes in a couple of months and most of these libraries assign 8 bit addresses (256 nodes), which does not cover that amount of nodes.

What do you suggest?


texts: Trying to use an LCD 1602 to display, but I don't have a 10 KOhm potentiometer

texts:
I'm following this tutorial page and I don't have a 10k ohm potentiometer on hand. Could I replace it with resistors to simulate a manual setting and replace the resistors to adjust to a new settings.

From what I was reading this pin is for contrast and I'm sure I could manually set the contrast once and be happy with it for quick prototyping. I'll be ordering a 10k ohm potentiometer on Monday.


texts: Reading +IPD response from serial.read() using Arduino UNO and ESP8266

texts:
I have a python server running on my PC and I am using an Arduino Uno (wifi enabled by a ESP8266 chip) as the client.
I can make the the server and client communicate using AT commands as shown below:

SoftwareSerial esp (8,9);

   void setup()
   {
   esp.begin(9600);
   esp.println("AT+CWMODE=3");
   delay(100);
   esp.println("AT+CIPSTART=\"TCP\",\"192.168.8.100\",5555");
   delay(1000);
   esp.println("AT+CIPSEND=3");
   delay(100);
   esp.println("bbb");
   delay(100); }

The string "bbb" is recieved on the server and the server responds back, which is shown in the serial monitor as:

+IPD,19:the string is found

I want to read this response and use it back in the code for further conditional statements. But i am unable to do this. So far i have tried these methods.

1st method by using esp.readString() as shown below:

String buffer="";
while (esp.available()>0)
    buffer+= esp.readString();
Serial.print(i4);

2nd by using esp.read() as shown below:

String buffer="";
char c;
while (esp.available()>0) {
    c= esp.read();
    buffer+=c;}
Serial.print(buffer);    // i have also tried using esp.write() directly for prinitng here intead of storing it in a buffer

These two methods returned with incomplete information in the response string buffer ie i only get:

busy s...

Recv 3 bytes

SEND OK

+IPD,19:the string

I can not get the entire response in the buffer as mentioned in the start. On the other hand if i execute the command AT+CWLAP and store its response in the buffer string, i get the entire thing. So i cant understand why is there a difference between the two.
Lastly i have also used esp.readBytes() as shown:

char c[500];
esp.readBytes(c,400);
esp.write(c);

This code gives me the whole response sometimes but sometimes it just gives a long garbage value. But the times it does give me the complete +IPD response, it switches some of the alphabets ie the string is found becomes the strjng is gound

If anyone could help me out i'll be very thankful.


texts: How to get constant readings from hall effect sensor

texts:
Im using linear Hall effect sensor to sense the magnetic flux at a point.
Values from the sensor is read using arduino's analogRead function.
This value changes as other devices are connected to arduino, like lighting a LED.

My guess is since the current passing through the Hall effect sensor also changes the magnetic flux and hence the reading, it might affect the reading in some way.

Any help is appreciated.. thank you.


texts: Arduino leonardo. Encoder mouse movement

texts:
I want to connect my sensonrs to an arduino leonardo.

The principal idea is use it like a scratch (like dj hero or beatmania??), if I move the scratsh up, the mouse will go up ( y Axis ), and if it go down, the y Axis down.

The middle is for gnd and the other four to 0 to 3 pin in the arduino.

So my problem is I am not sure about the conecction and also the code to run my program, beacuse all the thing that i try to do, had no work in my computer.


texts:
I have an Arduino Uno attached to my MacBook Air running the Arduino IDE 1.6.4.

The Arduino was visible in the Serial port section this morning, but then it just disappeared. The ON light on the Arduino still comes on, but I cannot connect to it through the port section. I attached the Uno to another computer and it did not appear there either. However, when a different Arduino is connected to my computer it does show up. I also tried using a different IDE version, and it did not appear there either.

All of the other topics I found regarding this were saying it is the OS's fault, but since I was able to see the other Arduino, I am pretty sure it is not. I updated the FTDI drivers, and I tried using a powered hub and it is still not there.

UPDATE:

When I took the chip out of the UNO that is not appearing and put it into a working UNO, I was able to see it, is it possible that the Serial port is just not working, and if so how would I fix that

Any help would be appreciated.


texts: Options for measuring position of garage door

texts: I'd like to be able to measure the position of my garage door. Determining if the garage door is fully open or fully closed should be fairly simple with some magnetic reed switches but I'd like to know the position of the door when it's partially open/closed.


texts: How to make ultrasonic and light sensors detect whether a person moving in or out

texts: I am trying to make a circuit that will be used for turning on a light whenever there are 1 or more people in a room. I need to add to a variable counter when someone enters and subtract when someone leaves. However, I do not know how to use the ultrasonic sensor for this purpose. What can I do?


texts: How can I declare custom pins when using with ESP8266 in MPU9250 library

texts:
I want to declare SCL and SCK pins like   Wire.begin(sda_pin, scl_pin); to use with ESP8266 to integrate a MPU 9250/6500 sensor.
I can't figure out a way to declare that in this code exaample provided by https://github.com/bolderflight/MPU9250

in the example of the above it has just passed as Wire to and created object like MPU9250 IMU(Wire,0x68); which was meant to be used with UNO boards(as I think)

And in any case if any of you have seen a library that can be used with the ESP8266 for the MPU 9250/6500 point me on that direction please (I'm trying to get the roll, pitch, yaw)


texts: How to run multiple functions one after another?

texts:
I want to fade a red LED up and down, then a green LED up and down, and repeat the whole cycle indefinitely.

I've been trying to run multiple functions one after another. However my current code seems to have them both fading in parallel.

I tried using a switch case, do while and the while loop but the code runs the two functions at once. So what is wrong with the code below?

This is my code:

void setup() {
    Serial.begin(9600);
    DDRD |= (1<<DDD6)|(1<<DDD5);
    TCCR0A = 0xF1;
}

uint8_t fade_seq;

void loop() {
    loop1:
    fade_seq++;
    while (fade_seq==1)
    {
        fade_red(1);
    }
    Serial.println(fade_seq);
    while (fade_seq==2)
    {
        fade_green(1);
    }
    if (fade_seq==3)
    {
        fade_seq=0;
        goto loop1;
    }
}

void fade_red(uint8_t cnt)
{
    uint8_t i,k;
    for (k=0;k<cnt;k++)
    {
        OCR0A+=1;
        _delay_ms(10);
        if (OCR0A == 255)
        {
            for (i=0;i<255;i++)
            {
                OCR0A--;
                _delay_ms(10);
            }
        }
    }
}

void fade_green(uint8_t cnt)
{
    uint8_t i,k,c;
    for (c=0;c<cnt;c++)
    {
        for (k=0;k<255;k++)
        {
            OCR0B+=1;
            _delay_ms(10);
            if (OCR0B == 255)
            {
                for (i=0;i<255;i++)
                {
                    OCR0B--;
                    _delay_ms(10);
                }
            }
        }
    }
}


texts:
I was wondering why there is a 15 ms delay between each iteration of a the main loop.

Code:
The following code shows the execution time expressed in microsec between each loop

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

void loop()
{
  Serial.println();
  Serial.print("Start: ");
  Serial.print(micros());
  Serial.print("/////////////////////");
  Serial.print("End:");
  Serial.print(micros());
}

Output:

Start: 789452/////////////////////End:821692
Start: 837292/////////////////////End:869532
Start: 885132/////////////////////End:917372
Start: 932972/////////////////////End:965212

Arduino needs 32,240 msec to print the messages to serial and to call the micros() function twice. And this it's fine. Now, considering the difference between the values of the End and the following Start, one question arises:

What does Arduino do between each loop?


texts: Why is setup() executed twice at runtime?

texts:
Code:

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

void loop() {
}

Output:

hello
hello

Why does hello print twice?


texts: Why does SoftwareSerial::read() return int?

texts:
The documentation on Arduino's website shows SoftwareSerial::read() as returning a char. (link)

The header shows that the method returns an int. (link)

The cpp definition shows SoftwareSerial::read() returning the value from a buffer array of uint8_t values. (link)

Given all of this:

Why would the interface return an int instead of a uint8_t?
Why do the Arduino docs show it as returning a char?
Is it safe to send/receive 8-bits at a time using this library?

For (3) I'm using an HC-06 if that matters.


texts:
G'day guys, I'm trying to get an ESP8266 to work with an Arduino Uno.Here is the wiring.

When I go to the serial monitor (115200 baud) and type: AT, there is not response from the ESP8266.Is there something that I am missing?I also have a servo motor connected, it works fine.

include "Arduino.h"
include "ESP8266.h"
include "dweet.h"
include "Servo.h"

define ESP8266_PIN_RX 10
define ESP8266_PIN_TX 11
define SERVO9G_PIN_SIG 2

const int servo9gRestPosition   = 20;
const int servo9gTargetPosition = 150;
const char *SSID     = "Wireless Network";
const char *PASSWORD = "wireless_password";

ESP8266 wifi(ESP8266_PIN_RX,ESP8266_PIN_TX);
Servo servo9g;

const int timeout = 10000;
char menuOption = 0;
long time0;

void setup()
{
   Serial.begin(9600);
   while (!Serial); //await connection.
   Serial.println("start");

   wifi.init(SSID, PASSWORD);
   servo9g.attach(SERVO9G_PIN_SIG);
   servo9g.write(servo9gRestPosition);
   delay(100);
   servo9g.detach();

}

void loop()
{
   servo9g.attach(SERVO9G_PIN_SIG);
   servo9g.write(servo9gTargetPosition);
   delay(500);
   servo9g.write(servo9gRestPosition);
   delay(500);
   servo9g.detach();
}

I'm using the ESP8266 Library.When trying to connect it just says Initializing device...


texts: Problem with programming digispark ATtiny85 board with Arduino IDE

texts:
I have bought a Digispark ATtiny85 board to learn about that microcontroller. So I tried using internal register names in the code rather than using Arduino in built functions. I can get the board to work when comes just input and output operations. For example the below code works and I can get the on board LED to turn ON and OFF
#include<avr/io.h>
void setup()
{
  DDRB |=(1 << PB1);  //set PB1 as output
}
void loop() {
 PORTB |= (1 << PB1);    // Turning ON LED connected to PB1
 delay(1000);            //Using Arduino IDE inbuilt delay function to generate delay of 1 second
 PORTB &= ~(1 << PB1);   //Turning the LED off
 delay(1000);

}
I have tried using Timer0 of ATtiny85 module to generate time delay of one second. But unfortunately I couldn't get it to work.
#include<avr/io.h>
#define F_CPU 16500000UL
#include<util/delay.h>

void timer_config()
{
 DDRB =0b00000010; // set PB1 as output
 GTCCR|= (1<<TSM);      ///Halt the timer for configuration
 TCCR0A=0x00;             //Normal mode
 TCCR0B=0x00;
 TCCR0B |= (1<<CS00)|(1<<CS02);   //prescaling with 1024
 TCNT0=0;
 GTCCR&=~(1<<TSM); //Start the timer
}

void tmdel()
{
 int i=0;
 while(i<=6)
 {
  while((TIFR & (1 << TOV0) )==0);        //Waiting for 0-255 and flag to raise
  TIFR|=(1<<TOV0);      //Clear the flag
  i=i++;                          //increment by one
 }
}

int main()
{
 timer_config();
 while(1)
 {
  PORTB|=(1<<PB1);     //PortB1 high
  tmdel();                         //Delay of 1 second
  PORTB&=~(1<<PB1);     //PORTB1 low
  tmdel();
 }
}

I have used the overflow flag to identify TCNT0 register status. I have uploaded the above code but the LED isn't responding as anticipated.
When searching the internet I have got few suggestions that this might be because Arduino IDE uses timer registers for delay function. When user attempts to access timer registers it might not work as intended.
But am not sure about the validity of above opinion. Can anyone help me with it? Since am learning this controller, practicing core programming is quite important. If I cannot program ATtiny85 using Arduino IDE this way, can someone suggest a way or alternate hardware setup to program ATtiny85 and access its registers without a problem.


texts: Sending Integer > 1 Byte from Android to Arduino over Serial

texts:
I´m using

public abstract void write(int b) throws IOException;

from class OutputStream on Android Studio to sent Integer (degrees from 0 to 360) to the Serial Port of my Arduino over HC06 Bluetooth module.

Degrees from 0 to 256 are read well by using

 int angle = Serial.read();

Values over 256 (1 Byte) are received as 0 are something weird.

I tried using

 Serial.parseInt();

as it should return an long int but all I get is one digit mostly 0.

I also tried using

Serial.readBytes(threeDigitsInt, 3);
angle = (threeDigitsInt[0] * 100) + (threeDigitsInt[1] * 10) + threeDigitsInt[2];

but I cannot tell what ends up in the array. Definitly not the correct single digit. I tried char[] and byte[] but I´m not able to reconstruct my send Integer value.

Summary: I want to send 360 as Integer from Android and have it as Integer on Arduino.

Appreciate your help!


texts: How to Send Live Sensor Data to iOS Custom Apps with BLE

texts: I am looking for a Bluetooth Low Energy (BLE) device that could send live sensor data from Arduino to iOS custom apps, not the app that is already in the app store. I would like to create my own apps to receive the sensor data. Or are there any other ways to achieve it?


texts:
I have a sensor and it generates an analogue signal.

I am reading all analogue data and sending it to my computer.

uint8_t sensors[] = { A0,A1,A2,A3,A4,A5,A6 };
const int len = sizeof(sensors) / sizeof(sensors[0]);
void loop(void)
{
    for (size_t i = 0; i < len; i++)
    {
        auto sensor = sensors[i];
        int sensorValue = analogRead(sensor);
        // Convert the analogue reading (which goes from 0 - 1023) to a voltage (0 - 5V):
        float voltage = sensorValue * (5.0 / 1023.0);
        char t[100];
        sprintf(t, "%d:%d$\n", sensor, sensorValue);
        uint8_t t1[100];
        //PrintSerial.println(t);
        memcpy(t1, t, 100);
        wifi.send(t1, strlen(t));
    }
    delay(300);
}

I plotted the analogue reading. Why does the graph look like this?


texts: How to find the difference between two timestamps

texts:
I'm using this time library to access the properties of unix timestamps like hours / minutes / etc. What I want to do is get the current time, and an estimated arrival time, and find the difference between them in minutes.

Here's my code: (My estimated time is coming from an API as an INT)

time_t timeEstimated = timeInt;
time_t timeNow = now();

But how do I find the difference between these two timestamps in minutes? I'd like to try and avoid all of the conditionals / math that would come with converting to hours / minutes / seconds / dates and subtracting each component if possible.


texts: Can we use an alternate RFID reader to read HID cards?

texts:
I'm working on a project where I need to read the HID RFID cards. Behind the card it shows as HID 0008p and based on the documentation, it looks like it uses a 125 kHz frequency. I tried using different 125 kHz RFID readers, but I was unable to read the card. What reader should I use?

I used RC522, and also another 125 kHz reader with Wiegand output, both  without any success.

Card Used : HID Proximity Card 0008p
Additional details about the card type : HID DuoProx II 1336

Here is the code i used - This works fine with SWH 5100 reader

But doesn't work with this reader EDK-125 TTL

volatile unsigned long tagID = 0;
volatile unsigned long lastBitArrivalTime;
volatile int bitCount = 0;

#define MAX_BITS 100                 // max number of bits
#define WEIGAND_WAIT_TIME  3000      // time to wait for another weigand pulse.

unsigned char databits[MAX_BITS];    // stores all of the data bits

unsigned long facilityCode;        // decoded facility code
unsigned long cardCode;            // decoded card code

 unsigned char i;

void ISRone(void)
{
  lastBitArrivalTime = millis();
  databits[bitCount] = 1;
  bitCount++;
  tagID <<= 1;
  tagID |= 1;
  Serial.println(bitCount);
}

void ISRzero(void)
{
  lastBitArrivalTime = millis();
  databits[bitCount] = 0;
  bitCount++;
  tagID <<= 1;
  Serial.println(bitCount);
}

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

  pinMode(2, INPUT);
  digitalWrite(2, HIGH);  // Enable pull-up resistor
  attachInterrupt(0, ISRzero, CHANGE);

  pinMode(3, INPUT);
  digitalWrite(3, HIGH);  // Enable pull-up resistor
  attachInterrupt(1, ISRone,  CHANGE);

  tagID = 0;
  bitCount = 0;
}

void loop()
{
  //  See if it has been more than 1/4 second since the last bit arrived
  if(bitCount > 0 && millis() - lastBitArrivalTime >  250)
  {
    Serial.print(bitCount, DEC);
    Serial.print(" bits: ");

 // 35 bit HID Corporate 1000 format
      // facility code = bits 2 to 14
      for (i=2; i<14; i++)
      {
         facilityCode <<=1;
         facilityCode |= databits[i];
      }

      // card code = bits 15 to 34
      for (i=14; i<34; i++)
      {
         cardCode <<=1;
         cardCode |= databits[i];
      }

 //   Serial.println(tagID);
    Serial.println(cardCode);
 //   Serial.println(facilityCode);

    cardCode = 0;
    facilityCode = 0;
    tagID = 0;
    bitCount = 0;

  }
}


texts: Is it required to delete variables before going to sleep?

texts:
This tutorial shows how to put the arduino to sleep and use a watchdog to wake up at intervals:
https://youtu.be/urLSDi7SD8M
I been studding c++ and as I am getting better I am instantiating objects with the new keyword. I have learned that if you create something with the new keyword you are responsible for deleting it from memory when you no longer needed. But I do not know if this applies when you put arduino to sleep.
Anyways my question is in the comments of the code:
Foo * someObject;

void setup()
{
    someObject = new Foo(arg1, arg2, ..); // crete an instance of someObject
   // init pins etc..
}

void loop()
{
     if(button1Pressed())
     {

          // **** DO I HAVE TO DELETE OBJECTS BEFORE GOING TO SLEEP? Do I need this line? ****
          delete someObject;

          gotToSleepAndWakeUpIn4Seconds() ;  // places arduino in sleep mode and wakes up again in 4 seconds

          int x = 0; // this line never executes arduino is on sleep mode and will wake up again in 4 seconds
     }

     // more code
     if(something)
        someObject->executeFunction1();

     // etc...
     // ....
}


texts: AT command not send but blue LED stays on

texts:
I am new to working with Arduino Uno and ESP8266.

Firstly I connected an ESP8266 to an Arduino Uno like so:

TX to TX,
RX to RX,
GND to GND,
VCC to 3.3V,
CH_PD to 3.3V and
adding RESET to GND on the Arduino Uno.

After completing the wire connection, I opened the Arduino IDE serial monitor, where it always shows symbols and text and I set baud rate 115200 and adjusted both NL and CR.

After all of that, when I send an AT command, then no response is shown.


texts: creating HTTP persistent connection, to create 'smooth' data over GSM sending

texts:
Project goals

Send data over GSM to firebase
Fast sampling - need to send 16 bytes every half second to firebase
Send data using GET or POST to server with PHP script, that redirect data to firebase

Problems --
Extremely low data rate!

Using standard GET or POST request from client(arduino) side, is impossible to achieve second (2) project goal.
To send data correctly I need to close connection with server, so next data package unfortunately waits(2-6 seconds) for establishing a new connection.

Is this quite nonsense? I'm using ArduinoHttpClient library.

My actual Nonsense Connection and fully useless, but works

while(1){

http.post("/test.php","application/x-www-form-urlencoded","data=0");
http.stop(); //closing connection with server

//next instruction take over 5 second to establish new connection :(

http.post("/test.php","application/x-www-form-urlencoded","data=0");
http.stop(); //closing connection with server, whyyy?
}

Data are send once per 2 - 6 seconds, this is not even funny. NEED to send data every 0.5 seconds!

So I decided to create super solution, which not works :C

while(1){
    http.post("/test.php","application/x-www-form-urlencoded","data=0");
    delay(xxx);
//no connection closing, no wasting time for establishing new one :)
}

Just tell my why this connection is not "Keep-Alive", also used with

  http.sendHeader("Connection: Keep-Alive"); or
  http.connectionKeepAlive();

//First run
http.post(blabla);// returns value: 0 & data are logged into firebase
//Second run
http.post(blabla);// returns value: -2 & data are not logged in firebase

my test.php file

<?php
require_once 'firebaseLib.php';
$url = 'https://czujniki-aa5ca.firebaseio.com/';
// --- Use your token from Firebase here
$token = ':-CCCCCCCCCCCCCCCCCCCCCCC';

$arduino_data_post = $_POST['data'];
$firebasePath = '/';

$fb = new fireBase($url, $token);
$response = $fb->push($firebasePath, $arduino_data_post);
sleep(2);


texts: Attiny85 - Method to discard glitched ADC values?

texts:
I have a problem i need to solve so i will simply it as much as possible.

Basically there is a system with a micro-controller where it reads 2 sensors. These 2 sensors are of variable resistance type, aka their measuring value is output as different resistance. For example one is a pressure sensor where at 0psi the sensor has a value of 20ohms to ground, and for 100psi it has a value of 120ohms. The sensor is connected between ground and a fixed value resistor so the output acts like a voltage divider.

The micro-controller seems to be multiplexing by switching pull up between each 2 sensors (probably because using a single ADC), at random times (as the microcontroller performs other functions) but approx. every 80ms for each sensor, and about 40ms between each sensor. So at 0ms it reads one sensor, at 40ms the other sensor, and at 80ms back at the first sensor and so on. I have no idea why they haven't used a fixed pull-up, but the pull-up is only done when the controller wants to read the sensor for only about 120us.

I wanted to read these sensors to input to an ECU, without affecting the original device. Thus the easiest solution i could think off as the pull-up isn't always high to perform a read, was to add another microcontroller (in my case a Digispark based on the ATtiny85 running at 16.5MHZ). Alternatively i could open up the device and modify it to use a fixed pull-up but let's say i want to avoid this route. The digispark essentially reads both sensor outputs and when it sees a voltage above ground it outputs it to the ECU. I have since then updated the program to check the ADC values it reads so that it is between the nominal range of the sensor. And while this works there are times where the ADC will read a wrong value and output it to the ECU which looks as random spikes and dips in the data.

Look at my following code:

  const int oil_in = 0; //P5
  const int temp_in = 1; //P2
  const int oil_out = 1; //P1
  const int temp_out = 4; //P4
  int oil_value = 0;
  int oil_value_good = 0;
  int temp_value = 0;
  int temp_value_good = 0;

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

// the loop routine runs over and over again forever:
void loop() {
  oil_value = analogRead(oil_in);
  if (oil_value > 106 && oil_value < 466)
  {
    oil_value_good=oil_value;
    analogWrite (oil_out, oil_value_good/4);
  }

    temp_value = analogRead(temp_in);
  if (temp_value > 113 && temp_value < 920)
 {
    temp_value_good=temp_value;
    analogWrite (temp_out, temp_value_good/4);
  }
}

Each ADC pin has a range of acceptable values. These correspond to the MIN AND MAX nominal values for each sensor. However there are times where the ADC will read at the wrong time and it will output either a MIN or a MAX value depending on the condition. I can replicate this on the breadboard by having the input to the ADC reading a nominal value, and by shorting it to either ground or VCC (5V) i can sometimes trick the ADC to read a MIN or MAX value. And since the next measurement will be done after some time, the output will produce these spikes. Since there is no sync between the readings these error data can be sometimes be outputed for 1-1.5s.

I've tried thinking hard about this problem, but i am not sure for a certain solution that will eliminate this problem. ADC interrupts, changing ADC pre-scaler, filtering of data, problem the reading window is really small (100-120us).

Also nominal ADC input values for each sensors are between 0.56V-2.33V for one sensor, and 0.6V-4.68V for the other sensor. Not sure if the interrupt can even be activated at such low voltage.

How do you think i should proceed?

Kind regards


texts: Using or creating Wi-Fi Direct (P2P) connection on ESP8266

texts:
I want to make a Wi-Fi Direct connection with an android device using my ESP8266. According to ESP8266WiFi Documentation and ESP8266 datasheet, the board has a SoftAP mode which is I think what is needed in a P2P connection (Being an AP and a client at the same time).
There is also ESP-NOW in the Espressif website but I think it's made only for esp-to-esp p2p connection and I can't modify it. (Correct me if I'm wrong)
I couldn't find any pre-made libraries for this job, so I decided to make my own, but I can't seem to find anything related to making a new type of protocol or connection. Is it even possible to develop a new type of protocol? If yes, I'd really appreciate a guide on how to get started.


texts: How much power should I supply to L293d shield to run 4 tt gear dc motors and 1 servo sg90?

texts:
I'm new to Arduino. I am trying to making an obstacle avoiding car using Arduino Uno and L293d motor driver shield.
Four tt gear dc motors and 1 servo motor were connected. How much power should I supply or which batteries and how much should I use? Also, how do I increase the speed of the motor? It's max is 255 in shield but that it is slow.


texts:
I have setup a arduino with a SIM300 based GSM board. I have

Tx of Arduino connected to the Rx of GSM board
Rx of Arduino connected to the Tx of GSM board
Gn of Arduino connected to the Gd of GSM board

The GSM has a Vodafone 3g sim, activated with 3g. The GSM board has 2 LED's, one remains ON and the other blinks ever 4-5 seconds. Which I guess means that its configured to work with the SIM.
I then run the following code.
SoftwareSerial mySerial(10, 11); // RX, TX
void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  mySerial.begin(9600);

  Serial.println("Serial ports initialized");

   delay(500);
   Serial.println("AT+CGATT=1");
   delay(500);
   Serial.println("AT+CGDCONT=1,\"IP\",\"TATA.DOCOMO.INTERNET\",\"0.0.0.0\",0,0");
   delay(500);
   Serial.println("AT+CDNSCFG=\"8.8.8.8\",\"8.8.4.4\"");
   delay(1000);
   Serial.println("AT+CSTT=\"TATA.DOCOMO.INTERNET\",\"\",\"\"");
   delay(2000);
   Serial.println("AT+CIICR");
   delay(5000);
   Serial.println("AT+CIFSR");
   delay(500);
   Serial.println("AT+CIPSTATUS");
   delay(500);
   Serial.println("AT+CDNSORIP=1");
   delay(500);
   Serial.println("AT+CIPSTART=\"TCP\",\"http://myec2DNS-us-west-2.compute.amazonaws.com:myportnumber/mywebservice/myreques/Authentication/Request?identity=somecode&identityType=sometype\",\"myportnumber\"");
   delay(500);
   Serial.println("AT+CIPSEND");
   delay(500);
   Serial.println("AT");
}

void loop() // run over and over
{
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}

On cutecom I get te following
Serial ports initialized
AT+CGATT=1
AT+CGDCONT=1,"IP","TATA.DOCOMO.INTERNET","0.0.0.0",0,0
AT+CDNSCFG="8.8.8.8","8.8.4.4"
AT+CSTT="TATA.DOCOMO.INTERNET","",""
AT+CIICR
AT+CIFSR
AT+CIPSTATUS
AT+CDNSORIP=1
AT+CIPSTART="TCP","http://myec2DNS-us-compute.amazonaws.com:8080/myservice/mycommand/Authentication/Request?identity=%somecode&identityType=1","8080"
AT+CIPSEND
AT

When I run `tail -f  /var/lib/tomcat7/logs/localhost_access_log.2014-09-20.txt' on my webserver, I get nothing from the arduino.
What am I missing here ?


texts:
Objective: Maybe I'm a bad Googler, but I am finding very little on wired Internet of Things sensor networks using Arduino.

Project Goals:

Arduino based sensor nodes that connect to the local network (not out to the internet)
All the benefits of adding adding/removing nodes, moving nodes, adding new routers for more ports.
Black box sensors that don't take any soldering to plug into the network (although they contain soldered components in the black box.
Using a master Raspberry Pi on the network to identify the nodes and read data from them.
Using Power over Ethernet (PoE) to power my sensor nodes.
Don't want to actually connect to the outside internet, just want the convenience of assembling a network with node names and such.

Why not use wireless solutions (e.g. XBee):

Currently, it seems Xbee is the way to go, but I don't want a wireless solution.

I want the reliability of a wired connection.
I don't want to have to worry about batteries

What I'm doing right now:

Currently, I have all my sensors wired to a central Arduino MEGA using 4-conductor security cable (Vcc, GND, and two signal conductors). The MEGA communicates over serial with a Raspberry Pi. This is annoying for the following reasons:

I have to solder/unsolder every time I want to change something.
I have to figure out which digital I/O pins are available on the MEGA and have to write down which signal conductor goes to which pin on the MEGA and means what on the sensor.
There is a finite number of pins.
Each sensor is its own unique project. I want to start standardizing these sensors to clean up the code.

What I have found so far:

I've been looking at XPort sensors; however they are very expensive (i.e. $60 ea.) and don't support PoE. If there is a solution using Arduino and an Ethernet Shield, it brings down the base cost of a sensor by a lot.

Request:

Where can I find out more information about wired Arduino sensors? Are there any prebuilt solutions that already do what I am looking for?


texts: In my recent project, I want to load Image in my Arduino. Is there any library available that can be used for loading Image in Arduino. Give some suggestion. Thank you!


texts: How to find if AC Appliance is on or off using ACS712 current Sensor

texts:
I am trying to get the status of appliance using current sensor. My Circuit looks like below image. I don't want to measure current. I just want to know whether appliance is on or off.

I am getting following readings when power turned on and off, I don't see any difference, I am not able to figure out whether the bulb is on or off.

Please help me to know the status of appliance/bulb.

PS. Please find my code below:

/*
Measuring AC Current Using ACS712
www.circuits4you.com
*/
const int sensorIn = A0;
int mVperAmp = 185; // Use 100 for 20A Module and 66 for 30A Module

double Voltage = 0;
double VRMS = 0;
double AmpsRMS = 0;

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

void loop(){

 Voltage = getVPP();
 VRMS = (Voltage/2.0) *0.707;  //root 2 is 0.707
 AmpsRMS = (VRMS * 1000)/mVperAmp;
 Serial.print(AmpsRMS);
 Serial.println(" Amps RMS");
}

float getVPP()
{
  float result;
  int readValue;             // value read from the sensor
  int maxValue = 0;          // store max value here
  int minValue = 1024;       // store min value here

   uint32_t start_time = millis();
   while((millis()-start_time) < 1000)  // sample for 1 Sec
   {
       readValue = analogRead(sensorIn);
       // see if you have a new maxValue
       if (readValue > maxValue)
       {
            /*record the maximum sensor value*/
           maxValue = readValue;
       }
       if (readValue < minValue)
       {
           /*record the minimum sensor value*/
           minValue = readValue;
       }
   }

   // Subtract min from max
   result = ((maxValue - minValue) * 5.0)/1024.0;

   return result;
 }


texts: what is fastest allowable serial baudrate?

texts:
what is the fastest serial read the Mega can do?
begin.Serial1(1024000) is accepted for compiling, but reading jibberish

any suggestions on a faster device?


texts: Coding Arduino's samples/period and cycles/sample configurations for input signal

texts:
Am I able to code the Arduino so that I can change cycles/sample of an input waveform and a number of samples/period configurations? I would like to modify these parameters in order to be able to store a high-frequency sinusoid but taking into account Arduino's 16MHz clock.
For examples, I have a 40,000kHz sine wave. I would like to sample it at 10 samples/period and having 10 cycles/sample. As a result, I need a (40,000kHz * 10samples/period * 10 cycles/sample = 4MHz clock, which Arduino can supply). Compared to a more standard 128 samples/period and 256 cycles/sample, which would require a 1.3GHz clock.


texts:
I have two Arduinos, a nano and a mega. I want to output 16 bit PWM, but can seem to only get it working on the nano. I'm adapting the code from this website: http://www.ofrecordings.com/2014/03/16/how-to-set-up-16-bit-pwm-with-an-arduino-uno-atmega328/

void setup() {
  // Set PB1/2 as outputs.
  DDRB |= (1 << DDB1) | (1 << DDB2);

  TCCR1A =
      (1 << COM1A1) | (1 << COM1B1) |
      // Fast PWM mode.
      (1 << WGM11);
  TCCR1B =
      // Fast PWM mode.
      (1 << WGM12) | (1 << WGM13) |
      // No clock prescaling (fastest possible
      // freq).
      (1 << CS10);
  OCR1A = 0;
  // Set the counter value that corresponds to
  // full duty cycle. For 15-bit PWM use
  // 0x7fff, etc. A lower value for ICR1 will
  // allow a faster PWM frequency.
  ICR1 = 0xffff;
}

void loop() {
  // Use OCR1A and OCR1B to control the PWM
  // duty cycle. Duty cycle = OCR1A / ICR1.
  // OCR1A controls PWM on pin 9 (PORTB1).
  // OCR1B controls PWM on pin 10 (PORTB2).
  OCR1A = 0x0000;
  delay(500);
  OCR1A = 0x8000;
  delay(500);
  OCR1A = 0xffff;
  delay(500);
}

That code works on the nano, but not on the mega. I expect that it output PWM on pins 11 and 12, but no luck. Care to explain how I can get it working? It's an entirely different microprocessor, and I'm not sure which parts of the code to change.


texts: How do I configure WEMOS D1 R2 Vin pin to output max voltage?

texts:
I am in need of 12VDC from my Wemos D1 R2. How do I configure the Vin pin to output the max (I think its 12VDC)?

board: Wemos D1 R2 V2.1.0 - ESP8266 (LOLIN D1 R2)

Pinout here in pictures below