texts:
I wrote this sketch along with an HC - SR 04 Ultrasonic transducer and a DC motor. Whenever the HC-SR 04 reads any distance less than 15 cm, the motor stops, otherwise it keeps running.

The problem is whenever I upload the sketch, the motor runs for a short while and stops. Then when I open my serial monitor, the motor runs until an object crosses the 15 cm threshold and stops right after the limit is crossed. But when I again put the object outside of the 15 cm range, the motor should start running again, but it doesn't.

I am using a this motor driver and a simple DC motor(12V).
Here's the code-

int trigPin1 = A0;
int echoPin1 = A1;
int distance1 = 0;
int E1 = 10;
int brake1 = 7;

void setup() {
  pinMode(trigPin1, OUTPUT);
  pinMode(echoPin1, INPUT);
  pinMode(brake1, OUTPUT);
  pinMode (E1, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  analogWrite(E1, 153);
  distance1 = getDistance(trigPin1, echoPin1);
  printDistance(1, distance1);
  delay(250);
  if(distance1 <=15){
    digitalWrite(brake1, HIGH);
  }
  else{
    analogWrite(E1, 153);
  }

}

int getDistance (int initPin, int echoPin) {
  digitalWrite(initPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(initPin, LOW);
  long pulseTime = pulseIn(echoPin, HIGH);
  int distance = pulseTime / 58.2;
  return distance;
}

void printDistance(int id, int dist) {

  Serial.print(id);
  if (dist >= 120 || dist <= 0 ) {
  Serial.println(" Out of range");
  }
  else{
   Serial.print("\t");
   Serial.print(dist);
   Serial.println(" cm");
}
}

What mistake am I doing? Moreover I am currently running it with one motor, I'll add another later on along with more sensors, so the motors are controlled by the left or right sensor. How do I make my code work with them?

Thanks...


texts: Solution to interrupt Arduino every n seconds

texts:
I'm a very beginner with electronics and of course with Arduino. Actually I've been in the software field (.NET) for the past 12 years. I am trying to develop a simple system to run for longer using Arduino Nano. Longer means roughly it could be for years continuously, expecting normal wear and tear.

So what I understood is Arduino loop always executes based on any values from sensors while in the loop. And also Arduino has some interrupt mechanism too.

But since the looping system feels pretty awkward for some situations, I tried to stop the loop using exit(0); inside the loop. So loop will stop  after the first execution.

I am trying to build an external simple interrupt hardware system (like any timer object in software) which interrupts Arduino in a specified interval, say 20 sec. So when that interrupt on that particular pin occurred we can call some function there to do the job and that's all from Arduino side and it can go back to sleep.

So I believe this will reduce the load on Arduino and of course since no looping it will not get heated at all. How can we make such a system (external timer) to interrupt Arduino in specific intervals? This is just a theory in mine, not an idea how to implement it in electronics.

How can I achieve this above scenario?


texts: Running stepper motor for specified no. of turns with Arduino?

texts:
I hope you are doing well.
I want to run a pretty big stepper motor for a specified number of turns, take, for instance, 25. Easy! But not for a beginner with Arduino and I'm not an electrician!
Here is my purpose once again: Rotate my stepper motor for 25 rounds at the maximum speed possible.
Here is a similar circuit that I found on the internet. If you ignore the potentiometer, that would be my circuit!

I think my purpose in kind of simple. But I don't know anything about the code. I would appreciate any advice or helpful complementary code! :)


texts: Can the following materials be used to power up an attendance based sensor?

texts: arduino uno, esp8266, rfid module rc522, sd card module, real time clock module, buzzer, led light and battery holder. I was planning to build a sensor that monitors attendance with the use of and RFID card, and I was planning to make it run on its own with the help of a battery instead of being connected to a computer. If not, is there another way that would be possible?


texts:
For my engineering class, I am designing a digital scale.  I have already made a working proof-of-concept by using jumper wires to connect several arduino modules to an Arduino UNO.

I want to make a PCB to simplify the design, and not just have a mess of arduino modules.  I want the design to be flat and small, so I need to make a custom PCB, integrating each module onto the board.  Say I'm not using a protoboard, but sending it to a company to get it custom manufactured.  This PCB would use through-hole components, and not SMD.

I am trying to build the eagle files for the PCB.  I have rounded up the SCH file for each arduino module, and the arduino itself.

I am trying to make this PCB in the easiest and fastest way possible.

Should I just copy and paste, and connect the modules' SCH files into one big SCH file?  Then create a BRD file to create the proper footprints and holes?

Thanks


texts: Why doesn't the master branch BOSSA work on Arduino Due?

texts:
I have downloaded BOSSA for Linux, and have run bossash->scan. I have also tried erasing and resetting the board before scanning. It does not work. According to the Arduino website, the native USB port is connected directly to the chip.

Isn't the master branch BOSSA (Arduino IDE uses it's own modified version of BOSSA) working because of a problem with this specific board, or have Arduino modified something inside the chip which alters the behaviour of the native port?


texts: Velux shutter with IO-Homecontrol control over ESP32

texts:
I want to controll my Velux shutter with an ESP32 and an transmitter-receiver.
I know that the bandwidth is 868 MHz but the problem is the IO-Homekitprotocol, I've read that it has pan 128bit key like an bank an ATM but I only want to emulate the remote control.
So I work with this libary https://github.com/LSatan/SmartRC-CC1101-Driver-Lib but I have no clue how to get the data from an remote control in an 868 MHz bandwith.
So is there anyone who know something about this and can help me to get the data from the remote control?


texts: Arduino and PHP communication only work if I open the Arduino IDE

texts:
I have a problem. I try to open a channel to arduino and PHP talk, the PHP would send a command and the Arduino should answer that. It works, but only if I execute some steps before:

sudo chmod 777 /dev/ttyACM0
sudo arduino
Open the serial monitor in arduino IDE
Close the serial monitor
Now everything is ok, they can talk

The first step is ok, I really need to do this, the 2-4 seems irrelevant, but the communication do not start without it. I put one LCD in arduino to print what he receive, when I send "HEYARD" with PHP to him, the RX led blinks and the TX led also, but nothing is printed on LCD. If I do the 2-4 steps, when PHP send "HEYARD", LCD show HEYARD and arduino answer with "HEYPHP"

Anyone could help? There is some way to open it via Terminal, or, at least, open the Serial Monitor from arduino and close to see if this start


texts: Is the DHT.h library compatible with ESP8266 Arduino IDE compiler?

texts:
I'm using the following 'compiler' to program my ESP8266-01 direct with Arduino IDE:

https://github.com/esp8266/Arduino

and I'm trying to read the temperature and humidity with the following library:

https://github.com/adafruit/DHT-sensor-library

since the DHT library was developed to be used on an Arduino board, should I be able to run it on the ESP8266?


texts: How to remove the 5 second boot delay on Digispark PRO (Attiny167)

texts:
I know there’s already a solution for removing the 5 seconds boot delay on Digispark (Attiny85), by writing a new bootloader someone already did to the Digispark. And to write code to it, you need to ground one pin.

This delay exists so the Attiny85, when powered on, waits for USB programming. Only after 5 seconds it will run the code written to it..

But I can’t find information on how to remove this 5 second delay on the Attiny167 - Digispark PRO.

Could the same modified bootloader of the Attiny85 be burned on the 167?

Or is there any other way to do it?

Thanks a lot!


texts: Connect Arduino via TX RX Pins to Computer's USB Port

texts:
I want to avoid using the big USB B connector to program my Arduino Mega. Since there are those RX TX Pins I thought, it would be possible, to connect my USB - Wires from my PC directly to those RX TX Pins. D+ -> TX and D- RX. This Post on Arduino Stackexchange says, those wires are just connected, while this post says the exact opposite.

I'm confused. Is it possible or would I damage my board when connecting USB wireq to RX / TX pins on my Arduino?


texts: When I turn on the servo it spins on its own before going to the right position and start the sketch

texts:
I can't get my head around this: when I turn the servo on it just spins on its own as if it's setting up, it goes to an angle superior to the one I want it to go. (Don't mind if it has to set up but it can't spin more than 20 degrees which is currently doing).

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos = 0;    // variable to store the servo position

int degrees_of_motion = 20;
int servo_speed = 88;

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

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


texts: I2C Temperature Sensor Communication Issue

texts:
I'm currently learning I2C and having some issues displaying the correct temperature in the serial monitor.

I am using an Arduino Uno and an SI7021 temperature sensor from Sparkfun; here's the datasheet I'm looking at.

The datasheet says that its device address is 0x40 and the temperature register is 0xF3 (maybe I am looking at this wrong?). However when I print the result to the screen it reads -1 degrees F.

Here's my code:

// SparkFun Si7021 Humidity and Temperature Sensor
#include <SparkFun_Si7021_Breakout_Library.h>
#include <Wire.h>

//Weather sensor slave address
int WeatherAddress = 0x40;

#define Temperature_Register_DATA 0xF3

//initialize humidity and temperature variables
float humidity = 0;
float tempf = 0;

//create a sensor from the Weather library
Weather temp_rh_sensor;

void setup() {
  Serial.begin(9600);
  //create wire object
  Wire.begin();
  //begin weather sensor
  temp_rh_sensor.begin();
}

void loop() {
  //begin transmission to weather sensor
  Wire.beginTransmission(WeatherAddress);
  //ask particular register for data (temperature register)
  Wire.write(Temperature_Register_DATA);
  Wire.endTransmission();
  //request the transmitted single byte from the register
  Wire.requestFrom(Temperature_Register_DATA, 1);
  if(Wire.available() <= 1) {
    tempf = Wire.read();
  }
  Serial.print("Temp: ");
  Serial.print(tempf);
  Serial.println("F, ");
  delay(1000);
}


texts: Raspberry Pi, Teensy and Arduino's on i2c

texts:
I just got into an interesting mess.

I have 3 Arduino's (Pro Mini's) and 2x Teensy's (3.1's) connected via I2C to a Raspberry Pi Master. The 2x Teensy's I2C data lines are connected via OctoBoards but that doesn't really matter since the OctoBoard maps the I2C Pin's of the Teensy to itself. I have 4k7 pullup resistors for SDA/SLC close to the master (also tried on the end - with no effect).

The Arduino's alone are super solid - no issues other than the occasionally I2C lockup when writing data.

The I2C interface has been running for over 3h with no problems.

Now as soon I add a Teensy to it, the bus locks-up and I need to completely shut down everything. Only thing I got to work was direct connection from RPI -> Teensy and even then there were sporadic detection issues.

I tried the Wire lib as well the IC2_T3 lib with no difference. Also tried with 4 different Teensy's with no difference.

Are the Teensy's not compatible with RPI?


texts: Sensor for very low temperature (liquid nitrogen)

texts:
I'm looking for a way to measure temperatures in range of 40 to -200 °C (100 to −320 °F). The usual solution DS18B20 works only down to -55 °C (-67 °F).

Any ideas?

p.s.
Precision of 2 °C would be good enough.


texts: ATmega 32A and 2560 R3 register to pin mapping?

texts:
I've been doing research for the last few hours trying to determine the mapping of physical pins to memory-mapped I/O registers for the Arduino Mega board (which is an ATmega 2560 R3).

My code is on GitHub in a pull request, but hasn't been merged yet because I'm not finished yet.
This is the upstream example I'm working from, which was written for an ATmega 32A.
Here is Arduino's 2560 pin mapping which doesn't tell which registers are mapped to which pins.
Here is avr/iomxx0_1.h which defines the ports with simple numbers that I can't make heads or tails of.
Here is a collection of links relevant to my research.
I broke down and cross-referenced all of the uses of memory-mapped I/O registers in the upstream example.

Some of the registers used include CS11, DDB4, DDRA, DDRB, GICR, INT0, INT1, ISC00, ISC10, MCUCR, PA0, PB5, PB7, PD2, PD3, PIND, PORTA, PORTD, SPCR, SPDR, SPIF, SPSR, TCCR1B, and TCNT1. I can't figure out which pins these are and/or what they do.

Here is a diagram provided by the upstream example:

Unfortunately, I'm not very good at reading these diagrams so I'm doing my best.

How can I determine the mapping of these registers to physical ports on both the ATmega 32A, which is the board the example was originally written for, and the ATmega 2560 R3, which is the board I'm currently working with?


texts: Wireless Bluetooth USB HUB using Arduino nano

texts:
I have the following problem/idea:

I have a electronics workbench and a separate PC desk. Now I have a USB HUB on the workbench, but it doesn't properly work, because the USB-cable to the pc is too long. My setup doesnt really allow me to put the PC somewhere else and the USB-hub is already mounted in the closest usable location.

A few days ago I remembered that I have a arduino nano with a hc-05 bluetooth module attached to its hardware serial port. And as both bluetooth and USB are serial connections I was wondering if I couldn't use the arduino sort of as a middle man and connect the arduino via bluetooth to the pc. Then have a software on the pc that registers the arduino as a USB hub with one port and run some code on the arduino that basically makes the arduino act as a USB host (I know that this is possible with the arduino nano) and have it just move data between the USB connection and the bluetooth module.

Im quite sure that all this should be possible. The atmega should even be capable of doing so at or close to maximum USB 2.0 data rates as that is only 12 Mbit/s and it can run at 16 MHz when powered with 5V. Im not quite sure about the maximum data rate for the bluetooth module though, but I can work with a little lower speeds...

The software for the pc could also be relatively straight forward. Something like a virtual USB-port and the software just shifting data from the com-port that is the bluetooth to this virtual USB-port.

So thats the idea. I have some experience in both programming microcontrollers and software for pc.

So what I need is a bit of help with this, as I am not quite sure how to accomplish this.

The parts that I will need the most help with are going to be the programming of the USB host on the arduino and the virtual USB-port on the pc.

The rest should be relatively easy as its basically just shifting data from one register into another.


texts: Connect one HC-05 "master" to two slaves at the same time

texts:
Does any one know what AT+CMODE=2 "slave loop" used for. As I try to connect one HC-05 master to two slaves using it, but it didn't work.
i donot know if AT+cmode=2 is used for connecting to multiple slaves or not as i want to know what is used for , i tried to understand what it do from the HC-05 datasheet but i didnot find anything useful about it excpet for what is this image


texts: Arduino Leonardo - disabling the debugger port

texts:
My Sketch program is working perfectly as a specialized keyboard application on the Leonardo. I want to disable the development tools drivers from the USB, (COM PORT) leaving only the HID Keyboard drivers.  I understand I will need to use the Arduino ISP or other method to load my code.

Is there any way to disable the drivers for the development tools from the on board USB, leaving just the HID drivers?


texts:
I've been using my Arduino UNO without a hith for a few days now, but suddenly I can't program it anymore.

When I try to programm my Arduino on Mac, I get the following Error:

avrdude: stk500_recv(): programmer is not responding

The USB option under serial port has disappeard (It was there before). Has anyone an idea on how to fix this?

The last thing I did is use the serial port for some communication. A reboot hasn't improved anything.

I tried programming Linux, but it resulted in the exact same result.


texts:
i am trying to compare the elements of two arrays before the code goes on to the next sequence. The elements of note[x] are filled with the note values of a song. and i want to be able to input values from a midi controller into learn[x]. how can i compare array learn[ ]  to array note[ ] before the showsequence(); is incremented?

 const int x = 100;
    int note[x];
    int learn[x];
    int largestindex = 0;
    int learnindex=0;
    void showsequence();
    void readsequnce();
    const int PLAY = 1;
    const int TRYAGIN = 2;
    int state=0;

 void loop() {
     if (state == PLAY) {
        showsequence();
        readsequnce();
      }
      else if (state == TRYAGIN) {
        incorrect();
       }
     MIDI.read();
    }
    void MyHandleNoteOn(byte channel, byte pitch, byte velocity) {
    learn[learnindex]=pitch;
     learnindex++;
    }

 void showsequence() {
      //Add a new index to the end of the songseq
      SongSeq[largestindex];
      largestindex++;
      //loop through the songseq
      for (int index = 0; index < largestindex; index++) {
        SongSeq[index]();
      }
    }

      void readsequnce() {
      static uint16_t nextkey;
      bool mademistake = false;
       nextkey=0;
       learnindex=0;

       if (array_cmp(learn, note, largestindex, largestindex) == true){
               // do this if they are equal
               lcd.setCursor(16, 2);
        lcd.print("True");
         }else{
               // do this if they are different
               lcd.setCursor(16, 2);
        lcd.print("False");
         }
    }

 boolean array_cmp(int *a, int *b, int len_a, int len_b){
         int n;

         // if their lengths are different, return false
         if (len_a != len_b) return false;

         // test each element to be the same. if not, return false
         for (n=0;n<len_a;n++) if (a[n]!=b[n]) return false;

         //ok, if we have not returned yet, they are equal :)
         return true;
    }


texts:
How would I establish a serial connection with python without using the serial monitor?

What I want to do is give my python script some input and have the arduino do something (blink for example)

I also want to be able to read in data with the arduino to give it to my python script.

What modules for python would be useful? I'm just starting out and don't have much of an idea for this one.

I am using a windows7 machine with python 2.7.6 and have an UNO board and a Leonardo board that I want to be able to use.


texts: ESP8266 connected to a HIGH pin and DPDT only works sometimes. Works everytime if connected to 3V3 pin

texts:
I have a Wemos D1 Mini hooked up to a DS2Y-S-DC3V DPDT switch.
When I have the coil ends are hooked up to a pin (D2) and ground, it will click when I set the pin HIGH. It should click again when it goes low, and then again with high, etc. But after while, it stops responding. Measuring the voltage while hooked up to the DPDT is 1.7 V.  When disconnected from the DPDT, the D2 pin and Ground voltage is as expected, 3.3V.
However, if I connect the DPDT terminals to the ESP's 3V3 pin and G, it works all day as many times as I wish.
I have multiple DPDTs. And two of the 6 don't work as expected. Why does it work when I directly hook it up to 3v terminal but not a HIGH pin? Shouldn't both be 3v?

Any ideas?


texts:
Sorry for novice question in Arduino, but I'm trying to figure out why res is keeping its value when up_cmd0 is being called again.

for example - if num=8 in first run and the result is :up_cmd0_res: 8, and second run num=12, the result is: up_cmd0_res: 812

void up_cmd0(){
  char num[8];
  char *res = "up_cmd0_res:";
  itoa(counter2, num, 10);
  strcat(res ,num);
  client.publish(inTopic,res);


texts: Zero-ing Compass | Following Magnet Strip Robot

texts:
So my problem is purely programming, I understand the problem but can't figure out what to do, Is there a library? should I create my own code for Zero-ing my compass so I don't have value from earth field in my equasion?

I have a small robot that I want it to follow a refrigerator magnet strip that is incrustated in floor
The compass on its own works well but I want to be able to drive my robots by a positive or negative value that I would receive from a library/function I coded off values from library of compass

The actual problem is that earth magnetic field will offset my value

Lets say north is on the left and magenet is also on the left. I should receive for example -1000 Gauss
but then if I put the magnet to the right but keep the same oriantationg of the magnet I will receive -500 when I really wanted 500 for example.

Now id like to take a measurement of earth magnetic field first and from there subtract current value off the actual values i get.
But my understanding of vector is very limited.

Doing this for a compass that its oriantation don't change would be pretty simple but, in my case compass will be mounted on robot itself therefore orientation will change all the time

Im not looking for some code but more a general idea on how to do this, either by using a library or some maths idea on how to acheive that.


texts:
I am trying to read the pH value from a analog pH meter, SEN-01454. From the source code I found, voltage maps to pH value. This is the code:

pHArray[pHArrayIndex++]=analogRead(SensorPin);
      if(pHArrayIndex==ArrayLenth)pHArrayIndex=0;
      voltage = avergearray(pHArray, ArrayLenth)*5.0/1024;
      pHValue = 3.5*voltage+Offset;
      samplingTime=millis();

But then the value is not correct. So how do i actually do it.

The example code from Wiki page for product.


texts: I want to run jvm on arduino.What minimum configuration do I need?

texts: If Arduino IDE itself is built on Java can I run JVM on the Arduino? If yes how should I do it?


texts: ESP8266 Arduino Json object array deserialisation into struct

texts:
I'm trying to de serialize an array of JSON objects into a struct.
Following the instructions given by the Arduino JSON assistant, I managed to produce this helper function:
void JsonPreprocessor(const char* buf)
{
  StaticJsonDocument<96> filter;

  JsonObject filter_ResponseData_Metros_0 = filter["ResponseData"]["Metros"].createNestedObject();
  filter_ResponseData_Metros_0["Destination"] = true;
  filter_ResponseData_Metros_0["ExpectedDateTime"] = true;
  filter_ResponseData_Metros_0["Deviations"] = true;

  StaticJsonDocument<512> doc;

  DeserializationError error = deserializeJson(doc, buf, DeserializationOption::Filter(filter));

  if (error) {
    Serial.print(F("deserializeJson() failed: "));
    Serial.println(error.f_str());
    return;
  }

  JsonArray ResponseData_Metros = doc["ResponseData"]["Metros"];
  for (int i = 0; i < MAX_ELEMENTS; i++)
  {
    strcpy(dep_arr[i].destination, ResponseData_Metros[i]["Destination"]);
    strcpy(dep_arr[i].destination, ResponseData_Metros[i]["ExpectedDateTime"]);
  }
}

The function writes into an array of structs declared like this:
struct Departure {
   char* destination;
   char* departure;
   int  deviation;
} depart;

struct Departure dep_arr[MAX_ELEMENTS];

And the JSON passed as a constant character array to the preprocessor function. Uploading and running this function keeps crashing my ESP8266 without any debug output. Without posting the whole json object, which is long enough as is without the filters, My object array in JSON looks similar to this after filtering:
{
  "ResponseData": {
    "Metros": [
      {
        "Destination": "Destination_1",
        "ExpectedDateTime": "2021-04-29T05:15:30",
        "Deviations": 1
      },
      {
        "Destination": "Destination_2",
        "ExpectedDateTime": "2021-04-29T05:21:30"
      },
      {
        "Destination": "Destination_2",
        "ExpectedDateTime": "2021-04-29T05:30:30"
      },
      {
        "Destination": "Destination_1",
        "ExpectedDateTime": "2021-04-29T05:36:30"
      },
      etc...
    ]
  }
}

In my test code I've defined my MAX_ELEMENTS macro to be 3.
I'm at a complete loss due to not having any debug output. I'm using ArduinoJson6 and my code is written and compiled on Arduino IDE 2.0.0-beta.5


texts: Why perform bitwise operations here? (SPI FRAM read method)

texts:
See: https://github.com/adafruit/Adafruit_FRAM_SPI/blob/master/Adafruit_FRAM_SPI.cpp
The following method reads and converts the input to 8 bit. I have several questions concerning its function.

Using addr = 0xFFFF as an example, the method converts the variable to 0xFF. I understand that bits are removed from the end, but surely 65535 != 255. Perhaps relatively, to their max size, but how is this a useful conversion? I might be missing something about bitwise here..

uint8_t Adafruit_FRAM_SPI::read8 (uint16_t addr)
{
 digitalWrite(_cs, LOW);
 SPItransfer(OPCODE_READ); //read memory from fram array (2-byte)
 SPItransfer((uint8_t)(addr >> 8));
 SPItransfer((uint8_t)(addr & 0xFF));
 uint8_t x = SPItransfer(0);
 digitalWrite(_cs, HIGH);
 return x;
}

Correct me if I'm wrong, the casting is to keep sign extension from occurring.

The masking I understand in theory, but do not at all understand its application here.

Finally, it always returns the same value x = 0, why?

I also see there's a write method but no read method. Only read8. Reasoning?


texts:
I need an Arduino Mega 2560 (that is the one that has more pins). I went to eBay and there are a lot of different boards. I'm thinking of buying an ATmega2560-16AU CH340G MEGA 2560 R3 Board + Free USB Cable for Arduino
. Is this one good? I mean, does it do the work? Is it compatible with the Arduino IDE? Anything I need to know?


texts: What does display.setSegments(&segto, 1, 1); do?

texts:
I am using a TM1637 display for my Arduino Uno. The goal was to just light up one point of the colon in the middle - what seems to be kind of impossible to accomplish. During research I stumbled over the following snippet, which I dont fully understand:
  uint8_t segto;
  int value = 1244;
  segto = 0x80 | display.encodeDigit((value/100)%10);
  display.setSegments(&segto, 1, 1);

Ok line 1 seems to declare s.th. like a char, an unsigned 8bit integer. Line 2 should be clear.
Line 3: The pipe symbol seems to do a kind of addition - never seen this before. The rest here is also not clear to me - why these strange calculation to pass a value (here 2) to .encodeDigit() ?
Finally line 4: Why is the adress of 'segto' passed to the function instead of just the value?
This all ends up showing a "2:" on the display. I got the snippet from this 'manual': https://robojax.com/learn/arduino/robojax-TM1637_display_manual.pdf
Maybe s.o. can help to light things up a bit


texts: http.POST is not sending data to local web page

texts:
I am using a nodeMCU to send data to my local web page developed using Spring boot but when I run the code I don't get an error the esp8266 connects to WiFi but I don't get anything on my spring boot app or any responses.
Here is the rest controller used from spring boot

@RestController
@RequestMapping("/getallcadres")
public class cadreController {
    @Autowired
    cadreRepository cadre;

@PostMapping("/getnbpassage")
    public String getnbrpassage(@RequestBody String nb){
        System.out.println("nombre de passage = "+nb);
        return "received";

    }
}

and the Arduino code

#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>

void setup() {

  Serial.begin(9600);//Serial connection
  WiFi.disconnect();
  WiFi.begin("Iphone de elaa", "27343550");   //WiFi connection

  while (WiFi.status() != WL_CONNECTED) {  //Wait for the WiFI connection completion

    delay(500);
    Serial.println("Waiting for connection");

  }
  Serial.println("Wifi is connected");
  Serial.println(WiFi.localIP());

}

void loop() {

 if(WiFi.status()== WL_CONNECTED){   //Check WiFi connection status
 Serial.println("here we start");
   HTTPClient http;    //Declare object of class HTTPClient

   http.begin("http://localhost:8080/getallcadres/getnbpassage");      //Specify request destination
   http.addHeader("Content-Type", "text/plain");  //Specify content-type header

   int httpCode = http.POST("5");   //Send the request
   String payload = http.getString();//Get the response payload

   Serial.println("return code"+httpCode);   //Print HTTP return code
   Serial.println(payload);    //Print request response payload

   http.end();  //Close connection

 }else{

    Serial.println("Error in WiFi connection");

 }

  delay(30000);  //Send a request every 30 seconds

}

I am using Arduino IDE 1.6.5 here is what I get


texts: Noob here.. Need help with a thermostat controlled relay

texts:
So After trying several sketches for a LM35 and none working I finally found one that was giving me accurate results. The problem is the code is way over my head. I was able to modify it enough to get the serial and temperature to a LCD but I cant figure out why its not tripping the relay after set values. The sketch completely ignores the temperature value therefor will never set the relay HIGH. What am I missing?

/*
 LM35 thermometer, no floats, no delays

  http://www.ti.com/lit/gpn/lm35
*/
const int relay = 0;
const byte sampleBin = 8, // number of samples for smoothing
           aInPin = A5;
const int fudge = 170; // adjust for calibration
const int kAref = 1090, // analog ref voltage * 1000
          kSampleBin = sampleBin * 1000,
          tEnd = 5000; // update time in mS
int tempC,
    tempF;
uint32_t total,  // sum of samples
         tStart; // timer start
int sensorPin = 5;// The analog pin the LM35's Vout is connected to.

#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

/*
Initialize serial connection with the computer*/
void setup()
{
  pinMode(relay, OUTPUT);
  Serial.begin(9600);
  lcd.begin(16,2);
  analogReference(INTERNAL); // use 1.1V internal ref
  analogRead(aInPin);
  for (int i = 0; i < sampleBin; i++) // for smoothing, fill total
    total += analogRead(aInPin);   // with sampleBin * current
                                   // reading
}

void loop()
{
  if (millis() - tStart > tEnd)
  {
    tStart = millis(); // reset timer
    total -= (total / sampleBin); // make room for new reading
    total += analogRead(aInPin); // add new reading
    tempC = total * kAref / (kSampleBin + fudge);
    tempF = (tempC * 18 + 3200) / 10;
    Serial.print("Temperature- ");
    prntTemp(tempF);
    Serial.println();
  }
}

void prntTemp(int temp)
{
  Serial.print(temp / 10); // whole degrees
  Serial.print(".");
  Serial.print(temp % 10); // tenths
  Serial.print("\t");

  // display Temperature on LCD
  lcd.setCursor(0,0);
  lcd.print("Temperature-");
  lcd.setCursor(0,1);
  lcd.print(tempF);
  lcd.println(" degrees F ");
  delay(10);// print data every 10milliseconds

  if (tempF >= 78.0)
  {
    digitalWrite(relay, HIGH);
  }
}


texts: Expand Arduino storage without an SD card

texts:
I'd like to have my Arduino write some files and store them somewhere. They won't be big files, but the 1Mb available on the device won't be enough.
I know an SD card is the popular solution, but the smallest SD card here is a little expensive, and more than enough, I mean, I could get by with around 10mb (or even less than that), so it would be wasteful to add a 1gb SD card (or a 512mb, 256 or 128), and it would be expensive too. Is there an intermediate solution?
Some way cheap of adding just a bit more?

Thanks


texts: Error messages while verifying code with Visual Studio Code

texts:
I move recently to use Visual Studio Code to develop for arduino. But I'm receiving some error messages while I'm trying to verify my code that confuse me. The messages are:

2020-04-12T13:53:40.409Z INFO c.a.u.n.HttpConnectionManager:148 [cc.arduino.packages.discoverers.serial.SerialDiscovery] Connect to https://builder.arduino.cc/builder/v1/boards/0x8087/0x0ACA, method=GET, request id=20892E5EE7E84976
2020-04-12T13:53:40.926Z INFO c.a.u.n.HttpConnectionManager:152 [cc.arduino.packages.discoverers.serial.SerialDiscovery] Request complete URL="https://builder.arduino.cc/builder/v1/boards/0x8087/0x0ACA", method=GET, response code=404, request id=20892E5EE7E84976, headers={null=[HTTP/1.1 404 Not Found], Cache-Control=[no-cache, no-store, must-revalidate], Server=[nginx], Connection=[keep-alive], Vary=[Origin], Pragma=[no-cache], Expires=[0], Content-Length=[0], Date=[Sun, 12 Apr 2020 13:53:41 GMT]}
2020-04-12T13:53:40.926Z WARN p.a.h.BoardCloudResolver:64 [cc.arduino.packages.discoverers.serial.SerialDiscovery] Fail to get the Vid Pid information from the builder response code=404
2020-04-12T13:53:40.937Z INFO c.a.u.n.HttpConnectionManager:148 [cc.arduino.packages.discoverers.serial.SerialDiscovery] Connect to https://builder.arduino.cc/builder/v1/boards/0x8087/0x0ACA, method=GET, request id=D8C082A90BB14CDF
2020-04-12T13:53:41.044Z INFO c.a.u.n.HttpConnectionManager:152 [cc.arduino.packages.discoverers.serial.SerialDiscovery] Request complete URL="https://builder.arduino.cc/builder/v1/boards/0x8087/0x0ACA", method=GET, response code=404, request id=D8C082A90BB14CDF, headers={null=[HTTP/1.1 404 Not Found], Cache-Control=[no-cache, no-store, must-revalidate], Server=[nginx], Connection=[keep-alive], Vary=[Origin], Pragma=[no-cache], Expires=[0], Content-Length=[0], Date=[Sun, 12 Apr 2020 13:53:41 GMT]}
2020-04-12T13:53:41.044Z WARN p.a.h.BoardCloudResolver:64 [cc.arduino.packages.discoverers.serial.SerialDiscovery] Fail to get the Vid Pid information from the builder response code=404

Based on this output it seems something is happening with these URLs but when I try to do the same in the same computer with Arduino IDE there is no such error messages.

Does anybody know how to get rid of these messages?

Thank you very much.


texts:
I have connected a I2C LCD with my NodeMCU v3. My pin configuration is as follows:
Node MCU ---> I2C LCD
GND           GND
3V            VIN
SDA           D2
SCL           D1

I have been testing a rather simple code:
#include <LiquidCrystal_I2C.h>

// set the LCD number of columns and rows
int lcdColumns = 16;
int lcdRows = 2;

// set LCD address, number of columns and rows
// if you don't know your display address, run an I2C scanner sketch
LiquidCrystal_I2C lcd(0x27, lcdColumns, lcdRows);

void setup(){
  // initialize LCD
  lcd.init();
  // turn on LCD backlight
  lcd.backlight();
}

void loop(){
  // set cursor to first column, first row
  lcd.setCursor(0, 0);
  // print message
  lcd.print("Hello, World!");
  delay(1000);
  // clears the display to print new message
  lcd.clear();
  // set cursor to first column, second row
  lcd.setCursor(0, 1);
  lcd.print("Hello, World!");
  delay(1000);
  lcd.clear();
}

But instead of displaying "Hello World" in alternate lines by LCD is displaying scrolling text which seems gibbersih. Can anyone enlighten me in this regard?

Thanks!


texts: Any way to not explicitly include dependent libraries?

texts:
When I am including the Adafruit_BMP280 library, Arduino IDE 1.7.10 complains that it wants all dependent libraries included:

Adafruit_Sensors.h
Wire.h
SPI.h

Isn't it possible to circumvent that? This question says to include the first library like

#include "Adafruit_BMP280"

but also with the full path, this doesn't work and just returns the same error.


texts: Faster TimerOne with Teensy 4.0 (600MHz)

texts:
I have a teensy 4.0 which runs at 600MHz, and is double superscaler (i.e. can execute two instructions per clock cycle, sometimes). I need an interrupt to happen faster than every microsecond. I've calculated that it's possible for the processor to run the my code at that speed with some reasonable overhead. Can TimerOne (or similar) be set to produce an interrupt more than once per microsecond?

Thanks in advance.


texts: Storing in a global variable using inline assembly

texts:
What I'm trying to do is pretty basic: I have a global variable and I'm trying to store some value in it (specifically, the SP_H and SP_L values).

The variable is an array of structs and I'm trying to access one of those structs.

This is what I am doing:

typedef struct_t { uint8_t sp_h, sp_l; } struct_t;

struct_t arr[MAX_STRUCTS];

void some_inline_assembly_function()
{
  volatile asm(

  // Determine where to store the new SP_H and SP_L register

  "lds r26, ???                \n\t" // <-- How do I store the address
                                            of arr[0].sp_h or arr[0].sp_l
                                            in the X registers (r26,27)
  "lds r27, ???                \n\t"

  // This part stores the stack pointer low and high byte indirectly
     using the X registers (r26,27), which is what I want.

  "in    r0, __SP_L__          \n\t"
  "st    x+, r0                \n\t"
  "in    r0, __SP_H__          \n\t"
  "st    x+, r0                \n\t"
  ::);
}

If this looks familiar, it is because it probably is. I'm trying to implement simple context switching (pushing the entire task context into the stack and retrieving another one). What I'm trying to accomplish is storing the current PC_H and PC_L to a global variable so that the "shceduler" knows where to start popping the registers and restore the context.

Yes, I know FreeRTOS does this. I need to know how to do this myself.

Thanks a bunch.


texts: Help understanding code to build circuit for plant reader

texts:
I'm working a design project that measures the tiny changes of conductivity in a plant. (To visualize how a plant reacts to its environment) I'm working with Arduino to realize that. Two wires are hooked up to the plant to measure the changes and are connected to the Arduino. I haven't worked with Arduino before but a friend got me the code from his plant reader (he got help too and doesn't know how to build it anymore). I do understand most of it but I just don't manage to translate the code he gave me into a circuit on the Arduino bread board. I use processing to visualize the measurements afterwards.

Who can help me building the circuit. I don't get what's happening at pin13. Thank you for helping me :)


texts: LED fade with LDR sensor depending on the light

texts:
I need help on a project. I just started to experiment with arduino 2 weeks ago and I am building a lamp that react to movement and interactions.
So the idea is; when there is nobody in the room, the light stay white.
And when there is someone, it turns orange and I want it to « breathe » (fade function).

I am using a LDR sensor to make it happen and so far my code looks like:

int LDRvalue = 1;
int RedLED = 9;
int GreenLED=10;
int BlueLED=11;
int pinLDR = A0;

void setup()
{
pinMode(RedLED, OUTPUT);
pinMode(GreenLED, OUTPUT);
pinMode(BlueLED, OUTPUT);
Serial.begin(9600);

}
void loop()
{
LDRvalue = analogRead(pinLDR);
Serial.print("valeur ldr: ");
Serial.println(LDRvalue);

int colour = map(LDRvalue, 0, 1023, 0, 255);
Serial.print("valeur mappe: ");
Serial.println(colour);

if(LDRvalue >= 1023)
{
analogWrite(RedLED, 255);
analogWrite(GreenLED, 255);
analogWrite(BlueLED, 255);
delay(1000);
}

else if((LDRvalue >= 800) & (LDRvalue < 1023))
{
analogWrite(RedLED, 255);
analogWrite(GreenLED, 255);
analogWrite(BlueLED, 255);
delay(1000);

}

else if((LDRvalue >= 600) & (LDRvalue < 800))
{
analogWrite(RedLED, 255);
analogWrite(GreenLED, 105);
analogWrite(BlueLED, 0);
delay(1000);

}
else if((LDRvalue >= 300) & (LDRvalue < 600))
{
analogWrite(RedLED, 255);
analogWrite(GreenLED, 35);
analogWrite(BlueLED, 0);
delay(1000);
}

else if((LDRvalue >= 150) & (LDRvalue < 300))
{
analogWrite(RedLED, 255);
analogWrite(GreenLED, 15);
analogWrite(BlueLED, 0);
delay(1000);

}

else if((LDRvalue >= 0) & (LDRvalue < 150))
{
analogWrite(RedLED, 255);
analogWrite(GreenLED, 0);
analogWrite(BlueLED, 0);
delay(1000);
}

delay(1);

}
void color(int red, int green, int blue)

{
analogWrite(RedLED, red);
analogWrite(GreenLED, green);
analogWrite(BlueLED, blue);
}

The code is working for the light changes depending on the human presence.
But I don’t know how to make it fade and breathe when it turns orange.

Could you help me to make it happen ?


texts: Is it possible to compile and upload code witout the IDE?

texts:
I just got started with Arduino, and found out that I need the IDE to compile and upload codes, which works perfectly fine. This is my code:
# pragma GCC optimize ("Ofast")

char i = 0 ;
unsigned long time, lastTime ;

void setup() {
    pinMode(LED_BUILTIN, OUTPUT) ;
}

void loop() {
    time = millis() ;

    if (time > lastTime) {
        lastTime = time + 100 ;
        i = ~i ;
        digitalWrite(LED_BUILTIN, i  ? HIGH : LOW) ;
    }
}

But the biggest problem is that the IDE is written in Java and it uses 1 GB of system's memory, and it's very heavy.
So is there a way I can use the Linux command line to compile and upload the code to the Arduino UNO?


texts: Feasibility of a Wi-Fi Positioning System

texts:
In the project of guiding a sight disabled person in a known environment, we need to have a precise way of figuring out where the user is. Our current solution is to use WPS.

This is however our first project with Arduino, and we're not quite sure if we're going the right way about this. We're thinking of getting a compass component and such, but is there something we should know before advancing further in the project?

EDIT: Additional information.
The system is placed on the user, most probably strapped to the arm. The communication to the Wi-Fi beacons will be done from there, as well as the calculations.

The environment is supposed to be as complex as an exposition hall, but we can aim higher.

Budget range is around $100, Arduino itself excluded. A UNO is already provided to us.


texts:
I am sending a packet of sensor information over an Arduino XBee setup. The first byte of the packet is the packet header for synchronization. The second byte is the number of bytes in the packet (excluding header and packet size byte). The first byte of the packet payload is an identifying number for the sensor. The second payload byte is the data from the sensor. The third payload byte is an XOR for simple error checking. The first payload byte for the sensor ID will never need to be escaped, but the other two payload bytes may need to be escaped. The following is code I wrote for sending a single packet:

Serial.write(PACKET_HEADER); // Packet header for synchronization
Serial.write(calculatePacketSize(data, XOR)); // Size of packet
Serial.write(unitInfo);
// Check if the data byte needs to be escaped
if(data == ESCAPE || data == PACKET_HEADER) {
    Serial.write(ESCAPE);
}
Serial.write(data);
// Check if the XOR byte needs to be escaped
if(XOR == ESCAPE || XOR == PACKET_HEADER) {
    Serial.write(ESCAPE);
}
Serial.write(XOR);

What I am unsure about is how to process a packet on the receiving end. One issue I see is that because there are a variable number of payload bytes, I cannot check via Serial.available() whether or not there are enough bytes to process the payload during this run through of loop(). How do I go about processing a packet, and making sure the packet was received error free? I need to just discard incomplete packets or anything without a header.


texts: Ultrasonic,pir,gas mq2 sensor using Arduino in one code?

texts:
I have a three sensors codes but its are separately.
I don't have knowledge of these code merg in single one code


texts: How to choose a transmit pin in the IRremote library for an Arduino Uno?

texts:
I am looking for a way to choose a pin on the Arduino Uno. This pin will be used to send the signal of an IR LED. I am using the IRremote library.

e.g.

Below is the IR send demo which uses pulse width modulation pin 3 to send the IR signal. I want to change that pin to any other pin.

Any pointers will make me very happy thanks.

/*
 * IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
 * An IR LED must be connected to Arduino PWM pin 3.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */

#include <IRremote.h>

IRsend irsend;

void setup()
{
}

void loop() {
    for (int i = 0; i < 3; i++) {
        irsend.sendSony(0xa90, 12);
        delay(40);
    }
    delay(5000); //5 second delay between each signal burst
}


texts:
I am trying to make something like roomba. Everything is going perfect. I want to have an ultrasonic sensor mounted on servo motor which rotate it from 0 deg to 180 deg & from 180 deg to 0 deg and the ultrasonic sensor will detect if there is any obstacles ahead. I want to take distance from the sensor. The servo motor rotates perfectly alone but when i tries to calculates the distance by the sensor which is mounted on it. The servo stops rotating. I have seen such type of systems in many projects like obstacles avoiding cars etc but i am unable to solve this problem. Can anybody tell me what i can do to solve this problem.

The code I am trying:

#include <Servo.h>
#define trigPin 2
#define echoPin 3
long duration;
int distanceCm;
Servo myservo;

int pos = 0;

void setup() {
myservo.attach(9);
myservo.write(0);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);

}

void loop()
{
  for (pos = 0; pos <= 180; pos += 1)
  {
    myservo.write(pos);
    //delay(500);
   int distance = calculate_distance();
    Serial.println(distance);
  }
  delay(100);
  for (pos = 180; pos >= 0; pos -= 1)
  {
    myservo.write(pos);
    //delay(500);
   int distance = calculate_distance();
    Serial.println(distance);
  }
  delay(100);
}

int calculate_distance()
{

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

duration = pulseIn(echoPin, HIGH);
distanceCm = duration*0.034/2;

return distanceCm;

}


texts: Arduino raise the error: `does not name a type` when an Object is used outside of the main two blocks setup and loop

texts:
I have this:

class Person{
public:
    int age;
};

Person p;
p.age;

void setup() { ... }

void loop() { ... }

And I got this error:

Compiling 'MyProgram' for 'Arduino Mega w/ ATmega2560 (Mega 2560)'
MyProgram.ino:18:1: error: 'p' does not name a type
Error compiling

But is I use the Person instance inside setup or loop functions it compiles find.

void setup() {
    // initialize digital pin 13 as an output.
    Person p;
    p.age;
}

I got this:

Compiling 'MyProgram' for 'Arduino Mega w/ ATmega2560 (Mega 2560)'
Binary sketch size: 4,674 bytes (used 2% of a 253,952 byte maximum) (3.45 secs)
Minimum Memory Usage: 428 bytes (5% of a 8192 byte maximum)

What is the different? Why the instance only can be used into the blocks?

I also declared a file with a simple class and then create a instance of it class outside the blocks and I got the same error. If I put the instance inside the blocks it works. So, any tips?


texts: Pass templated function as attachInterrupt parameter

texts:
So I want to do something like this:

template<int PIN, int CHANNEL>
void initPin() {
    attachInterrupt(PIN, rising<PIN, CHANNEL>, RISING);
}

template<int PIN, int CHANNEL>
void rising() {
    startTimes[CHANNEL] = micros();
    attachInterrupt(PIN, falling<PIN, CHANNEL>, FALLING);
}

template<int PIN, int CHANNEL>
void falling() {
    values[CHANNEL] = micros() - startTimes[CHANNEL];
    attachInterrupt(PIN, rising<PIN, CHANNEL>, RISING);
}

but the compiler gives me this error

no matches converting function ‘rising’ to type ‘void (*)()’

Can I even do this, or do I have to write all the functions by myself?


texts:
Hello i want to make an interactive dj booth.
When someone touches the foil the sound appears.
How do i connect the leonardo to a keyboard.press('n')?
And connect the board to foil so when you touches the foil the
n key is pressed?

Thank you!


texts: Arduino UNO with integrated ESP2866 wifi not working correctly

texts:
I bought this "knockoff" Arduino UNO with an integrated ESP 2866 wifi module. But I can't make it work. I've followed this tutorial because it's the same product as I have, but I can't make it work anyway - even blinking with LED doesn't work. Does anyone have experience with this exact (or similar) board with integrated ESP2866? I would be really glad for any help. link to the product. If you need to know anything else, I'll try my best to answer it.
My problem:
The board normally loads into IDE and i can send code to it. But after I do that, I get this:
Executable segment sizes:
IROM   : 228624          - code in flash         (default or ICACHE_FLASH_ATTR)
IRAM   : 26756   / 32768 - code in IRAM          (ICACHE_RAM_ATTR, ISRs...)
DATA   : 1248  )         - initialized variables (global, static) in RAM/HEAP
RODATA : 688   ) / 81920 - constants             (global, static) in RAM/HEAP
BSS    : 24880 )         - zeroed variables      (global, static) in RAM/HEAP
Sketch uses 257316 bytes (24%) of program storage space. Maximum is 1044464 bytes.
Global variables use 26816 bytes (32%) of dynamic memory, leaving 55104 bytes for local variables. Maximum is 81920 bytes.
esptool.py v2.8
Serial port COM6
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 2c:f4:32:44:1f:0b
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 4MB
Erasing flash (this may take a while)...
Chip erase completed successfully in 8.7s
Compressed 261472 bytes to 193136...
Wrote 261472 bytes (193136 compressed) at 0x00000000 in 17.0 seconds (effective 122.9 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

But the LED doesn't blink.


texts: Atmel SAM MCU (on Arduino Due) only boots after second power up

texts:
I am using an Arduino Due as a prototyping board for a microcontroller project. The due has the chip Atmel ATSAM3X8E, with an ARM Cortex-M3 core. I am programming the flash directly using Atmel Studio and SAM-BA over USB, I am not using the arduino tools or bootloader in any way, at least not to my knowledge. I am powering it over the USB port on the arduino.

I am able to program the flash and select flash for boot, but the problem is that the chip never works the first time I plug in the power. But if I cut the power and try again, it boots normally and the program starts. Then if I cut the power and wait a while, I have to power it up another two times before it works. It's like there is some volatile charge or RAM in there that needs to have been powered within the last minute for the chip to boot at power up like it should, but I don't know what. The result is the same if I plug the USB into my computer, or from a phone charger. Also the same whether I use the native or arduino programming USB port to power it.


texts:
I'm using an Arduino Mega which has 4 RX/TX UARTS/serials.
3 RX's of them I use for MIDI In
2 TX's of them I use for MIDI Out (maybe later a DMX out too)

One I use currently for debugging. On the other hand, in the future I want:

Using an ESP8266 WIFI which also seems to use an UART (both RX/TX)

Of course I can remove the debugging RX/TX, but maybe some more additions are needed and for the first RX/TX I need to remove the RX each time I upload (so I rather leave it for debugging).

I was wondering, is it possible to share an UART if I don't use the WIFI module and MIDI port at the same time?


texts: Arduino clients suddenly not able to connect (or publish) to MQTT

texts:
we are struggling with a project that has things (arduinos as clients) communicating to our MQTT broker (mosquitto) running on a DigitalOcean droplet (inside a docker). We have about 200 things at different locations sending about 20msg per minute each. Last week - after months without any issues - 20 clients suddenly were not able to connect to the server/publish anymore although they have been online. Today 4 other clients “went offline” the same second.

The latter 4 clients were fixed by simply restarting them. With the aforementioned 20 clients, we were able to test one (remotely) and we reflashed it (nothing changed with MQTT settings though) and it was then able to connect to the broker again...

First we thought it was a network issue but it all seems to be fine. Can you help us troubleshooting the issue? We run a DigitalOcean droplet for our mqtt server.


texts: How to read .txt file from the internet wirelessly

texts:
I am a complete beginner to Arduino, so I'm asking this moreso to see if a project will be feasible.

My ultimate goal is to have this arduino (whenever powered) check this website "https://services.swpc.noaa.gov/text/aurora-nowcast-map.txt" (every 15 minutes or something). If a specific value in the sort of array of space delimited numbers is above a threshold, it'll turn on an LED.

I want to use some WiFi shield (price is not an issue, I just don't want complicated powering) to have the Arduino read a .txt file from the internet. What will the simplest, most reliable hardware be, and how will I read this data in? An example may be very helpful!!!

I think I can handle the string-to-light part of the code, but am very unfamiliar with the wireless portion. Once I upload the script with the wireless "credentials" onto the Arduino, I would like it to just run whenever there's power/ the credentials change!

Sorry for the long mess, I know the question is a little buried and that there are similar questions, but I'm hoping by providing all the info, somebody might point me to a similar project, or have some advice with the whole project in context.

-Alex


texts: How to eliminate noise from PWM controlled 12V fan at low speed

texts:
I am trying to build a simple fan controller (single fan). So far I have successfully created a circuit which powers the fan with an external 12v DC adapter and added a transistor (NPN) to switch it on and off. The transistor is connected to a PWM port on the Arduino.

When putting HIGH on the port the fan works perfectly at high speed, but when I want to lower the speed (say analogWrite(fanPin, 150)) it starts to make a humming noise. I believe this is caused by the use of PWM.

What is the best way to control the speed of the fan without (too much) noise?

ps. The fan is a Cooler Master 3-wire PC fan. Transistor is a P2N2222A.

Update: Here is the schema I am using:


texts: Arduino std::map returning random values

texts:
I'm working with an arduino UNO. I would like to be able to send it set and get commands over serial and have it update class data class members accordingly by key value pair. I spoke to users in the cpp room, and they suggested I try using map to map every key to value.

command structure
command:key:value

ex. set:key1:20
ex. get:key2

I created a class called Uno, assigned all my keys to private data members, and defined set and get functions. However, I am experiencing unintended behavior.

Unintended behavior
The set function ends up setting key1 and key2 to the same value, and the get function returns a random integer value that wasn't assigned.

  #include <ArduinoSTL.h>
  #include <string.h>
  #include <map>

class Uno{
  //private
    int key1;
    int key2;
    std::map<String, int Uno::*> keys;
  public:
  //Constructor
    Uno(){
      key1 = 0;
      key2 = 0;
      keys["key1"] = &Uno::key1;
      keys["key2"] = &Uno::key2;
    }
    bool setKey(String key, int value){
      if (keys.count(key)) {
          this->*keys[key] = value;
          return true;
      }
      return false;
    }
    int getKey(String key){
      if (keys.count(key)) {
          return this->*keys[key];
      }
    }
};

String inputString = "";      // a String to hold incoming data
bool stringComplete = false;  // whether the string is complete
bool scan = false;            // whether a scan is in progress
Uno myMS;                      // global declaration of Mass Spec Class

void setup() {
  // initialize serial:
  Serial.begin(9600);
  // reserve 250 bytes for the inputString:
  inputString.reserve(250);
}

void loop() {
  if (stringComplete) {
    t(inputString); // tokenize and process string

    //RESET STRING
    inputString = "";
    stringComplete = false;
  }
}

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;
    }
  }
}

void t(String inputString) {
    //get command
    String command = getValue(inputString, ':', 0);

    if(command == "set"){
      // get key, get value
       String key = getValue(inputString, ':', 1);
       int value = (getValue(inputString, ':', 2)).toInt();
       Serial.println(myMS.setKey(key,value));
    }
    else if(command == "get"){
       String key = getValue(inputString, ':', 1);
       int value = myMS.getKey(key);
       Serial.println(value);
    }
    else if(command == "stop"){
       scan = false;
    }
    else if(command == "scan"){
       scan = true;
       while(scan){
//        Serial.println(myMS.scan());
       }
    }
    else{
       Serial.println("not recognized");
    }
}

String getValue(String data, char separator, int index)
{
  int found = 0;
  int strIndex[] = {0, -1};
  int maxIndex = data.length()-1;

  for(int i=0; i<=maxIndex && found<=index; i++){
    if(data.charAt(i)==separator || i==maxIndex){
        found++;
        strIndex[0] = strIndex[1]+1;
        strIndex[1] = (i == maxIndex) ? i+1 : i;
    }
  }
  return found>index ? data.substring(strIndex[0], strIndex[1]) : "";
}

EDIT: Here is a REPL IT working demo of concept provided by nwp.
https://repl.it/repls/AntiqueProductiveMineral

Sample output

set:key1:10 ===> 1 (GOOD)
get:key1 ===> 32512


texts: How can i get rid of the error "cannot convert 'String' to 'const char*'"

texts:
I want to get this code to recognise different commands and be able to parse the rest of the command, fore example I send "/sleep 5", and it will sleep for 5 seconds. However, I keep on getting this error "cannot convert 'String' to 'const char*'". here is my code:

#define maxCommandLength 64

String commands[] = {"/test", "/say", "/reset", "/sleep"};

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("Power on.");
}
char serial[maxCommandLength];
boolean valid;
void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Clearing command buffer(char 'serial'");
  for (byte i = 0; i < maxCommandLength; i++) {//if maxCommandLength is larger that 255, change 'byte i' to 'int i'
    serial[i] = ' ';
  }
  if (Serial.available()) {
    Serial.readBytesUntil(' ', serial, maxCommandLength);
  }
  if (serial[0] == '/') { //if it is a command
    Serial.print("Command recieved. \nCommand class:");
    Serial.println(serial);
    //test if command is valid
    for (byte i = 0; i < maxCommandLength; i++) {//if maxCommandLength is larger that 255, change 'byte i' to 'int i'
      valid = strcmp(serial,commands[i]);
      if(valid){
        break;
      }
    }
    //execution of command
    Serial.readBytesUntil(' ', serial, maxCommandLength);
    //.......
  }
}


texts:
I have three TFMini sensors I need all of them to detect. I only got one to work , pins 4,5 . My info in coding is basic . I really appreciate your help . Thanks in advance.
I think the problem is with Library I can't add TFMini_1.
Here is my code,
#include <SoftwareSerial.h>
#include "TFMini.h"
TFMini tfmini;
TFMini tfmini1;

//Declaring variables and constants
TFMini TFFront;
TFMini TFRight;
TFMini TFLeft;
SoftwareSerial SerialTFMini (4,5);    //(RX, TX)
SoftwareSerial SerialTFMini_1 (6,7);    //(RX, TX)
SoftwareSerial SerialTFMini_2(8,9);     //(RX, TX)

void getTFminiData(int* distance, int* strength) {
  static char i = 0;
  char j = 0;
  int checksum = 0;
  static int rx[9];
  if(SerialTFMini.available())

  {
    // Serial.println( "tfmini serial available" );
    rx[i] = SerialTFMini.read();

    if(rx[0] != 0x59) {
      i = 0;
    } else if(i == 1 && rx[1] != 0x59) {
      i = 0;
    } else if(i == 8) {
      for(j = 0; j < 8; j++) {
        checksum += rx[j];
      }
      if(rx[8] == (checksum % 256)) {
        *distance = rx[2] + rx[3] * 256;
        *strength = rx[4] + rx[5] * 256;
      }
      i = 0;
    } else
    {
      i++;
    }
  }
}

       //Threshold distance in "cm"; speak only when any object is nearer than this distance

void setup()
{

  //Initializing Baud Rates
  Serial.begin (115200);
  while(!Serial);                     //Wait for USB Serial Port to connect
  Serial.println("Initializing...");
  SerialTFMini.begin (TFMINI_BAUDRATE);

  //Initializing TFMini Sensors
tfmini.begin(&SerialTFMini);
}

void loop()
{
   int distance = 0;
  int strength = 0;

  getTFminiData(&distance, &strength);
  while(!distance) {
    getTFminiData(&distance, &strength);
    if(distance) {
      Serial.print(distance);
      Serial.print("cm\t");
      Serial.print("strength: ");
      Serial.println(strength);
    }
   }

delay(100);

}


texts: Is it possible to have an array of int arrays?

texts: I have a huge number of arrays, each with a series of numbers each referring to an LED on a strip. I want to be able to address each one by a number, so the logical solution to that for me was to make the whole thing into an array. Can that be done, or is there a better work around that can be implemented?


texts:
I've got an Arduino UNO REV3 SMD EDITION.

In the Arduino Editor, I've selected Arduino/Genuino Uno.

In a tutorial, I saw Hardware required : Arduino or Genuino Board

What is the difference between Arduino board and Genuino Board?


texts: Programming ATmega328p on external board with FT232R

texts:
I am making a 100W AC-DC linear power supply, for which I want to show output Voltage and Output current on LCD display. I already used shunt resistor and voltage resistor to bring both values to analog pins on my ATmega328P in DIP socket, which has an Arduino bootloader on it. I want to programm my ATmega328P on the board without taking it off everytime and putting it into Arduino UNO board to just programm it and put it back, so how can I integrate a programmer onto board?
I intend to use the FT232R ic, which I think would work more than fine for this application.
On finished product I want to have a USB connector on the case just to update/correct the software.


texts: read data from controller via RS485 Modbus rtu Arduino

texts:
I have a device with an rs485 port from which I would like to read the ph value. Below is the connection with the RS485 adapter.

I tried to read the data with this code but doesn't work:

#include SoftwareSerial.h

#define SSerialRX        10  //Serial Receive pin
#define SSerialTX        11  //Serial Transmit pin
#define SSerialTxControl 3   //RS485 Direction control
#define RS485Transmit    HIGH
#define RS485Receive     LOW
#define Pin13LED         13

SoftwareSerial RS485Serial(SSerialRX, SSerialTX); // RX, TX
byte byteSend;
byte request[] = {0, 0x03, 0, 0, 0, 0x01, 0x85, 0xDB};

void setup()
{
  // Start the built-in serial port, probably to Serial Monitor
  Serial.begin(9600);
  Serial.println("SerialRemote");  // Can be ignored

  pinMode(Pin13LED, OUTPUT);
  pinMode(SSerialTxControl, OUTPUT);

  digitalWrite(SSerialTxControl, RS485Receive);  // Init Transceiver

  RS485Serial.begin(9600);
  delay(2000);
   RS485Serial.write(request, sizeof(request));

   digitalWrite(Pin13LED, LOW);
   delay(10);
   digitalWrite(SSerialTxControl, RS485Receive);

}
void loop()
{

  if (RS485Serial.available())
  {
    byteSend = RS485Serial.read();   // Read the byte
    Serial.print(byteSend, HEX);
    Serial.print(" ");
  }
}

Could you help me?
Thanks


texts: I have a 5m strip of 24v tunable white LEDs and I'm trying to figure out what I need set it up. There's a pad for V+ and then one for brightness and one for warmth. If I plug the V+ in V+ on a 24v supply and the two others to V-, the whole thing lights up full intensity. The strip draws 16 Watts per meter (80 for the whole thing). As I understand it, you vary the two anodes by varying the resistance to ground. I've seen some instructions that this can be done with PWM pins, but I'm assuming that given the voltage and current, no arduino or similar can handle that much. Do I need transistors then? What specs do I look for to understand the limitations?


texts: Arduino Mega + SIM808 GSM + GPS Module + Program Switch ON without pressing Push Button?

texts:
I am new to IOT and tried out integration and a small test code with an Arduino Mega + SIM808 + GSM + GPS Module. It works fine with the SIM808 Library.

My requirement is to put it in an enclosure, but when the power restarts, for some reason we have to manually start the SIM 808 + GPS + GSM Module. Can we control it from code? Can we do a software trigger from Arduino code?

Maybe if we have some pins to connect and trigger the power on. Kindly provide inputs/suggestion for this module.

If you are aware of some module that can be started through code kindly suggest.

Here's one reference I found for a different module with Software Trigger.


texts:
I am trying to connect MFRC522 using nodeMCU and send a simple code to scan the tags but the IDE brings the following error:
Multiple libraries were found for "MFRC522.h"
 Used: /home/georgewayne/snap/arduino/current/Arduino/libraries/MFRC522
 Not used: /home/georgewayne/snap/arduino/current/Arduino/libraries/rfid-master
 Not used: /home/georgewayne/snap/arduino/current/Arduino/libraries/MFRC522-spi-i2c-uart-async
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

What do I do to rectify this error?


texts:
I have a problem with the interworking between Atmel Studio 7 and Arduino IDE 1.6.10.

I recently upgraded from IDE 1.0 to 1.6.10 and I can no longer upload my code to the Arduino. Everything works including compiling and it does recognise my COM3 port. Atmel Studio is configured for no external programmer.

When I compile with the Arduino IDE it does upload the code. My question is what goes wrong here, what do I need to do solve it. Thanks for your help

This the message I have in the end:

Compiling 'GridMonintor_V1R1' for 'Arduino Nano w/ ATmega328' Binary sketch size: 12,268 bytes (used 40% of a 30,720 byte maximum) (22.20 secs)

Minimum Memory Usage: 774 bytes (38% of a 2048 byte maximum) Uploading to I/O board using 'COM3'

avrdude: no programmer has been specified on the command line or the config file
         Specify a programmer using the -c option and try again


texts:
For a school assignment I need to make a LED blink on/of 3 times then stop.
Now I have come up with the following code:

I think it's ''clean'' enough for what it has to do, but I have a feeling that here must be a easier way to make the LED blink 3 times.

Question is: Is there a way to reapeat the part of code 3 times without copy&pasting it?


texts: How might I add a delay, close the servo and go to the start again?

texts:
#include <Servo.h>
Servo myServo;

  const int piezo = A0;
  const int button = 2;
  const int yellow = 3;
  const int green = 4;
  const int red = 5;

  int knockVal;
  int buttonVal;

const int quietKnock = 10;
const int loudKnock = 100;

boolean locked = false;
int numberOfKnocks = 0;

void setup()
{
  myServo.attach(9);
  pinMode(yellow, OUTPUT);
  pinMode(red, OUTPUT);
  pinMode(green, OUTPUT);
  pinMode(button, INPUT);
  Serial.begin(9600);

  digitalWrite(green, HIGH);
  myServo.write(0);
  Serial.println("The box is unlocked!");
}

void loop()
{ //start of loop
  if (locked == false)
  { //start of if1
    buttonVal = digitalRead(button);
    if (buttonVal == HIGH)
    { //Start of if2
      locked = true;
      digitalWrite(green, LOW);
      digitalWrite(red, HIGH);
      myServo.write(90);
      Serial.println("The box is locked!");
      delay (1000);

    }     //end of if2
  }      //end of if1

  if (locked == true)

  { //start of if3

    knockVal = analogRead(piezo);

    if (numberOfKnocks < 3 && knockVal > 0)

    { //start of if4

      if (checkForKnock(knockVal) == true)

      { //start of if5

        numberOfKnocks++;

      }   //send of if5

      Serial.print(3 - numberOfKnocks);
      Serial.println(" more knocks to go");

    }     //end of if4

    if (numberOfKnocks >= 3)

    { //start of if6
      locked = false;

      myServo.write(0);
      delay(20);
      digitalWrite(green, HIGH);
      digitalWrite(red, LOW);
      Serial.println("The box is unlocked!");

    }   //end of if
  }   //end of if3
}           //End of loop

boolean checkForKnock(int value)
{ //start of boolean

  if (value > quietKnock && value < loudKnock)

  { //start of if7

    digitalWrite(yellow, HIGH);
    delay(50);
    digitalWrite(yellow, LOW);
    Serial.print("Valid knock of value ");
    Serial.println(value);
    return true;
  }   //end of if7
  else
  { //start of else
    Serial.print("Bad knock value ");
    Serial.println(value);
    return false;
  }   //end of else
}     // end of boolean


texts: Problems powering standalone arduino with USB powerbank

texts:
I've successfully migrated and ATMEL328P-UP microcontroller from the Arduino Uno Board to a breaboard, following these instructions: https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard. Everything is OK, the bootloader worked and code is already uploaded an running.

The ATMEL is connected to a pair of sensors, and all the system works using 3.3V. And here comes the problem: I'm using a 5V USB power bank to power up everything. When I make this connection:

USB Power Bank @ 5V -> Arduino Uno board (without the microcontroller) -> 3.3 V Output from the board -> ATMEL/Sensors on the breadboard

everything works just fine! Now I decided to replace the Arduino uno board with an LM317 voltage regulator which gives me the 3.3V needed. The connection is this:

USB Power Bank @ 5V -> LM317 with 3.3 V output -> ATMEL/Sensors on the breadboard

and nothing happens! Is as if there wasn't enough current to feed the ATMEL nor the sensors. I've checked the Vcc/GND pins of the sensors and the ATMEL and they're all getting the required 3.3 V, but for some reason the system seems to be OFF.

What could be happening? I'm sure the USB power bank is at full charge, so it should be able to supply enough current. Any suggestions?

Thanks guys!


texts:
#include <Wire.h>
#include <LiquidCrystal.h>
int temp;
const int rs = 13, en = 12, d4 = 11, d5 = 10, d6 = 9, d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
char Nick[15] = {' ', ' ', 'T', 'A', 'R', 'I', 'F', ' ', 'Z', 'I', 'N', 'E', 'D', ' ', ' '};
int butonPin = 2;

void setup() {
  Wire.begin(1);
  Serial.begin(9600);
  pinMode(butonPin,INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(butonPin), Rev, RISING);
  lcd.begin(16, 2);
}

void loop() {
  Wire.onReceive(data);
  lcd.setCursor(2, 1);
  lcd.print(temp);

  if (temp < 25) {
    lcd.setCursor(5, 1);
    lcd.print("NORMAL");
    lcd.print(" ");
    lcd.setCursor(12, 1);
    lcd.print(" ");
  }
  if (temp >= 25 && temp <= 30) {
    lcd.setCursor(5, 1);
    lcd.print("HOT");
    lcd.print(" ");
    lcd.setCursor(11, 1);
    for (int i = 0 ; i < 3 ; i++) {
      lcd.print(" ");
    }
  }
  if (temp > 30) {
    lcd.setCursor(5, 1);
    lcd.print("VERY HOT");
    lcd.print(" ");
  }
  lcd.setCursor(0, 0);
  for (int j = 15; j > 0 ; j--) {
    lcd.print(Nick[j]);
  }
  lcd.setCursor(0, 0);
  delay(70);
  int swap = Nick[15];
  for (int i = 15; i > 0; i--) {
    Nick[i] = Nick[i - 1];
  }
  Nick[0] = swap;
}
void Rev(){
   Wire.onReceive(data);
  lcd.setCursor(2, 0);
  lcd.print(temp);

  if (temp < 25) {
    lcd.setCursor(5, 0);
    lcd.print("NORMAL");
    lcd.print(" ");
    lcd.setCursor(12, 0);
    lcd.print(" ");
  }
  if (temp >= 25 && temp <= 30) {
    lcd.setCursor(5, 0);
    lcd.print("HOT");
    lcd.print(" ");
    lcd.setCursor(11, 0);
    for (int i = 0 ; i < 3 ; i++) {
      lcd.print(" ");
    }
  }
  if (temp > 30) {
    lcd.setCursor(5, 0);
    lcd.print("VERY HOT");
    lcd.print(" ");
  }
  lcd.setCursor(0, 1);
  for (int j = 15; j > 0 ; j--) {
    lcd.print(Nick[j]);
  }
  lcd.setCursor(0, 1);
  delay(70);
  int swap = Nick[15];
  for (int i = 15; i > 0; i--) {
    Nick[i] = Nick[i - 1];
  }
  Nick[0] = swap;
}

void data(int numBytes) {
  while (Wire.available()) {
    temp = Wire.read();
  }
}

In lcd's first line i have scrolling text.
Second line it shows current temperature and data from another master device.
My question is i want to change text line when button pressed and text shouldn't go back to old state it need to be stay in changed line and when the button repressed it change again
In my code when the button pressed several times lcd  gone weird :

I tried swap lines with lcd.setCursor() function :
In loop function :

lcd.setCursor(0, 0);
      for (int j = 15; j > 0 ; j--) {
        lcd.print(Nick[j]);
      }

In reverse function :

lcd.setCursor(0, 1);
  for (int j = 15; j > 0 ; j--) {
    lcd.print(Nick[j]);
  }

Thanks for answers guys


texts: Reading sensor data, massaging it and performing operation based on transformed data

texts:
This is the outline of my project:

interpret environment data (sensor, motor, etc..).
Modify this data into a more usable form,
send it back to the same motor for further operation from modified data.

As an example (this is not the project, but just an example to make sure I am being clear).

A motor moves a conveyor belt with various size flasks on it, some large other small. Depending on the reading of the position of the motor (from encoder) another process (filling the flasks) will take place.  If the first motor encoder data indicated the flask was small then the amount of liquid poured will be small. If large, the amount of liquid dispensed will be large.

More generally, read the location of an item based on motor encoder feedback.  Modify this data. Send this modified data back to a different motor so that it does something specifically as a function of the first motor encoder data.

I am able to send the original encoder feedback to a file, manually massage it and paste it into an Arduino script, compile and have everything work great. I just want to remove the manual steps (cut & paste) and data massaging (I'm looking to an Arduino program to do that).

To further complicate things, I want this process to be part of a distributable package that does not require further compiling. Reading from a sim card is fine.  Also, I am not too price sensitive as the Arduino is a small portion of the total cost of the final product.

I hope someone can give me some insight or pathway to a solution.
All the very best, John.


texts: DFRobot GPS init error [Arduino Uno, SIM808]

texts:
i have problem with initialization DFRobot SIM808 actually when i try to recieve gps data by SoftwareSerial only it does works (i mean examples based on sending and reading command to and from serial's), and recieve data but very long string of data and i need only Latitude and Longitude and i think using DFRobot will be the easiest way to extract the data i need. So the simple test program like this one is not working:

    /*
### Get GPS data
1. This example is used to test SIM808 GPS/GPRS/GSM Shield's reading GPS data.
2. Open the SIM808_GetGPS example or copy these code to your project
3. Download and dial the function switch to Arduino
4. open serial helper
4. Place it outside, waiting for a few minutes and then it will send GPS data to serial

create on 2016/09/23, version: 1.0
by jason

*/
#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>

#define PIN_TX    7
#define PIN_RX    8
SoftwareSerial mySerial(PIN_TX,PIN_RX);
DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,

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

  //******** Initialize sim808 module *************
  while(!sim808.init()) {
      delay(1000);
      Serial.print("Sim808 init error\r\n");
  }

  //************* Turn on the GPS power************
  if( sim808.attachGPS())
      Serial.println("Open the GPS power success");
  else
      Serial.println("Open the GPS power failure");

}

void loop() {
   //************** Get GPS data *******************
   if (sim808.getGPS()) {
    Serial.print(sim808.GPSdata.year);
    Serial.print("/");
    Serial.print(sim808.GPSdata.month);
    Serial.print("/");
    Serial.print(sim808.GPSdata.day);
    Serial.print(" ");
    Serial.print(sim808.GPSdata.hour);
    Serial.print(":");
    Serial.print(sim808.GPSdata.minute);
    Serial.print(":");
    Serial.print(sim808.GPSdata.second);
    Serial.print(":");
    Serial.println(sim808.GPSdata.centisecond);
    Serial.print("latitude :");
    Serial.println(sim808.GPSdata.lat);
    Serial.print("longitude :");
    Serial.println(sim808.GPSdata.lon);
    Serial.print("speed_kph :");
    Serial.println(sim808.GPSdata.speed_kph);
    Serial.print("heading :");
    Serial.println(sim808.GPSdata.heading);
    Serial.println();

    //************* Turn off the GPS power ************
    sim808.detachGPS();
  }

}


texts: How do I erase internal EEPROM on a Arduino Pro Mini

texts:
I'm working on Arduino pro mini.
and I store some data in internal EEPROM.

So, I want to erase certain data from 0x00 to 0x28 address in EEPROM.

void loop()
{
 ...
 ...
 if(erase_eeprom_flag==1)
 {
   addr_uu=0;
          erase_eeprom_flag=0;
          for(kk=0;kk<28;kk++)
          {
              EEPROM.update(addr_uu,0);

              addr_uu=addr_uu+1;

          }
          Serial.println("OK");
          Serial.println(addr_uu,DEC);
          addr_uu=0;
      }
  }

But I got a data like(28 times '0' and other data 'xxx') "0000000000000000000000000000xxxxxxxxxxxx".

ex : 20170519    --->   expected data: 00000519
                        (inappropriate data: 000020170519)

So, here actually push "0" / add at begin operation happen but I want to remove data from those address.

Please tell which Arduino function help me for solving my issue.


texts: How to connect a MPU-6050 to an Arduino that already has a CNC Shield V3 on top of it?

texts:
I have a CNC Shield on top of an Arduino Uno (GRBL pinout) that controls 2 stepper motors through a4988 drivers and it is working like a charm.

Now I want to add an accelerometer to it. From my humble research, the MPU-6050 seems a good pick.

If I purchase stacking headers to lift the CNC shield, can I connect the accelerometer to the unused/reserved A4 and A5 from the Arduino, but power it using CNC's Ground and 5V pins?

I'm open to other approaches if I'm not doing it the proper way.


texts: Playstation module seeming to glitch out

texts: I am not sure if anyone out there is familiar with the PS2X module at all but I am seeming to have a few problems with it. Firstly whenever the square button gets pressed down on by me, all of the other 3 buttons (triangle, circle, and x) all detect that they have been pressed on when I have not actually pressed them down. The second problem is that I am using the 2 analogue joysticks on the PS2 remote to control the motors. The joysticks work by the top area being 0, the middle being 128 and the bottom area being 255. Sometimes for example when the joystick is in the centre the joystick detects 255 for about one tenth of a second (which would be indicating the joystick is downwards when I actually have it in the centre). The remote I am using is a PlayStation 2 wireless remote. The remote dongle is fully wired correctly to the arduino. Here is the link for the PS2X module: https://create.arduino.cc/projecthub/electropeak/how-to-interface-ps2-wireless-controller-w-arduino-a0a813


texts: SIM900 Shield read only sms headers without text

texts:
I enable messages about new SMS

AT+CNMI=2,2,0,0,0

OK

and when received sms, output like this.

+CMT: "+79XXXXXXXXX","1","15/09/23,01:34:03+24"
Test

But when I read message, output only before <CR><LF>
I don't see text of message.

AT+CMGR=1

+CMGR: "REC READ","+79XXXXXXXXX","1","15/09/23,00:34:17+24"

AT+CMGL="ALL"

+CMGL: 1,"REC READ","+79XXXXXXXXX","1","15/09/23,00:34:17+24"
+CMGL: 2,"REC READ","+79XXXXXXXXX","1","15/09/23,01:34:03+24"

I use following  (via SoftwareSerial) code for test this.
SMSGSM.GetSMS and SMSGSM.GetAuthorizedSMS of GSM GPRS GPS Shield Library receive only phone number without sms text.

I use this shield:

AT+GSV

SIMCOM_Ltd
SIMCOM_SIM900
Revision:1137B05SIM900M64_ST_ENHAN


texts: Using chipKIT WiFi Shield with an Arduino

texts:
I'm beginning with Arduino and I have to make two of them communicate via WiFi. I'm going to implement the examples for a WiFi Client and WiFi Server in their tutorials page.

The problem is I only have one Arduino WiFi Shield which is working fine. But I also have a chipKIT WiFi Shield.

My question is: Can I use this other shield to do what I want with one of my Arduinos (I have Uno, Mega and Due) and how? Because I've plugged the shield and I've uploaded the code but it didn't seem to work.


texts: Is it possible to add an additional board on Arduino Web Editor (create.arduino.cc)?

texts:
I'm using a board that can be programmed via Arduino IDE (a NodeMCU with ESP8266) and I've configured the Windows client successfully. I've added an additional board through "Preferences" menu by specifying its configuration url, following manufacturer's directions.

Now, I'm quite happy with the web editor, the one at create.arduino.cc, and I'd like to use it with this board too. Is there any way to configure additional boards?


texts:
I'm using an ESP8266 with the following pin configuration and it doesn't connect to my WiFi. The blue light on the ESP module is on and my LED is on. That's it.

VCC - 3.3v
GND - GND
CH_PD - 3.3v
GPIO 0 - GND
GPIO2 - LED

I'm using a 1,000 mah 3.7 LiPo battery for this.
Here's my Arduino code. I'm following a tutorial from nyl.io.

#include <ESP8266WiFi.h>
#include <ArduinoJson.h>

const char* ssid     = "sukkaa";
const char* password = "123456789123";
const char* host     = "www.sukkzzesp.tk"; // Your domain
String path          = "esp\light.json";
const int pin        = 2;

void setup() {
  pinMode(pin, OUTPUT);
  pinMode(pin, HIGH);
  Serial.begin(115200);
  delay(10);
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  int wifi_ctr = 0;
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("WiFi connected");
  Serial.println("IP address: " + WiFi.localIP());
}

void loop() {
  Serial.print("connecting to ");
  Serial.println(host);
  WiFiClient client;
  const int httpPort = 80;
  if (!client.connect(host, httpPort)) {
    Serial.println("connection failed");
    return;
  }
  client.print(String("GET ") + path + " HTTP/1.1\r\n" +
    "Host: " + host + "\r\n" +
    "Connection: keep-alive\r\n\r\n");
  delay(500); // wait for server to respond
  // read response
  String section="header";
  while(client.available()) {
    String line = client.readStringUntil('\r');
    // we’ll parse the HTML body here
    if (section=="header") { // headers..
      Serial.print(".");
      if (line=="\n") { // skips the empty space at the beginning
        section="json";
      }
    } else if (section=="json") { // print the good stuff
      section="ignore";
      String result = line.substring(1);
      // Parse JSON
      int size = result.length() + 1;
      char json[size];
      result.toCharArray(json, size);
      StaticJsonBuffer<200> jsonBuffer;
      JsonObject& json_parsed = jsonBuffer.parseObject(json);
      if (!json_parsed.success()) {
        Serial.println("parseObject() failed");
        return;
      }
      // Make the decision to turn off or on the LED
      if (strcmp(json_parsed["light"], "on") == 0) {
        digitalWrite(pin, HIGH);
        Serial.println("LED ON");
      } else {
        digitalWrite(pin, LOW);
        Serial.println("led off");
      }
    }
  }
  Serial.print("closing connection. ");
}

Pls help me with this error. Thanks.


texts: Use command line to upload program through hex file to Teensy-LC

texts:
I want to make a standalone programmer for Teensy-LC in windows 8.1.

So basically I have provided the board to a client of mine and now I want to change the program loaded into the Teensy-LC board.

But the solution available right now is to send the Teensy Loader and send the hex file. But the teensy LC board is packed inside a device. So reset button cannot be pressed.

Also it would be better if this code can be burned in an installer format instead of the Teensy Loader.

Is there any way to make this work?

EDIT

My Teensy.exe does not have the option for program or reboot
The icons are not accessible

Does that mean my interrupts are disabled or there might be something else I am doing wrong?
My program loads on pressing the reset button but I cannot press the program button inside Teensy.exe

If I turn off the Auto Mode, all icons go grey.


texts: Are there any pressure sensor for 22 kg (~50lbs) and more?

texts: I'm looking for pressure sensors up to 22 kg and more. So far the highest capacity I could found was 25 lbs. Do higher ones not exist?


texts: Can do I make an Arduino program that can decipher telephone touch tones?

texts:
I have an old land line phone that I want to connect to my Arduino.  Then I would like to write a program that can decipher the touch-tone button presses (which are a combination of two tones) so that the Arduino can react to specific key presses and numeric sequences.  My final goal is to make the Arduino play specific messages when the user enters in codes.  I am really not sure even where to begin.

Thanks for the hardwares fixes for this problem, but if possible, I am looking for a softwares solution.

This will be used to make a telephone (with an attached Arduino) that will play a series of conversations when specific codes are dialed.


texts: Storing Long numbers in arduino like phone numbers...How?

texts:
I am using 20 x 4 LCD And 3 x4 keypad I want to enter and store 3 inputs in different variables the code I am using can store 3 inputs and display it right in serial monitor example I type 5 digits using keypad it will store and display correctly in LCD and serial monitor the right value however if its more than five it has negative output and very far to what inputted. Thank you for help .The code is...

#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
SoftwareSerial mySerial(6,5);
#include <Keypad.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns

char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
byte rowPins[ROWS] = {19, 18, 17, 16}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {15, 14, 13}; //connect to the column pinouts of the keypad

int count=0;
Keypad kpd = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

char entryStr[12];   // This can hold up to 4 digits
int i=0;

void setup()
{
    mySerial.begin(9600);
    Serial.begin(9600);
    lcd.begin(20, 4);
}

void loop(){
    long n1, n2 , n3;

    lcd.setCursor(0,0);
    lcd.print("Enter n1:   ");

    lcd.setCursor(0,1);
    n1 = GetNumber();
    Serial.println ("n1: ");
    Serial.println (n1);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Enter  n2:   ");

    lcd.setCursor(0,1);
    n2= GetNumber();
    Serial.println ("n2: ");
    Serial.println (n2);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Enter n3:   ");
    lcd.setCursor(0,1);
    n3 = GetNumber();
    Serial.println ("n3: ");
    Serial.println (n3);
}

int GetNumber()
{
    long num = 0;
    char key = kpd.getKey();
    while(key != '#')
    {
        switch (key)
        {
            case NO_KEY:
            break;

            case '0': case '1': case '2': case '3': case '4':
            case '5': case '6': case '7': case '8': case '9':
            lcd.print(key);
            num = num * 10 + (key -'0');
            break;

            case '*':
            num = 0;
            lcd.clear();
            break;
        }
        key = kpd.getKey();
    }
    return num;
}


texts: Arduino Hardware serial library with rts/cts flow control support

texts:
Does there exist (any user developed etc.) version of the Hardware UART serial library that has support for RTS/CTS based flow control?
More interested in the Tx side (Arduino sends data, while the peripheral can back-pressure). The library should enable the Arduino to stop transmitting within 1 character of seeing a 'not ready' indication from the peripheral.

Thank you.


texts: Is the DigitalWriteFast library still needed?

texts:
Yesterday I played with a SRAM 621024 SRAM 1 Mbit IC and since I use a lot of pins, digitalReads and digitalWrites are needed including shift registers (see Example

Since it took a long time for reading/writing one byte, I checked for faster ways and found some posts, one of them was using digitalWriteFast:
Library

However, it did not make any difference... is it possible that the (fast) digitalWrite is already implemented in the default Arduino IDE/library?

Update: I found out I made a stupid mistake and the library was not used.

Now I get different values:

Writing 397.880 us per byte
Reading 386.524 us per byte

Without the fast library:

Writing 502.152 us per byte
Reading 483.752 us per byte

Note, there is also a digitalReadFast, but this does not affect the speed.

I did some more testing and found out that a digitalReadFast/digitalWriteFast cost just about 8-12 us, a pinModeFast is 0 us (negligable), however a shiftOut for setting the address cost 120-124 us ... since 3 shifts are needed to set an address, this results in 360-372 us. Subtracting this from the measured times above, writing takes around 25-38 us and reading 15-27us. I possibly can maybe optimize the bit operations a little bit.

However, the end result for using this RAM chip with enough speed is to either change the shift register to a faster one or remove the shift registers at all. This would mean about 30 pins needed for the SRAM only. The conclusion is: better use a 3K256, 23LC1024 or similar variant.

(Note: I tried a ShiftOutFast file), which reduces a shiftout to 36 us but 3 times 36 is still over 100 us, too much to compare to a 3K256/23LC1024 solution.


texts:
I'm trying to experiment with a "return" function. Yet each time I try to run my program, there happens to be an error, like "expected declaration before '}' token."

Can someone explain the basics of a return function, and look at my code below to possibly see what the problem could be?

{
int index;

pinMode(10, INPUT); //button input

int checkInput();

if (digitalRead(10) == 0) {

return 1;
else{

return 0;
 }
}


texts: Managing 2 ultrasonic sensors without blocking the other

texts:
I have an ultrasonic distance sensor. When this sensor is measuring a distance below 25 cm, a second sensor has to be measuring a distance below 5 cm. If not, there should be a one minute timespan, after which a speaker should make noise until the second sensor is measuring a distance below 5 cm.

I am having trouble with this. The first sensor has a lot of code it should be running as well, so using a while-loop to wait out one minute for the other sensor and creating noise after that isn't a possibility.

How do I go about this dilemma? I read into interrupts in Arduino but unfortunately I don't know how I'd make this work.


texts: Why isn't there bus contention on the MISO line during SPI-based programming?

texts:
Consider this image from sparkfun:

Let's say I have this setup, a master and n slaves, plus a programmer connected to the SPI lines.

When I program the master (Arduino), the Arduino is reset. This means that all the data pins go low.

Since SS is active low, all the SS pins on the slaves go active.

I believe this means that all the slaves start driving the same MISO line (blue arrow from slaves to master), either high or low.

Doesn't this result in bus contention on that line? If not, what's the mechanism that prevents bus contention from happening?


texts: Why do we declare constant lat and lon value

texts:
static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;
What does this mean?
https://github.com/mikalhart/TinyGPSPlus/blob/master/examples/FullExample/FullExample.ino
The above link contains the full example program of that line.
This line is from tinygps++ library for extracting the coordinates and displaying in a table format. I'm using arduino uno, GSM module and GPS module to extract the coordinates and transmit it as message. Can anyone explain what dies this constant value mean and why do we use this?


texts: Arduino nano (clone) with ethernet shield only works when I open up serial monitor

texts:
#include <EtherCard.h>

static byte mymac[] = { 0x7A,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[500];
static uint32_t timer;

const char website[] PROGMEM = "x0201g2.cloudapp.net";

static void my_callback (byte status, word off, word len) {
  delay(1000);
}

void setup () {

  Serial.begin(57600);
  ether.begin(sizeof Ethernet::buffer, mymac, 10);

  ether.dhcpSetup();

  ether.dnsLookup(website);
}

void loop () {

  ether.packetLoop(ether.packetReceive());

  if (millis() > timer) {
    timer = millis() + 5000;
    ether.browseUrl(PSTR("/foo/"), "bar", website, my_callback);
  }
}

The way I tested this is I open up SSH terminal for x0201g2.cloudapp.net to monitor any incoming traffic.

The result is that it works fine, when I have the "serial monitor" (in Arduino IDE) open. I would see that there's a consistent stream of GET requests.

However, when I do not have the serial monitor open nothing ever happen.

Initially I had some Serial println to show response status and IP address, so I thought it might be related to the fact that the MCU's serial  controller is waiting for a handshake or some sort of ACK/NACK to happen...if that make sense.

However, that was not the case now because even after I have removed all serial print statements it is behaving in exactly the same way (except that my monitor will show up blank, but I still need to bring it up for it to work).


texts:
I was programing the arduino and things were going great.
Then I plugged in another chip, and went to burn a boot loader.
(New chips) now, I get:

avrdude: usbdev_open(): did not find any USB device "usb"

when I try to upload code to old chips, I get:

avrdude: usbdev_open(): did not find any USB device "usb"

ten times.
I have tried reseting, and it doesnt do anything.
when I plug the device in,

dmesg shows that the device responds to my PC

[526199.130716] usb 3-1: new full-speed USB device number 7 using xhci_hcd
[526199.149422] usb 3-1: New USB device found, idVendor=2341, idProduct=0043
[526199.149427] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=220
[526199.149430] usb 3-1: Manufacturer: Arduino (www.arduino.cc)
[526199.149433] usb 3-1: SerialNumber: 649343332353518022F0
[526199.149579] usb 3-1: ep 0x82 - rounding interval to 1024 microframes, ep desc says 2040 microframes
[526199.149766] cdc_acm 3-1:1.0: ttyACM0: USB ACM device

IDE settings:
board: Audruino Uno
serial posrt /dev/ttyACM0
Programer: AVRISP mkII

I also tried AVR ISP

in the command line, I tried:

   avr-gcc -DF_CPU=16000000UL -mmcu=atmega328 -o Balls.out Balls.c
   avr-objcopy -O ihex -R .eeprom Balls.out  Balls.hex
   sudo avrdude -V -F -c stk500v1 -p m328 -b 19200 -P /dev/ttyACM0 -U flash:w:Balls.hex

each time, I get:

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

How can I troubleshoot the Arduino Uno?
Is this thing broken?


texts: List of sketches disappears off the bottom of my screen

texts:
v 2:1.0.5

The list of sketches disappears off the bottom of my screen and there is no scroll to reach them. This renders the IDE nearly useless.

Is there a solution?


texts:
I'm just reading through a header files for task code in ESP8266 SDK.
I found this line and wondering what does the word PRIVILEGED_FUNCTION after the function arguments braces means ?
void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;

PRIVILEGED_FUNCTION is defined here, but why it's used after the function braces ?
/* Ensure API functions go in the privileged execution section. */
#define PRIVILEGED_FUNCTION __attribute__((section("privileged_functions")))
#define PRIVILEGED_DATA __attribute__((section("privileged_data")))


texts: how many processor cycles/time does it minimaly take to transmit 1 Byte via Serial?

texts:
My understanding has been that the Serial transmission is indeed done (on the Arduino Uno) via the pins named TX->1 and RX<-0?
With this I assume that the Atmega has a machine code that would allow in 1 or processor cycles (125 or 62.5 ns) to set a byte (i.e. Port byte DDRD) as to forward exactly one bit of information for further processing to the ATmega16U2 "serial to USB" chip?

If this is true I would expect that 1 Byte = being 8 bits would require a discouragingly slow 8 to 12 cpu cycles (500ns to 1us)? Is this true?


texts: How do I interface two Arduino boards so they act as one with double the code space?

texts:
Can I connect two ARDUINO UNO circuit boards in serial to increase room for more code and more functionality. For instance I wish to connect six sensors to a board. I need code for all six sensors and there is not enough space on one board. If I connect two circuit boards in serial will that provide the space and functionality to run the code for all six sensors.
If not how is this accomplished? I am a beginner with ARDUINO and I have been assigned a big task to make the ARDUINO UNO circuit boards provide six different functions using sensors such as temperature, pressure, humidity, voltage, current and possibly other functions. I am new at this.