texts: How does the reset button work on the Arduino?

texts:
I'm confused about how and when to use the reset button on the Arduino. Do I simply press the button while it is on? Is it simply restarting the board or clearing the uploaded code as well? Currently when I press the button while my Uno is powered it does absolutely nothing.

I have been using this board for many weeks with no problem and just now I have been getting this error:

avrdude: stk500_getsync()

And I cannot upload code. I tried using the reset button but I see nothing happening on the board, no blink, no flicker, nothing indicating something was reset.


texts: Use ESP8266 as WiFi client connected to Arduino Pro Mini

texts:
So i'm trying to use the PubSubClient Library on my arduino mini pro, but I'm connecting to the internet via wifi using an ESP8266.

Using a mini means I have to use software serial to connect to the ESP, but I've ran into a problem. I can't find anywhere such as ESPWiFiClient to use with the examples from the PubSubClient library where they use EthernetClient.

Is there any available libraries that can emulate EthernetClient with an ESP module over software serial?


texts:
I'm sure this is a very basic coding mistake...

I'm picking up a reading from A0. If the value is 0, I want the value of the serial to be written to the Serial Monitor.

I also want it only to write to the Serial Monitor for the first time that the value falls to 0.

I don't understand why, when the value for SensorValue = 0, the if is not performed.

This is my code:

boolean must_print = true;
int sensorValue = 0;

// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  sensorValue = analogRead(A0);

  if (sensorValue = 0) {

     if (must_print = true)
    {
     must_print = false;
     Serial.println(sensorValue);
    }
  else
    must_print = true
  }

   delay(500);        // delay in between reads for stability
}

Thanks!


texts: Read Serial data from an arduino with c code

texts:
I am trying to receive data through the serial port from my SBC (a TS-7200), i am working with linux and handle serial communication using C/C++.To send data to the SBC  i'am using an arduino uno.

So basically the arduino is printing ASCII text data through Pin1 (Hardware Serial) in a loop with a 3ms delay.

From the SBC i read raw data in no canonical mode, ( in the code below are the parameters and configurations for the serial port) i'am trying to read one characters at a time, following the example from this page :
https:/ from this page/chrisheydrick.com/2012/06/17/how-to-read-serial-data-from-an-arduino-in-linux-with-c-part-3/.

but when i run the code it print the number 2 as 3, and the number 3 as f, I am not able to read ASCII characters.

I have tried several things but I have not been able to find the problem, Hope someone can help me.

Here is the Arduino code:

 #include <SoftwareSerial.h>
 SoftwareSerial mySerial(2,3); // RX, TX

 void setup() {

    Serial.begin(9600);
    mySerial.begin(9600);

  }

 void loop() {

   Serial.print(2);

   delay(3000);

   Serial.print(3);

   delay(3000);

}

The c code from the linux side:

#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <termios.h>

char *portname = "/dev/ttyAM1";
char buf[256];

int main(int argc, char *argv[])
{
  int fd,stop = 0;

/* Open the file descriptor in non-blocking mode */
fd = open(portname, O_RDWR | O_NOCTTY);

/* Set up the control structure */
struct termios toptions;

/* Get currently set options for the tty */
tcgetattr(fd, &toptions);

/* Set custom options */

/* 9600 baud */
cfsetispeed(&toptions, B9600);
cfsetospeed(&toptions, B9600);
/* 8 bits, no parity, no stop bits */
toptions.c_cflag &= ~PARENB;
toptions.c_cflag &= ~CSTOPB;
toptions.c_cflag &= ~CSIZE;
toptions.c_cflag |= CS8;
/* no hardware flow control */
toptions.c_cflag &= ~CRTSCTS;
/* enable receiver, ignore status lines */
toptions.c_cflag |= CREAD | CLOCAL;
/* disable input/output flow control, disable restart chars */
toptions.c_iflag &= ~(IXON | IXOFF | IXANY);
/* disable canonical input, disable echo,
   disable visually erase chars,
   disable terminal-generated signals */
toptions.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
/* disable output processing */
toptions.c_oflag &= ~OPOST;

/* wait for 1 character to come in before read returns */
/* WARNING! THIS CAUSES THE read() TO BLOCK UNTIL ALL */
/* CHARACTERS HAVE COME IN! */
toptions.c_cc[VMIN] = 1;
/* no minimum time to wait before read returns */
toptions.c_cc[VTIME] = 0;

/* commit the options */
tcsetattr(fd, TCSANOW, &toptions);

/* Wait for the Arduino to reset */
usleep(1000*1000);
/* Flush anything already in the serial buffer */
tcflush(fd, TCIFLUSH);

while(stop == 0){

  /* read up to 128 bytes from the fd */
  int n = read(fd, &buf, 128);
  usleep(3000*1000);
  /* print how many bytes read */
  printf("%i bytes got read...\n", n);
  /* print what's in the buffer */
  printf("Buffer contains...\n%s\n", buf);
 }
 return 0;
}

This is what i see:

2 bytes got read...
Buffer contains...
f
2 bytes got read...
Buffer contains...
3
2 bytes got read...
Buffer contains...
f
2 bytes got read...
Buffer contains...
3


texts:
I'm trying to read temperature and humidity from a DHT11 sensor and write values to a 20x4 LCD.
I hit a behaviour I don't understand. When I use the DHT tester program that come with the DHT library, everything works well. I get the DHT information on the Serial console. This DHT tester program use the pin 2 to read the data from the DHT.

I wrote the following code who works perfectly:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>  // F Malpartida's NewLiquidCrystal library
#include <DHT.h>

#define DHTTYPE DHT11
#define DHTPIN 13      // Digital

DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C    lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

void setup() {
  Serial.begin(9600);
  while (!Serial) {
  }
  Serial.println("Serial OK!");

  dht.begin();
  lcd.begin(20,4);
  lcd.setBacklight(0);
  lcd.clear();
  lcd.print("Hello! ");

  Serial.println("Init finished!");
}

void loop() {
  delay(2000);

  float DHT_hum = dht.readHumidity();
  float DHT_temp_c = dht.readTemperature(false);
  float DHT_temp_f = dht.readTemperature(true);

  if (isnan(DHT_hum) || isnan(DHT_temp_c) || isnan(DHT_temp_f)) {
    Serial.println("Failed to read from DHT sensor!!");
    lcd.clear();
    lcd.print("fail! ");
    return;
  }

  float heat_index = dht.computeHeatIndex(DHT_temp_f, DHT_hum);

  Serial.print("Humidity: ");
  Serial.print(DHT_hum);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(DHT_temp_c);
  Serial.print(" *C ");
  Serial.print(DHT_temp_f);
  Serial.print(" *F\t");
  Serial.print("Heat index: ");
  Serial.print(heat_index);
  Serial.println(" *F");

  lcd.clear();
  lcd.print("Humi: ");
  lcd.print(DHT_hum);
  lcd.print("%");
  lcd.setCursor(0, 1);
  lcd.print("Temp: ");
  lcd.print(DHT_temp_c);
  lcd.print("C");
  lcd.setCursor(14, 0);
  lcd.print("HI: ");
  lcd.setCursor(14, 1);
  lcd.print(dht.convertFtoC(heat_index));
  lcd.print("C");

}

As you can see, I use pin 13 for the DHT11 (DHTPIN).
If I set to it to "2" then my program is no longer working (having the pin connected or not doesn't change the result).
The serial display

Serial OK!
Init finished!
Failed to read from DHT sensor!!

and that's all, it even doesn't loop to display "Failed to read from DHT sensor!!" again. LCD text doesn't change too. Like if the program is totally exiting after "Serial.println("Failed to read from DHT sensor!!");"

I'm lost... The LCD lib I use is the very common one from fm
https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home


texts: What will happen if I keep my arduino on for 24 hours?

texts: Please tell me that if I keep my arduino uno on for 24 hours with a adapter, will it get harmed?


texts: How are HIDs (keyboard,joypad) created and mapped?

texts:
I am creating an electronic device that has a 4 position rotator switch and a SPST Momentary ON push button. For the knob, I plan for position 0 to be low (OFF). Position 1-3 are high (ON). But I want these positions to equate to a different signal so they each have different values. When push button is pressed, it sends a high (ON) signal.

Can someone point me into slightly setting up the circuit to accomplish this?
And how can I create a remapper program (preferably in C++) that detects the HID device and allows the end-user to remap the pushbutton signal to any QWERTY key? I want replicate this process for each input of my device.


texts: Can the official arduino GSM shield library be changed to work with hardware serial on mega

texts: I have a complex requirement that uses a number of libraries that depend on timing I.e. OneWire. When using the official GSM shield on a mega, it loads a version of software serial to talk to the GSM. I want to make it use a spare hardware serial port on the MEGA for more timing stability. How should I modify the GSM library to (optionally) auto detect a MEGA and then use a nominated serial port. I am happy to jumper the correct pins from the mega serial hardware port to the bent outwards pins 2 and 3 of the GSM shield ( pin 2 is already bent out if you use a MEGA anyway).


texts:
if (!MDNS.begin("esp8266")) {
    Serial.println("Error setting up MDNS responder!");
    while (1) {
      delay(1000);
    }
  }

I know this will result in an infinite loop if the if conditional is never satisfied, however I was wondering if this code would still result in an infinite loop if say, after 3 iterations the if conditional is satisfied?

Or if something like:

while(!MDNS.begin("esp8266")) {
   delay(1000);
}

is different?

Code from: https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266mDNS/examples/mDNS_Web_Server/mDNS_Web_Server.ino (line 58)


texts: Why is this Code not working with Esp8266 when it worked perfectly with Arduino Uno?

texts:
I'm making an attendance System using an RFID scanner, scanning RFID Card & saving Data in Excel.

When I used this code with Arduino Uno (by changing #define SS_PIN 12 and#define RST_PIN 9) it worked perfectly fine.

However, when I used the same code (by changing #define SS_PIN 15 and #define RST_PIN 5) the RFID is unable to scan any of the RFID Cards.

PIN CONNECTION Of ESP8266 & MFRC522
SDA to D8
SCK to D5
MOSI to D7
MISO to D6
GND to GND
RST to D1
3.3V to 3V3

#include <ESP8266WiFi.h>     //Include Esp library
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
#include <SPI.h>
#include <MFRC522.h>        //include RFID library

#define SS_PIN 15 //RX slave select
#define RST_PIN 5

MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.

byte card_ID[4]; //card UID size 4byte
byte Name1[4]={0x36,0x69,0x25,0xD9};//first UID card 36 69 25 D9
byte Name2[4]={0xA7,0xB5,0x33,0x04};//second UID card A7 B5 33 04

int NumbCard[2];//the number of cards. in my case i have just two cards.
int j=0;
int statu[2];//the number of cards. in my case i have just two cards.
int s=0;

int const RedLed=6;
int const GreenLed=5;
int const Buzzer=8;

String Log;
String Name;//user name
long Number;//user number
int n ;//The number of card you want to detect (optional)

void setup() {

  Serial.begin(9600); // Initialize serial communications with the PC
  SPI.begin();  // Init SPI bus
  mfrc522.PCD_Init(); // Init MFRC522 card

  Serial.println("CLEARSHEET");                 // clears starting at row 1
  Serial.println("LABEL,Date,Name,Number,Time IN,Time OUT");// make four columns (Date,Time,[Name:"user name"]line 48 & 52,[Number:"user number"]line 49 & 53)

  pinMode(RedLed,OUTPUT);
  pinMode(GreenLed,OUTPUT);
  pinMode(Buzzer,OUTPUT);

  delay(200);
   }

void loop() {
  //look for new card
   if ( ! mfrc522.PICC_IsNewCardPresent()) {
  return;//got to start of loop if there is no card present
 }
 // Select one of the cards
 if ( ! mfrc522.PICC_ReadCardSerial()) {
  return;//if read card serial(0) returns 1, the uid struct contians the ID of the read card.
 }

 for (byte i = 0; i < mfrc522.uid.size; i++) {
     card_ID[i]=mfrc522.uid.uidByte[i];

       if(card_ID[i]==Name1[i]){
       Name="First Employee";//user name
       Number=123456;//user number
       j=0;
       s=0;
      }
      else if(card_ID[i]==Name2[i]){
       Name="Second Employee";//user name
       Number=789101;//user number
       j=1;
       s=1;
      }
      else{
          digitalWrite(GreenLed,LOW);
          digitalWrite(RedLed,HIGH);
          goto cont;//go directly to line 71
     }
}
      if(NumbCard[j] == 1 && statu[s] == 0){
      statu[s]=1;
      Serial.print("DATA,DATE," + Name);//send the Name to excel
      Serial.print(",");
      Serial.print(Number); //send the Number to excel
      Serial.print(",");
      Serial.print("");
      Serial.print(",");
      Serial.println("TIME");

      }
      else if(NumbCard[j] == 0){
      NumbCard[j] = 1;
      n++;
      Serial.print("DATA,DATE," + Name);//send the Name to excel
      Serial.print(",");
      Serial.print(Number); //send the Number to excel
      Serial.print(",");
      Serial.print("TIME");
      Serial.print(",");
      Serial.println("");
      digitalWrite(GreenLed,HIGH);
      digitalWrite(RedLed,LOW);
      digitalWrite(Buzzer,HIGH);
      delay(30);
      digitalWrite(Buzzer,LOW);
      }
      else if(statu[s] == 1){
     //Turn Red LED when the employee Already Left
     digitalWrite(RedLed,HIGH);
      }
      delay(1000);
cont:
delay(2000);
digitalWrite(GreenLed,LOW);
digitalWrite(RedLed,LOW);

//if you want to close the Excel when all card had detected and save Excel file in Names Folder. in my case i have just 2 card (optional)
/*if(n==2){
    Serial.println("SAVEWORKBOOKAS,Names/WorkNames");
    Serial.println("FORCEEXCELQUIT");
    }*/
}


texts:
I'm getting my first steps on Arduino and I'm trying to do an exercise where I have to draw a graph bar in a 16x2 LCD that indicates the values read from a vector of 16 integer elements amplified by the value read from a potentiometer (connected to the analog pin A0) during runtime. The graph should change in real-time as I move the cursor of the potentiometer to the left or right.
I have the following code structure:

void loop() {
// Read the 16 vector elements and map then to the screen height ...
// Print out their values multiplied by the value read form the potentiometer, to the serial monitor ...
// Draw a bar for each one of the vector elements (you will have 16 bars in the end)...
// If the graph has reached the screen edge do not amplify it anyfurther. If it has reached the bottom, do the same
//Wait a bit. Start drawing everything from scratch.

So far what I have is:
#include<LiquidCrystal.h>

// Create an LCD object and connect control wires

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int vector[16] = {3, 7, 10, 15, 28, 12, 43, 1, 6, 19, 29, 23, 54, 76, 57, 66};

int value=0;

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

  // Specify the LCD's number of columns and rows

  lcd.begin(16, 2);
}

void loop(){

  value = analogRead(A0);

  for(int i=0; i<16; i++){
    int vector2[i] = map(vector[i], 0, 1024, 0, 20);
    Serial.println(vector2[i]*value);
  }
}

However I'm getting the following error so far:
 In function 'void loop()':
28:25: error: array must be initialized with a brace-enclosed initializer
 exit status 1

Also I can't think of a way to do the last 3 steps of the code structure I have.
I know that if i would want to print a bar like a character I could do:
#include<LiquidCrystal.h>

// Create an LCD object and connect control wires

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
byte bar[] ={B11111, B11111, B11111, B11111, B11111, B11111, B11111, B11111};

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

  // Specify the LCD's number of columns and rows

  lcd.begin(16, 2);
  lcd.createChar(0, bar);
}

void loop(){
lcd.setCursor(0,0);
cd.write(byte(0));

}

But even this would only print a column in the first row and column and not in both rows and first column of the LCD.
Can someone help me with the error I already have and give me some lights on how to do the last 3 steps of the code structure?


texts: Time Stamping data on an Arduino and reading it on a Java IDE

texts:
Does anyone have an idea on the best way to time stamp an arduino sketch that contains a data packet which is to be read out using a java IDE (IntelliJ) for graphic visualization of the packet. I tried declaring the time variable on the arduino section but having problem unpacking the unsigned long variable in java. Below is a snippet of the arduino code.

             unsigned long codeTime = 0; //The time the sketch takes to execute
         static unsigned long char dataArray [1]; // a variable to hold both sensor data

         void setup(){
              Serial.begin(9600);
              Serial1.begin(9600);
          }
         void state1(){
             if (Serial1.available()){
                    while (Serial1.available() > 0){
                 codeTime = millis(); //using the millis() instead of micros()
                 //memcpy should copy the whole data into position 0 ????
                 memcpy(&dataArray[0], &codeTime,sizeof(codeTime));
                 uint16_t newByte1 = Serial1.read(); // read in the first byte
                 uint16_t newByte2 = Serial1.read(); //read in the second byte
                 uint16_t dataByte = newByte2 >> 8;
                 dataByte = (dataByte | newByte1);
                 dataArray[1] = dataByte;
                 Serial1.write((uint16_t*)dataArray, sizeOf(dataArray));
                 }
               }
              }

            void loop(){
                   state1();
                   Serial1.flush();  //clear the serial port
                   delay(100);
                }

The question now is how do i unpack the data in java to ensure that the time variable (unsigned long time variable is well unpacked in the correct order)????. The second variable i could easily unpack in java as

              int variable1 = variable2 >> 8; //as it is a 16 bit integer I shifted
                                              // the msb/lsb accordingly
              variable1 = (variable1 | variable2);  // and finally casting it.


texts:
I've been dealing with this for quite a while now and searching all over for answers.. I'm trying to put together two floats into a char*. Separated by a ",".
This is the code I'm working with.

#include <DHT.h>
#include <RH_ASK.h>
#include <SPI.h>

#define DHT_pin 10
#define DHT_type DHT11

DHT dht(DHT_pin, DHT_type);
RH_ASK rf_driver;

float temp;
float hum;

char ch_temp[6];
char ch_hum[6];
char msg_out[12] = "";

void setup() {
  Serial.begin (115200);
  dht.begin();
  if (rf_driver.init()) {
    Serial.println("Radio transmitter initiated..");
  }
  else {
    Serial.println("Radio transmitter failed to initiate..");
    delay(1000);
  }
}
void loop() {
  temp = dht.readTemperature();
  hum = dht.readHumidity();

  dtostrf(temp, 5, 2, ch_temp);
  dtostrf(hum, 5, 2, ch_hum);
  strcat(msg_out, ch_temp);
  strcat(msg_out, ",");
  strcat(msg_out, ch_hum);

  Serial.println(msg_out);
  rf_driver.send((uint8_t *)msg_out, strlen(msg_out));
  rf_driver.waitPacketSent();
  Serial.print("data sent, package size: ");
  Serial.println(strlen(msg_out));
  delay(1000);

}

I have tried using different sizes of the char arrays, but it just goes crazy.
This is the console output:

Radio transmitter initiated..
22.00,34.00
data sent, package size: 11
⸮⸮Radio transmitter initiated..
22.00,34.00
data sent, package size: 11

So on its way through the second loop it fails, restarts and then on its third way through it just gives up... What am I doing wrong? :( Really sad over this.


texts: Arduino esp8266 interferes with analog sensors

texts:
UPDATE: I tried CNY70 sensor and the same error is valid for it too. Even outputs of CNY70 and LDR is the same while ESP8266 plugged in. I think ESP8266 interferes with all analog sensors

I connected my esp8266 and ldr sensor to my seeediuno (clon of arduino by seeedstudio) and ldr returns values like 70 110 105 120 etc. When I directly pointed light to ldr, return values don't change, value scatter randomly between 50-130. When I disconnect esp8266 and switch to arduino diecimila from ardunio ide, ldr sensor works fine. I think esp8266 somehow interferes with ldr sensor. How can I fix this problem?

#include "ESP8266WiFi.h"
#include "ESP8266HTTPClient.h"
[![#define SSID "myssşd"
#define PASS "mypass"
#define BID 000001

const char *host = "api.host.com";

void setup() {
  //start serial connection
  Serial.begin(115200);
  //configure pin 2 as an input and enable the internal pull-up resistor
  pinMode(2, INPUT);
  pinMode(13, OUTPUT);
  pinMode(A0, INPUT);

  WiFi.begin(SSID, PASS);

  while(WiFi.status() != WL_CONNECTED){
    delay(1000);
    Serial.println("Connecting...");
  }
  //If connection successful show IP address in serial monitor
  Serial.print("Connected to ");
  Serial.println(SSID);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());  //IP address assigned to your ESP
}

void loop() {
  //read the pushbutton value into a variable
  int sensorValMeal = analogRead(A0);
  Serial.println(sensorValMeal);
  delay(1000);
}

This is how my serial prints looks like. You can see the anomally, I added my events as well.

Connecting...
Connecting...
Connecting...
Connecting...
Connected to Anaconda
IP address: 192.168.1.21
42 <- This is start
41
41
41
41
41
41
41
40
40
151 <- I turned my phones light to ldr
78
85
84
89
92
69
97
99
100
96
104 <- I switched of my phone's light
63
103
103
108
108
109
109
114
111
112
111
103
112
113
114
112
116
104
116
116
101
117
118
118
108
122
80
109
118
123
124
125
124
114
127
127
127
98
126
127
124
114
125
127
125
124
127
98
127
126
104
127
127
126
118
128
127
92
123
126
127
128
127
111
130


texts: How to fix HC05 burning even after while using voltage regulator?

texts:
I'm using two circuits for my wireless head mouse project, one of them is a transmitter circuit with Arduino Pro Micro, HC05 Bluetooth module, Elechouse Voice Recognition Module V3.1, GY-521 module based on the MPU6050 sensor. The receiver circuit (Arduino Pro Micro + HC05 Bluetooth) will receive the sensor readings from the transmitter circuit. Both modules were powered by USB from the laptop initially. They worked fine. To make the transmitter circuit completely detached from the laptop, I used a 9V battery, and a voltage regulator of 5V. The receiver circuit was still c. I should mention that I was using voltage dividers for both of the transmitter, and receiver circuit's HC05 Bluetooth modules.
onnected to the laptop USB.
.
After using the voltage regulator, the module was working fine but suddenly the HC-05 burnt, led stopped working. Transmission failed. HC05 of the receiver module also burnt after 2 minutes. Why did this happen? What's the solution?
Circuit connection:
Hc05 connection same for transmitter & receiver circuit
HC05 Tx -> Arduino Rx
Hc 05 rx -> 2k ohm -> gnd
Hc05 rx -> 1k ohm -> hc05 tx
Hc05 vcc -> arduino 5v
Hc05 gnd -> arduino gnd
Voice Recognition Module tx -> arduino 8
Rx -> Arduino 9
Vcc- 5v
Gnd - gnd
Mpu6050 sda - Arduino 2
Scl- Arduino 3
Vcc - 5V
Gnd- Gnd
Voltage regulator connection:
The connection was 9V battery +ve to input, -ve to ground, output to Arduino 5V


texts: Designing a robotic arm using Arduino Uno

texts:
We are making a robotic arm using Arduino Uno board in which we are not able to decide which kind of motor to use.

Which motor will be better if we want to lift weight up to 1kg using gripper at the ending shaft of arm? Specification of our design is as given below:

4 DOF ARM
Movable vehicle as base weight of 1kg.
Individual length of link 20cm, 20cm, 10cm and after that gripper of 8cm length.

Which kind of motor should we use? DC or Servo?


texts: Question about number of sensors for Arduino Mega

texts: What is a good max number of sensors for an Arduino Mega? Since it has like -- 2? -- ground connections, is it better to keep the number of sensors to a minimum amount?


texts:
I am using RF Tx with Arduino Uno and Rx with NodeMCU. I use RF switch library. At the recipient side if I use an Arduino Uno MCU. I can receive the output, but with NodeMCU I have a blank serial monitor; no output is shown. RF.enable (0) is used in my code and pin D2 is connected to data of RF module.

Some one help me please.


texts: Is there something I can add to my ESP8266 script to track how much data it uses on WiFi?

texts: I want to set it up on a mobile hotspot but I'd like to get an idea of how much data my sketch uses first.


texts: Routing Matrix with a large number of I/O

texts:
Lets say that i would like to make a 128x128 routing matrix with an arduino uno,

Since i am unexperienced i think of using two 4051’s for 8x8 patching and because i want to persist the patch, controlling them with two quad d type flip flops, then repeat the circuit to reach 128x128 patching capibility. Then my output count would be sufficent in arduino uno.

I think this would work but sounds unelegant to me.
Do you have another advice for me to achieve this task?

Actually what I would like to achieve is a big digitally controlled patching matrix for my own analog synth circuits at home. So analog signals will be present and should have the avalibility to patch anything to anything.


texts: Do all serial ports on an Arduino MEGA 2560 have the potential to "brick" attached items when being flashed?

texts:
I was browsing through the hookup guide for SparkFun's OBD-II UART breakout and found something particularly worrying written half way down in a quite casually presented way:

  Keep in mind when you upload this to your board, you will want to disconnect the OBD-II board RX line from the Arduino TX-0, to prevent issues during code upload, such as bricking the OBD-II board.

For my money I think bricking your device should come with a more stark warning than one stuffed part way down a guide starting with "keep in mind" and continuing with "issues". Nonetheless it caught my attention as I tend to build sealed boxes that aren't sprawled in front of a keyboard ready to be rewired any time a re-flash might happen.

Is the real risk here the fact that all of the flashed data would stream past the RX pin of the UART board and potentially accidentally send a 'self-destruct' signal? (Also I'm not sure a system is really up to scratch if you can accidentally tell it to kill itself.)

Surely the programming port is not the one being borrowed by the UART hookup? On a MEGA 2560, using a different serial port, is this still a risk or is that only on boards with one serial port?


texts: Is there a way to have more than 14 Output pins on arduino?

texts: Is it possible to have more than 14 output pins on the Arduino, I am working on a project in which I need to light up several LEDs individually. I only have an Arduino Uno, and I don't want to get a Mega.


texts: Parsing UDP text from a Command using UDP

texts:
I want to send a parameter from my computer (i.e using Hercules software) using UDP protocol to my Arduino with Ethernet shield to turn 2 LED on and off (each of them).

The command I'm using is:

$A<lamp 1>,B<lamp 2>

for example

$A1,B0

Does anyone know how to write the sketch so the Arduino can read the parameter <lamp 1> and <lamp 2>?


texts: Receiving live astronomical coordinates on Arduino Mega using telnet and ESP8266 wifi module

texts:
I'd like to receive on my arduino live coordinates of planets of solar system. Because there are already websites listing every planet coordinates, I thought it would be easier to just use a wifi module (in my case an ESP8266) and connect the arduino to one of these website.

I have the option of getting it from this website, but I have no idea how to do that.

The other way of doing it may be to connect to Horizon via their telnet server at this adress :telnet://horizons.jpl.nasa.gov:6775

Though I know how establish a connection with this server on my computer using Putty, I have no idea how to connect my arduino to it, execute commands, and, more importantly, get data (RA and DEC) of every solar system main objects.

This is my first time using Arduino wifi module, so I have no experience with it, and I don't know what it is capable of.

Thanks a lot for your attention,

Thomas


texts: Why do you need a second resistor when using a photoresistor/LDR?

texts: A photoresistor is already a resistor and will limit the voltage in the circuit. Why can't this be connected to a pin and measured? Why is a second resistor needed to connect the photoresistor to ground?


texts: Expected unqualified ID before numeric constant

texts:
After debugging and having some conflicting declarations about analog pins, I finally thought it was done, after compiling I got this error:

32:0,
1:
31:12: error: expected unqualified-id before numeric constant

2:5: note: in expansion of macro 'B1'

I can't understand what this means. What's wrong with my code down here?

// don't judge me if it's too long and overcomplicated :P I'm still new xD
int AA1 = 0;
int B1 = 1;
int C1 = 2;
int D1 = 3;
int AA2 = 4;
int B2 = 5;
int C2 = 6;
int AA3 = 8;
int B3 = 9;
int C3 = 10;
int D3 = 11;
int B4 = 12;
int C4 = 13;
int sec = 0;
int min1 = 0;
int min2 = 0;
int hour1 = 8;
bool hour2 = 0;

void setup() {
  pinMode(AA1, OUTPUT);
  pinMode(B1, OUTPUT);
  pinMode(C1, OUTPUT);
  pinMode(D1, OUTPUT);
  pinMode(AA2, OUTPUT);
  pinMode(B2, OUTPUT);
  pinMode(C2, OUTPUT);
  pinMode(AA3, OUTPUT);
  pinMode(B3, OUTPUT);
  pinMode(C3, OUTPUT);
  pinMode(D3, OUTPUT);
  pinMode(B4, OUTPUT);
  pinMode(C4, OUTPUT);
}

void loop() {
  OutputOn();
  delay(1000);
  sec++;
  if(sec == 60) {
    sec = 0;
    min1++;
      if(min1 == 10) {
      min1 = 0;
      min2++;
        if(min2 == 6) {
        min2 = 0;
        hour1++;
          if(hour1 == 10) {
          hour1 = 0;
          hour2 = 1;
        }
        if(hour2 == 1, hour1 == 3) {
          hour1 = 1;
          hour2 = 0;
        }
      }
    }
  }
}

void OutputOn() {
  digitalWrite(B1, LOW);
  digitalWrite(C1, LOW);
  digitalWrite(D1, LOW);
  digitalWrite(A2, LOW);
  digitalWrite(B2, LOW);
  digitalWrite(C2, LOW);
  digitalWrite(A3, LOW);
  digitalWrite(B3, LOW);
  digitalWrite(C3, LOW);
  digitalWrite(D3, LOW);
  digitalWrite(B4, LOW);
  digitalWrite(C4, LOW);
  if(min1 == 1) { digitalWrite(AA1, HIGH); }
  if(min1 == 2) { digitalWrite(B1, HIGH); }
  if(min1 == 3) { digitalWrite(B1, HIGH); digitalWrite(AA1, HIGH); }
  if(min1 == 4) { digitalWrite(C1, HIGH); }
  if(min1 == 5) { digitalWrite(C1, HIGH); digitalWrite(AA1, HIGH); }
  if(min1 == 6) { digitalWrite(D1, HIGH); digitalWrite(B1, HIGH); }
  if(min1 == 7) { digitalWrite(D1, HIGH); digitalWrite(AA1, HIGH); digitalWrite(B1, HIGH); }
  if(min1 == 8) { digitalWrite(D1, HIGH); }
  if(min1 == 9) { digitalWrite(D1, HIGH); digitalWrite(AA1, HIGH); }
  if(min2 == 1) { digitalWrite(AA2, HIGH); }
  if(min2 == 2) { digitalWrite(B2, HIGH); }
  if(min2 == 3) { digitalWrite(B2, HIGH); digitalWrite(AA1, HIGH); }
  if(min2 == 4) { digitalWrite(C2, HIGH); }
  if(min2 == 5) { digitalWrite(C2, HIGH); digitalWrite(A2, HIGH); }
  if(min2 == 6) { digitalWrite(C2, HIGH); digitalWrite(B2, HIGH); }
  if(hour1 == 1) { digitalWrite(AA3, HIGH); }
  if(hour1 == 2) { digitalWrite(B3, HIGH); }
  if(hour1 == 3) { digitalWrite(B3, HIGH); digitalWrite(AA3, HIGH); }
  if(hour1 == 4) { digitalWrite(C3, HIGH); }
  if(hour1 == 5) { digitalWrite(C3, HIGH); digitalWrite(AA3, HIGH); }
  if(hour1 == 6) { digitalWrite(C3, HIGH); digitalWrite(B3, HIGH); }
  if(hour1 == 7) { digitalWrite(C3, HIGH); digitalWrite(AA3, HIGH); digitalWrite(B3, HIGH); }
  if(hour1 == 8) { digitalWrite(D3, HIGH); }
  if(hour1 == 9) { digitalWrite(D3, HIGH); digitalWrite(C3, HIGH); }
  if(hour2 == 1) { digitalWrite(B4, HIGH); digitalWrite(C4, HIGH); }
}

It's supposed to be code for a clock (if it wasn't obvious enough) hooked up to 4 7-segment decoders, also connected to 4 7-segment LED displays.


texts:
My question is simple: there is any Pascal or Pascal-class (FPC, Delphi, mikroPascal) programming language for Arduino?

Preferably (I hope I don't ask too much) that language should not be older than 10 years.

Update:
Let's not start a flame war about "why the xxx programming language is so much better Pascal" and keep focus on the core of this question. I know that Pascal has it flaws (nothing its perfect, right?). I accept them and I still want to use it :)
Many thanks.


texts: Different Counter Reading on Serial Monitor Vs .96" OLED I2C

texts:
I've cobbled some code together from reading multiple sources on the web.  Makeatronics in particular to help me get this rotary encoder code together (shout out to them).  I'm pretty close to the end, but now trying to port it over the OLED display.  Not sure what the issue is, but it doesn't miss counter steps when read on the serial monitor, but does when ported to the OLED.
I increased the clock speed to 400Khz using Wire.setClock as I saw that suggested in some other places for I2C comms.
1.) Any thoughts on how I can improve the code or hardware to get this to read without missing steps?
Hardware:

Nano (USB Powered)
White .96" OLED I2C SSD1306
HW-040 Rotary Encoder

Libraries:

Arduino WIRE
Adafruit SSD1306 Library

The Serial Monitor Code:

#define PinCLK 2
#define PinDT 3

volatile boolean turnDetected = false;
void rotarydetect() {
  turnDetected = true;
}

void setup() {
  attachInterrupt (digitalPinToInterrupt(2), rotarydetect, CHANGE);
  pinMode(PinCLK, INPUT_PULLUP);
  pinMode(PinDT, INPUT_PULLUP);
  Serial.begin(2000000);
}

void loop() {
  if(turnDetected) {
    turnDetected = false;

    static uint8_t enc_val = 0;
    static int16_t enc_count = 0;
    static int8_t lookup_table[] = {0,1,0,-1,-1,0,1,0,0,1,0,-1,-1,0,1,0};
    static long lastTimeToDebounce = 0;
    static int debounceTime = 1;
    static int enc_counter = 0;

    if((millis() - lastTimeToDebounce) > debounceTime) {

    enc_val <<= 2;
    enc_val = enc_val | ((PIND & 0b1100) >> 2);
    enc_counter = enc_counter + lookup_table[enc_val & 0b1111];

    Serial.print("Counter: ");
    Serial.println(enc_counter);
    Serial.println("");
    }
    lastTimeToDebounce = millis();
  }
}

And the OLED Code:

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h>

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

#define PinCLK 2
#define PinDT 3

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

volatile boolean rotated = false;

void rotarydetect() {
  rotated = true;
}

void setup() {
  Wire.begin();
  Wire.setClock(400000);
  attachInterrupt (digitalPinToInterrupt(2), rotarydetect, CHANGE);
  pinMode(PinCLK, INPUT_PULLUP);
  pinMode(PinDT, INPUT_PULLUP);

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
}

void loop() {
  if(rotated) {
    rotated = false;

    static uint8_t enc_val = 0;
    static int16_t enc_count = 0;
    static int8_t lookup_table[] = {0,1,0,-1,-1,0,1,0,0,1,0,-1,-1,0,1,0};
    static long lastTimeToDebounce = 0;
    static int debounceTime = 3;
    static int enc_counter = 0;

    if((millis() - lastTimeToDebounce) > debounceTime) {

    enc_val <<= 2;
    enc_val = enc_val | ((PIND & 0b1100) >> 2);
    enc_counter = enc_counter + lookup_table[enc_val & 0b1111];
    display.setCursor(0,0);
    display.clearDisplay();
    display.print("Counter: ");
    display.println(enc_counter);
    display.println("");
    display.display();

    }
    lastTimeToDebounce = millis();
  }
}

I also tried the LCD_1602 screen (still through the I2C module board), and more or less it has the same results.  I also switched the code from the ISR to trigger the code loop, to a polling loop that detects when the CLK pin changes state with the LCD 1602 screen.  Same array with bit shifting as above for state detection.  Same results.  I also removed the very low debouncing code altogether with the Wire.setClock(400000) same results.
Seems like this may be a I2C limitation for communication?


texts:
I have 2 HM10 Bluetooth modules connected to 2 Arduino Teensy running the following code.

void setup() {
  Serial.begin(9600);
  Serial1.begin(9600);
  // If the baudrate of the HM-10 module has been updated,
  // you may need to change 9600 by another value
  // Once you have found the correct baudrate,
  // you can update it using AT+BAUDx command
  // e.g. AT+BAUD0 for 9600 bauds
}

void loop() {
  char c;
  if (Serial.available()) {
    c = Serial.read();
    Serial1.println(c);
  }
  if (Serial1.available()) {
    c = Serial1.read();
    Serial.print(c);
  }
}

By pairing them using the AT commands I was able to send messages back and forth by writing to Serial1. However now when I try to send AT commands it will just send the string to the other module instead of replying OK etc. How do I break the connection and make the AT commands work again?

The tutorial I used to pair the modules.


texts: 10k ohm Potentiometer vs 10k ohm Resistor on LCD Display

texts:
I'm trying to use a LCD Display with my Arduino, but I don't have a potentiometer and all of the guides I find always require one, usually a 10k ohm potentiometer.

The point is that I'm not very good at this stuff, but I understand that the potentiometer is actually a resistor that can vary, am I correct? In that case, if I use a simple 10k resistor I would have the same result as if I was using that potentiometer at the higher resistance (10k).

Would it be correct to use the resistor instead of the potentiometer? Then I would have to plug the positive on one side of the resistor and both the negative and output to the LCD on the other side of the resistor?


texts: How to re-construct audio from series of analog integer input?

texts:
I'm trying to learn how to stream audio from the A0 pin of an ESP8266 NodeMCU board via UDP socket connection over to another windows computer that uses pyaudio to play it.   At the moment, all I get on the windows computer are a series of "popping" sounds each spaced about half a second apart.

I'm new to working with these types of break out boards, so I found an online project that I'm using as a starting point:

Streaming audio from ESP8266 to pyaudio working in Arduino IDE

I figure I start troubleshooting my popping sound issue by inspecting the UDP packets my ESP8266 code.  Below is the source code I'm working from:

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

const char* ssid = "change this";
const char* password = "change this";
int contconexion = 0;

WiFiUDP Udp;

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

  pinMode(5, OUTPUT);  //D1 Led de estado
  digitalWrite(15, LOW);

  WiFi.mode(WIFI_STA); //para que no inicie el SoftAP en el modo normal
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED and contconexion <50) { //Cuenta hasta 50 si no se puede conectar lo cancela
    ++contconexion;
    delay(250);
    Serial.print(".");
    digitalWrite(5, HIGH);
    delay(250);
    digitalWrite(5, LOW);
  }
  if (contconexion <50) {
      //para usar con ip fija
      IPAddress Ip(192,168,1,180);
      IPAddress Gateway(192,168,0,1);
      IPAddress Subnet(255,255,255,0);
      WiFi.config(Ip, Gateway, Subnet);

      Serial.println("");
      Serial.println("WiFi conectado");
      Serial.println(WiFi.localIP());
      //digitalWrite(5, HIGH);
  }
  else {
      Serial.println("");
      Serial.println("Error de conexion");
      //digitalWrite(15, LOW);
  }
}

void loop()
{
  Udp.beginPacket("192.168.0.26", 1234);

  for(int i=0; i<1024;i++){
    int old=micros();

    float analog = analogRead(A0);
    if (analog > 255) {
      analog = 255;
    }
    else if (analog < 0){
      analog = 0;
    }
    Udp.write(int(analog));
    Serial.print(int(analog));
    Serial.print(",");
    while(micros()-old<87); // 90uSec = 1Sec/11111Hz - 3uSec para los otros procesos
  }
  Serial.print(";;;;;");
  Udp.endPacket();
  delay(5);
}

Notice near the bottom of the file, I print out each analog value separated by a comma, and each data packet separated by five semicolons.

Can someone suggest a way for me to re-construct these series of integers into a sound file that I can inspect via listening with my own ears?  Then I can tell if the sound data being sent is complete?  Or let me know if there's a better way to test if all the data packets are being sent correctly.

UPDATE

I tried to create a wav file by doing this:

Take the list of all integers from Serial.print(int(analog)) and paste it into a file. I make sure all integers are space delimited (ie. no more commas or semicolons)
I copied the file over to a linux machine that had ffmpeg installed
I ran the command ffmpeg -f u8 -ar 11111 -ac 1 -i myfileofintegers -y test.wav

When I listen to the test.wav file, I just hear a series of rapid popping noises.  Not sure if I created the wav file properly?


texts: counting ADC samples ( using a light sensor)

texts:
i am new to micro controller programming and in need of help. i have managed to interface a light sensor to a micro controller (atmega 32a) and can read the value i.e. (1023) as per the set prescale. however i intended to achieve a single decimal value as the result. in this case (1) every time the sensor is exposed to light and successively perform an incremented tally as lights go on and off around the sensor ( i am using a LDR for this). i am currently having problem getting my micro controller to do this. i have searched all over the internet but no seems to assist me on this... please any insight on how to achieve this will be much appreciated. i know its a simple thing,HELP :(

basically just a means of making my micro controller count the number of times light falls on the LDR


texts: How to send message to multiple number using arduino and SIM900A mini v3.8.2?

texts:
I am using this code to send message using Arduino Uno & SIM900A mini v3.8.2 module. But I need to send same message on multiple numbers.

#include <SoftwareSerial.h>
SoftwareSerial SIM900A(10,11);
void setup()
{
  SIM900A.begin(9600);
  Serial.begin(9600);
  Serial.println ("SIM900A Ready");
  delay(100);
  Serial.println ("Type s to send message or r to receive message");
}
void loop()
{
  if (Serial.available()>0)
   switch(Serial.read())
  {
    case 's':
      SendMessage();
      break;
    case 'r':
      RecieveMessage();
      break;
  }
 if (SIM900A.available()>0)
   Serial.write(SIM900A.read());
}
 void SendMessage()
{
  Serial.println ("Sending Message");
  SIM900A.println("AT+CMGF=1");
  delay(1000);
  Serial.println ("Set SMS Number");
  SIM900A.println("AT+CMGS=\"+639176363802\"\r");
  delay(1000);
  Serial.println ("Set SMS Content");
  SIM900A.println("Sample Message");
  delay(100);
  Serial.println ("Finish");
  SIM900A.println((char)26);// ASCII code of CTRL+Z
  delay(1000);
  Serial.println ("Message has been sent");
}
 void RecieveMessage()
{
  Serial.println ("SIM900A SMS");
  delay (1000);
  SIM900A.println("AT+CNMI=2,2,0,0,0");
  delay(1000);
  Serial.write ("Unread Message done");
 }

Thank you in advance


texts: Whats the difference between RF options (wifi, xbee, NRF24L01)

texts:
When doing RF, you have many options.
Three of the most basic are in the title box

WiFi
Xbee
NRF24L01

What are the practical differences in using them. What is the purpose of each other and the pros and cons. What would you use depending on the application you had?

I do not have a project in mind, but i want to start learning about Rf. I searched ebay for wireless devices. but i couldnt understand the differences. My goal is simply learning


texts:
I have an Arduino Due that was programmed by the Arduino IDE, to cut things short I lost access to the original sketch (.ino) file, there is no way of recovering it no matter what.
I know that in the 8-bit MCUs I can read the .hex file from the flash memory, I already did that with PIC and AVR MCUs with their software programmer utilities.
My question is: Can I use a software programmer utility on Windows PC to extract the hex file to reprogram other Arduino Due with it? If yes, please help me.
I've read about the Bossac utility, it looks promising, but I have no experience in the ARM MCUs field at all.
again: I am NOT interested in C or Assembly code, I just want the .hex file.


texts: Hiding WLAN password when pushing to GitHub

texts:
I have started to use GitHub to store Arduino code. However some of my code uses the SSID and password for my WLAN which I don’t want published.

A common way of handling this in non-embedded programming is to use a configuration file, but that doesn’t seem to be a viable approach in programming the Arduino. I’m currently just commenting out the sensitive information before pushing it to GitHub, but one day I’m sure I’ll forget.

Is there another – better - way of handling this?


texts: ESP8266 to ESP8266 communication using Arduino IDE

texts:
I am trying to achieve communication between two ESP8266, ie one acts as a server and the other acts as a client, where i am passing the string from the server's serial monitor to the client. But the client is not receiving the string.

I have uploaded the server's and client's code below:

#include <ESP8266WiFi.h>
const char* ssid = "xxx";
const char* password = "xx";

WiFiServer server(80);
char inData[64];
char inChar=-1;

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.println("ip address..");
  IPAddress ip(192,168,1,2);
  IPAddress gateway(192,168,1,1);
  Serial.print(F("selecting static ip to:"));
  IPAddress subnet(255,255,255,0);
  WiFi.config(ip,gateway,subnet);
  Serial.print(WiFi.localIP());
}

void loop() {
  // Check if a client has connected
  WiFiClient client = server.available();
  byte numBytesAvailable= Serial.available();
  if(numBytesAvailable > 0) {
    client.print("hi");
    int i;
    for (i=0;i<numBytesAvailable;i++) {
      inChar= Serial.read();
      inData[i] = inChar;
    }
    inData[i] = '\0';
    client.print(inData);
    delay(500);
    client.flush();
    Serial.println(inData);
  }
  String line = client.readStringUntil('\r');
  Serial.println(line);
  delay(100);
}

Client code:

/*
 *  This sketch sends data via HTTP GET requests to data.sparkfun.com service.
 *
 *  You need to get streamId and privateKey at data.sparkfun.com and paste them
 *  below. Or just customize this script to talk to other HTTP servers.
 *
 */

#include <ESP8266WiFi.h>
void Readled(String line);
const char* ssid     = "xx";
int ledPin1 = 14;
int ledPin2 =  12;
int ledPin3 = 13;
int ledPin4 = 15;
String ON=String("ON");
String OFF=String("OFF");
char inData[64];
char inChar=-1;

void setup() {
  Serial.begin(115200);
  delay(10);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
}

void loop() {
  delay(200);
  // Use WiFiClient class to create TCP connections
  WiFiClient client;
  const int httpPort = 80;
  if (!client.connect("192.168.1.2", httpPort)) {
    Serial.println("connection failed");
    return;
  }
  // This will send the request to the server
  client.print("hi");
  while(client.available()) {
    String Data = client.readStringUntil('\r');
    Serial.println(Data);
    client.flush();
    Readled(Data);
  }
}

This is the logic. Please suggest me where I am going wrong.


texts: How to power my Arduino mini using wall socket?

texts:
I am trying to power my Arduino Mini (which is connected to IR receiver and a relay board). The idea is to hide the entire setup behind the electrical board including the power supply. I have hacked more than a few power adapters (ranging from Mobile chargers 5-7V to 12 V adapters)

This is what I understand from what I have read so far about Arduino Mini power supply.

I can power directly using Vcc pin if I supply 5V DC regulated. (not recommended)
I can power Raw pin by using 5-12V DC and the onboard regulator will take care of converting it. 12V is the maximum, I should not use 12V it can fry the regular if used for a long period as the on-board regulator is a linear one, so a lot of heat.

This is what I understand from what I have tried so far about Arduino Mini power supply:

Don't connect power supply EVER to Vcc, it will harm the board. ALWAYS use Raw.
12 V supply = puff. instantaneously. No more on-board regulator. Now that Arduino Mini only works if I connect it using Vcc. (the charger was rated 12V 500mA)
Connecting 5V DC (300mA) is heating the regulator alot.

I have connected the Relay and IR receiver directly to the Arduino mini. Pin 10-14 are used for the relays Ins and PWD 3 for IR output.

The mini works with these 5V mobile chargers but the amount it heats up scares me.  Any suggestions on what I should do?

Also how much current consumption would be needed. I have tried using a 5V 300mA charger and 5V 700mA charger. Both work almost the same. Why?

I am a computer engineer and very new to Arduino.

Linking a similar question: Most compact method of powering Arduino from wall socket


texts: Send a file from PC to Arduino using HC-06 module

texts:
I want to send a file from my Laptop using its own Bluetooth transmitter to Arduino. Arduino has HC-06 module as receiver.Arduino has SD Card fore store the file.
I was able to send bytes using Python application.
How to send a file using a Python application to Arduino?


texts: Can I connect an output pin to an input pin to measure it's voltage on a single board?

texts:
So just bought an arduino Uno and I've been playing around with it. I want to connect one of the input pins to one of the PWM outputs and measure the output from there by sending it to my computer through Serial and then plot it in python.

Sorry if this is a basic question.
Thanks


texts: Arduino with wifi shield and 5AA batteries current draw

texts:
Arduino uno with official Wifi Shield take 5 Volts.
Arduino lights up as it should when powered but the WiFi shield is dead the l9 doesn't light up but works fine when arduino is connected to usb cable.

I use 5 battery holder 5x1.5V = 7.5 V ; 2000 mAH

50 mA - Arduino
300 mA - WiFi shield

350 mA * 5h = 1750 mAh

5xAA = 7.5V ; 2000 mAh

Am I missing here something? It should last in the worst case scenario 5 hours with new batteries at 2000 mAH (which I think they have more but I do not have them on me right now).


texts: Implementing Quasi-Perpetual Battery on Arduino

texts:
I am interested in seeing how much "uptime" I can achieve with my Arduino device/project. I am brand new to electronics/robotics, and so I wanted to bounce my idea off of this community first and see if I am overlooking anything obvious/major, or if my overall approach is incorrect.

The idea is simple:

Provide my Arduino device with 2+ "rechargeable power sources" (described next) and then provide a mechanism to route power to any viable (non-dead) power source at any time. While one power source is being used to power the Arduino device, the other "idling" power sources are recharging. The intention is to allow the device to keep switching between power sources endlessly, in perpetuity, achieving 100% uptime (perfect "high availability").

As for each "rechargeable power source" I am thinking an energyShield (rechargeable Li-polymer) backed by a solar panel.

I did some preliminary research and was told that if I were to wire these power sources in series with diodes, then the circuit would always by default draw power from the source with the highest voltage. As soon as another source has higher voltage, the circuit begins drawing power from that one, and the "old source" begins recharging.

I'm a noob but not a fool, and I know there is no such thing as perpetual energy (hence the title "quasi-perpetual"), and I'm sure factors like sunlight/weather conditions/etc. would affect the efficacy of the solar panels, etc. But I guess my first concern is: am I doin' it right? Are there any caveats/pitfalls or considerations I'm overlooking here?

Assuming I'm more or less correct in my approach, the other concern is how to actually implement power sources and diodes in a series, and how to actually rig that all up and connect it to the Arduino board. Again, I'm a total electronics newbie, so I'm just having a tough time visualizing the precise solution there.

And as for determining the actual number of power sources (energyShield + solar panel combo) my device would need, I was just planning on starting with 2, and running the device at max power and monitoring their recharge rates. The more sources I add, the longer the device will operate. Obviously, at some point I'll either reach a point where its uptime is sufficient for my needs, or I'll run out of money. :-)


texts: Multiple SoftwareSerial ports - how to handle the limitations

texts:
I am building an access control project which uses two SoftwareSerial ports. One will be used for communication with an RFID reader and another one to receive serial messages via an Xbee (e.g. remote commands). The hardware serial port is used for a cabled serial connection to another remote "server"-Arduino, which then actuates the relays.

According to the Arduino website, the SoftwareSerial Library has, amongst others, the following limitation:  - "If using multiple software serial ports, only one can receive data at a time."

My plan is to poll constantly / on regular intervals both SoftwareSerial ports, e.g. by checking RFID_Serial.available() and XBeeSerial.available(), and if it turns out that data is available, to read it out and parse it accordingly. This obviouosly has to be done in an alternating fashion, i.e. one after the other. My questions are the following.

(1) Can I initialise the ports in void setup()

RFID_Serial.begin(..);
XBeeSerial.begin(..);

... and are they then both actually active simultaneously (i.e. ready for commans like xxxxSerial.available(), or xxxxSerial.read(), or is in this case only the XBeeSerial active, because I it was the last one to be initialised?

(2) If I want to poll one after the other, do I have to "close" one SoftwareSerial port, e.g. by RFID_Serial.end(); and open the other (XbeeSerial.begin(..)) before I can do XBeeSerial.available() or read out by XBeeSerial.read()?


texts:
This isn't strictly limited to Arduino but I spend a lot of time with serial devices on my Arduino and I'm sure that others do as well:

Here goes..

Let's say a device sends three characters [ABC] via serial at 9600 8N1.

And let's also say the device receiving the data only knows that it's serial stream and 8N1 but does not know the baud.

The receiving device would need to take a guess at the baud and so probably get it wrong. It would therefore receive weird characters.

Is there anyway/anything around that a user could paste the strange characters into that would reverse engineer (from the bit stream) to give the correct baud and hence correct ascii characters [ABC]?


texts: Controlling JX PDI-6221MG Digital Servo with Arduino

texts:
So, I naively bought two of these JX PDI-6221MG Digital Servos thought they would work with the Arduino straight out of the box, just like MG996R did, for instance, but it seems they won't. However, I hear some clicking noise when the motor is connected, tho.

These are the Servo specs:

Dead band: 2μs
Working frequence: 1520μs / 330hz
Operating Speed (4.8V): 0.18 sec/60°
Operating Speed (6V): 0.16 sec/60°
Stall Torque (4.8V): 17.25 kg/cm
Stall Torque (6V):  20.32 kg/cm
Dimensions: 40.5X20.2X38mm
Weight:  62 g
Connector Wire Length: JR  265 mm
Bearing: 2BB

Manufacturer site: http://www.jx-servo.com/English/Product/49513727.html

Additionally, I used 5V 2.4A power input alongside with the Arduino Nano running just some sample code:

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

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

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

Wiring:

I tested the same configuration with MG996R and SG90 and it worked. So what am I missing here?


texts:
I am trying to decode IR codes of my Samsung tv remote
But the receiver always receiving "0"
Schematics:

Code:
#include <IRremote.h>

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

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

void loop()
{
  if (irrecv.decode(&results))
    {
    int value = results.value;
    Serial.println(" ");
    Serial.print("Code: ");
    Serial.println(results.value);
    Serial.println(" ");
    irrecv.resume();
    Serial.println("*****************");
    }
}

Please help me to decode my IR codes


texts:
Hello I found an Arduino project that works with serial port parsing and it had very interesting parsing code. I am trying to use it in my project but I still don't understand some lines and what is going there. (I marked them with ???).

char inData[82]; //create 82 char array
byte index = 0; //index byte (0 - 255)
String string_convert; //String
int PCdata[20]; //int array

void setup() {
  Serial.begin(9600); //init port
}

void loop() {
  parsing(); //loop the function
}

void parsing() {
  while (Serial.available() > 0) {
    //while there is data in serial buffer (128 bytes)
    char aChar = Serial.read(); //aChar - current symbol in buffer
    if (aChar != 'E') {
      //if aChar isnt the 'E' (End) symbol do:
      inData[index] = aChar;
      //(inData - array, index - loop № counter) write all Buffer to the array
      index++; //index + 1 - loop count
      inData[index] = '\0';
      //set the next position to '\0' or null symbol
    } else {
      //if aChar or current buffer symbol is 'E' (End) do:
      char *p = inData; //create inData address pointer
      char *str; //create pointer
      index = 0; //set counter to 0
      String value = ""; //create string
      while ((str = strtok_r(p, ";", &p)) != NULL) { //???
        string_convert = str; //???
        PCdata[index] = string_convert.toInt(); //???
        index++; //counter + 1 - loop count
      }
      index = 0; //counter to 0
    }
  }
}

Thank you for help!


texts: Can't store time over 9 hours and 10 minutes

texts:
I am making a clock on my Arduino Uno using the time library http://playground.arduino.cc/Code/Time

I let the user set a time. Which is then converted to seconds and used in the

setTime(s);

function.
When the value is over 9:10h, the seconds evaluate to 4 294 941 360 seconds (=
1 193 039.27 hours)

A code snippet:

void timeChange() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Change time");
  lcd.setCursor(0, 1);
  lcd.print("00:00");
  int hoursSet    = 0; //Stores the hours added.
  int minutesSet  = 0; //Stores the minutes added.
  String printTime;
  bool timeComplete = false;
  while (!timeComplete) {
    int buttonVal = analogRead(A0);
    if (buttonVal >= 490 && buttonVal <= 520) { //Indicates button 3 is pressed. It's function is to add one hour to the time.
      hoursSet = (hoursSet + 1) % 24; //Adds one hour to the hours.
      delay(100);
    } else if (buttonVal >= 5 && buttonVal <= 10) { //Indicates button 4 is pressed. It's function si to add 5 minutes to the time.
      minutesSet = (minutesSet + 5) % 60; //Adds minutes to the minutes.
      delay(100);
    }

    lcd.setCursor(0,1);
    String strHr = String(hoursSet);
    String strMn = String(minutesSet);
    if(strHr.length() == 2){
      lcd.print(hoursSet);
    } else if(strHr.length() == 1) {
      lcd.print("0");
      lcd.setCursor(1, 1);
      lcd.print(hoursSet);
    }

    lcd.setCursor(2,1);
    lcd.print(":");
    lcd.setCursor(3,1);
    if(strMn.length() == 2){
      lcd.print(minutesSet);
    } else if(strMn.length() == 1) {
      lcd.print("0");
      lcd.setCursor(4, 1);
      lcd.print(minutesSet);
    }
    delay(100);

    if (buttonVal >= 990 && buttonVal <= 1010) { //if button 2 is pressed again, the timecomeplete is set to true, and the script continues.
      timeIsSet = true;
      timeComplete = true;
    }
  }
  lcd.clear(); //Clear the screen
  lcd.setCursor(0, 0);
  lcd.print("The time"); //Print text, move cursor and print the time
  lcd.setCursor(0, 1);
  String strHr = String(hoursSet);
  String strMn = String(minutesSet);
  if(strHr.length() == 2){
    lcd.print(hoursSet);
  } else if(strHr.length() == 1) {
    lcd.print("0");
    lcd.setCursor(1, 1);
    lcd.print(hoursSet);
  }
  lcd.setCursor(2,1);
  lcd.print(":");
  lcd.setCursor(3,1);
  if(strMn.length() == 2){
    lcd.print(minutesSet);
  } else if(strMn.length() == 1) {
    lcd.print("0");
    lcd.setCursor(4, 1);
    lcd.print(minutesSet);
  }
  lcd.print(" is saved!");
  setTime((hoursSet * 3600) + (minutesSet * 60));
  timeIsSet = true;
  delay(5000); //Wait five, seconds then proceed

}

Added this to the code:

      Serial.print("hours ");
  Serial.println(hoursSet);
  Serial.print("hours in s ");
  Serial.println(hoursSet * 3600);
  Serial.print("minutes ");
  Serial.println(minutesSet);
  Serial.print("minutes in s ");
  Serial.println(minutesSet * 60);
  Serial.print("Combined:  ");
  Serial.println( (hoursSet * 3600) + (minutesSet * 60) );

When I input 5:15 it results in:

  hours 5
  hours in s 18000
  minutes 15
  minutes in s 900
  Combined:  18900

When I input 9:15 it results in:

  hours 9
  hours in s 32400
  minutes 15
  minutes in s 900
  Combined:  -32236

So, it looks like the library only holds an Int. But that seems odd, as the function expects seconds.


texts: Can ESP32 used for mobile game controller?

texts: I have a term project: I need to develop a mobile game(Guitar Hero Like rhythm game) probably on Unity  and I need to develop a custom controller for this game that works on android device. There will be 3 buttons for notes and Bluetooth connections between android device and controller. My question is can I use ESP32 as a mobile game controller. If it's yes, which model that you suggest me?


texts: Difference between Wire.setClock() method and TWBR method for changing I2C Frequency

texts:
I want to change the I2C frequency of my Arduino Mega 2560. I did find two methods. One method is to change the TWBR variable after Wire.begin(). The other one is to use Wire.setClock() after Wire.begin().

Whats the difference between the 2 methods? which one is better? Can I set any I2C frequency I want?


texts: How to merge two arduino sketches, one for relay's and one for Servo motor?

texts:
Recently I uploaded individual codes for relay's and Servo motor seperately, it all worked fine. But when I combined these two codes and dumped in to the loop there is a delay in functioning of the relay's but the Servo motor is working fine.

I have to control these devices through Bluetooth HC-05 module.
Could you please help me with the code?

/*
simple LED test
*/
#include <Servo.h>
char val;         // variable to receive data from the serial port
int ledpin = 2; // LED connected to pin 2 (on-board LED)
Servo myservo;
int pos = 0;    // variable to store the servo position
int motor = 0;

void setup()
{
  pinMode(ledpin = 2, OUTPUT); // pin 2 (on-board LED) as OUTPUT
  pinMode(ledpin = 3, OUTPUT); // pin 3 (on-board LED) as OUTPUT
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  Serial.print("Arduino control Servo Motor Connected OK");
  Serial.print('\n');
  Serial.begin(9600);       // start serial communication at 115200bps
  digitalWrite(ledpin = 2 ,HIGH);
  digitalWrite(ledpin = 3 ,HIGH);

}

void loop()
{

      if( Serial.read() == 'a' )    // if 'a' was received led 2 is switched off
  {
    digitalWrite(ledpin = 2, HIGH);    // turn Off pin 2

  }

  if( Serial.read() == 'A' )               // if 'A' was received led 2 on
  {
    digitalWrite(ledpin = 2, LOW);  // turn ON pin 2

  }

  if( Serial.read() == 'b' )        // if 'b' was received led 3 is switched off
  {
    digitalWrite(ledpin = 3, HIGH);    // turn Off pin 3

  }

  if( Serial.read() == 'B' )               // if 'B' was received led 3 on
  {
    digitalWrite(ledpin = 3, LOW);  // turn ON pin 3

  }

  if (Serial.read() == '\n')
    {

   motor = Serial.parseInt();
    pos = Serial.parseInt();
      myservo.write(pos);
      delay(15);
      Serial.print("Data Response : ");
      Serial.print(motor, DEC);
      Serial.print(pos, DEC);

    }

    }


texts: How to determine which pins_arduino.h file is used?

texts:
For some applications I need access to the registers that control the output/input and high/low state of pins.  For example pin 10 on a adalogger is PORTB with a mask of _BV(6).  This information can be found in pins_arduino.h.  For some boards many variants get installed.  I turned on verbose compiling and looked through the output there as well as looking through boards.txt and platform.txt.  In that output I see an include to a directory with a pins_arduino.h file but there is nothing in that file but a definition for BUILTIN_LED.

When I run a function like digitalWrite(13,HIGH); how does it know which registers to use for pin 13?  Since my board has this pin, and digitalWrite(13, HIGH); makes an LED light up ... it's working.


texts: Can increasing the size of the software RX buffer cause problem in Arduino Uno

texts:
If I were to increase the of the buffer array from 64 to say 512 will this bring any long term problem in the Arduino Uno.

Changing from this:

#ifndef _SS_MAX_RX_BUFF
#define _SS_MAX_RX_BUFF 64 // RX buffer size
#endif

to this:

#ifndef _SS_MAX_RX_BUFF
#define _SS_MAX_RX_BUFF 512 // RX buffer size
#endif

This is the header file of the software serial.


texts: Bluetooth module is neither sending nor receiving data at baudrate(115200)

texts:
Im sending data between my arduino and android via bluetooth, using a simple chat app called "Bluetooth Terminal" . the code work perfectly at baudrate(9600) but I need to increase the speed to that of (115200) but nothing gets transmitted, or at least visible, anymore.

here's my code

#include <SoftwareSerial.h>

const int TXD = 3;
const int RXD = 4;
SoftwareSerial mrBlue(TXD, RXD);
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  mrBlue.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:

  if (mrBlue.available() > 0) {

    String data = mrBlue.readString();
    Serial.println(data);

  }

  if (Serial.available() > 0) {

    String data = Serial.readString();
    mrBlue.println(data);
  }

  delay(20);
}


texts:
I'm trying to measure the amount of time that has passed between every time a reed switch mounted on a wheel is activated to calculate the speed of a bike in miles per hour and display it on two 7 segment LEDs. This is what I have so far (without 7 seg code, as that works):

const int reed = A3;
float circumference;
float pi = 3.141592653589
unsigned long time0 = 0;
unsigned long time1;
unsigned long revolutionTime;

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

void loop() {
  circumference = (pi * 26); //26 = the diameter of the wheel
  int reedState = digitalRead(reed);
  if (reedState == HIGH) {
    time1 = millis();
    revolutionTime = (time1 - time0);
    time0 = time1;
    int mph = ((circumference / revolutionTime) * (3600000 / 63360)); //this is the conversion from inches/millisecond to miles/hour.
    Serial.println(mph);
    //And I'd print the result on the 7 segment displays here
  }
}

This code results in around 25 printed entries in the serial monitor from a single activation of the reed switch, all of which consist of randomly alternating values of either 0 or 4571.

Following each step of the code, I assume that the program would generate a garbage result for the first entry (because the time before the reed is activated for the first time could vary greatly), but that following entries would be the correct mph displayed on the 7 segment displays until the reed switch is activated again and a new mph is calculated.

So how would I go about modifying the code to get useful data?


texts: Wake Arduino (Atmega328) from sleep with ADXL345 interrupt

texts:
So I'm relatively new to microcontrollers, and I'm having a problem implementing a feature I want for a project.

I've learned about putting an Atmega328P to sleep from this tutorial. I'm using an Arduino Nano, so I only get my current down to ~9mA rather than the µAs the tutor is getting. Nonetheless, it demonstrates the abstraction I want to learn for when I move to just the Atmega328 with no board.

I've learned to wake up my microcontroller from sleep with a falling external interrupt on INT0/D2 from a simple button. My ISR is empty and just boots me back to the loop, which is fine. As an aside, I have heard that it is better to have simple and short ISR's, but I am not completely sure why.

My question is, can I use my ADXL345 to trigger an interrupt that wakes my Arduino? I am semi-familiar with using an ADXL345 over I2C, although I don't understand why my Sparkfun ADXL345 requires different wiring than my unbranded one, but that's for a separate question I suppose.

So my question is, is it possible, and if so, how? Also, is the I2C connection meaningful for an ADXL345 that is primarily being used as a wake-up interrupt on the Z-axis only? (My use case is an item someone picks up, which wakes my embedded circuit out of sleep and begins logging load cell and UWB sensor data, and is put back to sleep after a period of inactivity).

Thanks in advance - I appreciate any and all help!


texts:
I am trying to send sensor values to internet via enc28j60 module and web client example.

My problem is that i chose byte and float form for some sensors i can't convert these values to char form.

Code example below

UVSensorValue = analogRead(A0);               // UVSensorValue is in byte form
concentration = 1.1*pow(duration,3)-3.8*p...  // concentration is in float form

I want to store them in a char variable like this:

  param = "uv=5&temp=23.2&dust=0.62..."

And send them here:

ether.browseUrl(PSTR("/measures?"), param, website, browseUrlCallback);

I tried strcpy function or String convention but nothing worked. I know its a silly question however i stuck and cant find solution.

If someone could help me i would be pleased. Thanks in advance!


texts: 433MHz transmitter and receiver pair doesnt work

texts:
I have a pair of 433 MHz transmitter and receiver:

Transmitter is connected to Arduino pro mini, receiver to Arduino Uno R3.

Output of receiver on serial looks like that (it doesn't change much):

Basicly I am getting either 75x or zero regardless of transmitter is on or off.

in > upper
756
in > upper
758
0
0
 0
in > upper
758
0
in > upper
757
in > upper

Transmitter code:

#define rfTransmitPin 4
#define ledPin 6

void setup()
{
    pinMode(rfTransmitPin, OUTPUT);
    pinMode(ledPin, OUTPUT);
}

void loop()
{
    for(;;)
    {
         digitalWrite(rfTransmitPin, HIGH);     //Transmit a HIGH signal
         analogWrite(ledPin, 255);              //Turn the LED on
         delay(500);                            //Wait for 1 second

         digitalWrite(rfTransmitPin,LOW);       //Transmit a LOW signal
         analogWrite(ledPin, 0);                //Turn the LED off
         delay(500);                            //Variable delay
    }
}

Receiver code:

const unsigned int upperThreshold = 70;  //upper threshold value
const unsigned int lowerThreshold = 0;  //lower threshold value
const int ledPin = 13;

#define ReceiverPin  A0

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

    pinMode(ledPin, OUTPUT);

    DiodeTest();
}

void loop()
{
   int data = analogRead(ReceiverPin);
   delay(50);

   if(data>upperThreshold)
   {
       digitalWrite(ledPin, LOW);   //If a LOW signal is received, turn LED OFF
       Serial.println("in > upper");
   }

   if(data<lowerThreshold)
   {
       digitalWrite(ledPin, HIGH);   //If a HIGH signal is received, turn LED ON
       Serial.println("in < lower" );
   }

   Serial.println(data);
}


texts: Yun did not connect to WiFi after configuration and restart

texts:
When examined we find that Yun is still in master mode and 0% signal.

Any procedure known to solve this problem manually?

We can access Linux command under Mater mode AP-mode and print WiFi status

/usr/bin/pretty-wifi-info.lua

We know procedure to change REST API access

Method II:  config file

opkg update
opkg install nano
nano /etc/config/arduino

config arduino
        option password '775e9f944188a7bcb36e9ca5dc51672b44bcceeb7d56d89dfb914e$
        option wifi_reset_step 'clear'
        option secure_rest_api 'true'
...

Merhod 1:  UCI API    need access to the Linux system by YSM program

PASSWORD

uci set arduino.@arduino[0].secure_rest_api=true

OPEN:

uci commit arduino

Is there any procedure manually to perform the configuration by hand for the mode:

change to client?
then restart?
from master mode where we have access to Linux command line?

This question has been left unanswered before in all forums examined.
Maybe someone knows the answer.

The problem lies in the Linux not in the hardware or routers or PC, as proven by testing.


texts:
I’m considering using wifiManager mostly to have the ability not to hard code WiFi creditntials.
But In my current code I use WiFi’s functions as WiFi.setAutoReconnect(true) and WiFi.status() != WL_CONNECTED

How can it be done using WifiManager?


texts: Problems with using example code for Wi-Fi shield (arduino)

texts:
I have problems with the Wi-Fi shield example code.

#include <SPI.h>
#include <WiFi.h>

char ssid[] = "*****";          //  your network SSID (name)
char pass[] = "*****";   // your network password

int status = WL_IDLE_STATUS;
char servername[]="google.com";  // remote server we will connect to

WiFiClient client;

void setup() {
    Serial.begin(9600);
    //disable SD SPI
    pinMode(4, OUTPUT);
    digitalWrite(4, HIGH);

    Serial.println("Attempting to connect to WPA network...");
    Serial.print("SSID: ");
    Serial.println(ssid);

    status = WiFi.begin(ssid, pass);
    if ( status != WL_CONNECTED) {
        Serial.println("Couldn't get a wifi connection");
        // don't do anything else:
        while(true);
        }
     else {
     Serial.println("Connected to wifi");
     Serial.println("\nStarting connection...");
     // if you get a connection, report back via serial:
     if (client.connect(servername, 80)) {
         Serial.println("connected");
         // Make a HTTP request:
         client.println("GET /search?q=arduino HTTP/1.0");
         client.println();
      }
    }
}

 void loop() {

}

The Wi-Fi Shield has connected with the internet Wi-Fi, but the last printing was "Starting connection..." I can't get to connect to (google.com), why?


texts:
I've attached my LCD Display (AV1624YRB-SJ) to my Arduino Nano on the following pins:

#define LCD_RS 7
#define LCD_ENABLE 8
#define LCD_D4 9
#define LCD_D5 10
#define LCD_D6 11
#define LCD_D7 12
#define LCD_CONTRAST 6 //PWM Wave with capacitor for contrast

and im initializing it this way:

LiquidCrystal lcd(LCD_RS, LCD_ENABLE, LCD_D4, LCD_D5, LCD_D6, LCD_D7);

byte arrow[8] = {
    B00000, B00100, B00010, B11111, B00010, B00100, B00000,
};

void setup() {
  pinMode(LCD_CONTRAST, OUTPUT);
  pinMode(LCD_D4, OUTPUT);
  pinMode(LCD_D5, OUTPUT);
  pinMode(LCD_D6, OUTPUT);
  pinMode(LCD_D7, OUTPUT);
  analogWrite(LCD_CONTRAST, STARTCONTRAST); // Set LCD Contrast

  lcd.begin(16, 2);
  lcd.createChar(CHAR_ARROW, arrow);
  lcd.setCursor(3, 0);
  lcd.print("Welcome To");
  lcd.setCursor(1, 1);
  lcd.print("My Test");
  delay(2000);
}

The Problem is, that there is nothing to see on the display.
If i crank up the contrast slightly you can see something like a rolling shutter effect.

http://i.imgur.com/FOIEwVj.gif

The display worked just fine 3 days ago.
Where could be a mistake. I don't remember changing something, but i tried rewiring.


texts:
I have bought a MQ135 gas sensor. I have read online from multiple sources that a calibration/warm-up period of between 12-24hrs is required for the sensor to give its most accurate readings. I currently have it attached to one of my UNO's just spitting out Analog readings to the Serial monitor and seems (just after an hour!) to have settled at a reading of 50 which it has stayed at now for a period of around 20 minutes. My questions surrounding this process really are:

What is the point in doing this process if when a project that uses this sensor is powered off for some number of hours? Will you have to let it warm-up/calibrate again before having faith in the readings?
How do I actually identify PPM for a gas such as C02? Is there some form of constant that I should be comparing the reading obtained to or something similar?


texts: HC-08 Bluetooth module not showing up on iPad

texts: I have an HC-08 Bluetooth module Bluetooth module hooked up to an Arduino Uno but for some reason, it doesn’t show up in the Bluetooth menu in my iPad settings. Can you help?


texts:
Can I connect an Arduino Uno Wifi to Arduino Cloud? If yes, how? If no, what cloud is compatible?

I have tried to look online but I could not find anything that raises this question.


texts: I am bit of a noob when it comes to ESP programming. I have an ESP01 and a USB programmer for it, but every time I unplug it, it resets, which makes me wonder how can I make it battery-powered since every reboot resets the program.


texts:
I have a small project and I have some problems while working on that. The idea of the project is as below:
I have an LED which is operated by two "buttons". The buttons takes two values (1 or0) which I have to send from serial monitor.
One button is for LDR sensor, which lights up the LED when its value is below 300 (in my code). The other button turns it off (Value 0). The buttons are working together, so I have to consider both of them in my statements. The problem is that I cannot play with the serial monitor it's just looping continuously and I cant type anything as input.

Can anyone help me with this to find a solution to be able to input values for both buttons?

Here is the code:

const int analogInPin = A0; //LDR PIN
const int digitalOutPin = 13; // LED PIN
int outputValue;

int sensorValue = 0; //

char Buton1; //LDR button
char Buton2; //Blutooth button

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

void loop()
{
  while (Serial.available())
  {
    Serial.println("Button1 value: ");
    Buton1 = Serial.read();
    if (Buton1 == '1')
    {
      Buton2 = Serial.read();
      Serial.println("Button2 value: ");
      if (Buton1 == '1' and Buton2 == '0')
      {
        sensorValue = analogRead(analogInPin);
        outputValue = map(sensorValue, 0, 1023, 0, 255);
        Serial.print ("Sensor: ");
        Serial.println(sensorValue);
        if (sensorValue < 300);
        {
          digitalWrite(digitalOutPin, 255);
        }
      }
      else if (Buton1 == '1' and Buton2 == '1')
      {
        digitalWrite(digitalOutPin, 255);
        Serial.print("Both buttons are ON ! !");
      }
    }
    else if (Buton1 == '0')
    {
      Serial.println("Button2 value: ");
      Buton2 = Serial.read();
    }
    if (Buton1 == '0' and Buton2 == '1')
    {
      digitalWrite(digitalOutPin, 255);
    }
    else if (Buton1 == '0' and Buton2 == '0')
    {
      Serial.println("Both buttons are inactive ! Please reset");
      break;
    }
  }
}


texts: Output from LM35 temperature sensor varies wildly

texts:
I've seen other posts on this board which related to output from the LM35 sensor, but mine seem to be more 'extreme' than anything else I've seen.
I've connected the pins as is commonly suggested - left hand to 5v, middle A0, and right to GRN and used the folowing code
const int sensorPin = A0;

float sensorValue;
float voltageOut;

float temperatureC;
float temperatureF;

void setup() {

pinMode(sensorPin, INPUT);
Serial.begin(9600);

}

void loop() {

  sensorValue = analogRead(sensorPin);
  voltageOut = (sensorValue * 5000) / 1024;
  temperatureC = voltageOut / 10;

  Serial.print(sensorValue);
  Serial.print("\n");
  //Serial.print(temperatureC);
  //Serial.print("\n");

  delay(10000);
}

I commented out the temperature printing lines to avoid the error being in the conversion.
Leaving it run for a while I get the following
756.00
0.00
27.00
7.00
16.00
64.00
0.00
0.00
0.00
6.00
82.00
20.00
10.00
3.00
38.00
0.00
73.00
0.00
78.00
68.00
0.00
80.00
0.00
2.00
29.00
48.00
10.00
0.00
23.00
64.00
27.00
0.00
79.00
0.00
0.00
56.00
60.00
9.00
0.00
15.00
82.00
2.00
2.00
40.00
76.00
18.00
43.00
17.00
74.00
49.00
21.00
14.00
0.00
74.00
0.00
3.00
81.00
3.00
55.00
20.00
0.00
41.00
72.00
40.00
0.00
54.00
27.00

Our house is fairly stable in temperature, and the sensor is in a location out of anything which could drastically alter the temperature.
If anybody can suggest a reason for this I'd be grateful.


texts: Measuring lenght of time light levels peak using photoresistor

texts:
I'm trying to measure shutter speeds on old cameras. This essentially consists of:

Shining a torch at one end of the camera
putting the photoresistor at the other end
trigger the shutter which temporarily lets in the light from the torch (boosting the photoresistor values temporarily)
Recording the duration of the increased spike in light levels

What I have currently records light levels but the variation is massive and typically incorrect in that they change depending on how close the torch is to the shutter and typically records values between 400 and 900 ms which is far too long (should be about 50ms).

This is the key code I have so far:

if (shutterbot.opened())
{
    /* Measure length of time it is opened until closure */
    unsigned long previousMillis = millis();

    while(true)
    {
        unsigned long currentMillis = millis();
        unsigned long time_elapsed = currentMillis - previousMillis;

        if (shutterbot.closed())
        {
            finished = true;
            /* Report back to user */
            Serial.println("Shutter speed is: ");
            Serial.println(time_elapsed);
            break;
        }
    }

}

The open and close methods in the shutterbot class are:

/* If light is 10% higher, set it to start recording */
int Shutterbot::opened()
{
    if (light_level() > 400)
    {
    return true;
    }
    else
    {
    return false;
    }
}

/*
  If light drops to below 10% higher, set it to stop
  recording
 */
 int Shutterbot::closed()
 {
     if (light_level() < 400)
     {
     return true;
     }
     else
     {
     return false;
     }
}

The full project code is here and just needs a photoresistor module and an arduino uno to test. I'm not sure I've provided enough information so if there are any questions, please let me know. Any help is greatly appreciated and thanks for reading.


texts: How to turn servo to a specific location and then turn over

texts:
I work on my first arduino car project and i want to turn my servo to a position with a letter input

This is my code so far

 #include <Servo.h>
Servo servo;

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

 void loop() {

 if(Serial.available()>0){
 int  caz=Serial.read();
 switch(caz)
{
  case 'w':
      digitalWrite(8,LOW);
      digitalWrite(7,HIGH);
      break;
  case 's':
      digitalWrite(7,LOW);
      digitalWrite(8,HIGH);
      break;
  case'd':
       servo.attach(12);
       servo.write(0);
       break;
  case'a':
       servo.attach(11);
       servo.write(180);
       break;
   default:
       digitalWrite(7,LOW);
       digitalWrite(8,LOW);
       servo.attach(0);
  }
}

when i input 'a' or 'd' it starts turning until i input something else and i want it to stop after 10-30 degree .

And also i would like to do that to my motor , moving a bit when i input the key.


texts: HUZZAH ESP-8266 (by ADAFRUIT): How to use with the ARDUINO R3

texts:
I have recently purchased a ESP-8266 HUZZAH by adafruit. I'm kind of new to the whole arduino concept. I would like to know how I would be able to utilise this breakout board with my Arduino to do anything. I have searched on the internet and I know about flashing the board. However, I have no idea how to flash this device. Some help would be appreciated.

I also have no idea where to put my pins. I know that there are RX and TX pins on the UNO, but those are at 0 and 1. Most online guides are using something like 11/12 or 2/3.

Here is the link to the product website

Thanks,
Vraj


texts: LiPo + charge/boost circuit vs pre-built "power bank" - contrasting portable power sources

texts:
Portable 5V power for my projects - I was about to get the necessary parts to wire up an OEM LiPo battery (3.7V battery, boost circuit, charging circuit) when I took a peak at pre-built "power banks".  From all the sources I see the LiPo batteries alone cost more than the power bank, at much lower capacity.  For reference:

a 10400 mAh power pack (max output 3A @ 5V) is 26$ on Amazon
a 10000 mAh power pack (max output 2.1A @ 5V) is 9$ on Hobby King
a 2500 mAh LiPo is 17$ on Amazon
a 5000 mAh Lipo is 8$ on Hobby King

The power packs already have charging and voltage regulation circuitry! The price difference makes me think I am missing something.

Reading around I notice issues with power packs auto-shutdown at low current draws. But other than this power packs seem cost optimal and technically equivalent - at least within the output amperage range of the power banks.

Questions:

Are there any technical differences in output voltage, lifetime, or otherwise I am missing here?
Are there any "surprises" I'm going to face by using a power pack?
Can you recommend a solid power pack that doesn't shut down at arduino level draws. (My app will draw 800mA @ 5V max, but during sleep, the draw of an Arduino Nano)

Thanks!


texts: Arduino Mega prototype analog timer interrupts: newbie question

texts:
I am currently using an Arduino Mega with a fast vibration sensor to trigger the components operation (force sensor, temperature sensor) and also toggle sleep mode.

I am very new at this and I have been doing some googling, but I just can't seem to understand it.

So, my questions are:

How would I toggle(on/off) sleep mode?
How would I use interrupts (timer, pin change interrupt?) for an analog pin that triggers when the vibration sensor is triggered, resulting in other components operating?

I am currently working on a Mega, but I will eventually move on to the Arduino Mini Pro. I hope there are no exclusive problems later on.

I realize that this is not a professional question, but I find these tasks very challenging.

Please help me. An example link or perhaps example code to help me understand better.

Thank you very much.


texts:
I'm developing a sketch which I need to run on an Uno (for debug) and a Gemma (as the target).  Adafruit has their own Wire library (TinyWireM) which I was planning on using on the Gemma.  Thus, I was trying to use #if's to automatically include the correct library for the given target board.  However, it appears that the TinyWireM include files is always included even if the AVR_ATtiny85  macro symbol is undefined (I get many undefined symbols reported inside the Arduino\libraries\TinyWireM-master\USI_TWI_Master.cpp file).  If I comment out the TinyWireM.h include statement (inside the #if define statement), then it compiles fine.  Code example below.

So why isn't this include statement being skipped?  I'm at a loss.  Anyone have any thoughts?

Thx all.

Mike

#undef __AVR_ATtiny85__        // Debug only - making sure not defined.

#if defined (__AVR_ATtiny85__)
  #include <TinyWireM.h>    // Seems this file is still being included and
                          // must comment out this line when compiling
                          // code for an UNO.  This should not be necessary
                          // given __AVR_ATtiny85__ is not defined.
#else
  #include <Wire.h>         // This is the Wire library for the Uno.
#endif

void setup() { }

void loop() { }


texts:
I am currently doing research for a project of mine. My goal is simple: I want to pass input from a physical mouse, to a microcomputer to process the input and modify, and send the input in the form of USB HID to a PC.

  Mouse ---> Microcomputer (input modified) ---> PC

The Microcomputer preferably should be able to both send data to the PC (in the form of USB HID inputs as a mouse) and receive data from the PC.

I found the arduino Leonardo can act as a USB slave and emulate mouse movement, half of what I want. I need some microcomputer with capabilities to act both as a USB host and as a USB slave. I don't have experience with microcomputers, and I don't know how to find something with this feature.


texts: Move a servo slowly between 2 positions based on input

texts:
I am trying to move model railroad crossing gates from a vertical position to a horizontal position when a train is detected. I have the electronics in for the sensing of train position but want the gates to go down and stay down while the train passed.

To do this, I am looking to be able to use an Arduino to slowly move a servo between two different positions based on a digital input (HIGH or LOW) to one of the digital input pins.

When this digital input goes HIGH, the servo needs to slowly move to the other end of travel and then stop. It must stay there until the digital input goes LOW, at which time it needs to slowly move back to the starting position and again await for a HIGH input.

I cannot figure out how to move the servo slowly to each position and keep it there.


texts: Run HEX program from SD with another program

texts: I want to write a program in which I can select a HEX file recorded on a SD card (via a LED screen, etc.) and run it, i.e. transfer control to it, like launching programs on a PC. Is this possible and if so, how? I only found ways to directly run a sketch from an SD card without that "program"


texts: My ESP8266-01 doesn't want to respond to AT command after a successful flash!

texts:
Well hello, experts,
I've been trying to fix my issue all time, but all in vain.
I have an Esp8266-01 with 1MB memory. I've flashed it with an official AT firmware V2.0.0 of espressif with the help of this tutorial-arduino as a usb/TTL-: "https://www.allaboutcircuits.com/projects/flashing-the-ESP-01-firmware-to-SDK-v2.0.0-is-easier-now/", and it was a successful flash.
However, when trying to send AT commands in the serial monitor at different baud rates nothing happens.
I'll provide you with all the information down here:

Schematic for both flash and normal mode:

I used the official flasher tool from espressif
I used both Arduino IDE and Termite with no results
I've uploaded the blink sketch successfully into my module, but it never runs and blinks.
After lots of tries and resets I started to receive some information:

But still no answers from this module!!!
Could you help me, please?


texts: How do I write my code to reverse the motors in the opposite direction so the RSLK can move backwards?

texts:
I've assembled the TI RSLK Robot Maze Edition for a final project for my embedded systems class. Instead of using the MSP432P401R LaunchPad that came with the kit to control the power board, I've used an Arduino MEGA 2560 instead. I'm also using a KY-023 Analog Joystick to control the two dc motors.

int xPin = A0; // analog input for x-axis joystick
int yPin = A1; // analog input for y-axis joystick

int yPosition = 0;
int xPosition = 0;

//Right motor pins
#define MRSpeed 11
#define MRDir 10
#define MRSleep 9

//Left motor pins
#define MLSpeed 8
#define MLDir 7
#define MLSleep 6

void setup() {
 Serial.begin(9600);
 pinMode(xPin, INPUT); // setup x input
 pinMode(yPin, INPUT); // setup y input

 pinMode(MRSpeed, OUTPUT);
 pinMode(MRDir, OUTPUT);
 pinMode(MRSleep, OUTPUT);
 digitalWrite(MRSleep, 1);

 pinMode(MLSpeed, OUTPUT);
 pinMode(MLDir, OUTPUT);
 pinMode(MLSleep, OUTPUT);
 digitalWrite(MLSleep, 1);

 }

 void loop() {

  yPosition = analogRead(yPin);
  xPosition = analogRead(xPin);

  //Steer Forward
  if (yPosition > 1020)
  {
    analogWrite(MRSpeed, 255); //To move right wheel forward
    analogWrite(MLSpeed, 255); //To move left wheel forward
  }

   //To stop both wheels
    else if (yPosition = 506 || 505)
    {
      analogWrite(MRSpeed, 0);
      analogWrite(MLSpeed,0);
    }

     //Turn Right
      if(xPosition < 512)
      {
       analogWrite(MRSpeed, 0);
       analogWrite(MLSpeed, 255);
      }

     //Turn Left
       if(xPosition > 1020)
       {
         analogWrite(MRSpeed, 255);
         analogWrite(MLSpeed, 0);
       }

       }


texts: Arduino Uno still boots and runs but no serial communication over USB

texts:
After having the Arduino Uno running for a short period of time, it seems to no longer communicate over the USB port when connected to the computer. It still seems to turn on and run the program uploaded. However, it no longer receives or outputs any data and any attempts to re-upload code are met with timeout errors in the Arduino IDE. The TX/RX lights do not blink at all, but the "L" light always flashes right after the Arduino is plugged in.

I have the Arduino/Genuino Uno board selected in the Arduino IDE.

This is a legitimate board that I bought directly from Arduino.

Loopback test fails.

Nothing is connected to any of the pins on the Arduino whatsoever.

I have an Arduino Nano that communicates fine with my Windows 10 PC so that rules out the drivers and the PC itself.

My computer still recognizes the USB device as an Arduino Uno and assigns it to COM5.

Leaving it plugged in for a solid 15 minutes shows no chips on the board getting hot to the touch.

I have tried resetting the board before, during, and after attempting to upload code, no dice.

Are there other steps that I can take to try to fix the board, or am I going to have to accept that I fried the ATMEL16 chip on my Uno?


texts: Is my MQ-2 gas sensor analog or digital?

texts:
I have this MQ-2 gas sensor for an Arduino Uno:

I found these two articles about how to use it:

https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a
http://www.instructables.com/id/Ardunio-Smoke-And-Gas-SensorMQ-2/?ALLSTEPS

But I need to know if the sensor is analog or digital.
Also I would like to know what is the blue switch for.

This questions help me a bit:

It says that he use an analog sensor. But as this sensor is not mine I don't want to brake it or burn it.


texts:
I recently bought a brand new Arduino pro micro from Amazon, I set it up according to the instructions on sparkfun, except that when I plug it in, Windows doesn't even show that it tried to install device driver software. I figured it might just be a windows 10 thing because the tutorial was written on windows 7, so I forged ahead, and updated the device driver for COM3 in device manager, and attempted to upload a simple test for HID emulation:

#include <Keyboard.h>

void setup() {
  Keyboard.write('z');
}

void loop() {
  Keyboard.write('a');
  delay(5000);
}

It compiled just fine, and the IDE said it started uploading to the device, However, as it was uploading (or so I thought) I read a little farther and realized that the IDE wasn't set to use the right voltage (3.3V instead of 5V) I closed the IDE and reopened my sketch, changed the voltage to match up, and tried uploading it again. Here, it got stuck on the Uploading... text and so again, I closed the IDE.

Only the LED closest to the USB port is on, and it's solid green. I've connected to my computer using a Micro USB to USB adapter, and I initially plugged the board into a USB 3.0, but then switched to 2.0 to see if it made a difference. I have also tried it on Ubuntu 14.04 with no luck. I don't think it's bricked because if it was, my computer would still recognize it, but not know what it was (according to sparkfun), and as a result, I have yet to try the debricking method they suggest. Any thoughts?


texts: Serial.parseInt value always goes back to 0

texts:
I am trying to read a value between 1000 and 2000 from my Serial Monitor and use it to drive some motors through ESC.

The code works when I use a potentiometer mapped for 1000-2000. I am now trying to use a Serial Monitor, but the "val" keeps going from the value I enter (between 1000 and 2000) and quickly returns to 0.

Why is this?

Here is the code for reference:

#include <Servo.h>//Using servo library to control ESC
Servo esc1; //Creating a servo class with name as esc1
Servo esc2; //Creating a servo class with name as esc2
Servo esc3; //Creating a servo class with name as esc3
Servo esc4; //Creating a servo class with name as esc4
void setup()
{
  esc1.attach(7); //Specify the esc signal pin,Here as D10
  esc2.attach(6); //Specify the esc signal pin,Here as D9
  esc3.attach(5); //Specify the esc signal pin,Here as D8
  esc4.attach(4); //Specify the esc signal pin,Here as D7
  esc1.writeMicroseconds(1000); //initialize the signal to 1000
  esc2.writeMicroseconds(1000); //initialize the signal to 1000
  esc3.writeMicroseconds(1000); //initialize the signal to 1000
  esc4.writeMicroseconds(1000); //initialize the signal to 1000
  Serial.begin(9600);
}
void loop()
{
  int val; //Creating a variable val
  Serial.println("Input ESC Speed between 1000 and 2000:");
  while (Serial.available() > 0) {
    val = Serial.parseInt();
    Serial.println(val);
  }//Checks for a character in the serial monitor
  Serial.println(val);
  esc1.writeMicroseconds(val); //using val as the signal to esc
  esc2.writeMicroseconds(val); //using val as the signal to esc
  esc3.writeMicroseconds(val); //using val as the signal to esc
  esc4.writeMicroseconds(val); //using val as the signal to esc
}