texts:
I've a working hardware setup and two codes 1 to read the sht30 and push the data to my tft screen.

And 2 a code to set a fan (2fans) on and off.

I want to combine these whenever the humidity is over 50% the fans should go on.

3 issues arise.

less important my serial.println() doesn't print anything anymore
my second if loop doesn't get printed not in serial or in display
Fans are not getting activated by the code.

My searching leads me to think I need to convert my sht30.humidity into an int before making the if loop.

Or it could be something entirely else ofcourse.

#include <WEMOS_SHT3X.h>

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

Adafruit_SSD1306 display(1);
#if (SSD1306_LCDHEIGHT != 32)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

SHT3X sht30(0x45);

void setup() {
  Serial.begin(115200);
  pinMode(14, OUTPUT);
  // initialize with the I2C addr 0x3C
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.display();
  delay(1000);
  Serial.print("start");
  // Clear the buffer.
  display.clearDisplay();
}

void loop() {

 // Clear the buffer.
  display.clearDisplay();
  display.setTextSize(1);
  display.setCursor(0, 0);
  display.setTextColor(WHITE);

  if(sht30.get()==0)
  {
    display.setCursor(35, 10);
    display.println("T: ");
    display.setCursor(50, 10);
    display.println(sht30.cTemp);
    display.setCursor(35, 20);
    display.println("H: ");
    display.setCursor(50, 20);
    display.println(sht30.humidity);
  }
  else
  {
    display.setCursor(35, 10);
    display.println("Error!");
    Serial.println("error");
  }
  display.display();
  delay(1000);

  Hcheck();
  Serial.println("checking humidity");

}

void Hcheck() {
  delay(5000);
  Serial.println("============ Check Humidity ===============");
  display.clearDisplay();
  display.setCursor(35, 10);
  display.println(sht30.humidity);
  display.display();
  delay(1000);
  Serial.println(sht30.humidity);

  if(sht30.humidity <= 50 ) {
    digitalWrite(14, HIGH);
    display.clearDisplay();
    display.setCursor(35, 20);
    display.display();
    delay(500);
  }else {
    digitalWrite(14, LOW);
    delay(500);
    Serial.println("Air is dry");

  }

  }


texts:
I would like to know what device and model to use for an application where I will have 1 arduino as a master micro controller waiting to receive data from 5 slave arduino microcontrollers.
The Master arduino will be connected to local network via Ethernet cable so once it receive data from a Slave controller it needs to post to server the information, get a response back and in case the response is a "true" value then the Master need to talk back to the Slave in order to turn a LED on.
There will be cases when maybe 3 of the Slaves will send data at the same time, this doesn't mean at exactly the same millisecond. So I don't know if there will be data lost.
I was reading that Xbee maybe is the best device because it has a feature that will hold the data until there is a success communication with slave.

Is this a doable and "easy" task using Xbee? Anyone that already try to do something like this that can guide me?

I was reading that there is a device nRF24l01 that is very cheap and can do exactly what I need. Just that I don't really know how to start.

Appreciate any advice or help.


texts:
I have a Raspberry Pi 3 connected to the serial of my Arduino Uno (pins 0 and 1), but I also have another device connected to two other serial pins on the Arduino (pins 10 and 11, using the SoftwareSerial library).

What I want to do is send a string from the RPI, then the Arduino gets it and resends that information through the other serial port to my device.

Until now the Arduino can receive the information from the RPI, but I'm not sure how to send that same string through the other serial port, the one going to the device.

Here is the code I'm using:

#include <SoftwareSerial.h>

String b = "0";
SoftwareSerial portOne(2, 3); //RX= pin 2  TX= pin 3

void setup() {
  Serial.begin(9600, SERIAL_8N1);
  portOne.begin(9600);
}

void loop() {
  if (Serial.available() > 0) {
    b = Serial.readString();
    Serial.println("Data from RPI:");
  }
  portOne.listen();
  while(portOne.available() > 0){
      Serial.println("Data from port one:");
      Serial.println(b);
    }
  }

I just get the data coming from the RPI, but nothing from portOne.

Any thoughts?


texts: Sampling/transmission limits for USB and Arduino UNO R3

texts:
I'm very new at this and I need some help. This is a college project that I must do and not even the professor knows for certain if it is possible.

I have to sample two signals at a fixed sampling rate so there is no aliasing effect and it must be done at the same time (switching the ADC from one analog input to another)..

The signal would be then transmitted via USB to my computer. I guess that the transmission rate would be too slow to do this in real time. I will have to store this somewhere in the Arduino board so it can be transmitted afterwards.

Requirements:

It could be done with 8 bit resolution.
Sampling rate of at least 4.8kHz.
Record both signals for at least 0.1 second.

Is this even possible to do with my Arduino UNO R3? If it isn't, it would be with a sampling rate of 1.2kHz?

PS: I could try to lower the sampling frequency necessary by changing the aliasing filter that I built. The theoretical limit would be at about 1.2kHz for the best filter possible.


texts:
I am trying to control my WS2812B with a remote control. To archive this, I am using IRRemote library. The problem is that this two libraries doesn't work together.

I did some research and found out that it is a problem with timers.But, inside the IRRemote library file (boarddefs.h) there is a possibility to choose different timer (It uses TIMER2 as default, so I supposed that FastLed uses also Timer2).

So when I change the timer in boarddefs.h file to TIMER1, it is also now working fine for me. I keep recieving random IR codes. When I stop using FastLed library, I recive correct codes.

Some workaround to this problem is to read IR signal only once irrecv is idle:

  while (!irrecv.isIdle());  // if not idle, wait till complete
  if (irrecv.decode(&results)) {
     ...
  }

It makes around 80% of readings correct.

I am using arduino NANO clone. My question is, if there is any way to use IRRemote and FastLed libraries together other than using two arduino NANO (use one to read IR and other to control LEDs)?


texts: Using pushbutton to make Stepper motor rotate 90 degrees

texts:
Using a 28BYJ-48 Motor with a ULN2000 Driver. The motor works fine since I can rotate it using serial input.
Pushbutton is connected properly, Can light up an led if I connect one.
I want the motor to rotate 90 degrees everytime I push the button. When I run the code below the LEDs on the driver just blink rapidly, when I press and hold the button they stop blinking, keeping the state they were on already. e.g. if the LED A on the board was on at the moment I press the button, It stays on. If it was off, It stays off. you get the Idea.

code used:

#include <Stepper.h>;

 // pushbutton pin
 const int buttonPin = 2;

 int STEPS = 32;
 Stepper stepper(STEPS,8,9,10,11);

//create a variable to store a counter and set it to 0
int counter = 0;
void setup()
{
  pinMode(buttonPin, INPUT);
}

void loop()
{
 // local variable to hold the pushbutton states
  int buttonState;

  //read the digital state of buttonPin with digitalRead() function and store the           //value in buttonState variable
  buttonState = digitalRead(buttonPin);

  //if the button is pressed increment counter and wait a tiny bit to give us some          //time to release the button
  if (buttonState == LOW) // light the LED
  {
    counter++;
    delay(150);
  }

  if(counter == 1)
    stepper.step(512);  // zero degrees
  //else reset the counter to 0 which resets thr servo to 0 degrees
  else
   counter = 0;
}

EDIT 1: Modifying the code @Matej gave me, I was able to debug the problem that was causing the stepper to not rotate. the code:

#include <Stepper.h>

// pushbutton pin
const int buttonPin = 2;

const int STEPS = 32;
Stepper stepper(STEPS, 8, 9, 10, 11);
int val = 2048;

//create a variable to store a counter and set it to 0
int counter = 0;

unsigned long last_button_time = 0;   //for aving last millis

void setup(){
  pinMode(buttonPin, INPUT);
  Serial.begin(9600);
  stepper.setSpeed(1000);
}

void loop(){
  bool buttonState;   // local variable to hold the pushbutton states

  //read the digital state of buttonPin with digitalRead() function and store the           //value in buttonState variable
  buttonState = digitalRead(buttonPin);
  //if the button is pressed incremen counter and wait a tiny bit to give us some          //time to release the button
  if(buttonState == HIGH && millis() - last_button_time > 200){ // light the LED
    last_button_time = millis();
    counter = 1;
    Serial.println(counter);
  }

  if (counter == 1) {
    Serial.println("Please Write the desired angle");
    val = Serial.parseInt();
    delay(5000);
    counter = 0;
    if(Serial.available() > 0) {
    Serial.println("Stepping: ");
    Serial.print(val);
    stepper.step(val);
    counter = 0;
    Serial.println(counter);
    }
    else {
      Serial.println("ERROR LOOPING THROUGH IF STATEMENT");
    }
  }

}

The Serial output looks like this:

1
Please Write the desired angle
Stepping:
00
1
Please Write the desired angle
Stepping:
20480
1
Please Write the desired angle
Stepping:
20480

please note that In the first attempt, I wrote "2048" in Serial input to define the value of the integer (val), and nothing happened. in the second and third attempt, I also wrote 2048 (0 at the end is the counter variable) and the motor started shaking, but it didn't rotate.


texts: Sparkfun CCS811 sensor not interfacing with arduino

texts:
I have sparkfun indoor air quality sensor CCS811 which needs to be interfaced with arduino. I have soldered wires on the sensors and connected with arduino. Have checked the connection with multimeter so that part works. But even using example code on library still I am not getting reading from sensor.

Code:-

#include <Wire.h>

#include "SparkFunCCS811.h"

#define CCS811_ADDR 0x5B //Default I2C Address
//#define CCS811_ADDR 0x5A //Alternate I2C Address

CCS811 mySensor(CCS811_ADDR);

void setup()
{
  Serial.begin(9600);
  Serial.println("CCS811 Basic Example");

  Wire.begin(); //Inialize I2C Harware

  //It is recommended to check return status on .begin(), but it is not
  //required.
  CCS811Core::status returnCode = mySensor.begin();
  if (returnCode != CCS811Core::SENSOR_SUCCESS)
  {
    Serial.println(".begin() returned with an error.");
    //while (1); //Hang if there was a problem.
  }
}

void loop()
{
  //Check to see if data is ready with .dataAvailable()
  if (mySensor.dataAvailable())
  {
    //If so, have the sensor read and calculate the results.
    //Get them later
    mySensor.readAlgorithmResults();

    Serial.print("CO2[");
    //Returns calculated CO2 reading
    Serial.print(mySensor.getCO2());
    Serial.print("] tVOC[");
    //Returns calculated TVOC reading
    Serial.print(mySensor.getTVOC());
    Serial.print("] millis[");
    //Simply the time since program start
    Serial.print(millis());
    Serial.print("]");
    Serial.println();
  }

  delay(10); //Don't spam the I2C bus
}

Things I tried:-
1) different combination of  A4, A5 pins
2) 0x5A & 0x5B i2c address
3) using wake pin with ground
4) using 3.3 & 5V for powering sensor

What else needs to be done?


texts:
I will start by asking can the nodemcu and nrf24l01 be setup as a receiver.Im trying to read basic pir sensor data sent from arduino nano and  a nrf24l01 set as transmitter. I want to receive this data on nodemcu and a nrf24l01 set as a receiver. The problem is nodemcu serial monitor and tft display is showing nothing. The nrf's rec/transmitter work perfectly when connected to arduino nanos. My loop code will not cyle on the esp8266 and nrf24l01, which is verified by no data on the tft display and serial monitor showing no received data. If I disconnect either sck, mosi or miso the loop code will cycle but no data is received.

My connections

Nodemcu       NRF24L01
D8 -----------> CE
D3 -----------> CSN
D5 -----------> SCK
D6 -----------> MISO
D7 -----------> MOSI

My connections

 Nano           NRF24L01
Pin  7 ---------> CE
Pin  8 ---------> CSN
Pin 13 ---------> SCK
Pin 12 ---------> MISO
Pin 11 ---------> MOSI

!!!!!!Nodemcu and NRF24 Code!!!!!

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

#define CE D8
#define CSN D3
RF24 myRadio (CE, CSN);

 byte addresses[][6] = {"0","1"};

struct package
{
  int id=0;
  float VALUE = 0.0;
  char  text[100] ="empty";
};
typedef struct package Package;
Package data;

int led = D0;

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

  myRadio.begin();
  myRadio.setChannel(115);
  myRadio.setPALevel(RF24_PA_MAX);
  myRadio.setDataRate( RF24_250KBPS ) ;
  myRadio.openReadingPipe(1, addresses[0]);
  myRadio.startListening();
  delay(1000);
}

void loop()
{

  if ( myRadio.available())
  {
    while (myRadio.available())
    {
    myRadio.read(&data, sizeof(data));
    Serial.print("\nPackage:");             //Serial Monitor Text
    Serial.print(data.id);                  //id of data packag
    Serial.print("\n");                     //newline
    Serial.println(data.VALUE);       //text to receiver line 2
    Serial.println(data.text);  //text to receiver line 3

    digitalWrite(led, HIGH);
    delay(500);
    digitalWrite(led, LOW);
    delay(500);
   }

   }
}

!!!!!!Nano and NRF24 Code!!!!!

#include "RF24.h"

RF24 myRadio (7, 8);
byte addresses[][6] = {"0", "1"};

struct package
{
  int id = 1;
  float VALUE ;
  char  text[100] = "Sensor <1> Transfer";   //text to receiver
};
typedef struct package Package;
Package data;

const int pinSensor = 4; // output signal pin of laser module/laser pointer
int PirSensor = 3;

int led = 2;
void setup()
{
  pinMode(pinSensor, INPUT); // set the laser pin to output mode
  pinMode(led, OUTPUT);
  digitalWrite(led, LOW);
  Serial.begin(115200);

  myRadio.begin();
  myRadio.setChannel(115);
  myRadio.setPALevel(RF24_PA_MAX);
  myRadio.setDataRate( RF24_250KBPS ) ;
  myRadio.setCRCLength(RF24_CRC_16); // Set CRC length to 16-bit to ensure quality of data
  myRadio.openWritingPipe( addresses[0]);
  myRadio.stopListening();
  delay(1000);
  }

void loop()
{
 PirSensor = digitalRead(pinSensor); // receiver/detector send either LOW or HIGH
  if (PirSensor == 1){
    data1.VALUE = 1.00;
    Serial.print("Motion ");
    Serial.println(data.VALUE); // send value to console

    myRadio.write(&data, sizeof(data));

  Serial.print("\nPackage:");
  Serial.print(data.id);
  Serial.print("\n");
  Serial.println(data.VALUE);
  Serial.println(data.text);

  digitalWrite(led, HIGH);
  delay(500);
  digitalWrite(led, LOW);
  delay(500);
  }
else{
    data.VALUE = 0.00;
    Serial.print("No Motion");
    Serial.println(data.VALUE); // send value to console

    myRadio.write(&data, sizeof(data));

  Serial.print("\nPackage:");
  Serial.print(data.id);
  Serial.print("\n");
  Serial.println(data.VALUE);
  Serial.println(data.text);

  digitalWrite(led, HIGH);
  delay(500);
  digitalWrite(led, LOW);
  delay(500);
}
}


texts: Problem with Arduuino to breadboard Mega8

texts:
I am trying to make an arduino using mega8 mcu. After so much struggling with sync/response/signature  problems and reading the previous questions, finally managed to do it (almost). However I still have some weird problems.

I uploaded the arduinoISP sketch to an Uno for programming the chips: AtMega8A-PU and AtMega8L-8PI (I had a couple of L version from years ago).

For bootloader selected the Mega8 from NG board in IDE 1.8.5 then uploaded to Mega8A-PU
for the L version cloned the ng part in boards.txt and reduced the F_CPU to 8MHz, (same bootloader code) and uploaded to 8l

Now, I'm able to upload sketches to both using a usb-serial breakout board/ avrisp mkII.

my first problem is when I disconnect the converter board neither of the MCUs can start unless I pull up or pull down the RxD pin (#2) which i find accidentally. it seems they both stuck in bootloader part. even if i leave the reset pin floating (using internal pullup) and tie the rxd pin they work fine up on applying power (with like an annoying 15~16s delay). the resistor value I tried 1K and 10K but no difference in operation and delay time. it wont start with rxd open. I couldn't find why?

another question is running the code on mega 8L as reliable as on 8A? (need it for lower V)

More clarification: they both run with Xtals and 22pf caps on breadboard. the 8l also works fine with 16MHz Xtal at 5v.

sketch (I know it's not much of help):

void setup() {
  Serial.begin(19200);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  tone(10,3520);
}

volatile unsigned int i, var = 1;

void loop() {
  digitalWrite(9, HIGH);
  for(i = 0; i < 1500; i++)
                 var += ((var * 3) / 2);
                 // do something (if compiler not wipe it for optimizing :D )
  digitalWrite(9, LOW);
  Serial.println(millis());
}

sample of 8A and (similarly) uno output:

7 11 15 19 23 27 31 35 39 44 48 52 56 60 64 68 72 76 80 84 89 93 97 101 106 110

8L output @ 3.3v @8MHz:

16 24 32 40 51 59 67 75 86 94 102 110

tone() output is the same for all

Appreciate your help


texts: I've been trying to install esp32 on Arduino IDE for days now but I keep getting 'error downloading package' message. I checked the over and over again, it's correct. I even tried installing it manually using GitGUI but it's not working. Please help me.


texts: Why does a light bulb activate an infrared sensor? Is there a way I can filter this out?

texts:
I've made 3 programs. One is written in python, c++ processing and bash.

Everything seems to be okay but then sometimes I get a signal from the arduino that activates the function to lower down the volume on the python code listening for serial data. This is sometimes random but it seems that I can reproduce the same behavior when I turn the light on. I can cause the same disruption if I wave my hands over it quickly.

How can I filter this? I know that IR is part of the electromagnetic spectrum in which the visible light takes part. The sensor is facing upward for a type of omnidirectional receptor. I've placed a TV IR blackish cover over it but with the same results. Do I need to use the function to hash decode the incoming signal? I suppose that it needs a simple circuit as any other sensor.

I want to discard the possibility of a random activation in my code.

Edit:

Taken into consideration the answers until now I can confirm that this is part of a physical phenomena due to the distance between my light and the device.

As for the solution to my volume problem It seems that I used "0" in the same statement as the ir code I remapped in the python code. It turned out to be part of the IRlib library of the arduino code that returns a "0" when it encounters an unknown signal. (due to protocol specification? - out of useful range? )

The thing is that I can change the if statement value for other than "0" but that won't stop it from returning "0" and that's a disadvantage. The solution that came to me is simply intercepting the signal and use continue to skip this.

Is there any alternative to this?


texts: Not seeing frames returned from client when using ESP8266 Wifi Shield

texts:
I'm trying to make a web server using an Arduino R3 and Sparkfun ESP8266 Wifi Shield. I've built a webpage that has a form I would like to control the Arduino with.

Currently my sketch can successfully send the webpage, but when I use the form, 9 / 10 times I see no output on the serial monitor, and the 1/10 times I see the frame from the client the sketch seems to hang and the client keeps waiting for more data.

I'm using the Sparkfun ESP8266 libraries for the product I bought.

I don't think this is a hardware problem, I've visually inspected the Arduino and ESP pins and they seem ok. I don't think it's a memory problem.

I've put the salient part of the sketch below:

void serverDemo()
{
  // available() is an ESP8266Server function which will
  // return an ESP8266Client object for printing and reading.
  // available() has one parameter -- a timeout value. This
  // is the number of milliseconds the function waits,
  // checking for a connection.
  ESP8266Client client = server.available(1000);
  char clientline[BUFSIZ];
  int index = 0;

  if (client)
  {
    Serial.println(F("Client Connected!"));
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;

    while (client.connected())
    {
      if (client.available())
      {
        char c = client.read();

        if( index < BUFSIZ ) {
          clientline[index++] = c;
        } // end of if

        if (c == '\n' && currentLineIsBlank)
        {
          clientPrintProgmemArray(htmlHeaderTable, htmlHeaderTableSize, client);
          clientPrintProgmemArray(webpageTable, webpageTableSize, client);
          Serial.println(F("Page sent"));
          break;
        } // end of if

        if (c == '\n')
        {
          currentLineIsBlank = true;
        } // end of if

        else if (c != '\r')
        {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        } // end of if
      } // end of if( client.available() )
    } // end of while ( client.connected() )
    delay(10);
    client.stop();
    Serial.println(F("Client disconnected"));
    Serial.print(F("Index: "));
    Serial.println(index);
    Serial.print(F("Clientline: \""));
    for( int i = 0; i <= index; i++)
    {
      Serial.print(clientline[i]);
    }
    Serial.print(F("\"\r\n"));
    if( strstr(clientline, "e=1") != 0) {
      Serial.println("hooray!");
    }
  }
}

The header and webpage the Arduino sends to the client is:

HTTP/1.1 200 OK
Content-Type: text/html
Connection: close
<!DOCTYPE HTML>
<html>
<body>
<form action="/?" method="get">
    <input name="e" type="submit" value="0">
    <input name="e" type="submit" value="1">
</form>
</body>
</html>

The output I get on the serial monitor is:

ESP8266 Shield Present
Mode set to station
Connected to: XXXXX
My IP: 192.168.0.13
Server started! Go to 192.168.0.13

Client Connected!
Page sent
Client disconnected
Index: 2
Clientline: "
 "
Client Connected!
Page sent
Client disconnected
Index: 2
Clientline: "
 "

I'd be very grateful if anybody has any advice on where the problem lies.

Thanks in advance


texts: Smaller and cheaper alternative to Arduino Uno for permanent projects

texts:
I have played a bit around with a Arduino Uno that came in a kit with a breadboard and components. Soon I would like to make some more permanent things.

I would prefer a smaller and cheaper unit than the Arduino Uno but that is almost as easy to use as the Arduino Uno, and very similar to use.

Is the Arduino Pro Mini 328 - 5V/16MHz a logical next step?
At 1/6 of the size of the Arduino Uno it is plenty small.
At 10 $ a piece the price is also good.

I understand that I must solder to get it to work. That should not be a problem.

Will I also need a USB serial board to program the unit?


texts: How to transfer data from arduino to android via bluetooth?

texts:
I am having arduino uno board connected with bluetooth HC-05 module. I needed to transfer the data from arduino to android mobile via bluetooth.

Is it possible to transfer the data from arduino to android via bluetooth?


texts: Digispark Atinny85 not recognized (bootloader problem)

texts:
I recently bought the Attiny85 (picture below)

I managed to install it correctly following the official guides, never that a problem.
Drivers are installed correctly, and I used the Arduino IDE to actually upload a few sketches and tested them in two computers.
SUDDENLY
It has stopped working, based on my research, it seems that the bootloader got damaged....any idea on how to fix this? I thought about burning the bootloader using Arduino, but I barely got an idea on how to begin.
Backside of the Attiny85


texts: Adafruit DHT22 Library + Arduino Due not compiling?

texts:
i recently purchased a DHT22's and tried to get it to work using Adafruit's DHT library on Github.
When i compile it with a Arduino DUE, it gives me the following error:

C:\Users\Moz\Documents\Arduino\libraries\DHT-sensor-library-master\DHT.cpp: In constructor 'DHT::DHT(uint8_t, uint8_t, uint8_t)':
C:\Users\Moz\Documents\Arduino\libraries\DHT-sensor-library-master\DHT.cpp:14:9: error: invalid conversion from 'Pio*' to 'uint8_t {aka unsigned char}' [-fpermissive]
   _port = digitalPinToPort(pin);
         ^
Error compiling.

It compiles on a Arduino Uno but not on the DUE.

What is the reason for this?

Edit: Below is the example code i use

#include "DHT.h"

#define DHTPIN 2     // what pin we're connected to

#define DHTTYPE DHT22   // DHT 22  (AM2302)

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  Serial.println("DHTxx test!");
  dht.begin();
}

void loop() {

  delay(2000);
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  float f = dht.readTemperature(true);

  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  // Compute heat index in Fahrenheit (the default)
  float hif = dht.computeHeatIndex(f, h);
  // Compute heat index in Celsius (isFahreheit = false)
  float hic = dht.computeHeatIndex(t, h, false);

  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.print(" *C ");
  Serial.print(f);
  Serial.print(" *F\t");
  Serial.print("Heat index: ");
  Serial.print(hic);
  Serial.print(" *C ");
  Serial.print(hif);
  Serial.println(" *F");
}


texts:
I have two I2C devices connected to an Arduino Uno: an RTC and an OBD interface (see links below). The SCL/SDA of both devices connect parallel to SCL/SDA (respectively) of the Uno. My problem: when I set the time on the RTC (either using the autoset option, or explicitly) it reports back odd readings, like the date set back by 4 days, the hour set back by 2 hours etc. This happens even with the default bare-bones RTC sample sketch.

I tried two RTCs (one DS1307, and the one linked below): both show the same strange behavior. I tried 2 configurations: 1) NO pull-up resistors on either device, 2) two 10K pull-up resistors on BOTH devices. Both situations produce RTC errors. If I detach the OBD sensor from SCL/SDA, the RTC shows the proper time. If I remove the RTC, the OBD by itself (works fine. Before I spend more time experimenting: any advice how to solve this pull-up resistor situation (if this is what it is)?

Adafruit DS3231 Precision RTC

OBD Freematics interface


texts: How to get weight data from glass electronic bathroom scale sensors?

texts:
I am doing a small project with a bathroom scale but I run into some problems. I am using an Arduino Uno V3, HX711 module amp and a scale.

Scale:

HX711 amplifier:

I disassembled the scale to get to sensor wires and I am a bit confused. These sensors have three wires each. So they are half bridge sensors. The scale is using 4 sensors so when the scale is measuring it is measuring with a full bridge. And these 3 wires are RED, BLACK, BLUE. I don't know what is black (GND or Positive) and blue (same guess). Four red wires are given names E+, E-, S+ and S-. I will provide a picture of the disassembled scale.

Two blue wires are soldered together on each side. I guess red wires are signal (S+, S-, E+ and E-) but what are Blue and Black? Then I soldered the wires to these wires to get sensor readings but I don't know what is what.

The sensor is looking like this:

I tried:

Two different libraries for this project both named HX711 (for this module)
Changing A+ for A- on module

// Hx711.DOUT - pin #A1
// Hx711.SCK - pin #A0

#include "hx711.h"

Hx711 scale(A1, A0);

void setup() {

  Serial.begin(9600);

}

void loop() {

  Serial.print(scale.getGram(), 1);
  Serial.println(" g");

  delay(200);
}

with no success. I get 0.0g on the serial monitor when calm, and the same when load is on.

My questions are:
How to know which wire is GND, +5V and which is signal? How to connect 4 of these sensors to read data? How to use HX711 libraries available and HX711 module? And, most important, how to read data from this scale on serial?


texts: Communication between two Bluetooth modules of two Arduinos

texts:
I am designing a home automation project. I want to control different home appliances through GSM. I am designing it in such a way that each apparatus is connected to an Arduino and bluetooth module. There is a master unit with Arduino, Bluetooth and GSM modules. When the user sends a message, the GSM receives it and communicates via Bluetooth to the corresponding Bluetooth module and Arduino.

Is it possible to communicate between two Bluetooth modules of two Arduinos? Is there a better solution?


texts: I have an rs232 to TTL converter and I want to read something in the Arduino serial monitor by using the converter instead of using Arduino serial cable. I have connected the correct wiring in my opinion such as tx, Rx, Vcc and GND of the converter to Arduino pin 0 (Rx), pin 1 (Tx), 3.3 V and GND. But when I write something in the serial monitor of Arduino, I am getting nothing. But when I use only the arduino serial cable then I receive what I am writing in the serial monitor. Kindly can anyone tell me what am i doing wrong?


texts:
I'm currently developing a quad copter for my school project and I am coming to the part where I am collecting all the parts before I assemble everything.

I have recently encountered a roadblock. I am going to solder an Arduino nano onto a strip board, but the problem is I cannot seem to find cables/wires to connect the nano to the module.

Excuse my ignorance, but where can I find these cables for soldering and what are they called?


texts:
I would like to implement a camera to my Arduino project.

So far I have worked with some sensors (e.g. distance), Wifi and Bluetooth modules, buzzer etc. You can find some very good examples on the web on how to use these things on your project, from the wiring to the sketch.

But when we talk about cameras, I feel like things start to be more difficult - I don't know if it's because camera users should know better what they are doing and therefore don't need a step by step guide, if simply there is a lack of information.

I see myself like this guy and this guy. We just can't find a tutorial!

I'm looking forward to buy a VGA OV7670 AL422 FIFO camera or a Serial TTL JPEG with NTSC video, but I don't want to spend my money on something I won't be able to use.

There is any better camera I could buy (by better I mean an easier camera to start working and with some information for the implementation)?

Thank you.


texts: What electronics should I study to create something like a fridge temperature monitor?

texts:
I would like to be able to design an Arduino circuit for a fridge monitor that would have a temperature sensor, a small speaker to emit a sound when the temperature changes past a threshold and an LCD screen showing the current temperature.

I have found a few examples online, but I would like to know why components like capacitors and transistors are used in their circuits so I'd be able to design similar circuits myself.

I found this list of electronics topics:

Basic Theory
Basic Passive Components
Passive Circuits
Discrete Active Components
Active Circuits
Integrated Circuits
Digital Logic
Analog
Signals
Outputs
Inputs
Digital Electronics

Some of these things, like digital logic seem unnecessary in such a project, but obviously some others are useful, but I don't know which. I'd like to know what it would be useful to study so I can understand the reasons for the circuit design of something like a fridge monitor.


texts: Improvement security in a domotic project

texts:
I recently started with a domotic project, I began creating a lock opening with a RFID
currently I'm trying improving the code (I took from http://forum.arduino.cc/index.php?topic=256260)

but I have some question about the security of this system (or any in the domotic way).

First, I know any system is 100% secure. starting from there, I was thinking, what happens if someone known that the system is built in the arduino platform and has some knowlege about it, that person can create a sketch, upload to the board and make "opening" all the pings?, they will have access to that room or thing I'm protecting (or trying). This is just a excercise, I don't want to go in depth about the external security that the board/system must have.

So, searching topics about it, I didn't find anything to help in the solution of this theoretical problem. I read some articles about the bootloader and I think, the solution can be there, I know Arduino is a openSource solution, but I think it doesn't mean insecure, so I think some kind of system who check a key before to load a sketch can help. It can have a default key, who can be used to the developing process, and other key (any) who must be verified, in the current sketch.

I'll try to explain it a little better:

Developing Mode
Bootloader [No Key] -----> can upload any sketch

Production Mode
Bootloader[check mode] -----> [Sketch with the secure key]
[Upload New sketch] -----> Bootloader[check the key in the new sketch with the key in the current sketch] (allow or block access, according as appropriate)

I don't have deep knowledge in criptography or bootloading, so I don't know if it's corret solution. I saw there are some way to "download" the code of the board (in a bin), I don't know if with this way the key will be exposed.

can someone tell me if this basic security would be helpful?
if it's, can be possible to implement? how?
Will the key be exposed in the bin (in case of download)?


texts: Arduino MKR GSM 1400 fails to start up without Serial Monitor

texts:
This question is similar to another question, but I have added more details. See: MKR GSM 1400 Works only when connected to computer.
I have designed and built a custom board into which I plug an Arduino MKR GSM 1400. It's a basic IO abstraction level shifter as the system I am integrating to run on 24V logic (done via opto-couplers). Everything is working perfectly and as-designed. I've added an I2C EEPROM.
When I boot the board from an external ATX supply +12V line it doesn't complete setup. After I've left it for some time, I connect it to my PC USB port and open the serial monitor in the Arduino IDE and it simply completes the setup process and enters loop successfully.
Voltages are perfect. The 12-24V supply is first fed through a standard 7810 (since I need +10V for the analog lines of the controlled system) and then a 7805. The +5V output of the 7805 is sent into the Vin of the Arduino. Measuring VIN with a DMM reads +5.07V and VCC reads +3.33V. I have a 3.7V 300mAh 25C Li-Po connected to the battery port on the Arduino, to deal with the current requirements as specified in the documentation.
I thought this could be a power issue, so I also tried booting it with a 10Ah USB Power bank that has 2 x 5V 2A (3A Max) USB ports. Same result, until I connect the PC with the serial monitor.
Simplified Arduino Code:

#include <MKRGSM.h>
#include <Wire.h>

GSM gsm;
GPRS gprs;
GSMServer server(80);
GSMSSLClient client;
GSM_SMS sms;

void setup() {
  //Initialise Serial
  Serial.begin(9600);
  while(!Serial)
  {}
  Serial.println("Gineer.Industrial.GSM.Controller");
  Serial.println("www.gineer.co.za");
  Serial.print("Hardware Version: ");
  Serial.println(hwVersion);
  Serial.print("Software Version: ");
  Serial.println(swVersion);
  Serial.println();

  Serial.print("Connecting");

  bool connected = false;

  while (!connected) {

>>> Here is where it gets stuck until I plug in the USB Serial Monitor, and then it continues happily

    if ((gsm.begin(SIMpinNumber) == GSM_READY) &&
        (gprs.attachGPRS(SIMgprsAPN, SIMgprsLogin, SIMgprsPassword) == GPRS_READY)) {
      connected = true;
    } else {
      Serial.print(".");
      delay(1000);
    }
  }
.
.
.

Interestingly, the +5V output pin on the Arduino measures 4.68V when not connected to the PC. I don't however use this pin as I have the 7805 on my board. All other voltages measure as above at all times.


texts: error: no '' member function declared in class 'SonarSRF08'

texts:
Hi, I am a pretty novice coder and I am getting this error consistently with a library I have installed. Here is the code I am trying to run:

#include <Wire.h>
#include <SonarSRF02.h>
#include <SonarSRF08.h>

#define leftAddress ( 0xF2 >> 1)
#define rightAddress ( 0xE0 >> 1)
#define mainAddress ( 0xF8 >> 1)
SonarSRF02 LeftSonar;
SonarSRF02 RightSonar;
SonarSRF08 MainSonar;

char unit = 'c'; // 'i' for inches, 'c' for centimeters, 'm' for micro-seconds

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

    LeftSonar.connect(leftAddress);
    Serial.println("Left SRF02 US-Sensor ");
    Serial.println(LeftSonar.getSoft());

    RightSonar.connect(rightAddress);
    Serial.println("Right SRF02 US-Sensor ");
    Serial.println(RightSonar.getSoft());

    MainSonar.connect(mainAddress);
    Serial.println("Main SRF08 US-Sensor ");
    Serial.println(MainSonar.getSoft());
}

void loop() {
    float sensorReading = 0;

    sensorReading = LeftSonar.getRange(unit);
    // print out distance
    Serial.print("Distance from left: ");
    Serial.print(sensorReading);
    Serial.print(" ");
    Serial.print(unit);
    Serial.println();

    sensorReading = RightSonar.getRange(unit);
    // print out distance
    Serial.print("Distance from right: ");
    Serial.print(sensorReading);
    Serial.print(" ");
    Serial.print(unit);
    Serial.println();

    sensorReading = MainSonar.getRange(unit);
    // print out distance
    Serial.print("Distance from main: ");
    Serial.print(sensorReading);
    Serial.print(" ");
    Serial.print(unit);
    Serial.println();
}

My project is using an SRF08 sensor with an Arduino Mega 2560


texts: Passing variables for a PID in an interrupt

texts:
I'm needing to pass variables from my timerIsr() function to my loop() function. I have little experience with the Arduino language, I'm mostly familiar with Python so this has been quite difficult for me.

Essentially I'm creating a PID controller to maintain RPM of a fan motor if friction is applied to it. I'm implementing the PID control in the loop() function but I need the rotation variable information from my timerIsr() function. I've tried to return the variable info but it doesn't match up to the actual fan speed. I think it has something to do with difference delay/timer times operating at different instances but I'm unsure.

Here's what I have so far

#include "TimerOne.h"
#include <PID_v1.h>

int counter=0;

const int IN1 = 11;
const int IN2 = 10;
volatile float pot=0;
const int POT = 0;
const int ENA = 6;

double Setpoint, Input, Output;
double Kp=2, Ki=5, Kd=1;

PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, DIRECT);

void docount()  // counts from the speed sensor
{
  counter++;  // increase +1 the counter value
}

void timerIsr()
{
  Timer1.detachInterrupt();  //stop the timer
  Serial.print("Motor Speed: ");
  int rotation = (counter / 30);  // divide by number of holes in Disc
  Serial.print(rotation,DEC);
  Serial.println(" Rotation per second");
  counter=0;  //  reset counter to zero
  Timer1.attachInterrupt( timerIsr );  //enable the timer
  Serial.print("pot = ");
  Serial.print(pot);
  Serial.print("\n");

  //return rotation;
}

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

  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);

  Timer1.initialize(1000000); // set timer for 1sec
  attachInterrupt(0, docount, FALLING);  // increase counter when speed sensor pin goes High
  Timer1.attachInterrupt( timerIsr ); // enable the timer

  myPID.SetMode(AUTOMATIC);
}

void loop()
{
  //Input = timerIsr();
  pot=analogRead(POT)/4.01569;
  //Setpoint = sp;

  //Serial.print(Input);

  analogWrite(ENA, pot);
  digitalWrite(10, HIGH);  // set rotation of motor to Clockwise
  digitalWrite(11, LOW);

  delay (250);
}

As you can see I've commented some stuff out that's related to the PID library. Right now I'm just trying to pass the rotation variable to the loop() function.

Is it possible to update global variables at different times so any function can access them?


texts: Error Compiling for board Arduino Nano while using Adafruit GFX

texts:
Whys is this happening to me??
I have to meet a deadline please help!!
Here is my code.
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

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

// Declaration for SSD1306 display connected using software SPI (default case):
#define OLED_MOSI   11
#define OLED_CLK   12
#define OLED_DC    9
#define OLED_CS    8
#define OLED_RESET 10
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT,
  OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
void setup()
{
  Serial.begin(9600);

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

  display.display();
  delay(2000);

  display.clearDisplay();

  display.drawPixel(10, 10, SSD1306_WHITE);

  display.display();
  delay(2000);
  display.invertDisplay(true);
  delay(1000);
  display.invertDisplay(false);
  delay(1000);

  }
void loop()
{
drawLine(20,60,5,50,256);

}

The Error

C:\Users\hp\AppData\Local\Temp\ccyB6dO1.ltrans0.ltrans.o: In function
loop': C:\Users\hp\Desktop\Sunfox\Sunfox\BP_Plus_ECG\February_11\OLED_Testing_w_Adafruit\Test_2\Test_2/Test_2.ino:51: undefined reference to drawLine(unsigned int, unsigned int, unsigned
int, unsigned int, unsigned int)' collect2.exe: error: ld returned 1
exit status exit status 1 Error compiling for board Arduino Nano.


texts: I'm working on a NodeMCU project and have a small doubt about LEDs and resistors

texts:
In my NodeMCU I want a statement to turn on an LED, which is easy, just use pinnumber, HIGH. But, what I'm trying to do here is connect multiple LEDs to one pin like this:
I just wanted to know if this will work and whether all the LEDs will turn on by one command write (pinnumber, high) or do I have to do something else to this circuit?
Please help I'm a noob to electronics.
And also, is the resistor correct(1k ohm) or is it 220ohm, because different places suggest different things.


texts: Trying to individually control the servos in my robot using keyboard input

texts:
#include<Servo.h>
Servo ser1;
Servo ser2;
Servo ser3;
Servo ser4;
Servo ser5;
int poser = 0;
int val;
int mot;

void setup() {
  Serial.begin(9600);
  ser1.attach(4);
  ser2.attach(5);
  ser3.attach(6);
  ser4.attach(7);
  ser5.attach(8);
}

void loop() {
    Serial.print("Choose the motor");
      mot=Serial.read();
      switch(mot)
      {
        case 1:
        {
            val = Serial.read();
            if (val == 'd')
             {
                poser += 1;
                ser1.write(poser);
               delay(15);
             }
           if (val == 'a')
             {
                poser -= 1;
                ser1.write(poser);
                delay(15);
             }
           break;
         }
       case 2:
         {
           val = Serial.read();
           if (val == 'd')
            {
               poser += 1;
               ser2.write(poser);
               delay(15);
            }
           if (val == 'a')
            {
               poser -= 1;
               ser2.write(poser);
               delay(15);
            }
           break;
         }
      case 3:
         {
           val = Serial.read();
           if (val == 'd')
            {
              poser += 1;
              ser3.write(poser);
              delay(15);
            }
          if (val == 'a')
            {
              poser -= 1;
              ser3.write(poser);
              delay(15);
            }
          break;
         }
       case 4:
         {
            val = Serial.read();
            if (val == 'd')
             {
                poser += 1;
                ser4.write(poser);
                delay(15);
             }
           if (val == 'a')
             {
                poser -= 1;
                ser4.write(poser);
                delay(15);
             }
           break;
         }
       case 5:
         {
           val = Serial.read();
           if (val == 'd')
             {
                poser += 1;
                ser4.write(poser);
                delay(15);
             }
           if (val == 'a')
             {
                poser -= 1;
                ser4.write(poser);
                delay(15);
             }
           break;
          }
      default:
          {
              Serial.print("Type valid number");
              break;
          }
    }
  }

The code just shows "Choose the motor type valid number" repeatedly and the arm contorts as soon as I upload it. Can someone please check the code and tell me what could've gone wrong?


texts: Uno Wifi rev2 - after long time it disconnects

texts:
Given an Arduino Uno Wifi Rev2 with this small U-blox NINA wifi module.

All work great however after a long time (I can't be more exact but we talk here about weeks if not months), it suddenly disconnects.

This board is unattended, and the only way to recover is to reset the Arduino.

Here is my code:

WiFiServer server(PORT);

void setup() {
  connectToWifi();
  server.begin();
}

void connectToWifi() {
  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);
    if (status == WL_CONNECTED) break;

    // wait 10 seconds for connection:
    delay(10000);
  }
}

void loop() {
  // check WiFi status
  if (WL_CONNECTED != WiFi.status()) connectToWifi();

  WiFiClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        ... (other wifi-unrelated code)

        // close the connection:
        client.stop();
      }
    }
  }
}

When it disconnects from wifi, the router's dhcp manager console shows it with "waiting" status.

Note: I'm the only client, and only one character is sent to the Arduino at once, then the socket is closed. It is very unlikely, that a client hangs, and the board is stuck in the while loop.

Is this a known problem, or I have to dig myself more into this?

Thank you!


texts:
I have been trying to solve the problem of humidity sensors in a harsh environment (BBQ/Pizza Oven) and I came across this:
enter link description here

But I don't see any documentation on how to connect such a sensor to an arduino.

Are there any examples of how to integrate this?


texts:
Since some months, everyone can buy a board with this IC.

It is compatible with the ATMega328 and has some features like 12bit ADC (instead of 10 bit), DAC, unique ID and also 32MHz.

But I can't find it in the "normal" shops. Also on the LCSC it is not available. Only in this shop:
https://www.electrodragon.com/product/5pcs-logicgreen-lgt8f328p/
For 0.68$ compared to the 2$ for the atmega326P-AU of the other electronic parts shops (it is cheaper than the cheapest attiny with ADC!)

So the question. Is this chip just a clone for private use or can it be used as official alternative to the more expensive and original ATMega328?


texts: Error using SD card module: no matching function for call to

texts:
This code is just a test code to write a file to an SD card using an SD card module. When I run the code, I get this error message and I'm not sure what to do to fix the code: no matching function for call to'SDLib::SDClass::exists(SDLib::File&)'.

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

int cs = 10;

File myTest;

void setup()
{
  //
  char myTestName[] = "MyTest.txt";

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {

  }
  Serial.println("Initializing SD card...");
  Serial.println();

  pinMode(cs, OUTPUT);
  pinMode(SS, OUTPUT);
  if (!SD.begin(cs)) {
    Serial.println("SD did not initiliaze");
    while (1) ;
  }
  Serial.println("SD initialized.");

  if (! SD.exists(myTest)){
     myTest = SD.open(myTestName, FILE_WRITE);

     myTest.println("My 1st Line of Data");
     myTest.flush();
  }
  else{
    myTest = SD.open(myTestName, FILE_WRITE);
    myTest.println("Another Line of Data");
    myTest.flush();

  }

  Serial.println("Done Writing");

}

void loop()
{

}


texts: Liquid Crystal LCD Display Prints f in all rows and columns

texts:
The problem is that the Liquid Crystal LCD display only prints "f" on every row and every column.

When I tell it to print something, then the display prints "f" on every square(row, column) for a brief second, then each square shows three white bars stacked up parallel to each other (quite like an "=" sign except that there's one more bar on top").

I am also using a tmrpcm library, so I'm guessing that interrupts might have to do with this, but I have no idea how to solve the problem.

The link to the tmrpcm library is as follows: https://github.com/TMRh20/TMRpcm

Thank you so much. I need to get this done by tomorrow 8 A.M., so I'm pretty desperate.

#include <LiquidCrystal.h>
#include <SD.h>                      // need to include the SD library
//#define SD_ChipSelectPin 53  //example uses hardware SS pin 53 on Mega2560
#define SD_ChipSelectPin 10  //using digital pin 4 on arduino nano 328
#include <TMRpcm.h>           //  also need to include this library...

TMRpcm tmrpcm;   // create an object for use in this sketch
char mychar;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

volatile int pauseOnOff;

void setup(){

  tmrpcm.speakerPin = 9; //11 on Mega, 9 on Uno, Nano, etc

  if (!SD.begin(SD_ChipSelectPin)) {  // see if the card is present and can be initialized:
    Serial.println("SD fail");
    return;   // don't do anything more if not
  }
  else{
    Serial.println("success!");
  }

  tmrpcm.play("Closer.wav");

  lcd.begin(16, 2);

  lcd.print("hello, world!");
}

void loop(){

}


texts: Communication b/w Arduinos, master(M) and slave(S) via Tx Rx pins. M sends query to S which shows the data in serialmonitor. S fails to send data to M

texts:
Slave code
int arr[10] = {0,1,2,11,4,5,6,7,8,9};
char id = '1';
char re[2];
void setup() {
// Begin the Serial at 9600 Baud
Serial.begin(9600);
}
int ia;
void loop() {
Serial.readBytes(re,2);// slave gets the query
ia = re[1] - '0';
if (re[0] == id){
Serial.println(arr[ia]);// slave print in serial monitor
}
delay(500);
}

Master Code
char mystr[2] = "13";
void setup() {
// Begin the Serial at 9600 Baud
Serial.begin(9600);
}

void loop() {
Serial.write(mystr,2); //sends query to slave
delay(3000);
}


texts:
I'm building an instrument that has 72 buttons that can be pressed. Now I'm planning on using Arduino to send data to computer via USB cable about which buttons are pressed. So I figured I'd need 72 different input pins, one for each button(the button is connected to the Arduino via a wire). But, the Arduino doesn't have 72 input pins, so this seems kind of impossible. So what I'm looking for is a way to somehow extend the number of pins on the Arduino or another way to solve my problem. Maybe it would be better to use another micro-controller? Maybe using analog inputs for this is better?

If it makes any difference, the max number of buttons that can be pressed at once is 10.


texts: Simple Arduino - 74hc595 shift register construction [tmli5]

texts:
I'm quite new to Arduino world and I'm trying to understand how shift registers work.
I built this construction :

In fact, it is an Arduino Duemilanove with AtMega on it, but afaik it doesn't matter.

The tutorial I try to follow use SPI library so I try to do it too. I kind of understood that data input, latch and clock had to be pins 7, 4 and 11.

Basically, all I try to do is sending a byte to light the LEDs. As for me now, the sequence should light all LED, then no one, then one after another.
I know there is one more input ont the right side of the SR but I didn't plan this model so I ran out of LEDs...

This is the code I use :

#include <SPI.h>
#include <StandardCplusplus.h>
#include <vector>
#include <iterator>
#include <size_type>

using namespace std;

//pin du shift register
#define DATA_PIN 13
#define LATCH_PIN 4
#define CLOCK_PIN 11
//à utiliser plus tard
#define INPUT_PIN 2

void setup() {
  pinMode(DATA_PIN, OUTPUT);
  pinMode(LATCH_PIN, OUTPUT);
  pinMode(CLOCK_PIN, OUTPUT);
  //pinMode(INPUT_PIN, INPUT);

  SPI.setBitOrder(MSBFIRST);
  SPI.setDataMode(SPI_MODE0);
  SPI.setClockDivider(SPI_CLOCK_DIV2);
  SPI.begin();

  //SPI.transfer(getBit(3));
  //digitalWrite(LATCH_PIN, HIGH);
  //digitalWrite(LATCH_PIN, LOW);

  Serial.begin(9600);
  Serial.println("start !");
}

void loop() {
  shift(B11111111);
  shift(B00000000);
  shift(B10000000);
  shift(B01000000);
  shift(B00100000);
  shift(B00010000);
  shift(B00001000);
  shift(B00000100);
  shift(B00000010);
  shift(B00000001);
}

void shift(int n){
  SPI.transfer(n);
  digitalWrite(LATCH_PIN, HIGH);
  digitalWrite(LATCH_PIN, LOW);
  Serial.print("shift : ");
  Serial.println(n);
  delay(1000);
}

When I upload this code, LEDs sequence has no sense, but serial output was totally OK.

What I see (without the output 0 of course) is :
1111111, 0111111, 1011111, 1110111, 1111101 and then 1111111 without further changes, whereas serial output is 255, 0, 128, 64, 32, 16, 8, 4, 2, 1, 255, 0, 128 and so on.

I assume I didn't understand something important, and it prevent me from finding answers in google.

Thanks for helping, it's really disturbing for me.

EDITS :

changed the title, it is a 74HC595.

Strangest behavior too (not gonna create another topic for that now), I dont have to connect both the gnd and VCC from my arduino for this to light LEDs. It changes a little the brighness of LEDs, but surprisingly VCC< GND< both

This is the tutorial I use to understand shift registers : https://youtu.be/6fVbJbNPrEU?t=195, and the one that uses SPI is nXl4fb_LbcI

I am now aware that I should get one resistor for each LED but I don't have that much resistors and as far as I can see this don't harm my LEDs nor underpower them.


texts:
I want to find the length of upper one signal (purple one). So for that, i used pulseIn() function for that. But i just get 0 as a result in serial monitor.

int pulsepin = 8;
int value = 0;

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

void loop()
{
  value = pulseIn(pulsepin, HIGH);
  Serial.println(value);
  delay(1000);
}

Here, above is my arduino code which i used. I don't know why I don't get any reading except 0.


texts:
So I built an custom board based on the Atmega32u4. Schematics attached.

I managed to burn a bootloader for Pro Micro using Arduino Uno as an ISP.

The issue I have is that the board is dead when powered and to bring it to life I have to short pin1 of my crystal with VCC for a second. I discovered it by mistake..

The crystal I'm using is an Epson X1G004451000212.

Any idea why is this happening?


texts: Reading a car mass air flow, volumetric air flow meter

texts:
I'm looking to build an air flow meter that will output in standard liters per minute. The cheapest sensors seems to be a car's Mass Air Flow sensor. I'm wondering if there is a way use  one of these MAF to measure air flow in liters per minute.

Essentially I need to measure a medical ventilator's air flow in order to calibrate it. The gas flow analyzers that are normally used are way too expensive and offer too many extra features that I don't need.

Thank You


texts: How to avoid odd naming rules for Arduino when writing a library?

texts:
I'm building a small library that will be used and production and released open source. I'm paying a lot of attention to the "best practices" to make sure this code is reliable and easy to use. I also would also like to make this easy to edit. I'm having an issue with the naming scheme of the whole project.

There are a few Arduino naming quirks. If I have a sketch called mylib:

...I can't create a tab called mylib.cpp. However, I can create a file called mylib.h...
...The folder and main sketch file must be the same name as the folder it is in
...The sketch name (and folder) cannot contain any spaces.

Well, why are you creating a sketch for a library? The Arduino IDE won't open a .cpp file unless there's a sketch in that folder (and you have to open the .ino/.pde file in that folder). I'm trying to get this to work with the Arduino IDE so, if users need to edit the library, then can just open the file and go to the correct tab. If they use an external editor, they won't be able to compile it to see if there are any errors.

I'd ideally just do this structure:

my_lib
   |- my_lib.ino
   |- mylib.cpp
   |- mylib.h

However, a user might see that the folder is called my_lib and try including the file my_lib.h.

I think this is a major oversight in the Arduino IDE, but I need to have this work with the Arduino IDE. If it was just me working on this code, I might consider making the library directly in a project directory, but that isn't ideal. Is there anything that I can do to bypass this/make it easy for users to edit? Is there any "standard"/"convention" that defines how to do this?


texts:
i have been trying to use NO2 spec senor in arduino UNO. how to write the code for it to get the output in terms of 'ppm' and how to give connection.with the helo of cross-sensitivity given in datasheet how to detect the interference gases from this sensor itself..the datasheet URL:

https://www.spec-sensors.com/wp-content/uploads/2016/10/3SP_NO2_5F-C-Package-110-508.pdf


texts:
A friend has told me I shouldn't rely on functions because, during execution, they occupy a significant amount of RAM.
Is that true or, if it isn't, what's the maximum suggested level of function nesting at runtime?


texts: Ensuring specific frequency at specific time?

texts:
I, at the moment am trying to come up with a simple way where I can program an Arduino to provide a step signal with a given frequency, at a specific time.

The frequency has to be ramped up, and within a time duration of 10 seconds shall the frequency go from 0 Hz to 48000 Hz.

How do I ensure both the specific time of when the frequency occurs, and the specific frequency of the step signal?

Signal has to be used to driver a stepper motor.

Edit: Code current:

So i currently wrote this piece of code:

int timestep = 1;
while(1)
{
  unsigned long startTime = millis()
  while(startTime != 500)
  {
    digitalWrite(step_pin,LOW);
    delayMicroseconds(208/timestep);
    digitalWrite(step_pin,HIGH);
    delayMicroseconds(208/timestep);
  }

  timestep++;
}

For each 0.5s should the frequency be doubled..  would this work?

Edit 2.0:

I made an new implementation using @EdgarBonet 's answer, and with the help of Timer1 library that arduino provide (I guess?).

.h file

#ifndef stepper_motor_h
#define stepper_motor_h

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

#define step_pin  13
#define dir_pin   12
#define en_pin    11
#define max_step  200

 class stepper_motor
{
  public:
    stepper_motor();
    void step_pwm();
    static void callback();
    TimerOne timer1;
  private:
    //uint32_t period;
    bool alive_bool;
    //int step_count;
    bool position_bool;
};

#endif

.cpp file

#include "stepper_motor.h"

int step_count = 0;
uint32_t period = 40825UL << 16; // 20412,5 us fixed point arithmetic time = 0

stepper_motor::stepper_motor()
{
  //pinMode(BUILTIN_LED,OUTPUT);
  pinMode(step_pin, OUTPUT);
  pinMode(dir_pin, OUTPUT);
  pinMode(en_pin, OUTPUT);
  alive_bool = true;
  position_bool = false;
  step_count = 0;

}

static void stepper_motor::callback()
{
  if (step_count < 240)
  {
    uint32_t new_period = sqrt(2 * step_count / 4.8);
    period -= new_period;
    step_count++;
  }
  else
  {
    return;
  }
}

void stepper_motor::step_pwm()
{

  digitalWrite(en_pin, HIGH);

  delay(0.005);

  digitalWrite(dir_pin, HIGH);
  //LOW  - Move towards the sensor
  //HIGH -  Move away from the sensor

  delay(0.005);

  timer1.initialize(period);
  timer1.attachInterrupt(callback);
  timer1.pwm(step_pin, 512);

}


texts:
Hello Arduino enthusiasts! I've been working on a keypad lock system for school lately and I need some advice.Basically, my code checks if the entered passcode is the same than a predefined passcode stored in a variable. I must code a local web server hosted by my Arduino Mega board that allows someone to change the correct passcode remotely via Ethernet. I have coded a working program, but I am sure it can be better designed or done in an easier way, this is why I'm asking for advice on how I could improve the performances of my program or make it shorter. If you need further explanation, let me know and I'd be happy to explain. Thank you!

Here's my code(or if you think it's plain, with colors):

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

byte mac[] = { 0x90, 0xA2, 0xDA, 0x0E, 0xA5, 0x7E };
IPAddress ip(192,168,1,250);
EthernetServer server(80);

String HttpHeader;
String nwCode="";
int curCode=19988;

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

  if(Ethernet.begin(mac)==0){
    Serial.println("Failed to use DHCP");
    Ethernet.begin(mac, ip);
  }
  Serial.println(Ethernet.localIP());
  HttpHeader="";
}

void loop(){

  EthernetClient client = server.available();

  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        if (HttpHeader.length() < 16){
           if(nwCode.length()<5){
             if(isDigit(c)){
               nwCode.concat(c);
             }
           }
        }
        if (c == '\n') {
          if(nwCode.length()==5){
            curCode=nwCode.toInt();
            Serial.println(curCode);
          }
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("");
          client.println();
          client.print("<form method=get>");
          client.print("<input type='password' name=code required>
");
          client.print("<input type=submit value=submit></form>");
          client.print("");
          nwCode="";

          client.stop();
        }
      }
    }
  }
}

In the void setup() I try to connect to the internet with DHCP, and if not, just connect with specified IP and MAC addresses. I also print the IP address used to host the webpage so we know what to type in our browser. Then in the void loop() I wait till someone visits the IP address and show them the webpage. Next, we read the incoming GET request(new passcode submitted) and make sure it's not any longer than 5 chars (correct passcode is 5 chars long), then I take only the numbers (remove GET and HTTP 1.1 from the request) and store them in the nvCode variable. Then if the request has ended and the passcode is 5 chars long, set the current code value to the new code(Without this step the serial monitor outputs 11 everytime the page is loaded or I make a request, I think this comes from the HTTP 1.1 and isDigit().)
I know there are better ways of doing this and the simpler and shorter the better, so any advice is much appreciated, thanks!

I have used Serial output for debugging purposes and to better show what the code is doing but I plan on removing that afterwards.
Here are the outputs:

This is what the Serial monitor outputs when I power the Arduino board.
(The IP is the address where the webpage is hosted)

This is the webpage hosted by the Arduino board.

After submitting a new passcode, it sends a GET request.

The Serial monitor output after sending the new passcode.

TL;DR the nwCode variable must collect the passcode entered in the HTML form and must set var curCode's value to it. nwCode being the new passcode code and curCode being the current passcode.

!UPDATE!
I just realized that I can change the passcode once, but if I try to change it again after, I get the wrong numbers on the serial monitor, so my code has a problem somewhere. Any help regarding this issue would be much appreciated.


texts:
I am doing a project with Arduino to find CO2 in an environment. For this purpose, I bought a breakout board with an MG811 sensor on it. I bought it from eBay and it came with no datasheet. I searched on the internet and found the datasheet for the MG811.

With the help of the datasheet, I also found the formula to convert the input voltage to PPM. But later I realized that the device also has an amplifier on it, which is giving me higher voltages. I searched thoroughly and found the original device on Taobao.

Can someone please tell me how can I determine the gain so that I can convert the values I read to original values?

One more question. On the given web link, I also found that this device comes with a pin called TCM and with Google translate, I found that it shows temperature compensated output. Can you please explain me the use of this pin as well? If it is more advantageous for me, I'll use this instead of the normal analog output pin.


texts: How can I read a piezo sensor and have it output a fixed voltage?

texts:
I'm trying to creature an instrument out of a few boards I have. The plan is to have piezo sensors wait for a hit, then be read by a digital pin, then execute code based on what piezo sensor was hit.

I know how to make a note play, but I don't know how to read a signal from a piezo that's between 3V and 5V. I'm not worried about velocity measurements, I just want there to be a hit, register the hit through arduino, then relay the pin number to a track number.

I read that pin change interrupts can read a signal instantly.

Below is some example code for my audio output board that plays audio files. This specific bit of code is for "notes" on an instrument.

          wTrig.masterGain(-8);                 // Lower main volume
          wTrig.trackPlayPoly(6);               // Play first note
          delay(1000);
          wTrig.trackPlayPoly(7);               // Play second note
          delay(1000);
          wTrig.trackPlayPoly(8);               // Play third note
          delay(1000);
          wTrig.trackFade(6, -50, 5000, 1);     // Fade Track 6 to -50dB and stop
          wTrig.trackFade(7, -50, 5000, 1);     // Fade Track 7 to -50dB and stop
          wTrig.trackFade(8, -50, 5000, 1);     // Fade Track 8 to -50dB and stop

I don't have experience with code, but this is how I think activating a note would work:

wTrig.trackPlayPoly(pin number)
delay(100);
wTrig.trackFade(pin number, -50, 5000, 1);

As far as limiting voltage, don't I just need to put some resistors in circuit with the piezo sensors?

In psuedo-code, this is what I want to make happen:

Listen for signal from any pin
Store that pin number as a variable
wTrig.trackPlayPoly(pin number)
delay(100);
wTrig.trackFade(pin number, -50, 5000, 1);


texts: How can i connect the Mics-5132 to Arduino Uno (Carbon Monoxide Sensor)

texts:
hi. i don't know how can i connect Mics-5132 CO Sensor to my arduino.

plz help


texts: Trying to send .wav files between NodeMCU

texts:
Im trying yo send wav files between two nodeMCU. My setup is like this
uSD Card Module -> Arduino Mega -> Node MCU

So this is my setup, where I have 4 devices like this. One will serve as the central network(where I called it "server") where it will create an access point for the 3 other devices("modules") to connect to. The server will send data by using UDP so it can broadcast to the three modules simultaneously.
I'm able to send .txt files which is stored on the uSD module. Pass the .txt file contents to the nodeMCU through serial port, then recieve it on the other NodeMCU which will then send the data to the Arduino Mega also through serial port and will store it on its uSD Shield.

When I would try .wav files. It is able to send the whole .wav file to the NodeMCU from Arduino Mega (since .wav files are too big, I divide the .wav files into sets since the serial port can't handle too large data being sent/recieved. But when it would send the data from the nodeMCU to the other nodeMCU there are parts which are not being sent. When I try to observe what are not being sent, its part of the WAV Header Format, so it needs to be sent. Ill be posting the codes Im using to send and recieve and also a screenshot/example of the wav file as it is being sent.

Server's Arduino Mega Sending data to NodeMCU Serially:

void sendFiletoSerial(char fileSend[12]){
  Serial.println();
  Serial1.println();
  if (!myFile.open(fileSend, O_READ)) {
    sdf.errorHalt("opening test.txt for read failed");
  }
  Serial.print(fileSend);
  Serial.print(" Size:");
  Serial.println(myFile.fileSize());

  Serial1.print(fileSend);
  Serial1.print(" Size:");
  Serial1.println(myFile.fileSize());
  delay(1500);
  fileofSize = myFile.fileSize();
  myFile.close();
  // read from the file until there's nothing else in it:
  char data;
  long int index=0;
    for(int i =0; i<(fileofSize/tempSize);i++){
    if (!myFile.open(fileSend, O_READ)) {
    sdf.errorHalt("opening test.txt for read failed");
  }
    //Serial.println(i);
    myFile.seekSet(index);
  for(int j =0; j<tempSize;j++){
  int temp = myFile.read();
 intTempFile[j]=temp;
  index++;

  }
  for(int k =0;k<tempSize;k++){
  Serial1.write(intTempFile[k]);
  }
    myFile.close();
    delay(1500);
  }
  Serial.println("LAST SET OF DATA");
    if (!myFile.open(fileSend, O_READ)) {
    sdf.errorHalt("opening test.txt for read failed");
  }
    myFile.seekSet(index);
    int lastSetSize=fileofSize-((fileofSize/tempSize)*tempSize);
    Serial.println(fileofSize-((fileofSize/tempSize)*tempSize));
  for(int j =0; j<lastSetSize;j++){
 int temp = myFile.read();

 intTempFile[j]=temp;
  index++;

  }
  Serial.println();
  Serial.println("tempFile");
  for(int k =0;k<lastSetSize;k++){
  Serial1.write(intTempFile[k]);
  }
    myFile.close();

}

Server's code for Sending from NodeMCU to other Node MCU:

    if (Serial.available()) {
          byte readStr[100];
        Serial.readBytes(readStr,100);
       // Serial.write(readStr[i]);
        }

         port.beginPacket("192.168.4.255",2390);
         for(int i =0; i <100; i++){
        port.write(readStr[i]);
         }
         port.endPacket();
      }

Module's Code for NodeMCU to recieve data from other NodeMCU:

void dumpMode(){
  while(1){
    int packetSize = port.parsePacket();
      if (packetSize) {
        port.read(packetBuffer, fileSentSize);
        Serial.write(packetBuffer);

  }
  if(Serial.available()){
    String reply = Serial.readString();
    if(reply == "STOP"){
      break;
    }

    }
  }
}

Server's NodeMCU Sent Data:

RIFFäN  WAVEfmt      À]  À]    dataÀN  €€€€€€€€€€€€€€€€€€€€€€€€

Module's NodeMCU Recieved Data:

RIFFäN€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€

Is there something im doing wrong thats why NodeMCU is not either sending or recieving every content of the wav file?

Thank you for those who will help out. :)


texts: DHT11 and Liquidcrystal setting cursor issue

texts:
lcd_key = read_LCD_buttons();
float temp = dht.readTemperature();
delay(1000);
// lcd.setCursor(0,0);

if(temp < 0) {
    lcd.print(temp);
}

if(temp >= 0.00 || temp <= 5.00) {
    lcd.setCursor(0,6);
    lcd.print(temp);
    delay(100);
}

Here I got simple code about reading temperature from DHT sensor and lcd but when I raise or lower the DHT's temperature the lcd's cursor always printing my data from 0,0.

I want that when the temperature between 0-5 celcius it shall write data on 0,6 in lcd screen but this code not working.

Thank you for answers.


texts: Arduino Uno - temperature sensor DS18B20 not responding

texts:
I try to use a new DS18B20+ temperature sensor (sealed water proof version).

It doesn't work. My own code doesn't work, examples from DallasTemperature Library don't work, example from OneWire library doesn't work.

For example function sensors.getDeviceCount(); (DallasTemperature library) returns '0'.
Function tempSensor.getTempCByIndex(0); returns 65409 (int variable). !ds.search(addr) (OneWire library) also always return '0'. Then I am sure, Arduino code is alright.

I am sure DS18B20 is connected correctly:

white wire (onewire data) - onewire Arduino pin (tested with pin 2 and pin 13)
red wire (+V) - 5V Arduino pin
black wire (GND) - GND Arduinp pin
between 5V and DATA there is a 4k7 resistor

I have measured resistances between the temperature sensor's wires:

'+V' to 'data': 4,7 kOhm
'GND' to 'data': ~3 Ohm

I think between the GND and DATA sensor wires resistance should be much higher - am I right? Below you can see a block diagram copied from the sensor datasheet (https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf):

Maybe black and white wires are +V and GND (which one is +V?), red is data? Or it's broken? Or something else?

I have bought it here - https://botland.com.pl/pl/czujniki-temperatury/10936-sonda-wodoodporna-z-czujnikiem-temperatury-ds18b20-5m-brazowy-silikon.html?search_query=sonda+temperatury&results=43 (language: polish). it is written:

VCC - red
GND - black or green
data 1-wire - white or yellow


texts:
I am controlling a g-series 1000kv brushless motor with my arduino. Currently I have my setup as follows:

Now I used the code given to me in a tutorial which is also as seen below:

#include <Servo.h>
Servo ESC;     // create servo object to control the ESC
int potValue;  // value from the analog pin
void setup() {
  // Attach the ESC on pin 9
  ESC.attach(9,1000,2000); // (pin, min pulse width, max pulse width in
microseconds)
}
void loop() {
  potValue = analogRead(A0);   // reads the value of the potentiometer (value between 0 and 1023)
  potValue = map(potValue, 0, 1023, 0, 180);   // scale it to use it with the servo library (value between 0 and 180)
  ESC.write(potValue);    // Send the signal to the ESC
}

at any voltage (tested between 7.4v and 12v) i was not able to change the spin speed despite my knowledge being voltage x 1000 is the rpms. I want to run a piece of code that will spin the motor slowly but no solution is working.


texts: What is the difference between python and arduino programming?

texts:
I am a Python programmer and want to learn Arduino programming so want to know what are the main differences between Python and Arduino C++ programming?

Is Arduino C++ more complex than Python programming?
Are there any similarities that will help me?
Are there any formatting  restrictions like in Python?
Etc...

According to this page(printing hello), Aurdino programming looks easy to me.


texts: Connect output of Arduino DUE to input of Arduino Uno

texts:
I have a distance sensor connected to an Arduino DUE and I want to wire its output to an Arduino UNO.
In Arduino DUE, after calculating the distance, I convert a range of distances (0-10cm) to Volts (0-5V), then I map these to 0-255 values and I do AnalogWrite at the DAC pin.
In Arduino UNO, I AnalogRead from an analog pin (A0) which is connected with a jumpwire to the DAC pin of Arduino DUE. I was expecting to get values between 0 (when the distance is 0 cm) and 1023 (when the distance is 10 cm). But instead I get a weird and unstable range between 100 and 548.
The two Arduinos are connected with a jumpwire between grounds and a jumpwire between DAC and A0.
What am I doing wrong? I thought I had understood how to do this, but apparently not :)
Thank you for your help and time in advance!
Konstantina


texts: Plotting data from Arduino and using the serial monitor in parallel

texts:
I'm very new to the Arduino world so bare with me.
I would like to plot live data that I receive from my arduino. I use the Serial Monitor to read user input, show text, etc.
The only way I found to plot data from the arduino is by printing the data out in the serial monitor
I would rather prefer the data not to be shown in the serial monitor at all (just from a visual standpoint) but I guess there is no way around it.
Anyways, I would like to read and plot the data only when the user makes a specific input into the Serial Monitor.
Let's say the user types in: "start"
now the arduino prints out the values that needs to be plotted.
But every plotting tutorial on plotting with the arduino that I could find always prints out the data right from the start. I want to start the plotting with the specific user input.
I hope I could explain my question well enough.
Thank you in advance for your help.
Luca


texts: Rotate Robot head according to Sound level

texts:
I'm currently working on a robot using an Arduino and I'd like to control robot's head like this:

Imagine that it is on your desk and it can turn it's head through a range of 150 degrees like a human can do. So if I tap the desk in the the middle position, relative to his head rotation (in front of the robot), it should rotate his head by 75 degrees if he was looking at the left or right.

Likewise, I want to locate the desk tap or another sound source and make his head turn to that direction.

So in order to do that I have a solution, but I'm not confident enough to use it because I don't know whether is will give accurate results. This is what I thought:

I'll place two sound modules on the left and right sides of the robot. When a sound comes, I'll measure which microphone detects the higher sound level, and calculate an approximate angle to rotate the robot's head accordingly.

However, since I'm a newbie to Arduino, I've no real sense of whether that will work as I intend. Do people think this is a good method? If not, how can I improve it?

Also if you can, please suggest some good, Arduino compatible sound modules for this project. Thank you.


texts: Slow serial communication with arduino and response on the application?

texts:
Currently, I'm doing a project as I want to use my Arduino Mega 2560 as an interface to my computer with a photo interrupter and stepper motor. So I need to send some commands and data to the Arduino from my PC. However, after upload the code to the board, I found out the serial communication of the Arduino quite slow. In fact, the moment after the code done uploading, my command in the Serial Monitor takes almost a second to execute. Below is the details about the code:-

    // Include the Arduino Stepper Library
#include <Stepper.h>

// Number of steps per output rotation
const int stepsPerRevolution = 200;

// Create Instance of Stepper library
Stepper myStepper(stepsPerRevolution, 12, 11, 10, 9);

int val;
int counter = 0;

void setup()
{
  // set the speed at 200rpm:

  myStepper.setSpeed(200);
  // initialize the serial port:
  Serial.begin(9600);
}

void loop()
{
  val = analogRead(A0);
  Serial.println(val);

  myStepper.step(stepsPerRevolution);
  counter = counter + 1;
  Serial.println(counter);

if (val > 200){
    Serial.println("it is running");

   } else {
    myStepper.setSpeed(0);
    Serial.println(counter);

   }

}

Any help so much appreciated.


texts: Integrating Freescale Multi Sensor board with Arduino

texts:
I recently bought Freescale's FRDM-FXS-MULTI-B, and have been trying to integrate it with an Arduino UNO. The board descriptions say that it has the shield layout that matches that of an Arduino shield. So in theory, I should be able to integrate it fine.

The problem comes when I plug it in and try to program the Arduino. As soon as I plug it in, the board resets and hangs. If I try to upload a simple code (just reading the analogue signal from the light sensor), the IDE hangs when uploading. Sometimes, I can fix it by removing the shield and pressing the reset button, but sometimes that doesn't work: the computer doesn't recognise the Arduino on the port, and the IDE removes the port from the Port Selection option. When I do remove it and it resumes functioning normally, and I re-attach the shield, the board resets and hangs again, until I go into the Serial Monitor.

With this board, I realised the Bluetooth module is connected to the Serial Receive pin, which explains the hang in the IDE, but I cannot understand why it resets and hangs when I plug it in.

Does anyone have any experience with this board, and can help me out? Why can I not find any tutorials online? With the multitude of sensors on this shield, I'm guessing you can access them via normal I2C and SPI communications, right? How do you use the Bluetooth module on the board?


texts: "char inChar = (char)Serial.read();" why is the "char" in brackets? and what is it called

texts:
I am sure this is a very simple answer, but I don't know to look it up on google

In the example "SerialEvent" in the arduino IDE (v1.8.7), there is the following function

    void serialEvent() {
        while (Serial.available()) {
           // get the new byte:
           char inChar = (char)Serial.read();
           // add it to the inputString:
           inputString += inChar;
           // if the incoming character is a newline, set a flag so the main loop can
           // do something about it:
           if (inChar == '\n') {
               stringComplete = true;
           }
        }
     }

On the third line "char inChar = (char)Serial.read();" the (char) is given in brackets before the serial read.
Why is this? and more specifically how is called ?


texts: How to delay so that LED stays on a bit longer?

texts:
I have a circuit with a shift register which controls 8 LEDs: http://node-ardx.org/exercises/5. In code, I created a function cycle() cycle through each LED one at a time, but this occurs too quickly on the board. How can I add a delay inside the loop so that each LED stays on for 500ms?

Here's my code:

var five = require("johnny-five"), board, shiftRegister;

board = new five.Board();

board.on("ready", function() {
  shiftRegister = new five.ShiftRegister({
    pins: {
      data: 2,
      clock: 3,
      latch: 4
    }
  });

  var bytes = [
    00000001,
    00000010,
    00000100,
    00001000,
    00010000,
    00100000,
    01000000,
    10000000,
    00000000
  ];

  function cycle() {
      for ( var i = 0; i < bytes.length; i++ ) {
          console.log(bytes[i]);
          shiftRegister.send(bytes[i]);
      }
    }

  this.repl.inject({
    sr: shiftRegister
  });

  cycle();

});


texts: Attiny13 project with leds and electret microphone

texts:
I want to make a project similar to this Turn Signal Biking Jacket

.

But, instead of using Arduino Lilypad I want to use an 8 pin attiny13A-SH and want to use one electret microphone instead of the buttons.

I want to use led's only for the left, right and a stop indicator(on the back, i don't want the leds on the sides like the instructable project).

According to me, the leds require 1 pin each and will share a common gnd(that's 4 pins).

The microphone will require 1 additional pin, with 1 going to the gnd (5 pins).

And I might require 2 pins for the power outlet (6 pins out of 8).

Now, i am a newbie in all this stuff so i don't want to go about experimenting with the chips. I am ready to disable the reset pin cause i wont require the chip again. I have got a couple of instructable's to help me in the programming and set-up plan(though they have used Arduino Uno or Lilypad), so I only want to know if it is possible to make the project with the attiny13a chip without the requirement of any additional parts.

Also, as an alternative, i wanted to use these leds instead of the lilypad led's, so i want to know if i can do the model in exactly the same way without using any mofsets etc(i just want 6 leds on each side). I'm extremely sorry for my horrible drawing(First time and no correct tools. used paint!)
ANY HELP IS APPRECIATED.


texts:
I've salvaged this small IR blaster+receiver board from an old computer toy:

As you can see the board was connected to the main unit via a 4-wire cable labelled like this:

LED (yellow) (I guess this is the IR LED/blaster)
IR (white) (I guess this is the IR receiver)
VCC (red)
GND (black)

I'd like to use this board with an Arduino library like IRremote, but I am not sure about the VCC voltage and whether I need to add more components on the Arduino side.

UPDATE:
I've checked the LED with a multimeter and indeed it is a visible bicolor LED, so there is no IR blaster in this board. At this point, is there any good reason to keep the IR receiver on the board rather than just cutting it and reusing as a standalone component?


texts:
I understand how to connect one ESP-12 to an Arduino, but it's possible to make the ESP-12 connect to two arduinos? I found a lot of information about the gpio as txd-rdx but not at the inverse.

Is possible to connect pins 21 & 22 to one arduino and 7 & 16 to another one? What condiderations must I have to?


texts: multiple multiplexer (4051) - how to process the inputs?

texts:
I have my Arduiono which has only a limited amount of Inputs/Outputs. But in my project I will have to attach a ton of potentiometers/buttons/LEDs, so I will have to use the IC4051-Multiplexer/Demultiplexer.

I have understood how to switch the Inputs/Outputs via the 3-Bits. But I don't get it, how to connect multiple ID4051s and process the signals(?)

Can someone explain that to me?


texts:
I built my own Arduino UNO for a project at school. I think I have got the USB bootloader and Windows drivers all situated as the UNO shows up as an UNO in the device manager. When I try to load a sketch I get the error: avrdude: stk500_getsync(): not in sync: resp=0x10. (previously I received the same message with the message ending with resp=0x00)

I loaded a serial echo program using the ICSP and sent the message "serial test" to the UNO. I received this message back: {u{m}o¿wu{w

Can anyone help me troubleshoot this problem as I have ran out of things to test or look into.

Thanks in advance.

Edit: Added requested pictures of TX and RX. These were taken at Pin 0 and 1 of the headers. The scope showed the same results at the pins of the 328P but I couldn't operate the scope and hold the probe at the same time.


texts: Arduino Leonardo board - not running or appearing a USB on external power

texts:
I've got an Leonardo board, it seems to be official, in that it has the Arduino branding and Made In Italy on the bottom.

However I cannot get anything to run with external power supply. Everything when powered via the USB from the computer runs fine. As soon as I use any sort of external power, and I've tried both the barrel jack with 4x AA batteries, 6x AA batteries, 9v square battery and a Shield with 2x 3.7v lithium batteries - it turns on but doesn't do anything - the USB device doesn't even appear to the computer at all unless I pull the external power out again.

Is this a faulty board? Do I need to change the jumper arrangement on the board so it'll run with external power?


texts:
I need to split up code which I've already developed for one micro into two different Arduinos connected by serial. The "remote" micro is directly connected to a 20x4 character LCD and the main micro will be sending it a command set to print, move cursor, etc.

My plan was to make functions that used existing code such as
lcd.print("This or that");
to replace the lcd library on the main micro and send command bytes and data bytes up to the remote micro. Seems pretty straightforward.

Then I discovered that apparently lcd.print cannot be a function name. Fine, so I changed it to lcd_print(). So far, so good. But in the existing library, lcd.print accepts strings, bytes, just about anything any length. For example:
lcd_print("any string of any length");
lcd_print(a_2d_array [x] [y]);
lcd_print(this_byte);
lcd_print(this_integer);

Now it's getting over my head. I know I can painstakingly turn a single function into many different functions, but wouldn't it be nice to replicate the functionality of the Arduino LCD library with a single command:

lcd.print();

Then all I have to do is create the function and keep the existing code and send the bytes up to the slave micro. Wouldn't that be nice! I appreciate any thoughts. Thanks.


texts: How to use Serial Monitor without Arduino board?

texts:
I want to use Arduino(atmega8) on breadboard using USBASP programmer and want to use Serial Monitor without using any Arduino board as ISP programmer.
My questions: 1. Is such thing possible?
2. How do I do that?


texts:
There is an error between an Arduino Uno and Arduino IDE 1.0.6 the error is :

stk500_getsync(): not in sync: rep=0x00

It is impossible to update any program to the Arduino
What is the origin of this issue and how to fix it ?


texts: Arduino Uno - Variables randomly changing

texts:
So I have a circuit for a timer (I don't think it is the problem)

Sorry for it being a little messy.

And I have this code (probably the problem):

// LiquidCrystal - Version: Latest
#include <LiquidCrystal.h>

/*

*/

const int switchUnitButton = 9;
const int selectButton = 10;
const int startButton = 8;
const int stopButton = 7;
const int d4 = 5;
const int d5 = 4;
const int d6 = 3;
const int d7 = 2;
const int rs = 12;
const int en = 11;
String unit = "sec";
int unitCycle = 1;
int secCount = 0;
int minCount = 0;
int hourCount = 0;
int dayCount = 0;
int switchUnitState;
int prevUnitState;
int selectState;
int prevSelectState;
int startState;
int prevStartState;
int stopState;
int prevStopState;
LiquidCrystal lcd = LiquidCrystal(rs, en, d4, d5, d6, d7);

void setup() {
  Serial.begin(9600);
  pinMode(switchUnitButton, INPUT);
  pinMode(selectButton, INPUT);
  pinMode(startButton, INPUT);
  pinMode(stopButton, INPUT);
  lcd.begin(16, 2);
  lcd.clear();
}

void loop() {

  switchUnitState = digitalRead(switchUnitButton);
  selectState = digitalRead(selectButton);
  startState = digitalRead(startButton);
  stopState = digitalRead(stopButton);

  if (switchUnitState == HIGH) {
    if (prevUnitState != switchUnitState) {
      if (unitCycle < 4) {
       unitCycle++;
      } else if (unitCycle == 4) {
       unitCycle = 1;
      }
    }
  }

  Serial.print(unitCycle + "\n");

  if (unitCycle == 1) {
    unit = "sec";
  } else if (unitCycle == 2) {
    unit = "min";
  } else if (unitCycle == 3) {
    unit = "hour";
  } else {
    unit = "day";
  }

  Serial.print(unit + "\n");

  if (selectState == HIGH) {
    if (prevSelectState != selectState) {
      if (unit == "day") {
        dayCount++;
      } else if (unit == "sec") {
        secCount++;
      } else if (unit == "hour") {
        hourCount++;
      } else if (unit == "min") {
        minCount++;
      }
    }
  }

  lcd.setCursor(0, 0);
  lcd.print("Sec: " + String(secCount) + " Min: " + String(minCount));
  lcd.setCursor(0, 1);
  lcd.print("Hr: " + String(hourCount) + " Day: " + String(dayCount));

  prevUnitState = switchUnitState;
  prevSelectState = selectState;
  prevStartState = startState;
  prevStopState = stopState;
}

And sometimes without me clicking a button the unit value changes or sometimes when I click the selectButton for the amount to go up it changes which unit it is adding to. And sometimes the string has parts before it from other units like "inhour" what is happening?


texts:
Not a pure Arduino question really. I'm actually using a standalone ATmega168. So far I've been using AVR-ISP programmer (working from AVR Studio) to program the chip. After everything is done, the chip will be covered and I will only have access to the I2C pins. The MISO,MOSI, etc pins will be unreachable.

I was just wondering if there was a way to use the I2C pins to update the program that is burned on the chip. I won't need to burn the bootloader again, but just to update the program if it needs to be.


texts: Cannot send any UDP packets from ESP8266 Wemos D1

texts:
I am attempting to send sensor data from a battery-powered device using UDP. The goal is to send a datagram immediately after the wifi station awakes from sleep then immediately go back to sleep after writing the datagram to a given IP address or hostname.
I can send data to Thingspeak's API using their library so I know the device works, but when attempting to use the WiFiUDP library to send a datagram to an IP address on the same LAN I see nothing happen. My device is getting on the wifi and the udp.endPacket() command is returning successful, but I am not receiving the packets on the server. I know the server works because I can use nc to send UDP packets from other machines on the LAN.
Here is my sketch with the irrelevant bits redacted.
// https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/station-class.html
#include <ESP8266WiFi.h>
// https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/udp-examples.html
#include <WiFiUdp.h>

// Create udp class instance
WiFiUDP udp;

void setup() {
  Serial.begin(115200);
  Serial.print("Connecting to WiFi");
  WiFi.mode(WIFI_STA);
  WiFi.hostname(hostname);
  WiFi.begin(ssid, pass);

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

  Serial.print("SSID:\t");
  Serial.println(WiFi.SSID());

  Serial.print("IP address:\t");
  Serial.println(WiFi.localIP());

  Serial.print("Gateway:\t");
  Serial.println(WiFi.gatewayIP());

  uint8_t buffer[50] = "hello world";
  char message[] = "hello world 2";

  IPAddress staticIP(192, 168, 1, 118);
  udp.beginPacket(staticIP, 3381);
  udp.write(buffer, 11);
  //udp.write(message);
  udp.endPacket();

  // Calculate required sleep time and go to sleep
  long sleepTime = measurementInterval - millis(); // in milliseconds
  if (sleepTime < 100) sleepTime = 100; // set minimum sleep of 0.1 second
  Serial.print ("Going to sleep now for ");
  Serial.print((float)sleepTime / 1000, 3);
  Serial.println (" seconds.");
  Serial.print ("Time going to sleep=");
  Serial.print ((float)millis() / 1000, 3);
  ESP.deepSleep(sleepTime * 5000); // convert to microseconds
}

And my node server just to be complete here:
const dgram = require('dgram')
const server = dgram.createSocket('udp4')

server.on('error', (err) => {
  console.log(`server error:\n${err.stack}`)
  server.close()
})

server.on('message', (msg, rinfo) => {
  console.log(`got message from ${rinfo.address}:${rinfo.port} - ${msg}`)
})

server.on('listening', () => {
  const address = server.address()
  console.log(`server listening ${address.address}:${address.port}`)
})

server.bind(3381)

I've also tried adding delays between each function to no avail.


texts:
This is my first time working on Arduino for my project and I ran into an issue. I'm trying to make a very simple Vending Machine. Coin or any obstacle passes in front of the IR sensor and based on that, the user can either press button 1 or 2 and based on that motor 1 or 2 would run respectively.
The overall logic works exactly how I want it to, the issue I'm facing is that the variable (sensorStatus) storing the IR sensor value isn't working correctly. Whether anything passes in front of it or not, it lets me press the buttons anyways and the motor starts working.
void loop() {

  int sensorStatus;

  //this is where im having the issue
  if (digitalRead(inSensor) == LOW) sensorStatus = LOW;

  if(sensorStatus == LOW) {
      buttonStatus1 = digitalRead(inButton1);

      if(buttonStatus1 == HIGH) {
        digitalWrite(relayControl1_1, LOW);
      } else {
        digitalWrite(relayControl1_1, HIGH);
      }

      buttonStatus2 = digitalRead(inButton2);

      if(buttonStatus2 == HIGH) {
        digitalWrite(relayControl2_1, LOW);
      } else {
        digitalWrite(relayControl2_1, HIGH);
      }

      sensorStatus = HIGH;
   }
}

If I don't use this logic and store the value of the sensor directly into the variable (sensorStatus), the whole program seems to be working till I have an obstacle in front of the sensor continuously. I don't want this to happen, I want it to work in such a way that once an obstacle passes in front of the sensor it keeps the value (even after the obstacle is gone) until a button is pressed and after that, it gets rid of the value to repeat the process once again. It seems to be a code logic issue but I can't seem to figure out the logic behind it.
My Complete Source Code:
const int relayControl1_1 = 13; // relay 1 of 1 (input 1)
const int relayControl1_2 = 12; // relay 1 of 2 (input 2)
const int relayControl2_1 = 11; // relay 2 of 1 (input 3)
const int relayControl2_2 = 10; // relay 2 of 2 (input 4)

const int inButton1 = 9; //input button 1
const int inButton2 = 8; //input button 2

int buttonStatus1 = 0;
int buttonStatus2 = 0;

const int inSensor = 7;

void setup() {
  Serial.begin(9600);
  pinMode(relayControl1_1, OUTPUT);
  pinMode(relayControl1_2, OUTPUT);
  pinMode(relayControl2_1, OUTPUT);
  pinMode(relayControl2_2, OUTPUT);

  pinMode(inButton1, INPUT_PULLUP);
  pinMode(inButton2, INPUT_PULLUP);

  pinMode(inSensor, INPUT_PULLUP);

}

void loop() {

  int sensorStatus;

  //this is where im having the issue
  if (digitalRead(inSensor) == LOW) sensorStatus = LOW;

  if(sensorStatus == LOW) {
      buttonStatus1 = digitalRead(inButton1);

      if(buttonStatus1 == HIGH) {
        digitalWrite(relayControl1_1, LOW);
      } else {
        digitalWrite(relayControl1_1, HIGH);
      }

      buttonStatus2 = digitalRead(inButton2);

      if(buttonStatus2 == HIGH) {
        digitalWrite(relayControl2_1, LOW);
      } else {
        digitalWrite(relayControl2_1, HIGH);
      }

      sensorStatus = HIGH;
   }
}


texts: Are there any ePaper modules that are bigger than 2.7 inches for arduino

texts:
I am looking for a large ePaper Display for the Arduino. The issue is is that I cannot seem to find one any larger than 4.5 inches in size. That will be compatible with arduino. Even with a controller board.

Are there any companies that sell controller boards for these displays? Is there anyone who can manufacture these epd displays upon request?

I am looking to take this project to a pcb board after I prototype it so do I need to build my own controller? If what parts would you need? Is it easy for a designer with intermediate capability?

I can find all kinds of display like at pervasivedisplays.com and Mouser.com

The end goal is to create a Arduino based project that I can score skeet with to keep track of my average score.


texts: Need Help in circuit diagram of 8*8 reed switch matrix

texts:
I am designing 8*8 reed switch matrix which will be connected to Arduino. I am using Arduino Duemilanove. I have completed the matrix portion but don't know how to connect and where to connect the other elements.

I decided to use the following items:

Arduino (Duemilanove)
64x Reed Switch
64x Diode (1N4148)
20x Resistors (10K)
1x 74HC595
1x 74HC165

I don't know where to place the Resistors and shift Registers and connection from shift registers to arduino. I need help in the circuit diagram. Please help me out with the circuit diagram.

Reference: https://mtifall10.wordpress.com/2010/12/10/magnetic-sensing-chessboard/